./components/ogre/AttributeObserver.cpp

       1  //
          // C++ Implementation: AttributeObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "AttributeObserver.h"
          #include <Eris/Entity.h>
          #include "services/logging/LoggingService.h"
          
          namespace EmberOgre {
          
      33  AttributeObserver::AttributeObserver(  Eris::Entity* entity,   const std::string& attributeName )
          : mSlot(  sigc::mem_fun(  *this,   &AttributeObserver::attributeChanged ) )
          {
           if (  entity ) {
           entity->observe(  attributeName,   mSlot );
           } else {
           S_LOG_WARNING(  "Tried to observer the attribute " << attributeName << " or a null entity." );
           }
          }
          
      43  AttributeObserver::~AttributeObserver(   )
          {
           mSlot.disconnect(   );
          }
          
      48  void AttributeObserver::attributeChanged(  const Atlas::Message::Element& attributeValue )
          {
           EventChanged.emit(  attributeValue );
          }
          
          
          }

./components/ogre/AttributeObserver.h

       1  //
          // C++ Interface: AttributeObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREATTRIBUTEOBSERVER_H
          #define EMBEROGREATTRIBUTEOBSERVER_H
          
          #include <sigc++/trackable.h>
          #include <Eris/Entity.h>
          
          
          namespace Eris {
      31  class Entity;
          }
          
          namespace EmberOgre {
          
          /**
           Observes changes to a specific attribute and emits a signal.
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      40  class AttributeObserver : public sigc::trackable
          {
          public:
          
      44   AttributeObserver(  Eris::Entity* entity,   const std::string& attributeName );
      45   ~AttributeObserver(   );
          
      47   sigc::signal<void,   const Atlas::Message::Element&> EventChanged;
          
          protected:
      50   Eris::Entity::AttrChangedSlot mSlot;
          
      52   void attributeChanged(  const Atlas::Message::Element& attributeValue );
          };
          
          }
          
          #endif

./components/ogre/Avatar.cpp

       1  /*
           Avatar.cpp by Erik Hjortsberg
           Copyright (  C ) 2002 Miguel Guzman,   Erik Hjortsberg & The Worldforge
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          
          #include "Avatar.h"
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          #include <typeinfo>
          
          
          #include "services/EmberServices.h"
          #include "services/server/ServerService.h"
          #include "services/config/ConfigService.h"
          // #include "services/sound/SoundService.h"
          
          
          #include "EmberEntity.h"
          #include "EmberPhysicalEntity.h"
          #include "AvatarController.h"
          #include "AvatarCamera.h"
          
          #include "AvatarEmberEntity.h"
          #include "model/Model.h"
          #include "model/SubModel.h"
          #include "EmberOgre.h"
          #include "MathConverter.h"
          #include "input/Input.h"
          
          #include <Eris/Avatar.h>
          #include <Eris/Connection.h>
          #include <Eris/TypeInfo.h>
          
          namespace EmberOgre {
          
          
      54  Avatar::Avatar(   )
          : mErisAvatarEntity(  0 ),   mHasChangedLocation(  false )
          {
           mTimeSinceLastServerMessage = 0;
           setMinIntervalOfRotationChanges(  1000 ); //milliseconds
           mAccumulatedHorizontalRotation = 0;
           mThresholdDegreesOfYawForAvatarRotation = 100;
          
          
           ///these are the defaults,   but if anything is set in the config file that will override these values as updateFromConfig is called
           mWalkSpeed = 2.47;
           mRunSpeed = 5; ///5 seems to be the max speed in cyphesis
          
          
           /// Create the Avatar tree of nodes,   with a base entity
           /// and attach all the needed cameras
          
           createAvatar(   );
          
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          
           Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->EventChangedConfigItem.connect(  sigc::mem_fun(  *this,   &Avatar::ConfigService_EventChangedConfigItem ) );
          
           ///update values from the config
           updateFromConfig(   );
          
          }
          
      82  Avatar::~Avatar(   )
          {
          
          }
          
      87  void Avatar::setMinIntervalOfRotationChanges(  Ogre::Real milliseconds )
          {
           mMinIntervalOfRotationChanges = milliseconds;
          }
          
      92  void Avatar::createAvatar(   )
          {
           // The avatar itself
           mAvatarNode = static_cast<Ogre::SceneNode*>(  EmberOgre::getSingleton(   ).getSceneManager(   )->getRootSceneNode(   )->createChild(   ) );
           mAvatarNode->setPosition(  Ogre::Vector3(  0,  0,  0 ) );
           //mAvatarNode->setOrientation(  0,  1,  0,  0 );
           //mAvatarNode->setScale(  Ogre::Vector3(  0.01,  0.01,  0.01 ) );
          
          /* // Model Node and Entity for display
           // TODO: do also the scaling here! That way the other nodes can be positioned in their real places
           mAvatarModelNode = static_cast<Ogre::SceneNode*>(  mAvatarNode->createChild(  "AvatarModelNode" ) );
          
           Model* model = new Model(  "AvatarEntity" );
           model->create(  "settler" );
          
          // Model* model = Model::Create(  "spider.modeldef.xml",   "AvatarEntity" );
           //Model::Create(  "malebuilder.modeldef.xml",   "AvatarEntity1" );
          
          
           mAvatarModel = model;
          
           mAvatarModelNode->attachObject(  mAvatarModel );
           mAvatarModelNode->rotate(  Ogre::Vector3::UNIT_Y,  (  Ogre::Degree )90 );*/
          
          
          /* Ogre::Light* light = mSceneMgr->createLight(  "AvatarLight__" );
           light->setType(  Ogre::Light::LT_POINT );
           light->setCastShadows(  true );
           light->setDiffuseColour(  0.6,  0.6,  0.6 );
           //light->setSpecularColour(  1,   1,   1 );
           light->setAttenuation(  50,  1,  0.0005,  0 );
           mAvatarModelNode->attachObject(  light );*/
          //
          // mAvatarModelNode->showBoundingBox(  true );
          
          }
          
     129  bool Avatar::frameStarted(  const Ogre::FrameEvent & event )
          {
          
           if (  mEntitiesToBeAddedToInventory.size(   ) > 0 ) {
           std::set<Eris::Entity*>::iterator I = mEntitiesToBeAddedToInventory.begin(   );
           std::set<Eris::Entity*>::iterator I_end = mEntitiesToBeAddedToInventory.end(   );
          
           for (  ; I != I_end; ++I ) {
           //no need to do dynamic cast here
           EmberEntity* emberEntity = static_cast<EmberEntity*>(  *I );
           EventAddedEntityToInventory.emit(  emberEntity );
           }
          
           mEntitiesToBeAddedToInventory.clear(   );
           }
          
          
          /* if (  mEntitiesToBeRemovedFromInventory.size(   ) > 0 ) {
           std::set<Eris::Entity*>::iterator J = mEntitiesToBeRemovedFromInventory.begin(   );
           std::set<Eris::Entity*>::iterator J_end = mEntitiesToBeRemovedFromInventory.end(   );
          
           for (  ; J != J_end; ++J ) {
           EmberEntity* emberEntity = dynamic_cast<EmberEntity*>(  *J );
           if (  emberEntity )
           EventRemovedEntityFromInventory.emit(  emberEntity );
           }
          
           mEntitiesToBeRemovedFromInventory.clear(   );
           }*/
           return true;
          }
          
          
          
     163  void Avatar::updateFrame(  AvatarControllerMovement& movement )
          {
          
           ///for now we'll just rotate without notifying the server
           ///except when moving!
           attemptRotate(  movement );
          
          
           ///this next method will however send send stuff to the server
           attemptMove(  movement );
          
           ///only adjust if there is actual movement. If we adjust when there's only rotation we'll get a strange jerky effect (  some bug I guess )
           if (  movement.isMoving ) {
           adjustAvatarToNewPosition(  &movement );
           }
          
          }
          
     181  void Avatar::attemptMove(  AvatarControllerMovement& movement )
          {
           Ogre::Vector3 move = movement.movementDirection;
           bool isRunning = movement.mode == AvatarMovementMode::MM_RUN;
           Ogre::Real timeSlice = movement.timeSlice;
           float speed = isRunning ? mRunSpeed : mWalkSpeed;
           Ogre::Vector3 rawVelocity = move * speed;
          
          
           ///first we'll register the current state in newMovementState and compare to mCurrentMovementState
           ///that way we'll only send stuff to the server if our movement changes
           AvatarMovementState newMovementState;
           newMovementState.orientation = mAvatarNode->getOrientation(   );
           newMovementState.velocity = rawVelocity;// * newMovementState.orientation.xAxis(   );
          
           if (  move != Ogre::Vector3::ZERO ) {
           newMovementState.isMoving = true;
           newMovementState.isRunning = isRunning;
           } else {
           newMovementState.isMoving = false;
           newMovementState.isRunning = false;
           }
           bool sendToServer = false;
          
           //first we check if we are already moving
           if (  !mCurrentMovementState.isMoving ) {
           //we are not moving. Should we start to move?
           if (  newMovementState.isMoving ) {
           //we'll start moving
           //let's send the movement command to the server
           sendToServer = true;
          
           } else if (  !(  newMovementState.orientation == mMovementStateAtLastServerMessage.orientation ) ) {
           //we have rotated since last server update
           //let's see if it's ok to send server message
           //if not we have to wait some more frames until we'll send an update
           if (  isOkayToSendRotationMovementChangeToServer(   ) ) {
           sendToServer = true;
           }
           }
           } else {
           //we are already moving
           //let's see if we've changed speed or direction or even stopped
           if (  !newMovementState.isMoving ) {
           S_LOG_VERBOSE(   "Avatar stopped moving." );
           //we have stopped; we must alert the server
           sendToServer = true;
           } else if (  newMovementState.velocity != mCurrentMovementState.velocity || !(  newMovementState.orientation == mCurrentMovementState.orientation ) ){
           //either the speed or the direction has changed
           sendToServer = true;
           }
           }
          
          
           if (  sendToServer ) {
           S_LOG_VERBOSE(  "Sending move op to server." );
           mMovementStateAtBeginningOfMovement = newMovementState;
           mMovementStateAtLastServerMessage = newMovementState;
           mTimeSinceLastServerMessage = 0;
          
          
           //for now we'll only send velocity
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->moveInDirection(  Ogre2Atlas_Vector3(  newMovementState.orientation * newMovementState.velocity ),   Ogre2Atlas(  newMovementState.orientation ) );
          
          // Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->moveInDirection(  Ogre2Atlas(  mCurrentMovementState.velocity ),   Ogre2Atlas(  mCurrentMovementState.orientation ) );
          
           } else {
           mTimeSinceLastServerMessage += timeSlice * 1000;
           }
          
           if (  newMovementState.isMoving ) {
           //do the actual movement of the avatar node
           mAvatarNode->translate(  mAvatarNode->getOrientation(   ) * (  rawVelocity * timeSlice ) );
           }
           mCurrentMovementState = newMovementState;
          
          }
          
     259  void Avatar::adjustAvatarToNewPosition(  AvatarControllerMovement* movement )
          {
           ///allow the eris entity to adjust to the containing node
           if (  mErisAvatarEntity ) {
           mErisAvatarEntity->adjustPosition(   );
           }
          // MotionManager::getSingleton(   ).adjustHeightPositionForNode(  mAvatarNode );
          }
          
          
     269  void Avatar::attemptJump(   ) {}
          
          
     272  void Avatar::attemptRotate(  AvatarControllerMovement& movement )
          {
           //TODO: remove the direct references to AvatarCamera
          /* float degHoriz = movement.rotationDegHoriz;
           float degVert = movement.rotationDegVert;
           Ogre::Real timeSlice = movement.timeSlice;*/
          
          // mAccumulatedHorizontalRotation += (  degHoriz * timeSlice );
          
           //if we're moving we must sync the rotation with messages sent to the server
           if (  !movement.isMoving && fabs(  getAvatarCamera(   )->getYaw(   ).valueDegrees(   ) ) > mThresholdDegreesOfYawForAvatarRotation ) {
          // mAvatarNode->setOrientation(  movement.cameraOrientation );
           mAvatarNode->rotate(  Ogre::Vector3::UNIT_Y,  getAvatarCamera(   )->getYaw(   ) );
           Ogre::Degree yaw = getAvatarCamera(   )->getYaw(   );
           getAvatarCamera(   )->yaw(  -yaw );
          // mAccumulatedHorizontalRotation = 0;
           } else if (  isOkayToSendRotationMovementChangeToServer(   ) && (  getAvatarCamera(   )->getYaw(   ).valueDegrees(   ) ) ) {
           // rotate the Avatar Node only in X position (  no vertical rotation )
          // mAvatarNode->setOrientation(  movement.cameraOrientation );
           mAvatarNode->rotate(  Ogre::Vector3::UNIT_Y,  getAvatarCamera(   )->getYaw(   ) );
           Ogre::Degree yaw = getAvatarCamera(   )->getYaw(   );
           getAvatarCamera(   )->yaw(  -yaw );
          
          // mAvatarNode->rotate(  Ogre::Vector3::UNIT_Y,  mAccumulatedHorizontalRotation );
          // mAccumulatedHorizontalRotation = 0;
           }
          
          }
          
     301  bool Avatar::isOkayToSendRotationMovementChangeToServer(   )
          {
           return mTimeSinceLastServerMessage > mMinIntervalOfRotationChanges;
          
          }
          
     307  AvatarCamera* Avatar::getAvatarCamera(   ) const
          {
           return mAvatarController->getAvatarCamera(   );
          }
          
     312  AvatarEmberEntity* Avatar::getAvatarEmberEntity(   )
          {
           return mErisAvatarEntity;
          }
          
          
     318  void Avatar::setAvatarController(  AvatarController* avatarController )
          {
           mAvatarController = avatarController;
          }
          
     323  void Avatar::movedInWorld(   )
          {
           ///only snap the avatar to the postiion and orientation sent from the server if we're not moving or if we're not recently changed location
           ///The main reason when moving is that we don't want to have the avatar snapping back in the case of lag
           ///However,   if we've just recently changed location,   we need to also update the orientation to work with the new location.
           if (  !mCurrentMovementState.isMoving || mHasChangedLocation )
           {
           mAvatarNode->setPosition(  Atlas2Ogre(  mErisAvatarEntity->getPosition(   ) ) );
           const WFMath::Quaternion& orient = mErisAvatarEntity->getOrientation(   );
           mAvatarNode->setOrientation(  Atlas2Ogre(  orient ) );
           ///we must set this,   else ember will think that we've rotated the avatar ourselves and try to send an update to the server
           mMovementStateAtLastServerMessage.orientation = mAvatarNode->getOrientation(   );
           mHasChangedLocation = false;
           }
          
          /*
           Ember::SoundService* mySoundService = Ember::EmberServices::getSingleton(   ).getSoundService(   );
           {
           mySoundService->updateAvatarSourcePosition(  
           mErisAvatarEntity->getPosition(   ),  
           mErisAvatarEntity>getOrientation(   ) );
           mySoundService->playAvatarSound(   );
           }
          */
          }
          
     349  void Avatar::avatar_LocationChanged(  Eris::Entity* entity )
          {
           ///if we've changed location,   we need to update the orientation. This is done on the next onMoved event,   which is why we must honour the updated values on next onMoved event,   even though we might be moving.
           mHasChangedLocation = true;
          }
          
          
     356  void Avatar::createdAvatarEmberEntity(  AvatarEmberEntity *emberEntity )
          {
           Ogre::SceneNode* oldAvatar = mAvatarNode;
          
           ///check if the user is of type "creator" and thus an admin
           Eris::TypeService* typeService = emberEntity->getErisAvatar(   )->getConnection(   )->getTypeService(   );
           if (  emberEntity->getType(   )->isA(  typeService->getTypeByName(  "creator" ) ) ) {
           mIsAdmin = true;
           } else {
           mIsAdmin = false;
           }
          
           //mAvatarNode->getParent(   )->removeChild(  mAvatarNode->getName(   ) );
          
           //HACK!!! DEBUG!!
           //mAvatarNode->getParent(   )->removeChild(  mAvatarNode->getName(   ) );
           //EmberEntity->getSceneNode(   )->addChild(  mAvatarNode );
          // mSceneMgr->getRootSceneNode(   )->addChild(  mAvatarNode );
           //HACK!!! DEBUG!!
          
           mAvatarNode = emberEntity->getSceneNode(   );
           mAvatarModel = emberEntity->getModel(   );
          
           mErisAvatarEntity = emberEntity;
           emberEntity->setAvatar(  this );
          
          
          
           mAvatarController->createAvatarCameras(  emberEntity->getSceneNode(   ) );
          
           EmberOgre::getSingleton(   ).getSceneManager(   )->destroySceneNode(  oldAvatar->getName(   ) );
           Input::getSingleton(   ).setMovementModeEnabled(  true );
          
           mErisAvatarEntity->LocationChanged.connect(  sigc::mem_fun(  *this,   &Avatar::avatar_LocationChanged ) );
          
          }
          
     393  void Avatar::ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key )
          {
           if (  section == "general" ) {
           if (  key == "avatarrotationupdatefrequency"  ) {
           updateFromConfig(   );
           }
           } else if (  section == "input" ) {
           if (  key == "walkspeed"  ) {
           updateFromConfig(   );
           }
           } else if (  section == "input" ) {
           if (  key == "runspeed"  ) {
           updateFromConfig(   );
           }
           }
          }
          
     410  void Avatar::updateFromConfig(   )
          {
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "general",   "avatarrotationupdatefrequency" ) ) {
           double frequency = static_cast<double>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "general",   "avatarrotationupdatefrequency" ) );
           setMinIntervalOfRotationChanges(  static_cast<Ogre::Real>(  frequency ) );
           }
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "input",   "walkspeed" ) ) {
           mWalkSpeed = static_cast<double>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "input",   "walkspeed" ) );
           }
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "input",   "runspeed" ) ) {
           mRunSpeed = static_cast<double>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "input",   "runspeed" ) );
           }
          
          }
          
          
          // void Avatar::touch(  EmberEntity* entity )
          // {
          // Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->touch(  entity );
          // }
          
          /*
          Ogre::Camera* Avatar::getCamera(   ) const
          {
           return mAvatarController->getCamera(   );
          }
          */
          }
          
          

./components/ogre/Avatar.h

       1  /*
           Avatar.h by Miguel Guzman (  Aglanor )
           Copyright (  C ) 2002 Miguel Guzman & The Viewforge Project
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef AVATAR_H
          #define AVATAR_H
          #include "EmberOgrePrerequisites.h"
          
          #include <sigc++/trackable.h>
          #include <sigc++/signal.h>
          
          
          #include "framework/Singleton.h"
          
          namespace Eris {
      32   class Entity;
          }
          
          
          namespace EmberOgre {
          
          namespace Model {
      39   class Model;
          }
          
          class EmberEntity;
      43  class AvatarCamera;
      44  class AvatarController;
      45  class AvatarEmberEntity;
          struct AvatarControllerMovement;
          
          struct AvatarMovementState
          {
          public:
           bool isMoving;
           bool isRunning;
           Ogre::Vector3 velocity;
           Ogre::Quaternion orientation;
          };
          
          /**
           * This class holds the Avatar. In general it recieves instructions from mainly
           * AvatarController to attempt to move or rotate the avatar. After checking
           * with the world rules if such a thing is allowed,   the world node is manipulated.
           * If it's a movement it has to be animated.
           *
           */
      64  class Avatar :
      65  public sigc::trackable,  
      66  public Ogre::FrameListener
          {
      68   friend class AvatarController;
      69   friend class AvatarEmberEntity;
          
           public:
          
      73   Avatar(   );
      74   virtual ~Avatar(   );
          
          
           /**
           * Gets the avatar camera.
           * @return
           */
      81   AvatarCamera* getAvatarCamera(   ) const;
          
           /**
           * Gets the scene node which the avatar is attached to.
           * @return
           */
      87   inline Ogre::SceneNode* getAvatarSceneNode(   ) const;
          
           /**
           * Called each frame.
           * @param event
           * @return
           */
      94   virtual bool frameStarted(  const Ogre::FrameEvent & event );
          
           /**
           * Call this when the Eris::Entity representing the avatar has been created.
           * @param EmberEntity
           */
     100   void createdAvatarEmberEntity(  AvatarEmberEntity *EmberEntity );
          
           /**
           * Call this when the avatar entity has moved in the world.
           */
     105   void movedInWorld(   );
          
          
           /**
           * Called each frame.
           * @param movement
           */
     112   void updateFrame(  AvatarControllerMovement& movement );
          
           /**
           * Sets the controller object responsible for controlling the avatar.
           * @param avatarController
           */
     118   void setAvatarController(  AvatarController* avatarController );
          
           /**
           * Access for the Eris::Entity which represents the Avatar.
           * @return
           */
     124   AvatarEmberEntity* getAvatarEmberEntity(   );
          
          
           /**
           * sets the minimum interval to wait before sending new rotation changes to the server
           * this is not done instantly to prevent swamping of data to the server
           * set this lower if you experience too jerky game play
           * @param milliseconds
           */
     133   void setMinIntervalOfRotationChanges(  Ogre::Real milliseconds );
          
           /**
           Emitted when an entity is added to the inventory.
           */
     138   sigc::signal<void,   EmberEntity* > EventAddedEntityToInventory;
          
           /**
           Emitted when an entity is removed from the inventory.
           */
     143   sigc::signal<void,   EmberEntity* > EventRemovedEntityFromInventory;
          
           /**
           True if the current user have admin rights,   i.e. is a "creator".
           */
     148   inline bool isAdmin(   ) const;
          
          protected:
          
           /**
           * adjust the avatar to the new position in the terrain
           * for now this means setting the correct heigth
           * accoring to mercator terrain,   but it will probably
           * be extended to also include stuff as positioning the avatars feet
           * right
           */
     159   void adjustAvatarToNewPosition(  AvatarControllerMovement* movement );
          
           /**
           * This method will determine if it's ok to send a small movement change,   such as
           * a small deviation direction during an already begun movement to the server.
           */
     165   bool isOkayToSendRotationMovementChangeToServer(   );
          
           /**
           Time in milliseconds since we last sent an movement update to the server.
           */
     170   Ogre::Real mTimeSinceLastServerMessage;
          
           /**
           In milliseconds,   the minimum time we must wait between sending updates to the server. Set this higher to avoid spamming the server.
           */
     175   Ogre::Real mMinIntervalOfRotationChanges;
          
           /**
           In degrees the minimum amount of degrees we can yaw the camera until we need to send an update to the server of our new position.
           */
     180   Ogre::Real mThresholdDegreesOfYawForAvatarRotation;
          
           /**
           In degrees the accumulated yaw movement since we last sent an update to the server. If this exceeds mThresholdDegreesOfYawForAvatarRotation we need to send an update to the server.
           */
           float mAccumulatedHorizontalRotation;
          
           /**
           * Attempts to move the avatar in a certain direction
           * Note that depending on what the rules allows (  i.e. collision detection,  
           * character rules etc. ) the outcome of the attempt is uncertain.
           *
           * The parameter timeSlice denotes the slice of time under which the movement
           * shall take place.
           */
     195   void attemptMove(  AvatarControllerMovement& movement );
          
           /**
           * Attempts to rotate the avatar to a certain direction
           * Note that depending on what the rules allows (  i.e. collision detection,  
           * character rules etc. ) the outcome of the attempt is uncertain.
           *
           * When standing still one can rotate how much one want.
           * But when moving,   rotation happens in interval
           *
           */
     206   void attemptRotate(  AvatarControllerMovement& movement );
          
          
           /**
           * Attempts to stop the avatar.
           * This should work in most cases.
           *
           */
     214   void attemptStop(   );
          
           /**
           * Attempt to jump.
           */
     219   void attemptJump(   );
          
          
           /**
           * Creates the avatar. We'll have to extend this functionality later on to
           * allow for different avatars.
           */
     226   void createAvatar(   );
          
          
           /**
           * Creates and sets up the different cameras.
           */
     232   void createAvatarCameras(  Ogre::SceneNode* avatarSceneNode );
          
           /**
           * How many meters per second the avatar can walk.
           * This should be set through some kind of rule checking with the server
           * depending on the character. To be done later.
           */
           float mWalkSpeed;
          
           /**
           * How many meters per second the avatar can run.
           * This should be set through some kind of rule checking with the server
           * depending on the character. To be done later.
           */
           float mRunSpeed;
          
           /**
           * The main avatar model
           */
     251   Model::Model* mAvatarModel;
          
           /**
           * The main avatar scenenode
           */
     256   Ogre::SceneNode* mAvatarNode;
          
          
          
           /** node for rotating the model for the entity
           * if it's not looking in the -Z direction (  default )
           * To be removed once we've standarized on models
           */
     264   Ogre::SceneNode* mAvatarModelNode;
          
           /**
           The Eris::Entity which represents the Avatar.
           */
     269   AvatarEmberEntity* mErisAvatarEntity;
          
           /**
           * this is used to make sure starts and stops of movement is only sent to the server once
           */
           AvatarMovementState mCurrentMovementState;
           AvatarMovementState mMovementStateAtBeginningOfMovement; //this is perhaps not needed
           AvatarMovementState mMovementStateAtLastServerMessage;
          
           /**
           The instance responsible for listening for movement updates and sending those to the server.
           */
     281   AvatarController* mAvatarController;
          
           /**
           Keep a temporary list of entities that needs to be added to the inventory.
           */
     286   std::set<Eris::Entity*> mEntitiesToBeAddedToInventory;
          
           /**
           Keep a temporary list of entities that needs to be removed from the inventory.
           */
     291   std::set<Eris::Entity*> mEntitiesToBeRemovedFromInventory;
          
          
           /**
           * catch changes to the configuration
           * @param section
           * @param key
           */
     299   void ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key );
          
           /**
           * Listen for location changes,   since after a location change we need to honour the onMoved updates even if we're in movement mode.
           * @param entity
           */
     305   void avatar_LocationChanged(  Eris::Entity* entity );
          
           /**
           * updates values from the configuration
           */
     310   void updateFromConfig(   );
          
           /**
           True if the current user have admin rights,   i.e. is a "creator".
           */
     315   bool mIsAdmin;
          
           /**
           If set to true,   the avatar has just changed location,   so the next onMoved operation will contain the new orientation and position information for the new location.
           */
     320   bool mHasChangedLocation;
          
          
          }; //End of class declaration
          
     325  bool Avatar::isAdmin(   ) const
          {
           return mIsAdmin;
          }
     329  Ogre::SceneNode* Avatar::getAvatarSceneNode(   ) const
          {
           return mAvatarNode;
          }
          
          }
          
          #endif // ENTITY_LISTENER_H

./components/ogre/AvatarCamera.cpp

          /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "AvatarCamera.h"
          #include "Avatar.h"
          #include "GUIManager.h"
          #include "EmberOgre.h"
          #include "EmberEntity.h"
          // #include "WorldEmberEntity.h"
          #include "MathConverter.h"
          
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #ifndef WIN32
          #include "services/sound/SoundService.h"
          #endif
          
          #include "MousePicker.h"
          // #include "jesus/JesusPickerObject.h"
          
          #include "SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeRaySceneQuery.h"
          #include "framework/Tokeniser.h"
          #include "framework/ConsoleBackend.h"
          
          #include "GUIManager.h"
          #include "input/Input.h"
          
          #include "IWorldPickListener.h"
          
          #include "framework/osdir.h"
          
          #ifdef __WIN32__
          #include <windows.h>
          #include <direct.h>
          #endif
          
          
          namespace EmberOgre {
          
      56  Recorder::Recorder(   ): mSequence(  0 ),   mAccruedTime(  0.0f ),   mFramesPerSecond(  20.0f )
          {
          }
          
      60  void Recorder::startRecording(   )
          {
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          }
      64  void Recorder::stopRecording(   )
          {
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
          }
          
      69  bool Recorder::frameStarted(  const Ogre::FrameEvent& event )
          {
           mAccruedTime += event.timeSinceLastFrame;
           if (  mAccruedTime >= (  1.0f / mFramesPerSecond ) ) {
           mAccruedTime = 0.0f;
           std::stringstream filename;
           filename << "screenshot_" << mSequence++ << ".tga";
           const std::string dir = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ) + "/recordings/";
           try {
           //make sure the directory exists
          
           struct stat tagStat;
           int ret;
           ret = stat(   dir.c_str(   ),   &tagStat  );
           if (  ret == -1 ) {
           #ifdef __WIN32__
           mkdir(  dir.c_str(   ) );
           #else
           mkdir(  dir.c_str(   ),   S_IRWXU );
           #endif
           }
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when creating directory for screenshots. Message: " << std::string(  ex.what(   ) ) );
           stopRecording(   );
           return true;
           }
           try {
           // take screenshot
           EmberOgre::getSingleton(   ).getRenderWindow(   )->writeContentsToFile(  dir + filename.str(   ) );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "Could not write screenshot to disc. Message: "<< ex.getFullDescription(   ) );
           stopRecording(   );
           return true;
           }
           }
           return true;
          }
          
          
          
     109  AvatarCamera::AvatarCamera(  Ogre::SceneNode* avatarNode,   Ogre::SceneManager* sceneManager,   Ogre::RenderWindow* window,   GUIManager* guiManager,   Ogre::Camera* camera ) :
           SetCameraDistance(  "setcameradistance",   this,   "Set the distance of the camera." ),  
           ToggleRendermode(  "toggle_rendermode",   this,   "Toggle between wireframe and solid render modes." ),  
           ToggleFullscreen(  "toggle_fullscreen",   this,   "Switch between windowed and full screen mode." ),  
           Screenshot(  "screenshot",   this,   "Take a screenshot and write to disk." ),  
           Record(  "+record",   this,   "Record to disk." ),  
           mInvertCamera(  false ),  
           mGUIManager(  guiManager ),  
           mCamera(  camera ),  
           mAvatarNode(  0 ),  
           mSceneManager(  sceneManager ),  
           mDegreeOfPitchPerSecond(  50 ),  
           mDegreeOfYawPerSecond(  50 ),  
           degreePitch(  0 ),  
           degreeYaw(  0 ),  
           mWindow(  window ),  
           mViewPort(  0 ),  
           mClosestPickingDistance(  10000 ),  
           mLastPosition(  Ogre::Vector3::ZERO ),  
           mAdjustTerrainRaySceneQuery(  0 ),  
           mCameraRaySceneQuery(  0 ),  
           mIsAdjustedToTerrain(  true )
          // mLastOrientationOfTheCamera(  avatar->getOrientation(   ) )
          {
           createNodesForCamera(   );
           createViewPort(   );
           setAvatarNode(  avatarNode );
          
           /// Register this as a frame listener
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          
          
           if (  mGUIManager ) {
           mGUIManager->getInput(   ).EventMouseMoved.connect(  sigc::mem_fun(  *this,   &AvatarCamera::Input_MouseMoved ) );
           }
          
           Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->EventChangedConfigItem.connect(  sigc::mem_fun(  *this,   &AvatarCamera::ConfigService_EventChangedConfigItem ) );
          
           updateValuesFromConfig(   );
           createRayQueries(   );
          }
          
          AvatarCamera::~AvatarCamera(   )
          {
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
           EmberOgre::getSingleton(   ).getSceneManager(   )->destroyQuery(  mAdjustTerrainRaySceneQuery );
           EmberOgre::getSingleton(   ).getSceneManager(   )->destroyQuery(  mCameraRaySceneQuery );
          }
          
          void AvatarCamera::createRayQueries(   )
          {
           mAdjustTerrainRaySceneQuery = EmberOgre::getSingletonPtr(   )->getSceneManager(   )->createRayQuery(  mAdjustTerrainRay,   Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK );
           ///only test for terrain
           mAdjustTerrainRaySceneQuery->setWorldFragmentType(  Ogre::SceneQuery::WFT_SINGLE_INTERSECTION );
           mAdjustTerrainRaySceneQuery->setSortByDistance(  true );
           mAdjustTerrainRaySceneQuery->setQueryTypeMask(  Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK );
          
          
           unsigned long queryMask = Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK;
           queryMask |= MousePicker::CM_AVATAR;
           queryMask |= MousePicker::CM_ENTITY;
           queryMask |= MousePicker::CM_NATURE;
           queryMask |= MousePicker::CM_UNDEFINED;
          // queryMask |= Ogre::RSQ_FirstTerrain;
          
           mCameraRaySceneQuery = mSceneManager->createRayQuery(   Ogre::Ray(   ),   queryMask );
           mCameraRaySceneQuery->setWorldFragmentType(  Ogre::SceneQuery::WFT_SINGLE_INTERSECTION );
           mCameraRaySceneQuery->setSortByDistance(  true );
          
          }
          
          
          void AvatarCamera::createNodesForCamera(   )
          {
           mAvatarCameraRootNode = mSceneManager->createSceneNode(  "AvatarCameraRootNode" );
           //we need to adjust for the height of the avatar mesh
           mAvatarCameraRootNode->setPosition(  Ogre::Vector3(  0,  2,  0 ) );
           //rotate to sync with WF world
           mAvatarCameraRootNode->rotate(  Ogre::Vector3::UNIT_Y,  (  Ogre::Degree )-90 );
          
           mAvatarCameraPitchNode = mAvatarCameraRootNode->createChildSceneNode(  "AvatarCameraPitchNode" );
           mAvatarCameraPitchNode->setPosition(  Ogre::Vector3(  0,  0,  0 ) );
           mAvatarCameraNode = mAvatarCameraPitchNode->createChildSceneNode(  "AvatarCameraNode" );
           setCameraDistance(  10 );
          
          // mCamera = mSceneManager->createCamera(  "AvatarCamera" );
           mAvatarCameraNode->attachObject(  mCamera );
           // Look to the Avatar's head
           //mAvatar3pCamera->setAutoTracking(  true,   mAvatar1pCameraNode );
           mCamera->setNearClipDistance(  0.5 );
          
           ///set the far clip distance high to make sure that the sky is completely shown
           if (  Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->hasCapability(  Ogre::RSC_INFINITE_FAR_PLANE ) )
           {
          /* //NOTE: this won't currently work with the sky
           mCamera->setFarClipDistance(  0 );*/
          
           mCamera->setFarClipDistance(  10000 );
           } else {
           mCamera->setFarClipDistance(  10000 );
           }
          
           //create the nodes for the camera
           setMode(  MODE_THIRD_PERSON );
          // createViewPort(   );
          }
          
          void AvatarCamera::setMode(  Mode mode )
          {
           mMode = mode;
          /* if (  mMode == MODE_THIRD_PERSON ) {
           mCamera->setAutoTracking(  true,   mAvatarCameraRootNode );
           } else {
           mCamera->setAutoTracking(  false );
           }*/
          
          
          }
          
          const Ogre::Quaternion& AvatarCamera::getOrientation(  bool onlyHorizontal ) const {
           if (  !onlyHorizontal ) {
           return getCamera(   )->getDerivedOrientation(   );
           } else {
           static Ogre::Quaternion quat;
           quat = getCamera(   )->getDerivedOrientation(   );
           quat.x = 0;
           quat.z = 0;
           return quat;
           }
          }
          
          const Ogre::Vector3& AvatarCamera::getPosition(   ) const
          {
           return mCamera->getDerivedPosition(   );
          }
          
          void AvatarCamera::attach(  Ogre::SceneNode* toNode ) {
           mIsAttached = true;
           assert(  mAvatarCameraRootNode );
           if (  mAvatarCameraRootNode->getParent(   ) ) {
           mAvatarCameraRootNode->getParent(   )->removeChild(  mAvatarCameraRootNode->getName(   ) );
           }
           toNode->addChild(  mAvatarCameraRootNode );
          
           setCameraDistance(  10 );
           mAvatarCameraNode->setOrientation(  Ogre::Quaternion::IDENTITY );
           mAvatarCameraNode->_update(  true,   true );
           std::stringstream ss;
           ss << "Attached camera to node: " << toNode->getName(   ) <<". New position: " << mCamera->getWorldPosition(   ) << " New orientation: " << mCamera->getWorldOrientation(   );
           S_LOG_VERBOSE(  ss.str(   ) );
          }
          
          
          void AvatarCamera::enableCompositor(  const std::string& compositorName,   bool enable )
          {
           if (  std::find(  mLoadedCompositors.begin(   ),   mLoadedCompositors.end(   ),   compositorName ) == mLoadedCompositors.end(   ) ) {
           Ogre::CompositorManager::getSingleton(   ).addCompositor(  mWindow->getViewport(  0 ),   compositorName );
           }
           Ogre::CompositorManager::getSingleton(   ).setCompositorEnabled(  mWindow->getViewport(  0 ),   compositorName,   enable );
          }
          
          void AvatarCamera::createViewPort(   )
          {
          
          // Ogre::CompositorManager::getSingleton(   ).addCompositor(  mWindow->getViewport(  0 ),   "Bloom" );
          // Ogre::CompositorManager::getSingleton(   ).setCompositorEnabled(  mWindow->getViewport(  0 ),   "Bloom",   true );
          
          // assert(  mCamera );
          // assert(  !mViewPort );
          // // Create 1st person viewport,   entire window
          // mViewPort = mWindow->addViewport(  mCamera );
          // mViewPort->setBackgroundColour(  Ogre::ColourValue(  0,  0,  0 ) );
          // mCamera->setAspectRatio(  
          // Ogre::Real(  mViewPort->getActualWidth(   ) ) / Ogre::Real(  mViewPort->getActualHeight(   ) ) );
          
          
          }
          
          
          void AvatarCamera::toggleRenderMode(   )
          {
           S_LOG_INFO(  "Switching render mode." );
           if (  mCamera->getPolygonMode(   ) == Ogre::PM_SOLID ) {
           mCamera->setPolygonMode(  Ogre::PM_WIREFRAME );
           } else {
           mCamera->setPolygonMode(  Ogre::PM_SOLID );
           }
          }
          
          void AvatarCamera::setAvatarNode(  Ogre::SceneNode* sceneNode )
          {
           mAvatarNode = sceneNode;
           attach(  mAvatarNode );
          }
          
          void AvatarCamera::setCameraDistance(  Ogre::Real distance )
          {
           mWantedCameraDistance = distance;
           _setCameraDistance(  distance );
          }
          
          void AvatarCamera::_setCameraDistance(  Ogre::Real distance )
          {
           mCurrentCameraDistance = distance;
           Ogre::Vector3 pos(  0,  0,  distance );
           mAvatarCameraNode->setPosition(  pos );
           EventChangedCameraDistance.emit(  distance );
          }
          
          void AvatarCamera::pitch(  Ogre::Degree degrees )
          {
           if (  mInvertCamera ) {
           degrees -= degrees * 2;
           }
           if (  mMode == MODE_THIRD_PERSON ) {
           degreePitch += degrees;
           mAvatarCameraPitchNode->pitch(  degrees );
           } else {
           mAvatarCameraNode->pitch(  degrees );
           }
          }
          void AvatarCamera::yaw(  Ogre::Degree degrees )
          {
           if (  mMode == MODE_THIRD_PERSON ) {
           degreeYaw += degrees;
           mAvatarCameraRootNode->yaw(  degrees );
          
           mAvatarCameraRootNode->needUpdate(   );
          // Ogre::Quaternion q = mAvatarCameraRootNode->_getDerivedOrientation(   );
           } else {
           mAvatarCameraNode->yaw(  degrees );
           }
          
          }
          
          void AvatarCamera::Input_MouseMoved(  const MouseMotion& motion,   Input::InputMode mode )
          /*(  int xPosition,   int yPosition,   Ogre::Real xRelativeMovement,   Ogre::Real yRelativeMovement,   Ogre::Real timeSinceLastMovement )*/
          {
           if (  mode == Input::IM_MOVEMENT ) {
           Ogre::Degree diffX(  mDegreeOfYawPerSecond * motion.xRelativeMovement );
           Ogre::Degree diffY(  mDegreeOfPitchPerSecond * motion.yRelativeMovement );
          
           if (  diffX.valueDegrees(   ) ) {
           this->yaw(  diffX );
           // this->yaw(  diffX * e->timeSinceLastFrame );
           }
           if (  diffY.valueDegrees(   ) ) {
           this->pitch(  diffY );
           // this->pitch(  diffY * e->timeSinceLastFrame );
           }
          
           if (  diffY.valueDegrees(   ) || diffX.valueDegrees(   ) ) {
           MovedCamera.emit(  mCamera );
           }
           }
          }
          
          
          
          
          void AvatarCamera::pickInWorld(  Ogre::Real mouseX,   Ogre::Real mouseY,   const MousePickerArgs& mousePickerArgs )
          {
           S_LOG_INFO(  "Trying to pick an entity at mouse coords: " << Ogre::StringConverter::toString(  mouseX ) << ":" << Ogre::StringConverter::toString(  mouseY ) << "." );
          
           /// Start a new ray query
           Ogre::Ray cameraRay = getCamera(   )->getCameraToViewportRay(   mouseX,   mouseY  );
          
           mCameraRaySceneQuery->setRay(  cameraRay );
           mCameraRaySceneQuery->execute(   );
          
          
           ///now check the entity picking
           Ogre::RaySceneQueryResult& queryResult = mCameraRaySceneQuery->getLastResults(   );
           bool continuePicking = true;
          
           for (  WorldPickListenersStore::iterator I = mPickListeners.begin(   ); I != mPickListeners.end(   ); ++I ) {
           (  *I )->initializePickingContext(   );
           }
          
          
           Ogre::RaySceneQueryResult::iterator rayIterator = queryResult.begin(    );
           Ogre::RaySceneQueryResult::iterator rayIterator_end = queryResult.end(    );
           if (  rayIterator != rayIterator_end ) {
           for (   ; rayIterator != rayIterator_end && continuePicking; rayIterator++  ) {
           for (  WorldPickListenersStore::iterator I = mPickListeners.begin(   ); I != mPickListeners.end(   ); ++I ) {
           (  *I )->processPickResult(  continuePicking,   *rayIterator,   cameraRay,   mousePickerArgs );
           if (  !continuePicking ) {
           break;
           }
           }
           }
           }
          
           for (  WorldPickListenersStore::iterator I = mPickListeners.begin(   ); I != mPickListeners.end(   ); ++I ) {
           (  *I )->endPickingContext(  mousePickerArgs );
           }
          }
          
           bool AvatarCamera::worldToScreen(  const Ogre::Vector3& worldPos,   Ogre::Vector3& screenPos )
           {
          
           Ogre::Vector3 hcsPosition = mCamera->getProjectionMatrix(   ) * (  mCamera->getViewMatrix(   ) * worldPos );
          
           if (  (  hcsPosition.x < -1.0f ) ||
           (  hcsPosition.x > 1.0f ) ||
           (  hcsPosition.y < -1.0f ) ||
           (  hcsPosition.y > 1.0f ) )
           return false;
          
          
           screenPos.x = (  hcsPosition.x + 1 ) * 0.5;
           screenPos.y = (  -hcsPosition.y + 1 ) * 0.5;
          
           return true;
           }
          
           void AvatarCamera::setClosestPickingDistance(  Ogre::Real distance )
           {
           mClosestPickingDistance = distance;
           }
          
           Ogre::Real AvatarCamera::getClosestPickingDistance(   )
           {
           return mClosestPickingDistance;
           }
          
           bool AvatarCamera::adjustForTerrain(   )
           {
           /// We will shoot a ray from the camera base node to the camera. If it hits anything on the way we know that there's something between the camera and the avatar and we'll position the camera closer to the avatar. Thus we'll avoid having the camera dip below the terrain
           ///For now we'll only check against the terrain
           const Ogre::Vector3 direction(  -mCamera->getDerivedDirection(   ) );
           ///If the direction if pointing straight upwards we'll end up in an infinite loop in the ray query
           if (  direction.z != 0 ) {
          
           mAdjustTerrainRay.setDirection(  direction );
           mAdjustTerrainRay.setOrigin(  mAvatarCameraRootNode->getWorldPosition(   ) );
          
           mAdjustTerrainRaySceneQuery->setRay(  mAdjustTerrainRay );
          
           mAdjustTerrainRaySceneQuery->execute(   );
          
           Ogre::RaySceneQueryResult queryResult = mAdjustTerrainRaySceneQuery->getLastResults(   );
           Ogre::RaySceneQueryResult::iterator rayIterator = queryResult.begin(    );
           for (   ; rayIterator != queryResult.end(   ); ++rayIterator  ) {
           Ogre::RaySceneQueryResultEntry& entry = *rayIterator;
          
           if (  entry.worldFragment ) {
           Ogre::Vector3 position = entry.worldFragment->singleIntersection;
           Ogre::Real distance = mAvatarCameraRootNode->getWorldPosition(   ).distance(  position );
           if (  distance < mWantedCameraDistance ) {
           _setCameraDistance(  distance - 0.1 );
           } else {
           if (  mWantedCameraDistance != mCurrentCameraDistance ) {
           _setCameraDistance(  mWantedCameraDistance );
           }
           }
           break;
           }
           }
           }
          
          /* Ogre::RaySceneQuery *raySceneQueryHeight = EmberOgre::getSingletonPtr(   )->getSceneManager(   )->createRayQuery(   Ogre::Ray(  mCamera->getDerivedPosition(   ),   Ogre::Vector3::NEGATIVE_UNIT_Y ),   Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK );
          
          
           raySceneQueryHeight->execute(   );
          
           //first check the terrain picking
           Ogre::RaySceneQueryResult queryResult = raySceneQueryHeight->getLastResults(   );
          
           if (  queryResult.begin(    ) != queryResult.end(   ) ) {
           Ogre::Vector3 position = queryResult.begin(   )->worldFragment->singleIntersection;
           Ogre::Real terrainHeight = position.y;
           //pad it a little
           //terrainHeight += 0.4;
           Ogre::Real cameraHeight = mCamera->getDerivedPosition(   ).y;
           Ogre::Real cameraNodeHeight = mAvatarCameraNode->getWorldPosition(   ).y;
           if (  terrainHeight > cameraHeight ) {
           mCamera->move(  mCamera->getDerivedOrientation(   ).Inverse(   ) * Ogre::Vector3(  0,  terrainHeight - cameraHeight,  0 ) );
          // mCamera->lookAt(  mAvatarCameraRootNode->getPosition(   ) );
          
           } else if (  cameraHeight != cameraNodeHeight ) {
           Ogre::Real newHeight = std::max<Ogre::Real>(  terrainHeight,   cameraNodeHeight );
           mCamera->move(  Ogre::Vector3(  0,  newHeight - cameraHeight,  0 ) );
           mCamera->lookAt(  mAvatarCameraRootNode->getWorldPosition(   ) );
          
           }
          
           }*/
          
           return true;
           }
          
          void AvatarCamera::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  Screenshot == command ) {
           //just take a screen shot
           takeScreenshot(   );
           } else if(  SetCameraDistance == command )
           {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string distance = tokeniser.nextToken(   );
           if (  distance != "" ) {
           float fDistance = Ogre::StringConverter::parseReal(  distance );
           setCameraDistance(  fDistance );
           }
           } else if (  ToggleFullscreen == command ){
           SDL_WM_ToggleFullScreen(  SDL_GetVideoSurface(   ) );
          
           } else if (  ToggleRendermode == command ) {
           toggleRenderMode(   );
           } else if (  Record == command ) {
           mRecorder.startRecording(   );
           } else if (  Record.getInverseCommand(   ) == command ) {
           mRecorder.stopRecording(   );
           }
          }
          
          void AvatarCamera::updateValuesFromConfig(   )
          {
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "input",   "invertcamera" ) ) {
           mInvertCamera = static_cast<bool>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "input",   "invertcamera" ) );
           }
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "input",   "cameradegreespersecond" ) ) {
           mDegreeOfPitchPerSecond = mDegreeOfYawPerSecond = (  double )Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "input",   "cameradegreespersecond" );
           }
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "input",   "adjusttoterrain" ) ) {
           mIsAdjustedToTerrain = static_cast<bool>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "input",   "adjusttoterrain" ) );
           }
          }
          
          void AvatarCamera::ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key )
          {
           if (  section == "input" ) {
           if (  key == "invertcamera" || key == "cameradegreespersecond" || key == "adjusttoterrain" ) {
           updateValuesFromConfig(   );
           }
           }
          }
          
          bool AvatarCamera::frameStarted(  const Ogre::FrameEvent& event )
          {
           if (  mIsAdjustedToTerrain ) {
           if (  mCamera->getDerivedPosition(   ) != mLastPosition ) {
           adjustForTerrain(   );
           }
           }
           mLastPosition = mCamera->getDerivedPosition(   );
          // #ifndef WIN32
          // Ember::SoundService* mySoundService = Ember::EmberServices::getSingleton(   ).getSoundService(   );
          // {
          // mySoundService->updateListenerPosition(  
          // Ogre2Atlas(  mCamera->getPosition(   ) ),  
          // Ogre2Atlas(  mCamera->getOrientation(   ) ) );
          // }
          // #endif
           return true;
          }
          
          void AvatarCamera::pushWorldPickListener(  IWorldPickListener* worldPickListener )
          {
           mPickListeners.push_front(  worldPickListener );
          }
          
          const std::string AvatarCamera::_takeScreenshot(   )
          {
           // retrieve current time
           time_t rawtime;
           struct tm* timeinfo;
           time(  &rawtime );
           timeinfo = localtime(  &rawtime );
          
           // construct filename string
           // padding with 0 for single-digit values
           std::stringstream filename;
           filename << "screenshot_" << (  (  *timeinfo ).tm_year + 1900 ); // 1900 is year "0"
           int month = (  (  *timeinfo ).tm_mon + 1 ); // January is month "0"
           if(  month <= 9 )
           {
           filename << "0";
           }
           filename << month;
           int day = (  *timeinfo ).tm_mday;
           if(  day <= 9 )
           {
           filename << "0";
           }
           filename << day << "_";
           int hour = (  *timeinfo ).tm_hour;
           if(  hour <= 9 )
           {
           filename << "0";
           }
           filename << hour;
           int min = (  *timeinfo ).tm_min;
           if(  min <= 9 )
           {
           filename << "0";
           }
           filename << min;
           int sec = (  *timeinfo ).tm_sec;
           if(  sec <= 9 )
           {
           filename << "0";
           }
           filename << sec << ".jpg";
          
           const std::string dir = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ) + "/screenshots/";
           try {
           //make sure the directory exists
          
           oslink::directory osdir(  dir );
          
           if (  !osdir.isExisting(   ) ) {
          #ifdef __WIN32__
           mkdir(  dir.c_str(   ) );
          #else
           mkdir(  dir.c_str(   ),   S_IRWXU );
          #endif
           }
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when creating directory for screenshots. Message: " << std::string(  ex.what(   ) ) );
           throw Ember::Exception(  "Error when saving screenshot. Message: " + std::string(  ex.what(   ) ) );
           }
          
           try {
           // take screenshot
           mWindow->writeContentsToFile(  dir + filename.str(   ) );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "Could not write screenshot to disc. Message: "<< ex.getFullDescription(   ) );
           throw Ember::Exception(  "Error when saving screenshot. Message: " + ex.getDescription(   ) );
           }
           return dir + filename.str(   );
          }
          
          void AvatarCamera::takeScreenshot(   )
          {
           try {
           const std::string& result = _takeScreenshot(   );
           S_LOG_INFO(  result );
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  "Wrote image: " + result );
           } catch (  const Ember::Exception& ex ) {
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  "Error when saving screenshot: " + ex.getError(   ) );
           }
          }
          
          }
          
          
          
          
          

./components/ogre/AvatarCamera.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          
          /*
           * An instance of this is a player controlled camera fastened to the Avatar.
           * It should be possible to subclass this in order to provide different behaviour
           */
          
          
          #ifndef AVATARCAMERA_H
          #define AVATARCAMERA_H
          
          #include "EmberOgrePrerequisites.h"
          
          #include <sigc++/trackable.h>
          
          
          #include "framework/ConsoleObject.h"
          
          #include "input/Input.h"
          #include <stack>
          
          namespace EmberOgre {
          
      41  class Avatar;
      42  class InputManager;
      43  class GUIManager;
      44  class EmberEntity;
          struct MouseMotion;
          struct EntityPickResult;
      47  class IWorldPickListener;
          struct MousePickerArgs;
          
      50  class Recorder :public Ogre::FrameListener
          {
          public:
      53   Recorder(   );
      54   void startRecording(   );
      55   void stopRecording(   );
           /**
           * Methods from Ogre::FrameListener
           */
      59   bool frameStarted(  const Ogre::FrameEvent& event );
          private:
           int mSequence;
           float mAccruedTime;
           float mFramesPerSecond;
          };
          
          
      67  class AvatarCamera
          :
      69  public sigc::trackable,  
      70  public Ember::ConsoleObject,  
      71  public Ogre::FrameListener
          {
          public:
          
           enum Mode {
           MODE_THIRD_PERSON = 1,  
           MODE_FIRST_PERSON = 2
           };
          
      80   AvatarCamera(  Ogre::SceneNode* avatarNode,   Ogre::SceneManager* sceneManager,   Ogre::RenderWindow* window,   GUIManager* guiManager,   Ogre::Camera* camera );
      81   virtual ~AvatarCamera(   );
          
           /**
           * Pitches the camera the supplied degrees
           */
      86   virtual void pitch(  Ogre::Degree degrees );
          
           /**
           * Yaws the camera the supplied degrees
           */
      91   virtual void yaw(  Ogre::Degree degrees );
          
           /**
           * returns the current degrees of pitch from the cameras initial position
           */
      96   inline const Ogre::Degree& getPitch(   ) const;
          
           /**
           * returns the current degrees of yaw from the cameras initial position
           */
     101   inline const Ogre::Degree& getYaw(   ) const;
          
           /**
           * returns a pointer to the Ogre::Camera instance
           */
     106   inline Ogre::Camera* getCamera(   );
     107   inline Ogre::Camera* getCamera(   ) const;
          
           /**
           * Returns the current camera orientation in the world
           */
     112   virtual const Ogre::Quaternion& getOrientation(  bool onlyHorizontal = true ) const;
          
          
           /**
           * Returns the position of the camera in the world.
           * @return
           */
     119   const Ogre::Vector3& getPosition(   ) const;
          
          
     122   void setMode(  Mode mode );
          
           /**
           * sets the node to which the camera is attached
           */
     127   virtual void setAvatarNode(  Ogre::SceneNode* sceneNode );
          
           /**
           * emitted when the camra moves
           */
     132   sigc::signal<void,   Ogre::Camera*> MovedCamera;
          
           /**
           * emitted when the distance between the camera and the avatar has changed
           * @param Ogre::Real the new distance
           */
     138   sigc::signal<void,   Ogre::Real> EventChangedCameraDistance;
          
          // int xPosition,   int yPosition,   Ogre::Real xRelativeMovement,   Ogre::Real yRelativeMovement,   Ogre::Real timeSinceLastMovement );
          
          // void mouseMoved (  Ogre::MouseEvent *e );
          // void mouseDragged (  Ogre::MouseEvent *e ) {};
          
     145   void pickInWorld(  Ogre::Real mouseX,   Ogre::Real mouseY,   const MousePickerArgs& args );
          
          // EntityPickResult pickAnEntity(  Ogre::Real mouseX,   Ogre::Real mouseY );
          // std::vector<Ogre::RaySceneQueryResultEntry> AvatarCamera::pickObject(  Ogre::Real mouseX,   Ogre::Real mouseY,   std::vector<Ogre::UserDefinedObject*> exclude,   unsigned long querymask  );
          
     150   void setClosestPickingDistance(  Ogre::Real distance );
     151   Ogre::Real getClosestPickingDistance(   );
          
           /**
           * returns true if the worldPos is on screen,   putting the screen pos into the x & y of the second Vector3
           * returns false if the worldPos is off screen
           * @param worldPos
           * @param screenPos
           * @return
           */
     160   bool worldToScreen(  const Ogre::Vector3& worldPos,   Ogre::Vector3& screenPos );
          
           /**
           * Attaches the camera to the specified scene node.
           * @param toNode
           */
     166   void attach(  Ogre::SceneNode* toNode );
          
           /**
           * Adjusts the camera for the terrain,   so it doesn't dip below it.
           * @return
           */
     172   bool adjustForTerrain(   );
          
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
     180   virtual void runCommand(  const std::string &command,   const std::string &args );
          
          
           /**
           * Sets the distance from the camera to the avatar.
           * @param distance the new distance
           */
     187   void setCameraDistance(  Ogre::Real distance );
          
           /**
           * Methods from Ogre::FrameListener
           */
     192   bool frameStarted(  const Ogre::FrameEvent& event );
           //bool frameEnded(  const Ogre::FrameEvent& event );
          
           /**
           * Enables and disables a compositor by name.
           * @param compositorName
           * @param enable
           */
     200   void enableCompositor(  const std::string& compositorName,   bool enable );
          
          
           /**
           * Adds a new world pick listener to the queue of listeners.
           * @param worldPickListener
           */
     207   void pushWorldPickListener(  IWorldPickListener* worldPickListener );
          
     209   const Ember::ConsoleCommandWrapper SetCameraDistance;
     210   const Ember::ConsoleCommandWrapper ToggleRendermode;
     211   const Ember::ConsoleCommandWrapper ToggleFullscreen;
     212   const Ember::ConsoleCommandWrapper Screenshot;
     213   const Ember::ConsoleCommandWrapper Record;
          
           /**
           Toggles between wireframe and solid render mode.
           */
     218   void toggleRenderMode(   );
          
           /**
           * takes a screen shot and writes it to disk
           */
     223   void takeScreenshot(   );
          
          protected:
          
           typedef std::deque<IWorldPickListener*> WorldPickListenersStore;
     228   WorldPickListenersStore mPickListeners;
          
           typedef std::vector<std::string> CompositorNameStore;
          
     232   Recorder mRecorder;
          
     234   CompositorNameStore mLoadedCompositors;
          
           Mode mMode;
          
     238   bool mIsAttached;
          
           /**
           If true,   the camera is inverted in the y axis.
           */
     243   bool mInvertCamera;
          
           /**
           Creates the rays needed for mouse picking and camera adjustment.
           */
     248   void createRayQueries(   );
          
          
           /**
           * creates all nodes needed for the camera
           */
     254   void createNodesForCamera(   );
          
     256   const std::string _takeScreenshot(   );
          
     258   void createViewPort(   );
     259   GUIManager* mGUIManager;
          
          
     262   Ogre::Camera* mCamera;
     263   Ogre::SceneNode* mAvatarNode;
     264   Ogre::SceneManager* mSceneManager;
           //Ogre::Quaternion mLastOrientationOfTheCamera;
          
     267   Ogre::SceneNode* mAvatarCameraRootNode;
     268   Ogre::SceneNode* mAvatarCameraPitchNode;
     269   Ogre::SceneNode* mAvatarCameraNode;
          
     271   Ogre::Degree mDegreeOfPitchPerSecond;
     272   Ogre::Degree mDegreeOfYawPerSecond;
          
     274   Ogre::Degree degreePitch;
     275   Ogre::Degree degreeYaw;
     276   Ogre::RenderWindow* mWindow;
     277   Ogre::Viewport* mViewPort;
          
           //in meters how far we can pick objects
     280   Ogre::Real mClosestPickingDistance;
          
     282   Ogre::Vector3 mLastPosition;
     283   Ogre::Real mWantedCameraDistance,   mCurrentCameraDistance;
          
     285   Ogre::RaySceneQuery *mAdjustTerrainRaySceneQuery,   *mCameraRaySceneQuery;
     286   Ogre::Ray mAdjustTerrainRay;
          
     288   bool mIsAdjustedToTerrain;
          
     290   void Input_MouseMoved(  const MouseMotion& motion,   Input::InputMode mode );
          
     292   void ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key );
          
     294   void updateValuesFromConfig(   );
          
           /**
           * Internal method for setting the camera distance.
           * @param distance the new distance
           */
     300   void _setCameraDistance(  Ogre::Real distance );
          
          };
          
          
          ///inline implementations
          
     307   const Ogre::Degree& AvatarCamera::getPitch(   ) const
           {
           return degreePitch;
           }
          
     312   const Ogre::Degree& AvatarCamera::getYaw(   ) const
           {
           return degreeYaw;
           }
          
     317   Ogre::Camera* AvatarCamera::getCamera(   ) {
           return mCamera;
           }
     320   Ogre::Camera* AvatarCamera::getCamera(   ) const {
           return mCamera;
           }
          
          
          
     326  class ICameraMount
          {
     328   virtual ~ICameraMount(   ) {};
          
           /**
           * Pitches the camera the supplied degrees
           */
     333   virtual void pitch(  Ogre::Degree degrees ) = 0;
          
           /**
           * Yaws the camera the supplied degrees
           */
     338   virtual void yaw(  Ogre::Degree degrees ) = 0;
          
           /**
           * returns the current degrees of pitch from the cameras initial position
           */
     343   virtual const Ogre::Degree& getPitch(   ) const = 0;
          
           /**
           * returns the current degrees of yaw from the cameras initial position
           */
     348   virtual const Ogre::Degree& getYaw(   ) const = 0;
          
           /**
           * Returns the current camera orientation in the world
           */
     353   virtual const Ogre::Quaternion& getOrientation(  bool onlyHorizontal = true ) const = 0;
          
           /**
           * Returns the position of the camera in the world.
           * @return
           */
     359   virtual const Ogre::Vector3& getPosition(   ) const = 0;
          
     361   void setMode(  AvatarCamera::Mode mode );
          
           /**
           * sets the node to which the camera is attached
           */
     366   virtual void setAvatarNode(  Ogre::SceneNode* sceneNode );
          
          };
          
     370  class MainCamera
          {
     372   virtual ~MainCamera(   ) {}
          
           /**
           * returns a pointer to the Ogre::Camera instance
           */
     377   inline Ogre::Camera* getCamera(   );
     378   inline Ogre::Camera* getCamera(   ) const;
          
           /**
           * emitted when the camra moves
           */
     383   sigc::signal<void,   Ogre::Camera*> MovedCamera;
          
          
     386   void pickInWorld(  Ogre::Real mouseX,   Ogre::Real mouseY,   const MousePickerArgs& args );
          
     388   void setClosestPickingDistance(  Ogre::Real distance );
     389   Ogre::Real getClosestPickingDistance(   );
          
           /**
           * returns true if the worldPos is on screen,   putting the screen pos into the x & y of the second Vector3
           * returns false if the worldPos is off screen
           * @param worldPos
           * @param screenPos
           * @return
           */
     398   bool worldToScreen(  const Ogre::Vector3& worldPos,   Ogre::Vector3& screenPos );
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
     405   virtual void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           * Methods from Ogre::FrameListener
           */
     410   bool frameStarted(  const Ogre::FrameEvent& event );
          
           /**
           * Enables and disables a compositor by name.
           * @param compositorName
           * @param enable
           */
     417   void enableCompositor(  const std::string& compositorName,   bool enable );
          
          
           /**
           * Adds a new world pick listener to the queue of listeners.
           * @param worldPickListener
           */
     424   void pushWorldPickListener(  IWorldPickListener* worldPickListener );
          
     426   const Ember::ConsoleCommandWrapper ToggleRendermode;
     427   const Ember::ConsoleCommandWrapper ToggleFullscreen;
     428   const Ember::ConsoleCommandWrapper Screenshot;
     429   const Ember::ConsoleCommandWrapper Record;
          
           /**
           Toggles between wireframe and solid render mode.
           */
     434   void toggleRenderMode(   );
          
           /**
           * takes a screen shot and writes it to disk
           */
     439   void takeScreenshot(   );
          
          };
          
     443  class AvatarCameraMount : ICameraMount
          {
           /**
           * emitted when the distance between the camera and the avatar has changed
           * @param Ogre::Real the new distance
           */
     449   sigc::signal<void,   Ogre::Real> EventChangedCameraDistance;
          
           /**
           * Sets the distance from the camera to the avatar.
           * @param distance the new distance
           */
     455   void setCameraDistance(  Ogre::Real distance );
          
     457   const Ember::ConsoleCommandWrapper SetCameraDistance;
          
          };
          
     461  class FreeFlyingMount : ICameraMount
          {
          };
          
          
          
          }
          
          #endif // AVATARCAMERA_H

./components/ogre/AvatarController.cpp

          /*
           Copyright (  C ) 2004 Erik Hjortsberg
           some parts Copyright (  C ) 2004 bad_camel at Ogre3d forums
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          
          
          #include "AvatarController.h"
          
          
          #include "EmberEntity.h"
          #include "EmberPhysicalEntity.h"
          #include "AvatarEmberEntity.h"
          #include "AvatarCamera.h"
          #include "GUIManager.h"
          #include "Avatar.h"
          #include "EmberOgre.h"
          // #include "SceneManagers/EmberPagingSceneManager/include/EmberPagingSceneManager.h"
          #include "terrain/TerrainGenerator.h"
          #include "terrain/ISceneManagerAdapter.h"
          
          
          #include "input/Input.h"
          
          #include "framework/Tokeniser.h"
          #include "MathConverter.h"
          #include "services/EmberServices.h"
          #include "services/server/ServerService.h"
          
          
          using namespace Ogre;
          namespace EmberOgre {
          
          
          AvatarControllerMovement::AvatarControllerMovement(   ) :
           rotationDegHoriz(  0 ),  
           rotationDegVert(  0 ),  
           timeSlice(  0 ),  
           movementDirection(  Ogre::Vector3::ZERO ),  
           mode(  AvatarMovementMode::MM_WALK ),  
           isMoving(  false )
          {
          }
          
          
          
      61  AvatarControllerInputListener::AvatarControllerInputListener(  AvatarController& controller )
          : mController(  controller )
          {
           Input::getSingleton(   ).EventMouseButtonPressed.connect(  sigc::mem_fun(  *this,   &AvatarControllerInputListener::input_MouseButtonPressed ) );
           Input::getSingleton(   ).EventMouseButtonReleased.connect(  sigc::mem_fun(  *this,   &AvatarControllerInputListener::input_MouseButtonReleased ) );
          
          }
          
      69  void AvatarControllerInputListener::input_MouseButtonPressed(  Input::MouseButton button,   Input::InputMode mode )
          {
           if (  mode == Input::IM_MOVEMENT && button == Input::MouseButtonLeft ) {
           mController.mMovementDirection.x = 1;
           }
          }
          
      76  void AvatarControllerInputListener::input_MouseButtonReleased(  Input::MouseButton button,   Input::InputMode mode )
          {
           if (  mode == Input::IM_MOVEMENT && button == Input::MouseButtonLeft ) {
           mController.mMovementDirection.x = 0;
           }
          }
          
      83  AvatarController::AvatarController(  Avatar* avatar,   Ogre::RenderWindow* window,   GUIManager* guiManager,   Ogre::Camera* camera )
          : RunToggle(  "+run",   this,   "Toggle running mode." )
      85  ,   ToggleCameraAttached(  "toggle_cameraattached",   this,   "Toggle between the camera being attached to the avatar and free flying." )
          ,   CharacterMoveForward(  "+character_move_forward",   this,   "Move the avatar forward." )
          ,   CharacterMoveBackward(  "+character_move_backward",   this,   "Move the avatar backward." )
          ,   CharacterMoveDownwards(  "+character_move_downwards",   this,   "Move the avatar downwards." )
          ,   CharacterMoveUpwards(  "+character_move_upwards",   this,   "Move the avatar upwards." )
          ,   CharacterStrafeLeft(  "+character_strafe_left",   this,   "Strafe left." )
          ,   CharacterStrafeRight(  "+character_strafe_right",   this,   "Strafe right." )
          /*,   CharacterRotateLeft(  "+character_rotate_left",   this,   "Rotate left." )
          ,   CharacterRotateRight(  "+character_rotate_right",   this,   "Rotate right." )*/
          ,   MoveCameraTo(  "movecamerato",   this,   "Moves the camera to a point." )
          ,   mMovementCommandMapper(  "movement",   "key_bindings_movement" )
          ,   mWindow(  window )
          ,   mGUIManager(  guiManager )
          ,   mAvatarCamera(  0 )
          ,   mCamera(  camera )
          ,   mEntityUnderCursor(  0 )
          ,   mSelectedEntity(  0 )
          ,   mFreeFlyingCameraNode(  0 )
          ,   mIsRunning(  false )
          ,   mMovementDirection(  Ogre::Vector3::ZERO )
          ,   mDecalObject(  0 )
          ,   mDecalNode(  0 )
          ,   mControllerInputListener(  *this )
          {
          
           mMovementCommandMapper.restrictToInputMode(  Input::IM_MOVEMENT  );
          
           setAvatar(  avatar );
          
          
           mAvatar->setAvatarController(  this );
          
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          
          
           mFreeFlyingCameraNode = EmberOgre::getSingleton(   ).getSceneManager(   )->getRootSceneNode(   )->createChildSceneNode(   );
           mFreeFlyingCameraNode->setPosition(  0,  30,  0 );
           detachCamera(   );
          
          
           mMovementCommandMapper.bindToInput(  Input::getSingleton(   ) );
          
           GUIManager::getSingleton(   ).getEntityPickListener(   )->EventPickedEntity.connect(  sigc::mem_fun(  *this,   &AvatarController::entityPicker_PickedEntity ) );
          
          }
     130  AvatarController::~AvatarController(   )
          {
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
           delete mAvatarCamera;
          }
          
     136  void AvatarController::createAvatarCameras(  Ogre::SceneNode* avatarSceneNode )
          {
           if (  mAvatarCamera == 0 ) {
           mAvatarCamera = new AvatarCamera(  avatarSceneNode,   EmberOgre::getSingletonPtr(   )->getSceneManager(   ),   mWindow,   mGUIManager,   mCamera );
           } else {
           attachCamera(   );
           }
          }
          
     145  void AvatarController::setAvatar(  Avatar* avatar )
          {
           mAvatar = avatar;
           createAvatarCameras(  avatar->getAvatarSceneNode(   ) );
           attachCamera(   );
          }
          
          
          
     154  void AvatarController::runCommand(  const std::string &command,   const std::string &args )
          {
           if (  RunToggle == command ) {
           mIsRunning = true;
           } else if (  RunToggle.getInverseCommand(   ) == command ) {
           mIsRunning = false;
           } else if (  ToggleCameraAttached == command )
           {
           if (  mIsAttached ) {
           detachCamera(   );
           } else {
           attachCamera(   );
           }
           } else if (  CharacterMoveForward == command ) {
           mMovementDirection.x = 1;
           } else if (  CharacterMoveForward.getInverseCommand(   ) == command ) {
           mMovementDirection.x = 0;
           } else if (  CharacterMoveBackward == command ) {
           mMovementDirection.x = -1;
           } else if (  CharacterMoveBackward.getInverseCommand(   ) == command ) {
           mMovementDirection.x = 0;
           } else if (  CharacterStrafeLeft == command ) {
           mMovementDirection.z = -1;
           } else if (  CharacterStrafeLeft.getInverseCommand(   ) == command ) {
           mMovementDirection.z = 0;
           } else if (  CharacterStrafeRight == command ) {
           mMovementDirection.z = 1;
           } else if (  CharacterStrafeRight.getInverseCommand(   ) == command ) {
           mMovementDirection.z = 0;
           } else if (  CharacterMoveUpwards == command ) {
           mMovementDirection.y = 1;
           } else if (  CharacterMoveUpwards.getInverseCommand(   ) == command ) {
           mMovementDirection.y = 0;
           } else if (  CharacterMoveDownwards == command ) {
           mMovementDirection.y = -1;
           } else if (  CharacterMoveDownwards.getInverseCommand(   ) == command ) {
           mMovementDirection.y = 0;
          /* } else if (  CharacterRotateLeft == command ) {
           mAvatarCamera->yaw(  Ogre::Degree(  -15 ) );
           } else if (  CharacterRotateRight == command ) {
           mAvatarCamera->yaw(  Ogre::Degree(  15 ) );*/
           } else if (  MoveCameraTo == command ) {
           if (  !mIsAttached ) {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string x = tokeniser.nextToken(   );
           std::string y = tokeniser.nextToken(   );
           std::string z = tokeniser.nextToken(   );
          
           if (  x == "" || y == "" || z == "" ) {
           return;
           } else {
           Ogre::Vector3 position(  Ogre::StringConverter::parseReal(  x ),  Ogre::StringConverter::parseReal(  y ),  Ogre::StringConverter::parseReal(  z ) );
           mFreeFlyingCameraNode->setPosition(  position );
           }
           }
           }
          }
          
          
     214  void AvatarController::detachCamera(   )
          {
           mIsAttached = false;
           mAvatarCamera->attach(  mFreeFlyingCameraNode );
           //mAvatarCamera->setMode(  AvatarCamera::MODE_FIRST_PERSON );
          }
          
          
     222  void AvatarController::attachCamera(   )
          {
           mIsAttached = true;
           mAvatarCamera->attach(  mAvatar->getAvatarSceneNode(   ) );
           //mAvatarCamera->setMode(  AvatarCamera::MODE_FIRST_PERSON );
          }
          
          
     230  bool AvatarController::frameStarted(  const Ogre::FrameEvent& event )
          {
          
           if (  mDecalObject )
           {
           ///hide the decal when we're close to it
           if (  mDecalNode->getWorldPosition(   ).distance(  mAvatar->getAvatarSceneNode(   )->getWorldPosition(   ) ) < 1 ) {
           mDecalNode->setVisible(  false );
           }
           }
          
          // if (  mDecalObject ) {
          // Ogre::Real newSize = mPulsatingController->calculate(  event.timeSinceLastFrame );
          // //mDecalNode->setScale(  Ogre::Vector3(  newSize,   1.0f,   newSize ) );
          // // mDecalNode->yaw(  Ogre::Radian(  0.1f ) );
          // }
          
          // EmberPagingSceneManager* mScnMgr = static_cast<EmberPagingSceneManager*>(  EmberOgre::getSingleton(   ).getSceneManager(   ) );
          // if (  mGUIManager->getInput(   )->isKeyDown(  SDLK_F4 ) ) {
          // /* Real change;
          // mScnMgr->getOption(   "MaxPixelError",   &change  );
          // change -= 0.5f;
          // mScnMgr->setOption(   "MaxPixelError",   &change  ); */
          // --Ogre::PagingLandScapeOptions::getSingleton(   ).maxPixelError;
          // Ogre::PagingLandScapeOptions::getSingleton(   ).calculateCFactor(   );
          // mScnMgr->WorldDimensionChange(   );
          // }
          // if (  mGUIManager->getInput(   )->isKeyDown(  SDLK_F5 ) ) {
          // /* Real change;
          // mScnMgr->getOption(   "MaxPixelError",   &change  );
          // change += 0.5f;
          // mScnMgr->setOption(   "MaxPixelError",   &change  ); */
          // ++Ogre::PagingLandScapeOptions::getSingleton(   ).maxPixelError;
          // Ogre::PagingLandScapeOptions::getSingleton(   ).calculateCFactor(   );
          // mScnMgr->WorldDimensionChange(   );
          // }
          //
          
           movementForFrame = AvatarControllerMovement(   );
          
          /* if (  mMovementDirection != Ogre::Vector3::ZERO ) {*/
           movementForFrame.mode = mIsRunning ? AvatarMovementMode::MM_RUN : AvatarMovementMode::MM_WALK;
           movementForFrame.isMoving = true;
           movementForFrame.movementDirection = mMovementDirection;
           movementForFrame.timeSlice = event.timeSinceLastFrame;
           if (  movementForFrame.mode != mPreviousMovementForFrame.mode ) {
           EventMovementModeChanged.emit(  movementForFrame.mode );
           }
          // } else {
          // }
          
          // if (  mGUIManager->isInMovementKeysMode(   ) ) {
          // movementForFrame.movementDirection = Ogre::Vector3::ZERO;
          // movementForFrame.mIsRunning = false;
          // movementForFrame.isMoving = false;
          
          /* checkMovementKeys(  event,   EmberOgre::getSingleton(   ).getInput(   ) );
          
          
           movementForFrame.timeSlice = event.timeSinceLastFrame;
           } */
          
           if (  mIsAttached ) {
          // mAvatarCamera->adjustForTerrain(   );
           mAvatar->updateFrame(  movementForFrame );
           } else {
           Ogre::Real scaler = 50;
           //make this inverse,   so that when the run key is pressed,   the free flying camera goes slower
           //this is since we assume that one wants to go fast when in free flying mode
           if (  movementForFrame.mode == AvatarMovementMode::MM_RUN ) {
           scaler = 10;
           }
           Ogre::Vector3 correctDirection(  movementForFrame.movementDirection.z,   movementForFrame.movementDirection.y,   -movementForFrame.movementDirection.x );
           mFreeFlyingCameraNode->translate(  mAvatarCamera->getOrientation(  false ) * (  correctDirection * movementForFrame.timeSlice * scaler ) );
          
           }
           mPreviousMovementForFrame = movementForFrame;
          
          
          
           return true;
          }
          
          
     314  const AvatarControllerMovement & AvatarController::getCurrentMovement(   ) const
          {
           return movementForFrame;
          }
          
          
     320  AvatarCamera* AvatarController::getAvatarCamera(   ) const
          {
           return mAvatarCamera;
          }
          
     325  void AvatarController::entityPicker_PickedEntity(  const EntityPickResult& result,   const MousePickerArgs& args )
          {
          ///don't do this now that we have a "move to" option in the menu,   since it will confuse the users
          /* if (  args.pickType == MPT_DOUBLECLICK ) {
           moveToPoint(  result.position );
           }*/
          }
          
     333  void AvatarController::moveToPoint(  const Ogre::Vector3& point )
          {
           if (  !mDecalNode ) {
           createDecal(  point );
           }
          
           if (  mDecalNode ) {
           ///make sure it's at the correct height,   since the visibility of it is determined by the bounding box
           Ogre::Real height = EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getAdapter(   )->getHeightAt(  point.x,   point.z );
           mDecalNode->setPosition(  Ogre::Vector3(  point.x,   height,   point.z ) );
           mDecalNode->setVisible(  true );
           }
          
           WFMath::Vector<3> atlasVector = Ogre2Atlas_Vector3(  point );
           WFMath::Point<3> atlasPos(  atlasVector.x(   ),   atlasVector.y(   ),   atlasVector.z(   ) );
          /* WFMath::Point<3> atlas2dPos(  atlasVector.x(   ),   atlasVector.y(   ),   0 );
           WFMath::Point<3> avatar2dPos(  mAvatar->getAvatarEmberEntity(   )->getPosition(   ).x(   ),   mAvatar->getAvatarEmberEntity(   )->getPosition(   ).y(   ),   0 );
           WFMath::Vector<3> direction(  1,   0,   0 );
           direction = direction.rotate(  mAvatar->getAvatarEmberEntity(   )->getOrientation(   ) );
           WFMath::Vector<3> directionToPoint = atlas2dPos - avatar2dPos;
           WFMath::Quaternion rotation;
           rotation = rotation.rotation(  directionToPoint,   direction );*/
           //Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->moveInDirection(  WFMath::Vector<3>(  0,  0,  0 ),   rotation );
          
          
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->moveToPoint(  atlasPos );
          }
          
          
     362  void AvatarController::teleportTo(  const Ogre::Vector3& point,   EmberEntity* locationEntity )
          {
           WFMath::Vector<3> atlasVector = Ogre2Atlas_Vector3(  point );
           WFMath::Point<3> atlasPos(  atlasVector.x(   ),   atlasVector.y(   ),   atlasVector.z(   ) );
          
          
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->place(  mAvatar->getAvatarEmberEntity(   ),   locationEntity,   atlasPos );
          }
          
          
     372  void AvatarController::createDecal(  Ogre::Vector3 position )
          {
           try {
           // Create object MeshDecal
           Ogre::SceneManager* sceneManager = EmberOgre::getSingleton(   ).getSceneManager(   );
           Ogre::NameValuePairList params;
           params["materialName"] = "/global/ember/terraindecal";
           params["width"] = StringConverter::toString(   2  );
           params["height"] = StringConverter::toString(   2  );
           params["sceneMgrInstance"] = sceneManager->getName(   );
          
           mDecalObject = sceneManager->createMovableObject(  
           "AvatarControllerMoveToDecal",  
           "PagingLandScapeMeshDecal",  
           &params  );
          
           // Add MeshDecal to Scene
           mDecalNode = sceneManager->createSceneNode(  "AvatarControllerMoveToDecalNode" );
           ///the decal code is a little shaky and relies on us setting the position of the node before we add the moveable object
           EmberOgre::getSingleton(   ).getWorldSceneNode(   )->addChild(  mDecalNode );
           mDecalNode->setPosition(  position );
           mDecalNode->attachObject(  mDecalObject );
           // mDecalNode->showBoundingBox(  true );
          
          
           mPulsatingController = new Ogre::WaveformControllerFunction(  Ogre::WFT_SINE,   1,   0.33,   0.25 );
           } catch (  const Ogre::Exception& ex )
           {
           S_LOG_WARNING(  "Error when creating terrain decal: " << ex.what(   ) );
           }
          }
          
          
          }
          

./components/ogre/AvatarController.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef AVATARCONTROLLER_H
          #define AVATARCONTROLLER_H
          
          #include "EmberOgrePrerequisites.h"
          
          
          // #include <SDL.h>
          #include <sigc++/trackable.h>
          
          #include "input/Input.h"
          #include "input/InputCommandMapper.h"
          #include "framework/ConsoleObject.h"
          #include "EntityWorldPickListener.h"
          
          
          
          namespace EmberOgre {
      36  class Avatar;
      37  class EmberEntity;
      38  class AvatarCamera;
          
      40  class GUIManager;
          
      42  class InputManager;
      43  class Input;
      44  class AvatarController;
          
          /**
          The movement mode of the avatar,   run or walk.
          */
      49  class AvatarMovementMode {
          public:
           enum Mode
           {
           MM_WALK = 0,  
           MM_RUN = 1
           };
          };
          
          
          /**
          Used for sending the current desired movement to the actual avatar.
          */
          struct AvatarControllerMovement
          {
           AvatarControllerMovement(   );
          
           float rotationDegHoriz;
           float rotationDegVert;
           Ogre::Real timeSlice;
           Ogre::Vector3 movementDirection;
           AvatarMovementMode::Mode mode;
           bool isMoving;
           Ogre::Quaternion cameraOrientation;
          };
          
          /**
          Listens for left mouse button pressed in movement mode and moves the character forward.
          */
      78  class AvatarControllerInputListener
          {
          public:
      81   AvatarControllerInputListener(  AvatarController& controller );
          
          protected:
          
      85   void input_MouseButtonPressed(  Input::MouseButton button,   Input::InputMode mode );
      86   void input_MouseButtonReleased(  Input::MouseButton button,   Input::InputMode mode );
      87   AvatarController& mController;
          };
          
          /**
          Controls the avatar. All avatar movement is handled by an instance of this class.
          */
      93  class AvatarController
      94  : public Ogre::FrameListener,  
      95  public sigc::trackable,  
      96  public Ember::ConsoleObject
          {
          public:
      99   friend class AvatarControllerInputListener;
          
     101   AvatarController(  Avatar* avatar,   Ogre::RenderWindow* window,   GUIManager* guiManager,   Ogre::Camera* camera );
          
     103   virtual ~AvatarController(   );
          
           /**
           Each frame we check if we should update the avatar.
           */
     108   virtual bool frameStarted(  const Ogre::FrameEvent & event );
          
          
           /**
           Emitted when the movement mode changes between run and walk.
           */
     114   sigc::signal<void,   AvatarMovementMode::Mode> EventMovementModeChanged;
          
          
          
     118   void createAvatarCameras(  Ogre::SceneNode* avatarSceneNode );
          
           /**
           * Gets the AvatarCamera.
           * @return
           */
     124   AvatarCamera* getAvatarCamera(   ) const;
          
           /**
           * Detaches the camera from the avatar and attaches it to the free flying node.
           */
     129   void detachCamera(   );
          
           /**
           * Attaches the camera to the avatar.
           */
     134   void attachCamera(   );
          
           /**
           * Gets the current movement for this frame.
           * @return
           */
     140   const AvatarControllerMovement& getCurrentMovement(   ) const;
          
     142   const Ember::ConsoleCommandWrapper RunToggle;
     143   const Ember::ConsoleCommandWrapper ToggleCameraAttached;
          
     145   const Ember::ConsoleCommandWrapper CharacterMoveForward;
     146   const Ember::ConsoleCommandWrapper CharacterMoveBackward;
     147   const Ember::ConsoleCommandWrapper CharacterMoveDownwards;
     148   const Ember::ConsoleCommandWrapper CharacterMoveUpwards;
     149   const Ember::ConsoleCommandWrapper CharacterStrafeLeft;
     150   const Ember::ConsoleCommandWrapper CharacterStrafeRight;
          /* const Ember::ConsoleCommandWrapper CharacterRotateLeft;
           const Ember::ConsoleCommandWrapper CharacterRotateRight;*/
          
     154   const Ember::ConsoleCommandWrapper MoveCameraTo;
          
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
     162   virtual void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           Moves the avatar to the specified point.
           A terrain decal will be shown.
           */
     168   void moveToPoint(  const Ogre::Vector3& point );
          
           /**
           * Teleports the avatar to the specified point.
           * @param point
           * @param locationEntity
           */
     175   void teleportTo(  const Ogre::Vector3& point,   EmberEntity* locationEntity );
          
          protected:
          
     179   InputCommandMapper mMovementCommandMapper;
          
     181   Ogre::RenderWindow* mWindow;
          
     183   GUIManager* mGUIManager;
          
          
          // void checkMovementKeys(  const Ogre::FrameEvent & event,   const Input& input );
          
          
     189   AvatarCamera* mAvatarCamera;
     190   void setAvatar(  Avatar* avatar );
     191   Ogre::Camera* mCamera;
          
          
           /**
           * Avatar
           */
     197   Avatar* mAvatar;
          
     199   EmberEntity* mEntityUnderCursor;
     200   EmberEntity* mSelectedEntity;
          
           AvatarControllerMovement movementForFrame,   mPreviousMovementForFrame;
          
     204   Ogre::SceneNode* mFreeFlyingCameraNode;
     205   bool mIsAttached;
           /**
           True if we're in running mode.
           */
     209   bool mIsRunning;
          
     211   Ogre::Vector3 mMovementDirection;
          
           /**
           Listen for double clicks and send the avatar to the double clicked position.
           */
     216   void entityPicker_PickedEntity(  const EntityPickResult& result,   const MousePickerArgs& args );
          
           /**
           Creates the terrain decal needed for displaying where the avatar is heading.
           */
     221   void createDecal(  Ogre::Vector3 position );
          
     223   Ogre::MovableObject* mDecalObject;
     224   Ogre::SceneNode* mDecalNode;
     225   Ogre::WaveformControllerFunction* mPulsatingController;
          
     227   AvatarControllerInputListener mControllerInputListener;
          };
          
          
          
          }
          
          #endif // AvatarController_H

./components/ogre/AvatarEmberEntity.cpp

          /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          
          #include "EmberEntity.h"
          #include "EmberPhysicalEntity.h"
          // #include "PersonEmberEntity.h"
          #include "framework/ConsoleBackend.h"
          #include "Avatar.h"
          #include "GUIManager.h"
          #include "model/Model.h"
          #include "AvatarEmberEntity.h"
          #include "EmberOgre.h"
          #include "MousePicker.h"
          
          #include <Eris/Entity.h>
          #include <Eris/Avatar.h>
          #include <OgreTagPoint.h>
          
          namespace EmberOgre {
          
          
      38  AvatarEmberEntity::AvatarEmberEntity(  const std::string& id,   Eris::TypeInfo* type,   Eris::View* vw,   Ogre::SceneManager* sceneManager,   Eris::Avatar* erisAvatar ) : EmberPhysicalEntity(  id,   type,   vw,   sceneManager ),   SetAttachedOrientation(  "setattachedorientation",   this,   "Sets the orienation of an item attached to the avatar: <attachpointname> <x> <y> <z> <degrees>" ),  
      39  mAvatar(  0 ),   mErisAvatar(  erisAvatar )
          {
          }
          
      43  AvatarEmberEntity::~AvatarEmberEntity(   )
          {}
          
          
      47  void AvatarEmberEntity::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  SetAttachedOrientation == command ) {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string attachPointName = tokeniser.nextToken(   );
           if (  attachPointName != "" ) {
           std::string x = tokeniser.nextToken(   );
           std::string y = tokeniser.nextToken(   );
           std::string z = tokeniser.nextToken(   );
           std::string degrees = tokeniser.nextToken(   );
           if (  x != "" && y != "" && z != "" && degrees != "" ) {
           Ogre::Degree ogreDegrees(  Ogre::StringConverter::parseReal(  degrees ) );
           Ogre::Quaternion rotation(  ogreDegrees,   Ogre::Vector3(  Ogre::StringConverter::parseReal(  x ),   Ogre::StringConverter::parseReal(  y ),   Ogre::StringConverter::parseReal(  z ) ) );
           if (  getModel(   ) ) {
           const Model::Model::AttachPointWrapperStore* attachPoints = getModel(   )->getAttachedPoints(   );
           if (  attachPoints ) {
           for (  Model::Model::AttachPointWrapperStore::const_iterator I = attachPoints->begin(   ); I != attachPoints->end(   ); ++I ) {
           if (  I->AttachPointName == attachPointName ) {
           I->TagPoint->setOrientation(  rotation );
           }
           }
           }
           }
           }
           }
           }
          }
          
      76  void AvatarEmberEntity::init(  const Atlas::Objects::Entity::RootEntity &ge,   bool fromCreateOp )
          {
           EmberPhysicalEntity::init(  ge,   fromCreateOp );
           mModel->setQueryFlags(  MousePicker::CM_AVATAR );
          
          
          }
          
      84  void AvatarEmberEntity::onMoved(   )
          {
           //EmberPhysicalEntity::onMoved(   );
          
           if (  getAvatar(   ) ) {
           getAvatar(   )->movedInWorld(   );
           }
           Eris::Entity::onMoved(   );
          }
          
      94  void AvatarEmberEntity::onImaginary(  const Atlas::Objects::Root& act )
          {
           Atlas::Message::Element attr;
           if (  act->copyAttr(  "description",   attr ) != 0 || !attr.isString(   ) ) {
           return;
           }
          
           /// Make the message appear in the chat box
           GUIManager::getSingleton(   ).AppendAvatarImaginary.emit(  getName(   ) + " " + attr.String(   ) );
          }
          
          /*
          void AvatarEmberEntity::handleTalk(  const std::string &msg )
          {
           std::string message = "<";
           message.append(  getName(   ) );
           message.append(  "> " );
           message.append(  msg );
           GUIManager::getSingleton(   ).AppendIGChatLine.emit(  message );
           std::cout << "TRACE - AVATAR SAYS: [" << message << "]\n" << std::endl;
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  message );
          }
          */
          /*
          void AvatarEmberEntity::setVisible(  bool vis )
          {
           //TODO
           //mOgreEntity->setVisible(  true );
          }
          */
          
          //void AvatarEmberEntity::addMember(  Entity *e )
     126  void AvatarEmberEntity::onChildAdded(  Entity *e )
          {
           //mAvatar->EventAddedEntityToInventory.emit(  static_cast<EmberEntity*>(  e ) );
           EmberOgre::getSingleton(   ).getAvatar(   )->mEntitiesToBeAddedToInventory.insert(  e );
           //PersonEmberEntity::addMember(  e );
           EmberPhysicalEntity::onChildAdded(  e );
          
          }
          
          
          /*void AvatarEmberEntity::rmvMember(  Entity *e )*/
     137  void AvatarEmberEntity::onChildRemoved(  Entity *e )
          {
           EmberOgre::getSingleton(   ).getAvatar(   )->EventRemovedEntityFromInventory.emit(  static_cast<EmberEntity*>(  e ) );
           EmberPhysicalEntity::onChildRemoved(  e );
          // mAvatar->mEntitiesToBeRemovedFromInventory.insert(  e );
          // PersonEmberEntity::rmvMember(  e );
          }
          
          
          
          // void AvatarEmberEntity::onLocationChanged(  Eris::Entity *oldLocation,   Eris::Entity *newLocation )
          // {
          // return EmberEntity::onLocationChanged(  oldLocation,   newLocation );
          //
          //
          //
          // Ogre::Vector3 oldWorldPosition = getSceneNode(   )->getWorldPosition(   );
          // EmberEntity* EmberEntity = dynamic_cast<EmberEntity*>(  newLocation );
          // Ogre::SceneNode* newOgreParentNode = EmberEntity->getSceneNode(   );
          //
          // /* if (  EmberEntity )
          // {
          // newOgreParentNode = EmberEntity->getSceneNode(   );
          // } else {
          // newOgreParentNode = EmberOgre::getSingleton(   ).getSceneManager(   )->getSceneNode(  newLocation->getId(   ) );
          // }*/
          //
          // if (  getSceneNode(   )->getParent(   ) ) {
          // //detach from our current object and add to the new entity
          // getSceneNode(   )->getParent(   )->removeChild(  getSceneNode(   )->getName(   ) );
          // }
          // newOgreParentNode->addChild(  getSceneNode(   ) );
          //
          //
          // // Entity::setContainer(  pr );
          // Eris::Entity::onLocationChanged(  oldLocation,   newLocation );
          //
          // //we adjust the entity so it retains it's former position in the world
          // Ogre::Vector3 newWorldPosition = getSceneNode(   )->getWorldPosition(   );
          // getSceneNode(   )->translate(  oldWorldPosition - newWorldPosition );
          // }
          
     179  Ogre::SceneNode* AvatarEmberEntity::getAvatarSceneNode(   )
          {
           return getScaleNode(   );
          }
          
          
          
          
          }
          

./components/ogre/AvatarEmberEntity.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          
          #ifndef AVATARDIMEENTITY_H
          #define AVATARDIMEENTITY_H
          
          namespace Eris
          {
      25   class Entity;
      26   class Avatar;
          }
          
          namespace EmberOgre {
          
          namespace Model {
      32   class Model;
          }
          
          class EmberPhysicalEntity;
      36  class EmberEntity;
      37  class Avatar;
          
          /**
           * This is the main player avatar. We want this one to behave a little different
           * than the other game entities,   thus it has it's own subclass.
           *
           */
      44  class AvatarEmberEntity
      45  : public EmberPhysicalEntity,  
      46  public Ember::ConsoleObject
          {
          public:
          
      50   AvatarEmberEntity(  const std::string& id,   Eris::TypeInfo* type,   Eris::View* vw,   Ogre::SceneManager* sceneManager,   Eris::Avatar* erisAvatar );
      51   virtual ~AvatarEmberEntity(   );
          
           /**
           * used by the main application to set the EmberOgre::Avatar connected to this instance
           */
      56   inline void setAvatar(  Avatar* avatar );
      57   inline Avatar* getAvatar(   );
          
           /**
           * returns the Ogre::SceneNode which represents the avatar
           */
      62   Ogre::SceneNode* getAvatarSceneNode(   );
          
           /**
           * Returns the Eris Avatar instance.
           * @return
           */
      68   inline Eris::Avatar* getErisAvatar(   );
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
      75   virtual void runCommand(  const std::string &command,   const std::string &args );
          
      77   const Ember::ConsoleCommandWrapper SetAttachedOrientation;
          
          protected:
          
      81   virtual void onChildAdded(  Entity *e );
      82   virtual void onChildRemoved(  Entity *e );
          
           /**Eris methods,   see Eris::Entity.h for documentation */
          // virtual void handleTalk(  const std::string &msg );
      86   virtual void onMoved(   );
      87   virtual void onImaginary(  const Atlas::Objects::Root& act );
          /* virtual void addMember(  Entity *e );
           virtual void rmvMember(  Entity *e );*/
           //virtual void setVisible(  bool vis );
           //virtual void setContainer(  Eris::Entity *pr );
           //virtual void onLocationChanged(  Eris::Entity *oldLocation,   Eris::Entity *newLocation );
      93   virtual void init(  const Atlas::Objects::Entity::RootEntity &ge,   bool fromCreateOp );
          
          
      96   Avatar* mAvatar;
      97   Eris::Avatar* mErisAvatar;
          };
          
          ///inline implementations
     101  void AvatarEmberEntity::setAvatar(  Avatar* avatar )
          {
           mAvatar = avatar;
          }
     105  Avatar* AvatarEmberEntity::getAvatar(   )
          {
           return mAvatar;
          }
     109  Eris::Avatar* AvatarEmberEntity::getErisAvatar(   )
          {
           return mErisAvatar;
          }
          
          }
          
          #endif // AVATARDIMEENTITY_H

./components/ogre/CameraMount.cpp

       1  //
          // C++ Implementation: CameraMount
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "CameraMount.h"
          
          namespace EmberOgre {
          
      27  CameraMount::CameraMount(   )
          {
          }
          
          
      32  CameraMount::~CameraMount(   )
          {
          }
          
          
          }

./components/ogre/CameraMount.h

       1  //
          // C++ Interface: CameraMount
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRECAMERAMOUNT_H
          #define EMBEROGRECAMERAMOUNT_H
          
          namespace EmberOgre {
          
          /**
          @author Erik Hjortsberg
          */
      31  class CameraMount{
          public:
      33   CameraMount(   );
          
      35   ~CameraMount(   );
          
          };
          
          }
          
          #endif

./components/ogre/ConsoleObjectImpl.cpp

          /*
           ConsoleObjectImpl.cpp by Miguel Guzman (  Aglanor )
           Copyright (  C ) 2002 Miguel Guzman & The Worldforge Project
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // config headers
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          // system headers
          
          // library headers
          #include "EmberOgrePrerequisites.h"
          
          // local headers
          #include "ConsoleObjectImpl.h"
          #include "framework/ConsoleBackend.h"
          #include "framework/Tokeniser.h"
          
          #include "main/Application.h"
          // #include <SDL.h>
          
          template<> EmberOgre::ConsoleObjectImpl* Ember::Singleton<EmberOgre::ConsoleObjectImpl>::ms_Singleton = 0;
          
          namespace EmberOgre {
          
          
      43  ConsoleObjectImpl::ConsoleObjectImpl(  void ) :
          Quit(  "quit",   this,   "Quit Ember." ),  
      45  ToggleErisPolling(  "toggle_erispolling",   this,   "Switch server polling on and off." )
          {
          }
      48  ConsoleObjectImpl::~ConsoleObjectImpl(   )
          {
          
          }
          
          
      54  void ConsoleObjectImpl::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  command == Quit.getCommand(   ) ) {
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  "Bye" );
           quit(   );
           } else if (  ToggleErisPolling == command ){
           Ember::Application::getSingleton(   ).setErisPolling(  !Ember::Application::getSingleton(   ).getErisPolling(   ) );
           }
          }
          
      64  void ConsoleObjectImpl::quit(   )
          {
           Ember::Application::getSingleton(   ).quit(   );
          }
          
          }
          

./components/ogre/ConsoleObjectImpl.h

       1  /*
           ConsoleObjectImpl.h by Miguel Guzman (  Aglanor )
           Copyright (  C ) 2002 Miguel Guzman & The Worldforge Project
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef __EmberOgre_ConsoleObjectImpl_H__
          #define __EmberOgre_ConsoleObjectImpl_H__
          
          #include "framework/ConsoleObject.h"
          #include "framework/Singleton.h"
          
          namespace EmberOgre {
      27  class ConsoleObjectImpl: public Ember::ConsoleObject,   public Ember::Singleton<ConsoleObjectImpl>
          {
           public:
          
      31   ConsoleObjectImpl(  void );
      32   ~ConsoleObjectImpl(   );
          
           /**
           * Receive commands from console
           */
      37   void runCommand(  const std::string &command,   const std::string &args );
          
           private:
          
          
          
      43   void quit(   );
          
           /// List of Ogre's console commands
      46   const Ember::ConsoleCommandWrapper Quit;
      47   const Ember::ConsoleCommandWrapper ToggleErisPolling;
          
          
          }; // End of class declaration
          
          }
          
          #endif

./components/ogre/EmberEntity.cpp

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "EmberEntity.h"
          
          #include "framework/Service.h"
          #include "framework/ConsoleBackend.h"
          #include "services/EmberServices.h"
          #include "services/sound/SoundService.h"
          #include "EmberEntityFactory.h"
          #include "MotionManager.h"
          #include "GUIManager.h"
          #include "terrain/TerrainArea.h"
          #include "MathConverter.h"
          
          #include "EmberOgre.h"
          #include <OgreWireBoundingBox.h>
          #include <OgreException.h>
          
          #include <Mercator/Area.h>
          //#include <Atlas/Objects/ObjectsFwd.h>
          #include <Eris/TypeInfo.h>
          #include <Eris/View.h>
          #include <Atlas/Formatter.h>
          #include <Atlas/Objects/Decoder.h>
          #include <Atlas/Codecs/XML.h>
          #include <Atlas/Message/MEncoder.h>
          #include <Atlas/Message/QueuedDecoder.h>
          
          
          #include "model/Model.h"
          
          using namespace Ogre;
          
          
          namespace Ogre {
          
           /**
           This is just like a WireBoundBox but not aligned to the axes,   hence it will correctly line up according to it's orientation.
           */
      56   class OOBBWireBoundingBox : public WireBoundingBox
           {
           public:
          
      60   void getWorldTransforms(   Matrix4* xform  ) const
           {
           SimpleRenderable::getWorldTransforms(  xform );
           }
           //-----------------------------------------------------------------------
      65   const Quaternion& getWorldOrientation(  void ) const
           {
           return SimpleRenderable::getWorldOrientation(   );
           }
           //-----------------------------------------------------------------------
      70   const Vector3& getWorldPosition(  void ) const
           {
           return SimpleRenderable::getWorldPosition(   );
           }
          
           };
          
          };
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          namespace EmberOgre {
          
          
      95  const std::string EmberEntity::MODE_STANDING(  "standing" );
      96  const std::string EmberEntity::MODE_RUNNING(  "running" );
      97  const std::string EmberEntity::MODE_WALKING(  "walking" );
      98  const std::string EmberEntity::MODE_SWIMMING(  "swimming" );
      99  const std::string EmberEntity::MODE_FLOATING(  "floating" );
     100  const std::string EmberEntity::MODE_FIXED(  "fixed" );
          
     102  const std::string EmberEntity::BboxMaterialName(  "BaseYellowNoLightning" );
          
          
     105  EmberEntity::EmberEntity(  const std::string& id,   Eris::TypeInfo* ty,   Eris::View* vw,  Ogre::SceneManager* sceneManager )
          :
          Eris::Entity(  id,   ty,   vw )
          ,   mIsInitialized(  false )
          ,   mIsInMotionManager(  false )
          ,   mErisEntityBoundingBox(  0 )
          ,   mOgreNode(  0 )
          ,   mTerrainArea(  0 )
          {
           createSceneNode(  sceneManager );
          }
          
     117  EmberEntity::~EmberEntity(   )
          {
           //detach all children so we don't destroy them
           while (  getSceneNode(   )->numChildren(   ) ) {
           getSceneNode(   )->removeChild(  (  short unsigned int )0 );
           }
           Ogre::SceneNode* parent = static_cast<Ogre::SceneNode*>(  getSceneNode(   )->getParent(   ) );
           if (  parent ) {
           parent->removeAndDestroyChild(  getSceneNode(   )->getName(   ) );
           } else {
           getSceneNode(   )->getCreator(   )->destroySceneNode(  getSceneNode(   )->getName(   ) );
           }
           ///make sure it's not in the MotionManager
           ///TODO: keep a marker in the entity so we don't need to call this for all entities
           MotionManager::getSingleton(   ).removeEntity(  this );
          
           if (  mErisEntityBoundingBox ) {
           mErisEntityBoundingBox->getParentSceneNode(   )->getCreator(   )->destroySceneNode(  mErisEntityBoundingBox->getParentSceneNode(   )->getName(   ) );
           }
           delete mErisEntityBoundingBox;
          
           //mSceneManager->destroySceneNode(  getSceneNode(   )->getName(   ) );
          }
          
     141  void EmberEntity::init(  const Atlas::Objects::Entity::RootEntity &ge,   bool fromCreateOp )
          {
           Eris::Entity::init(  ge,   fromCreateOp );
          
           synchronizeWithServer(   );
          
           // set the Ogre node position and orientation based on Atlas data
           std::stringstream ss;
           ss << "Entity " << getId(   ) << "(  " << getName(   ) << " ) placed at (  " << getPredictedPos(   ).x(   ) << ",  " << getPredictedPos(   ).y(   ) << ",  " << getPredictedPos(   ).x(   ) << " )";
           S_LOG_VERBOSE(   ss.str(   ) );
          
           if (  hasAttr(  "area" ) ) {
           mTerrainArea = std::auto_ptr<Terrain::TerrainArea>(  new Terrain::TerrainArea(  this ) );
           if (  mTerrainArea->init(   ) ) {
           addArea(  mTerrainArea.get(   ) );
           }
           }
          
           mIsInitialized = true;
          
          }
          
     163  void EmberEntity::synchronizeWithServer(   )
          {
           if (  getPosition(   ).isValid(   ) ) {
           getSceneNode(   )->setPosition(  Atlas2Ogre(  getPredictedPos(   ) ) );
           adjustPosition(   );
           }
           if (  getOrientation(   ).isValid(   ) ) {
           getSceneNode(   )->setOrientation(  Atlas2Ogre(  getOrientation(   ) ) );
           }
          
          }
          
          
     176  void EmberEntity::createSceneNode(  Ogre::SceneManager* sceneManager )
          {
           EmberEntity* container = getEmberLocation(   );
           if (  container == 0 ) {
           //S_LOG_VERBOSE(   "Entity created in limbo: "<< this->getId(   ) << " (  " << this->getName(   ) << " )"  )
          
           mOgreNode = sceneManager->createSceneNode(  getId(   ) );
          
           } else {
           Ogre::SceneNode * node = container->getSceneNode(   );
           mOgreNode = node->createChildSceneNode(  getId(   ) );
           }
          }
          
     190  void EmberEntity::updateMotion(  Ogre::Real timeSlice )
          {
           getSceneNode(   )->setPosition(  Atlas2Ogre(  getPredictedPos(   ) ) );
           adjustPosition(   );
          
           //if there's a debug bounding box for the eris entity,   update it's position
           if (  mErisEntityBoundingBox ) {
           mErisEntityBoundingBox->getParentSceneNode(   )->setPosition(  getSceneNode(   )->getPosition(   ) );
           mErisEntityBoundingBox->getParentSceneNode(   )->setOrientation(  getSceneNode(   )->getOrientation(   ) );
           }
          
          }
          
          
          
          
     206  void EmberEntity::onMoved(   )
          {
           Eris::Entity::onMoved(   );
           const WFMath::Quaternion& orient = getOrientation(   );
           getSceneNode(   )->setOrientation(  Atlas2Ogre(  orient ) );
           updateMotion(  0 );
          }
          
     214  void EmberEntity::setMoving(  bool moving )
          {
           // Call the overridden method
           Eris::Entity::setMoving(  moving );
          
           MotionManager* motionManager = &MotionManager::getSingleton(   );
           if (  moving ) {
           //the entity is moving
           if (  !mIsInMotionManager ) {
           motionManager->addEntity(  this );
           mIsInMotionManager = true;
           }
           } else {
           //the entity has stopped moving
           if (  mIsInMotionManager ) {
           motionManager->removeEntity(  this );
           mIsInMotionManager = false;
           }
           }
          
          
          
          }
          
     238  void EmberEntity::onTalk(  const Atlas::Objects::Operation::RootOperation& talkArgs )
          {
           const std::vector<Atlas::Objects::Root>& args = talkArgs->getArgs(   );
           if (  args.empty(   ) ) {
           Eris::Entity::onTalk(  talkArgs );
           return;
           }
          
           const Atlas::Objects::Root& talk = args.front(   );
          
          
           if (  !talk->hasAttr(  "say" ) ) {
           Eris::Entity::onTalk(  talkArgs );
           return;
           }
          
          
           ///some talk operations come with a predefined set of suitable responses,   so we'll store those so that they can later on be queried by the GUI for example
           mSuggestedResponses.clear(   );
           if (  talk->hasAttr(  "responses" ) ) {
           if (  talk->getAttr(  "responses" ).isList(   ) ) {
           const Atlas::Message::ListType & responseList = talk->getAttr(  "responses" ).asList(   );
           Atlas::Message::ListType::const_iterator I = responseList.begin(   );
           for(  ; I != responseList.end(   ); ++I ) {
           mSuggestedResponses.push_back(  I->asString(   ) );
           }
          
           }
           }
          
           const std::string& msg = talk->getAttr(  "say" ).asString(   );
          
          
          
          
           std::string message = "<";
           message.append(  getName(   ) );
           message.append(  ",  " );
           const std::string& type = getType(   )->getName(   ); // Eris type as a string
           message.append(  type );
           message.append(  "> " );
           message.append(  msg );
           S_LOG_VERBOSE(   "Entity says: [" << message << "]\n"  )
          
           /// Make the message appear in the chat box
           GUIManager::getSingleton(   ).AppendIGChatLine.emit(  msg,   this );
          
           /// Make a sound in OpenAL
          // Ember::EmberServices::getSingleton(   ).getSoundService(   )->playTalk(  msg,  
          // getPosition(   ),  getOrientation(   ) );
          
           /// Call the method of the base class (  since we've overloaded it )
           Eris::Entity::onTalk(  talkArgs );
          }
          
          
     294  void EmberEntity::onSoundAction(   const Atlas::Objects::Operation::RootOperation & op  )
          {
           Eris::Entity::onSoundAction(  op );
          }
          
          
     300  void EmberEntity::onVisibilityChanged(  bool vis )
          {
           checkVisibility(  vis );
           Eris::Entity::onVisibilityChanged(  vis );
          }
          
     306  void EmberEntity::checkVisibility(  bool vis )
          {
           ///since we don't want to show all entities solely by their server flags (  for example,   an inventory item belonging to a character might not be shown even though the server thinks it's visible ) we have to some more checks before we decide whether to show this or not
           EmberEntity* container = static_cast<EmberEntity*>(  getLocation(   ) );
           if (  container ) {
           ///check with the parent first if we should show ourselves
           if (  vis && container->allowVisibilityOfMember(  this ) ) {
           ///don't cascade,   only change the top node
           setVisible(  true );
           } else {
           setVisible(  false );
           }
          
           } else {
           setVisible(  vis );
           }
          }
          
          
     325  void EmberEntity::setVisible(  bool visible )
          {
           ///when entities are hidden,   we detach them from the rendering scene graph altogether. this speeds up Ogre since it doesn't have to calculate visibility for nodes that are hidden anyway
           if (  !visible ) {
           if (  getSceneNode(   )->getParent(   ) ) {
           getSceneNode(   )->getParent(   )->removeChild(  getSceneNode(   ) );
           }
           } else {
           if (  getLocation(   ) ) {
           if (  !getSceneNode(   )->getParent(   ) ) {
           getEmberLocation(   )->getSceneNode(   )->addChild(  getSceneNode(   ) );
           }
           }
           }
          
           getSceneNode(   )->setVisible(  visible && getLocation(   ),   false );
          }
          
          
     344  void EmberEntity::adjustPosition(   )
          {
           if (  getPredictedPos(   ).isValid(   ) ) {
           adjustPosition(  Atlas2Ogre(   getPredictedPos(   )  ) );
           }
          }
          
     351  void EmberEntity::adjustPosition(  const Ogre::Vector3& position )
          {
           if (  mMovementMode == MM_FIXED ) {
          
           } else {
           EmberEntity* container = getEmberLocation(   );
           if (  container ) {
           container->adjustPositionForContainedNode(  this,   position );
           }
           }
          }
          
     363  const Ogre::Vector3& EmberEntity::getOffsetForContainedNode(  const Ogre::Vector3& localPosition,   EmberEntity* const entity )
          {
           ///send it upwards until we get a an entity which knows how to set the position (  we'll in most cases end up in the world which will adjust the height a bit )
           EmberEntity* container = getEmberLocation(   );
           if (  container ) {
           //TerrainPosition derivedPosition(  getPredictedPos(   ).x(   ) + position.x(   ),   getPredictedPos(   ).y(   ) + position.y(   ) );
           return container->getOffsetForContainedNode(  localPosition + getSceneNode(   )->getPosition(   ),   entity );
           } else {
           return Ogre::Vector3::ZERO;
           }
          
          
          }
          
          
          
     379  void EmberEntity::adjustPositionForContainedNode(  EmberEntity* const entity,   const Ogre::Vector3& position )
          {
          
           Ogre::SceneNode* sceneNode = entity->getSceneNode(   );
           //Ogre::Vector3 position = sceneNode->getPosition(   );
           const Ogre::Vector3& offset = getOffsetForContainedNode(  position,   entity );
           if (  offset != Ogre::Vector3::ZERO ) {
           sceneNode->setPosition(  position + offset );
           }
          
          }
          
     391  void EmberEntity::onLocationChanged(  Eris::Entity *oldLocation )
          {
          
           if (  getLocation(   ) == oldLocation )
           {
           S_LOG_WARNING(   "Same new location as old for entity: " << this->getId(   ) << " (  " << this->getName(   ) << " )"  );
           return Eris::Entity::onLocationChanged(  oldLocation );
          
           }
           Eris::Entity::onLocationChanged(  oldLocation );
          
           ///if we're attached to something,   detach from it
           detachFromModel(   );
          
           if (  !getLocation(   ) ) {
           return;
           } else {
           EmberEntity* newLocationEntity = getEmberLocation(   );
          
           const Ogre::Vector3 oldWorldPosition = getSceneNode(   )->getWorldPosition(   );
          // const Ogre::Quaternion oldWorldOrientation = getSceneNode(   )->getWorldOrientation(   );
          
           if (  getSceneNode(   )->getParentSceneNode(   ) ) {
           ///detach from our current object
           getSceneNode(   )->getParentSceneNode(   )->removeChild(  getSceneNode(   )->getName(   ) );
           }
           if (  newLocationEntity ) {
           // add to the new entity
           newLocationEntity->getSceneNode(   )->addChild(  getSceneNode(   ) );
           S_LOG_VERBOSE(   "Entity: " << this->getId(   ) << " (  " << this->getName(   ) << " ) relocated to: "<< newLocationEntity->getId(   ) << " (  " << newLocationEntity->getName(   ) << " )"  );
           if (  getPosition(   ).isValid(   ) ) {
           ///note that in some instances,   for instance when the avatar enters the sty,   the position isn't updated yet,   which will make the avatar "snap" to an incorrect position (  since the parent node has changed ) until next frame,   when the position should have been updated
           getSceneNode(   )->setPosition(  Atlas2Ogre(  getPredictedPos(   ) ) );
           adjustPosition(   );
           std::stringstream ss;
           ss << getPredictedPos(   );
           S_LOG_VERBOSE(  "New position for entity: " << this->getId(   ) << " (  " << this->getName(   ) << "  ) :" << ss.str(   ) );
           }
           if (  getOrientation(   ).isValid(   ) ) {
           getSceneNode(   )->setOrientation(  Atlas2Ogre(  getOrientation(   ) ) );
           std::stringstream ss;
           ss << getOrientation(   );
           S_LOG_VERBOSE(  "New orientation for entity: " << this->getId(   ) << " (  " << this->getName(   ) << "  ) :" << ss.str(   ) );
           }
          // getSceneNode(   )->rotate(  newLocationEntity->getSceneNode(   )->getWorldOrientation(   ) - oldWorldOrientation );
          
           } else {
           ///the entity has no current parent,   and should be placed in limbo (  hopefully a more correct parent will be submitted in a future LocationChanged event
           S_LOG_VERBOSE(   "Entity relocated to limbo: "<< this->getId(   ) << " (  " << this->getName(   ) << " )"  );
           // mSceneManager->getRootSceneNode(   )->addChild(  getSceneNode(   ) );
           }
          
           checkVisibility(  isVisible(   ) );
          
           ///we'll adjust the entity so it retains it's former position in the world,   but only for moving entities
           ///since else we'll get a "gap" when we're waiting on updated positions from the server
           ///this isn't optimal
           if (  isMoving(   ) ) {
           const Ogre::Vector3& newWorldPosition = getSceneNode(   )->getWorldPosition(   );
           getSceneNode(   )->translate(  oldWorldPosition - newWorldPosition );
           }
           }
          
          }
          
     456  void EmberEntity::onAction(  const Atlas::Objects::Operation::RootOperation& act )
          {
           const std::list<std::string> &p = act->getParents(   );
           std::list<std::string>::const_iterator I = p.begin(   );
          
           if (  I == p.end(   ) ) return;
          
           const std::string& name = *I;
           std::string message = getName(   ) + " performs a " + name + ".";
          
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  message );
          
           S_LOG_VERBOSE(   "Entity: " << this->getId(   ) << " (  " << this->getName(   ) << " ) action: " << name );
           Entity::onAction(  act );
          }
          
     472  void EmberEntity::onImaginary(  const Atlas::Objects::Root& act )
          {
           Atlas::Message::Element attr;
           if (  act->copyAttr(  "description",   attr ) && attr.isString(   ) ) {
           std::string message = getName(   ) + " " + attr.asString(   ) + ".";
          
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  message );
          
           S_LOG_VERBOSE(  "Entity: " << this->getId(   ) << " (  " << this->getName(   ) << " ) imaginary: " << attr.String(   ) );
           }
          
           Entity::onImaginary(  act );
          
          }
          
          
     488  bool EmberEntity::allowVisibilityOfMember(  EmberEntity* entity ) {
           return true;
          }
          
     492  const std::vector< std::string >& EmberEntity::getSuggestedResponses(    ) const
          {
           return mSuggestedResponses;
          }
          
     497  bool EmberEntity::hasSuggestedResponses(    ) const
          {
           return mSuggestedResponses.size(   ) > 0;
          }
          
          
     503  void EmberEntity::addArea(  Terrain::TerrainArea* area )
          {
          ///just pass it on to the parent until we get to someone who knows how to handle this (  preferrably the terrain )
           if (  getEmberLocation(   ) ) {
           getEmberLocation(   )->addArea(  area );
           }
          }
          
     511  void EmberEntity::onAttrChanged(  const std::string& str,   const Atlas::Message::Element& v )
          {
           if (  str == "mode" ) {
           parseModeChange(  v );
           } else if (  str == "bbox" ) {
           Entity::onAttrChanged(  str,   v );
           onBboxChanged(   );
           return;
           }
           Entity::onAttrChanged(  str,   v );
          }
          
     523  void EmberEntity::parseModeChange(  const Atlas::Message::Element& v )
          {
           const std::string& mode = v.asString(   );
           MovementMode newMode;
           if (  mode.empty(   ) ) {
           newMode = MM_DEFAULT;
           } else if (  mode == MODE_STANDING ) {
           newMode = MM_STANDING;
           } else if (  mode == MODE_RUNNING ) {
           newMode = MM_RUNNING;
           } else if (  mode == MODE_WALKING ) {
           newMode = MM_WALKING;
           } else if (  mode == MODE_SWIMMING ) {
           newMode = MM_SWIMMING;
           } else if (  mode == MODE_FLOATING ) {
           newMode = MM_FLOATING;
           } else if (  mode == MODE_FIXED ) {
           newMode = MM_FIXED;
           } else {
           newMode = MM_DEFAULT;
           }
          
           onModeChanged(  newMode );
          }
          
     548  void EmberEntity::onModeChanged(  MovementMode newMode )
          {
           if (  newMode == MM_FIXED ) {
           adjustPosition(   );
           }
           mMovementMode = newMode;
          }
          
     556  void EmberEntity::setVisualize(  const std::string& visualization,   bool visualize )
          {
           if (  visualization == "OgreBBox" ) {
           showOgreBoundingBox(  visualize );
           } else if (  visualization == "ErisBBox" ) {
           showErisBoundingBox(  visualize );
           }
          }
          
     565  bool EmberEntity::getVisualize(  const std::string& visualization ) const
          {
           if (  visualization == "OgreBBox" ) {
           return getShowOgreBoundingBox(   );
           } else if (  visualization == "ErisBBox" ) {
           return getShowErisBoundingBox(   );
           }
           return false;
          }
          
          
     576  void EmberEntity::showOgreBoundingBox(  bool show )
          {
           getSceneNode(   )->showBoundingBox(  show );
          }
          
     581  void EmberEntity::showErisBoundingBox(  bool show )
          {
          
           createErisBboxMaterial(   );
          
           ///if there's no bounding box,   create one now
           ///allowing for some lazy loading
           if (  !mErisEntityBoundingBox ) {
           mErisEntityBoundingBox = new Ogre::OOBBWireBoundingBox(   );
           mErisEntityBoundingBox->setMaterial(  BboxMaterialName );
           Ogre::SceneNode* boundingBoxNode = EmberOgre::getSingleton(   ).getWorldSceneNode(   )->createChildSceneNode(   );
           boundingBoxNode->attachObject(  mErisEntityBoundingBox );
          
           Ogre::AxisAlignedBox aabb(  Atlas2Ogre(  getBBox(   ) ) );
          
           mErisEntityBoundingBox->setupBoundingBox(  aabb );
          
           boundingBoxNode->setPosition(  Atlas2Ogre(  getPredictedPos(   ) ) );
           boundingBoxNode->setOrientation(  Atlas2Ogre(  getOrientation(   ) ) );
           }
           mErisEntityBoundingBox->setVisible(  show );
          
          }
          
     605  void EmberEntity::createErisBboxMaterial(   )
          {
           if (  !Ogre::MaterialManager::getSingleton(   ).resourceExists(  BboxMaterialName ) ) {
           Ogre::MaterialPtr baseYellowNoLighting = Ogre::MaterialManager::getSingleton(   ).create(  BboxMaterialName,  
           Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME );
           baseYellowNoLighting->setLightingEnabled(  false );
           baseYellowNoLighting->setAmbient(  Ogre::ColourValue(  1,   1,   0.7 ) );
           baseYellowNoLighting->setDiffuse(  Ogre::ColourValue(  1,   1,   0.7 ) );
           }
          }
          
     616  void EmberEntity::onBboxChanged(   )
          {
           if (  mErisEntityBoundingBox ) {
           mErisEntityBoundingBox->setupBoundingBox(  Atlas2Ogre(  getBBox(   ) ) );
           }
          }
          
          
     624  bool EmberEntity::getShowOgreBoundingBox(   ) const
          {
           return getSceneNode(   )->getShowBoundingBox(   );
          }
     628  bool EmberEntity::getShowErisBoundingBox(   ) const
          {
           return (  mErisEntityBoundingBox && mErisEntityBoundingBox->isVisible(   ) );
          
          }
          
          //inline
     635  Ogre::SceneNode* EmberEntity::getSceneNode(   ) const
          {
           return mOgreNode;
          }
          
     640  EmberEntity* EmberEntity::getEmberLocation(   ) const
          {
           return static_cast<EmberEntity*>(  getLocation(   ) );
          }
          
          
     646  const Ogre::AxisAlignedBox& EmberEntity::getWorldBoundingBox(  bool derive ) const
          {
           static Ogre::AxisAlignedBox boundingBox(  0,  0,  0,  0,  0,  0 );
           return boundingBox;
          }
          
     652  const Ogre::Sphere & EmberEntity::getWorldBoundingSphere (  bool derive ) const
          {
           static Ogre::Sphere sphere;
           return sphere;
          }
          
     658  std::vector<std::string> EmberEntity::getDefaultUseOperators(   )
          {
           ///get the use operations from Eris and return them a simple vector of strings
           std::vector<std::string> operators;
          
           Eris::TypeInfoArray types = getUseOperations(   );
          
           for (  Eris::TypeInfoArray::iterator I = types.begin(   ); I != types.end(   ); ++I ) {
           operators.push_back(  (  *I )->getName(   ) );
           }
          
           return operators;
          }
          
     672  Ogre::SceneManager* EmberEntity::getSceneManager(   )
          {
           assert(  mOgreNode );
           return mOgreNode->getCreator(   );
          }
          
     678  static void dumpElement(  const std::string &prefix,   const std::string &name,   const Atlas::Message::Element &e,   std::ostream& outstream,   std::ostream& logOutstream )
          {
          
           if (  e.isMap(   ) ) {
           logOutstream << prefix << name << ": Dumping Map" << std::endl;
           Atlas::Message::MapType::const_iterator itr = e.asMap(   ).begin(   );
           Atlas::Message::MapType::const_iterator end = e.asMap(   ).end(   );
           outstream << prefix << name << ":" << std::endl;
           for (  ; itr != end; ++itr ) {
           dumpElement(  prefix + " ",   itr->first,   itr->second,   outstream,   logOutstream );
           }
           logOutstream << prefix << "Finished Dumping Map" << std::endl;
           } else if (  e.isList(   ) ) {
           logOutstream << prefix << name << ": Dumping List" << std::endl;
           Atlas::Message::ListType::const_iterator itr = e.asList(   ).begin(   );
           Atlas::Message::ListType::const_iterator end = e.asList(   ).end(   );
           outstream << prefix << name << ":" << std::endl;
           for (  ; itr != end; ++itr ) {
           dumpElement(  prefix + " ",   "",   *itr,   outstream,   logOutstream );
           }
           logOutstream << prefix << "Finished Dumping List" << std::endl;
           } else {
           if (  e.isString(   ) ) outstream << prefix << name << ": " << e.asString(   ) << std::endl;
           if (  e.isNum(   ) ) outstream << prefix << name << ": " << e.asNum(   ) << std::endl;
           }
          }
          
     705  void EmberEntity::dumpAttributes(  std::iostream& outstream,   std::ostream& logOutstream ) const
          {
           logOutstream << "Dumping attributes for entity " << getId(   ) << "(  " << getName(   ) << " )" << std::endl;
          
           Atlas::Message::QueuedDecoder decoder;
           //std::fstream file;
          
           Atlas::Codecs::XML codec(  outstream,   decoder );
           Atlas::Formatter formatter(  outstream,   codec );
           Atlas::Message::Encoder encoder(  formatter );
           formatter.streamBegin(   );
           encoder.streamMessageElement(  getAttributes(   ) );
          
           formatter.streamEnd(   );
          
          
          // const Eris::Entity::AttrMap &attribs = getAttributes(   );
          
          // Eris::Entity::AttrMap::const_iterator itr = attribs.begin(   );
          // Eris::Entity::AttrMap::const_iterator end = attribs.end(   );
          // for (  ; itr != end; ++itr ) {
          // dumpElement(  "",  itr->first,   itr->second,   outstream,   logOutstream );
          // }
          }
          
          }
          
          
          
          
          

./components/ogre/EmberEntity.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef DIMEENTITY_H
          #define DIMEENTITY_H
          
          #include "EmberOgrePrerequisites.h"
          
          
          #include <Atlas/Objects/Entity.h>
          #include <Atlas/Objects/Operation.h>
          
          #include <Eris/Entity.h>
          
          namespace Ogre
          {
      32   class OOBBWireBoundingBox;
          }
          
          namespace Mercator
          {
      37   class Area;
          }
          
      40  namespace Eris
          {
           class View;
          }
          
          namespace EmberOgre {
          
          namespace Model {
      48   class Model;
          }
          
      51  namespace Terrain
          {
           class TerrainArea;
          }
          
      56  class EmberEntityFactory;
          /**
           * A representation of an Eris::Entity,   ie. a world entity.
           * Note that most entities in the game world will be of type EmberPhysicalEntity
           * as they will have some sort of physical representation.
           * For things such as boundaries and weather,   this is a nice class.
           */
      63  class EmberEntity : public Eris::Entity {
      64   friend class EmberEntityFactory;
          public:
          
          
           enum MovementMode
           {
           MM_DEFAULT = 0,  
           MM_STANDING = 1,  
           MM_FLOATING = 2,  
           MM_PROJECTILE = 3,  
           MM_SWIMMING = 4,  
           MM_WALKING = 5,  
           MM_RUNNING = 6,  
           MM_FIXED = 7
           };
          
      80   static const std::string MODE_STANDING;
      81   static const std::string MODE_RUNNING;
      82   static const std::string MODE_WALKING;
      83   static const std::string MODE_SWIMMING;
      84   static const std::string MODE_FLOATING;
      85   static const std::string MODE_FIXED;
          
           /**
           The material used for showing the eris bbox.
           */
      90   static const std::string BboxMaterialName;
          
          
          
      94   EmberEntity(  const std::string& id,   Eris::TypeInfo* ty,   Eris::View* vw,  Ogre::SceneManager* sceneManager );
      95   virtual ~EmberEntity(   );
          
          
           /**
           * Called by contained entites to determine how they should be adjusted,   for example snap to the ground.
           * For instance a house entitiy containing a player entity.
           * This should of course be extended to a more dynamic physics simulation
           * in the future
           */
     104   virtual void adjustPositionForContainedNode(  EmberEntity* const entity,   const Ogre::Vector3& position );
          
          
           /**
           * Adjust the height of the entity so that it "snaps" to the ground.
           * This is most often done by making a call to the containing node's
           * adjustPositionForContainedNode method.
           */
     112   virtual void adjustPosition(   );
     113   virtual void adjustPosition(  const Ogre::Vector3& position );
          
           /**
           * return the scenenode to which this entity belongs
           */
     118   Ogre::SceneNode* getSceneNode(   ) const;
          
           /**
           * Called by a contained member to see if the member is allowed to be shown.
           * This can be reimplemented in a subclass such as AvatarEmberEntity to
           * disallow things that belongs to a characters inventory to be shown.
           */
     125   virtual bool allowVisibilityOfMember(  EmberEntity* entity );
          
          
           /**
           *return true if the entity has a list of suggested responses
           */
     131   bool hasSuggestedResponses(   ) const;
          
           /**
           * returns a list of all suggested responses
           */
     136   const std::vector< std::string >& getSuggestedResponses(   ) const;
          
          
           /**
           * Sets the visibity of the Entity
           * @param visible
           */
     143   virtual void setVisible(  bool visible );
          
          
           /**
           * gets the location as cast to an EmberEntity
           * @return
           */
     150   EmberEntity* getEmberLocation(   ) const;
          
           /**
           attaches the entity to another entity (  or in reality another Model )
           */
     155   virtual void attachToPointOnModel(  const std::string& point,   Model::Model* model ) {};
          
           /**
           detaches the entity from another entity (  or in reality another Model )
           */
     160   virtual void detachFromModel(   ) {};
          
           /**
           if this is true,   init(  ... ) has been called and the entity been set up
           */
     165   inline bool isInitialized(   ) const;
          
           /**
           the mode the entity is in,   like walking,   running,   swimming etc.
           */
     170   inline MovementMode getMovementMode(   ) const;
          
           /**
           Call this method once per frame to update the motion of the entity
           */
     175   virtual void updateMotion(  Ogre::Real timeSlice );
          
           /**
           For debugging.
           Shows the Ogre bounding box.
           */
     181   virtual void showOgreBoundingBox(  bool show );
          
          
           /**
           For debugging.
           Shows the eris/atlas bounding box.
           @see mErisEntityBoundingBox
           */
     189   virtual void showErisBoundingBox(  bool show );
          
           /**
           returns whether the ogre bounding box is shown
           */
     194   virtual bool getShowOgreBoundingBox(   ) const;
          
           /**
           returns whether the eris/atlas bounding box is shown
           @see mErisEntityBoundingBox
           */
     200   virtual bool getShowErisBoundingBox(   ) const;
          
           /**
           * returns the world bounding box of the entity
           * @param derive whether to derive from attached objects too
           * @return
           */
     207   virtual const Ogre::AxisAlignedBox& getWorldBoundingBox(  bool derive = true ) const;
          
          
     210   virtual const Ogre::Sphere & getWorldBoundingSphere (  bool derive=true ) const;
          
           /**
           * Returns a list of the default use operators that can be used with this entity.
           For example,   an axe would have a list of operators such as "chop" and "sharpen".
           * @return
           */
     217   std::vector<std::string> getDefaultUseOperators(   );
          
          
           /**
           * Synchronizes the position and orientation of the entity with the server.
           */
     223   void synchronizeWithServer(   );
          
          
           /**
           Dumps all of this entity's attributes to the supplied outstream.
           */
     229   void dumpAttributes(  std::iostream& outstream,   std::ostream& logOutstream ) const;
          
           /**
           * General method for turning on and off debug visualizations. Subclasses might support more types of visualizations than the ones defined here.
           * @param visualization The type of visualization. Currently supports "OgreBBox" and "ErisBBox".
           * @param visualize Whether to visualize or not.
           */
     236   virtual void setVisualize(  const std::string& visualization,   bool visualize );
          
          
           /**
           * Gets whether a certain visualization is turned on or off.
           * @param visualization The type of visualization. Currently supports "OgreBBox" and "ErisBBox".
           * @return true if visualization is turned on,   else false
           */
     244   virtual bool getVisualize(  const std::string& visualization ) const;
          
          protected:
          
          
           /**
           * Gets the position of a contained node.
           * @param position
           * @param entity
           * @return
           */
     255   virtual const Ogre::Vector3& getOffsetForContainedNode(  const Ogre::Vector3& position,   EmberEntity* const entity );
          
          
           /**
           if this is true,   init(  ... ) has been called and the entity been set up
           */
     261   bool mIsInitialized;
          
           /**
           if true,   the entity is already registered with the motion manager,   so we don't need to add it again (  which can be expensive since
           the motionmanager holds all entities needing updated motions in a std::set )
           */
     267   bool mIsInMotionManager;
          
           /**
           * Overridden from Eris::Entity
           * @see Eris::Entity
           */
     273   virtual void onMoved(   );
     274   virtual void setMoving(  bool moving );
     275   virtual void onTalk(  const Atlas::Objects::Operation::RootOperation& talk );
          // virtual void setContainer(  Entity *pr );
     277   virtual void onVisibilityChanged(  bool vis );
     278   virtual void onLocationChanged(  Eris::Entity *oldLocation );
     279   virtual void onAction(  const Atlas::Objects::Operation::RootOperation& act );
     280   virtual void onImaginary(  const Atlas::Objects::Root& act );
     281   virtual void onSoundAction(  const Atlas::Objects::Operation::RootOperation& op );
          
     283   virtual void addArea(  Terrain::TerrainArea* area );
     284   virtual void onAttrChanged(  const std::string& str,   const Atlas::Message::Element& v );
          
          
     287   virtual void onModeChanged(  MovementMode newMode );
          
           /**
           * Called when the bounding box has changed.
           */
     292   virtual void onBboxChanged(   );
          
           /**
          
           For debugging purposes. This holds a bounding box of how the entity appears in the eris/atlas world.
           This is often different from the Ogre bounding box.
           */
     299   Ogre::OOBBWireBoundingBox* mErisEntityBoundingBox;
          
           /**
           * Creates the material used for the eris bboxes,   if not already created.
           */
     304   void createErisBboxMaterial(   );
          
          
          
           /**
           * Creates the main scene node which holds the entity.
           */
     311   void createSceneNode(  Ogre::SceneManager* sceneManager );
          
           /**
           override from eris
           this is called by eris just after the entity has been put into the world
           */
     317   virtual void init(  const Atlas::Objects::Entity::RootEntity &ge,   bool fromCreateOp );
          
     319   virtual void checkVisibility(  bool vis );
          
           /**
           Sometimes when talking to an entity,   the server will provide suggested responses. These are stored here.
           */
     324   std::vector<std::string> mSuggestedResponses;
          
           /**
           * The main SceneNode which holds the entity in the ogre world space.
           */
     329   Ogre::SceneNode* mOgreNode;
          
           /**
           Gets the scene manager that manages the Ogre scene node held by this.
           */
     334   Ogre::SceneManager* getSceneManager(   );
          
           /**
           If there's a terrainarea belonging to this entity,   that's stored here.
           */
     339   std::auto_ptr<Terrain::TerrainArea> mTerrainArea;
          
          
           /**
           the mode the entity is in,   like walking,   running,   swimming etc.
           */
           MovementMode mMovementMode;
          
          
           /**
           * parses the current mode from the submitted element,   which should be taken from the "mode" attribute
           * this method will in turn call onModeChanged if the mode is changed
           * @param v
           */
     353   void parseModeChange(  const Atlas::Message::Element& v );
          
          };
          
          
          ///inline implementations
     359   bool EmberEntity::isInitialized(   ) const
           {
           return mIsInitialized;
           }
          
     364   EmberEntity::MovementMode EmberEntity::getMovementMode(   ) const
           {
           return mMovementMode;
           }
          
          
          }
          
          #endif // DIMEENTITY_H

./components/ogre/EmberEntityActionCreator.cpp

       1  //
          // C++ Implementation: EmberEntityActionCreator
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EmberEntityActionCreator.h"
          #include "EmberEntityModelAction.h"
          #include "EmberEntityPartAction.h"
          #include "model/mapping/Cases/CaseBase.h"
          
          using namespace EmberOgre::Model::Mapping;
          
          namespace EmberOgre {
          
      32  EmberEntityActionCreator::EmberEntityActionCreator(  EmberPhysicalEntity& entity )
          : mEntity(  entity )
          {
          }
          
          
      38  EmberEntityActionCreator::~EmberEntityActionCreator(   )
          {
          }
          
      42  void EmberEntityActionCreator::createActions(  ModelMapping& modelMapping,   Cases::CaseBase* aCase,   Definitions::CaseDefinition& caseDefinition )
          {
           Definitions::CaseDefinition::ActionStore::iterator endJ = caseDefinition.getActions(   ).end(   );
           for (  Definitions::CaseDefinition::ActionStore::iterator J = caseDefinition.getActions(   ).begin(   ); J != endJ; ++J ) {
           if (  J->getType(   ) == "display-part" ) {
           EmberEntityPartAction* action = new EmberEntityPartAction(  mEntity,   J->getValue(   ) );
           aCase->addAction(  action );
           } else if (  J->getType(   ) == "display-model" ) {
           EmberEntityModelAction* action = new EmberEntityModelAction(  mEntity,   J->getValue(   ) );
           aCase->addAction(  action );
           }
           }
          
          }
          
          }

./components/ogre/EmberEntityActionCreator.h

       1  //
          // C++ Interface: EmberEntityActionCreator
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREEMBERENTITYACTIONCREATOR_H
          #define EMBEROGREEMBERENTITYACTIONCREATOR_H
          #include "EmberOgrePrerequisites.h"
          #include "EmberPhysicalEntity.h"
          
          #include "model/mapping/ModelMapping.h"
          #include "model/mapping/Definitions/ModelMappingDefinition.h"
          #include "model/mapping/ModelMappingManager.h"
          #include "model/mapping/IActionCreator.h"
          
          namespace EmberOgre {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      38  class EmberEntityActionCreator : public Model::Mapping::IActionCreator
          {
          public:
      41   EmberEntityActionCreator(  EmberPhysicalEntity& entity );
          
      43   ~EmberEntityActionCreator(   );
      44   virtual void createActions(  Model::Mapping::ModelMapping& modelMapping,   Model::Mapping::Cases::CaseBase* aCase,   Model::Mapping::Definitions::CaseDefinition& caseDefinition );
          protected:
      46   EmberPhysicalEntity& mEntity;
          
          
          };
          
          }
          
          #endif

./components/ogre/EmberEntityFactory.cpp

          /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "EmberEntityFactory.h"
          
          #include <Eris/Entity.h>
          #include <Eris/View.h>
          #include <Eris/TypeInfo.h>
          #include <Eris/Avatar.h>
          
          #include "services/server/ServerService.h"
          #include "services/EmberServices.h"
          
          
          #include "EmberEntity.h"
          #include "WorldEmberEntity.h"
          #include "EmberPhysicalEntity.h"
          #include "AvatarEmberEntity.h"
          #include "EmberOgre.h"
          
          
          #include "model/Model.h"
          #include "model/ModelDefinition.h"
          #include "model/ModelDefinitionManager.h"
          #include "model/mapping/EmberModelMappingManager.h"
          
          
          
          #include "framework/ConsoleBackend.h"
          #include "terrain/TerrainGenerator.h"
          
          #include "Avatar.h"
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include "framework/osdir.h"
          
          #ifdef WIN32
           #include <tchar.h>
           #define snprintf _snprintf
           #include <io.h> // for _access,   Win32 version of stat(   )
           #include <direct.h> // for _mkdir
          // #include <sys/stat.h>
          
           #include <iostream>
           #include <fstream>
           #include <ostream>
          #else
           #include <dirent.h>
          #endif
          
          namespace EmberOgre {
          
          
      74  EmberEntityFactory::EmberEntityFactory(  Eris::View* view,   Terrain::TerrainGenerator* terrainGenerator,   Eris::TypeService* typeService )
          : ShowModels(  "showmodels",   this,   "Show or hide models." )
      76  ,   DumpAttributes(  "dump_attributes",   this,   "Dumps the attributes of a supplied entity to a file. If no entity id is supplied the current avatar will be used." )
          ,   mTerrainGenerator(  terrainGenerator )
          ,   mTypeService(  typeService )
          ,   mTerrainType(  0 )
          ,   mWorldEntity(  0 )
          ,   mView(  view )
          {
           mView->registerFactory(  this );
          
           mTerrainType = mTypeService->getTypeByName(  "world" );
          
           getErisAvatar(   )->GotCharacterEntity.connect(  sigc::mem_fun(  *this,   &EmberEntityFactory::gotAvatarCharacter ) );
          
          }
          
          
          
      93  EmberEntityFactory::~EmberEntityFactory(   )
          {
          /// there is no way to deregister the factory from the View,   instead the View will delete the factory when deleted
          // mView->deregisterFactory(  this );
          }
          
          /// create whatever entity the client desires
     100  Eris::Entity* EmberEntityFactory::instantiate(  const Atlas::Objects::Entity::RootEntity &ge,   Eris::TypeInfo* type,   Eris::View* w )
          {
          
           Eris::Entity* emberEntity(  0 );
          
           bool isPhysical = Model::Mapping::EmberModelMappingManager::getSingleton(   ).getManager(   ).getDefinitionForType(  type ) != 0;
          
           if (  ge->getId(   ) == getErisAvatar(   )->getId(   ) ) {
          
           AvatarEmberEntity* avatarEntity = createAvatarEntity(  ge,   type,   w );
           emberEntity = avatarEntity;
          
           } else if (  type->isA(  mTerrainType ) ) {
          
           emberEntity = createWorld(  ge,   type,   w );
          
           } else if (  !isPhysical ) {
           S_LOG_VERBOSE(  "Creating immaterial entity." );
          
           ///we don't want this to have any Ogre::Entity
           emberEntity = new EmberEntity(  ge->getId(   ),   type,   w,   EmberOgre::getSingleton(   ).getSceneManager(   ) );
          
           } else {
          
           emberEntity = createPhysicalEntity(  ge,   type,   w );
          
           }
          
           S_LOG_VERBOSE(  "Entity added to game view." );
           return emberEntity;
          }
          
     132  bool EmberEntityFactory::accept(  const Atlas::Objects::Entity::RootEntity &ge,   Eris::TypeInfo* type )
          {
           return true;
          }
          
          
     138  Eris::Entity* EmberEntityFactory::createWorld(  const Atlas::Objects::Entity::RootEntity & ge,   Eris::TypeInfo* type,   Eris::View *world ) {
           assert(  !mWorldEntity );
           mWorldEntity = new WorldEmberEntity(  ge->getId(   ),   type,   world,   EmberOgre::getSingleton(   ).getSceneManager(   ),   mTerrainGenerator );
           return mWorldEntity;
          }
          
     144  WorldEmberEntity* EmberEntityFactory::getWorld(   ) const
          {
           return mWorldEntity;
          }
          
     149  void EmberEntityFactory::gotAvatarCharacter(  Eris::Entity* entity )
          {
           AvatarEmberEntity* avatarEntity = static_cast<AvatarEmberEntity*>(  entity );
           EmberOgre::getSingleton(   ).getAvatar(   )->createdAvatarEmberEntity(  avatarEntity );
           EmberOgre::getSingleton(   ).EventCreatedAvatarEntity.emit(  avatarEntity );
          }
          
          
          
          
          
          
     161  EmberPhysicalEntity* EmberEntityFactory::createPhysicalEntity(  const Atlas::Objects::Entity::RootEntity &ge,  Eris::TypeInfo* type,   Eris::View *world ) {
          
           EmberPhysicalEntity* entity = new EmberPhysicalEntity(  ge->getId(   ),   type,   world,   EmberOgre::getSingleton(   ).getSceneManager(   ) );
          
           return entity;
          
          }
          
     169  AvatarEmberEntity* EmberEntityFactory::createAvatarEntity(  const Atlas::Objects::Entity::RootEntity &ge,   Eris::TypeInfo* type,   Eris::View *world )
          {
           return new AvatarEmberEntity(  ge->getId(   ),   type,   world,  EmberOgre::getSingleton(   ).getSceneManager(   ),   getErisAvatar(   ) );
          }
          
     174  int EmberEntityFactory::priority(   ) {
           return 10;
          }
          
     178  Eris::Avatar* EmberEntityFactory::getErisAvatar(   )
          {
           return mView->getAvatar(   );
          }
          
     183  void EmberEntityFactory::dumpAttributesOfEntity(  const std::string& entityId ) const
          {
           EmberEntity* entity = EmberOgre::getSingleton(   ).getEmberEntity(  entityId );
           if (  entity ) {
           ///make sure the directory exists
           std::string dir(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ) + "/entityexport/" );
          
           if (  !oslink::directory(  dir ).isExisting(   ) ) {
           S_LOG_INFO(  "Creating directory " << dir );
          #ifdef __WIN32__
           mkdir(  dir.c_str(   ) );
          #else
           mkdir(  dir.c_str(   ),   S_IRWXU );
          #endif
           }
          
           const std::string fileName(  dir + entityId + ".atlas" );
           std::fstream exportFile(  fileName.c_str(   ),   std::fstream::out );
          
           S_LOG_INFO(  "Dumping attributes to " << fileName );
           entity->dumpAttributes(  exportFile,   std::cout );
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  std::string(  "Dumped attributes to " ) + fileName );
           }
          }
          
          
     209  void EmberEntityFactory::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  command == ShowModels.getCommand(   ) )
           {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string value = tokeniser.nextToken(   );
           if (  value == "true" ) {
           S_LOG_INFO(  "Showing models." );
           Model::ModelDefinitionManager::getSingleton(   ).setShowModels(  true );
           } else if (  value == "false" ) {
           S_LOG_INFO(  "Hiding models." );
           Model::ModelDefinitionManager::getSingleton(   ).setShowModels(  false );
           }
           } else if (  DumpAttributes == command ) {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string value = tokeniser.nextToken(   );
           if (  value == "" ) {
           if (  getErisAvatar(   ) ) {
           dumpAttributesOfEntity(  getErisAvatar(   )->getEntity(   )->getId(   ) );
           }
           } else {
           dumpAttributesOfEntity(  value );
           }
           }
          }
          
          
          
          
          }
          

./components/ogre/EmberEntityFactory.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef DIMEENTITYFACTORY_H
          #define DIMEENTITYFACTORY_H
          #include "EmberOgrePrerequisites.h"
          
          #include <Eris/Factory.h>
          
          #include <Atlas/Objects/Entity.h>
          
          #include <sigc++/trackable.h>
          
          #include "framework/ConsoleObject.h"
          namespace Eris
          {
      32   class Entity;
      33   class View;
      34   class TypeService;
      35   class TypeInfo;
      36   class Avatar;
          }
          
          namespace EmberOgre {
          
          namespace Terrain
          {
      43  class TerrainGenerator;
          }
          
          class AvatarEmberEntity;
      47  class EmberTerrainPageSource;
      48  class EmberPhysicalEntity;
      49  class EmberEntity;
      50  class ViewEmberEntity;
      51  class WorldEmberEntity;
          
          /**
           * Creates the EmberEntities required.
           * Basically this attaches to Eris and creates Entites on demand.
           * @see Eris::Factory
           *
           */
      59  class EmberEntityFactory :
      60  public Eris::Factory,  
      61  public sigc::trackable,  
      62  public Ember::ConsoleObject
          {
          public:
          
           typedef std::set<Ogre::String> StringSet;
          
          
           /**
           Default constructor. This should be instantiated by EmberOgre or similiar high level object. Note that Eris upon shutdown will delete all registered factories,   so don't delete an instance of this yourself.
           */
      72   EmberEntityFactory(  Eris::View* view,   Terrain::TerrainGenerator* terrainGenerator,   Eris::TypeService* typeService );
      73   virtual ~EmberEntityFactory(   );
          
           /**
           Will always return true.
           */
      78   virtual bool accept(  const Atlas::Objects::Entity::RootEntity &ge,   Eris::TypeInfo* type );
          
           /**
           Creates instances of EmberEntity and its subclasses.
           */
      83   virtual Eris::Entity* instantiate(  const Atlas::Objects::Entity::RootEntity &ge,   Eris::TypeInfo* type,   Eris::View* w );
          
           /** retrieve this factory's priority level; higher priority factories
           get first chance to process a recieved Atlas entity. The default implementation
           returns one. */
      88   virtual int priority(   );
          
           /**
           Returns the main world entity.
           */
      93   WorldEmberEntity* getWorld(   ) const;
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
     100   virtual void runCommand(  const std::string &command,   const std::string &args );
          
          
           /**
           Command for setting whether models should be shown or not.
           */
     106   const Ember::ConsoleCommandWrapper ShowModels;
          
           /**
           Dumps the attributes of a supplied entity to the std::out.
           */
     111   const Ember::ConsoleCommandWrapper DumpAttributes;
          
          
           /**
           * Dumps the attributes of the entity with the supplied id to the std::out.
           * @param entityId
           * @return
           */
     119   void dumpAttributesOfEntity(  const std::string& entityId ) const;
          
          protected:
          
          
           /**
           Creates a WorldEmberEntity instance.
           */
     127   Eris::Entity* createWorld(  const Atlas::Objects::Entity::RootEntity & ge,  Eris::TypeInfo* type,   Eris::View *world );
           /**
           Creates a EmberPhysicalEntity instance.
           */
     131   EmberPhysicalEntity* createPhysicalEntity(  const Atlas::Objects::Entity::RootEntity &ge,   Eris::TypeInfo* type,   Eris::View *world );
           /**
           Creates a AvatarEmberEntity instance.
           */
     135   AvatarEmberEntity* createAvatarEntity(  const Atlas::Objects::Entity::RootEntity &ge,   Eris::TypeInfo* type,   Eris::View *world );
          
     137   void gotAvatarCharacter(  Eris::Entity* entity );
          
          
          
     141   Terrain::TerrainGenerator* mTerrainGenerator;
     142   Eris::TypeService* mTypeService;
     143   Eris::TypeInfo* mTerrainType;
          
     145   Eris::Avatar* getErisAvatar(   );
          
     147   WorldEmberEntity *mWorldEntity;
          
     149   Eris::View* mView;
          
          
          };
          
          }
          
          #endif // DIMEENTITYFACTORY_H

./components/ogre/EmberEntityModelAction.cpp

       1  //
          // C++ Implementation: EmberEntityModelAction
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EmberEntityModelAction.h"
          
          namespace EmberOgre {
          
      27  EmberEntityModelAction::EmberEntityModelAction(  EmberPhysicalEntity& entity,   std::string modelName )
          : mEntity(  entity ),   mModelName(  modelName )
          {
          }
          
          
      33  EmberEntityModelAction::~EmberEntityModelAction(   )
          {
          }
          
      37  void EmberEntityModelAction::activate(   )
          {
           mEntity.setModel(  mModelName );
           S_LOG_VERBOSE(  "Showing model " << mModelName );
          }
          
      43  void EmberEntityModelAction::deactivate(   )
          {
           mEntity.setModel(  "" );
           S_LOG_VERBOSE(  "Hiding model " << mModelName );
          }
          
          
          }

./components/ogre/EmberEntityModelAction.h

       1  //
          // C++ Interface: EmberEntityModelAction
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREEMBERENTITYMODELACTION_H
          #define EMBEROGREEMBERENTITYMODELACTION_H
          
          #include "EmberOgrePrerequisites.h"
          #include "EmberPhysicalEntity.h"
          
          // #include "model/mapping/ModelMapping.h"
          #include "model/mapping/Actions/Action.h"
          
          namespace EmberOgre {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      37  class EmberEntityModelAction : public Model::Mapping::Actions::Action
          {
          public:
      40   EmberEntityModelAction(  EmberPhysicalEntity& entity,   std::string modelName );
      41   ~EmberEntityModelAction(   );
          
      43   virtual void activate(   );
      44   virtual void deactivate(   );
          
          protected:
      47   EmberPhysicalEntity& mEntity;
          
      49   std::string mModelName;
          };
          
          }
          
          #endif

./components/ogre/EmberEntityPartAction.cpp

       1  //
          // C++ Implementation: EmberEntityPartAction
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "EmberEntityPartAction.h"
          
          #include "model/Model.h"
          
          
          namespace EmberOgre {
          
          
      32  EmberEntityPartAction::EmberEntityPartAction(  EmberPhysicalEntity& entity,   std::string partName )
          : mEntity(  entity ),   mPartName(  partName )
          {
          }
          
          
      38  EmberEntityPartAction::~EmberEntityPartAction(   )
          {
          }
          
      42  void EmberEntityPartAction::activate(   )
          {
           S_LOG_VERBOSE(  "Showing part " << mPartName );
           mEntity.showModelPart(  mPartName );
          // Model::Model* model = mEntity.getModel(   );
          // if (  model ) {
          // model->showPart(  mPartName );
          //
          // }
          }
          
      53  void EmberEntityPartAction::deactivate(   )
          {
           S_LOG_VERBOSE(  "Hiding part " << mPartName );
           mEntity.hideModelPart(  mPartName );
          // Model::Model* model = mEntity.getModel(   );
          // if (  model ) {
          // model->hidePart(  mPartName,   false );
          // }
          }
          
          }

./components/ogre/EmberEntityPartAction.h

       1  //
          // C++ Interface: EmberEntityPartAction
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREEMBERENTITYPARTACTION_H
          #define EMBEROGREEMBERENTITYPARTACTION_H
          #include "EmberOgrePrerequisites.h"
          #include "EmberPhysicalEntity.h"
          
          #include "model/mapping/ModelMapping.h"
          #include "model/mapping/Actions/Action.h"
          
          namespace EmberOgre {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      36  class EmberEntityPartAction : public Model::Mapping::Actions::Action
          {
          public:
      39   EmberEntityPartAction(  EmberPhysicalEntity& entity,   std::string partName );
      40   ~EmberEntityPartAction(   );
          
      42   virtual void activate(   );
      43   virtual void deactivate(   );
          
          protected:
      46   EmberPhysicalEntity& mEntity;
          
      48   std::string mPartName;
          };
          
          }
          
          #endif

./components/ogre/EmberEntityUserObject.cpp

       1  //
          // C++ Implementation: EmberEntityUserObject
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EmberEntityUserObject.h"
          #include "ogreopcode/include/OgreCollisionObject.h"
          #include "EmberEntity.h"
          #include "model/Model.h"
          
          
          namespace EmberOgre {
          
          const Ogre::String EmberEntityUserObject::s_TypeName = "EmberEntityPickerObject";
          
          
      34  EmberEntityUserObject::EmberEntityUserObject(  EmberEntity* emberEntity,   Model::Model* model,   ICollisionDetector* collisionDetector )
          : mEmberEntity(  emberEntity ),  
          mModel(  model ),  
          mCollisionDetector(  collisionDetector )
          // mCollisionObjects(  collisionObjects ),  
          {
          }
          
          // CollisionObjectStore EmberEntityUserObject::getCollisionObjects(   ) const
          // {
          // return mCollisionObjects;
          // }
          
      47  EmberEntityUserObject::~EmberEntityUserObject(   )
          {
           delete mCollisionDetector;
          /* OgreOpcode::CollisionContext* collideContext = OgreOpcode::CollisionManager::getSingletonPtr(   )->getDefaultContext(   );
           for (  EmberEntityUserObject::CollisionObjectStore::iterator I = mCollisionObjects.begin(   ); I != mCollisionObjects.end(   ); ++I )
           {
           collideContext->removeObject(  *I );
           OgreOpcode::CollisionManager::getSingleton(   ).destroyShape(  (  *I )->getShape(   ) );
           delete *I;
           }*/
          }
          
      59  void EmberEntityUserObject::refit(   )
          {
           if (  mCollisionDetector ) {
           mCollisionDetector->refit(   );
           }
          /* for (  EmberEntityUserObject::CollisionObjectStore::iterator I = mCollisionObjects.begin(   ); I != mCollisionObjects.end(   ); ++I )
           {
           (  *I )->refit(   );;
           }*/
          }
          
      70  EmberEntity* EmberEntityUserObject::getEmberEntity(   ) const
          {
           return mEmberEntity;
          }
          
      75  Model::Model* EmberEntityUserObject::getModel(   ) const
          {
           return mModel;
          }
          
      80  const Ogre::String & EmberEntityUserObject::getTypeName (  void ) const
          {
           return s_TypeName;
          }
          
          
          
          };

./components/ogre/EmberEntityUserObject.h

       1  //
          // C++ Interface: EmberEntityUserObject
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREEMBERENTITYUSEROBJECT_H
          #define EMBEROGREEMBERENTITYUSEROBJECT_H
          
          #include "EmberOgrePrerequisites.h"
          
          
          
          namespace Ogre
          {
      32   class Entity;
          };
          
          namespace EmberOgre {
          
          namespace Model {
      38   class Model;
          }
      40  class EmberEntity;
          
          
          struct CollisionResult
          {
           bool collided;
           Ogre::Vector3 position;
           Ogre::Real distance;
          };
          
          /**
          @author Erik Hjortsberg
          
          * Interface for collision detectors,   responsible for determining collision information for the entity that they are attached to.
          */
      55  class ICollisionDetector
          {
          public:
      58   virtual ~ICollisionDetector(   ) {};
          
           /**
           * Testa whether the provided ray hits the entity.
           * @param ray The ray to test.
           * @param result The result of the collision. If the ray hits,   the collision detector must update this object.
           */
      65   virtual void testCollision(  Ogre::Ray& ray,   CollisionResult& result ) = 0;
           /**
           * Refits the collision mesh against the entity. This is called to ensure that the collision mesh fits animated entities.
           */
      69   virtual void refit(   ) = 0;
          
          
           /**
           * Called when the entity changes,   such as a subentity being hidden or shown. Implementations must reload the collision data.
           */
      75   virtual void reload(   ) = 0;
          
           /**
           * Sets whether the collision data should be visualized for debugging purposes.
           * @param visualize
           */
      81   virtual void setVisualize(  bool visualize ) = 0;
           /**
           * Gets whether the collision data should be visualized for debugging purposes.
           * @return
           */
      86   virtual bool getVisualize(   ) const = 0;
          
          };
          
          
          /**
          @author Erik Hjortsberg
          
          Instances of this class can be attached to scene nodes in the ogre system. They will allow for the Ember system to be accessed directly from Ogre,   without having to do lookups.
          This is generally mostly used for mouse picking and collision handling.
          
          */
      98  class EmberEntityUserObject : public Ogre::UserDefinedObject
          {
          public:
          
           /**
           The type of UserDefinedObject
           */
     105   static const std::string s_TypeName;
          // typedef std::vector<OgreOpcode::CollisionObject*> CollisionObjectStore;
          
           /**
           * Constructor.
           * @param emberEntity A valid EmberEntity instance.
           * @param model A valid Model instance.
           * @param collisionObject A valid vector of collision objects.
           * @return
           */
     115   EmberEntityUserObject(  EmberEntity* emberEntity,   Model::Model* model,   ICollisionDetector* collisionDetector );
          
     117   virtual ~EmberEntityUserObject(   );
          
           /**
           * Gets the EmberEntity contained.
           * @return
           */
     123   EmberEntity* getEmberEntity(   ) const;
          
           /**
           * Gets the Model instance.
           * @return
           */
     129   Model::Model* getModel(   ) const ;
          
           /**
           * Gets a pointer to a vector of CollisionObjects. This can be used for checking collisions.
           * @return
           */
          // CollisionObjectStore* getCollisionObjects(   ) { return &mCollisionObjects; }
          
           /**
           * Overloaded method for getting the type name of this instance.
           * @param
           * @return
           */
     142   virtual const Ogre::String & getTypeName (  void ) const;
          
     144   void refit(   );
          
     146   inline ICollisionDetector* getCollisionDetector(   ) const;
          
          private:
     149   EmberEntity* mEmberEntity;
     150   Model::Model* mModel;
           //CollisionObjectStore mCollisionObjects;
     152   ICollisionDetector* mCollisionDetector;
          
          };
          
     156  ICollisionDetector* EmberEntityUserObject::getCollisionDetector(   ) const
          {
           return mCollisionDetector;
          }
          
          };
          
          #endif

./components/ogre/EmberOgre.cpp

       1  /*
          -----------------------------------------------------------------------------
          OgreApp.cpp by Miguel Guzman Miranda (  Aglanor )
          Based on OGRE sample applications:
           OGRE (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://ogre.sourceforge.net
          Based on the Ember main application by the Ember team
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          
          
          -----------------------------------------------------------------------------
          */
          
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "EmberOgre.h"
          
          // Headers to stop compile problems from headers
          #include <stdlib.h>
          #include <stddef.h>
          #include <stdio.h>
          #include <sys/types.h>
          
          #ifdef WIN32
           #include <tchar.h>
           #define snprintf _snprintf
           #include <io.h> // for _access,   Win32 version of stat(   )
           #include <direct.h> // for _mkdir
          // #include <sys/stat.h>
          
           #include <iostream>
           #include <fstream>
           #include <ostream>
          #else
           #include <dirent.h>
          #endif
          
          #include "EmberOgrePrerequisites.h"
          
          // ------------------------------
          // Include Eris header files
          // ------------------------------
          /*#include <Eris/PollDefault.h>*/
          #include <Eris/Connection.h>
          #include <Eris/View.h>
          
          
          
          //Ember headers
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/server/ServerService.h"
          #include "services/config/ConfigService.h"
          #include "services/metaserver/MetaserverService.h"
          #include "services/sound/SoundService.h"
          #include "services/scripting/ScriptingService.h"
          #include "services/wfut/WfutService.h"
          #include "framework/ConsoleBackend.h"
          #include "framework/ConsoleObject.h" //TODO: this will be included in a different class
          #include "framework/binreloc.h" //this is needed for binreloc functionality
          
          
          // ------------------------------
          // Include OGRE Ember client files
          // ------------------------------
          #include "terrain/TerrainGenerator.h"
          #include "terrain/TerrainLayerDefinitionManager.h"
          
          
          #include "ConsoleObjectImpl.h"
          #include "Avatar.h"
          #include "AvatarController.h"
          #include "EmberEntityFactory.h"
          #include "MotionManager.h"
          #include "AvatarCamera.h"
          #include "GUIManager.h"
          #include "manipulation/EntityMoveManager.h"
          
          
          #include "EmberEntity.h"
          #include "WorldEmberEntity.h"
          
          #include "environment/meshtree/TParameters.h"
          #include "environment/Tree.h"
          
          #include "carpenter/Carpenter.h"
          #include "carpenter/BluePrint.h"
          
          #include <OgreSceneManager.h>
          #include "SceneManagers/EmberPagingSceneManager/include/EmberPagingSceneManager.h"
          #include "SceneManagers/EmberPagingSceneManager/include/EmberPagingSceneManagerAdapter.h"
          #include "model/ModelDefinitionManager.h"
          #include "model/ModelDefinition.h"
          #include "model/mapping/EmberModelMappingManager.h"
          
          #include "ogreopcode/include/OgreCollisionManager.h"
          #include "OpcodeCollisionDetectorVisualizer.h"
          
          // ------------------------------
          // Include Ember header files
          // ------------------------------
          
          #include "framework/ConsoleBackend.h"
          
          
          
          #include "jesus/Jesus.h"
          #include "jesus/XMLJesusSerializer.h"
          
          #include "framework/osdir.h"
          
          #include "framework/Exception.h"
          #include "OgreLogObserver.h"
          #include "OgreResourceLoader.h"
          
          #include "widgets/LoadingBar.h"
          
          #include "sound/OgreSoundProvider.h"
          
          #include "OgreSetup.h"
          
          #include "manipulation/MaterialEditor.h"
          #include "MediaUpdater.h"
          
          #include "main/Application.h"
          #include "input/InputCommandMapper.h"
          #include "input/Input.h"
          
          #include "OgreResourceProvider.h"
          #include "scripting/LuaScriptingProvider.h"
          
          template<> EmberOgre::EmberOgre* Ember::Singleton<EmberOgre::EmberOgre>::ms_Singleton = 0;
          
          namespace EmberOgre {
          
     152   void assureConfigFile(  const std::string& filename,   const std::string& originalConfigFileDir )
           {
           struct stat tagStat;
           int ret = stat(   filename.c_str(   ),   &tagStat  );
           if (  ret == -1 ) {
           ret = stat(   (  originalConfigFileDir +filename ).c_str(   ),   &tagStat  );
           if (  ret == 0 ) {
           ///copy conf file from shared
           std::ifstream instream (  (  originalConfigFileDir + filename ).c_str(   ) );
           std::ofstream outstream (  filename.c_str(   ) );
           outstream << instream.rdbuf(   );
           }
           }
           }
          
          
          
     169  EmberOgre::EmberOgre(   ) :
          mAvatar(  0 ),  
          mAvatarController(  0 ),  
          mRoot(  0 ),  
          mSceneMgr(  0 ),  
          mWindow(  0 ),  
          mInput(  std::auto_ptr<Input>(  new Input ) ),  
          mGeneralCommandMapper(  std::auto_ptr<InputCommandMapper>(  new InputCommandMapper(  "general" ) ) ),  
          mEmberEntityFactory(  0 ),  
          mTerrainGenerator(  0 ),  
          mMotionManager(  0 ),  
          mGUIManager(  0 ),  
          mModelDefinitionManager(  0 ),  
          mModelMappingManager(  0 ),  
          mTerrainLayerManager(  0 ),  
          mMoveManager(  0 ),  
          mKeepOnRunning(  true ),  
          mJesus(  0 ),  
          mLogObserver(  0 ),  
          mMaterialEditor(  0 ),  
          mCollisionManager(  0 ),  
          mCollisionDetectorVisualizer(  0 )
          {
           Ember::Application::getSingleton(   ).EventServicesInitialized.connect(  sigc::mem_fun(  *this,   &EmberOgre::Application_ServicesInitialized ) );
          }
          
     195  EmberOgre::~EmberOgre(   )
          {
           delete mCollisionDetectorVisualizer;
           delete mCollisionManager;
           delete mMaterialEditor;
           delete mJesus;
           delete mMoveManager;
          
           ///The factory will be deleted by the mWorldView when that is deleted later on,   so we shall not delete it here
          // delete mEmberEntityFactory;
           delete mAvatarController;
           delete mAvatar;
          
           ///start with deleting the eris world,   then shut down ogre
          // delete mWorldView;
          
           delete mMotionManager;
           delete mTerrainGenerator;
          
           delete mGUIManager;
          
           delete mTerrainLayerManager;
           delete mModelMappingManager;
          
           ///we need to make sure that all Models are destroyed before Ogre begins destroying other movable objects (  such as Entities )
           ///this is because Model internally uses Entities,   so if those Entities are destroyed by Ogre before the Models are destroyed,   the Models will try to delete them again,   causing segfaults and other wickedness
           ///by deleting the model manager we'll assure that
           delete mModelDefinitionManager;
          
           if (  mWindow ) {
           mRoot->detachRenderTarget(  mWindow );
           }
          
           Ogre::LogManager::getSingleton(   ).getDefaultLog(   )->removeListener(  mLogObserver );
           delete mLogObserver;
          
           if (  mOgreSetup.get(   ) ) {
           mOgreSetup->shutdown(   );
           mOgreSetup.release(   );
           }
          
          
          /* delete mOgreResourceLoader;
          // mSceneMgr->shutdown(   );
          // delete mWorldView;
           //mSceneMgr->removeAllCameras(   );
          // mSceneMgr->clearScene(   );
           delete mGUIManager;
           delete mTerrainGenerator;
           delete mMotionManager;
          // if (  mAvatar )
          // delete mAvatar;
           delete mAvatarController;*/
          // delete mModelDefinitionManager;
          /* if (  mEmberEntityFactory )
           delete mEmberEntityFactory;*/
          // delete mRoot;
          
          
          
          
          
          }
          
     259  bool EmberOgre::frameEnded(  const Ogre::FrameEvent & evt )
          {
           return true;
          }
          
     264  bool EmberOgre::frameStarted(  const Ogre::FrameEvent & evt )
          {
           //OgreOpcode::CollisionManager::getSingletonPtr(   )->getDefaultContext(   )->visualize(  true,   false,   false,   false,   true,   true );
          // if (  !mKeepOnRunning )
          // S_LOG_INFO(   "Shutting down Ember." );
          // return mKeepOnRunning;
           return true;
          }
          
     273  bool EmberOgre::renderOneFrame(   )
          {
           mInput->processInput(   );
           if (  mInput->isApplicationVisible(   ) ) {
           return mRoot->renderOneFrame(   );
           }
           return true;
          }
          
     282  void EmberOgre::shutdownGui(   )
          {
           delete mGUIManager;
           mGUIManager = 0;
          }
          
     288  void EmberOgre::go(   )
          {
           if (  !setup(   ) )
           return;
          }
          
          
          
          // These internal methods package up the stages in the startup process
          /** Sets up the application - returns false if the user chooses to abandon configuration. */
     298  bool EmberOgre::setup(   )
          {
           S_LOG_INFO(  "Compiled against ogre version " << OGRE_VERSION );
          
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingleton(   ).getConfigService(   );
          
           checkForConfigFiles(   );
          
           ///Create a setup object through which we will start up Ogre.
           mOgreSetup = std::auto_ptr<OgreSetup>(  new OgreSetup );
          
           mLogObserver = new OgreLogObserver(   );
          
           ///if we do this we will override the automatic creation of a LogManager and can thus route all logging from ogre to the ember log
           new Ogre::LogManager(   );
           Ogre::LogManager::getSingleton(   ).createLog(  "Ogre",   true,   false,   true );
           Ogre::LogManager::getSingleton(   ).getDefaultLog(   )->addListener(  mLogObserver );
          
           ///We need a root object.
           mRoot = mOgreSetup->createOgreSystem(   );
          
           if (  !mRoot ) {
           throw Ember::Exception(  "There was a problem setting up the Ogre environment,   aborting." );
           }
          
           ///Create the model definition manager
           mModelDefinitionManager = new Model::ModelDefinitionManager(   );
          
           mModelMappingManager = new Model::Mapping::EmberModelMappingManager(   );
          
           mTerrainLayerManager = new Terrain::TerrainLayerDefinitionManager(   );
          
           ///Create a resource loader which loads all the resources we need.
           OgreResourceLoader ogreResourceLoader;
           ogreResourceLoader.initialize(   );
          
           ///check if we should preload the media
           bool preloadMedia = configSrv->itemExists(  "media",   "preloadmedia" ) && (  bool )configSrv->getValue(  "media",   "preloadmedia" );
           bool useWfut = configSrv->itemExists(  "wfut",   "enabled" ) && (  bool )configSrv->getValue(  "wfut",   "enabled" );
          
          
           bool carryOn = mOgreSetup->configure(   );
           if (  !carryOn ) return false;
           mWindow = mOgreSetup->getRenderWindow(   );
          
          
           ///start with the bootstrap resources,   after those are loaded we can show the LoadingBar
           ogreResourceLoader.loadBootstrap(   );
          
          
           mSceneMgr = mOgreSetup->chooseSceneManager(   );
          
           ///create the main camera,   we will of course have a couple of different cameras,   but this will be the main one
           Ogre::Camera* camera = mSceneMgr->createCamera(  "MainCamera" );
           Ogre::Viewport* viewPort = mWindow->addViewport(  camera );
           ///set the background colour to black
           viewPort->setBackgroundColour(  Ogre::ColourValue(  0,  0,  0 ) );
           camera->setAspectRatio(  Ogre::Real(  viewPort->getActualWidth(   ) ) / Ogre::Real(  viewPort->getActualHeight(   ) ) );
          
           ///The input object must know the resoluton of the screen
           unsigned int height,   width,   depth;
           int top,   left;
           mWindow->getMetrics(  width,   height,   depth,   left,   top );
           mInput->initialize(  width,   height );
          
           ///bind general commands
           mGeneralCommandMapper->readFromConfigSection(  "key_bindings_general" );
           mGeneralCommandMapper->bindToInput(  *mInput );
          
           ///we need a nice loading bar to show the user how far the setup has progressed
           Gui::LoadingBar loadingBar;
          
           Gui::LoadingBarSection wfutSection(  loadingBar,   0.2,   "Media update" );
           loadingBar.addSection(  &wfutSection );
           Gui::WfutLoadingBarSection wfutLoadingBarSection(  wfutSection );
          
           Gui::LoadingBarSection resourceGroupSection(  loadingBar,   0.8,   "Resource loading" );
           loadingBar.addSection(  &resourceGroupSection );
           unsigned int numberOfSections = ogreResourceLoader.numberOfSections(   ) - 1; ///remove bootstrap since that's already loaded
           Gui::ResourceGroupLoadingBarSection resourceGroupSectionListener(  resourceGroupSection,   numberOfSections,   (  preloadMedia ? numberOfSections : 0  ),   0.7 );
          
           loadingBar.start(  mWindow );
           loadingBar.setVersionText(  std::string(  "Version " ) + VERSION  );
          
           /// Turn off rendering of everything except overlays
           mSceneMgr->clearSpecialCaseRenderQueues(   );
           mSceneMgr->addSpecialCaseRenderQueue(  Ogre::RENDER_QUEUE_OVERLAY );
           mSceneMgr->setSpecialCaseRenderQueueMode(  Ogre::SceneManager::SCRQM_INCLUDE );
          
           if (  useWfut ) {
           S_LOG_INFO(  "Updating media." );
           MediaUpdater updater;
           updater.performUpdate(   );
           }
          
           ///create the collision manager
           mCollisionManager = new OgreOpcode::CollisionManager(  mSceneMgr );
           mCollisionDetectorVisualizer = new OpcodeCollisionDetectorVisualizer(   );
          
           ogreResourceLoader.loadGui(   );
           ogreResourceLoader.loadGeneral(   );
          
           ///add ourself as a frame listener
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          
           ///should media be preloaded?
           if (  preloadMedia )
           {
           S_LOG_INFO(   "Begin preload." );
           ogreResourceLoader.preloadMedia(   );
           S_LOG_INFO(   "End preload." );
           }
           try {
           mGUIManager = new GUIManager(  mWindow,   mSceneMgr );
           EventGUIManagerCreated.emit(  *mGUIManager );
           } catch (  ... ) {
           ///we failed at creating a gui,   abort (  since the user could be running in full screen mode and could have some trouble shutting down )
           throw Ember::Exception(  "Could not load gui,   aborting. Make sure that all media got downloaded and installed correctly." );
           }
          
          
          
           if (  chdir(  configSrv->getHomeDirectory(   ).c_str(   ) ) ) {
           S_LOG_WARNING(  "Failed to change directory to '"<< configSrv->getHomeDirectory(   ) << "'" );
           }
          
           // Avatar
           mAvatar = new Avatar(   );
          
           mAvatarController = new AvatarController(  mAvatar,   mWindow,   mGUIManager,   camera );
           EventAvatarControllerCreated.emit(  *mAvatarController );
          
           mTerrainGenerator = new Terrain::TerrainGenerator(  new EmberPagingSceneManagerAdapter(  mSceneMgr ) );
           EventTerrainGeneratorCreated.emit(  *mTerrainGenerator );
           mMotionManager = new MotionManager(   );
          // mMotionManager->setTerrainGenerator(  mTerrainGenerator );
           EventMotionManagerCreated.emit(  *mMotionManager );
          
          // mSceneMgr->setPrimaryCamera(  mAvatar->getAvatarCamera(   )->getCamera(   ) );
          
           mMoveManager = new EntityMoveManager(   );
          
          
          
          
           mRoot->addFrameListener(  mMotionManager );
           new ConsoleObjectImpl(   );
          
          
           try {
           mGUIManager->initialize(   );
           EventGUIManagerInitialized.emit(  *mGUIManager );
           } catch (  ... ) {
           ///we failed at creating a gui,   abort (  since the user could be running in full screen mode and could have some trouble shutting down )
           throw Ember::Exception(  "Could not initialize gui,   aborting. Make sure that all media got downloaded and installed correctly." );
           }
          
           /// Create the scene
           createScene(   );
           EventSceneCreated.emit(   );
          
           ///this should be in a separate class,   a separate plugin even
           ///disable for now,   since it's not used
           //setupJesus(   );
          
           /// Back to full rendering
           mSceneMgr->clearSpecialCaseRenderQueues(   );
           mSceneMgr->setSpecialCaseRenderQueueMode(  Ogre::SceneManager::SCRQM_EXCLUDE );
          
           mMaterialEditor = new MaterialEditor(   );
          
           loadingBar.finish(   );
          
           return true;
          
          }
          
          
     476  EmberEntity* EmberOgre::getEmberEntity(  const std::string & eid )
          {
           assert(  getMainView(   ) );
           return static_cast<EmberEntity*>(  getMainView(   )->getEntity(  eid ) );
          }
          
          
     483  void EmberOgre::checkForConfigFiles(   )
          {
           if (  chdir(  Ember::EmberServices::getSingleton(   ).getConfigService(   )->getHomeDirectory(   ).c_str(   ) ) ) {
           S_LOG_WARNING(  "Failed to change directory to '"<< Ember::EmberServices::getSingleton(   ).getConfigService(   )->getHomeDirectory(   ) << "',   will not copy config files." );
           return;
           }
          
           const std::string& sharePath(  Ember::EmberServices::getSingleton(   ).getConfigService(   )->getSharedConfigDirectory(   ) );
          
           ///make sure that there are files
           assureConfigFile(  "ogre.cfg",   sharePath );
           //assureConfigFile(  "plugins.cfg",   sharePath );
          }
          
          
     498  void EmberOgre::preloadMedia(  void )
          {
           Ogre::ResourceGroupManager::getSingleton(   ).initialiseAllResourceGroups(   );
          
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingleton(   ).getConfigService(   );
          
          
           std::vector<std::string> shaderTextures;
          
           shaderTextures.push_back(  std::string(  configSrv->getValue(  "shadertextures",   "rock" ) ) );
           shaderTextures.push_back(  std::string(  configSrv->getValue(  "shadertextures",   "sand" ) ) );
           shaderTextures.push_back(  std::string(  configSrv->getValue(  "shadertextures",   "grass" ) ) );
          
           for (  std::vector<std::string>::iterator I = shaderTextures.begin(   ); I != shaderTextures.end(   ); ++I ) {
           try {
           Ogre::TextureManager::getSingleton(   ).load(  *I,   "General" );
           } catch (  const Ogre::Exception& e ) {
           S_LOG_FAILURE(   "Error when loading texture " << *I << ".\n\rError message: " << e.getDescription(   ) );
           }
           }
          
           //only autogenerate trees if we're not using the pregenerated ones
           if (  configSrv->itemExists(  "tree",   "usedynamictrees" ) && (  (  bool )configSrv->getValue(  "tree",   "usedynamictrees" ) ) ) {
           Environment::Tree tree;
           tree.makeMesh(  "GeneratedTrees/European_Larch",   Ogre::TParameters::European_Larch );
           tree.makeMesh(  "GeneratedTrees/Fir",   Ogre::TParameters::Fir );
           }
          
          
          
          
          }
          
     531  void EmberOgre::setupJesus(   )
          {
           const std::string datadir = Ember::EmberServices::getSingleton(   ).getConfigService(   )->getSharedDataDirectory(   );
          
           Carpenter::Carpenter* carpenter = new Carpenter::Carpenter(   );
           mJesus = new Jesus(  carpenter );
           XMLJesusSerializer serializer(  mJesus );
          
           std::string dir(  Ember::EmberServices::getSingleton(   ).getConfigService(   )->getSharedDataDirectory(   ) + "carpenter/blockspec" );
          
           std::string filename;
          
           //oslink::directory needs to be destroyed before a new one can be used,   regular copy constructor doesn't seem to work
           //we could also use new/delete,   but scopes works as well
           {
           oslink::directory osdir(  dir );
           while (  osdir ) {
           filename = osdir.next(   );
           S_LOG_VERBOSE(   "Loading blockspec: " << filename  );
           serializer.loadBlockSpec(  dir + "/" + filename );
           }
           }
           //load all buildingblockspecs
           dir = Ember::EmberServices::getSingleton(   ).getConfigService(   )->getSharedDataDirectory(   ) + "carpenter/modelblockspecs";
           {
           oslink::directory osdir(  dir );
           while (  osdir ) {
           filename = osdir.next(   );
           S_LOG_VERBOSE(   "Loading buildingblockspecC: " << filename );
           serializer.loadBuildingBlockSpecDefinition(  dir + "/" + filename );
           }
           }
           //load all modelmappings
           dir = Ember::EmberServices::getSingleton(   ).getConfigService(   )->getSharedDataDirectory(   ) + "jesus/modelmappings";
           {
           oslink::directory osdir(  dir );
           while (  osdir ) {
           filename = osdir.next(   );
           S_LOG_VERBOSE(   "Loading modelmapping: " << filename  );
           serializer.loadModelBlockMapping(  dir + "/" + filename );
           }
           }
          
           //load all global blueprints
           dir = Ember::EmberServices::getSingleton(   ).getConfigService(   )->getSharedDataDirectory(   ) + "carpenter/blueprints";
           {
           oslink::directory osdir(  dir );
           while (  osdir ) {
           filename = osdir.next(   );
           S_LOG_VERBOSE(   "Loading blueprint: " << filename  );
           Carpenter::BluePrint* blueprint = serializer.loadBlueprint(  dir + "/" + filename );
           if (  blueprint ) {
           blueprint->compile(   );
           bool result = mJesus->addBluePrint(  blueprint );
           if (  !result )
           {
           S_LOG_FAILURE(   "Could not add blueprint: " << filename );
           }
           }
           }
           }
           //load all local blueprints
           dir = Ember::EmberServices::getSingleton(   ).getConfigService(   )->getHomeDirectory(   ) + "carpenter/blueprints";
           {
           oslink::directory osdir(  dir );
           while (  osdir ) {
           filename = osdir.next(   );
           S_LOG_VERBOSE(   "Loading local blueprint: " << filename  );
           Carpenter::BluePrint* blueprint = serializer.loadBlueprint(  dir + "/" + filename );
           if (  blueprint ) {
           blueprint->compile(   );
           bool result = mJesus->addBluePrint(  blueprint );
           if (  !result )
           {
           S_LOG_FAILURE(   "Could not add blueprint: " << filename  );
           }
           }
           }
           }
          
          
           EventCreatedJesus.emit(  mJesus );
          }
          
     615  void EmberOgre::createScene(  void )
          {
          
           ///initially,   while in the "void",   we'll use a clear ambient light
           mSceneMgr->setAmbientLight(  Ogre::ColourValue(  1,   1,   1 ) );
          
          }
          
     623  void EmberOgre::Server_GotView(  Eris::View* view )
          {
          // mWorldView = view;
           mEmberEntityFactory = new EmberEntityFactory(  view,   mTerrainGenerator,   Ember::EmberServices::getSingleton(   ).getServerService(   )->getConnection(   )->getTypeService(   ) );
          }
          
     629  EmberEntity* EmberOgre::getEntity(  const std::string & id )
          {
           ///this of course relies upon all entities being created by our factory
           return static_cast<EmberEntity*>(  getMainView(   )->getEntity(  id ) );
          }
          
          
     636  void EmberOgre::connectedToServer(  Eris::Connection* connection )
          {
           //EventCreatedAvatarEntity.connect(  sigc::mem_fun(  *mAvatar,   &Avatar::createdAvatarEmberEntity ) );
           EventCreatedEmberEntityFactory.emit(  mEmberEntityFactory );
          }
          
          
          
     644  Avatar* EmberOgre::getAvatar(   ) const {
           return mAvatar;
          }
          
          
     649  Ogre::SceneManager* EmberOgre::getSceneManager(   ) const
          {
           return mSceneMgr;
          }
          
     654  Terrain::TerrainGenerator* EmberOgre::getTerrainGenerator(   ) const
          {
           return mTerrainGenerator;
          }
          
     659  MotionManager* EmberOgre::getMotionManager(   ) const
          {
           return mMotionManager;
          }
          
     664  Ogre::Root* EmberOgre::getOgreRoot(   ) const
          {
           assert(  mRoot );
           return mRoot;
          }
          
     670  Ogre::SceneNode * EmberOgre::getWorldSceneNode(    ) const
          {
           if (  mEmberEntityFactory && mEmberEntityFactory->getWorld(   ) ) {
           return mEmberEntityFactory->getWorld(   )->getSceneNode(   );
           } else {
           return mSceneMgr->getRootSceneNode(   );
           }
          /* Ogre::SceneNode* node = mSceneMgr->getSceneNode(  "0" );
           //TODO: implement better exception handling
           if (  node == 0 )
           throw Exception(   );
           return node;*/
          }
          
     684  Ogre::SceneNode* EmberOgre::getRootSceneNode(   ) const
          {
           return mSceneMgr->getRootSceneNode(   );
          }
          
          
     690  AvatarCamera* EmberOgre::getMainCamera(   ) const
          {
           return mAvatar->getAvatarCamera(   );
          }
          
     695  EmberEntityFactory* EmberOgre::getEntityFactory(   ) const
          {
           return mEmberEntityFactory;
          }
          
     700  AvatarController* EmberOgre::getAvatarController(   ) const
          {
           return mAvatarController;
          }
          
          // // void EmberOgre::setErisPolling(  bool doPoll )
          // // {
          // // mPollEris = doPoll;
          // // }
          // //
          // // bool EmberOgre::getErisPolling(   ) const
          // // {
          // // return mPollEris;
          // // }
          
          
     716  void EmberOgre::initializeEmberServices(  const std::string& prefix,   const std::string& homeDir )
          {
          
          }
          
     721  void EmberOgre::Application_ServicesInitialized(   )
          {
           Ember::EmberServices::getSingleton(   ).getServerService(   )->GotConnection.connect(  sigc::mem_fun(  *this,   &EmberOgre::connectedToServer ) );
           Ember::EmberServices::getSingleton(   ).getServerService(   )->GotView.connect(  sigc::mem_fun(  *this,   &EmberOgre::Server_GotView ) );
          
           mScriptingResourceProvider = std::auto_ptr<OgreResourceProvider>(  new OgreResourceProvider(  "Scripting" ) );
           Ember::EmberServices::getSingleton(   ).getScriptingService(   )->setResourceProvider(  mScriptingResourceProvider.get(   ) );
           ///register the lua scripting provider
           Ember::EmberServices::getSingleton(   ).getScriptingService(   )->registerScriptingProvider(  new LuaScriptingProvider(   ) );
          
          }
          
     733  Eris::View* EmberOgre::getMainView(   )
          {
           return Ember::Application::getSingleton(   ).getMainView(   );
          }
          
          
          }

./components/ogre/EmberOgre.h

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
           (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://ogre.sourceforge.net/
          
          Copyright � 2000-2002 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          */
          
          #ifndef __EmberOgre_H__
          #define __EmberOgre_H__
          
          #include "EmberOgrePrerequisites.h"
          
          // ------------------------------
          // Include sigc header files
          // ------------------------------
          #include <sigc++/trackable.h>
          #include <sigc++/signal.h>
          
          
          #include "framework/Singleton.h"
          
          
          
          namespace Eris {
      42  class View;
      43  class Connection;
          }
          
          namespace Carpenter
          {
      48  class Carpenter;
      49  class BluePrint;
          }
          
      52  namespace Ember
          {
          class StreamLogObserver;
          }
          
          namespace OgreOpcode {
      58  class CollisionManager;
          }
          
      61  namespace EmberOgre {
          
          namespace Terrain
          {
          class TerrainGenerator;
          class TerrainLayerDefinitionManager;
          }
          
          namespace Model {
           class ModelDefinitionManager;
           namespace Mapping {
           class EmberModelMappingManager;
           }
          }
          
          class CameraRotator;
          
          class CameraFrameListener;
          
          class Avatar;
          
          class AvatarCamera;
          
          class AvatarController;
          
          class AvatarEmberEntity;
          
          class EmberEntityFactory;
          
          class EmberPagingSceneManager;
          
          class MotionManager;
          
          class Input;
          
          class InputManager;
          
          class InputCommandMapper;
          
          class GUIManager;
          
          class Jesus;
          
          class EmberEntity;
          
          class OgreResourceLoader;
          
          class OgreLogObserver;
          
          class EntityMoveManager;
          
          class MaterialEditor;
          
          class OgreSetup;
          
          class OgreResourceProvider;
          class OpcodeCollisionDetectorVisualizer;
          
          /**
          
          The main class of ember. This functions as a hub for almost all subsystems. (  Perhaps this should be refactored? )
          
          */
          class EmberOgre : public Ember::Singleton<EmberOgre>,  
          public sigc::trackable,  
          public Ogre::FrameListener
          {
          public:
          
          
           /// Standard constructor
           EmberOgre(   );
          
           /// Standard destructor
           ~EmberOgre(   );
          
           virtual bool frameStarted(  const Ogre::FrameEvent & evt );
           virtual bool frameEnded(  const Ogre::FrameEvent & evt );
          
           /**
           * starts the main app
           */
           virtual void go(   );
          // void shutdown(   );
          
           /**
           * Initialize all Ember services needed for this application
           * @param the prefix for the application,   not appliable if running under win32
           * @param the an alternative home directory. If the default should be used,   send an empty string.
           */
           void initializeEmberServices(  const std::string& prefix,   const std::string& homeDir );
          
           void Server_GotView(  Eris::View* world );
           void connectedToServer(  Eris::Connection* connection );
          
          
           // TODO: possibly we'd like to do the following in a different way,  
           // perhaps refactoring stuff
           Avatar* getAvatar(   ) const;
           Ogre::SceneManager* getSceneManager(   ) const;
           Terrain::TerrainGenerator* getTerrainGenerator(   ) const;
           MotionManager* getMotionManager(   ) const;
           Ogre::Root* getOgreRoot(   ) const;
           EmberEntityFactory* getEntityFactory(   ) const;
           AvatarCamera* getMainCamera(   ) const;
           AvatarController* getAvatarController(   ) const;
           inline EntityMoveManager* getMoveManager(   ) const;
          // inline Input& getInput(   );
          
           /**
           * Gets the entity with the supplies id from the world.
           */
           EmberEntity* getEmberEntity(  const std::string & eid );
          
           inline Jesus* getJesus(   ) const;
          
           inline Ogre::RenderWindow* getRenderWindow(   ) const;
          
          
           sigc::signal<void,   EmberEntityFactory*> EventCreatedEmberEntityFactory;
           sigc::signal<void,   AvatarEmberEntity*> EventCreatedAvatarEntity;
           sigc::signal<void,   Jesus*> EventCreatedJesus;
          
           /**
           Emitted before the eris polling is started
           */
          // sigc::signal<void> EventStartErisPoll;
          
           /**
           Emitted after the eris polling has finished
           */
          // sigc::signal<void> EventEndErisPoll;
          
           /**
           * returns the scenenode of the world entity
           * throws en exception if no such node has been created
           * @return
           */
           Ogre::SceneNode* getWorldSceneNode(   ) const;
          
          
           /**
           * returns the root scene node
           * @return
           */
           Ogre::SceneNode* getRootSceneNode(   ) const;
          
          
           /**
           Emitted after the GUIManager has been created,   but not yet initialized
           */
           sigc::signal<void,   GUIManager&> EventGUIManagerCreated;
           /**
           Emitted after the GUIManager has been initilized
           */
           sigc::signal<void,   GUIManager&> EventGUIManagerInitialized;
          
           /**
           Emitted after the Motion has been created
           */
           sigc::signal<void,   MotionManager&> EventMotionManagerCreated;
          
          
           /**
           Emitted after the TerrainGenerator has been created
           */
           sigc::signal<void,   Terrain::TerrainGenerator&> EventTerrainGeneratorCreated;
          
           /**
           Emitted after the AvatarController has been created
           */
           sigc::signal<void,   AvatarController&> EventAvatarControllerCreated;
          
           /**
           Emitted after the base Ogre scene has been created
           */
           sigc::signal<void> EventSceneCreated;
          
           EmberEntity* getEntity(  const std::string & id );
          
           /**
           * Call this to "soft quit" the app. This means that an signal will be emitted,   which hopefully will be taken care of by some widget,   which will show a confirmation window,   asking the user if he/she wants to quit.
           However,   if there is no widget etc. handling the request,   the application will instantly quit.
           */
          // void requestQuit(   );
          
           /**
           * Sets whether eris should be polled each frame. Defaults to true.
           * @param doPoll
           */
          // void setErisPolling(  bool doPoll );
          
           /**
           * Gets whether eris should be polled each frame.
           * @return
           */
          // bool getErisPolling(   ) const;
          
           /**
           Renders one frame.
           */
           bool renderOneFrame(   );
          
           /**
           * Sets up the application - returns false if the user chooses to abandon configuration.
           * @return
           */
           bool setup(   );
          
           void shutdownGui(   );
          
          protected:
          
           /**
           utility object for setting up and tearing down ogre
           */
           std::auto_ptr<OgreSetup> mOgreSetup;
          
           Eris::View* getMainView(   );
          
           /**
           * The main user avatar
           */
           Avatar* mAvatar;
          
           /**
           When connected to a world,   handles the avatar and patches mouse and keyboard movement events on the avatar.
           */
           AvatarController* mAvatarController;
          
           /**
           The main Ogre root object. All of Ogre is accessed through this.
           */
           Ogre::Root *mRoot;
          
           /**
           The main scene manager of the world.
           */
           EmberPagingSceneManager* mSceneMgr;
          
           /**
           The main render window. There can be many more render targets in the system,   but they will all reside within this render window (  such as entity preview through CEGUI ).
           */
           Ogre::RenderWindow* mWindow;
          
           /**
           The main input object.
           */
           std::auto_ptr<Input> mInput;
          
           /**
           An InputCommandMapper that will handle all general input events.
           */
           std::auto_ptr<InputCommandMapper> mGeneralCommandMapper;
          
           /**
           Main factory for all entities created in the world.
           */
           EmberEntityFactory* mEmberEntityFactory;
          
           /**
           * Creates the basic scene with a single avatar,   just for testing purpose.
           * NOTE: remove this when going final
           * @param
           */
           void createScene(  void );
          
           /**
           * Sets up Jesus. This inialized the mJesus member and loads all building blocks,   blueprint and modelblocks etc.
           */
           void setupJesus(   );
          
           /**
           * Preloads the media,   thus avoiding frame rate drops ingame.
           * @param
           */
           void preloadMedia(  void );
          
           /**
          
           makes sure that there are files in ~/.ember
           */
           void checkForConfigFiles(   );
          
           /**
           Responsible for handling of terrain.
           */
           Terrain::TerrainGenerator* mTerrainGenerator;
          
           /**
           Responsible for updating motions and animations of entities.
           */
           MotionManager* mMotionManager;
          
           /**
           Responsible for the GUI.
           */
           GUIManager* mGUIManager;
          
           /**
           Resonsible for managing all Model definitions;
           */
           Model::ModelDefinitionManager* mModelDefinitionManager;
          
           /**
           Handles all model mappings.
           */
           Model::Mapping::EmberModelMappingManager* mModelMappingManager;
          
           Terrain::TerrainLayerDefinitionManager* mTerrainLayerManager;
          
           /**
           Responsible for allowing movement of entities in the world by the user.
           */
           EntityMoveManager* mMoveManager;
          
           /**
           when this is false the app will exit
           */
           bool mKeepOnRunning;
          
           /**
           main entry point for the Jesus system (  which is an Ember wrapper for the Carpenter lib )
           */
           Jesus* mJesus;
          
           /**
           Once connected to a world,   this will hold the main world view.
           */
          // Eris::View* mWorldView;
          
           /**
           Controls whether eris should be polled at each frame update.
           */
          // bool mPollEris;
          
           /**
           The main log observer used for all logging. This will send Ogre logging events on to the internal Ember logging framework.
           */
           OgreLogObserver* mLogObserver;
          
           /**
           Patches logging events from the Ember logging framework on to a file writer.
           */
          // Ember::StreamLogObserver* mStreamLogObserver;
          
           /**
           Helper object that allows for easy Ogre material editing.
           */
           MaterialEditor* mMaterialEditor;
          
           void Application_ServicesInitialized(   );
          
           std::auto_ptr<OgreResourceProvider> mScriptingResourceProvider;
          
           OgreOpcode::CollisionManager* mCollisionManager;
           OpcodeCollisionDetectorVisualizer* mCollisionDetectorVisualizer;
          
          };
          
          // Input& EmberOgre::getInput(   )
          // {
          // return mInput;
          // }
          EntityMoveManager* EmberOgre::getMoveManager(   ) const
          {
           return mMoveManager;
          }
          
          Jesus* EmberOgre::getJesus(   ) const
          {
           return mJesus;
          }
          Ogre::RenderWindow* EmberOgre::getRenderWindow(   ) const
          {
           return mWindow;
          }
          
          
          }
          
          
          #endif

./components/ogre/EmberOgrePrerequisites.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef __EmberPrerequisites_H__
          #define __EmberPrerequisites_H__
          
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "OgreIncludes.h"
          
          // #include "MathConverter.h"
          
          ///include the Logging service,   since we want logging available from most classes
          ///in most cases,   use the S_LOG* defines
          ///such as:
          ///S_LOG_INFO(  "some info" )
          #include "services/logging/LoggingService.h"
          
          #include "framework/Exception.h"
          
          
          
          
          ///utility defines for stl containers
          ///for example:
          ///TYPEDEF_STL_VECTOR(  std::string,   StringVector )
          ///defines a new type called StringVector
          ///you can then use StringVector::iterator etc..
          
          #define TYPEDEF_STL_MKITERATORS(  name ) \
           typedef name::iterator name##Iter; \
           typedef name::const_iterator name##CIter; \
           typedef name::reverse_iterator name##RIter; \
           typedef name::const_reverse_iterator name##CRIter
          
          #define TYPEDEF_STL_CONTAINER1(  container,   tp,   name ) \
           typedef std::container<tp> name; \
           TYPEDEF_STL_MKITERATORS(  name )
          
          #define TYPEDEF_STL_CONTAINER2(  container,   tp1,   tp2,   name ) \
           typedef std::container<tp1,   tp2> name; \
           TYPEDEF_STL_MKITERATORS(  name )
          
          #define TYPEDEF_STL_VECTOR(  tp,   name ) TYPEDEF_STL_CONTAINER1(  vector,   tp,   name )
          #define TYPEDEF_STL_LIST(  tp,   name ) TYPEDEF_STL_CONTAINER1(  list,   tp,   name )
          #define TYPEDEF_STL_SET(  tp,   name ) TYPEDEF_STL_CONTAINER1(  set,   tp,   name )
          #define TYPEDEF_STL_MAP(  tpkey,   tpval,   name ) TYPEDEF_STL_CONTAINER2(  map,   tpkey,   tpval,   name )
          
          typedef unsigned int uint;
          
          #endif

./components/ogre/EmberPhysicalEntity.cpp

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "EmberPhysicalEntity.h"
          
          
          #include "framework/ConsoleBackend.h"
          #include "MotionManager.h"
          #include "model/Model.h"
          #include "model/ModelDefinition.h"
          #include "model/SubModel.h"
          #include "model/ParticleSystemBinding.h"
          #include "model/Action.h"
          
          #include "model/mapping/EmberModelMappingManager.h"
          #include "model/mapping/ModelMapping.h"
          #include "model/mapping/ModelMappingManager.h"
          
          #include "environment/Environment.h"
          #include "environment/Forest.h"
          #include "EmberEntityFactory.h"
          #include "WorldEmberEntity.h"
          
          
          #include "EmberEntityActionCreator.h"
          
          
          #include <OgreException.h>
          
          #include "EmberOgre.h"
          #include "MousePicker.h"
          
          #include "EmberEntityUserObject.h"
          #include "OpcodeCollisionDetector.h"
          #include "MeshCollisionDetector.h"
          
          
          #include <Eris/Entity.h>
          #include <Eris/View.h>
          #include <Eris/TypeInfo.h>
          
          
          namespace EmberOgre {
          
      60  const char * const EmberPhysicalEntity::ACTION_STAND = "__movement_idle";
      61  const char * const EmberPhysicalEntity::ACTION_RUN = "__movement_run";
      62  const char * const EmberPhysicalEntity::ACTION_WALK = "__movement_walk";
      63  const char * const EmberPhysicalEntity::ACTION_SWIM = "__movement_swim";
      64  const char * const EmberPhysicalEntity::ACTION_FLOAT = "__movement_float";
          
          
          
      68  EmberPhysicalEntity::EmberPhysicalEntity(  const std::string& id,   Eris::TypeInfo* ty,   Eris::View* vw,   Ogre::SceneManager* sceneManager ) :
          EmberEntity(  id,   ty,   vw,   sceneManager ),  
          mCurrentMovementAction(  0 ),  
          mActiveAction(  0 ),  
          mModelAttachedTo(  0 ),  
          mModelMarkedToAttachTo(  0 ),  
          mModel(  0 ),  
          mScaleNode(  0 ),  
          mModelMapping(  0 )
          {
          }
          
      80  EmberPhysicalEntity::~EmberPhysicalEntity(   )
          {
           delete mModelMapping;
          
           if (  mModel ) {
           delete mModel->getUserObject(   );
           getSceneManager(   )->destroyMovableObject(  mModel );
           }
           Ogre::SceneNode *parent = static_cast<Ogre::SceneNode*>(  getScaleNode(   )->getParent(   ) );
           if (  parent ) {
           parent->removeAndDestroyChild(  getScaleNode(   )->getName(   ) );
           }
          
           ///make sure it's not in the MotionManager
           ///TODO: keep a marker in the entity so we don't need to call this for all entities
           MotionManager::getSingleton(   ).removeAnimatedEntity(  this );
          
          /*
          
           mSceneManager->removeEntity(  mOgreEntity );
           mSceneManager->removeEntity(  mOgreEntity );
          
           delete mOgreEntity;
           delete mSceneNode;
           */
          }
          
     107  EmberEntity* EmberPhysicalEntity::getEntityAttachedToPoint(  const std::string& attachPoint )
          {
           ///first check with the attach points
           const std::string* entityId(  0 );
           for(  AttachedEntitiesStore::const_iterator I = mAttachedEntities.begin(   ); I != mAttachedEntities.end(   ); ++I ) {
           if (  I->second == attachPoint ) {
           entityId = &I->first;
           break;
           }
           }
          
           if (  entityId ) {
           ///then get the entity from the world
           EmberEntity* entity = EmberOgre::getSingleton(   ).getEmberEntity(  *entityId );
           return entity;
           }
           return 0;
          }
          
          
     127  void EmberPhysicalEntity::setVisible(  bool visible )
          {
           EmberEntity::setVisible(  visible );
          // if (  !visible ) {
          // if (  getScaleNode(   )->getParent(   ) ) {
          // mOgreNode->removeChild(  getScaleNode(   ) );
          // }
          // } else {
          // if (  !getScaleNode(   )->getParent(   ) ) {
          // mOgreNode->addChild(  getScaleNode(   ) );
          // }
          // }
           getScaleNode(   )->setVisible(  visible && getLocation(   ),   false );
           //getModel(   )->setVisible(  visible );
          }
          
     143  void EmberPhysicalEntity::createScaleNode(   )
          {
           mScaleNode = mOgreNode->createChildSceneNode(  getId(   ) + "_scaleNode" );
          }
          
     148  void EmberPhysicalEntity::setModel(  const std::string& modelName )
          {
           if (  mModel ) {
           if (  mModel->getDefinition(   )->getName(   ) == modelName ) {
           return;
           } else {
           getSceneManager(   )->destroyMovableObject(  mModel );
           }
           }
           mModel = Model::Model::createModel(  EmberOgre::getSingleton(   ).getSceneManager(   ),   modelName,   getId(   ) );
          
           ///if the model definition isn't valid,   use a placeholder
           if (  !mModel->getDefinition(   )->isValid(   ) ) {
           S_LOG_FAILURE(   "Could not find " << modelName << ",   using placeholder." );
           ///add a placeholder model
           Model::ModelDefnPtr modelDef = mModel->getDefinition(   );
           modelDef->createSubModelDefinition(  "placeholder.mesh" )->createPartDefinition(  "main" )->setShow(   true );
           modelDef->setValid(   true );
           modelDef->reloadAllInstances(   );
           }
           ///rotate node to fit with WF space
           ///perhaps this is something to put in the model spec instead?
          // scaleNode->rotate(  Ogre::Vector3::UNIT_Y,  (  Ogre::Degree )90 );
          
           mScaleNode->attachObject(  mModel );
          }
          
          
     176  void EmberPhysicalEntity::showModelPart(  const std::string& partName )
          {
           Model::Model* model = getModel(   );
           if (  model ) {
           model->showPart(  partName );
          
           ///if we already have set up a collision object we must reload it
           EmberEntityUserObject* userObject = static_cast<EmberEntityUserObject*>(  getModel(   )->getUserObject(   ) );
           if (  userObject && userObject->getCollisionDetector(   ) ) {
           userObject->getCollisionDetector(   )->reload(   );
           }
           }
          }
          
     190  void EmberPhysicalEntity::hideModelPart(  const std::string& partName )
          {
           Model::Model* model = getModel(   );
           if (  model ) {
           model->hidePart(  partName );
          
           ///if we already have set up a collision object we must reload it
           EmberEntityUserObject* userObject = static_cast<EmberEntityUserObject*>(  getModel(   )->getUserObject(   ) );
           if (  userObject && userObject->getCollisionDetector(   ) ) {
           userObject->getCollisionDetector(   )->reload(   );
           }
           }
          }
          
     204  void EmberPhysicalEntity::init(  const Atlas::Objects::Entity::RootEntity &ge,   bool fromCreateOp )
          {
           ///first we need to create the scale node
           createScaleNode(   );
          
           /// we need a model mapping
           createModelMapping(   );
          
           assert(  mModelMapping );
           mModelMapping->initialize(   );
           if (  !mModel ) {
           S_LOG_WARNING(  "Entity of type " << getType(   )->getName(   ) << " have no default model,   using placeholder." );
           setModel(  "placeholder" );
           }
          
           ///once we have that,   we need which model to use and can create the model
          // createModel(   );
          
           onModeChanged(  EmberEntity::MM_DEFAULT );
           EmberEntity::init(  ge,   fromCreateOp );
           getModel(   )->setQueryFlags(  MousePicker::CM_ENTITY );
          
          /* assert(  mOgreNode );
           assert(  mScaleNode );*/
          
           //if there is no bounding box,   scaleNode hasn't been called,   so do it here
          /* if (  !hasBBox(   ) ) {
           scaleNode(   );
           }*/
          
           //translate the scale node according to the translate defined in the model
          // getScaleNode(   )->translate(  getModel(   )->getDefinition(   )->getTranslate(   ) );
           initFromModel(   );
          
          /* EmberEntityUserObject* userObject = new EmberEntityUserObject(  this,   getModel(   ),   0,   0 );
           getModel(   )->setUserObject(  userObject );*/
          
           /** If there's an idle animation,   we'll randomize the entry value for that so we don't end up with too many similiar entities with synched animations (  such as when you enter the world at origo and have 20 settlers doing the exact same motions. */
           Model::Action* idleaction = mModel->getAction(  ACTION_STAND );
           if (  idleaction ) {
           idleaction->getAnimations(   ).addTime(  Ogre::Math::RangeRandom(  0,   15 ) );
           }
          
          
           //check if we should do delayed attachment
           if (  mModelMarkedToAttachTo ) {
           attachToPointOnModel(  mAttachPointMarkedToAttachTo,   mModelMarkedToAttachTo );
           mModelMarkedToAttachTo = 0;
           mAttachPointMarkedToAttachTo = "";
           }
          
           //NOTE: for now,   add all particle systems. we will want to add some visibility flag or something in the future
           for (  Model::ParticleSystemSet::iterator I = mModel->getParticleSystems(   ).begin(   ); I != mModel->getParticleSystems(   ).end(   ); ++I )
           {
           getScaleNode(   )->attachObject(  (  *I )->getOgreParticleSystem(   ) );
           }
          
           getModel(   )->Reloaded.connect(  sigc::mem_fun(  *this,   &EmberPhysicalEntity::Model_Reloaded ) );
           getModel(   )->Resetting.connect(  sigc::mem_fun(  *this,   &EmberPhysicalEntity::Model_Resetting ) );
          
          
          
          }
          
     268  void EmberPhysicalEntity::initFromModel(   )
          {
          
           ///make a copy of the original bbox
           mDefaultOgreBoundingBox = mModel->getBoundingBox(   );
          
           getScaleNode(   )->setOrientation(  Ogre::Quaternion::IDENTITY );
           ///rotate node to fit with WF space
           ///perhaps this is something to put in the model spec instead?
           getScaleNode(   )->rotate(  Ogre::Vector3::UNIT_Y,  (  Ogre::Degree )90 );
           getScaleNode(   )->rotate(  getModel(   )->getRotation(   ) );
          
           scaleNode(   );
          
           getScaleNode(   )->setPosition(  Ogre::Vector3::ZERO );
           ///translate the scale node according to the translate defined in the model
           getScaleNode(   )->translate(  getModel(   )->getDefinition(   )->getTranslate(   ) );
          
           connectEntities(   );
          
           const Model::RenderingDefinition* renderingDef = mModel->getDefinition(   )->getRenderingDefinition(   );
           if (  renderingDef && renderingDef->getScheme(   ) == "forest" ) {
           Environment::Forest* forest = EmberOgre::getSingleton(   ).getEntityFactory(   )->getWorld(   )->getEnvironment(   )->getForest(   );
           for (  Model::Model::SubModelSet::const_iterator I = mModel->getSubmodels(   ).begin(   ); I != mModel->getSubmodels(   ).end(   ); ++I ) {
          // if (  (  *I )->getEntity(   )->isVisible(   ) ) {
           (  *I )->getEntity(   )->setVisible(  true );
           forest->addTree(  (  *I )->getEntity(   ),   getScaleNode(   )->getWorldPosition(   ),   getScaleNode(   )->getWorldOrientation(   ).getYaw(   ),   getScaleNode(   )->getScale(   ).y );
          // }
           }
           mModel->setRenderingDistance(  100 );
          // getScaleNode(   )->detachObject(  mModel );
          // getSceneNode(   )->removeChild(  getScaleNode(   ) );
          // getScaleNode(   )->setVisible(  false );
           }
          
          }
          
     305  void EmberPhysicalEntity::createModelMapping(   )
          {
           delete mModelMapping;
           EmberEntityActionCreator creator(  *this );
           mModelMapping = ::EmberOgre::Model::Mapping::EmberModelMappingManager::getSingleton(   ).getManager(   ).createMapping(  this,   &creator );
          }
          
     312  void EmberPhysicalEntity::connectEntities(   )
          {
           if (  getModel(   ) ) {
           if (  getModel(   )->getUserObject(   ) ) {
           delete getModel(   )->getUserObject(   );
           }
          // ICollisionDetector* collisionDetector = new OpcodeCollisionDetector(  getModel(   ) );
           ICollisionDetector* collisionDetector = new MeshCollisionDetector(  getModel(   ) );
           EmberEntityUserObject* userObject = new EmberEntityUserObject(  this,   getModel(   ),   collisionDetector );
           getModel(   )->setUserObject(  userObject );
           }
          }
          
          
     326  void EmberPhysicalEntity::attachToPointOnModel(  const std::string& point,   Model::Model* model )
          {
           //if we're not initialized,   delay attachment until after init
           if (  !isInitialized(   ) ) {
           mModelMarkedToAttachTo = model;
           mAttachPointMarkedToAttachTo = point;
           } else {
           if (  model->hasAttachPoint(  point ) && model->getSkeleton(   ) ) {
           getScaleNode(   )->detachObject(  getModel(   ) );
           getModel(   )->setVisible(  true );
           model->attachObjectToAttachPoint(   point,   getModel(   ),   getScaleNode(   )->getScale(   ),   getModel(   )->getDefinition(   )->getRotation(   ) );
           mModelAttachedTo = model;
           }
           }
          }
          
     342  void EmberPhysicalEntity::detachFromModel(   )
          {
           if (  mModelAttachedTo ) {
           mModelAttachedTo->detachObjectFromBone(  getModel(   )->getName(   ) );
           getScaleNode(   )->attachObject(  getModel(   ) );
           checkVisibility(  isVisible(   ) );
           mModelAttachedTo = 0;
           }
          }
          
     352  void EmberPhysicalEntity::showOgreBoundingBox(  bool show )
          {
           getScaleNode(   )->showBoundingBox(  show );
          }
          
          
     358  bool EmberPhysicalEntity::getShowOgreBoundingBox(   ) const
          {
           return getScaleNode(   )->getShowBoundingBox(   );
          }
          
     363  Model::Model* EmberPhysicalEntity::getModel(   ) const
          {
           return mModel;
          }
          
     368  void EmberPhysicalEntity::Model_Reloaded(   )
          {
           initFromModel(   );
           attachAllEntities(   );
          }
          
     374  void EmberPhysicalEntity::Model_Resetting(   )
          {
           if (  getModel(   )->getUserObject(   ) ) {
           delete getModel(   )->getUserObject(   );
           }
           getModel(   )->setUserObject(  0 );
           detachAllEntities(   );
          }
          
     383  void EmberPhysicalEntity::processWield(  const std::string& wieldName,   const Atlas::Message::Element& idElement )
          {
           S_LOG_VERBOSE(  "Set " << wieldName << " to " << idElement.asString(   ) );
           const std::string& id = idElement.asString(   );
           if (  id.empty(   ) ) {
           detachEntity(  wieldName );
           } else {
           //detach first
           detachEntity(  wieldName );
           attachEntity(  wieldName,   id );
           }
          }
          
     396  void EmberPhysicalEntity::processOutfit(  const Atlas::Message::MapType & outfitMap )
          {
          }
          
          
     401  void EmberPhysicalEntity::onAttrChanged(  const std::string& str,   const Atlas::Message::Element& v ) {
           EmberEntity::onAttrChanged(  str,   v );
          
           ///this is kind of a hack,   but it allows characters to wield other entities in their hands
           if (  str == "right_hand_wield" || str == "left_hand_wield" ) {
           processWield(  str,   v );
           return;
           }
          // if (  str == "outfit" ) {
          // if (  v.isMap(   ) ) {
          // const Atlas::Message::MapType & outfitMap = v.asMap(   );
          // int i = 0;
          // }
          // }
          // if (  str == "bbox" ) {
          // scaleNode(   );
          // }
          
           //check if the changed attribute should affect any particle systems
           if (  mModel->hasParticles(   ) ) {
           const Model::ParticleSystemBindingsPtrSet& bindings = mModel->getAllParticleSystemBindings(   );
           for (  Model::ParticleSystemBindingsPtrSet::const_iterator I = bindings.begin(   ); I != bindings.end(   ); ++I ) {
           if (  (  *I )->getVariableName(   ) == str && v.isNum(   ) ) {
           (  *I )->scaleValue(  v.asNum(   ) );
           }
           }
           }
          
          
          }
          
     432  void EmberPhysicalEntity::onModeChanged(  MovementMode newMode )
          {
          /* if (  newMode != mMovementMode )
           {*/
           const char * actionName;
           if (  newMode == EmberEntity::MM_WALKING ) {
           actionName = ACTION_WALK;
           } else if (  newMode == EmberEntity::MM_RUNNING ) {
           actionName = ACTION_RUN;
           } else if (  newMode == EmberEntity::MM_SWIMMING ) {
           actionName = ACTION_SWIM;
           } else {
           actionName = ACTION_STAND;
           }
           if (  !mCurrentMovementAction || mCurrentMovementAction->getName(   ) != actionName ) {
           ///first disable the current action
           if (  mCurrentMovementAction ) {
           mCurrentMovementAction->getAnimations(   ).reset(   );
           }
          
           Model::Action* newAction = mModel->getAction(  actionName );
           mCurrentMovementAction = newAction;
           if (  newAction ) {
           MotionManager::getSingleton(   ).addAnimatedEntity(  this );
          // mCurrentMovementAction->getAnimations(   )->setEnabled(  true );
          
           } else {
           MotionManager::getSingleton(   ).removeAnimatedEntity(  this );
           }
           }
           //might set mCurrentMovementAction to 0
          // }
          
           EmberEntity::onModeChanged(  newMode );
          }
          
          
     469  void EmberPhysicalEntity::onChildAdded(  Entity *e )
          {
           Eris::Entity::onChildAdded(  e );
           //see if it's in our attach map
           if (  mAttachedEntities.find(  e->getId(   ) ) != mAttachedEntities.end(   ) ) {
           EmberEntity* emberEntity = static_cast<EmberEntity*>(  e );
           emberEntity->attachToPointOnModel(  mAttachedEntities[e->getId(   )],   getModel(   ) );
           }
          
          /* if (  hasChild(  entityId ) ) {
           }*/
          
          
          }
          
          
          
     486  void EmberPhysicalEntity::onChildRemoved(  Entity *e )
          {
           //NOTE: we don't have to do detachment here,   like we do attachment in onChildAdded,   since that is done by the EmberEntity::onLocationChanged(  ... ) method
           Eris::Entity::onChildRemoved(  e );
          }
          
          
     493  void EmberPhysicalEntity::scaleNode(   ) {
          
           getScaleNode(   )->setScale(  1,   1,   1 );
          
           const Ogre::Vector3& ogreMax = mDefaultOgreBoundingBox.getMaximum(   );
           const Ogre::Vector3& ogreMin = mDefaultOgreBoundingBox.getMinimum(   );
          
           if (  hasBBox(   ) ) {
          
           const WFMath::AxisBox<3>& wfBoundingBox = getBBox(   );
           const WFMath::Point<3>& wfMax = wfBoundingBox.highCorner(   );
           const WFMath::Point<3>& wfMin = wfBoundingBox.lowCorner(   );
          
           Ogre::Real scaleX;
           Ogre::Real scaleY;
           Ogre::Real scaleZ;
          
          
          
           switch (  getModel(   )->getUseScaleOf(   ) ) {
           case Model::ModelDefinition::MODEL_HEIGHT:
           scaleX = scaleY = scaleZ = fabs(  (  wfMax.z(   ) - wfMin.z(   ) ) / (  ogreMax.y - ogreMin.y ) );
           break;
           case Model::ModelDefinition::MODEL_WIDTH:
           scaleX = scaleY = scaleZ = fabs(  (  wfMax.x(   ) - wfMin.x(   ) ) / (  ogreMax.x - ogreMin.x ) );
           break;
           case Model::ModelDefinition::MODEL_DEPTH:
           scaleX = scaleY = scaleZ = fabs(  (  wfMax.y(   ) - wfMin.y(   ) ) / (  ogreMax.z - ogreMin.z ) );
           break;
           case Model::ModelDefinition::MODEL_NONE:
           scaleX = scaleY = scaleZ = 1;
           break;
          
           case Model::ModelDefinition::MODEL_ALL:
           default:
           scaleX = fabs(  (  wfMax.x(   ) - wfMin.x(   ) ) / (  ogreMax.x - ogreMin.x ) );
           scaleY = fabs(  (  wfMax.z(   ) - wfMin.z(   ) ) / (  ogreMax.y - ogreMin.y ) );
           scaleZ = fabs(  (  wfMax.y(   ) - wfMin.y(   ) ) / (  ogreMax.z - ogreMin.z ) );
           }
          
          
           //Ogre::Real finalScale = std::max(  scaleX,   scaleY );
           //finalScale = std::max(  finalScale,   scaleZ );
           getScaleNode(   )->setScale(  scaleX,   scaleY,   scaleZ );
          
           } else if (  !getModel(   )->getScale(   ) ) {
           //set to small size
          
           Ogre::Real scaleX = (  0.25 / (  ogreMax.x - ogreMin.x ) );
           Ogre::Real scaleY = (  0.25 / (  ogreMax.y - ogreMin.y ) );
           Ogre::Real scaleZ = (  0.25 / (  ogreMax.z - ogreMin.z ) );
           getScaleNode(   )->setScale(  scaleX,   scaleY,   scaleZ );
           }
          
           if (  getModel(   )->getScale(   ) ) {
           if (  getModel(   )->getScale(   ) != 1 ) {
           //only scale if it's not 1
           getScaleNode(   )->scale(  getModel(   )->getScale(   ),   getModel(   )->getScale(   ),   getModel(   )->getScale(   ) );
           }
           }
          
          
          }
          
     557  const Ogre::Vector3& EmberPhysicalEntity::getOffsetForContainedNode(  const Ogre::Vector3& position,   EmberEntity* const entity )
          {
           ///if the model has an offset specified,   use that,   else just send to the base class
           const Ogre::Vector3& offset = getModel(   )->getDefinition(   )->getContentOffset(   );
           if (  offset != Ogre::Vector3::ZERO ) {
           return offset;
           } else {
           return EmberEntity::getOffsetForContainedNode(  position,   entity );
           }
          
          }
          
          
     570  void EmberPhysicalEntity::updateMotion(  Ogre::Real timeSlice )
          {
           EmberEntity::updateMotion(  timeSlice );
          }
          
          
     576  void EmberPhysicalEntity::updateAnimation(  Ogre::Real timeSlice )
          {
           if (  mActiveAction ) {
           bool continuePlay = false;
           mActiveAction->getAnimations(   ).addTime(  timeSlice,   continuePlay );
           if (  !continuePlay ) {
           mActiveAction->getAnimations(   ).reset(   );
           mActiveAction = 0;
           }
           } else {
           if (  mCurrentMovementAction ) {
           bool continuePlay = false;
           //check if we're walking backward
           if (  static_cast<int>(  (  WFMath::Vector<3>(  getVelocity(   ) ).rotate(  (  getOrientation(   ).inverse(   ) ) ) ).x(   ) ) < 0 ) {
           mCurrentMovementAction->getAnimations(   ).addTime(  -timeSlice,   continuePlay );
           } else {
           mCurrentMovementAction->getAnimations(   ).addTime(  timeSlice,   continuePlay );
           }
           }
           }
          }
          
     598  void EmberPhysicalEntity::setMoving(  bool moving )
          {
          // MotionManager* motionManager = &MotionManager::getSingleton(   );
          // if (  moving ) {
          // if (  getModel(   )->isAnimated(   ) ) {
          // getModel(   )->stopAnimation(  "idle" );
          // getModel(   )->startAnimation(  "walk" );
          // }
          // } else {
          // if (  getModel(   )->isAnimated(   ) ) {
          // getModel(   )->stopAnimation(  "walk" );
          // getModel(   )->startAnimation(  "idle" );
          // }
          // }
           EmberEntity::setMoving(  moving );
          }
          
     615  void EmberPhysicalEntity::detachEntity(  const std::string & attachPoint )
          {
           const std::string* entityId(  0 );
           for(  AttachedEntitiesStore::const_iterator I = mAttachedEntities.begin(   ); I != mAttachedEntities.end(   ); ++I ) {
           if (  I->second == attachPoint ) {
           entityId = &I->first;
           break;
           }
           }
          
           if (  entityId ) {
           if (  hasChild(  *entityId ) ) {
           //we already have the entity,   do the detachment
           EmberEntity* entity = EmberOgre::getSingleton(   ).getEntity(  *entityId );
           if (  entity ) {
           entity->detachFromModel(   );
           }
           }
           mAttachedEntities.erase(  *entityId );
           }
          }
          
     637  void EmberPhysicalEntity::attachEntity(  const std::string & attachPoint,   const std::string & entityId )
          {
           mAttachedEntities[entityId] = attachPoint;
           if (  hasChild(  entityId ) ) {
           //we already have the entity,   do the attachment now,   else we will just wait for the onChildAdded event
           EmberEntity* entity = EmberOgre::getSingleton(   ).getEntity(  entityId );
           if (  entity ) {
           entity->attachToPointOnModel(  attachPoint,   getModel(   ) );
           }
           }
          }
          
     649  void EmberPhysicalEntity::detachAllEntities(   )
          {
           for(  AttachedEntitiesStore::const_iterator I = mAttachedEntities.begin(   ); I != mAttachedEntities.end(   ); ++I ) {
           detachEntity(  I->first );
           }
          }
          
     656  void EmberPhysicalEntity::attachAllEntities(   )
          {
          //HACK: this should be data driven
           if (  hasAttr(  "right_hand_wield" ) ) {
           const Atlas::Message::Element& idElement = valueOfAttr(  "right_hand_wield" );
           attachEntity(  "right_hand_wield",   idElement.asString(   ) );
           } else if (  hasAttr(  "left_hand_wield" ) ) {
           const Atlas::Message::Element& idElement = valueOfAttr(  "left_hand_wield" );
           attachEntity(  "left_hand_wield",   idElement.asString(   ) );
           }
          }
          
          
     669  void EmberPhysicalEntity::onBboxChanged(   )
          {
           EmberEntity::onBboxChanged(   );
           scaleNode(   );
          }
          
     675  const Ogre::AxisAlignedBox& EmberPhysicalEntity::getWorldBoundingBox(  bool derive ) const
          {
           return getModel(   )->getWorldBoundingBox(  derive );
          }
          
     680  const Ogre::Sphere & EmberPhysicalEntity::getWorldBoundingSphere (  bool derive ) const
          {
           return getModel(   )->getWorldBoundingSphere(  derive );
          }
          
     685  void EmberPhysicalEntity::onAction(  const Atlas::Objects::Operation::RootOperation& act )
          {
          
          /* std::string allattribs;
          
           //Atlas::Objects::BaseObjectData::const_iterator I = act->begin(   );
           std::list< std::string >::const_iterator I = act->getParents(   ).begin(   );
          
           for (  ; I != act->getParents(   ).end(   ); ++I )
           {
           //const Atlas::Message::Element e = (  const Atlas::Message::Element )(  *I ).second;
           allattribs.append(  (  *I ) + " : " );
          
           }*/
          
           const std::list<std::string> &p = act->getParents(   );
           std::list<std::string>::const_iterator I = p.begin(   );
          
           if (  I != p.end(   ) ) {
           const std::string& name = *I;
          
           Model::Action* newAction = mModel->getAction(  name );
          
           ///If there's no action found,   try to see if we have a "default action" defined to play instead.
           if (  !newAction ) {
           newAction = mModel->getAction(  "default_action" );
           }
          
           if (  newAction ) {
           MotionManager::getSingleton(   ).addAnimatedEntity(  this );
           mActiveAction = newAction;
           newAction->getAnimations(   ).reset(   );
           mCurrentMovementAction->getAnimations(   ).reset(   );
           }
           }
           EmberEntity::onAction(  act );
          }
          
     723  bool EmberPhysicalEntity::allowVisibilityOfMember(  EmberEntity* entity ) {
           return mModel->getDefinition(   )->getShowContained(   );
          }
          
     727  void EmberPhysicalEntity::setVisualize(  const std::string& visualization,   bool visualize )
          {
           if (  visualization == "CollisionObject" ) {
           if (  getModel(   ) ) {
           EmberEntityUserObject* userObject = static_cast<EmberEntityUserObject*>(  getModel(   )->getUserObject(   ) );
           if (  userObject && userObject->getCollisionDetector(   ) ) {
           userObject->getCollisionDetector(   )->setVisualize(  visualize );
           }
           }
           } else {
           EmberEntity::setVisualize(  visualization,   visualize );
           }
          }
          
     741  bool EmberPhysicalEntity::getVisualize(  const std::string& visualization ) const
          {
           if (  visualization == "CollisionObject" ) {
           if (  getModel(   ) ) {
           EmberEntityUserObject* userObject = static_cast<EmberEntityUserObject*>(  getModel(   )->getUserObject(   ) );
           if (  userObject && userObject->getCollisionDetector(   ) ) {
           return userObject->getCollisionDetector(   )->getVisualize(   );
           }
           }
           return false;
           } else {
           return EmberEntity::getVisualize(  visualization );
           }
          }
          
          /*
          void EmberPhysicalEntity::handleTalk(  const std::string &msg )
          {
          
           std::string message = "<";
           message.append(  getName(   ) );
           message.append(  "> " );
           message.append(  msg );
           std::cout << "TRACE - ENTITY SAYS: [" << message << "]\n" << std::endl;
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  message );
          }
          */
          
          
          
          /*
          void EmberPhysicalEntity::setContainer(  Entity *pr )
          {
          
           EmberEntity* EmberEntity = dynamic_cast<EmberEntity*>(  pr );
           if (  EmberEntity ) {
           //detach from our current object and add to the new entity
           getSceneNode(   )->getParent(   )->removeChild(  getSceneNode(   )->getName(   ) );
           EmberEntity->getSceneNode(   )->addChild(  getSceneNode(   ) );
          
           } else {
           //detach from our current object and add to the world
           getSceneNode(   )->getParent(   )->removeChild(  getSceneNode(   )->getName(   ) );
           getSceneNode(   )->getCreator(   )->getRootSceneNode(   )->addChild(  getSceneNode(   ) );
           }
          
          }
          */
          
          
          
          
          
          
          }

./components/ogre/EmberPhysicalEntity.h

          /*
           Copyright (  C ) 2004 Erik Hjortsberg
           some parts Copyright (  C ) 2004 bad_camel at Ogre3d forums
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef DIMEPHYSICALENTITY_H
          #define DIMEPHYSICALENTITY_H
          
          #include "EmberOgrePrerequisites.h"
          
          #include "EmberEntity.h"
          
          
          namespace EmberOgre {
          
          namespace Model {
      31   class Model;
      32   class Action;
           namespace Mapping {
      34   class ModelMapping;
           }
          };
          
          
          
      40  class EmberEntity;
          
          typedef std::list<Model::Action*> ActionStore;
          
          /**
           * Represents a Ember entity with a physical representation in the world.
           * This is represented by a an Ogre::Entity.
           */
      48  class EmberPhysicalEntity : public EmberEntity
          {
      50  friend class EmberEntityModelAction;
      51  friend class EmberEntityPartAction;
          public:
          
           static const char * const ACTION_STAND;
      55   static const char * const ACTION_RUN;
      56   static const char * const ACTION_WALK;
      57   static const char * const ACTION_SWIM;
      58   static const char * const ACTION_FLOAT;
          
          
          
          
           EmberPhysicalEntity(  const std::string& id,   Eris::TypeInfo* ty,   Eris::View* vw,   Ogre::SceneManager* sceneManager );
           virtual ~EmberPhysicalEntity(   );
          
          
          
           /**
           * return the Model of this object
           */
           Model::Model* getModel(   ) const;
          
           inline Ogre::SceneNode* getScaleNode(   ) const;
          
          
          
          
          
           virtual void setVisible(  bool visible );
          
           virtual void attachToPointOnModel(  const std::string& point,   Model::Model* model );
           virtual void detachFromModel(   );
          
           virtual void updateMotion(  Ogre::Real timeSlice );
          
           void updateAnimation(  Ogre::Real timeSlice );
          
           virtual void showOgreBoundingBox(  bool show );
          // virtual void showErisBoundingBox(  bool show );
          
           virtual bool getShowOgreBoundingBox(   ) const;
          // virtual bool getShowErisBoundingBox(   );
          
          
           /**
           * Returns the entity that's attched to the specified point,   if there is such
           * @param attachPoint
           * @return a pointer to the EmberEntity,   or 0 if none found
           */
           EmberEntity* getEntityAttachedToPoint(  const std::string& attachPoint );
          
           virtual const Ogre::AxisAlignedBox& getWorldBoundingBox(  bool derive = true ) const;
           virtual const Ogre::Sphere & getWorldBoundingSphere (  bool derive=true ) const;
          
          
           /**
           * Called by a contained member to see if the member is allowed to be shown.
           * This can be reimplemented in a subclass such as AvatarEmberEntity to
           * disallow things that belongs to a characters inventory to be shown.
           */
           virtual bool allowVisibilityOfMember(  EmberEntity* entity );
          
          
           /**
           * General method for turning on and off debug visualizations. Subclasses might support more types of visualizations than the ones defined here.
           * @param visualization The type of visualization. Currently supports "OgreBBox" and "ErisBBox".
           * @param visualize Whether to visualize or not.
           */
           virtual void setVisualize(  const std::string& visualization,   bool visualize );
          
          
           /**
           * Gets whether a certain visualization is turned on or off.
           * @param visualization The type of visualization. Currently supports "OgreBBox" and "ErisBBox".
           * @return true if visualization is turned on,   else false
           */
           virtual bool getVisualize(  const std::string& visualization ) const;
          
          protected:
          
           void setModel(  const std::string& modelName );
          
           void showModelPart(  const std::string& partName );
           void hideModelPart(  const std::string& partName );
          
           virtual const Ogre::Vector3& getOffsetForContainedNode(  const Ogre::Vector3& position,   EmberEntity* const entity );
          
           /**
           * creates EmberEntityUserObjects,   connects them and sets up the collision detection system
           * @return
           */
           void connectEntities(   );
          
           void createModelMapping(   );
           void createScaleNode(   );
          
          
           /**
           * Called when the bounding box has changed.
           */
           virtual void onBboxChanged(   );
          
           /**
           * Called when the movement mode has changed. We might want to update the animation of the entity,   for example if it's a human.
           * @param newMode
           */
           virtual void onModeChanged(  MovementMode newMode );
          
           /**
           The current movement action of the entity,   for example a walk action or a run action.
           */
           Model::Action* mCurrentMovementAction;
          
           /**
           All the active actions,   except the movement action (  since it's stored in mCurrentMovementAction ).
           These actions will be updated each frame.
           NOTE: we currently don't allow for multiple actions playing at the same time
           */
           //ActionStore mActiveActions;
           Model::Action* mActiveAction;
          
           /**
           If the entity is attached to another entity,   this is the model to which it is attached to.
           This will be 0 if the entity isn't attached.
           */
           Model::Model* mModelAttachedTo;
          
           Model::Model* mModelMarkedToAttachTo;
           std::string mAttachPointMarkedToAttachTo;
          
           virtual void onChildAdded(  Entity *e );
           virtual void onChildRemoved(  Entity *e );
          
          
          
           /**
           * Detaches an entity which is already wielded.
           * @param entityId
           */
           void detachEntity(  const std::string & entityId );
          
           /**
           * Attaches an entity to a certain attach point
           * @param attachPoint the name of the attachpoint to attach to
           * @param entityId the id of the entity to attach to
           */
           void attachEntity(  const std::string & attachPoint,   const std::string & entityId );
          
           /**
           Detaches all currently attached entities. Call this before the Model is resetted.
           */
           void detachAllEntities(   );
          
           /**
           Attaches all entities that aren't currently attached.
           */
           void attachAllEntities(   );
          
          
           /**
           * Process wield ops,   which means wielding and unwielding entities. This methos will in turn call the appropriate attachEntity and detachEntity methods.
           * @param wieldName the attachpoint to update
           * @param idElement the id of the entity to wield
           */
           void processWield(  const std::string& wieldName,   const Atlas::Message::Element& idElement );
          
          
           /**
           * Processes the outfit map and updates the appearance.
           * @param outfitMap
           */
           void processOutfit(  const Atlas::Message::MapType & outfitMap );
          
           /**
           * Overridden from Eris::Entity
           * @param str
           * @param v
           */
           virtual void onAttrChanged(  const std::string& str,   const Atlas::Message::Element& v );
           /**
           * Overridden from Eris::Entity
           * @param act
           */
           virtual void onAction(  const Atlas::Objects::Operation::RootOperation& act );
          
           typedef std::map<std::string,   std::string> AttachedEntitiesStore;
           /**
           A store of all attached entities,   indexed by their id.
           */
           AttachedEntitiesStore mAttachedEntities;
          
          // virtual void onMoved(   );
           /**
           * Overridden from Eris::Entity
           * @param moving
           */
           virtual void setMoving(  bool moving );
          
           /**
           * Overridden from Eris::Entity
           * @param ge
           */
           virtual void init(  const Atlas::Objects::Entity::RootEntity &ge,   bool fromCreateOp );
          
          
           /**
           The default size of the ogre bounding box,   before any scaling is done.
           */
           Ogre::AxisAlignedBox mDefaultOgreBoundingBox;
          
          
           /**
           * Scales the Ogre::SceneNode to the size of the AxisBox defined by Eris::Entity
           */
           virtual void scaleNode(   );
          
           //void setNodes(   );
          
          
           /**
           * The model of the entity
           */
           Model::Model* mModel;
          
           /**
           * We need to scale the Ogre::Entity,   because the underlying media is not
           * always correctly scaled.
           * But since each Eris::Entity can contain child entites,   we'll get problems
           * with scaling if we attach the children to a scaled node.
           * Thus we use a separate,   scaled node.
           */
           Ogre::SceneNode* mScaleNode;
          
           void Model_Reloaded(   );
          
           void Model_Resetting(   );
          
           void initFromModel(   );
          
           Model::Mapping::ModelMapping* mModelMapping;
          
          
          };
          
          Ogre::SceneNode* EmberPhysicalEntity::getScaleNode(   ) const
          {
           return mScaleNode;
          }
          
          
          }
          #endif // DIMEPHYSICALENTITY_H

./components/ogre/EntityWorldPickListener.cpp

          //
          // C++ Implementation: EntityWorldPickListener
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityWorldPickListener.h"
          #include "EmberOgre.h"
          #include "EmberEntityUserObject.h"
          
          #include "model/Model.h"
          #include "EmberEntityFactory.h"
          
          #include "EmberEntity.h"
          #include "WorldEmberEntity.h"
          
          #include "MousePicker.h"
          
          namespace EmberOgre {
          
      37  EntityWorldPickListenerVisualizer::EntityWorldPickListenerVisualizer(  EntityWorldPickListener& pickListener )
          : mEntity(  0 ),   mDebugNode(  0 )
          {
           mDebugNode = EmberOgre::getSingleton(   ).getSceneManager(   )->getRootSceneNode(   )->createChildSceneNode(   );
           Ogre::Entity* mEntity = EmberOgre::getSingleton(   ).getSceneManager(   )->createEntity(  "pickerDebugObject",   "fireball.mesh" );
           ///start out with a normal material
           mEntity->setMaterialName(  "BasePointMarkerMaterial" );
           mEntity->setRenderingDistance(  300 );
           mEntity->setQueryFlags(  MousePicker::CM_NONPICKABLE );
           mDebugNode->attachObject(  mEntity );
          
           pickListener.EventPickedEntity.connect(  sigc::mem_fun(  *this,   &EntityWorldPickListenerVisualizer::picker_EventPickedEntity ) );
          }
          
      51  EntityWorldPickListenerVisualizer::~EntityWorldPickListenerVisualizer(   )
          {
           EmberOgre::getSingleton(   ).getSceneManager(   )->destroyEntity(  mEntity );
           EmberOgre::getSingleton(   ).getSceneManager(   )->destroySceneNode(  mDebugNode->getName(   ) );
          }
          
      57  void EntityWorldPickListenerVisualizer::picker_EventPickedEntity(  const EntityPickResult& result,   const MousePickerArgs& mouseArgs )
          {
           mDebugNode->setPosition(  result.position );
          }
          
          
          
      64  EntityWorldPickListener::EntityWorldPickListener(   )
          : VisualizePicking(  "visualize_picking",   this,   "Visualize mouse pickings." )
      66  ,   mClosestPickingDistance(  0 )
          ,   mFurthestPickingDistance(  0 )
          ,   mVisualizer(  0 )
          {
          }
          
          
      73  EntityWorldPickListener::~EntityWorldPickListener(   )
          {
          }
          
      77  void EntityWorldPickListener::initializePickingContext(   )
          {
           mClosestPickingDistance = 0;
           mFurthestPickingDistance = 0;
           mResult = EntityPickResult(   );
           mResult.entity = 0;
           mResult.position = Ogre::Vector3::ZERO;
           mResult.distance = 0;
          }
          
      87  void EntityWorldPickListener::endPickingContext(  const MousePickerArgs& mousePickerArgs )
          {
           if (  mResult.entity ) {
           std::stringstream ss;
           ss << mResult.position;
           S_LOG_VERBOSE(  "Picked entity: " << ss.str(   ) << " distance: " << mResult.distance );
           EventPickedEntity(  mResult,   mousePickerArgs );
           }
          }
          
          
          
          
     100  void EntityWorldPickListener::processPickResult(  bool& continuePicking,   Ogre::RaySceneQueryResultEntry& entry,   Ogre::Ray& cameraRay,   const MousePickerArgs& mousePickerArgs )
          {
          
           if (  entry.worldFragment ) {
           ///this is terrain
           ///a position of -1,   -1,   -1 is not valid terrain
           Ogre::SceneQuery::WorldFragment* wf = entry.worldFragment;
           static Ogre::Vector3 invalidPos(  -1,   -1,   -1 );
           if (  wf->singleIntersection != invalidPos ) {
           if (  mFurthestPickingDistance == 0 ) {
           mResult.entity = EmberOgre::getSingleton(   ).getEntityFactory(   )->getWorld(   );
           mResult.position = wf->singleIntersection;
           mResult.distance = entry.distance;
           continuePicking = false;
           } else {
           if (  entry.distance < mResult.distance ) {
           mResult.entity = EmberOgre::getSingleton(   ).getEntityFactory(   )->getWorld(   );
           mResult.position = wf->singleIntersection;
           mResult.distance = entry.distance;
           continuePicking = false;
           }
           }
           }
          /* std::stringstream ss;
           ss << wf->singleIntersection;
           S_LOG_VERBOSE(  "Picked in terrain: " << ss.str(   ) << " distance: " << mResult.distance );*/
          
           } else if (  entry.movable ) {
           Ogre::MovableObject* pickedMovable = entry.movable;
           if (  pickedMovable->isVisible(   ) && pickedMovable->getUserObject(   ) != 0 && pickedMovable->getUserObject(   )->getTypeName(   ) == "EmberEntityPickerObject" ) {
           EmberEntityUserObject* anUserObject = static_cast<EmberEntityUserObject*>(  pickedMovable->getUserObject(   ) );
           ///refit the opcode mesh to adjust for changes in the mesh (  for example animations )
           anUserObject->refit(   );
          
           ICollisionDetector* collisionDetector = anUserObject->getCollisionDetector(   );
           if (  collisionDetector ) {
           CollisionResult collisionResult;
           collisionResult.collided = false;
           collisionDetector->testCollision(  cameraRay,   collisionResult );
           if (  collisionResult.collided ) {
           EntityPickResult result;
           result.entity = anUserObject->getEmberEntity(   );
           result.position = collisionResult.position;
           result.distance = collisionResult.distance;
           if (  mFurthestPickingDistance == 0 ) {
           ///test all objects that fall into this distance
           mFurthestPickingDistance = (  pickedMovable->getParentSceneNode(   )->getWorldPosition(   ) - cameraRay.getOrigin(   ) ).length(   ) + pickedMovable->getBoundingRadius(   );
           mResult = result;
           } else {
           if (  (  pickedMovable->getParentSceneNode(   )->getWorldPosition(   ) - cameraRay.getOrigin(   ) ).length(   ) - pickedMovable->getBoundingRadius(   ) > mFurthestPickingDistance ) {
           continuePicking = false;
           } else {
           if (  result.distance < mResult.distance ) {
           mResult = result;
           }
           }
           }
          
           }
           }
          
          
          
          
           ///only do opcode detection if there's a CollisionObject
          // for (  EmberEntityUserObject::CollisionObjectStore::iterator I = collisionObjects->begin(   ); I != collisionObjects->end(   ); ++I ) {
          // OgreOpcode::ICollisionShape* collisionShape = (  *I )->getShape(   );
          // OgreOpcode::CollisionPair pick_result;
          //
          // if (  collisionShape->rayCheck(  OgreOpcode::COLLTYPE_QUICK,  anUserObject->getModel(   )->_getParentNodeFullTransform(   ),  cameraRay,   1000,   pick_result ) ) {
          // EntityPickResult result;
          // result.entity = anUserObject->getEmberEntity(   );
          // result.position = pick_result.contact;
          // result.distance = pick_result.distance;
          //
          // std::stringstream ss;
          // ss << result.position;
          // S_LOG_VERBOSE(  "Picked entity: " << ss.str(   ) << " distance: " << result.distance );
          // EventPickedEntity(  result,   mousePickerArgs );
          // continuePicking = false;
          //
          // }
          // }
           }
           }
          
          }
          
     188  void EntityWorldPickListener::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  VisualizePicking == command ) {
           if (  mVisualizer.get(   ) ) {
           mVisualizer.reset(   );
           } else {
           mVisualizer = std::auto_ptr<EntityWorldPickListenerVisualizer>(  new EntityWorldPickListenerVisualizer(  *this ) );
           }
           }
          }
          
          }

./components/ogre/EntityWorldPickListener.h

       1  //
          // C++ Interface: EntityWorldPickListener
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREENTITYWORLDPICKLISTENER_H
          #define EMBEROGREENTITYWORLDPICKLISTENER_H
          
          #include "EmberOgrePrerequisites.h"
          #include "IWorldPickListener.h"
          #include <sigc++/signal.h>
          #include "framework/ConsoleObject.h"
          
          
          namespace EmberOgre {
          
          
      35  class EmberEntity;
      36  class EntityWorldPickListener;
          /**
           * Struct used for returning the result of a mouse pick.
           */
          struct EntityPickResult
          {
           EmberEntity* entity;
           Ogre::Vector3 position;
           Ogre::Real distance;
          };
          
          /**
          Visualizes the picking operation by placing a large ball at the picked position.
          */
      50  class EntityWorldPickListenerVisualizer : public virtual sigc::trackable
          {
          public:
      53   EntityWorldPickListenerVisualizer(  EntityWorldPickListener& pickListener );
      54   virtual ~EntityWorldPickListenerVisualizer(   );
          
          private:
      57   Ogre::Entity* mEntity;
      58   Ogre::SceneNode* mDebugNode;
      59   void picker_EventPickedEntity(  const EntityPickResult& result,   const MousePickerArgs& mouseArgs );
          };
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      65  class EntityWorldPickListener : public IWorldPickListener,   public Ember::ConsoleObject
          {
          public:
      68   EntityWorldPickListener(   );
          
      70   ~EntityWorldPickListener(   );
          
      72   virtual void initializePickingContext(   );
          
      74   virtual void endPickingContext(  const MousePickerArgs& mousePickerArgs );
          
          
      77   virtual void processPickResult(  bool& continuePicking,   Ogre::RaySceneQueryResultEntry& entry,   Ogre::Ray& cameraRay,   const MousePickerArgs& mousePickerArgs );
          
      79   sigc::signal<void,   const EntityPickResult&,   const MousePickerArgs&> EventPickedEntity;
          
      81   const Ember::ConsoleCommandWrapper VisualizePicking;
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
      88   virtual void runCommand(  const std::string &command,   const std::string &args );
          
          protected:
           float mClosestPickingDistance,   mFurthestPickingDistance;
           EntityPickResult mResult;
          
      94   std::auto_ptr<EntityWorldPickListenerVisualizer> mVisualizer;
          
          };
          
          }
          
          #endif

./components/ogre/FreeCameraController.cpp

       1  //
          // C++ Implementation: FreeCameraController
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "FreeCameraController.h"
          
          namespace EmberOgre {
          
      27  FreeCameraController::FreeCameraController(   )
          {
          }
          
          
      32  FreeCameraController::~FreeCameraController(   )
          {
          }
          
          
          };

./components/ogre/FreeCameraController.h

       1  //
          // C++ Interface: FreeCameraController
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREFREECAMERACONTROLLER_H
          #define EMBEROGREFREECAMERACONTROLLER_H
          
          namespace EmberOgre {
          
          /**
          @author Erik Hjortsberg
          
          This is a controller wchich allows for free flight.
          */
      33  class FreeCameraController{
          public:
      35   FreeCameraController(   );
          
      37   ~FreeCameraController(   );
          
          };
          
          };
          
          #endif

./components/ogre/GUICEGUIAdapter.cpp

       1  //
          // C++ Implementation: GUICEGUIAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "GUICEGUIAdapter.h"
          
          #include <CEGUIExceptions.h>
          #include <CEGUIGlobalEventSet.h>
          #include <elements/CEGUIEditbox.h>
          #include <elements/CEGUIMultiLineEditbox.h>
          
          namespace EmberOgre {
          
      32  GUICEGUIAdapter::GUICEGUIAdapter(  CEGUI::System *system,   CEGUI::OgreCEGUIRenderer *renderer ):
          mGuiSystem(  system )
          ,   mGuiRenderer(  renderer )
          ,   mSelectedText(  0 )
          {
          
           //lookup table for sdl scancodes and CEGUI keys
           mKeyMap[SDLK_BACKSPACE] = CEGUI::Key::Backspace;
           mKeyMap[SDLK_TAB] = CEGUI::Key::Tab;
          /* mKeyMap[SDLK_CLEAR] = CEGUI::Key::Clear;*/
           mKeyMap[SDLK_RETURN] = CEGUI::Key::Return;
           mKeyMap[SDLK_PAUSE] = CEGUI::Key::Pause;
           mKeyMap[SDLK_ESCAPE] = CEGUI::Key::Escape;
           mKeyMap[SDLK_SPACE] = CEGUI::Key::Space;
          /* mKeyMap[SDLK_EXCLAIM] = CEGUI::Key::Exclaim;*/
          /* mKeyMap[SDLK_QUOTEDBL] = CEGUI::Key::;
           mKeyMap[SDLK_HASH] = CEGUI::Key::;
           mKeyMap[SDLK_DOLLAR] = CEGUI::Key::;
           mKeyMap[SDLK_AMPERSAND] = CEGUI::Key::;
           mKeyMap[SDLK_QUOTE] = CEGUI::Key::;
           mKeyMap[SDLK_LEFTPAREN] = CEGUI::Key::;
           mKeyMap[SDLK_RIGHTPAREN] = CEGUI::Key::;
           mKeyMap[SDLK_ASTERISK] = CEGUI::Key::;*/
           mKeyMap[SDLK_PLUS] = CEGUI::Key::Add;
          /* mKeyMap[SDLK_COMMA] = CEGUI::Key::;*/
           mKeyMap[SDLK_MINUS] = CEGUI::Key::Minus;
           mKeyMap[SDLK_PERIOD] = CEGUI::Key::Period;
          /* mKeyMap[SDLK_SLASH] = CEGUI::Key::;*/
           mKeyMap[SDLK_0] = CEGUI::Key::One;
           mKeyMap[SDLK_1] = CEGUI::Key::Two;
           mKeyMap[SDLK_2] = CEGUI::Key::Two;
           mKeyMap[SDLK_3] = CEGUI::Key::Three;
           mKeyMap[SDLK_4] = CEGUI::Key::Four;
           mKeyMap[SDLK_5] = CEGUI::Key::Five;
           mKeyMap[SDLK_6] = CEGUI::Key::Six;
           mKeyMap[SDLK_7] = CEGUI::Key::Seven;
           mKeyMap[SDLK_8] = CEGUI::Key::Eight;
           mKeyMap[SDLK_9] = CEGUI::Key::Nine;
           mKeyMap[SDLK_COLON] = CEGUI::Key::Colon;
           mKeyMap[SDLK_SEMICOLON] = CEGUI::Key::Semicolon;
          /* mKeyMap[SDLK_LESS] = CEGUI::Key::;*/
          /* mKeyMap[SDLK_EQUALS] = CEGUI::Key::;
           mKeyMap[SDLK_GREATER] = CEGUI::Key::;
           mKeyMap[SDLK_QUESTION] = CEGUI::Key::;*/
          /* mKeyMap[SDLK_AT] = CEGUI::Key::;*/
          /* mKeyMap[SDLK_LEFTBRACKET] = CEGUI::Key::;*/
           mKeyMap[SDLK_BACKSLASH] = CEGUI::Key::Backslash;
          /* mKeyMap[SDLK_RIGHTBRACKET] = CEGUI::Key::;*/
          /* mKeyMap[SDLK_CARET] = CEGUI::Key::;
           mKeyMap[SDLK_UNDERSCORE] = CEGUI::Key::;
           mKeyMap[SDLK_BACKQUOTE] = CEGUI::Key::;*/
           mKeyMap[SDLK_a] = CEGUI::Key::A;
           mKeyMap[SDLK_b] = CEGUI::Key::B;
           mKeyMap[SDLK_c] = CEGUI::Key::C;
           mKeyMap[SDLK_d] = CEGUI::Key::D;
           mKeyMap[SDLK_e] = CEGUI::Key::E;
           mKeyMap[SDLK_f] = CEGUI::Key::F;
           mKeyMap[SDLK_g] = CEGUI::Key::G;
           mKeyMap[SDLK_h] = CEGUI::Key::H;
           mKeyMap[SDLK_i] = CEGUI::Key::I;
           mKeyMap[SDLK_j] = CEGUI::Key::J;
           mKeyMap[SDLK_k] = CEGUI::Key::K;
           mKeyMap[SDLK_l] = CEGUI::Key::L;
           mKeyMap[SDLK_m] = CEGUI::Key::M;
           mKeyMap[SDLK_n] = CEGUI::Key::N;
           mKeyMap[SDLK_o] = CEGUI::Key::O;
           mKeyMap[SDLK_p] = CEGUI::Key::P;
           mKeyMap[SDLK_q] = CEGUI::Key::Q;
           mKeyMap[SDLK_r] = CEGUI::Key::R;
           mKeyMap[SDLK_s] = CEGUI::Key::S;
           mKeyMap[SDLK_t] = CEGUI::Key::T;
           mKeyMap[SDLK_u] = CEGUI::Key::U;
           mKeyMap[SDLK_v] = CEGUI::Key::V;
           mKeyMap[SDLK_w] = CEGUI::Key::W;
           mKeyMap[SDLK_x] = CEGUI::Key::X;
           mKeyMap[SDLK_y] = CEGUI::Key::Y;
           mKeyMap[SDLK_z] = CEGUI::Key::Z;
           mKeyMap[SDLK_DELETE] = CEGUI::Key::Delete;
           mKeyMap[SDLK_UP] = CEGUI::Key::ArrowUp;
           mKeyMap[SDLK_DOWN] = CEGUI::Key::ArrowDown;
           mKeyMap[SDLK_RIGHT] = CEGUI::Key::ArrowRight;
           mKeyMap[SDLK_LEFT] = CEGUI::Key::ArrowLeft;
           mKeyMap[SDLK_INSERT] = CEGUI::Key::Insert;
           mKeyMap[SDLK_HOME] = CEGUI::Key::Home;
           mKeyMap[SDLK_END] = CEGUI::Key::End;
           mKeyMap[SDLK_PAGEUP] = CEGUI::Key::PageUp;
           mKeyMap[SDLK_PAGEDOWN] = CEGUI::Key::PageDown;
           mKeyMap[SDLK_F1] = CEGUI::Key::F1;
           mKeyMap[SDLK_F2] = CEGUI::Key::F2;
           mKeyMap[SDLK_F3] = CEGUI::Key::F3;
           mKeyMap[SDLK_F4] = CEGUI::Key::F4;
           mKeyMap[SDLK_F5] = CEGUI::Key::F5;
           mKeyMap[SDLK_F6] = CEGUI::Key::F6;
           mKeyMap[SDLK_F7] = CEGUI::Key::F7;
           mKeyMap[SDLK_F8] = CEGUI::Key::F8;
           mKeyMap[SDLK_F9] = CEGUI::Key::F9;
           mKeyMap[SDLK_F10] = CEGUI::Key::F10;
           mKeyMap[SDLK_F11] = CEGUI::Key::F11;
           mKeyMap[SDLK_F12] = CEGUI::Key::F12;
           mKeyMap[SDLK_F13] = CEGUI::Key::F13;
           mKeyMap[SDLK_F14] = CEGUI::Key::F14;
           mKeyMap[SDLK_F15] = CEGUI::Key::F15;
           mKeyMap[SDLK_NUMLOCK] = CEGUI::Key::NumLock;
           mKeyMap[SDLK_SCROLLOCK] = CEGUI::Key::ScrollLock;
           mKeyMap[SDLK_RSHIFT] = CEGUI::Key::RightShift;
           mKeyMap[SDLK_LSHIFT] = CEGUI::Key::LeftShift;
           mKeyMap[SDLK_RCTRL] = CEGUI::Key::RightControl;
           mKeyMap[SDLK_LCTRL] = CEGUI::Key::LeftControl;
           mKeyMap[SDLK_RALT] = CEGUI::Key::RightAlt;
           mKeyMap[SDLK_LALT] = CEGUI::Key::LeftAlt;
          
          
           ///set up the capturing of text selected event for the copy-and-paste functionality
          
          //window->subscribeEvent(  event,   CEGUI::Event::Subscriber(  &method,   this ) );
          
           CEGUI::GlobalEventSet::getSingleton(   ).subscribeEvent(  "MultiLineEditbox/TextSelectionChanged",   CEGUI::Event::Subscriber(  &GUICEGUIAdapter::MultiLineEditbox_selectionChangedHandler,   this ) );
           CEGUI::GlobalEventSet::getSingleton(   ).subscribeEvent(  "Editbox/TextSelectionChanged",   CEGUI::Event::Subscriber(  &GUICEGUIAdapter::Editbox_selectionChangedHandler,   this ) );
           //CEGUI::GlobalEventSet::getSingleton(   ).subscribeEvent(  "Editbox/TextSelectionChanged",   &GUICEGUIAdapter::selectionChangedHandler );
          
          
          
          }
          
          
     157  GUICEGUIAdapter::~GUICEGUIAdapter(   )
          {
          }
          
     161  bool GUICEGUIAdapter::MultiLineEditbox_selectionChangedHandler(  const CEGUI::EventArgs& args )
          {
           CEGUI::MultiLineEditbox* editbox = static_cast<CEGUI::MultiLineEditbox*>(  mGuiSystem->getGUISheet(   )->getActiveChild(   ) );
           mSelectedText = &editbox->getText(   );
           mSelectionStart = editbox->getSelectionStartIndex(   );
           mSelectionEnd = editbox->getSelectionEndIndex(   );
          /* const CEGUI::String& text = editbox->getText(   );
           if (  editbox->getSelectionLength(   ) > 0 ) {
           std::string selection = text.substr(  editbox->getSelectionStartIndex(   ),   editbox->getSelectionEndIndex(   ) ).c_str(   );
           S_LOG_VERBOSE(  "Selected text: " << selection );
           }*/
          // S_LOG_VERBOSE(  "Selected text." );
          
           return true;
          }
          
     177  bool GUICEGUIAdapter::Editbox_selectionChangedHandler(  const CEGUI::EventArgs& args )
          {
           CEGUI::Editbox* editbox = static_cast<CEGUI::Editbox*>(  mGuiSystem->getGUISheet(   )->getActiveChild(   ) );
           mSelectedText = &editbox->getText(   );
           mSelectionStart = editbox->getSelectionStartIndex(   );
           mSelectionEnd = editbox->getSelectionEndIndex(   );
           S_LOG_VERBOSE(  "Selected text." );
           return true;
          }
          
          // bool GUICEGUIAdapter::selectionChangedHandler(  const CEGUI::EventArgs& args )
          // {
          // S_LOG_VERBOSE(  "" );
          // }
          
     192  bool GUICEGUIAdapter::injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse )
          {
           try {
           CEGUI::MouseCursor::getSingleton(   ).setPosition(  CEGUI::Point(  (  motion.xPosition ),   (  motion.yPosition ) ) );
           mGuiSystem->injectMouseMove(  0.0f,   0.0f );
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           }
           return true;
          }
          
     203  bool GUICEGUIAdapter::injectMouseButtonUp(  const Input::MouseButton& button )
          {
           CEGUI::MouseButton ceguiButton;
           if (  button == Input::MouseButtonLeft ) {
           ceguiButton = CEGUI::LeftButton;
           } else if(  button == Input::MouseButtonRight ) {
           ceguiButton = CEGUI::RightButton;
           } else if(  button == Input::MouseButtonMiddle ) {
           ceguiButton = CEGUI::MiddleButton;
           } else {
           return true;
           }
          
           try {
           mGuiSystem->injectMouseButtonUp(  ceguiButton );
           return false;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           } catch (  ... ) {
           S_LOG_WARNING(  "Unknown error in CEGUI." );
           }
           return true;
          }
          
     227  bool GUICEGUIAdapter::injectMouseButtonDown(  const Input::MouseButton& button )
          {
           CEGUI::MouseButton ceguiButton;
           if (  button == Input::MouseButtonLeft ) {
           ceguiButton = CEGUI::LeftButton;
           } else if(  button == Input::MouseButtonRight ) {
           ceguiButton = CEGUI::RightButton;
           } else if(  button == Input::MouseButtonMiddle ) {
           ceguiButton = CEGUI::MiddleButton;
           } else if(  button == Input::MouseWheelDown ) {
           try {
           mGuiSystem->injectMouseWheelChange(  -1.0 );
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           }
           return false;
           } else if(  button == Input::MouseWheelUp ) {
           try {
           mGuiSystem->injectMouseWheelChange(  1.0 );
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           }
           return false;
           } else {
           return true;
           }
          
           try {
           mGuiSystem->injectMouseButtonDown(  ceguiButton );
           return false;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           }
           return true;
          }
          
     263  bool GUICEGUIAdapter::injectChar(  char character )
          {
           try {
           //cegui can't handle tabs,   so we have to convert it to a couple of spaces
           if (  character == '\t' ) {
           mGuiSystem->injectChar(  ' ' );
           mGuiSystem->injectChar(  ' ' );
           mGuiSystem->injectChar(  ' ' );
           mGuiSystem->injectChar(  ' ' );
           //can't handle CR either really,   insert a line break (  0x0a ) instead
           } else if (  character == '\r' ) {
           //mGuiSystem->injectChar(  0x0a );
           mGuiSystem->injectKeyDown(  CEGUI::Key::Return );
           mGuiSystem->injectKeyUp(  CEGUI::Key::Return );
           } else {
           mGuiSystem->injectChar(  character );
           }
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           }
           return true;
          
          }
          
     287  bool GUICEGUIAdapter::injectKeyDown(  const SDLKey& key )
          {
           try {
           mGuiSystem->injectKeyDown(  mKeyMap[key] );
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           }
           return true;
          
          }
          
     298  bool GUICEGUIAdapter::injectKeyUp(  const SDLKey& key )
          {
           try {
           mGuiSystem->injectKeyUp(  mKeyMap[key] );
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           }
           return true;
          
          }
          
          
          
          }

./components/ogre/GUICEGUIAdapter.h

       1  //
          // C++ Interface: GUICEGUIAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREGUICEGUIADAPTER_H
          #define EMBEROGREGUICEGUIADAPTER_H
          
          #include "EmberOgrePrerequisites.h"
          #include <CEGUISystem.h>
          #include <CEGUIEventArgs.h>
          #include <CEGUIInputEvent.h>
          
          #include "input/IInputAdapter.h"
          #include "input/Input.h"
          
          
          namespace CEGUI {
      36  class System;
      37  class OgreCEGUIRenderer;
          
          }
          
          namespace EmberOgre {
          
      43  TYPEDEF_STL_MAP(  SDLKey,   CEGUI::Key::Scan,   SDLKeyMap );
          
          /**
          @author Erik Hjortsberg
          
          Provides an adapter between the input system and CEGUI.
          */
      50  class GUICEGUIAdapter : public IInputAdapter {
          public:
          
           /**
           * Creates a new instance.
           * @param system A valid CEGUI::System
           * @param renderer A valid CEGUI::OgreCEGUIRenderer
           * @return
           */
      59   GUICEGUIAdapter(  CEGUI::System *system,   CEGUI::OgreCEGUIRenderer *renderer );
          
      61   ~GUICEGUIAdapter(   );
          
      63   virtual bool injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse );
      64   virtual bool injectMouseButtonUp(  const Input::MouseButton& button );
      65   virtual bool injectMouseButtonDown(  const Input::MouseButton& button );
      66   virtual bool injectChar(  char character );
      67   virtual bool injectKeyDown(  const SDLKey& key );
      68   virtual bool injectKeyUp(  const SDLKey& key );
          
          private:
      71   CEGUI::System *mGuiSystem;
      72   CEGUI::OgreCEGUIRenderer *mGuiRenderer;
          
           /**
           mapping of SDL-keys to CEGUI keys
           */
      77   SDLKeyMap mKeyMap;
          
      79   bool MultiLineEditbox_selectionChangedHandler(  const CEGUI::EventArgs& args );
      80   bool Editbox_selectionChangedHandler(  const CEGUI::EventArgs& args );
          
      82   const CEGUI::String* mSelectedText;
      83   size_t mSelectionStart,   mSelectionEnd;
          };
          
          }
          
          #endif

./components/ogre/GUIManager.cpp

          /*
           Copyright (  C ) 2004 Miguel Guzman (  Aganor )
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "GUIManager.h"
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include "services/scripting/ScriptingService.h"
          
          #include <CEGUIWindowManager.h>
          #include <CEGUISchemeManager.h>
          #include <CEGUIExceptions.h>
          #include <CEGUIFactoryModule.h>
          #include <elements/CEGUIPushButton.h>
          #include <elements/CEGUIGUISheet.h>
          #include <elements/CEGUIMultiLineEditbox.h>
          #include <elements/CEGUIEditbox.h>
          
          
          #include "widgets/Widget.h"
          #include "MousePicker.h"
          
          #include "AvatarCamera.h"
          #include "EmberOgre.h"
          #include "input/Input.h"
          #include "gui/ActiveWidgetHandler.h"
          
          #include "widgets/WidgetDefinitions.h"
          
          #include "EmberEntity.h"
          #include "EmberPhysicalEntity.h"
          #include "AvatarEmberEntity.h"
          
          #include "framework/IScriptingProvider.h"
          
          #include "components/ogre/scripting/LuaScriptingProvider.h"
          
          #include "GUICEGUIAdapter.h"
          
          #include "widgets/icons/IconManager.h"
          #include "widgets/EntityIconManager.h"
          
          
          #ifdef __WIN32__
          #include <windows.h>
          #include <direct.h>
          #endif
          
          #include "EntityWorldPickListener.h"
          
          template<> EmberOgre::GUIManager* Ember::Singleton<EmberOgre::GUIManager>::ms_Singleton = 0;
          
          using namespace CEGUI;
          using namespace EmberOgre::Gui;
          
          namespace EmberOgre {
          
      72  unsigned long GUIManager::msAutoGenId(  0 );
          
          
      75  GUIManager::GUIManager(  Ogre::RenderWindow* window,   Ogre::SceneManager* sceneMgr )
          : ToggleInputMode(  "toggle_inputmode",   this,   "Toggle the input mode." )
      77  ,   ReloadGui(  "reloadgui",   this,   "Reloads the gui." )
          ,   mGuiCommandMapper(  "gui",   "key_bindings_gui" )
          ,   mPicker(  0 )
          ,   mEntityWorldPickListener(  0 )
          ,   mSheet(  0 )
          ,   mWindowManager(  0 )
          ,   mDebugText(  0 )
          ,   mWindow(  window )
          ,   mGuiSystem(  0 )
          ,   mGuiRenderer(  0 )
          ,   mLuaScriptModule(  0 )
          ,   mIconManager(  0 )
          ,   mActiveWidgetHandler(  0 )
          {
           mGuiCommandMapper.restrictToInputMode(  Input::IM_GUI  );
          
           ///we need this here just to force the linker to also link in the WidgetDefinitions
           WidgetDefinitions w;
          
           try {
          
           S_LOG_INFO(  "Starting CEGUI" );
           mDefaultScheme = "EmberLook";
           S_LOG_VERBOSE(  "Setting default scheme to "<< mDefaultScheme );
          
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
           if (  chdir(  configSrv->getEmberDataDirectory(   ).c_str(   ) ) ) {
           S_LOG_WARNING(  "Failed to change to the data directory. Gui loading might fail." );
           }
          
           //use a macro from CEGUIFactoryModule
           //DYNLIB_LOAD(   "libCEGUIFalagardBase.so" );
          
          
          
           mGuiRenderer = new CEGUI::OgreCEGUIRenderer(  window,   Ogre::RENDER_QUEUE_OVERLAY,   false,   0,   sceneMgr );
          // mScriptManager = new GUIScriptManager(   );
           CEGUI::ResourceProvider* resourceProvider = mGuiRenderer->createResourceProvider(   );
           resourceProvider->setDefaultResourceGroup(  "Gui" );
          
           Ember::IScriptingProvider* provider;
           provider = Ember::EmberServices::getSingleton(   ).getScriptingService(   )->getProviderFor(  "LuaScriptingProvider" );
           if (  provider != 0 ) {
           LuaScriptingProvider* luaScriptProvider = static_cast<LuaScriptingProvider*>(  provider );
           mLuaScriptModule = new LuaScriptModule(  luaScriptProvider->getLuaState(   ) );
           mGuiSystem = new CEGUI::System(  mGuiRenderer,   resourceProvider,   0,   mLuaScriptModule,   "cegui/datafiles/configs/cegui.config" );
          
           Ember::EmberServices::getSingleton(   ).getScriptingService(   )->EventStopping.connect(  sigc::mem_fun(  *this,   &GUIManager::scriptingServiceStopping ) );
           } else {
           mGuiSystem = new CEGUI::System(  mGuiRenderer,   resourceProvider,   0,   0,   "cegui/datafiles/configs/cegui.config" );
           }
          
           mWindowManager = &CEGUI::WindowManager::getSingleton(   );
          
          
          
           try {
           mGuiSystem->setDefaultMouseCursor(  getDefaultScheme(   ),   "MouseArrow" );
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "CEGUI - could not set mouse pointer. Make sure that the correct scheme " << getDefaultScheme(   ) << " is available. Message: " << ex.getMessage(   ).c_str(   ) );
           throw Ember::Exception(  ex.getMessage(   ).c_str(   ) );
           }
          
          
           mSheet = mWindowManager->createWindow(  (  CEGUI::utf8* )"DefaultGUISheet",   (  CEGUI::utf8* )"root_wnd" );
           mGuiSystem->setGUISheet(  mSheet );
           mSheet->activate(   );
           mSheet->moveToBack(   );
           mSheet->setDistributesCapturedInputs(  false );
          
           BIND_CEGUI_EVENT(  mSheet,   CEGUI::ButtonBase::EventMouseButtonDown,   GUIManager::mSheet_MouseButtonDown );
           BIND_CEGUI_EVENT(  mSheet,   CEGUI::Window::EventInputCaptureLost,   GUIManager::mSheet_CaptureLost );
           BIND_CEGUI_EVENT(  mSheet,   CEGUI::ButtonBase::EventMouseDoubleClick,   GUIManager::mSheet_MouseDoubleClick );
          
           //set a default tool tip
           CEGUI::System::getSingleton(   ).setDefaultTooltip(  getDefaultScheme(   ) + "/Tooltip" );
          
           S_LOG_INFO(  "CEGUI system set up" );
          
           mPicker = new MousePicker(   );
          
           ///create a new entity world pick listener which listens for event
           ///TODO: should this really be here?
           mEntityWorldPickListener = new EntityWorldPickListener(   );
          
           ///don't connect it yet since there's no AvatarCamera yet,   wait until that's created
           EmberOgre::getSingleton(   ).EventAvatarControllerCreated.connect(  sigc::mem_fun(  *this,   &GUIManager::EmberOgre_AvatarControllerCreated ) );
          
           getInput(   ).EventKeyPressed.connect(  sigc::mem_fun(  *this,   &GUIManager::pressedKey ) );
           getInput(   ).setInputMode(  Input::IM_GUI );
          
           ///add adapter for CEGUI
           mCEGUIAdapter = new GUICEGUIAdapter(  mGuiSystem,   mGuiRenderer );
           getInput(   ).addAdapter(  mCEGUIAdapter );
          
           mGuiCommandMapper.bindToInput(  getInput(   ) );
          
           ///connect to the creation of the avatar,   since we want to switch to movement mode when that happens
           EmberOgre::getSingleton(   ).EventCreatedAvatarEntity.connect(  sigc::mem_fun(  *this,   &GUIManager::EmberOgre_CreatedAvatarEntity ) );
          
           mActiveWidgetHandler = new Gui::ActiveWidgetHandler(  *this );
          
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          
          
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "GUIManager - error when creating gui. Message: " << ex.getMessage(   ).c_str(   ) );
           throw Ember::Exception(  ex.getMessage(   ).c_str(   ) );
          
           }
          
          }
          
          
     191  GUIManager::~GUIManager(   )
          {
           S_LOG_INFO(  "Shutting down GUI manager." );
          
           WidgetStore widgetStoreCopy(  mWidgets );
           for (  WidgetStore::iterator I = widgetStoreCopy.begin(   ); I != widgetStoreCopy.end(   ); ++I ) {
           S_LOG_INFO(  "Deleting widget " << (  *I )->getPrefix(   ) << "." );
           delete *I;
           }
          
           delete mActiveWidgetHandler;
           delete mEntityIconManager;
           delete mIconManager;
          
           delete mGuiSystem;
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
           delete mCEGUIAdapter;
          
           delete mEntityWorldPickListener;
           delete mPicker;
           delete mGuiRenderer;
           delete mLuaScriptModule;
           //delete mMousePicker;
           //mMousePicker = 0;
          
          }
          
     218  void GUIManager::initialize(   )
          {
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
           chdir(  configSrv->getEmberDataDirectory(   ).c_str(   ) );
           try {
           mDebugText = (  CEGUI::GUISheet* )mWindowManager->createWindow(  "DefaultGUISheet",   (  CEGUI::utf8* )"DebugText" );
           mSheet->addChildWindow(  mDebugText );
           mDebugText->setMaxSize(  CEGUI::UVector2(  UDim(  1.0f,   0 ),   UDim(  0,   25 ) ) );
           mDebugText->setPosition(  CEGUI::UVector2(  UDim(  0.0f,   0 ),   UDim(  1.0f,   -25 ) ) );
           mDebugText->setSize(  CEGUI::UVector2(  UDim(  1.0f,   0 ),   UDim(  0,   25 ) ) );
          
          /* mDebugText->setFrameEnabled(  false );
           mDebugText->setBackgroundEnabled(  false );*/
           //stxt->setHorizontalFormatting(  StaticText::WordWrapCentred );
          
          
           //the console and quit widgets are not lua scripts,   and should be loaded explicit
          // mConsoleWidget = static_cast<ConsoleWidget*>(  createWidget(  "ConsoleWidget" ) );
          // if (  !mConsoleWidget ) {
          // throw Ember::Exception(  "Could not create console widget." );
          // }
           createWidget(  "Quit" );
           } catch (  const std::exception& e ) {
           S_LOG_FAILURE(  "GUIManager - error when initializing widgets: " << e.what(   ) );
           throw e;
           } catch (  const CEGUI::Exception& e ) {
           S_LOG_FAILURE(  "GUIManager - error when initializing widgets: " << e.getMessage(   ).c_str(   ) );
           throw e;
           }
           try {
           mIconManager = new Gui::Icons::IconManager(   );
           } catch (  const std::exception& e ) {
           S_LOG_FAILURE(  "GUIManager - error when creating icon manager: " << e.what(   ) );
           } catch (  const CEGUI::Exception& e ) {
           S_LOG_FAILURE(  "GUIManager - error when creating icon manager: " << e.getMessage(   ).c_str(   ) );
           }
          
           try {
           mEntityIconManager = new Gui::EntityIconManager(  *this );
           } catch (  const std::exception& e ) {
           S_LOG_FAILURE(  "GUIManager - error when creating entity icon manager: " << e.what(   ) );
           } catch (  const CEGUI::Exception& e ) {
           S_LOG_FAILURE(  "GUIManager - error when creating entity icon manager: " << e.getMessage(   ).c_str(   ) );
           }
          
          
           std::vector<std::string> widgetsToLoad;
           widgetsToLoad.push_back(  "StatusIconBar" );
           widgetsToLoad.push_back(  "IngameChatWidget" );
          // widgetsToLoad.push_back(  "InventoryWidget" );
           widgetsToLoad.push_back(  "InspectWidget" );
           widgetsToLoad.push_back(  "MakeEntityWidget" );
           widgetsToLoad.push_back(  "JesusEdit" );
           widgetsToLoad.push_back(  "ServerWidget" );
           widgetsToLoad.push_back(  "Help" );
           widgetsToLoad.push_back(  "MeshPreview" );
          
           ///this should be defined in some kind of text file,   which should be different depending on what game you're playing (  like mason )
           try {
           ///load the bootstrap script which will load all other scripts
           Ember::EmberServices::getSingleton(   ).getScriptingService(   )->loadScript(  "lua/Bootstrap.lua" );
           } catch (  const std::exception& e ) {
           S_LOG_FAILURE(  "Error when loading bootstrap script. Error message: " << e.what(   ) );
           } catch (  const CEGUI::Exception& e ) {
           S_LOG_FAILURE(  "Error when loading bootstrap script. Error message: " << e.getMessage(   ).c_str(   ) );
           }
          
           for (  std::vector<std::string>::iterator I = widgetsToLoad.begin(   ); I != widgetsToLoad.end(   ); ++I ) {
           try {
           S_LOG_VERBOSE(  "Loading widget " << *I );
           createWidget(  *I );
           } catch (  const std::exception& e ) {
           S_LOG_FAILURE(  "Error when initializing widget " << *I << " : " << e.what(   ) );
           } catch (  const CEGUI::Exception& e ) {
           S_LOG_FAILURE(  "Error when initializing widget " << *I << " : " << e.getMessage(   ).c_str(   ) );
           }
           }
          
          }
          
     298  void GUIManager::scriptingServiceStopping(   )
          {
           mGuiSystem->setScriptingModule(  0 );
           delete mLuaScriptModule;
           mLuaScriptModule = 0;
          }
          
     305  void GUIManager::EmitEntityAction(  const std::string& action,   EmberEntity* entity )
          {
           EventEntityAction.emit(  action,   entity );
          }
          
          
     311  CEGUI::Window* GUIManager::createWindow(  const std::string& windowType )
          {
           std::stringstream ss;
           ss << "_autoWindow_" << (  msAutoGenId++ );
           return createWindow(  windowType,   ss.str(   ) );
          }
          
     318  CEGUI::Window* GUIManager::createWindow(  const std::string& windowType,   const std::string& windowName )
          {
           try {
           CEGUI::Window* window = mWindowManager->createWindow(  windowType,   windowName );
           return window;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating new window of type " << windowType << " with name " << windowName << ".\n" << ex.getMessage(   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when creating new window of type " << windowType << " with name " << windowName << ".\n" << ex.what(   ) );
           return 0;
           }
          }
          
     332  Widget* GUIManager::createWidget(   )
          {
           return createWidget(  "Widget" );
          }
          
     337  Widget* GUIManager::createWidget(  const std::string& name )
          {
           Widget* widget(  0 );
           try {
          
           widget = WidgetLoader::createWidget(  name );
           if (  widget == 0 ) {
           S_LOG_FAILURE(   "Could not find widget with name " << name  );
           return 0;
           }
           widget->init(  this );
           widget->buildWidget(   );
           addWidget(  widget );
           S_LOG_INFO(   "Successfully loaded widget " << name  );
           } catch (  const std::exception& e ) {
           S_LOG_FAILURE(   "Error when loading widget " << name << ": " << e.what(   ) );
           return 0;
           } catch (  const CEGUI::Exception& e ) {
           S_LOG_FAILURE(   "Error when loading widget " << name << ": " << e.getMessage(   ).c_str(   ) );
           return 0;
           }
           return widget;
          }
          
     361  void GUIManager::destroyWidget(  Widget* widget )
          {
           if (  !widget )
           {
           S_LOG_WARNING(  "Trying to destroy null widget." );
           return;
           }
           removeWidget(  widget );
           delete widget;
          }
          
          
     373  void GUIManager::setDebugText(  const std::string& text )
          {
           if (  mDebugText )
           {
           mDebugText->setText(  text );
           }
          }
          
     381  Input& GUIManager::getInput(   ) const
          {
           return Input::getSingleton(   );
          }
          
          
     387  CEGUI::Window* GUIManager::getMainSheet(   ) const
          {
           return mSheet;
          }
          
     392  void GUIManager::removeWidget(  Widget* widget )
          {
           WidgetStore::iterator I = std::find(  mWidgets.begin(   ),   mWidgets.end(   ),   widget );
           if (  I != mWidgets.end(   ) ) {
           mWidgets.erase(  I );
           }
          }
          
     400  void GUIManager::addWidget(  Widget* widget )
          {
           mWidgets.push_back(  widget );
          }
          
          
          
          
          
          
     410  bool GUIManager::frameStarted(  const Ogre::FrameEvent& evt )
          {
           try {
           CEGUI::System::getSingleton(   ).injectTimePulse(  evt.timeSinceLastFrame );
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           }
          // if (  mPreviousInputMode == IM_GUI ) {
          // if (  !mInput->getInputMode(   ) ) {
          // EventInputModeChanged.emit(  IM_MOVEMENT );
          // mPreviousInputMode = IM_MOVEMENT;
          // }
          // } else {
          // if (  mInput->isInGUIMode(   ) ) {
          // EventInputModeChanged.emit(  IM_GUI );
          // mPreviousInputMode = IM_GUI;
          // }
          // }
          
          
          
           //iterate over all widgets and send them a frameStarted event
           WidgetStore::iterator I = mWidgets.begin(   );
           WidgetStore::iterator I_end = mWidgets.end(   );
          
           for (  ; I != I_end; ++I ) {
           Widget* aWidget = *I;
           try {
           aWidget->frameStarted(  evt );
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_WARNING(  "Error in CEGUI: " << ex.getMessage(   ).c_str(   ) );
           }
           }
          
           EventFrameStarted.emit(  evt.timeSinceLastFrame );
          
           return true;
          
          
          }
          
     451  bool GUIManager::mSheet_MouseButtonDown(  const CEGUI::EventArgs& args )
          {
           if (  isInGUIMode(   ) ) {
           const CEGUI::MouseEventArgs& mouseArgs = static_cast<const CEGUI::MouseEventArgs&>(  args );
           S_LOG_VERBOSE(  "Main sheet is capturing input" );
           CEGUI::Window* aWindow = CEGUI::Window::getCaptureWindow(   );
           if (  aWindow ) {
           aWindow->releaseInput(   );
           aWindow->deactivate(   );
           }
           //mSheet->activate(   );
           //mSheet->captureInput(   );
          
           if (  mPicker ) {
           const CEGUI::Point& position = CEGUI::MouseCursor::getSingleton(   ).getDisplayIndependantPosition(   );
           MousePickerArgs pickerArgs;
           pickerArgs.windowX = mouseArgs.position.d_x;
           pickerArgs.windowY = mouseArgs.position.d_y;
           pickerArgs.pickType = MPT_CLICK;
           mPicker->doMousePicking(  position.d_x,   position.d_y,   pickerArgs );
           }
           }
          
          
           return true;
          }
          
     478  bool GUIManager::mSheet_MouseDoubleClick(  const CEGUI::EventArgs& args )
          {
          
           const CEGUI::MouseEventArgs& mouseArgs = static_cast<const CEGUI::MouseEventArgs&>(  args );
           S_LOG_VERBOSE(  "Main sheet double click." );
           CEGUI::Window* aWindow = CEGUI::Window::getCaptureWindow(   );
           if (  aWindow ) {
           aWindow->releaseInput(   );
           aWindow->deactivate(   );
           }
           //mSheet->activate(   );
           //mSheet->captureInput(   );
          
           if (  mPicker ) {
           const CEGUI::Point& position = CEGUI::MouseCursor::getSingleton(   ).getDisplayIndependantPosition(   );
           MousePickerArgs pickerArgs;
           pickerArgs.windowX = mouseArgs.position.d_x;
           pickerArgs.windowY = mouseArgs.position.d_y;
           pickerArgs.pickType = MPT_DOUBLECLICK;
           mPicker->doMousePicking(  position.d_x,   position.d_y,   pickerArgs );
           }
          
          
           return true;
          }
          
     504  bool GUIManager::mSheet_CaptureLost(  const CEGUI::EventArgs& args )
          {
           S_LOG_VERBOSE(  "Main sheet lost input" );
           return true;
          }
          
     510  const bool GUIManager::isInMovementKeysMode(   ) const {
           return mSheet->isCapturedByThis(   ) || !isInGUIMode(   );
          }
          
     514  const bool GUIManager::isInGUIMode(   ) const {
           return getInput(   ).getInputMode(   ) == Input::IM_GUI;
          }
          
     518  void GUIManager::pressedKey(  const SDL_keysym& key,   Input::InputMode inputMode )
          {
           if (  (  key.mod & KMOD_CTRL || key.mod & KMOD_LCTRL || key.mod & KMOD_RCTRL ) && (  key.sym == SDLK_c || key.sym == SDLK_x ) ) {
          
           bool cut = (  key.sym == SDLK_x );
           CEGUI::Window* active = mSheet->getActiveChild(   );
           if (  !active ) return;
          
           CEGUI::String seltext;
           const CEGUI::String& type = active->getType(   );
          
           if (  type.find(  "/MultiLineEditbox" ) != CEGUI::String::npos ) {
           CEGUI::MultiLineEditbox* edit = static_cast<CEGUI::MultiLineEditbox*>(  active );
           CEGUI::String::size_type beg = edit->getSelectionStartIndex(   );
           CEGUI::String::size_type len = edit->getSelectionLength(   );
           seltext = edit->getText(   ).substr(   beg,   len  ).c_str(   );
          
           // are we cutting or just copying?
           if (  cut ) {
           if (  edit->isReadOnly(   ) ) return;
           CEGUI::String newtext = edit->getText(   );
           edit->setText(   newtext.erase(   beg,   len  )  );
           }
          
           } else if (  type.find(  "/Editbox" ) != CEGUI::String::npos ) {
           CEGUI::Editbox* edit = static_cast<CEGUI::Editbox*>(  active );
           CEGUI::String::size_type beg = edit->getSelectionStartIndex(   );
           CEGUI::String::size_type len = edit->getSelectionLength(   );
           seltext = edit->getText(   ).substr(   beg,   len  ).c_str(   );
          
           // are we cutting or just copying?
           if (  cut ) {
           if (  edit->isReadOnly(   ) ) return;
           CEGUI::String newtext = edit->getText(   );
           edit->setText(   newtext.erase(   beg,   len  )  );
           }
           }
           getInput(   ).writeToClipboard(   seltext.c_str(   )  );
           }
          }
          
          
          
     561  void GUIManager::runCommand(  const std::string &command,   const std::string &args )
          {
           if (  command == ToggleInputMode.getCommand(   ) ) {
           getInput(   ).toggleInputMode(   );
           } else if (  command == ReloadGui.getCommand(   ) ) {
           Ogre::TextureManager* texMgr = Ogre::TextureManager::getSingletonPtr(   );
           Ogre::ResourcePtr resource = texMgr->getByName(  "cegui/" + getDefaultScheme(   ) + ".png" );
           if (  !resource.isNull(   ) ) {
           resource->reload(   );
           }
           }
          }
          
          // void GUIManager::pushMousePicker(   MousePicker * mousePicker  )
          // {
          // mMousePickers.push(  mousePicker );
          // }
          
          // MousePicker * GUIManager::popMousePicker(   )
          // {
          // ///only pop if there's more than one registered picker
          // if (  mMousePickers.size(   ) > 1 )
          // mMousePickers.pop(   );
          // return mMousePickers.top(   );
          // }
          
     587  void GUIManager::EmberOgre_CreatedAvatarEntity(  AvatarEmberEntity* entity )
          {
           ///switch to movement mode,   since it appears most people don't know how to change from gui mode
           getInput(   ).setInputMode(  Input::IM_MOVEMENT );
          }
          
     593  void GUIManager::EmberOgre_AvatarControllerCreated(  AvatarController& controller )
          {
           EmberOgre::getSingleton(   ).getMainCamera(   )->pushWorldPickListener(  mEntityWorldPickListener );
          }
          
     598  const std::string& GUIManager::getLayoutDir(   ) const
          {
           static std::string dir(  "cegui/datafiles/layouts/" );
           return dir;
          }
          
     604  const std::string& GUIManager::getDefaultScheme(   ) const
          {
           return mDefaultScheme;
          }
          
     609  EntityWorldPickListener* GUIManager::getEntityPickListener(   ) const
          {
           return mEntityWorldPickListener;
          }
          
     614  Gui::Icons::IconManager* GUIManager::getIconManager(   )
          {
           return mIconManager;
          }
          
     619  Gui::EntityIconManager* GUIManager::getEntityIconManager(   )
          {
           return mEntityIconManager;
          }
          
          
          }
          
          

./components/ogre/GUIManager.h

       1  /*
           Copyright (  C ) 2004 Miguel Guzman (  Aglanor )
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef GUIMANAGER_H
          #define GUIMANAGER_H
          
          
          #include "EmberOgrePrerequisites.h"
          
          #include <CEGUIBase.h>
          #include <OgreCEGUIRenderer.h>
          
          #include <sigc++/trackable.h>
          
          #include "framework/Singleton.h"
          
          #include <SDL.h>
          #include <stack>
          
          #include "framework/ConsoleObject.h"
          
          #include "input/Input.h"
          #include "input/InputCommandMapper.h"
          
          namespace CEGUI
          {
      42  class GUISheet;
      43  class LuaScriptModule;
          }
          
          namespace Ember {
      47  class IScriptingProvider;
          }
          
      50  namespace EmberOgre {
          
          class EmberEntity;
          class TerrainGenerator;
          class CEGUI::Window;
          class MousePicker;
          class Input;
          class AvatarEmberEntity;
          class GUICEGUIAdapter;
          class EntityWorldPickListener;
          class AvatarController;
          
          namespace Gui {
          class Widget;
          class EntityIconManager;
          class ActiveWidgetHandler;
          namespace Icons {
          class IconManager;
          }
          }
          
          /**
           * This class will be responsible for all the GUI related things
           */
          class GUIManager :
          public Ember::Singleton<GUIManager>,  
          Ogre::FrameListener,  
          public sigc::trackable,  
          public Ember::ConsoleObject
          {
          public:
          
           typedef std::vector<Gui::Widget*> WidgetStore;
          
           static const std::string SCREENSHOT;
           static const std::string TOGGLEINPUTMODE;
          
          
           GUIManager(  Ogre::RenderWindow* window,   Ogre::SceneManager* sceneMgr );
           virtual ~GUIManager(   );
          
           sigc::signal<void,   const std::string&,   EmberEntity*> AppendIGChatLine;
           sigc::signal<void,   const std::string&,   EmberEntity*> AppendOOGChatLine;
           sigc::signal<void,   const std::string&> AppendAvatarImaginary;
          
           sigc::signal<void,   const std::string&,   EmberEntity*> EventEntityAction;
          
           /**
           Emitted every frame.
           */
           sigc::signal<void,   float> EventFrameStarted;
          
           /**
           * Emits an action for a certain entity.
           * An action could be something like "touch" or "inspect".
           * @param action
           */
           void EmitEntityAction(  const std::string& action,   EmberEntity* entity );
          
           /**
           * Removed a widget from the system.
           * @param widget
           */
           void removeWidget(  Gui::Widget* widget );
          
           /**
           * Adds a new widget to the system. This means it will recieve FrameStarted events.
           * @param widget
           */
           void addWidget(  Gui::Widget* widget );
          
           /**
           * Called by Ogre each frame.
           * @param evt
           * @return
           */
           bool frameStarted(  const Ogre::FrameEvent& evt );
          
           /**
           * Gets the root sheet of the CEGUI windowing system.
           * @return
           */
           CEGUI::Window* getMainSheet(   ) const;
          
          
           /**
           * Called by EmberOgre at initialization.
           */
           void initialize(   );
          
          
           /**
           * sets a text to be shown somewhere on the screen,   used for debugging purposes
           * @param text
           */
           void setDebugText(  const std::string& text );
          
           /**
           * true if we're in GUI mode,   which means that input events will be sent to the CEGUI system instead of the "world"
           * @return
           */
           const bool isInGUIMode(   ) const;
          
          
           /**
           * true if keyboard input should make the avatar move
           * this happens when wither 1 ) we're not in gui mode 2 ) the background sheet has the input control (  thus,   when something else,   like an edit box has input control,   that edit box will recieve key strokes
           * @return
           */
           const bool isInMovementKeysMode(   ) const;
          
           /**
           * Gets the currently active MousePicker instance.
           * @return
           */
           inline MousePicker* getMousePicker(   ) { return mMousePickers.top(   ); }
          
          
           /**
           * accessor for the Input instance object
           * @return
           */
           Input& getInput(   ) const;
          
           /**
           * Pushes a new mouse picker onto the stack,   "pushing down" the current mouse picker.
           * @param mousePicker
           */
          // void pushMousePicker(  MousePicker* mousePicker );
          
           /**
           * Pops the current mouse picker from the stack and returns the next in line.
           * It's not possible to empty the stack. If there's only one picker left,   no popping will be done,   and the last picker will be returned.
           * @return
           */
          // MousePicker* popMousePicker(   );
          
           inline CEGUI::OgreCEGUIRenderer* getGuiRenderer(   ) const {return mGuiRenderer;}
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
           virtual void runCommand(  const std::string &command,   const std::string &args );
          
          
           /**
           * returns the path to the directory where all layouts are stored
           * @return
           */
           const std::string& getLayoutDir(   ) const;
          
           /**
           Creates a new window of the supplied type,   giving it an autogenerated,   unique name.
           */
           CEGUI::Window* createWindow(  const std::string& windowType );
          
           /**
           Creates a new window of the supplied type with the supplied name.
           */
           CEGUI::Window* createWindow(  const std::string& windowType,   const std::string& windowName );
          
           /**
           * Creates a new Widget
           * @return
           */
           Gui::Widget* createWidget(   );
          
           /**
           * creates a widget
           * @see WidgetLoader
           * @param name the type of widget to create
           * @return
           */
           Gui::Widget* createWidget(  const std::string& name );
          
           /**
           * Destroys a widget previously created by createWidget
           * @param widget The widget to destroy.
           */
           void destroyWidget(  Gui::Widget* widget );
          
           /**
           * Gets the name of the default scheme used (  such as "EmberLook" or "WindowsLook" )
           * @return
           */
           const std::string& getDefaultScheme(   ) const;
          
           EntityWorldPickListener* getEntityPickListener(   ) const;
          
           /**
           Command for toggling between the input modes.
           */
           const Ember::ConsoleCommandWrapper ToggleInputMode;
          
           /**
           Command for reloading the gui.
           */
           const Ember::ConsoleCommandWrapper ReloadGui;
          
          
           /**
           * Accessor for the IconManager which handles low level icons.
           * @return The main IconManager
           */
           Gui::Icons::IconManager* getIconManager(   );
          
           /**
           * Accessor for the EntityIconManager,   which handles entity icons and slots.
           * @return The main EntityIconManager
           */
           Gui::EntityIconManager* getEntityIconManager(   );
          
          protected:
          
           /**
           Counter for autonaming of windows.
           */
           static unsigned long msAutoGenId;
          
           InputCommandMapper mGuiCommandMapper;
          
           MousePicker* mPicker;
          
           EntityWorldPickListener* mEntityWorldPickListener;
          
           CEGUI::Window* mSheet;
           CEGUI::WindowManager* mWindowManager;
           CEGUI::GUISheet* mDebugText;
          
           Ogre::RenderWindow* mWindow;
           CEGUI::System* mGuiSystem;
           CEGUI::OgreCEGUIRenderer* mGuiRenderer;
          
           std::string mDefaultScheme;
          
           /**
           all loaded widgets are stored here
           */
           WidgetStore mWidgets;
          
           /**
           A stack of the mouse pickers used. This allows for a component to "push down" the current mouse picker in favor of its own
           */
           std::stack<MousePicker*> mMousePickers;
          
           //events
           bool mSheet_MouseButtonDown(  const CEGUI::EventArgs& args );
           bool mSheet_MouseDoubleClick(  const CEGUI::EventArgs& args );
           bool mSheet_CaptureLost(  const CEGUI::EventArgs& args );
          
           /**
           * hooked to EmberOgre::EventCreatedAvatarEntity,   switches the input mode to movement mode
           * @param entity
           */
           void EmberOgre_CreatedAvatarEntity(  AvatarEmberEntity* entity );
          
           /**
           * hooked to EmberOgre::EventAvatarControllerCreated,   connects the mEntityWorldPickListener to the main AvatarCamera
           * @param controller
           */
           void EmberOgre_AvatarControllerCreated(  AvatarController& controller );
          
          // InputMode mPreviousInputMode;
           void pressedKey(  const SDL_keysym& key,   Input::InputMode inputMode );
          
           /**
           Adapter for CEGUI which will send input events to CEGUI
           */
           GUICEGUIAdapter* mCEGUIAdapter;
          
           CEGUI::LuaScriptModule* mLuaScriptModule;
          
           void scriptingServiceStopping(   );
          
           Gui::Icons::IconManager* mIconManager;
           Gui::EntityIconManager* mEntityIconManager;
           Gui::ActiveWidgetHandler* mActiveWidgetHandler;
          };
          }
          
          
          #endif

./components/ogre/IWorldPickListener.h

       1  //
          // C++ Interface: IWorldPickListener
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREIWORLDPICKLISTENER_H
          #define EMBEROGREIWORLDPICKLISTENER_H
          
          #include "EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
          
          /**
          The kind of mouse click operation.
          */
          enum MousePickType
          {
           ///Simple click
           MPT_CLICK = 1,  
           ///Double click
           MPT_DOUBLECLICK = 2
          
          };
          
          /**
          Mouse picking info from the windowing system.
          */
          struct MousePickerArgs
          {
           /**
           The x and y coords in local window space.
           */
           float windowX,   windowY;
          
           MousePickType pickType;
          };
          
          
      60  class IWorldPickListener
          {
          public:
          
      64  virtual ~IWorldPickListener(   ) {}
          
          /**
          Called at the start of a picking context. This allows the pickers to be reset and to keep state for each picking.
          */
      69  virtual void initializePickingContext(   ) {}
          
          /**
          Called when the picking is over,   either because one of the processPickResult calls set continuePicking to false,   or because there are no more objects to pick.
          */
      74  virtual void endPickingContext(  const MousePickerArgs& mousePickerArgs ) {}
          
          /**
           * Processes the pick result.
           * This will be called for each picked object.
           * @param continuePicking set this to false if you don't want to process any more pick results,   or don't want any other IWorldPickListener to process the pick any more
           * @param entry The actual pick entry.
           * @param cameraRay The ray which resulted in the pick.
           * @param mousePickerArgs The original mouse picker arguments.
           */
      84  virtual void processPickResult(  bool& continuePicking,   Ogre::RaySceneQueryResultEntry& entry,   Ogre::Ray& cameraRay,   const MousePickerArgs& mousePickerArgs ) = 0;
          
          
          };
          
          }
          
          #endif

./components/ogre/MathConverter.h

       1  /*
          -----------------------------------------------------------------------------
          MathConverter.h by Miguel Guzman Miranda (  Aglanor )
          Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          
          Copyright © 2003 The Worldforge Project (  http://www.worldforge.org )
          This file is part of Ember client (  http://www.worldforge.org/dev/eng/clients/Ember )
          
          This code is distributed under the GNU GPL (  General Public License ).
          See file COPYING for details.
          
          -----------------------------------------------------------------------------
          
          -----------------------------------------------------------------------------
          Filename: MathConverter.h
          Description: Point,   Vector and Quaternion converter
           for world-centric coordinates (  Atlas-wfmath like )
           to/from screen-centric coordinates (  Ogre like ).
          
           Atlas is World-centric (  picture a map ):
           x is east
           y is north
           z is up
          
           Ogre is screen-centric (  picture your monitor screen ):
           x is right
           y is up
           z is depth (  negative towards the screen,  
           positive is towards you,  
           so the coord system is also dextrogyrous )
          
           --------------------------------------------------------
           Example of Atlas --> Ogre conversion
          
           Picture this is the world map,   in both cases:
           ^ North
           |
           | East
           (  Up )--->
          
          
           Atlas Ogre
          
           ^ a.y ^ -o.z
           | |
           | a.x | o.x
           (  a.z )---> (  o.y )--->
          
           --------------------------------------------------------
           Example of Ogre --> Atlas conversion
          
           Picture this is your computer screen,   in both cases:
           ^ Up
           |
           | Left
           (  You )--->
          
           Ogre Atlas
          
           ^ o.y ^ a.z
           | |
           | o.x | a.x
           (  o.z )---> (  -a.y )--->
          
           The math is:
          
           Atlas.x = Ogre.x
           Atlas.y = -Ogre.z
           Atlas.z = Ogre.y
          
           Ogre.x = Atlas.x
           Ogre.y = Atlas.z
           Ogre.z = -Atlas.y
          
          -----------------------------------------------------------------------------
          */
          
          #ifndef __MATH_CONVERTER_H__
          #define __MATH_CONVERTER_H__
          
          // ------------------------------
          // Include WFmath header files
          // ------------------------------
          #include <wfmath/point.h>
          #include <wfmath/vector.h>
          #include <wfmath/axisbox.h>
          #include <wfmath/quaternion.h>
          #include <wfmath/const.h>
          
          #include <math.h>
          
          namespace EmberOgre {
          
          typedef WFMath::Point<2> TerrainPosition;
          
          // //note that this will ignore the y value of the supplied ogre vector
          // inline TerrainPosition Ogre2Atlas(  Ogre::Vector3& p ) {
          // return WFMath::Point<2>(  p.x,  -p.z );
          // }
          
          /*inline Ogre::Vector3 Atlas2Ogre(  TerrainPosition& p ) {
           return Ogre::Vector3(  p.x(   ),  0,  -p.y(   ) );
          }*/
     104  inline Ogre::Vector3 Atlas2Ogre(  const TerrainPosition& p ) {
           return Ogre::Vector3(  p.x(   ),  0,  -p.y(   ) );
          }
          
     108  inline Ogre::Vector2 Atlas2Ogre_Vector2(  const TerrainPosition& p ) {
           return Ogre::Vector2(  p.x(   ),  -p.y(   ) );
          }
          
          // inline WFMath::Point<3> Ogre2Atlas(  Ogre::Vector3& p ) {
          // return WFMath::Point<3>(  p.x,  -p.z,  p.y );
          // }
          
          /*inline WFMath::Vector<3> Ogre2Atlas_Vector3(  Ogre::Vector3& p ) {
           return WFMath::Vector<3>(  p.x,  -p.z,  p.y );
          }*/
     119  inline WFMath::Point<3> Ogre2Atlas(  const Ogre::Vector3& p ) {
           return WFMath::Point<3>(  p.x,  -p.z,  p.y );
          }
          
     123  inline TerrainPosition Ogre2Atlas(  const Ogre::Vector2& p ) {
           return TerrainPosition(  p.x,  -p.y );
          }
          
     127  inline TerrainPosition Ogre2Atlas_TerrainPosition(  const Ogre::Vector3& p ) {
           return TerrainPosition(  p.x,  -p.z );
          }
          
     131  inline WFMath::Vector<3> Ogre2Atlas_Vector3(  const Ogre::Vector3& p ) {
           return WFMath::Vector<3>(  p.x,  -p.z,  p.y );
          }
          
          // inline Ogre::Vector3 Atlas2Ogre(  WFMath::Point<3>& p ){
          // return Ogre::Vector3(  p.x(   ),  p.z(   ),  -p.y(   ) );
          // }
          
     139  inline Ogre::Vector3 Atlas2Ogre(  const WFMath::Point<3>& p ){
           return Ogre::Vector3(  p.x(   ),  p.z(   ),  -p.y(   ) );
          }
          
          // inline Ogre::Vector3 Atlas2Ogre(  WFMath::Vector<3>& v ){
          // return Ogre::Vector3(  v.x(   ),  v.z(   ),  -v.y(   ) );
          // }
          
     147  inline Ogre::Vector3 Atlas2Ogre(  const WFMath::Vector<3>& v ){
           return Ogre::Vector3(  v.x(   ),  v.z(   ),  -v.y(   ) );
          }
          
          // inline Ogre::Quaternion Atlas2Ogre(  WFMath::Quaternion& aq ){
          // if (  !aq.isValid(   ) ) {
          // return Ogre::Quaternion::IDENTITY;
          // }
          // return Ogre::Quaternion(  aq.scalar(   ),  aq.vector(   ).x(   ),  aq.vector(   ).z(   ),  -aq.vector(   ).y(   ) );
          // }
          
     158  inline Ogre::Quaternion Atlas2Ogre(  const WFMath::Quaternion& aq ){
           if (  !aq.isValid(   ) ) {
           return Ogre::Quaternion::IDENTITY;
           }
           return Ogre::Quaternion(  aq.scalar(   ),  aq.vector(   ).x(   ),  aq.vector(   ).z(   ),  -aq.vector(   ).y(   ) );
          }
          
          //is this correct?
          // inline WFMath::Quaternion Ogre2Atlas(  Ogre::Quaternion& aq ){
          // return WFMath::Quaternion(  aq.w,  aq.x,  -aq.z,  aq.y );
          // }
     169  inline WFMath::Quaternion Ogre2Atlas(  const Ogre::Quaternion& aq ){
           return WFMath::Quaternion(  aq.w,  aq.x,  -aq.z,  aq.y );
          }
          
     173  inline Ogre::AxisAlignedBox Atlas2Ogre(  const WFMath::AxisBox<3>& axisBox ){
           if (  !axisBox.isValid(   ) ) {
           return Ogre::AxisAlignedBox(   );
           }
           return Ogre::AxisAlignedBox(  axisBox.lowCorner(   ).x(   ),   axisBox.lowCorner(   ).z(   ),   -axisBox.highCorner(   ).y(   ),   axisBox.highCorner(   ).x(   ),   axisBox.highCorner(   ).z(   ),   -axisBox.lowCorner(   ).y(   ) );
          }
          
     180  inline Ogre::TRect<Ogre::Real> Atlas2Ogre(  const WFMath::AxisBox<2>& atlasBox ) {
           if (  !atlasBox.isValid(   ) ) {
           return Ogre::TRect<Ogre::Real>(   );
           }
           return Ogre::TRect<Ogre::Real>(  atlasBox.lowCorner(   ).x(   ),   -atlasBox.highCorner(   ).y(   ),   atlasBox.highCorner(   ).x(   ),   -atlasBox.lowCorner(   ).y(   ) );
          }
          
          
     188  inline WFMath::AxisBox<3> Ogre2Atlas(  const Ogre::AxisAlignedBox& axisBox ){
           if (  axisBox.isNull(   ) || axisBox.isInfinite(   ) ) {
           return WFMath::AxisBox<3>(   );
           }
           return WFMath::AxisBox<3>(  WFMath::Point<3>(  axisBox.getMinimum(   ).x,   axisBox.getMinimum(   ).z,   -axisBox.getMaximum(   ).y ),   WFMath::Point<3>(  axisBox.getMaximum(   ).x,   axisBox.getMaximum(   ).z,   -axisBox.getMinimum(   ).y ) );
          }
          
          
          }
          
          
          
          /*
          Ogre::Vector3 Ogre::Vector3(  WFMath::Vector<3> v ) {
           return Ogre::Vector3(  v.x(   ),  v.z(   ),  -v.y(   ) );
          }
          
          
          WFMath::Point<3>::operator Ogre::Vector3(   ) const{
           return Ogre::Vector3(  this.x(   ),  this.z(   ),  -this.y(   ) );
          }
          */
          
          #endif

./components/ogre/MediaDeployer.cpp

       1  /*
           ConsoleObjectImpl.cpp by Miguel Guzman (  Aglanor )
           Copyright (  C ) 2002 Miguel Guzman & The Worldforge Project
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // config headers
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          // system headers
          
          // library headers
          #include "EmberOgrePrerequisites.h"
          
          // local headers
          #include "MediaDeployer.h"
          
          namespace EmberOgre {
          
          //TODO: add a sequence for mediadeployer ids
          //TODO: add several methods for adding media with different params
          
          MediaDeployer* MediaDeployer::_mediaDeployerInstance = 0;
          
      40  MediaDeployer & MediaDeployer::getSingleton(  void )
          {
           if(  _mediaDeployerInstance == 0 )
           _mediaDeployerInstance = new MediaDeployer;
           return *_mediaDeployerInstance;
          }
          
      47  MediaDeployer::MediaDeployer(  void )
          {
           mSceneMgr = Ogre::Root::getSingleton(   ).getSceneManager(  Ogre::ST_EXTERIOR_CLOSE );
          }
          
      52  MediaDeployer::~MediaDeployer(   )
          {
          
          }
          
      57  bool MediaDeployer::addMedia(  std::string modelName )
          {
           return true;
          }
          
      62  bool MediaDeployer::addMedia(  std::string modelName,   std::string id,   Ogre::Vector3 position )
          {
          
           // create the ogre node and entity
           Ogre::SceneNode* ogreNode = static_cast<Ogre::SceneNode*>(  mSceneMgr->getRootSceneNode(   )->createChild(   ) );
           Ogre::Entity* ogreEntity;
           ogreEntity = mSceneMgr->createEntity(  id,  modelName );
           ogreNode->setPosition(  position );
           ogreNode->attachObject(  ogreEntity );
          
           return true;
          }
          
          }
          

./components/ogre/MediaDeployer.h

       1  /*
           ConsoleObjectImpl.h by Miguel Guzman (  Aglanor )
           Copyright (  C ) 2002 Miguel Guzman & The Worldforge Project
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef __EmberOgre_MediaDeployer_H__
          #define __EmberOgre_MediaDeployer_H__
          
          namespace EmberOgre {
          
      25  class MediaDeployer
          {
          
           public:
          
      30   ~MediaDeployer(   );
          
      32   static MediaDeployer & getSingleton(  void );
          
      34   bool addMedia(  std::string );
      35   bool addMedia(  std::string,   std::string,   Ogre::Vector3 );
          
           private:
          
           /**
           * Private constructor (  for singleton )
           */
      42   MediaDeployer(  void );
          
           /**
           * Instance variable for singleton console object implementation.
           */
           static MediaDeployer* _mediaDeployerInstance;
          
           /**
           * Scene manager to which deploy the media
           */
      52   Ogre::SceneManager* mSceneMgr;
          
          }; // End of class declaration
          }
          
          
          #endif

./components/ogre/MediaUpdater.cpp

       1  //
          // C++ Implementation: MediaUpdater
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "MediaUpdater.h"
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include "services/wfut/WfutService.h"
          
          namespace EmberOgre {
          
      31  MediaUpdater::MediaUpdater(   )
          {
          }
          
          
      36  MediaUpdater::~MediaUpdater(   )
          {
          }
          
      40  void MediaUpdater::performUpdate(   )
          {
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingleton(   ).getConfigService(   );
           Ember::WfutService* wfutSrv= Ember::EmberServices::getSingleton(   ).getWfutService(   );
          
           if (  configSrv->itemExists(  "wfut",   "server" ) ) {
           std::string server(  configSrv->getValue(  "wfut",   "server" ) );
           if (  configSrv->itemExists(  "wfut",   "channel" ) ) {
           std::string channel(  configSrv->getValue(  "wfut",   "channel" ) );
          
           wfutSrv->startUpdate(  server,   channel,   configSrv->getHomeDirectory(   ) ,   "" );
           while (  wfutSrv->poll(   ) ) {
           }
          
           }
           }
          
          }
          
          
          }

./components/ogre/MediaUpdater.h

       1  //
          // C++ Interface: MediaUpdater
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREMEDIAUPDATER_H
          #define EMBEROGREMEDIAUPDATER_H
          
          namespace EmberOgre {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      31  class MediaUpdater{
          public:
      33   MediaUpdater(   );
          
      35   ~MediaUpdater(   );
          
      37   void performUpdate(   );
          
          
          
          };
          
          }
          
          #endif

./components/ogre/MeshCollisionDetector.cpp

       1  //
          // C++ Implementation: MeshCollisionDetector
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          // This code is taked from http://www.ogre3d.org/wiki/index.php/Raycasting_to_the_polygon_level (  2008-01-13 ),   where it's released as Public Domain,   and now relicensed to GPL. Author is unknown.
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "MeshCollisionDetector.h"
          
          #include "EmberOgrePrerequisites.h"
          
          #include "model/Model.h"
          #include "model/SubModel.h"
          
          namespace EmberOgre {
          
      37  MeshCollisionDetector::MeshCollisionDetector(  Model::Model* model )
          :mModel(  model )
          {
          }
          
          
      43  MeshCollisionDetector::~MeshCollisionDetector(   )
          {
          }
          
      47  void MeshCollisionDetector::reload(   )
          {
          }
          
      51  void MeshCollisionDetector::refit(   )
          {
          }
          
      55  void MeshCollisionDetector::setVisualize(  bool visualize )
          {
          }
      58  bool MeshCollisionDetector::getVisualize(   ) const
          {
           return false;
          }
          
      63  void MeshCollisionDetector::testCollision(  Ogre::Ray& ray,   CollisionResult& result )
          {
          
           // at this point we have raycast to a series of different objects bounding boxes.
           // we need to test these different objects to see which is the first polygon hit.
           // there are some minor optimizations (  distance based ) that mean we wont have to
           // check all of the objects most of the time,   but the worst case scenario is that
           // we need to test every triangle of every object.
           Ogre::Real closest_distance = -1.0f;
           Ogre::Vector3 closest_result;
           const Model::Model::SubModelSet& submodels = mModel->getSubmodels(   );
           for (  Model::Model::SubModelSet::const_iterator I = submodels.begin(   ); I != submodels.end(   ); ++I )
           {
           Ogre::Entity* pentity = (  *I )->getEntity(   );
           if (  pentity->isVisible(   ) ) {
           // mesh data to retrieve
           size_t vertex_count;
           size_t index_count;
           Ogre::Vector3 *vertices;
           unsigned long *indices;
          
           // get the mesh information
           getMeshInformation(  pentity->getMesh(   ),   vertex_count,   vertices,   index_count,   indices,  
           pentity->getParentNode(   )->getWorldPosition(   ),  
           pentity->getParentNode(   )->getWorldOrientation(   ),  
           pentity->getParentNode(   )->getScale(   ) );
          
           // test for hitting individual triangles on the mesh
           bool new_closest_found = false;
           for (  int i = 0; i < static_cast<int>(  index_count ); i += 3 )
           {
           // check for a hit against this triangle
           std::pair<bool,   Ogre::Real> hit = Ogre::Math::intersects(  ray,   vertices[indices[i]],  
           vertices[indices[i+1]],   vertices[indices[i+2]],   true,   false );
          
           // if it was a hit check if its the closest
           if (  hit.first )
           {
           if (  (  closest_distance < 0.0f ) ||
           (  hit.second < closest_distance ) )
           {
           // this is the closest so far,   save it off
           closest_distance = hit.second;
           new_closest_found = true;
           }
           }
           }
          
           // free the verticies and indicies memory
           delete[] vertices;
           delete[] indices;
          
           // if we found a new closest raycast for this object,   update the
           // closest_result before moving on to the next object.
           if (  new_closest_found )
           {
           closest_result = ray.getPoint(  closest_distance );
           }
           }
           }
          
          
           // return the result
           if (  closest_distance >= 0.0f )
           {
           // raycast success
           result.collided = true;
           result.position = closest_result;
           result.distance = closest_distance;
           }
           else
           {
           // raycast failed
           result.collided = false;
           }
          }
          
          
          // Get the mesh information for the given mesh.
          // Code found on this forum link: http://www.ogre3d.org/wiki/index.php/RetrieveVertexData
     143  void MeshCollisionDetector::getMeshInformation(  const Ogre::MeshPtr mesh,  
     144   size_t &vertex_count,  
     145   Ogre::Vector3* &vertices,  
     146   size_t &index_count,  
           unsigned long* &indices,  
     148   const Ogre::Vector3 &position,  
     149   const Ogre::Quaternion &orient,  
     150   const Ogre::Vector3 &scale )
          {
           bool added_shared = false;
           size_t current_offset = 0;
           size_t shared_offset = 0;
           size_t next_offset = 0;
           size_t index_offset = 0;
          
           vertex_count = index_count = 0;
          
           // Calculate how many vertices and indices we're going to need
           for (  unsigned short i = 0; i < mesh->getNumSubMeshes(   ); ++i )
           {
           Ogre::SubMesh* submesh = mesh->getSubMesh(   i  );
          
           // We only need to add the shared vertices once
           if(  submesh->useSharedVertices )
           {
           if(   !added_shared  )
           {
           vertex_count += mesh->sharedVertexData->vertexCount;
           added_shared = true;
           }
           }
           else
           {
           vertex_count += submesh->vertexData->vertexCount;
           }
          
           // Add the indices
           index_count += submesh->indexData->indexCount;
           }
          
          
           // Allocate space for the vertices and indices
           vertices = new Ogre::Vector3[vertex_count];
           indices = new unsigned long[index_count];
          
           added_shared = false;
          
           // Run through the submeshes again,   adding the data into the arrays
           for (   unsigned short i = 0; i < mesh->getNumSubMeshes(   ); ++i )
           {
           Ogre::SubMesh* submesh = mesh->getSubMesh(  i );
          
           Ogre::VertexData* vertex_data = submesh->useSharedVertices ? mesh->sharedVertexData : submesh->vertexData;
          
           if(  (  !submesh->useSharedVertices )||(  submesh->useSharedVertices && !added_shared ) )
           {
           if(  submesh->useSharedVertices )
           {
           added_shared = true;
           shared_offset = current_offset;
           }
          
           const Ogre::VertexElement* posElem =
           vertex_data->vertexDeclaration->findElementBySemantic(  Ogre::VES_POSITION );
          
           Ogre::HardwareVertexBufferSharedPtr vbuf =
           vertex_data->vertexBufferBinding->getBuffer(  posElem->getSource(   ) );
          
           unsigned char* vertex =
           static_cast<unsigned char*>(  vbuf->lock(  Ogre::HardwareBuffer::HBL_READ_ONLY ) );
          
           // There is _no_ baseVertexPointerToElement(   ) which takes an Ogre::Real or a double
           // as second argument. So make it float,   to avoid trouble when Ogre::Real will
           // be comiled/typedefed as double:
           // Ogre::Real* pReal;
           float* pReal;
          
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
          
           Ogre::Vector3 pt(  pReal[0],   pReal[1],   pReal[2] );
          
           vertices[current_offset + j] = (  orient * (  pt * scale ) ) + position;
           }
          
           vbuf->unlock(   );
           next_offset += vertex_data->vertexCount;
           }
          
          
           Ogre::IndexData* index_data = submesh->indexData;
           size_t numTris = index_data->indexCount / 3;
           Ogre::HardwareIndexBufferSharedPtr ibuf = index_data->indexBuffer;
          
           bool use32bitindexes = (  ibuf->getType(   ) == Ogre::HardwareIndexBuffer::IT_32BIT );
          
           unsigned long* pLong = static_cast<unsigned long*>(  ibuf->lock(  Ogre::HardwareBuffer::HBL_READ_ONLY ) );
           unsigned short* pShort = reinterpret_cast<unsigned short*>(  pLong );
          
          
           size_t offset = (  submesh->useSharedVertices )? shared_offset : current_offset;
          
           if (   use32bitindexes  )
           {
           for (   size_t k = 0; k < numTris*3; ++k )
           {
           indices[index_offset++] = pLong[k] + static_cast<unsigned long>(  offset );
           }
           }
           else
           {
           for (   size_t k = 0; k < numTris*3; ++k )
           {
           indices[index_offset++] = static_cast<unsigned long>(  pShort[k] ) +
           static_cast<unsigned long>(  offset );
           }
           }
          
           ibuf->unlock(   );
           current_offset = next_offset;
           }
          }
          
          }

./components/ogre/MeshCollisionDetector.h

       1  //
          // C++ Interface: MeshCollisionDetector
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREMESHCOLLISIONDETECTOR_H
          #define EMBEROGREMESHCOLLISIONDETECTOR_H
          
          #include "EmberEntityUserObject.h"
          
          namespace EmberOgre {
          
          /**
           Uses a brute force approach to checking for intersection by iterating through all vertices to see which intersects the ray.
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      34  class MeshCollisionDetector : public ICollisionDetector
          {
          public:
      37   MeshCollisionDetector(  Model::Model* model );
          
      39   virtual ~MeshCollisionDetector(   );
          
      41   virtual void testCollision(  Ogre::Ray& ray,   CollisionResult& result );
      42   virtual void refit(   );
           /**
           * Called when the entity changes,   such as a subentity being hidden or shown. Implementations must reload the collision data.
           */
      46   virtual void reload(   );
          
      48   virtual void setVisualize(  bool visualize );
      49   virtual bool getVisualize(   ) const;
          
          protected:
      52   Model::Model* mModel;
      53   void getMeshInformation(  const Ogre::MeshPtr mesh,  
      54   size_t &vertex_count,  
      55   Ogre::Vector3* &vertices,  
      56   size_t &index_count,  
           unsigned long* &indices,  
      58   const Ogre::Vector3 &position,  
      59   const Ogre::Quaternion &orient,  
      60   const Ogre::Vector3 &scale );
          };
          
          }
          
          #endif

./components/ogre/MotionManager.cpp

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "EmberEntity.h"
          #include "EmberPhysicalEntity.h"
          
          #include "EmberOgre.h"
          #include "MathConverter.h"
          #include "MotionManager.h"
          // #include "terrain/TerrainGenerator.h"
          
          template<> EmberOgre::MotionManager* Ember::Singleton<EmberOgre::MotionManager>::ms_Singleton = 0;
          namespace EmberOgre {
          
          
      31  MotionManager::MotionManager(   )
          : mControllerManager(  &Ogre::ControllerManager::getSingleton(   ) )
          {
           mInfo.MovingEntities = mMotionSet.size(   );
           mInfo.AnimatedEntities = mAnimatedEntities.size(   );
           mInfo.Animations = mAnimations.size(   );
          }
          
          
      40  MotionManager::~MotionManager(   )
          {}
          
          
      44  void MotionManager::doMotionUpdate(  Ogre::Real timeSlice )
          {
           std::set<EmberEntity*>::iterator I;
           for (  I = mMotionSet.begin(   ); I != mMotionSet.end(   ); ++I ) {
           updateMotionForEntity(  *I,   timeSlice );
           }
          }
          
      52  void MotionManager::doAnimationUpdate(  Ogre::Real timeSlice )
          {
          
           EntityStore::iterator I = mAnimatedEntities.begin(   );
           for (  ;I != mAnimatedEntities.end(   ); ++I ) {
           I->second->updateAnimation(  timeSlice );
           }
          /* AnimationStateSet::iterator I = mAnimations.begin(   );
           AnimationStateSet::iterator I_end = mAnimations.end(   );
           for (  ;I != I_end; ++I ) {
           if (  (  *I )->getEnabled(   ) ) {
           (  *I )->addTime(  timeSlice );
           }
           }*/
          }
          
          
          
      70  void MotionManager::updateMotionForEntity(  EmberEntity* entity,   Ogre::Real timeSlice )
          {
           entity->updateMotion(  timeSlice );
          }
          
          // void MotionManager::adjustHeightPositionForNode(  Ogre::SceneNode* sceneNode ) {
          // Ogre::Vector3 position = sceneNode->getPosition(   );
          // //get the height from Mercator through the TerrainGenerator
          // assert(  mTerrainGenerator );
          // TerrainPosition pos = Ogre2Atlas_TerrainPosition(  position );
          // float height = mTerrainGenerator->getHeight(  pos );
          // sceneNode->setPosition(  position.x,   height,  position.z );
          //
          // }
          
      85  bool MotionManager::frameStarted(  const Ogre::FrameEvent& event )
          {
           doMotionUpdate(  event.timeSinceLastFrame );
           doAnimationUpdate(  event.timeSinceLastFrame );
           return true;
          }
          
      92  bool MotionManager::frameEnded(  const Ogre::FrameEvent& event )
          {
           return true;
          }
          
      97  void MotionManager::addEntity(  EmberEntity* entity )
          {
           mMotionSet.insert(  entity );
           mInfo.MovingEntities = mMotionSet.size(   );
           entity->updateMotion(  0 );
          }
          
     104  void MotionManager::removeEntity(  EmberEntity* entity )
          {
           mMotionSet.erase(  entity );
           mInfo.MovingEntities = mMotionSet.size(   );
          // entity->updateMotion(  0 );
          }
          
          
          
     113  void MotionManager::addAnimatedEntity(  EmberPhysicalEntity* entity )
          {
           mAnimatedEntities[entity->getId(   )] = entity;
           mInfo.AnimatedEntities = mAnimatedEntities.size(   );
          }
          
     119  void MotionManager::removeAnimatedEntity(  EmberPhysicalEntity* entity )
          {
           mAnimatedEntities.erase(  entity->getId(   ) );
           mInfo.AnimatedEntities = mAnimatedEntities.size(   );
          }
          
          
     126  void MotionManager::addAnimation(  Ogre::AnimationState* animationState )
          {
          
           animationState->setEnabled(  true );
           mAnimations.insert(  animationState );
           mInfo.Animations = mAnimations.size(   );
          
          /*
           //check if it's not already added
           AnimationStateSet::const_iterator I = mAnimations.find(  animationState );
           if (  I == mAnimations.end(   ) ) {
           animationState->setEnabled(  true );
           mAnimations.insert(  animationState );
          
          
           //how is the overhead on creating a ControllerFunction for each single AnimationState?
           //perhaps we should keep ControllerFunction bound to Animation instead?
           Ogre::AnimationControllerFunction* controllerFunction = new Ogre::AnimationControllerFunction(  animationState->getLength(   ) );
           animationControllerType* animationController = Ogre::ControllerManager::getSingleton(   ).createController(  mControllerManager->getFrameTimeSource(   ),   animationState,   controllerFunction );
          
           animationState->setEnabled(  true );
          
           mAnimations.insert(  animationStateMap::value_type(  animationState,   animationController ) );
          
           }
           */
          
          }
          
     155  void MotionManager::removeAnimation(  Ogre::AnimationState* animationState )
          {
           AnimationStateSet::const_iterator I = mAnimations.find(  animationState );
           if (  I != mAnimations.end(   ) ) {
           mAnimations.erase(  *I );
           //animationControllerType* animationController = mAnimations[animationState];
           /* don't need to do this as SharePtr uses reference counting
           Ogre::SharedPtr< ControllerFunction<Ogre::Real> > controllerFunctionPtr = (  animationController->getFunction(   ) );
           delete *controllerFunctionPtr;
           */
          
          /* mAnimations.erase(  I->first );
          
           animationControllerType* controllerFunction = I->second;
           if (  controllerFunction )
           {
           }
           Ogre::ControllerManager::getSingleton(   ).destroyController(  controllerFunction );
           std::cout << "removed controller\n";
           */
          // Ogre::ControllerManager::getSingleton(   ).destroyController(  I->second );
          
           }
           mInfo.Animations = mAnimations.size(   );
          
          }
          
     182  void MotionManager::pauseAnimation(  Ogre::AnimationState* animationState )
          {
           animationState->setEnabled(  false );
          /*
           animationControllerType* animationController = mAnimations[animationState];
           animationController->setEnabled(  false );
           */
          }
          
     191  void MotionManager::unpauseAnimation(  Ogre::AnimationState* animationState )
          {
           animationState->setEnabled(  true );
          /*
           animationControllerType* animationController = mAnimations[animationState];
           animationController->setEnabled(  true );
           */
          }
          
          
          // void MotionManager::setTerrainGenerator(  TerrainGenerator* generator ) {
          // mTerrainGenerator = generator;
          // }
          
          
          }

./components/ogre/MotionManager.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef MOTIONMANAGER_H
          #define MOTIONMANAGER_H
          
          #include "EmberOgrePrerequisites.h"
          #include <OgrePredefinedControllers.h>
          #include "framework/Singleton.h"
          
          namespace EmberOgre {
          
      28  class EmberEntity;
      29  class EmberPhysicalEntity;
          // class TerrainGenerator;
          
          /**
           * This class will be responsible for making sure that entites moves
           * in a nice and fluid way. Eventually we'll also implement physics,   perhaps it
           * will go into here.
           * The manager also takes care of keeping tabs on all animations.
           */
      38  class MotionManager : public Ogre::FrameListener,   public Ember::Singleton<MotionManager> {
          public:
          
           /**
           A struct containing information about the MotionManager.
           */
           struct MotionManagerInfo
           {
           size_t AnimatedEntities;
           size_t MovingEntities;
           size_t Animations;
           };
          
      51   MotionManager(   );
      52   virtual ~MotionManager(   );
           //static MotionManager & getSingleton(  void );
          
           /**
           * Adds a EmberEntity to the movement list.
           * That means that until removeEntity is called for the specific entity
           * new positions for the entity will be calculated for each frame.
           */
      60   void addEntity(  EmberEntity* entity );
      61   void removeEntity(  EmberEntity* entity );
          
           /**
           * Registers an animationState. After registration it will be enough to use
           * AnimationState::enabled(  bool ) to toggle the animation on and off
           */
      67   void addAnimation(  Ogre::AnimationState* animationState );
           /**
           * Deregisters an animationState
           */
      71   void removeAnimation(  Ogre::AnimationState* animationState );
           /**
           * Pauses the supplies animationState
           */
      75   void pauseAnimation(  Ogre::AnimationState* animationState );
           /**
           * Unpauses (  starts ) an already paused animationState
           */
      79   void unpauseAnimation(  Ogre::AnimationState* animationState );
          
      81   void addAnimatedEntity(  EmberPhysicalEntity* entity );
      82   void removeAnimatedEntity(  EmberPhysicalEntity* entity );
          
          /* void addAction(  Action* action );
           void removeAction(  Action* action );*/
          
          
          
           /**
           * Methods from Ogre::FrameListener
           */
      92   bool frameStarted(  const Ogre::FrameEvent& event );
      93   bool frameEnded(  const Ogre::FrameEvent& event );
          
           /**
           * Adjusts the height of the supplied node
           */
           //void adjustHeightPositionForNode(  Ogre::SceneNode* sceneNode );
          
          // void setTerrainGenerator(  TerrainGenerator* generator );
          
           /**
           * Gets info about the MotionManager.
           * @return
           */
     106   inline const MotionManagerInfo& getInfo(   ) const;
          
          private:
          
           typedef std::map<std::string ,   EmberPhysicalEntity*> EntityStore;
     111   EntityStore mAnimatedEntities;
          
          
           MotionManagerInfo mInfo;
          // typedef std::set<Action*> ActionStore;
          // ActionStore mActions;
          
           /**
           * A pointer to the applications ControllerManager. This will take care of
           * keeping tabs on all controllers.
           */
     122   Ogre::ControllerManager* mControllerManager;
           typedef Ogre::Controller<Ogre::Real> animationControllerType;
           typedef std::map<Ogre::AnimationState*,   animationControllerType*> animationStateMap;
           typedef std::set<Ogre::AnimationState*> AnimationStateSet;
           /**
           * A map of AnimationState's and their corresponding Controllers
           */
     129   AnimationStateSet mAnimations;
          
          
           //static MotionManager* _instance;
          
           /** This method will iterate over all registered moving entities and update
           * their positions.
           */
     137   void doMotionUpdate(  Ogre::Real timeSlice );
          
           /** This method will iterate over all registered animationStates and update
           * those that are enabled
           */
     142   void doAnimationUpdate(  Ogre::Real timeSlice );
          
          
           /**
           * Update the motion for a single EmberEntity
           */
     148   void updateMotionForEntity(  EmberEntity* entity,   Ogre::Real timeSlice );
          
           /**
           * This contains all of the entities that will be moved each frame
           */
     153   std::set<EmberEntity*> mMotionSet;
          
          // TerrainGenerator* mTerrainGenerator;
          
          };
          
     159  const MotionManager::MotionManagerInfo& MotionManager::getInfo(   ) const
          {
           return mInfo;
          }
          
          
          }
          
          
          #endif // MOTIONMANAGER_H

./components/ogre/MousePicker.cpp

       1  //
          // C++ Implementation: MousePicker
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "EmberEntity.h"
          #include "EmberOgre.h"
          //#include "EmberPhysicalEntity.h"
          //#include "PersonEmberEntity.h"
          //#include "AvatarEmberEntity.h"
          #include "AvatarCamera.h"
          #include "GUIManager.h"
          //#include "AvatarController.h"
          
          #include "MousePicker.h"
          
          namespace EmberOgre {
          
      37  MousePicker::MousePicker(   )
          {
          }
          
          
      42  MousePicker::~MousePicker(   )
          {
          }
          
      46  void MousePicker::doMousePicking(  const Ogre::Real x,   const Ogre::Real y,  const MousePickerArgs& args )
          {
           AvatarCamera* camera = EmberOgre::getSingleton(   ).getMainCamera(   );
          
          
           camera->pickInWorld(  x,   y,   args );
          /* if (  result.entity ) {
           mLastPickedEntityResult = result;
           onEventPickedEntity(  mLastPickedEntityResult,   args );
           } else {
           onEventPickedNothing(  args );
           }*/
          
          }
          
          
          
          // void MousePicker::onEventPickedEntity(  const EntityPickResult & result,   const MousePickerArgs& args )
          // {
          // EventPickedEntity.emit(  result,   args );
          // }
          //
          // void MousePicker::onEventPickedNothing(  const MousePickerArgs& args )
          // {
          // EventPickedNothing.emit(  args );
          // }
          
          
          
          };

./components/ogre/MousePicker.h

       1  //
          // C++ Interface: MousePicker
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef DIMEOGREMOUSEPICKER_H
          #define DIMEOGREMOUSEPICKER_H
          
          #include <sigc++/signal.h>
          
          
          #include "IWorldPickListener.h"
          #include "EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
          
          /**
          Class used for picking stuff in the world.
          Since we sometimes want different picking behaviour (  sometimes we want to pick building blocks,   sometimes we want to pick entities ) it's possible to create derived classes and register them with the GUIManager.
          
          @author Erik Hjortsberg
          */
      41  class MousePicker
          {
          public:
           enum ClickMasks
           {
           CM_AVATAR = 1<<9,  
           CM_ENTITY = 1<<10,  
           CM_NATURE = 1<<11,  
           CM_UNDEFINED = 1<<12,  
           CM_NONPICKABLE = 1<<13
           };
          
      53   MousePicker(   );
          
      55   virtual ~MousePicker(   );
          
           /**
           * Try to pick something at the specified coordinates
           * @param x
           * @param y
           * @param args
           */
      63   virtual void doMousePicking(  const Ogre::Real x,   const Ogre::Real y,   const MousePickerArgs& args );
          
          
          
          // sigc::signal<void,   const MousePickerArgs&> EventPickedNothing;
          
          // inline EmberEntity* getLastPickedEntity(   ) { return mLastPickedEntityResult.entity; }
          
          
          protected:
          
          // virtual void onEventPickedEntity(  const EntityPickResult & result,   const MousePickerArgs& args );
          // virtual void onEventPickedNothing(  const MousePickerArgs& args );
          
          
          
          
           //the currently selected entity
          // EmberEntity* mEntityUnderCursor;
          
           //the last clicked entity
          // EntityPickResult mLastPickedEntityResult;
          };
          
          }
          
          #endif

./components/ogre/OgreIncludes.h

       1  //
          // C++ Interface: OgreIncludes
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          //base include files needed for Ogre
          
          
          //we don't want to use the ogre memory manager,   since it messes with Atlas in debug mode,   so we'll simply define __MemoryManager_H__ here so that the OgreMemoryMacros.h never will be parsed
          
          //however,   we'll put this in config.h for now instead
          
          // #ifndef __MemoryManager_H__
          // #define __MemoryManager_H__
          // #endif
          
          // #define OGRE_MEMORY_MACROS
          // #include <OgreMemoryMacros.h>
          // #include <OgreNoMemoryMacros.h>
          //#include <OgreNoMemoryMacros.h>
          #include <Ogre.h>

./components/ogre/OgreInfo.cpp

       1  //
          // C++ Implementation: OgreInfo
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OgreInfo.h"
          
          #ifdef WIN32
          #else
           #include <GL/gl.h>
          #endif
          
          
          namespace EmberOgre {
          
      33  OgreInfo::OgreInfo(   )
          {
          }
          
          
      38  OgreInfo::~OgreInfo(   )
          {
          }
          
          
      43  bool OgreInfo::isIndirect(   ) const
          {
          #ifdef WIN32
           ///TODO: add checks for win32 too
           return false;
          #else
           const GLubyte* pcRenderer = glGetString(  GL_RENDERER );
           const std::string renderer(  (  const char* )pcRenderer );
          
           return renderer.find(  "Indirect" ) != std::string::npos;
          #endif
          
          }
          
          
          }

./components/ogre/OgreInfo.h

       1  //
          // C++ Interface: OgreInfo
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREOGREINFO_H
          #define EMBEROGREOGREINFO_H
          
          #include "EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
          /**
          
           Provides methods for getting some basic information about the Ogre environment.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      36  class OgreInfo{
          public:
      38   OgreInfo(   );
          
      40   ~OgreInfo(   );
          
          
           /**
           * True if the rendering is indirect,   for example when using Mesa drivers on Linux. This will result in _very_ bad performance,   and is usually caused by the user not having vendor drivers installed.
           * @return
           */
      47   bool isIndirect(   ) const;
          
          };
          
          }
          
          #endif

./components/ogre/OgreLogObserver.cpp

       1  //
          // C++ Implementation: OgreLogObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OgreLogObserver.h"
          
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          
          
          using namespace Ogre;
          namespace EmberOgre {
          
          
          
      34  OgreLogObserver::OgreLogObserver(   )
          {
          }
          
      38  OgreLogObserver::~OgreLogObserver(   )
          {
          
          }
          
          
          
      45  void OgreLogObserver::messageLogged(   const String& message,   LogMessageLevel lml,   bool maskDebug,   const String &logName  )
          {
           static std::string ogre(  "(  Ogre ) " );
           switch (  lml ) {
           case Ogre::LML_TRIVIAL:
           Ember::EmberServices::getSingletonPtr(   )->getLoggingService(   )->log(  "Ogre",   Ember::LoggingService::VERBOSE,   (  ogre + message ).c_str(   ) );
           break;
           case Ogre::LML_NORMAL:
           Ember::EmberServices::getSingletonPtr(   )->getLoggingService(   )->log(  "Ogre",   Ember::LoggingService::INFO,   (  ogre + message ).c_str(   ) );
           break;
           case Ogre::LML_CRITICAL:
           Ember::EmberServices::getSingletonPtr(   )->getLoggingService(   )->log(  "Ogre",   Ember::LoggingService::FAILURE,   (  ogre + message ).c_str(   ) );
           break;
           }
          }
          
          
          
          
          }

./components/ogre/OgreLogObserver.h

       1  //
          // C++ Interface: OgreLogObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREOGRELOGOBSERVER_H
          #define EMBEROGREOGRELOGOBSERVER_H
          
          #include "EmberOgrePrerequisites.h"
          #include "framework/StreamLogObserver.h"
          
          namespace EmberOgre {
          
          /**
          @author Erik Hjortsberg
          A log observer which writes to the Ogre log system.
          This is a combined Ogre::LogListener and a Ember::StreamLogObserver.
          The Ember::StreamLogObserver part does the main work,   while the Ogre::LogListener implementation allow us to recieve ogre log events.
          */
      37  class OgreLogObserver: public Ogre::LogListener
          {
           public:
           /**
           * Creates a new OgreLogObserver using default values.
           */
      43   OgreLogObserver(   );
      44   ~OgreLogObserver(   );
      45   virtual void messageLogged(   const Ogre::String& message,   Ogre::LogMessageLevel lml,   bool maskDebug,   const Ogre::String &logName  );
          
           protected:
          
          
          
          };
          
          }
          
          #endif

./components/ogre/OgreResourceLoader.cpp

       1  //
          // C++ Implementation: OgreResourceLoader
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OgreResourceLoader.h"
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/server/ServerService.h"
          #include "services/config/ConfigService.h"
          #include "model/ModelDefinitionManager.h"
          
          #include "framework/osdir.h"
          #include <fstream>
          
          namespace EmberOgre {
          
      35  OgreResourceLoader::OgreResourceLoader(   ) : mLoadRecursive(  false )
          {
          }
          
          
      40  OgreResourceLoader::~OgreResourceLoader(   )
          {
          }
          
      44  void OgreResourceLoader::initialize(   )
          {
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
          
           ///check from the config if we should load media recursively
           ///this is needed for most authoring,   since it allows us to find all meshes before they are loaded
           if (  configSrv->itemExists(  "media",   "loadmediarecursive" ) ) {
           mLoadRecursive = (  bool )configSrv->getValue(  "media",   "loadmediarecursive" );
           }
          
          // chdir(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ).c_str(   ) );
           ///load the resource file
           const std::string configPath(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getSharedConfigDirectory(   ) + "/resources.cfg" );
           S_LOG_VERBOSE(  "Loading resources definitions from " << configPath );
           mConfigFile.load(  configPath );
          
          }
          
      62  unsigned int OgreResourceLoader::numberOfSections(   )
          {
           unsigned int numberOfSections = 0;
           Ogre::ConfigFile::SectionIterator I = mConfigFile.getSectionIterator(   );
           while (  I.hasMoreElements(   ) ) {
           numberOfSections++;
           I.moveNext(   );
           }
           return numberOfSections - 1;
          }
          
          
      74  bool OgreResourceLoader::addSharedMedia(  const std::string& path,   const std::string& type,   const std::string& section,   bool recursive )
          {
           static const std::string& sharedMediaPath = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getSharedMediaDirectory(   );
          
           bool foundDir = false;
          
           S_LOG_INFO(  "Looking for " << sharedMediaPath + path );
           if (  isExistingDir(  sharedMediaPath + path ) ) {
           S_LOG_INFO(  "Adding dir " << sharedMediaPath + path );
           try {
           Ogre::ResourceGroupManager::getSingleton(   ).addResourceLocation(  
           sharedMediaPath + path,   type,   section,   recursive );
           foundDir = true;
           } catch (  const Ogre::Exception& ex ) {
           const std::string& message = ex.getFullDescription(   );
           S_LOG_FAILURE(  "Couldn't load " + sharedMediaPath + path + ". Error: "<< message );
           }
           }
          
           return foundDir;
          }
          
      96  bool OgreResourceLoader::addUserMedia(  const std::string& path,   const std::string& type,   const std::string& section,   bool recursive )
          {
           static const std::string& userMediaPath = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getUserMediaDirectory(   );
           static const std::string& emberMediaPath = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getEmberMediaDirectory(   );
          
           bool foundDir = false;
          
           S_LOG_VERBOSE(  "Looking for " << userMediaPath + path );
           if (  isExistingDir(  userMediaPath + path ) ) {
           S_LOG_VERBOSE(  "Adding dir " << userMediaPath + path );
           try {
           Ogre::ResourceGroupManager::getSingleton(   ).addResourceLocation(  
           userMediaPath + path,   type,   section,   recursive );
           foundDir = true;
           } catch (  const Ogre::Exception& ) {
           ///don't report anything
           }
           }
          
           ///try with ember-media
           S_LOG_VERBOSE(  "Looking for " << emberMediaPath + path );
           if (  isExistingDir(  emberMediaPath + path ) ) {
           S_LOG_VERBOSE(  "Adding dir " << emberMediaPath + path );
           try {
           Ogre::ResourceGroupManager::getSingleton(   ).addResourceLocation(  
           emberMediaPath + path,   type,   section,   recursive );
           foundDir = true;
           } catch (  const Ogre::Exception& ) {
           S_LOG_FAILURE(  "Couldn't load " + emberMediaPath + path + ". Continuing as if nothing happened." );
           }
           }
           return foundDir;
          }
          
          
     131  void OgreResourceLoader::loadBootstrap(   )
          {
           loadSection(  "Bootstrap" );
          }
          
     136  void OgreResourceLoader::loadGui(   )
          {
           loadSection(  "Gui" );
          }
          
     141  void OgreResourceLoader::loadGeneral(   )
          {
           loadSection(  "General" );
           loadSection(  "ModelDefinitions" );
          
          
           loadAllUnloadedSections(   );
          
           ///out of pure interest we'll print out how many modeldefinitions we've loaded
           Ogre::ResourceManager::ResourceMapIterator I = Model::ModelDefinitionManager::getSingleton(   ).getResourceIterator(   );
           int count = 0;
           while (  I.hasMoreElements(   ) ) {
           ++count;
           I.moveNext(   );
           }
          
           S_LOG_INFO(  "Finished loading " << count << " modeldefinitions." );
          }
          
     160  void OgreResourceLoader::preloadMedia(   )
          {
           try {
           Ogre::ResourceGroupManager::getSingleton(   ).loadResourceGroup(  "General" );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "An error occurred when preloading media. Message:\n\t"<< ex.getFullDescription(   ) );
           }
           try {
           Ogre::ResourceGroupManager::getSingleton(   ).loadResourceGroup(  "Gui" );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "An error occurred when preloading media. Message:\n\t"<< ex.getFullDescription(   ) );
           }
           try {
           Ogre::ResourceGroupManager::getSingleton(   ).loadResourceGroup(  "ModelDefinitions" );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "An error occurred when preloading media. Message:\n\t"<< ex.getFullDescription(   ) );
           }
          
          
          // Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
          //
          //
          // std::vector<std::string> shaderTextures;
          //
          // shaderTextures.push_back(  std::string(  configSrv->getValue(  "shadertextures",   "rock" ) ) );
          // shaderTextures.push_back(  std::string(  configSrv->getValue(  "shadertextures",   "sand" ) ) );
          // shaderTextures.push_back(  std::string(  configSrv->getValue(  "shadertextures",   "grass" ) ) );
          //
          // for (  std::vector<std::string>::iterator I = shaderTextures.begin(   ); I != shaderTextures.end(   ); ++I ) {
          // try {
          // Ogre::TextureManager::getSingleton(   ).load(  *I,   "General" );
          // } catch (  const Ogre::Exception& e ) {
          // S_LOG_FAILURE(   "Error when loading texture " << *I  )
          // }
          // }
          }
          
     197  void OgreResourceLoader::loadSection(  const std::string& sectionName )
          {
           if (  sectionName != "" && std::find(  mLoadedSections.begin(   ),   mLoadedSections.end(   ),   sectionName ) == mLoadedSections.end(   ) )
           {
           bool mediaAdded = false;
          
           S_LOG_VERBOSE(  "Adding resource section " << sectionName );
           // Ogre::ResourceGroupManager::getSingleton(   ).createResourceGroup(  sectionName );
          
           Ogre::ConfigFile::SettingsIterator I = mConfigFile.getSettingsIterator(  sectionName );
           std::string finalTypename;
           while (  I.hasMoreElements(   ) ) {
           //Ogre::ConfigFile::SettingsMultiMap J = I.getNext(   );
           const std::string& typeName = I.peekNextKey(   );
           const std::string& archName = I.peekNextValue(   );
          
           finalTypename = typeName.substr(  0,   typeName.find(  "[" ) );
           if (  Ogre::StringUtil::endsWith(  typeName,   "[shared]" ) ) {
           mediaAdded |= addSharedMedia(  archName,   finalTypename,   sectionName,   mLoadRecursive );
           } else {
           mediaAdded |= addUserMedia(  archName,   finalTypename,   sectionName,   mLoadRecursive );
           }
           I.moveNext(   );
           }
           mLoadedSections.push_back(  sectionName );
          
           ///only initialize the resource group if it has media
           if (  mediaAdded ) {
           try {
           Ogre::ResourceGroupManager::getSingleton(   ).initialiseResourceGroup(  sectionName );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "An error occurred when loading media from section '" << sectionName << "'. Message:\n\t"<< ex.getFullDescription(   ) );
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "An error occurred when loading media from section '" << sectionName << "'. Message:\n\t"<< ex.what(   ) );
           } catch (  ... ) {
           S_LOG_FAILURE(  "An unknown error occurred when loading media from section '" << sectionName << "'." );
           }
           }
           }
          }
          
     238  void OgreResourceLoader::loadAllUnloadedSections(   )
          {
           S_LOG_VERBOSE(  "Now loading all unloaded sections." );
           Ogre::ConfigFile::SectionIterator I = mConfigFile.getSectionIterator(   );
           while (  I.hasMoreElements(   ) ) {
           const std::string& sectionName = I.peekNextKey(   );
           loadSection(  sectionName );
           I.moveNext(   );
           }
          
          }
          
          
     251  bool OgreResourceLoader::isExistingDir(  const std::string& path ) const
          {
           bool exists = false;
           oslink::directory osdir(  path );
           exists = osdir.isExisting(   );
           if (  !exists ) {
           ///perhaps it's a file?
           std::ifstream fin(  path.c_str(   ) ,   std::ios::in  );
           exists = !fin.fail(   );
           }
           return exists;
          }
          
          
          }

./components/ogre/OgreResourceLoader.h

       1  //
          // C++ Interface: OgreResourceLoader
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREOGRERESOURCELOADER_H
          #define EMBEROGREOGRERESOURCELOADER_H
          
          #include "EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
          /**
          @author Erik Hjortsberg
          */
      33  class OgreResourceLoader{
          public:
      35   OgreResourceLoader(   );
          
      37   ~OgreResourceLoader(   );
          
      39   void initialize(   );
          
      41   void loadBootstrap(   );
      42   void loadGui(   );
      43   void loadGeneral(   );
          
      45   void preloadMedia(   );
          
      47   unsigned int numberOfSections(   );
          
          protected:
      50   bool mLoadRecursive;
      51   Ogre::ConfigFile mConfigFile;
          
      53   void loadSection(  const std::string& sectionName );
          
      55   bool addUserMedia(  const std::string& path,   const std::string& type,   const std::string& section,   bool recursive );
      56   bool addSharedMedia(  const std::string& path,   const std::string& type,   const std::string& section,   bool recursive );
          
      58   bool isExistingDir(  const std::string& path ) const;
          
      60   void loadAllUnloadedSections(   );
          
      62   std::vector<std::string> mLoadedSections;
          };
          
          }
          
          #endif

./components/ogre/OgreResourceProvider.cpp

       1  //
          // C++ Implementation: OgreResourceProvider
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OgreResourceProvider.h"
          #include "framework/Exception.h"
          
          namespace EmberOgre {
          
      28  OgreResourceWrapper::OgreResourceWrapper(  Ogre::DataStreamPtr dataStream )
          {
           mSize = dataStream->size(   );
           mBuffer = new char[mSize];
           dataStream->read(  mBuffer,   mSize );
          }
          
      35  OgreResourceWrapper::~OgreResourceWrapper(   )
          {
           delete[] mBuffer;
          }
          
      40  char* OgreResourceWrapper::getDataPtr(   )
          {
           return mBuffer;
          }
          
      45  bool OgreResourceWrapper::hasData(   )
          {
           return mSize != 0;
          }
          
      50  size_t OgreResourceWrapper::getSize(   )
          {
           return mSize;
          }
          
          
          
      57  OgreResourceProvider::OgreResourceProvider(  const std::string& groupName )
          : mGroupName(  groupName )
          {
          }
          
          
      63  OgreResourceProvider::~OgreResourceProvider(   )
          {
          }
          
      67  Ember::ResourceWrapper OgreResourceProvider::getResource(  const std::string& name )
          {
           Ogre::DataStreamPtr input =
           Ogre::ResourceGroupManager::getSingleton(   ).openResource(  name.c_str(   ),   mGroupName.c_str(   ) );
          
           if (  input.isNull(   ) )
           {
           throw Ember::Exception(  "Unable to open resource file '" + name + "' in resource group '" + name + "'." );
           }
           OgreResourceWrapper* wrapper = new OgreResourceWrapper(  input );
           input->close(   );
           return Ember::ResourceWrapper(  wrapper,   name );
          
          // Ogre::String buf = input->getAsString(   );
          // const size_t memBuffSize = buf.length(   );
          //
          // unsigned char* mem = new unsigned char[memBuffSize];
          // memcpy(  mem,   buf.c_str(   ),   memBuffSize );
          //
          // output.setData(  mem );
          // output.setSize(  memBuffSize );
          }
          
          
          
          
          }

./components/ogre/OgreResourceProvider.h

       1  //
          // C++ Interface: OgreResourceProvider
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREOGRERESOURCEPROVIDER_H
          #define EMBEROGREOGRERESOURCEPROVIDER_H
          
          #include "framework/IScriptingProvider.h"
          #include <Ogre.h>
          
          namespace EmberOgre {
          
          
      32  class OgreResourceWrapper : public Ember::IResourceWrapper
          {
          public:
      35   OgreResourceWrapper(  Ogre::DataStreamPtr dataStream );
      36   virtual ~OgreResourceWrapper(   );
          
      38   virtual char* getDataPtr(   );
      39   virtual bool hasData(   );
      40   virtual size_t getSize(   );
          private:
           char* mBuffer;
      43   size_t mSize;
          };
          
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      50  class OgreResourceProvider : public Ember::IResourceProvider
          {
          public:
      53   OgreResourceProvider(  const std::string& groupName );
          
      55   virtual ~OgreResourceProvider(   );
          
      57   virtual Ember::ResourceWrapper getResource(  const std::string& name );
          private:
      59   std::string mGroupName;
          
          };
          
          }
          
          #endif

./components/ogre/OgreSetup.cpp

       1  //
          // C++ Implementation: OgreSetup
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "OgreSetup.h"
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          
          #ifdef WIN32
           #include <SDL.h>
           #include <SDL_syswm.h>
          #else
           #include <SDL/SDL.h>
           #include <SDL/SDL_syswm.h>
           #include "framework/binreloc.h"
           #include <GL/glx.h>
          #endif
          #include "SceneManagers/EmberPagingSceneManager/include/EmberPagingSceneManager.h"
          // #include "image/OgreILCodecs.h"
          #include "framework/Tokeniser.h"
          
          extern "C" {
          #include <signal.h> /* signal name macros,   and the signal(   ) prototype */
          }
          
          namespace EmberOgre {
          
          
          
      55  OgreSetup::OgreSetup(   )
          {
          }
          
          
      60  OgreSetup::~OgreSetup(   )
          {
          }
          
      64  void OgreSetup::shutdown(   )
          {
          // Ogre::ILCodecs::deleteCodecs(   );
           delete mRoot;
           mRoot = 0;
           SDL_Quit(   );
          }
          
          
      73  Ogre::Root* OgreSetup::createOgreSystem(   )
          {
          
          // const std::string& sharePath(  Ember::EmberServices::getSingleton(   ).getConfigService(   )->getSharedConfigDirectory(   ) );
           std::string pluginExtension = ".so";
           mRoot = new Ogre::Root(  "",   "ogre.cfg",   "" );
          
           ///we will try to load the plugins from series of different location,   with the hope of getting at least one right
           std::vector<std::string> pluginLocations;
          
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingleton(   ).getConfigService(   );
           if (  configSrv->itemExists(  "ogre",   "plugins" ) ) {
           std::string plugins(  configSrv->getValue(  "ogre",   "plugins" ) );
           ///if it's defined in the config,   use that location first
           if (  configSrv->itemExists(  "ogre",   "plugindir" ) ) {
           std::string pluginDir(  configSrv->getValue(  "ogre",   "plugindir" ) );
           pluginLocations.push_back(  pluginDir );
           }
           #ifdef __WIN32__
           pluginExtension = ".dll";
           #else
           pluginExtension = ".so";
          
           #ifdef ENABLE_BINRELOC
           ///binreloc might be used
           char* br_libdir = br_find_lib_dir(  br_strcat(  PREFIX,   "/lib" ) );
           std::string libDir(  br_libdir );
           free(  br_libdir );
           pluginLocations.push_back(  libDir + "/ember/OGRE" );
           #endif
           #ifdef OGRE_PLUGINDIR
           ///also try with the plugindir defined for Ogre
           pluginLocations.push_back(  OGRE_PLUGINDIR );
           #endif
           ///enter the usual locations if Ogre is installed system wide,   with local installations taking precedence
           pluginLocations.push_back(  "/usr/local/lib/OGRE" );
           pluginLocations.push_back(  "/usr/lib/OGRE" );
           #endif
           Ember::Tokeniser tokeniser(  plugins,   ",  " );
           std::string token = tokeniser.nextToken(   );
           while (  token != "" ) {
           for (  std::vector<std::string>::iterator I = pluginLocations.begin(   ); I != pluginLocations.end(   ); ++I ) {
           std::string pluginPath(  (  *I ) + "/" + token + pluginExtension );
           bool success = false;
           try {
           S_LOG_INFO(  "Trying to load the plugin " << pluginPath );
           mRoot->loadPlugin(  pluginPath );
           success = true;
           break;
           } catch (  ... ) {
           S_LOG_INFO(  "Error when loading plugin '" << token << "' with path '" << pluginPath << "'. This is not fatal,   we will continue trying with some other paths." );
           }
           if (  !success ) {
           S_LOG_WARNING(  "Error when loading plugin '" << token << "' after trying different parts. We'll continue,   but there might be problems later on." );
           }
           }
           token = tokeniser.nextToken(   );
           }
           }
          
          // std::vector<Ogre::String> tokens = Ogre::StringUtil::split(  dsp,   "." );
           Ember::Tokeniser tokeniser(   );
          
           // Register image codecs
          // Ogre::ILCodecs::registerCodecs(   );
          
           return mRoot;
          }
          
          /**
          Shut down SDL correctly,   else if run in full screen the display might be messed up.
          */
     145  extern "C" void shutdownHandler(  int signal )
          {
           std::cerr << "Crashed with signal " << signal << ",   will try to shut down SDL gracefully. Please report bugs at https://bugs.launchpad.net/ember" << std::endl;
           SDL_Quit(   );
           exit(  signal );
          }
          
          
          /** Configures the application - returns false if the user chooses to abandon configuration. */
     154  bool OgreSetup::configure(  void )
          {
           bool suppressConfig = false;
           bool success = false;
           if (  Ember::EmberServices::getSingleton(   ).getConfigService(   )->itemExists(  "ogre",   "suppressconfigdialog" ) ) {
           suppressConfig = static_cast<bool>(  Ember::EmberServices::getSingleton(   ).getConfigService(   )->getValue(  "ogre",   "suppressconfigdialog" ) );
           }
           if (  suppressConfig ) {
           success = mRoot->restoreConfig(   );
           } else {
           success = mRoot->showConfigDialog(   );
           }
          
           if(  success )
           {
          #if __WIN32__
           ///this will only apply on DirectX
           ///it will force DirectX _not_ to set the FPU to single precision mode (  since this will mess with mercator amongst others )
           try {
           mRoot->getRenderSystem(   )->setConfigOption(  "Floating-point mode",   "Consistent" );
          
           } catch (  const Ogre::Exception& )
           {
           ///we don't know what kind of render system is used,   so we'll just swallow the error since it doesn't affect anything else than DirectX
           }
          
          
           mRenderWindow = mRoot->initialise(  true,   "Ember" );
          
           ///do some FPU fiddling,   since we need the correct settings for stuff like mercator (  which uses fractals etc. ) to work
           _fpreset(   );
           _controlfp(  _PC_64,   _MCW_PC );
           _controlfp(  _RC_NEAR ,   _MCW_RC );
          
           // Allow SDL to use the window Ogre just created
          
           // Old method: do not use this,   because it only works
           // when there is 1 (  one ) window with this name!
           // HWND hWnd = FindWindow(  tmp,   0 );
          
           // New method: As proposed by Sinbad.
           // This method always works.
           HWND hWnd;
           mRenderWindow->getCustomAttribute(  "WINDOW",   &hWnd );
          
           char tmp[64];
           // Set the SDL_WINDOWID environment variable
           sprintf(  tmp,   "SDL_WINDOWID=%d",   hWnd );
           putenv(  tmp );
          
           if (  SDL_Init(  SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0 )
           {
           S_LOG_FAILURE(  "Couldn't initialize SDL:\n\t\t" );
           S_LOG_FAILURE(  SDL_GetError(   ) );
           }
          
           // if width = 0 and height = 0,   the window is fullscreen
          
           // This is necessary to allow the window to move1
           // on WIN32 systems. Without this,   the window resets
           // to the smallest possible size after moving.
           SDL_SetVideoMode(  mRenderWindow->getWidth(   ),   mRenderWindow->getHeight(   ),   0,   0 ); // first 0: BitPerPixel,  
           // second 0: flags (  fullscreen/... )
           // neither are needed as Ogre sets these
          
           static SDL_SysWMinfo pInfo;
           SDL_VERSION(  &pInfo.version );
           SDL_GetWMInfo(  &pInfo );
          
           // Also,   SDL keeps an internal record of the window size
           // and position. Because SDL does not own the window,   it
           // missed the WM_POSCHANGED message and has no record of
           // either size or position. It defaults to {0,   0,   0,   0},  
           // which is then used to trap the mouse "inside the
           // window". We have to fake a window-move to allow SDL
           // to catch up,   after which we can safely grab input.
           RECT r;
           GetWindowRect(  pInfo.window,   &r );
           SetWindowPos(  pInfo.window,   0,   r.left,   r.top,   0,   0,   SWP_NOMOVE | SWP_NOSIZE );
          
           ///do some FPU fiddling,   since we need the correct settings for stuff like mercator (  which uses fractals etc. ) to work
           _fpreset(   );
           _controlfp(  _PC_64,   _MCW_PC );
           _controlfp(  _RC_NEAR ,   _MCW_RC );
          #else
          
           ///On *NIX,   Ogre can have either a SDL or an GLX backend (  or "platform",   it's selected at compile time by the --with-platform=[GLX|SDL] option ). Ogre 1.2+ uses GLX by default.
           ///However,   we use SDL for our input systems. If the SDL backend then is used,   everything is already set up for us.
           ///If on the other hand the GLX backend is used,   we need to do some fiddling to get SDL to play nice with the GLX render system.
          
           ///Check if SDL already has been initalized. If it has,   we know that Ogre uses the SDL backend (  the call to SDL_Init happens at mRoot->restoreConfig(   ) )
           if(  SDL_WasInit(  SDL_INIT_VIDEO )==0 ) {
           ///SDL hasn't been initilized,   we thus know that we're using the GLX platform,   and need to initialize SDL ourselves
          
           /// we start by trying to figure out what kind of resolution the user has selected,   and whether full screen should be used or not
           unsigned int height = 768,   width = 1024;
           bool fullscreen;
          
           parseWindowGeometry(  mRoot->getRenderSystem(   )->getConfigOptions(   ),   width,   height,   fullscreen );
          
           SDL_Init(  SDL_INIT_VIDEO );
          
          
          
           ///this is a failsafe which guarantees that SDL is correctly shut down (  returning the screen to correct resolution,   releasing mouse etc. ) if there's a crash.
           atexit(  SDL_Quit );
           signal(  SIGSEGV,   shutdownHandler );
           signal(  SIGABRT,   shutdownHandler );
           signal(  SIGBUS,   shutdownHandler );
           signal(  SIGILL,   shutdownHandler );
          
          
           ///set the window size
          // int flags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE | SDL_HWSURFACE;
           int flags = SDL_HWPALETTE | SDL_HWSURFACE;
          
          // SDL_GL_SetAttribute(   SDL_GL_DOUBLEBUFFER,   1  );
           // request good stencil size if 32-bit colour
          /* if (  colourDepth == 32 )
           {
           SDL_GL_SetAttribute(   SDL_GL_STENCIL_SIZE,   8 );
           }*/
          
           if (  fullscreen )
           flags |= SDL_FULLSCREEN;
          
           SDL_SetVideoMode(  width,   height,  0,   flags ); // create an SDL window
          
           SDL_WM_SetCaption(  "Ember",  "ember" );
          
           SDL_SysWMinfo info;
           SDL_VERSION(  &info.version );
          
           SDL_GetWMInfo(  &info );
          
           std::string dsp(  &(  DisplayString(  info.info.x11.display )[1] ) );
           std::vector<Ogre::String> tokens = Ogre::StringUtil::split(  dsp,   "." );
          
           Ogre::NameValuePairList misc;
           std::string s = Ogre::StringConverter::toString(  (  long )info.info.x11.display );
           s += ":" + tokens[1] +":";
           s += ":" + Ogre::StringConverter::toString(  (  long )info.info.x11.window );
           misc["parentWindowHandle"] = s;
          
           //misc["externalGLControl"] = "true";
          
          /* GLXContext glxContext(  glXGetCurrentContext(   ) );
           GLXDrawable glxDrawable(  glXGetCurrentDrawable(   ) );
           std::string glxContextString = Ogre::StringConverter::toString(  (  long )glxContext );
           glxContextString += ":" + Ogre::StringConverter::toString(  (  long )glxDrawable );
           misc["glxcontext"] = glxContextString;*/
          
           /// initialise root,   without creating a window
           mRoot->initialise(  false );
          
           mRenderWindow = mRoot->createRenderWindow(  "MainWindow",   width,   height,   true,   &misc );
          
           ///we need to set the window to be active by ourselves,   since GLX by default sets it to false,   but then activates it upon receiving some X event (  which it will never recieve since we'll use SDL ).
           ///see OgreGLXWindow.cpp
           mRenderWindow->setActive(  true );
           mRenderWindow->setAutoUpdated(  true );
          
           } else {
           mRenderWindow = mRoot->initialise(  true,   "Ember" );
           }
          
          
           ///set the icon of the window
           Uint32 rmask,   gmask,   bmask,   amask;
          
          #if SDL_BYTEORDER == SDL_BIG_ENDIAN
           rmask = 0xff000000;
           gmask = 0x00ff0000;
           bmask = 0x0000ff00;
           amask = 0x000000ff;
          #else
           rmask = 0x000000ff;
           gmask = 0x0000ff00;
           bmask = 0x00ff0000;
           amask = 0xff000000;
          #endif
          
          /**
          An bitmap of the ember icon,   to be used for setting the window icon for SDL.
          */
          static struct {
           unsigned int width;
           unsigned int height;
           unsigned int bytes_per_pixel; /* 3:RGB,   4:RGBA */
           unsigned char pixel_data[64 * 64 * 3 + 1];
          } emberIcon = {
           64,   64,   3,  
           "C+\37B )\36?&\31?'\32C+\36D-\40@(  \34='\33>(  \33C,  \40O8+YC7[F8U>1M6&F.\36E,  "
           "\35M3!R8&Q7&N3#J/\37F,  \35G*\34K.\40Q2$V7*\\<0^=2_>4_?5\\<1R2 )R2(  ]<5hIAjL"
           "BdHA_D;ZB8W@7V?7[F>bOFkYNsaUo^T`OFN>4I8.G5*?,  !7$\31:%\33D-$L2*M3*K1(  J.&N"
           "/(  U7/[<5Z<5R80N5+K1'E-\40B*\37C-\37B.\40@*\35? )\34B,  \37H1$N:-T?4M9+B,  \40"
           "<%\35>'\36C,  \37I2\"O5%R8(  S7(  R6'N3$N1#O3$S5'W8+X8.Y8.W6-T5*O/$B\"\31?\37\27"
           "F&\37Q4+S8/U;3X@7_E=aI@_I@^JB]KBaQHjZQn^UhYO_PFXI?PC8D7+:.!;-\40C2'H4*F1"
           "'A*!:#\32:#\33E,  $Q70X?7\\D<R:0U=3T<1bLCbMC_KBYE;UC8TC7SD9VE;[LCSC:I92E53"
           "G75K95L9/P;/YD9_J@^H=aI>bJ>bG<_D8aD9`C7aC8^@5Z:/Y8/Y:1_?6dF<gJ@dI@`G>^F>"
           "_G?_JAcMDdPGeTKhWNp_Wrd\\l`WeYQaWN]UJZRGZRFe]Qpf[vi`ug^jZQ\\IAP<4M:0J7.I"
           "4,  I4,  ZB7cMAzf[ye[wf\\wf[q`VhZQ[MESF=WI@VIAUHAPD;OA8SF=UG=VG<WH=ZH;fRFhRF"
           "rYLmTGfK>a@2`?0a=/f@1f<,  f=.c:,  ]3$c7+oOByXL{[NyZOwZOoRGt\\SnVL\\D:V@6R<1]"
           "I?saX\210xn\211|rwmaZSFSL@UPD_[Orm_|vi\177uj\202vk\201sj\201pg\200qfyi_h"
           "XNWG=P8-V?4r^UmZOveZxk_tg\\naXXLDI<5F:3J@9KA:MC;E:2L@9SG@PC9A1'Q<0Y?3fH;"
           "nOBrPBrOBnI8zVEuK7uH2wB+wB*u8!\243\32\24\240!\23\235\30\23r@-pI9g?1hB5lH"
           ";}_T\177cXeF:U8*K/#H.\"L5 )XB7`LBTH>D;2=7-<8.=9/EB6HB7KB8UJAbTLqd\\\177rh"
           "\203umzmdpcZF3 )@-$aQJUE=`QHl`Ti\\S_RIF:3;/(  LB;\\TMaZStngNG@D;4G<7>1,  7\"\32"
           "D*\36X:,  mOB{\\OsPArL;qJ7pD/o?'v@%u7\32u0\20\1772\22\262\17\4\260\30\3\200"
           "'\11z/\20s/\23m3\35d.\31d5\40mF4\177cSxYLiL@M0$C'\32;!\26@*!A,  \";*\":,  #<"
           "1(  3+\"/%\34:0&5+$,  $\37 )#\40'\36\32 )\35\25:.%I=6H<4MA8\36\21\15\27\14\12A"
           "857-%8.%K@8PC<:*&'\31\25\33\22\17\34\24\20""61*65-64.'$\37C<53&\40*\32\24"
           "= )\"F1'O5%X;*`?.iA.r@+|G.\205K1\217P2\226O/\226H\"\225?\21\232A\21\316\5"
           "\1\316\14\1\243C\26\240M\"\230B\30\220>\27\206>\34\202H+\204V;\204^G\177"
           "YHxSEkG:Y9+J,  \40P5*H.&@ )\";'!7%\35""4#\33,  \35\27#\27\22!\24\17\30\17\15\25"
           "\20\17\22\14\13\31\17\11+!\31;3+1 )\40*#\33\30\20\16\23\15\12<74+%\40\34\26"
           "\21\34\23\20(  \33\30""6%\".\36\33*\37\34""92,  _\\SLLBGF<DB63 )\37C3*ZB:sZR\220"
           "~uiJ:iC/nB-wE0\206Q:\233fL\243eF\242Q,  \250M\36\251C\17\261G\17\276=\21\351"
           "%\5\3475\10\301G$\260`9\255fC\237U3\220G&\206D&\210Q9\204S>\200UBvL;]3!X"
           "2#]=0eF:X:/U<3R;5S>7J73@/*T>9N:4<+#.\40\31!\31\23%\37\33(  $!-(  %\33\27\24\17"
           "\14\12\"\35\30\35\27\22C>972. )$\40,  %#4+(  5-+60-72/KFBRMH@93<5-:0'8'\34<'\35"
           "I1%I*\33T0\37U+\30i8!{F.\212V=\236iO\251lN\246Z4\245H\27\262O\31\276T\35"
           "\305R\31\3378\24\376O\0\376m\0\355=\"\332\205Y\323\203]\302lB\263_:\245X"
           "5\226N.\213L.\211ZB\204[FpI5c= )eA1`@0O1!G,  !J1 )='\40""0\37\31""6\"\34B+$D"
           ",  &;'!/\37\27,  #\36.'#1+(  /,  *\31\27\25\15\13\10\10\4\3\13\10\10""6/-6/,  FA<]"
           "WQ]VRQLIMKFIFBNGBJ?:?/ )A/(  I1(  M2%V</P6%cD/fA )l@%uC(  \212W9\222Y:\234Z7\240"
           "P'\245H\30\262M\27\277U\35\314b+\325g/\354?\37\376_\0\376\261\0\376\5\0\342"
           "s5\331n5\322p>\317\200Z\304zR\271rK\255kD\244kL\250\200j\240ze\205_G\204"
           "cNyXCkL7oTEs^PcPEWG<UD;L;0R@3O=1K;3XJA^QHvh`}tl^VN>7/2. )-*&D?<@:5TNIVOI0"
           "(  #'\40\32;/&WI=bN@P9+O6(  Q6&Q5'U?3fQC\\D4t[IoK4{O6\214_F\217Y=\244mO\244^"
           ";\256^7\270_4\306g8\323uD\334vC\346\200L\364=\40\376k\0\376\326\0\376D\0"
           "\364E\40\346s9\336uB\320f2\313sG\301qC\262c9\247a@\225R4\214P5\204Q6\200"
           "S:jA*^:#G*\30C.\37G8*H?5JF=<8-A=.C?/A;1LF=G?7WNFhaXQLBFA8841 )%!:53=74^XT"
           "mfaQIC<2+A4 )WF8U<*U: )W:*]>._@1cJ>ycWhQAfJ9nG3tB )\217[>\214K )\236X5\245Q )"
           "\264Z.\307nB\323wI\333q>\345r;\357s3\3720\22\376y\0\376\326\0\376\263\0\376"
           "\22\0\365o<\353{E\341zH\325qA\306b,  \277k=\261gB\252nP\225Y:\234lO\225jL\200"
           "U9mC+a<%cC0`E5WA3RA6YL>J?1RG7WK>RE9UIAZOG^TM>4-2+$\37\34\30\34\31\25=:65"
           "2/D?;UOIXQKXNFXNCVH;XE6R9,  S;/gK?^D7[C6aI:pVF\225\200p\207cN\217_F\217S3\232"
           "V3\253a=\270f=\301a2\321n?\332m7\344p8\360v:\365u7\3720\23\376z\0\376\326"
           "\0\376\326\0\376y\0\3726\32\365z=\356\203R\344\204W\326r=\310h5\267d:\254"
           "fC\225Q-\220X6\211V8\206X:yL0rJ7dA1X9+P7+S?6mYL_K=UC5M:1_MCTD;]PGcYQG<49"
           "/'\22\16\14\22\16\13=9640-1,  '60*80+7/ )1,  '80 )NA6N;2P=5ZE:^E:cH:iN@oO>wR=\177"
           "M4\211N0\234[;\264tU\271jE\276^0\316g6\332k7\347vA\363\203P\365~F\364w<\371"
           "@\36\376c\0\376\326\0\376\326\0\376\320\0\3767\0\370I!\365z?\355w@\341t="
           "\321g1\300^0\263\\4\240Q+\230R+\227\\;\226fF\213_AxR9{]IxdTeUHK;0]J<gUEe"
           "SFaPDZJ?RB:^QHl_XSF?F<4\24\21\16\11\7\6""421*'%\40\34\27#\36\31*$\36'\40"
           "\35!\33\27""4*$=0'L:/Q<0Y>.sSBqP>yUB\203YB\211Y>\226^?\242b?\257hB\271g;"
           "\311sF\325zJ\337yD\351v:\364\202G\365~C\364s5\364s4\366`-\376$\0\376\311"
           "\0\376\326\0\376\326\0\376\247\0\376\4\0\366e-\366\202J\357\205P\342|F\330"
           "|J\307l:\262X'\246U )\234X.\231c=\221b@\200S6\206bI\204eO\200eSiTFq_Sxg[f"
           "VIhXM]PFVJAdUNvh`cRKZMD\15\13\11\4\4\4-,  *%\"\40#\35\32""0 )$<50C<8:2,  @4,  K"
           "=4TB7[C5lN:tP9uL4{J/\200I*\216Q-\246f@\251]2\266`1\306k8\322o:\341}G\354"
           "\200E\366\210L\366\210L\367\212Q\366\212P\367\220X\367\221[\373-\32\376\215"
           "\0\376\326\0\376\326\0\376\326\0\376t\0\3736\36\365\200G\365|@\352m0\335"
           "k2\317f-\302e1\271i:\255i<\241g>\230eA\220aB\202U:yO7jG5fK;r\\Ls_QiWJbPD"
           "aOCM=3P@7[MEI8/I8/\6\5\5\1\1\1.++#\37\36\34\27\24\33\23\20$\33\31""1'$ )\""
           "\35*\36\26:&\32I1%Q5(  eB-\200V<\216aD\223aA\227[6\236Z2\257h>\277rF\305k7"
           "\323q;\337v<\353y;\365y<\365~B\365z9\365z6\365u.\365x6\365|=\371E\"\376^"
           "\0\376\326\0\376\326\0\376\326\0\376\326\0\376Q\0\371>\34\365u5\364p/\347"
           "g(  \332j0\307Z!\275a.\262f7\245c6\234c;\215V4\200L/tF,  oG-qQ<cG4L3\"\\F8XC"
           "5RA5K:2: )!C4-,  \32\22:(  \37\26\26\25\10\10\11""965,  '%\"\31\26\"\27\22(  \33\26"
           """6 )#4(  \40""8 )\37F0!X<(  aB.wP8\213_A\215X6\230^:\242`8\250\\/\267d3\307p="
           "\324u?\337t6\353t2\366p0\376\2\0\365v4\366\177=\365{7\365x3\366~<\365t1\370"
           "M\40\376G\0\376\326\0\376\326\0\376\326\0\376\326\0\376\272\0\376\17\0\366"
           "p4\365|<\364z6\347x;\327o7\306`+\272d4\260h;\235Y/\221T1\206O/\203T7yN5m"
           "I5oP=cF2W<*^F6cOAeRDcPDcSJVC9lYO\23\23\22\25\26\26PLLE?=0%!&\31\24 )\32\24"
           """4%\36""5'\35""5$\32F,  \33Z:%kG/\177S7\225bA\220R+\234X-\261l?\275qC\306"
           "o;\323t<\335q2\352u0\370d0\376\22\0\376\7\0\366x1\366}5\365p(  \364i\36\365"
           "y6\365|=\370U%\376=\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376"
           "?\0\370T&\365q,  \365x3\361s0\342o1\323k2\304g4\264b0\241T'\227U2\207H'y@\37"
           "r@\"qF+gA'bA+Y=-Z?.dK:r\\Lp\\P\\JA.\31\20""3\36\25\10\12\11\3\4\4?<=D>=9"
           "/.7-+>3/@3/D4-F0&R8 )W4!`4\34p9\36\212M-\231V1\242U,  \253S%\301i:\322{I\332"
           "o5\347s6\370d5\3762\0\376\36\0\366`\"\365p )\364o'\364l$\364l$\364j!\364l"
           "$\370H\32\376K\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376^\0"
           "\370=\25\364d\33\364l%\365v3\354e\40\332^\36\312`&\266S\37\237F\30\237X/"
           "\221R,  \200I'tD&c7\33`8\37U2\35V9'J/\40K3%fPC{f[\200meR;0:\"\31%''003[Y]M"
           "LN.-/\35\35\36\"\40\40/*(  8- )?0'D-#C$\26L\"\17^ )\21p.\17\1770\14\226@\30\246"
           "B\24\270G\24\313Q\31\336Y\33\365B\26\376 )\0\376|\0\376\3\0\362X\23\362V\20"
           "\362V\17\362W\20\362W\21\362U\15\362S\10\370 )\5\376n\0\376\326\0\376\326"
           "\0\376\326\0\376\326\0\376\326\0\376[\0\3672\11\362T\13\362T\13\362W\21\363"
           "\\\25\343S\20\314H\13\266E\20\242>\17\221>\26\200:\27r8\31a1\25P$\14F#\17"
           """5\27\10$\17\3\32\13\3\31\13\5\"\24\15K;4o^WM5-'\17\6\25\25\26\26\26\30"
           "GFJA@A122(  (  &(  &$-(  %0(  \37""3#\31""9\"\25G%\23X+\23i3\25{5\20\214=\23\235?\20"
           "\257B\16\306Q\30\333^!\357i,  \373\33\12\376\236\0\376\210\0\372\"\10\362^"
           "\30\362\\\27\362^\33\363b\40\363b\40\363`\37\366?\22\376\24\0\376\270\0\376"
           "\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376E\0\367A\24\363_\34\362"
           "^\32\363]\34\364b$\363m-\340f-\314]*\271Y-\244L%\222D\40\207C#y>$n=(  `;(  V"
           ":,  P7,  G2 )6%\35,  \34\25F4,  iWMS8.B&\35\12\11\14\1\1\1,  '(   )##0(  %9-&:-&?.$J4%Z;"
           "(  Z5\37g:!zA$\221Q-\243W*\261]+\272T\34\314]\40\335e#\354e!\371E\35\376;\0"
           "\376\326\0\376\221\0\373\40\11\365j%\365j$\364h$\364l*\364j'\366U\35\376"
           "\17\0\376\235\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\317"
           "\0\376#\0\366^%\364h\37\364c\32\376\11\0\376\17\0\366f%\360m*\336_\40\317"
           "]%\274S\37\247@\24\237A\30\224?\33\211?\40\204F,  w@,  i3\35f8%W0\40D#\26D(  \37"
           "P943\33\30""0\33\30\25\26\30\10\12\12""3-++\40\35 )\32\25""4\"\33@ )\40J-\40"
           "T1\37i<%\200L1\212N.\231W0\246[6\257Z1\303f3\321o7\335s8\353w6\366o,  \376"
           "\11\0\376\254\0\376\326\0\376\270\0\376\13\0\365k,  \365o )\365o-\365r0\365"
           "h!\372(  \11\376\200\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376"
           "\326\0\376\256\0\376\10\0\365d\40\366o(  \371A\24\376E\0\376\30\0\366X\27\365"
           "g!\354f\40\333\\\32\311V\36\274R!\254H\34\236C\31\223C!\212?\37\207A$\177"
           ">%f,  \33T#\21M#\25H(  \37D*&\25\1\1\16\0\0\17\21\20\25\26\25""941/$\37'\31\23"
           "/\36\26""8\37\25?\40\25M(  \33h:$tB+\203E%\222L&\243R )\264Z,  \312n:\325o7\341"
           "i )\362r1\371F!\376X\0\376\326\0\376\326\0\376\323\0\3763\0\367[,  \365s2\365"
           "w9\365u7\367Z$\376+\0\376\320\0\376\326\0\376\326\0\376\326\0\376\326\0\376"
           "\326\0\376\326\0\376t\0\3725\25\365p )\366]\31\376\27\0\376\256\0\376!\0\366"
           "^&\365q/\365m'\342b!\322`'\301\\(  \252L\37\231B\32\217C\34\207A\37w6\32n4"
           "\34h7#Y1!_>0eL@^I@5\36\23""0\31\14\0\0\0\1\1\1+&$(  \35\30/#\31> )\36E )\31I"
           "+\32^8$sA'\177D$\215P.\235R(  \255Z*\277d0\315h/\337w;\360\203G\366{<\376\10"
           "\0\376\257\0\376\326\0\376\326\0\376\326\0\376d\0\371@\36\365p.\366z<\366"
           "\200E\3736\35\376}\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376"
           "\326\0\376\322\0\376-\0\370^(  \366w3\372@\35\376g\0\376\326\0\376u\0\3735"
           "\33\366z:\365l&\354h$\337t<\317l;\273[,  \255W.\224D\33\204@\31\200F#xF )wN"
           "7vT@~cS~k`qbZPC9N?7\2\2\0\1\1\1*&&$\32\27\36\21\15(  \26\17""7\34\23E%\27e"
           "8\37xB%\203K*\220I\"\240N\40\257R\37\274R\33\320[\37\343g#\364k#\367A\15"
           "\376H\0\376\326\0\376\326\0\376\326\0\376\326\0\376\207\0\372#\12\364`\32"
           "\364c\34\366_\37\376\23\0\376\300\0\376\326\0\376\326\0\376\326\0\376\326"
           "\0\376\326\0\376\326\0\376\214\0\376\1\0\365j\"\365`\35\376\15\0\376\270"
           "\0\376\326\0\376\322\0\376U\0\371-\14\365i\"\364h\36\344a\34\322Z\35\273"
           "H\20\255L\34\231B\27\207=\24u2\15e*\13h8\35c>'\\A0|i\\\236\222\207\222\205"
           "}dWM\4\3\0\1\1\1.* )!\32\27\33\20\15%\25\17>'\36R7*oI5rA(  }=\37\231P-\253X"
           ".\271[+\306[%\332i )\353g\40\365s.\3731\30\376\203\0\376\326\0\376\326\0\376"
           "\326\0\376\326\0\376\223\0\373!\12\364j#\365l'\367G\30\376F\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\317\0\376+\0\366I\21\365"
           "j\37\370T\35\3768\0\376\326\0\376\326\0\376\326\0\376\316\0\3763\0\371>\30"
           "\365k$\356b\31\333]\34\312\\#\266O\35\245M\40\226N&\206G$}G+pB(  M(  \23A%\25"
           "XE6seY`REL<.\26\22\12\5\4\2""2-+'\34\31-\33\23""5!\26J+\36Y8 )jC.u<!\211D"
           "!\237X2\262b9\303l>\317e/\341m0\363o*\364a\27\376\3\0\376\241\0\376\326\0"
           "\376\326\0\376\326\0\376\326\0\376\244\0\374\31\10\367Z\37\367h*\3728\30"
           "\376n\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\233"
           "\0\374\36\14\376\3\0\366T\30\370F\27\376L\0\376\326\0\376\326\0\376\326\0"
           "\376\326\0\376\266\0\376\26\0\367U\40\366w3\345i(  \324c )\301\\ )\261[0\241"
           "Z3\222T1\206Q1\201V=rR>mSBfRCN=2\31\11\5\20\6\5\21\16\7\26\20\12C;6:,  $<'"
           "\35C+\37P/\37a6#n?'\203C!\225M$\244S )\262W(  \305c/\324b'\345]\25\365i\34\364"
           "^\23\376\3\0\376\247\0\376\326\0\376\326\0\376\326\0\376\326\0\376\316\0"
           "\376S\0\376+\0\376\24\0\373,  \21\376\203\0\376\326\0\376\326\0\376\326\0\376"
           "\326\0\376\326\0\376\322\0\376:\0\371N\37\376#\0\376'\0\370O\35\376>\0\376"
           "\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\211\0\376\1\0\366u3\355"
           "h#\332b$\314g3\263V'\245\\4\214H$}@\40|K3uR?nRCiSDbOC6$\32\"\22\12\2\1\1"
           "\25\15\11E837%\35-\34\24""4\37\26<\35\21N\37\14d*\16{5\23\215>\24\233?\23"
           "\261J\27\300K\20\330[\33\355`\27\363U\11\363[\17\373!\10\376\214\0\376\326"
           "\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\303\0\376\35\0\373"
           "!\13\376\224\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376s\0\372"
           " )\10\365c\40\376\13\0\376\203\0\376\23\0\376\15\0\376\267\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\376\326\0\376E\0\371D\31\365x5\337a!\313^%\260"
           "I\26\240H\33\222F\36}8\25t9\33U.\33U7'mWI\213yl\205p_nVD\0\0\0\2\2\2""0+"
           "*#\30\24$\25\20""1\35\25>!\26V*\30o3\27\200;\30\220C\34\242G\33\267P\36\314"
           "[$\335[\31\362Z\16\364g\36\364f\36\367@\14\376E\0\376\326\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\376\326\0\376\272\0\376\13\0\373\35\11\376\231"
           "\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376P\0\373#\10\372 )"
           "\10\376\5\0\376\266\0\376p\0\3712\21\376C\0\376\322\0\376\326\0\376\326\0"
           "\376\326\0\376\326\0\376\257\0\376\13\0\366w9\350t8\325k2\301a-\260\\/\237"
           "S+\217L*\177C'h;$aA-v^O\213zm\217|n\213uf\22\15\12\15\13\14;65-#!'\27\21"
           "+\23\13""7\30\13S&\22v9\32\206?\33\222>\27\244D\31\273O\32\322`&\345d\37"
           "\364f\35\364d\34\364h\40\364f\40\373\"\12\376\217\0\376\326\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\376\306\0\376\24\0\373!\14\376\224\0\376\326\0"
           "\376\326\0\376\326\0\376\326\0\376\326\0\376\312\0\376\210\0\376x\0\376\241"
           "\0\376\326\0\376\270\0\376\14\0\373*\22\376\210\0\376\326\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\376?\0\370Q\"\360\177E\331d )\311g4\274lB\245^"
           "7\215K(  \211Q2yL4kL9YE7`QFYJ<lZLF;6XMH\207{vsaZC.&2\32\20""8\33\15H\37\15"
           "a$\11\204:\24\227E\33\260S#\302W\34\321Q\23\350^\30\365p(  \365q-\370L\33\376"
           "\7\0\376\23\0\376\23\0\376\245\0\376\326\0\376\326\0\376\326\0\376\326\0"
           "\376\325\0\376J\0\371+\12\376u\0\376\326\0\376\326\0\376\326\0\376\326\0"
           "\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\303\0\376"
           "\23\0\371B\32\376Z\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376"
           "a\0\3719\21\363j&\337g,  \316i9\274e:\245V0\223P.\177B%h:$M0#0$\36""3,  (  .\""
           "\30UF;\27\17\13""8+$od_hWP]H>^E:hI9`7#`(  \17\2004\21\2178\17\250C\23\301O"
           "\30\327X\31\354Z\17\364^\21\367E\21\376\15\0\376\230\0\376c\0\3719\22\376"
           "\31\0\376\303\0\376\326\0\376\326\0\376\326\0\376\326\0\376\273\0\376\27"
           "\0\376\24\0\376\276\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\376\313\0\376H\0\371;\32\373.\26\376\206\0\376"
           "\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376C\0\367L\33\365s.\341d"
           "$\311Z$\273b6\250Z4\234Z:\221]C{Q<cE5;,  &*&$%\33\25aUL\0\0\0\7\6\5:42/#\37"
           ",  \34\25""0\33\23D%\31O )\30X&\17\1773\15\226@\23\253C\21\302K\24\331X\30\360"
           "]\24\366L\14\376\10\0\376\226\0\376\326\0\376\214\0\373#\11\372\"\10\376"
           "\211\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\250\0\376\27"
           "\0\375v\0\373\324\1\373\323\1\372\323\1\374\324\0\375\325\0\376\326\0\376"
           "\326\0\376\316\0\376A\0\3728\31\372,  \16\376P\0\376\322\0\376\326\0\376\326"
           "\0\376\326\0\376\326\0\376\263\0\376\15\0\365i&\365};\351z=\325o7\300d5\253"
           "Z0\234U0\213P2vI1eF5K9/:1+\33\24\16@94%\40\35\32\26\23?620!\34*\26\17""3"
           "\31\17H%\27U,  \31[ )\16y.\11\2238\12\253C\16\303L\21\334W\30\363b\32\372*\13"
           "\376z\0\376\326\0\376\326\0\376\270\0\376\13\0\3709\16\376Z\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\376\326\0\375\326\1\375\303\1\375\300\3\355\312"
           "\17\245\215!\237\200\15\334\267\3\367\317\0\373\323\0\375\325\0\376\310\0"
           "\3762\0\376-\0\376|\0\376\322\0\376\326\0\376\326\0\376\326\0\376\326\0\376"
           "\323\0\376?\0\371H$\365s/\366~>\355y:\331p6\307h3\262Z*\240Q%\214H!\200S"
           "6qN:cM@XMG\30\25\22\23\21\17;3,  -%\37F:45#\34""4\35\23I-\40Y7(  d7%j1\27{/\16"
           "\2268\15\253C\20\310M\20\336U\20\367C\17\376>\0\376\324\0\376\326\0\376\326"
           "\0\376\321\0\376*\0\370D\26\376L\0\376\326\0\376\326\0\376\326\0\375\325"
           "\0\376\326\1\376\326\0\375\326\6\352\314.\263\246l569#\40\40; )\1\224v\1\333"
           "\266\0\366\317\0\373\323\0\375\317\0\376\322\0\376\326\0\376\326\0\376\326"
           "\0\376\326\0\376\326\0\376\326\0\376g\0\3724\30\366\200B\365s/\365w3\357"
           "s/\330c$\312j3\267`-\245W*\223P*\201Q5nH1r]Opf_\"\37\33\0\0\0\36\31\23\33"
           "\25\17=502\"\33,  \30\17>'\34T7 )f?-u>'\212F )\250Q,  \265U*\312X\"\336W\26\373"
           "\40\12\376\223\0\376\326\0\376\326\0\376\326\0\376\326\0\376=\0\3729\32\376"
           "n\0\376\326\0\375\325\0\375\326\0\376\326\0\376\326\0\370\323\17\347\316"
           "H\341\327\250mkd\3\3\0'(  *\0\1\3\5\2\0<+\0\224v\0\332\265\0\366\317\0\372"
           "\323\0\375\325\0\376\326\0\376\326\0\376\326\0\376\326\0\376\207\0\376\1"
           "\0\365_\34\366z7\366~=\366z6\361u2\336j*\312b'\273b.\254].\226R+\200N0yU"
           "?\202l_\211~wQMI\"!\37\2\1\0\11\7\2.*&\40\27\21\37\20\11,  \27\15""8\35\20"
           "C\40\21` )\20v1\21\2319\16\260F\24\304Y!\340e&\374\25\10\376\256\0\376\326"
           "\0\376\326\0\376\326\0\376\326\0\376\200\0\376K\0\375\302\0\375\325\0\376"
           "\326\0\376\326\0\373\324\5\356\314\33\347\317Y\357\342\251\263\255\226\25"
           "\23\12\1\1\0!!#\21\22\22\0\0\0\0\0\0\6\2\0<*\0\230z\0\335\270\0\370\320\0"
           "\373\323\0\375\325\0\376\326\0\376\271\0\376\20\0\370['\365l\"\365d\36\366"
           "p.\366s+\363u.\341o.\316h,  \276b.\254Z )\227P%}H )wS;\210qa\227\213\202uniP"
           "NJ\26\24\13\30\30\20""62+&\35\26\"\26\14(  \30\14-\27\12""7\27\10V!\10p.\16"
           "\2165\13\2479\10\272C\16\330P\20\371#\7\376\206\0\376\326\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\375\325\0\376\326\0\376\326\0\367\321\7\347\305"
           "\26\337\3039\352\325s\355\337\246\220\204yGD9\4\3\0\0\0\0\16\16\16##%\0\0"
           "\0\0\0\0\0\0\0\0\0\0\5\2\0>-\0\230{\0\336\271\0\371\321\0\373\324\0\375\211"
           "\0\373%\14\365j#\371M\36\376\14\0\376\15\0\366s1\365{6\343u5\321n2\301h0"
           "\261b0\234X+xG&kF.u^N{mdME>1+%CC934+C@:3+$2'\35""6(  \35<(  \32D )\33]2\35t;\37"
           "\206<\31\251D\24\277N\30\322V\32\361K\22\376\34\0\376\262\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\375\325\0\366\316\4\335\272\21\312\260;\332\307"
           "y\346\327\236\343\327\265\32\22\21\203\200\177\6\5\0\1\1\0\0\0\0\2\2\2''"
           " )\6\6\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0<-\0\246\210\7\360\312\3\375\300"
           "\0\3765\0\376\7\0\376I\0\376\203\0\376A\0\370R\35\364u )\341l&\317f'\272U"
           "\32\257Z'\235W+o;\35_9\"[B1VF<\37\25\14\22\7\1KKA[[Snmea[QRF<A1&6\"\25""7"
           "\36\20Q+\30o:!\204A\40\240A\23\273G\20\313M\20\351^\27\3707\13\376\36\0\376"
           "\231\0\376\326\0\376\326\0\376\326\0\374\324\1\307\245\21\221\201:\245\233"
           "o\264\253\222\302\274\263\252\244\252\253\251\270\36\34\34\1\1\0\0\0\0\0"
           "\0\0\0\0\0\34\34\35\30\30\31\0\0\0\0\0\0\0\0\0\0\0\0\5\5\5\13\14\15\34\34"
           "\36ME/\342\277\10\376\326\0\376\315\0\376\271\0\376\311\0\376>\0\376I\0\371"
           "L\32\362o\"\336`\30\314]\36\275Z\"\252L\30\231M#xD*\\2\35K/\37E5+\"\32\20"
           "/&\36\33\34\23\32\32\25""52/4/'?5 )O?2J4%J0!eB0s?&~<\35\217:\21\262D\20\311"
           "U\35\342_\35\364`\24\367>\10\376\2\0\376C\0\376\246\0\376\326\0\374\324\0"
           "\305\245\10""91\10""0,  \30;8.GEDfenPPY\17\17\17\6\6\7\2\2\2\0\0\0\0\0\0\12"
           "\12\13,  ,  .\17\17\20\26\26\27\33\33\35\35\36\37\35\35\37\34\34\36\22\22\24"
           "i[\13\362\315\2\375\325\0\376\326\0\376\257\0\376,  \0\373:\27\376c\0\372="
           "\23\361p#\337j&\320e,  \300\\'\266^/\235S.\206W>\201ZDfM@N?80(  \"PGB87*47.:"
           "83+&\35.$\31""7(  \35= )\36""8!\23N.\36e8\"t8\32\2007\24\251K\34\304O\24\327"
           "V\25\362k#\365b\27\365h\35\370A\21\376\12\0\376\237\0\373\324\0\346\302\2"
           "O@\1\2\2\0\4\3\0\2\2\1\4\4\4\33\33\34++.(  (  *$$%\40\40!\36\36\40'' )DDH//1\40"
           "\40\"\16\16\17\7\7\7\1\1\1\0\0\0\1\1\0\245\213\4\371\322\0\375\325\0\376"
           "\314\0\376#\0\371E\31\376\11\0\376\201\0\373,  \15\356q&\335m+\313^$\272V!"
           "\263\\.\231T1o?'iE2H2(  9.*\14\11\10\34\33\31(  %\35""53(  B<53*!1%\35/\40\27""8"
           "#\32@(  \33P1#]1\36u:!\205A\"\243L#\300Q\31\321\\\36\350d\37\365k\"\365k\36"
           "\365o$\371<\21\376c\0\374\324\4\334\274\26w_\6\10\4\0\0\0\0\0\0\0\0\0\0\0"
           "\0\0\0\0\0\2\2\2\4\4\5\6\6\6\7\7\10\20\20\20**-\0\0\0\0\0\0\0\0\0\0\0\0\0"
           "\0\0\0\0\0(  \40\0\327\265\0\373\323\0\376\326\0\376\316\0\376<\0\373'\15\376"
           "C\0\376\222\0\373%\15\352p(  \333p0\312h/\275e3\263e6\227X3h>%]<(  R?4QGB\35"
           "\33\32\17\17\16\25\16\13\33\22\13""8.(  6+#B3,  Q@7cNDoSFrQAoC0|F.\212M0\237"
           "R-\272S!\315a*\340f%\364z6\365n$\365k\40\365<\24\355|3\350\323g\213|*?7\13"
           "\22\13\0\17\6\0\6\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\27\27\30"
           "\34\34\35\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0v`\0\363\315\0\375\325\0\376"
           "\326\0\376\326\0\376\311\0\376\215\0\376\303\0\376s\0\3728\25\346r.\324j"
           "*\306g0\265^+\260d9\217P-kB )`@.\\I?VNI$!\37\23\21\20I>7C82MD>F:4D7/SB8r\\"
           "R|_S}ZLqD2l6\37w8\33\211E%\245F\30\311f2\330p9\350n0\356l*\320zP\304\207"
           "\220qg_\227\221z'!\0,  (  \26\7\7\4\0\0\0\10\3\0\13\3\0\3\1\1\0\0\0\0\0\0\0\0"
           "\0\0\0\0\0\0\0$$%\14\14\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\34\22\4\275\233"
           "\1\372\323\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0"
           "\376,  \0\363b+\341x:\323r9\307o?\270e9\253_8\213N/a:%O0!<,  $4.,  \17\17\16\16"
           "\16\15RD>WICgZUXHC?.':&\35P7.hK@zWJ\200VFzE0\177B(  \204C%\226B\30\271U%\311"
           "e3\331d )\224Z:\200\177\217\277\277\337\265\263\313\40\37\32\11\10\0\22\21"
           "\17\17\17\16\2\2\2\4\5\5\11\11\12\37\32\31\7\6\6\0\0\0\0\0\0\0\0\0\5\5\5"
           "(  (   )\3\3\3\0\0\0\1\1\1\7\6\6\34\33\36VV[\217\210xK>\30\261\217\1\376\326\0"
           "\376\326\0\376\326\0\376\326\0\376\307\0\376d\0\3730\21\347t0\332r5\312h"
           "/\273_.\255Z-\237S )\211O1X0\33B&\26J8/`WRROLIFC\32\12\7(  \31\23L<:J82:%\37"
           """5\37\30A&\37S4 )c@4pE7vD/zA'\201@\40\220E\40\252G\26\301R\35\326d,  \177A"
           "!\16\16\17$$(   ) )/\17\17\20\21\21\22\27\27\31'' )\21\21\22\22\22\22\16\16\17"
           "\12\12\12\1\1\1\0\0\0\0\0\0\0\0\0\20\20\21\"\"#\0\0\0\0\0\0\10\6\5%#'st\205"
           "\273\272\323769\0\1\2\14\14\14jP\0\366\203\0\376r\0\376U\0\376\35\0\3727"
           "\23\356i#\337n-\320j.\302c,  \265]-\240N\"\225K#\207K+^5!;\37\22/\40\30""9"
           "0+#\37\32\40\36\31\35\14\10\26\6\2<,  (  F2.E/*K4,  V:0X7+\\:-f=,  j<'q:!\205E&\231"
           "V2\251U )\275X$\311Q\27\305X\35\40\13\2\0\0\0\0\0\0\4\4\4\5\5\5\16\17\17\31"
           "\31\32\1\1\1\0\0\0\0\0\0\10\3\0\4\1\0\4\1\0\0\0\0\0\0\0$$&\22\22\24\0\0\0"
           "\5\1\0\11\1\0\22\12\2,  (  !PLJ\25\24\20\11\11\10\23\24\25\5\5\5I\16\5\3232\24"
           "\371?\16\366\\\27\361p$\342f\37\323a\37\305_$\262O\31\260\\/\234Q'\210?\32"
           "\200G )pF1W<0\\KCjb\\he_mlfE6/>0*UEAQ>:@*$3\34\24""7\33\23@!\26R1#a: )c7#h"
           "7\40w?\"\216Q0\242\\3\270b0\307b*\324a\"\1779\21\1\1\0\0\0\0\0\0\0\0\0\0"
           "\23\23\24\11\11\11\0\0\0\0\0\0\35\22\0\241\201\0\234}\0\207j\1oY\2fR\3j["
           "\20iU\10sZ\3\216l\1\251\204\0\233|\0&\40\0\15\13\0\6\6\4\11\11\12\36\37\40"
           "\21\21\22\11\12\13\222E\30\365q$\362g\32\343_\26\322R\14\302L\11\272W\36"
           "\252M\33\234D\27\216C\32}8\23t;\36rJ7\202h\\\211zq\213\202~{wszxr;,  %:-'I"
           ";6B2+B-&@(  !9\33\23<\33\20L,  \37c?.g=+f7!l6\33\200B\"\222L'\247R&\272T\37\305"
           "O\26\277R\31*\21\3\1\0\0\0\0\0\1\1\2\30\31\32\2\3\3\1\0\0\3\1\0\205d\0\373"
           "\323\0\372\322\0\370\320\0\365\316\0\362\314\1\361\313\1\362\314\1\365\316"
           "\0\370\320\0\373\323\0\363\313\0XB\0\0\0\0\0\0\0\0\0\0\21\21\22\1\2\2\0\0"
           "\0\255E\17\362b\27\346h%\326X\25\307Q\21\272P\25\256M\31\235E\30\232N#\217"
           "J(  q3\30l3\34`8 )jNAkZQ`WP51+(  %\40>/*D72L@9M>7bNFpZQmSHpSG{]R}[LsL:j>*s@(  \200"
           "D%\207E#\235P'\267^/\275S\32\314[\36\263R\35\212<\21y5\21e\32\14g\36\17o"
           "I\2\220n\0\266\224\0\361\312\0\376\326\0\376\326\0\376\326\0\376\326\0\376"
           "\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\314\246"
           "\0WF\0-!\0\25\20\4\33\25\24\20\5\2""6\23\3\332V\21\345a\33\326U\22\313V\26"
           "\272H\14\263O\33\243F\24\224>\21\2068\16\177;\30n1\26c-\27I$\24K0%ZI?jbY"
           "LHA;81OD=ND=LA<G95TE=cQJgSHkSGqYLtTDqM<g<(  p>&}F )\206J*\224O )\256[/\264S\40"
           "\301Y!\315\\\35\332a\34\347i\40\363p%\371?\24\376\31\0\376\210\0\376\316"
           "\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0"
           "\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\326\0\376\316\0\361"
           "\236\0\337D\1\317%\13\324W\25\342Y\21\341V\16\327\\\32\310R\22\275P\26\261"
           "K\25\243C\20\233E\27\234P(  \213B\36w6\27g,  \23`-\31I$\26C(  \34ZI?ypgqoehg]1"
           " )!%\35\26/#\37&\32\30+\37\32&\33\25""0\"\32A,  #>(  \37O0#c=+mE0xG/\200H*\211"
           "N.\224Q-\243T,  \256V )\271Y'\301V\34\320b&\331a\40\345j&\357l#\370Q\24\373"
           "(  \14\376%\0\376Y\0\376}\0\376\225\0\376\246\0\376\257\0\376\263\0\376\263"
           "\0\376\260\0\376\251\0\376\231\0\376\206\0\376o\0\376N\0\376#\0\376\4\0\370"
           ">\16\364`\25\352^\24\337X\23\320K\15\310O\23\275L\26\262G\25\251H\32\234"
           "A\27\235J(  \221C\"\1778\34u4\32g-\27U%\24A\36\22""4\30\16""4!\32:1,  &$\34&"
           "%\32\10\3\1\26\11\4""7,  %?3,  L<4?0 )0\40\26""3\34\20/\26\13<\37\22U.\34Y/\33"
           "k9\"v<!~>\37\205?\35\217A\34\231D\31\250M\37\255E\22\271G\21\306O\26\321"
           "W\31\336b\36\346e\40\355^\21\363I\12\366<\17\370-\14\372!\11\372\27\6\372"
           "\23\5\373\21\4\373\22\6\372\26\11\372\31\11\371\37\11\370*\20\3673\20\366"
           "I\35\364Z\40\363g\37\353a\34\337U\20\327U\20\312O\20\300V\40\261H\26\242"
           "9\14\234;\16\2126\16\2047\25\2014\25\2007\26l(  \15X\33\7T!\17D\33\20""0\22"
           "\13$\16\11\"\24\20#\36\34\3\2\2\0\0\0 )\36\31*\33\25""3$\36 )\27\24,  \31\25"
           ".\35\25.\34\22""1\34\21/\31\20""4\36\23<\37\21U1\40T,  \27`0\27g1\25m2\24z"
           "9\32\2009\31\215A\34\224@\21\242H\25\261V%\265Q\35\301Y\37\313`*\320[\36"
           "\324U\20\331]\26\337d\36\340d\34\341f\36\341[\21\337X\20\340i$\341f!\340"
           "e\36\341`\30\341e\36\340^\33\333[\31\326X\31\317Z\35\311V\32\303P\26\271"
           "J\25\253@\20\250F\27\235?\22\223:\23\215;\24\2020\13~5\31o+\22f+\23h.\33"
           "a*\27M\"\25@\33\22H+\40VA6fVMng_MMC79/B0,  <*&6%\"\40\16\12\31\6\3!\15\6""0"
           "\36\27""8$\33""3\40\27,  \30\17+\25\13""5\33\17""4\30\14?\37\20I%\23U-\32c"
           "6\36d2\30n6\31p1\16s.\12|3\21\2037\21\226J\36\250U'\257X )\254N\33\253J\30"
           "\260N\33\260L\31\262I\23\266I\17\275N\23\300W\36\277Y\"\274T\35\275X$\275"
           "^/\275c5\267O\34\261P\40\256X.\240G\35\233E\35\216;\21\2066\17\1772\20\200"
           "7\30\206>\37\203=\35{8\35j.\26a+\26^,  \30i4\"m=,  g=0W6*Z@6oZO\215\200u\242"
           "\234\222\220\216\203mmaC.+H30R<:C,  *7\40\33""8\40\33E/*P93W@8T<2N5*P1'K-#"
           "F(  \34T2\40oL6\202\\D\200YAyM5~L.|D${@\40y<\32\202>\32\222N(  \232M#\241P&\253"
           "Y/\260X+\261\\.\250O\40\247I\30\263V%\274e7\270c3\261Z+\261^1\262_4\260c"
           ";\247T*\240P(  \232P,  \226M+\216I*\207J/~A'w:#p3\37~C.\210P=\213XI\200OBuE7"
           "l>1rH;rL@mKBlOCgODn[P\201uh\231\223\211\243\242\226\231\231\214L40M40[@<"
           "T84G+(  D )%M3-P92S=6Q>8[G?[D=Q:3R;/YA5eK>lP?sS@uR<zT={S:wJ0sC'wB%\204Q3\207"
           "P3\207L/\220T7\225S4\223Q2\212J*\203B\"\212K+\223Y;\216V7\217[;\225cC\222"
           "]@\214\\AxJ1qE-j@*h>*mA/pC1j=,  ^2#V*\36W-\"[9/[=5]A8Z=5P4,  D,  %>(  !@,  %<+$0\""
           "\34+\37\31""6-%IE?IJDPQJ,  \36\34%\27\25""3$!,  \34\31%\26\25'\31\27""3$\40:"
           "+ );20C96SGBZNH\\OIXKFbUOcTL\\MG`NFfRFmWKoXJv_RpUGoPBsTCtTEoN@pPBnM?gH;bF"
           "9]A4X?1W=0S9+V@3\\E7ZC4O:.B1&<-%7*\"2$\35""7%\36=&\37:$\36""3!\33""1\35\30"
           "/\36\31(  \35\31#\33\27#\32\27#\33\30%\35\32(  !\35&!\35%\40\35-'%3.,  3/,  *&%\""
           "\36\34\5\4\2\7\6\5\6\4\3\7\5\4\5\3\2\10\6\5\22\20\17\34\32\31\23\22\20\23"
           "\22\22""20/0.-*'%,   )'#!\40 )'%@<:\31\26\25?<:732_XW.**D?>'%$\21\21\22 )%$:5"
           "3\31\30\27+'%\34\32\30\27\25\24\30\26\25\32\25\24\34\25\23\33\30\27\34\33"
           "\33\27\26\26\27\25\25\30\25\24\27\24\21\22\16\15\24\21\17\20\16\14\30\23"
           "\20\35\26\23\"\31\27*!\37\37\34\32\25\23\21\36\33\31#\34\30'\40\33""40-3"
           "30>?=TUSddaffbYXUgec\215\211\207\230\225\221zuqQIE>6292.(  \40\31""2 )\"3*#"
           "90*B:3G?8C:3<1+4+#1'\40;1*F;4>6/2 )\"90 )OFA\\UO[TOUOJNJEOIEVQN_[Vic^mgcle"
           "`d\\W]VPYQKWPHYOG]SMf[Th^XcYRWMGNC;F;2;1 )2 )!2'\36""9.$G9/SD;WJ@RE;K>4H=4"
           "I@6IC<MLHUXT`ebqus\200\201\200wxu__[`a\\\203\201\177\232\224\221\213\204"
           "\201sjig]\\\\SO",  
          };
          
          
          ///We'll use the emberIcon struct
           SDL_Surface * iconSurface = SDL_CreateRGBSurfaceFrom(  emberIcon.pixel_data,   64,   64,   24,   64*3,  
           rmask,   gmask,   bmask,   0 );
           if (  iconSurface ) {
           SDL_WM_SetIcon(  iconSurface,   0 );
           }
          
          
          #endif
          
           setStandardValues(   );
          
           return true;
           }
           else
           {
           return false;
           }
          }
          
     713  void OgreSetup::setStandardValues(   )
          {
           /// Set default mipmap level (  NB some APIs ignore this )
           Ogre::TextureManager::getSingleton(   ).setDefaultNumMipmaps(  5 );
          
           /// Set default animation mode
           Ogre::Animation::setDefaultInterpolationMode(  Ogre::Animation::IM_SPLINE );
          
           ///remove padding for bounding boxes
           Ogre::MeshManager::getSingletonPtr(   )->setBoundsPaddingFactor(  0 );
          
           ///all new movable objects shall by default be unpickable; it's up to the objects themselved to make themselves pickable
           Ogre::MovableObject::setDefaultQueryFlags(  0 );
          }
          
          
     729  EmberPagingSceneManager* OgreSetup::chooseSceneManager(   )
          {
           /// Create new scene manager factory
           EmberPagingSceneManagerFactory* sceneManagerFactory = new EmberPagingSceneManagerFactory(   );
          
           /// Register our factory
           Ogre::Root::getSingleton(   ).addSceneManagerFactory(  sceneManagerFactory );
          
           EmberPagingSceneManager* sceneMgr = static_cast<EmberPagingSceneManager*>(  mRoot->createSceneManager(  Ogre::ST_EXTERIOR_REAL_FAR,   "EmberPagingSceneManager" ) );
          
           ///We need to call init scene since a lot of components used by the scene manager are thus created
           sceneMgr->InitScene(   );
          
           return sceneMgr;
          }
          
     745  void OgreSetup::parseWindowGeometry(  Ogre::ConfigOptionMap& config,   unsigned int& width,   unsigned int& height,   bool& fullscreen )
          {
           Ogre::ConfigOptionMap::iterator opt = config.find(  "Video Mode" );
           if (  opt != config.end(   ) ) {
           Ogre::String val = opt->second.currentValue;
           Ogre::String::size_type pos = val.find(  'x' );
           if (  pos != Ogre::String::npos ) {
          
           width = Ogre::StringConverter::parseUnsignedInt(  val.substr(  0,   pos ) );
           height = Ogre::StringConverter::parseUnsignedInt(  val.substr(  pos + 1 ) );
           }
           }
          
           ///now on to whether we should use fullscreen
           opt = config.find(  "Full Screen" );
           if (  opt != config.end(   ) ) {
           fullscreen = (  opt->second.currentValue == "Yes" );
           }
          
          }
          
          
          }

./components/ogre/OgreSetup.h

       1  //
          // C++ Interface: OgreSetup
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREOGRESETUP_H
          #define EMBEROGREOGRESETUP_H
          
          #include "EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
      30  class EmberPagingSceneManager;
          
          /**
           A class used for setting up Ogre. Instead of creating the Ogre root object and the main render window direclty,   use this to guarantee that everything is set up correctly.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      36  class OgreSetup{
          public:
      38   OgreSetup(   );
          
      40   ~OgreSetup(   );
          
           /**
           * Creates the ogre base system.
           * @return
           */
      46   Ogre::Root* createOgreSystem(   );
          
           /**
           * Configures the application - returns false if the user chooses to abandon configuration.
           * @param
           * @return
           */
      53   bool configure(  void );
          
           /**
           * Gets the main render window.
           * @return
           */
      59   inline Ogre::RenderWindow* getRenderWindow(   ) const;
          
           /**
           * Gets the Ogre root object.
           * @return
           */
      65   inline Ogre::Root* getRoot(   ) const;
          
           /**
           * chooses and sets up the correct scene manager
           * @param
           */
      71   EmberPagingSceneManager* chooseSceneManager(   );
          
           /**
           * Shuts down the ogre system.
           */
      76   void shutdown(   );
          
          private:
          
           /**
           Holds the Ogre root object.
           */
      83   Ogre::Root* mRoot;
          
           /**
           Holds the main render window.
           */
      88   Ogre::RenderWindow* mRenderWindow;
          
          
           /**
           * Attempts to parse out the user selected geometry options for ogre.
           * @param config The option map,   usually found inside the currently selected RenderSystem.
           * @param width The width of the window in pixels.
           * @param height The height of the window in pixels.
           * @param fullscreen Whether fullscreen should be used or not.
           */
      98   void parseWindowGeometry(  Ogre::ConfigOptionMap& config,   unsigned int& width,   unsigned int& height,   bool& fullscreen );
          
           /**
           Sets standard values in the ogre environment.
           */
     103   void setStandardValues(   );
          
          };
          
     107  Ogre::Root* OgreSetup::getRoot(   ) const { return mRoot;}
     108  Ogre::RenderWindow* OgreSetup::getRenderWindow(   ) const { return mRenderWindow;}
          
          }
          
          #endif

./components/ogre/OpcodeCollisionDetector.cpp

       1  //
          // C++ Implementation: OpcodeCollisionDetector
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OpcodeCollisionDetector.h"
          #include "ogreopcode/include/OgreCollisionManager.h"
          #include "ogreopcode/include/OgreEntityCollisionShape.h"
          #include "ogreopcode/include/OgreCollisionObject.h"
          
          #include "EmberOgrePrerequisites.h"
          #include "EmberEntityUserObject.h"
          
          #include "OpcodeCollisionDetectorVisualizer.h"
          
          #include "model/Model.h"
          #include "model/SubModel.h"
          namespace EmberOgre {
          
      37  OpcodeCollisionDetector::OpcodeCollisionDetector(  Model::Model* model ) : mModel(  model ),   mVisualizer(  0 )
          {
           buildCollisionObjects(   );
          }
          
      42  OpcodeCollisionDetector::~OpcodeCollisionDetector(   )
          {
           destroyCollisionObjects(   );
          }
          
      47  void OpcodeCollisionDetector::reload(   )
          {
           destroyCollisionObjects(   );
           buildCollisionObjects(   );
          }
          
          
      54  void OpcodeCollisionDetector::destroyCollisionObjects(   )
          {
           OgreOpcode::CollisionContext* collideContext = OgreOpcode::CollisionManager::getSingletonPtr(   )->getDefaultContext(   );
           for (  OpcodeCollisionDetector::CollisionObjectStore::iterator I = mCollisionObjects.begin(   ); I != mCollisionObjects.end(   ); ++I )
           {
           OgreOpcode::ICollisionShape* shape = (  *I )->getShape(   );
           collideContext->destroyObject(  *I );
           OgreOpcode::CollisionManager::getSingleton(   ).destroyShape(  shape );
           }
           mCollisionObjects.clear(   );
          
          }
          
      67  void OpcodeCollisionDetector::buildCollisionObjects(   )
          {
           OgreOpcode::CollisionContext* collideContext = OgreOpcode::CollisionManager::getSingletonPtr(   )->getDefaultContext(   );
           const Model::Model::SubModelSet& submodels = mModel->getSubmodels(   );
           for (  Model::Model::SubModelSet::const_iterator I = submodels.begin(   ); I != submodels.end(   ); ++I )
           {
           Ogre::Entity* entity = (  *I )->getEntity(   );
          // if (  entity->isVisible(   ) ) {
           std::string collideShapeName(  std::string(  "entity_" ) + entity->getName(   ) );
           OgreOpcode::EntityCollisionShape *collideShape = OgreOpcode::CollisionManager::getSingletonPtr(   )->createEntityCollisionShape(  collideShapeName.c_str(   ) );
           // if (  !collideShape->isInitialized(   ) ) {
           collideShape->load(  entity );
           // }
           OgreOpcode::CollisionObject* collideObject = collideContext->createObject(  collideShapeName );
          
           collideObject->setShape(  collideShape );
          
           collideContext->addObject(  collideObject );
          
           mCollisionObjects.push_back(  collideObject );
          // }
          // collideObject->setDebug(  true,   false,   false,   false );
           /* collideShape->setDebug(  true );
           collideShape->visualize(   );*/
           /*
           EmberEntityUserObject* userObject = new EmberEntityUserObject(  this,   getModel(   ),   (  *I )->getEntity(   ),   0 );
           (  *I )->getEntity(   )->setUserObject(  userObject );*/
           }
          }
          
      97  void OpcodeCollisionDetector::refit(   )
          {
           for (  OpcodeCollisionDetector::CollisionObjectStore::iterator I = mCollisionObjects.begin(   ); I != mCollisionObjects.end(   ); ++I )
           {
           (  *I )->refit(   );
           }
          }
          
          
     106  void OpcodeCollisionDetector::testCollision(  Ogre::Ray& ray,   CollisionResult& result )
          {
          
           for (  OpcodeCollisionDetector::CollisionObjectStore::iterator I = mCollisionObjects.begin(   ); I != mCollisionObjects.end(   ); ++I ) {
           OgreOpcode::ICollisionShape* collisionShape = (  *I )->getShape(   );
           OgreOpcode::CollisionPair pick_result;
          
           if (  collisionShape->rayCheck(  OgreOpcode::COLLTYPE_QUICK,   mModel->_getParentNodeFullTransform(   ),   ray,   1000.0f,   pick_result,   false ) ) {
           result.collided = true;
           result.distance = pick_result.distance;
           result.position = pick_result.contact;
           return;
           }
           }
          }
          
     122  void OpcodeCollisionDetector::setVisualize(  bool visualize )
          {
           if (  visualize ) {
           if (  !mVisualizer ) {
           mVisualizer = new OpcodeCollisionDetectorVisualizerInstance(  *this );
           }
           } else {
           delete mVisualizer;
           mVisualizer = 0;
           }
          }
          
     134  bool OpcodeCollisionDetector::getVisualize(   ) const
          {
           return mVisualizer != 0;
          }
          
          
          }

./components/ogre/OpcodeCollisionDetector.h

       1  //
          // C++ Interface: OpcodeCollisionDetector
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREOPCODECOLLISIONDETECTOR_H
          #define EMBEROGREOPCODECOLLISIONDETECTOR_H
          
          #include "EmberEntityUserObject.h"
          
          namespace OgreOpcode
          {
      30   class CollisionObject;
           namespace Details
           {
      33   class OgreOpcodeDebugger;
           }
          };
          
          namespace EmberOgre {
          
      39  class OpcodeCollisionDetector;
      40  class OpcodeCollisionDetectorVisualizerInstance;
          
          namespace Model
          {
      44  class Model;
          }
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      50  class OpcodeCollisionDetector
          : public ICollisionDetector
          {
          public:
           friend class OpcodeCollisionDetectorVisualizerInstance;
          
           OpcodeCollisionDetector(  Model::Model* model );
           virtual ~OpcodeCollisionDetector(   );
          
           virtual void testCollision(  Ogre::Ray& ray,   CollisionResult& result );
           virtual void refit(   );
           /**
           * Called when the entity changes,   such as a subentity being hidden or shown. Implementations must reload the collision data.
           */
           virtual void reload(   );
          
           virtual void setVisualize(  bool visualize );
           virtual bool getVisualize(   ) const;
          private:
           typedef std::vector<OgreOpcode::CollisionObject*> CollisionObjectStore;
           void buildCollisionObjects(   );
           void destroyCollisionObjects(   );
           CollisionObjectStore mCollisionObjects;
           Model::Model* mModel;
           OpcodeCollisionDetectorVisualizerInstance* mVisualizer;
          };
          }
          
          #endif

./components/ogre/OpcodeCollisionDetectorVisualizer.cpp

       1  //
          // C++ Implementation: OpcodeCollisionDetectorVisualizer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OpcodeCollisionDetectorVisualizer.h"
          #include "ogreopcode/include/OgreOpcodeDebugObject.h"
          #include "ogreopcode/include/OgreCollisionManager.h"
          #include "ogreopcode/include/OgreEntityCollisionShape.h"
          #include "ogreopcode/include/OgreCollisionObject.h"
          #include "OpcodeCollisionDetector.h"
          
          namespace EmberOgre {
          
          template<> EmberOgre::OpcodeCollisionDetectorVisualizer* Ember::Singleton<EmberOgre::OpcodeCollisionDetectorVisualizer>::ms_Singleton = 0;
          
      34  OpcodeCollisionDetectorVisualizer::OpcodeCollisionDetectorVisualizer(   )
          {
           mOpcodeDebugger = new OgreOpcode::Details::OgreOpcodeDebugger(  "OpcodeCollisionDetectorVisualizer",   OgreOpcode::CollisionManager::getSingletonPtr(   )->getSceneManager(   ) );
          
          }
          
      40  OpcodeCollisionDetectorVisualizer::~OpcodeCollisionDetectorVisualizer(   )
          {
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
           mOpcodeDebugger->clearAll(   );
           delete mOpcodeDebugger;
          }
          
      47  bool OpcodeCollisionDetectorVisualizer::frameStarted(  const Ogre::FrameEvent& event )
          {
           mOpcodeDebugger->clearAll(   );
           for (  VisualizerInstanceStore::iterator I = mInstances.begin(   ); I != mInstances.end(   ); ++I ) {
           (  *I )->visualize(  mOpcodeDebugger );
           }
           return true;
          }
          
      56  void OpcodeCollisionDetectorVisualizer::addInstance(  OpcodeCollisionDetectorVisualizerInstance* instance )
          {
           if (  !mInstances.size(   ) ) {
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
           }
           mInstances.push_back(  instance );
          }
          
      64  void OpcodeCollisionDetectorVisualizer::removeInstance(  OpcodeCollisionDetectorVisualizerInstance* instance )
          {
           VisualizerInstanceStore::iterator I = std::find(  mInstances.begin(   ),   mInstances.end(   ),   instance );
           if (  I != mInstances.end(   ) ) {
           mInstances.erase(  I );
           }
           if (  !mInstances.size(   ) ) {
           mOpcodeDebugger->clearAll(   );
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
           }
          }
          
          
          
      78  OpcodeCollisionDetectorVisualizerInstance::OpcodeCollisionDetectorVisualizerInstance(  OpcodeCollisionDetector& detector ) : mDetector(  detector )
          {
           OpcodeCollisionDetectorVisualizer::getSingleton(   ).addInstance(  this );
          }
          
      83  OpcodeCollisionDetectorVisualizerInstance::~OpcodeCollisionDetectorVisualizerInstance(   )
          {
           for (  OpcodeCollisionDetector::CollisionObjectStore::iterator I = mDetector.mCollisionObjects.begin(   ); I != mDetector.mCollisionObjects.end(   ); ++I )
           {
           (  *I )->getShape(   )->clearViz(   );
           }
           OpcodeCollisionDetectorVisualizer::getSingleton(   ).removeInstance(  this );
          }
          
      92  void OpcodeCollisionDetectorVisualizerInstance::visualize(  OgreOpcode::Details::OgreOpcodeDebugger* debugger )
          {
           for (  OpcodeCollisionDetector::CollisionObjectStore::iterator I = mDetector.mCollisionObjects.begin(   ); I != mDetector.mCollisionObjects.end(   ); ++I )
           {
           (  *I )->getShape(   )->clearViz(   );
           (  *I )->getShape(   )->visualize(  debugger );
           }
          }
          
          
          }

./components/ogre/OpcodeCollisionDetectorVisualizer.h

       1  //
          // C++ Interface: OpcodeCollisionDetectorVisualizer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREOPCODECOLLISIONDETECTORVISUALIZER_H
          #define EMBEROGREOPCODECOLLISIONDETECTORVISUALIZER_H
          
          #include "framework/Singleton.h"
          #include <Ogre.h>
          
          namespace OgreOpcode
          {
      31   class CollisionObject;
           namespace Details
           {
      34   class OgreOpcodeDebugger;
           }
          };
          
          namespace EmberOgre {
          
      40  class OpcodeCollisionDetector;
      41  class OpcodeCollisionDetectorVisualizerInstance;
          
          /**
          Helps with visualizing the collision objects. Create and register instances of OpcodeCollisionDetectorVisualizerInstance to visualize entities.
          @see OpcodeCollisionDetectorVisualizerInstance
          */
      47  class OpcodeCollisionDetectorVisualizer : public Ember::Singleton<OpcodeCollisionDetectorVisualizer>,   public Ogre::FrameListener
          {
          public:
      50   friend class OpcodeCollisionDetectorVisualizerInstance;
           /**
           * Default ctor.
           */
      54   OpcodeCollisionDetectorVisualizer(   );
      55   virtual ~OpcodeCollisionDetectorVisualizer(   );
           /**
           * Methods from Ogre::FrameListener
           */
      59   virtual bool frameStarted(  const Ogre::FrameEvent& event );
          
           /**
           * Registers an instance of OpcodeCollisionDetectorVisualizerInstance to be rendered each frame.
           * @param instance An instance of OpcodeCollisionDetectorVisualizerInstance which in turn points to an instance of EmberPhysicalEntity.
           */
      65   void addInstance(  OpcodeCollisionDetectorVisualizerInstance* instance );
           /**
           * Removes an instance of OpcodeCollisionDetectorVisualizerInstance which will no longer be rendered each frame.
           * @param instance An instance of OpcodeCollisionDetectorVisualizerInstance which in turn points to an instance of EmberPhysicalEntity.
           */
      70   void removeInstance(  OpcodeCollisionDetectorVisualizerInstance* instance );
          protected:
           typedef std::vector<OpcodeCollisionDetectorVisualizerInstance*> VisualizerInstanceStore;
          
           /**
           * The debugger object responsible for rendering.
           */
      77   OgreOpcode::Details::OgreOpcodeDebugger* mOpcodeDebugger;
          
           /**
           * All the registered instances which will be rendered each frame.
           */
      82   VisualizerInstanceStore mInstances;
          };
          
      85  class OpcodeCollisionDetectorVisualizerInstance
          {
          public:
      88   OpcodeCollisionDetectorVisualizerInstance(  OpcodeCollisionDetector& detector );
      89   virtual ~OpcodeCollisionDetectorVisualizerInstance(   );
          
           /**
           * Called each frame by OpcodeCollisionDetectorVisualizer to let the object tell the debugger how to render this instance.
           * @param debugger
           */
      95   void visualize(  OgreOpcode::Details::OgreOpcodeDebugger* debugger );
          
          protected:
      98   OpcodeCollisionDetector& mDetector;
          };
          
          }
          
          #endif

./components/ogre/PersonEmberEntity.cpp

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "EmberEntity.h"
          #include "EmberPhysicalEntity.h"
          #include "model/Model.h"
          
          // #include "PersonEmberEntity.h"
          namespace EmberOgre {
          
      26  PersonEmberEntity::PersonEmberEntity(  const std::string& id,   Eris::TypeInfo* ty,   Eris::View* vw,   Ogre::SceneManager* sceneManager,   Ogre::SceneNode* nodeWithModel ) :
          EmberPhysicalEntity(  id,   ty,   vw,   sceneManager,   nodeWithModel )
          
          {
          }
          
      32  PersonEmberEntity::~PersonEmberEntity(   )
          {}
          
      35  void PersonEmberEntity::init(  const Atlas::Objects::Entity::RootEntity &ge )
          {
           EmberPhysicalEntity::init(  ge );
          // mModel->setQueryFlags(  EmberEntity::CM_PERSONS );
          }
          
      41  bool PersonEmberEntity::allowVisibilityOfMember(  EmberEntity* entity )
          {
           return false;
          }
          }

./components/ogre/PersonEmberEntity.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef PERSONDIMEENTITY_H
          #define PERSONDIMEENTITY_H
          #include "EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
      25  class EmberPhysicalEntity;
      26  class PersonEmberEntity : public EmberPhysicalEntity {
          public:
          
      29   PersonEmberEntity(  const std::string& id,   Eris::TypeInfo* ty,   Eris::View* vw,   Ogre::SceneManager* sceneManager,   Ogre::SceneNode* nodeWithModel );
      30   virtual ~PersonEmberEntity(   );
          
      32   virtual bool allowVisibilityOfMember(  EmberEntity* entity );
          
          protected:
      35   virtual void init(  const Atlas::Objects::Entity::RootEntity &ge );
          
          
          };
          
          }
          #endif // PERSONDIMEENTITY_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/DRGNURBSSurface.h

       1  // DRGNURBSSurface.h: interface for the CDRGNURBSSurface class.
          // ------------------------------------------------------------------------------------
          // Copyright © 1999 Intel Corporation
          // All Rights Reserved
          //
          // Permission is granted to use,   copy,   distribute and prepare derivative works of this
          // software for any purpose and without fee,   provided,   that the above copyright notice
          // and this statement appear in all copies. Intel makes no representations about the
          // suitability of this software for any purpose. This software is provided "AS IS."
          //
          // Intel specifically disclaims all warranties,   express or implied,   and all liability,  
          // including consequential and other indirect damages,   for the use of this software,  
          // including liability for infringement of any proprietary rights,   and including the
          // warranties of merchantability and fitness for a particular purpose. Intel does not
          // assume any responsibility for any errors which may appear in this software nor any
          // responsibility to update it.
          // ------------------------------------------------------------------------------------
          //
          // PURPOSE:
          //
          // Declaration of the CDRGNURBSSurface class for rendering NURBS surfaces.
          // Accompanies the article "Rendering NURBS Surfaces in Real-Time". Please refer
          // to the article for an understanding of the methods in this class.
          // ------------------------------------------------------------------------------------
          //
          // Author: Dean Macri - Intel Developer Relations Divison -- Tools and Technology Group
          //
          ////////////////////////////////////////////////////////////////////////////////////////
          //
          // Yoinked from http://www.gamasutra.com/features/19991117/macri_pfv.htm
          // Hacked into an unholy mess for use with OGRE by Chris "Antiarc" Heald (  antiarc@captionthis.com )
          // Date: 11/9/2003
          //
          ////////////////////////////////////////////////////////////////////////////////////////
          
          
          #if !defined(  AFX_DRGNURBSSURFACE_H__0D6D594B_6F3B_11D3_BE36_00902752C5DF__INCLUDED_ )
          #define AFX_DRGNURBSSURFACE_H__0D6D594B_6F3B_11D3_BE36_00902752C5DF__INCLUDED_
          
          #if _MSC_VER > 1000
          #pragma once
          #endif
          
          #define SIMD_SIZE 1
          
          #define ALIGNED_NEW(  s,   t ) new t[s];
          #define ALIGNED_DELETE(  x ) do { if(  (  x ) ) { delete x; x = NULL; } } while (  0 )
          #define SAFE_RELEASE(  x ) do { if(  (  x ) ) { x->Release(   ); x = NULL; } } while (  0 )
          #define SAFE_DELETE(  x ) do { if(  (  x ) ) { delete x; x = NULL;} } while (  0 )
          
          // Some handy-dandy macros
          //
          #define CLAMP_UPPER(  x ) if (  x>1.0f ) { x = 1.0f; }
          #define CLAMP_LOWER(  x ) if (  x<0.0f ) { x = 0.0f; }
          
          struct Point4D
          {
           float x;
           float y;
           float z;
           float w;
          };
          
          struct splinePoint
          {
           float x;
           float y;
           float z;
          };
          
      71  class CDRGNURBSSurface
          {
          private:
           Point4D* m_pControlPoints;
           float* m_UBasisCoefficients;
           float* m_VBasisCoefficients;
           float* m_UKnots;
           float* m_VKnots;
           float* m_UBasis;
           float* m_dUBasis;
           float* m_VBasis;
           float* m_dVBasis;
           Point4D* m_UTemp;
           Point4D* m_dUTemp;
           int* m_TessUKnotSpan;
           int* m_TessVKnotSpan;
          
           int m_iUDegree,   m_iVDegree;
           int m_iUOrder,   m_iVOrder;
           int m_iUKnots,   m_iVKnots;
           int m_iUControlPoints,   m_iVControlPoints;
          
           int m_iUBasisSpans,   m_iVBasisSpans;
          
           int m_iUTessellations,   m_iVTessellations;
          
           splinePoint* m_pVertices;
          
      99   void Cleanup(  void );
     100   float ComputeCoefficient(  float* fKnots,   int iInterval,   int i,   int p,   int k );
     101   void ComputeBasisCoefficients(  void );
     102   void EvaluateBasisFunctions(  void );
          
          public:
     105   CDRGNURBSSurface(  void );
     106   virtual ~CDRGNURBSSurface(  void );
          
     108   bool Init(  int uDegree,   int vDegree,   int uControlPoints,   int vControlPoints,  
           Point4D* pControlPoints,   float* pUKnots,   float* pVKnots,  
           int iDefaultUTessellations = 10,   int iDefaultVTessellations = 10 );
          
     112   void UpdateControlPoints(  Point4D* pControlPoints );
          
     114   splinePoint getData(  int index );
     115   virtual void SetTessellations(  int iUTessellations,   int iVTessellations );
     116   virtual void TessellateSurface(  void );
     117   virtual int GetTriangleCount(  void );
          
          };
          
          #endif // !defined(  AFX_DRGNURBSSURFACE_H__0D6D594B_6F3B_11D3_BE36_00902752C5DF__INCLUDED_ )

./components/ogre/SceneManagers/EmberPagingSceneManager/include/EmberPagingLandScapeData2D_HeightField.h

       1  //
          // C++ Interface: EmberPagingLandScapeData2D_HeightField
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #ifndef EMBERPAGINGLANDSCAPEDATA2D_HEIGHTFIELD_H
          #define EMBERPAGINGLANDSCAPEDATA2D_HEIGHTFIELD_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeData2D.h"
          
          
          namespace EmberOgre
          {
          namespace Terrain {
      34   class TerrainPage;
          }
          /**
           * A specialized class for loading 2D Data from Mercator,   through an EmberOgre::TerrainPage class..
           */
          
      40   class EmberPagingLandScapeData2D_HeightField: public Ogre::PagingLandScapeData2D
           {
           public:
      43   EmberPagingLandScapeData2D_HeightField(  Ogre::PagingLandScapeData2DManager *pageMgr );
      44   virtual Ogre::String getName(   ) const {return Ogre::String(  "EmberHeightField" );}
      45   virtual ~EmberPagingLandScapeData2D_HeightField(   void  ) {};
          
      47   virtual const Ogre::Vector3 getNormal(   const Ogre::Real mX,   const Ogre::Real mZ  );
      48   virtual const Ogre::ColourValue getBase(   const Ogre::Real mX,   const Ogre::Real mZ  );
      49   virtual const Ogre::ColourValue getCoverage(   const Ogre::Real mX,   const Ogre::Real mZ  );
      50   virtual const Ogre::Real getShadow(   const Ogre::Real mX,   const Ogre::Real mZ,   const bool& positive  );
          
      52   virtual Ogre::PagingLandScapeData2D* newPage(   );
          
      54   virtual const Ogre::Real getMaxAbsoluteHeight(  void ) const;
           protected:
          
      57   virtual void _save(   void  );
      58   virtual bool _load(   const uint x,   const uint z  );
      59   virtual void _load(   void  );
      60   virtual void _unload(   void  );
          
           private:
      63   Terrain::TerrainPage* mTerrainPage;
           };
          
          }
          
          
          #endif
          

./components/ogre/SceneManagers/EmberPagingSceneManager/include/EmberPagingLandScapeTexture.h

       1  //
          // C++ Interface: EmberPagingLandScapeTexture
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #ifndef EMBERPAGINGLANDSCAPETEXTURE_H
          #define EMBERPAGINGLANDSCAPETEXTURE_H
          
          #include "../../../EmberOgrePrerequisites.h"
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeTexture.h"
          
          namespace EmberOgre
          {
          
      34  class EmberPagingLandScapeTexture : public Ogre::PagingLandScapeTexture
          {
          
          public:
      38   EmberPagingLandScapeTexture(  Ogre::PagingLandScapeTextureManager *pageMgr );
      39   virtual ~EmberPagingLandScapeTexture(   void  );
          
      41   virtual Ogre::String getName(   ) const {return Ogre::String(  "EmberTexture" );}
          
      43   virtual Ogre::PagingLandScapeTexture* newTexture(    );
      44   virtual bool isMaterialSupported(  bool recursive = true );
      45   void setOptions(  void );
          
          protected:
      48   virtual void _loadMaterial(   void  );
          
      50   virtual void _unloadMaterial(   void  );
          
          };
          
          }
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/EmberPagingSceneManager.h

       1  //
          // C++ Interface: EmberPagingSceneManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #ifndef EMBERPAGINGSCENEMANAGER_H
          #define EMBERPAGINGSCENEMANAGER_H
          
          #include "../../../EmberOgrePrerequisites.h"
          #include "OgrePagingLandScapeSceneManager.h"
          // #include "OgrePagingLandScapeOptions.h"
          
          
          namespace EmberOgre {
          namespace Terrain {
      34  class TerrainGenerator;
          }
      36  class EmberPagingSceneManager;
          
          namespace Model {
      39  class Model;
          }
          
      42  class IPageData
          {
           void createHeightData(  Ogre::Real* heightData );
           Ogre::MaterialPtr getMaterial(   );
          };
          
          
      49  class IPageDataProvider
          {
      51   IPageData* getPageData(  Ogre::Vector2 position );
          };
          
          
           /// Factory for OctreeSceneManager
      56   class EmberPagingSceneManagerFactory : public Ogre::SceneManagerFactory
           {
           protected:
      59   void initMetaData(  void ) const;
           public:
      61   EmberPagingSceneManagerFactory(   ) {}
      62   ~EmberPagingSceneManagerFactory(   ) {}
           /// Factory type name
      64   static const Ogre::String FACTORY_TYPE_NAME;
      65   Ogre::SceneManager* createInstance(  const Ogre::String& instanceName );
      66   void destroyInstance(  Ogre::SceneManager* instance );
           };
          
          /**
           * This is a specialization of Ogre::PagingLandScapeSceneManager.
           *
           * @see Ogre::PagingLandScapeSceneManager
           */
      74  class EmberPagingSceneManager : public Ogre::PagingLandScapeSceneManager {
          public:
          
          
          
           /** Things that need to be allocated once
           */
      81   void InitScene(   void  );
          
      83   EmberPagingSceneManager(  const Ogre::String &name );
          
          // EmberTerrainSceneManager(   );
          // virtual ~EmberTerrainSceneManager(   );
          
          // void attachPage(  Ogre::ushort pageX,   Ogre::ushort pageZ,   Ogre::TerrainPage* page,  float maxY,   float minY );
          // Ogre::TerrainPage* getTerrainPage(   const Ogre::Vector3 & pt  );
          
           /*
           * Resizes the octree. Do this after adding pages.
           */
          // void doResize(   );
          
           /*
           * The scenemanager stores the pages in vectors. This does not allow
           * for pages with negative indices.
           * But WF uses negative terrain coordinates.
           * Thus we need to offset the indices.
           */
          /* int getPageOffset(   );
          
           void setWorldGeometry(   const Ogre::String& filename  );
           void setWorldGeometry(   Ogre::TerrainOptions& options  );*/
          
          
           /* const Ogre::PagingLandScapeOptions * getOptions(   ) const
           {
           assert(  mOptions );
           return mOptions;
           }*/
          
          
           /**
           * Utility method for creating a new Model.
           * @param modelName the id of the model
           * @param modelDefinitionName the name of the model defition from which the model should be created
           * @return
           */
     121   Model::Model* createModel(  
     122   const Ogre::String& modelName,  
     123   const Ogre::String& modelDefinitionName  );
          
     125   void registerProvider(  IPageDataProvider* provider );
          
          protected:
          
           /*
           * @see EmberOgre::EmberTerrainSceneManager::getPageOffset(   )
           */
     132   Ogre::ushort mPageOffset;
          
          // /*
          // * Stitches the neighbours,   preventing gaps
          // */
          // void setupPageNeighbors(  Ogre::ushort pageX,   Ogre::ushort pageZ,   Ogre::TerrainPage* page );
          
           /*
           * Max and min values for the world. Used to resize the octree.
           */
           float mMaxX;
           float mMaxY;
           float mMaxZ;
           float mMinX;
           float mMinY;
           float mMinZ;
          
     149   IPageDataProvider* mProvider;
          
          
          private:
          };
          
          }
          
          #endif // EMBERPAGINGSCENEMANAGER_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/EmberPagingSceneManagerAdapter.h

       1  //
          // C++ Interface: EmberPagingSceneManagerAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "../../../EmberOgrePrerequisites.h"
          
          #include "../../../terrain/ISceneManagerAdapter.h"
          
          namespace Ogre
          {
      30  class PagingLandScapeOptions;
      31  class SceneManager;
          }
          
          namespace EmberOgre {
          
      36  class EmberPagingSceneManager;
          
      38  class EmberPagingSceneManagerAdapter : public Terrain::ISceneManagerAdapter
          {
          
          public:
          
      43   EmberPagingSceneManagerAdapter(  EmberPagingSceneManager* scenemanager );
          
          
      46   virtual int getPageSize(   );
      47   virtual Ogre::Real getHeightAt(  const Ogre::Real x,   const Ogre::Real z );
          
      49   virtual void setWorldPagesDimensions(  int numberOfPagesHeight,   int numberOfPagesWidth,   int heightOffsetInPages,   int widthOffsetInPages );
          
      51   virtual void setCamera(  Ogre::Camera* camera );
      52   virtual void setResourceGroupName(  const std::string& groupName );
      53   virtual void loadOptions(  const std::string& filePath );
      54   virtual void resize(  Ogre::AxisAlignedBox newSize,   int levels );
      55   virtual void loadScene(   );
          
      57   virtual void setOption(  const std::string& strKey,   const void* pValue );
      58   virtual void getOption(  const std::string& strKey,   void* pDestValue );
          
      60   virtual Ogre::SceneManager* getSceneManager(   ) const;
      61   virtual void reloadAllPages(   );
      62   virtual void reloadPage(  unsigned int x,   unsigned int z );
          
          private:
      65   EmberPagingSceneManager* mSceneManager;
      66   Ogre::PagingLandScapeOptions* getOptions(   );
          
          };
          
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgreDebugRectangle2D.h

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          
          #ifndef _DebugRectangle2D_H__
          #define _DebugRectangle2D_H__
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          #ifdef _VISIBILITYDEBUG
          
          #include "OgreSimpleRenderable.h"
          
          namespace Ogre
          {
          
           /** Allows the rendering of a simple 2D rectangle
           This class renders a simple 2D rectangle; this rectangle has no depth and
           therefore is best used with specific render queue and depth settings,  
           like RENDER_QUEUE_BACKGROUND and 'depth_write off' for backdrops,   and
           RENDER_QUEUE_OVERLAY and 'depth_check off' for fullscreen quads.
           */
      44   class DebugRectangle2D : public SimpleRenderable
           {
           protected:
           /** Override this method to prevent parent transforms (  rotation,  translation,  scale )
           */
      49   void getWorldTransforms(  Matrix4* xform ) const;
           /** @copydoc Renderable::getWorldOrientation */
      51   const Quaternion& getWorldOrientation(  void ) const;
           /** @copydoc Renderable::getWorldPosition */
      53   const Vector3& getWorldPosition(  void ) const;
          
           public:
          
      57   DebugRectangle2D(   );
      58   ~DebugRectangle2D(   );
          
           /** Sets the corners of the rectangle,   in relative coordinates.
           @param
           left Left position in screen relative coordinates,   -1 = left edge,   1.0 = right edge
           top Top position in screen relative coordinates,   1 = top edge,   -1 = bottom edge
           right Right position in screen relative coordinates
           bottom Bottom position in screen relative coordinates
           */
      67   void setCorners(  Real left,   Real top,   Real right,   Real bottom );
          
      69   Real getSquaredViewDepth(  const Camera* cam ) const { return 0; }
          
      71   Real getBoundingRadius(  void ) const { return 0; }
           /// Identity view and projection
          #ifdef PLSM2_EIHORT
      74   bool getUseIdentityProjection(  void ) const { return mUseIdentityProjection; }
          #else
      76   bool useIdentityProjection(  void ) const { return true; }
          #endif
           /// Identity view and projection
          #ifdef PLSM2_EIHORT
      80   bool getUseIdentityView(  void ) const { return mUseIdentityView; }
          #else
      82   bool useIdentityView(  void ) const { return true; }
          #endif
          
           };
          
          }// namespace
          
          #endif //_VISIBILITYDEBUG
          
          #endif // _DebugRectangle2D_H__
          

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgreOcclusionBoundingBox.h

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
           (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          #ifndef _OcclusionBoundingBox_H__
          #define _OcclusionBoundingBox_H__
          
          #include "OgrePrerequisites.h"
          
          #include "OgreSimpleRenderable.h"
          
          namespace Ogre
          {
          
           /** Allows the rendering of an opaque bounding box.
           @remarks
           This class builds a opaque renderable from a given aabb. A pointer to this class can be
           added to a render queue to display the bounding box of an object.
           */
      40   class OcclusionBoundingBox : public SimpleRenderable
           {
           protected:
           /** Override this method to prevent parent transforms (  rotation,  translation,  scale )
           */
      45   void getWorldTransforms(  Matrix4* xform ) const;
           /** @copydoc Renderable::getWorldOrientation */
      47   const Quaternion& getWorldOrientation(  void ) const;
           /** @copydoc Renderable::getWorldPosition */
      49   const Vector3& getWorldPosition(  void ) const;
          
           /** Builds the wireframe line list.
           */
      53   void setupBoundingBoxVertices(  const AxisAlignedBox& aab );
          
      55   Real mRadius;
          
           public:
          
      59   OcclusionBoundingBox(   );
      60   ~OcclusionBoundingBox(   );
          
      62   virtual PolygonMode getRenderDetail(   ) const;
          
           /** Builds the wireframe line list.
           @param
           aabb bounding box to build a wireframe from.
           */
      68   void setupBoundingBox(  const AxisAlignedBox& aabb );
          
      70   Real getSquaredViewDepth(  const Camera* cam ) const;
          
      72   Real getBoundingRadius(  void ) const { return mRadius; }
          
           };
          
          }// namespace
          
          #endif
          
          

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeAxisAlignedBoxSceneQuery.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreeAxisAlignedBoxSceneQuery.h - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004 by Jon Anderson
          email : janders@users.sf.net
          ***************************************************************************/
          
          #ifndef PagingLandScapeAxisAlignedBoxSCENEQUERY_H
          #define PagingLandScapeAxisAlignedBoxSCENEQUERY_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgreSceneManager.h"
          
          namespace Ogre
          {
          
          /** PagingLandScape implementation of AxisAlignedBoxSceneQuery. */
          class _OgrePagingLandScapeExport PagingLandScapeAxisAlignedBoxSceneQuery : public DefaultAxisAlignedBoxSceneQuery
          {
          public:
      46   PagingLandScapeAxisAlignedBoxSceneQuery(  SceneManager* creator );
           virtual ~PagingLandScapeAxisAlignedBoxSceneQuery(  void );
          
           /** See RayScenQuery. */
           /** Finds any entities that intersect the AAB for the query. */
           void execute(  SceneQueryListener* listener );
          
           // Structure returned in the geometry field of the worldFragment for this
           // query. Cut'n'paste this into your client w/out the setters if using
           // this query from a client.
           struct CustomQueryResult
           {
           enum CustomQueryResultTypes { QUERY_EXTENTS_TYPE,   SUBSECTION_EXTENTS_TYPE,   VERTEX_TYPE };
          
           void SetQueryExtents(   int width,   int height  )
           {
           type_ = QUERY_EXTENTS_TYPE;
           data_.queryExtents_.width_ = width;
           data_.queryExtents_.height_ = height;
           }
           void SetSubsectionExtents(   int width,   int height,   short renderLevel,   int subX,   int subZ  )
           {
           type_ = SUBSECTION_EXTENTS_TYPE;
           data_.subExtents_.width_ = width;
           data_.subExtents_.height_ = height;
           data_.subExtents_.renderLevel_ = renderLevel;
           data_.subExtents_.subX_ = subX;
           data_.subExtents_.subZ_ = subZ;
           }
           void SetVertex(   const Vector3& vertex,   bool included  )
           {
           type_ = VERTEX_TYPE;
           // Can't use a Vector3 in a union,   so we'll break it up.
           data_.vertexData_.x_ = vertex.x;
           data_.vertexData_.y_ = vertex.y;
           data_.vertexData_.z_ = vertex.z;
           data_.vertexData_.included_ = included;
           }
          
           CustomQueryResultTypes type_;
           union
           {
           struct
           {
           int width_;
           int height_;
           } queryExtents_;
           struct
           {
           int width_;
           int height_;
           short renderLevel_;
           int subX_;
           int subZ_;
           } subExtents_;
           struct
           {
           Real x_;
           Real y_;
           Real z_;
           bool included_;
           } vertexData_;
           } data_;
           };
          };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeCallBackEvent.h

       1  #ifndef __PagingLandScapeCallBackEvent_H__
          #define __PagingLandScapeCallBackEvent_H__
          
          #include "Ogre.h"
          #include "OgrePagingLandScapeCallback.h"
          
          namespace Ogre
          {
           //---------------------------------------------------------------------
      10   class PagingLandscapeEvent
           {
           public:
      13   PagingLandscapeEvent(  const size_t pagex,   const size_t pagez,  
      14   const size_t tilex,   const size_t tilez,  
      15   const Real* heightData,   const AxisAlignedBox &Bbox ) :
           mPagex(  pagex ),  
           mPagez(  pagez ),  
           mTilex(  tilex ),  
           mTilez(  tilez ),  
           mHeightData(  heightData ),  
           mBbox(  Bbox )
           {
          
           };
      25   ~PagingLandscapeEvent(   ){};
          
      27   const size_t mPagex;
      28   const size_t mPagez;
      29   const size_t mTilex;
      30   const size_t mTilez;
      31   const Real* mHeightData;
      32   const AxisAlignedBox &mBbox;
          
           };
           typedef fastdelegate::FastDelegate1<PagingLandscapeEvent *> PagingLandscapeDelegate;
          }
          #endif //__PagingLandScapeCallBackEvent_H__

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeCallback.h

          // FastDelegate.h
          // Efficient delegates in C++ that generate only two lines of asm code!
          // Documentation is found at http://www.codeproject.com/cpp/FastDelegate.asp
          //
          // - Don Clugston,   Mar 2004.
          // Major contributions were made by Jody Hagins.
          // History:
          // 24-Apr-04 1.0 * Submitted to CodeProject.
          // 28-Apr-04 1.1 * Prevent most unsafe uses of evil static function hack.
          // * Improved syntax for horrible_cast (  thanks Paul Bludov ).
          // * Tested on Metrowerks MWCC and Intel ICL (  IA32 )
          // * Compiled,   but not run,   on Comeau C++ and Intel Itanium ICL.
          // 27-Jun-04 1.2 * Now works on Borland C++ Builder 5.5
          // * Now works on /clr "managed C++" code on VC7,   VC7.1
          // * Comeau C++ now compiles without warnings.
          // * Prevent the virtual inheritance case from being used on
          // VC6 and earlier,   which generate incorrect code.
          // * Improved warning and error messages. Non-standard hacks
          // now have compile-time checks to make them safer.
          // * implicit_cast used instead of static_cast in many cases.
          // * If calling a const member function,   a const class pointer can be used.
          // * MakeDelegate(   ) global helper function added to simplify pass-by-value.
          // * Added fastdelegate.clear(   )
          // 16-Jul-04 1.2.1* Workaround for gcc bug (  const member function pointers in templates )
          // 30-Oct-04 1.3 * Support for (  non-void ) return values.
          // * No more workarounds in client code!
          // MSVC and Intel now use a clever hack invented by John Dlugosz:
          // - The FASTDELEGATEDECLARE workaround is no longer necessary.
          // - No more warning messages for VC6
          // * Less use of macros. Error messages should be more comprehensible.
          // * Added include guards
          // * Added FastDelegate::empty(   ) to test if invocation is safe (  Thanks Neville Franks ).
          // * Now tested on VS 2006 Express Beta,   PGI C++
          // 24-Dec-04 1.4 * Added DelegateMemento,   to allow collections of disparate delegates.
          // * <,  >,  <=,  >= comparison operators to allow storage in ordered containers.
          // * Substantial reduction of code size,   especially the 'Closure' class.
          // * Standardised all the compiler-specific workarounds.
          // * MFP conversion now works for CodePlay (  but not yet supported in the full code ).
          // * Now compiles without warnings on _any_ supported compiler,   including BCC 5.5.1
          // * New syntax: FastDelegate< int (  char *,   double ) >.
          // 14-Feb-05 1.4.1* Now treats =0 as equivalent to .clear(   ),   ==0 as equivalent to .empty(   ). (  Thanks elfric ).
          // * Now tested on Intel ICL for AMD64,   VS2006 Beta for AMD64 and Itanium.
          // 30-Mar-05 1.5 * Safebool idiom: "if (  dg )" is now equivalent to "if (  !dg.empty(   ) )"
          // * Fully supported by CodePlay VectorC
          // * Bugfix for Metrowerks: empty(   ) was buggy because a valid MFP can be 0 on MWCC!
          // * More optimal assignment,  == and != operators for static function pointers.
          
          #ifndef FASTDELEGATE_H
          #define FASTDELEGATE_H
          #if _MSC_VER > 1000
          #pragma once
          #endif // _MSC_VER > 1000
          
          #include <memory.h> // to allow <,  > comparisons
          
          ////////////////////////////////////////////////////////////////////////////////
          // Configuration options
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          // Uncomment the following #define for optimally-sized delegates.
          // In this case,   the generated asm code is almost identical to the code you'd get
          // if the compiler had native support for delegates.
          // It will not work on systems where sizeof(  dataptr ) < sizeof(  codeptr ).
          // Thus,   it will not work for DOS compilers using the medium model.
          // It will also probably fail on some DSP systems.
          #define FASTDELEGATE_USESTATICFUNCTIONHACK
          
          // Uncomment the next line to allow function declarator syntax.
          // It is automatically enabled for those compilers where it is known to work.
          //#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
          
          ////////////////////////////////////////////////////////////////////////////////
          // Compiler identification for workarounds
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          // Compiler identification. It's not easy to identify Visual C++ because
          // many vendors fraudulently define Microsoft's identifiers.
          #if defined(  _MSC_VER ) && !defined(  __MWERKS__ ) && !defined(  __VECTOR_C ) && !defined(  __ICL ) && !defined(  __BORLANDC__ )
          #define FASTDLGT_ISMSVC
          
          #if (  _MSC_VER <1300 ) // Many workarounds are required for VC6.
          #define FASTDLGT_VC6
          #pragma warning(  disable:4786 ) // disable this ridiculous warning
          #endif
          
          #endif
          
          // Does the compiler uses Microsoft's member function pointer structure?
          // If so,   it needs special treatment.
          // Metrowerks CodeWarrior,   Intel,   and CodePlay fraudulently define Microsoft's
          // identifier,   _MSC_VER. We need to filter Metrowerks out.
          #if defined(  _MSC_VER ) && !defined(  __MWERKS__ )
          #define FASTDLGT_MICROSOFT_MFP
          
          #if !defined(  __VECTOR_C )
          // CodePlay doesn't have the __single/multi/virtual_inheritance keywords
          #define FASTDLGT_HASINHERITANCE_KEYWORDS
          #endif
          #endif
          
          // Does it allow function declarator syntax? The following compilers are known to work:
          #if defined(  FASTDLGT_ISMSVC ) && (  _MSC_VER >=1310 ) // VC 7.1
          #define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
          #endif
          
          // Gcc(  2.95+ ),   and versions of Digital Mars,   Intel and Comeau in common use.
          #if defined (  __DMC__ ) || defined(  __GNUC__ ) || defined(  __ICL ) || defined(  __COMO__ )
          #define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
          #endif
          
          // It works on Metrowerks MWCC 3.2.2. From boost.Config it should work on earlier ones too.
          #if defined (  __MWERKS__ )
          #define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
          #endif
          
          #ifdef __GNUC__ // Workaround GCC bug #8271
           // At present,   GCC doesn't recognize constness of MFPs in templates
          #define FASTDELEGATE_GCC_BUG_8271
          #endif
          
          
          
          ////////////////////////////////////////////////////////////////////////////////
          // General tricks used in this code
          //
          // (  a ) Error messages are generated by typdefing an array of negative size to
          // generate compile-time errors.
          // (  b ) Warning messages on MSVC are generated by declaring unused variables,   and
          // enabling the "variable XXX is never used" warning.
          // (  c ) Unions are used in a few compiler-specific cases to perform illegal casts.
          // (  d ) For Microsoft and Intel,   when adjusting the 'this' pointer,   it's cast to
          // (  char * ) first to ensure that the correct number of *bytes* are added.
          //
          ////////////////////////////////////////////////////////////////////////////////
          // Helper templates
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          
          namespace fastdelegate {
          namespace detail { // we'll hide the implementation details in a nested namespace.
          
          // implicit_cast< >
          // I believe this was originally going to be in the C++ standard but
          // was left out by accident. It's even milder than static_cast.
          // I use it instead of static_cast<> to emphasize that I'm not doing
          // anything nasty.
          // Usage is identical to static_cast<>
          template <class OutputClass,   class InputClass>
     152  inline OutputClass implicit_cast(  InputClass input ){
           return input;
          }
          
          // horrible_cast< >
          // This is truly evil. It completely subverts C++'s type system,   allowing you
          // to cast from any class to any other class. Technically,   using a union
          // to perform the cast is undefined behaviour (  even in C ). But we can see if
          // it is OK by checking that the union is the same size as each of its members.
          // horrible_cast<> should only be used for compiler-specific workarounds.
          // Usage is identical to reinterpret_cast<>.
          
          // This union is declared outside the horrible_cast because BCC 5.5.1
          // can't inline a function with a nested class,   and gives a warning.
          template <class OutputClass,   class InputClass>
     167  union horrible_union{
           OutputClass out;
           InputClass in;
          };
          
          template <class OutputClass,   class InputClass>
     173  inline OutputClass horrible_cast(  const InputClass input ){
           horrible_union<OutputClass,   InputClass> u;
           // Cause a compile-time error if in,   out and u are not the same size.
           // If the compile fails here,   it means the compiler has peculiar
           // unions which would prevent the cast from working.
           typedef int ERROR_CantUseHorrible_cast[sizeof(  InputClass )==sizeof(  u )
           && sizeof(  InputClass )==sizeof(  OutputClass ) ? 1 : -1];
           u.in = input;
           return u.out;
          }
          
          ////////////////////////////////////////////////////////////////////////////////
          // Workarounds
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          // Backwards compatibility: This macro used to be necessary in the virtual inheritance
          // case for Intel and Microsoft. Now it just forward-declares the class.
          #define FASTDELEGATEDECLARE(  CLASSNAME ) class CLASSNAME;
          
          // Prevent use of the static function hack with the DOS medium model.
          #ifdef __MEDIUM__
          #undef FASTDELEGATE_USESTATICFUNCTIONHACK
          #endif
          
          // DefaultVoid - a workaround for 'void' templates in VC6.
          //
          // (  1 ) VC6 and earlier do not allow 'void' as a default template argument.
          // (  2 ) They also doesn't allow you to return 'void' from a function.
          //
          // Workaround for (  1 ): Declare a dummy type 'DefaultVoid' which we use
          // when we'd like to use 'void'. We convert it into 'void' and back
          // using the templates DefaultVoidToVoid<> and VoidToDefaultVoid<>.
          // Workaround for (  2 ): On VC6,   the code for calling a void function is
          // identical to the code for calling a non-void function in which the
          // return value is never used,   provided the return value is returned
          // in the EAX register,   rather than on the stack.
          // This is true for most fundamental types such as int,   enum,   void *.
          // Const void * is the safest option since it doesn't participate
          // in any automatic conversions. But on a 16-bit compiler it might
          // cause extra code to be generated,   so we disable it for all compilers
          // except for VC6 (  and VC5 ).
          #ifdef FASTDLGT_VC6
          // VC6 workaround
          typedef const void * DefaultVoid;
          #else
          // On any other compiler,   just use a normal void.
          typedef void DefaultVoid;
          #endif
          
          // Translate from 'DefaultVoid' to 'void'.
          // Everything else is unchanged
          template <class T>
          struct DefaultVoidToVoid { typedef T type; };
          
          template <>
          struct DefaultVoidToVoid<DefaultVoid> { typedef void type; };
          
          // Translate from 'void' into 'DefaultVoid'
          // Everything else is unchanged
          template <class T>
          struct VoidToDefaultVoid { typedef T type; };
          
          template <>
          struct VoidToDefaultVoid<void> { typedef DefaultVoid type; };
          
          
          
          ////////////////////////////////////////////////////////////////////////////////
          // Fast Delegates,   part 1:
          //
          // Conversion of member function pointer to a standard form
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          // GenericClass is a fake class,   ONLY used to provide a type.
          // It is vitally important that it is never defined,   so that the compiler doesn't
          // think it can optimize the invocation. For example,   Borland generates simpler
          // code if it knows the class only uses single inheritance.
          
          // Compilers using Microsoft's structure need to be treated as a special case.
          #ifdef FASTDLGT_MICROSOFT_MFP
          
          #ifdef FASTDLGT_HASINHERITANCE_KEYWORDS
           // For Microsoft and Intel,   we want to ensure that it's the most efficient type of MFP
           // (  4 bytes ),   even when the /vmg option is used. Declaring an empty class
           // would give 16 byte pointers in this case....
           class __single_inheritance GenericClass;
          #endif
           // ...but for Codeplay,   an empty class *always* gives 4 byte pointers.
           // If compiled with the /clr option (  "managed C++" ),   the JIT compiler thinks
           // it needs to load GenericClass before it can call any of its functions,  
           // (  compiles OK but crashes at runtime! ),   so we need to declare an
           // empty class to make it happy.
           // Codeplay and VC4 can't cope with the unknown_inheritance case either.
     268   class GenericClass {};
          #else
     270   class GenericClass;
          #endif
          
          // The size of a single inheritance member function pointer.
          const int SINGLE_MEMFUNCPTR_SIZE = sizeof(  void (  GenericClass::* )(   ) );
          
          // SimplifyMemFunc< >::Convert(   )
          //
          // A template function that converts an arbitrary member function pointer into the
          // simplest possible form of member function pointer,   using a supplied 'this' pointer.
          // According to the standard,   this can be done legally with reinterpret_cast<>.
          // For (  non-standard ) compilers which use member function pointers which vary in size
          // depending on the class,   we need to use knowledge of the internal structure of a
          // member function pointer,   as used by the compiler. Template specialization is used
          // to distinguish between the sizes. Because some compilers don't support partial
          // template specialisation,   I use full specialisation of a wrapper struct.
          
          // general case -- don't know how to convert it. Force a compile failure
          template <int N>
          struct SimplifyMemFunc {
           template <class X,   class XFuncType,   class GenericMemFuncType>
           inline static GenericClass *Convert(  X *pthis,   XFuncType function_to_bind,  
           GenericMemFuncType &bound_func ) {
           // Unsupported member function type -- force a compile failure.
           // (  it's illegal to have a array with negative size ).
           typedef char ERROR_Unsupported_member_function_pointer_on_this_compiler[N-100];
           return 0;
           }
          };
          
          // For compilers where all member func ptrs are the same size,   everything goes here.
          // For non-standard compilers,   only single_inheritance classes go here.
          template <>
          struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE> {
           template <class X,   class XFuncType,   class GenericMemFuncType>
           inline static GenericClass *Convert(  X *pthis,   XFuncType function_to_bind,  
           GenericMemFuncType &bound_func ) {
          #if defined __DMC__
           // Digital Mars doesn't allow you to cast between abitrary PMF's,  
           // even though the standard says you can. The 32-bit compiler lets you
           // static_cast through an int,   but the DOS compiler doesn't.
           bound_func = horrible_cast<GenericMemFuncType>(  function_to_bind );
          #else
           bound_func = reinterpret_cast<GenericMemFuncType>(  function_to_bind );
          #endif
           return reinterpret_cast<GenericClass *>(  pthis );
           }
          };
          
          ////////////////////////////////////////////////////////////////////////////////
          // Fast Delegates,   part 1b:
          //
          // Workarounds for Microsoft and Intel
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          
          // Compilers with member function pointers which violate the standard (  MSVC,   Intel,   Codeplay ),  
          // need to be treated as a special case.
          #ifdef FASTDLGT_MICROSOFT_MFP
          
          // We use unions to perform horrible_casts. I would like to use #pragma pack(  push,   1 )
          // at the start of each function for extra safety,   but VC6 seems to ICE
          // intermittently if you do this inside a template.
          
          // __multiple_inheritance classes go here
          // Nasty hack for Microsoft and Intel (  IA32 and Itanium )
          template<>
          struct SimplifyMemFunc< SINGLE_MEMFUNCPTR_SIZE + sizeof(  int ) > {
           template <class X,   class XFuncType,   class GenericMemFuncType>
           inline static GenericClass *Convert(  X *pthis,   XFuncType function_to_bind,  
           GenericMemFuncType &bound_func ) {
           // We need to use a horrible_cast to do this conversion.
           // In MSVC,   a multiple inheritance member pointer is internally defined as:
           union {
           XFuncType func;
           struct {
           GenericMemFuncType funcaddress; // points to the actual member function
           int delta; // #BYTES to be added to the 'this' pointer
           }s;
           } u;
           // Check that the horrible_cast will work
           typedef int ERROR_CantUsehorrible_cast[sizeof(  function_to_bind )==sizeof(  u.s )? 1 : -1];
           u.func = function_to_bind;
           bound_func = u.s.funcaddress;
           return reinterpret_cast<GenericClass *>(  reinterpret_cast<char *>(  pthis ) + u.s.delta );
           }
          };
          
          // virtual inheritance is a real nuisance. It's inefficient and complicated.
          // On MSVC and Intel,   there isn't enough information in the pointer itself to
          // enable conversion to a closure pointer. Earlier versions of this code didn't
          // work for all cases,   and generated a compile-time error instead.
          // But a very clever hack invented by John M. Dlugosz solves this problem.
          // My code is somewhat different to his: I have no asm code,   and I make no
          // assumptions about the calling convention that is used.
          
          // In VC++ and ICL,   a virtual_inheritance member pointer
          // is internally defined as:
          struct MicrosoftVirtualMFP {
           void (  GenericClass::*codeptr )(   ); // points to the actual member function
           int delta; // #bytes to be added to the 'this' pointer
           int vtable_index; // or 0 if no virtual inheritance
          };
          // The CRUCIAL feature of Microsoft/Intel MFPs which we exploit is that the
          // m_codeptr member is *always* called,   regardless of the values of the other
          // members. (  This is *not* true for other compilers,   eg GCC,   which obtain the
          // function address from the vtable if a virtual function is being called ).
          // Dlugosz's trick is to make the codeptr point to a probe function which
          // returns the 'this' pointer that was used.
          
          // Define a generic class that uses virtual inheritance.
          // It has a trival member function that returns the value of the 'this' pointer.
          struct GenericVirtualClass : virtual public GenericClass
          {
           typedef GenericVirtualClass * (  GenericVirtualClass::*ProbePtrType )(   );
           GenericVirtualClass * GetThis(   ) { return this; }
          };
          
          // __virtual_inheritance classes go here
          template <>
          struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 2*sizeof(  int ) >
          {
          
           template <class X,   class XFuncType,   class GenericMemFuncType>
           inline static GenericClass *Convert(  X *pthis,   XFuncType function_to_bind,  
           GenericMemFuncType &bound_func ) {
           union {
           XFuncType func;
           GenericClass* (  X::*ProbeFunc )(   );
           MicrosoftVirtualMFP s;
           } u;
           u.func = function_to_bind;
           bound_func = reinterpret_cast<GenericMemFuncType>(  u.s.codeptr );
           union {
           GenericVirtualClass::ProbePtrType virtfunc;
           MicrosoftVirtualMFP s;
           } u2;
           // Check that the horrible_cast<>s will work
           typedef int ERROR_CantUsehorrible_cast[sizeof(  function_to_bind )==sizeof(  u.s )
           && sizeof(  function_to_bind )==sizeof(  u.ProbeFunc )
           && sizeof(  u2.virtfunc )==sizeof(  u2.s ) ? 1 : -1];
           // Unfortunately,   taking the address of a MF prevents it from being inlined,   so
           // this next line can't be completely optimised away by the compiler.
           u2.virtfunc = &GenericVirtualClass::GetThis;
           u.s.codeptr = u2.s.codeptr;
           return (  pthis->*u.ProbeFunc )(   );
           }
          };
          
          #if (  _MSC_VER <1300 )
          
          // Nasty hack for Microsoft Visual C++ 6.0
          // unknown_inheritance classes go here
          // There is a compiler bug in MSVC6 which generates incorrect code in this case!!
          template <>
          struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(  int ) >
          {
           template <class X,   class XFuncType,   class GenericMemFuncType>
           inline static GenericClass *Convert(  X *pthis,   XFuncType function_to_bind,  
           GenericMemFuncType &bound_func ) {
           // There is an apalling but obscure compiler bug in MSVC6 and earlier:
           // vtable_index and 'vtordisp' are always set to 0 in the
           // unknown_inheritance case!
           // This means that an incorrect function could be called!!!
           // Compiling with the /vmg option leads to potentially incorrect code.
           // This is probably the reason that the IDE has a user interface for specifying
           // the /vmg option,   but it is disabled - you can only specify /vmg on
           // the command line. In VC1.5 and earlier,   the compiler would ICE if it ever
           // encountered this situation.
           // It is OK to use the /vmg option if /vmm or /vms is specified.
          
           // Fortunately,   the wrong function is only called in very obscure cases.
           // It only occurs when a derived class overrides a virtual function declared
           // in a virtual base class,   and the member function
           // points to the *Derived* version of that function. The problem can be
           // completely averted in 100% of cases by using the *Base class* for the
           // member fpointer. Ie,   if you use the base class as an interface,   you'll
           // stay out of trouble.
           // Occasionally,   you might want to point directly to a derived class function
           // that isn't an override of a base class. In this case,   both vtable_index
           // and 'vtordisp' are zero,   but a virtual_inheritance pointer will be generated.
           // We can generate correct code in this case. To prevent an incorrect call from
           // ever being made,   on MSVC6 we generate a warning,   and call a function to
           // make the program crash instantly.
           typedef char ERROR_VC6CompilerBug[-100];
           return 0;
           }
          };
          
          
          #else
          
          // Nasty hack for Microsoft and Intel (  IA32 and Itanium )
          // unknown_inheritance classes go here
          // This is probably the ugliest bit of code I've ever written. Look at the casts!
          // There is a compiler bug in MSVC6 which prevents it from using this code.
          template <>
          struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(  int ) >
          {
           template <class X,   class XFuncType,   class GenericMemFuncType>
           inline static GenericClass *Convert(  X *pthis,   XFuncType function_to_bind,  
           GenericMemFuncType &bound_func ) {
           // The member function pointer is 16 bytes long. We can't use a normal cast,   but
           // we can use a union to do the conversion.
           union {
           XFuncType func;
           // In VC++ and ICL,   an unknown_inheritance member pointer
           // is internally defined as:
           struct {
           GenericMemFuncType m_funcaddress; // points to the actual member function
           int delta; // #bytes to be added to the 'this' pointer
           int vtordisp; // #bytes to add to 'this' to find the vtable
           int vtable_index; // or 0 if no virtual inheritance
           } s;
           } u;
           // Check that the horrible_cast will work
           typedef int ERROR_CantUsehorrible_cast[sizeof(  XFuncType )==sizeof(  u.s )? 1 : -1];
           u.func = function_to_bind;
           bound_func = u.s.funcaddress;
           int virtual_delta = 0;
           if (  u.s.vtable_index ) { // Virtual inheritance is used
           // First,   get to the vtable.
           // It is 'vtordisp' bytes from the start of the class.
           const int * vtable = *reinterpret_cast<const int *const*>(  
           reinterpret_cast<const char *>(  pthis ) + u.s.vtordisp  );
          
           // 'vtable_index' tells us where in the table we should be looking.
           virtual_delta = u.s.vtordisp + *reinterpret_cast<const int *>(  
           reinterpret_cast<const char *>(  vtable ) + u.s.vtable_index );
           }
           // The int at 'virtual_delta' gives us the amount to add to 'this'.
           // Finally we can add the three components together. Phew!
           return reinterpret_cast<GenericClass *>(  
           reinterpret_cast<char *>(  pthis ) + u.s.delta + virtual_delta );
           };
          };
          #endif // MSVC 7 and greater
          
          #endif // MS/Intel hacks
          
          } // namespace detail
          
          ////////////////////////////////////////////////////////////////////////////////
          // Fast Delegates,   part 2:
          //
          // Define the delegate storage,   and cope with static functions
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          // DelegateMemento -- an opaque structure which can hold an arbitary delegate.
          // It knows nothing about the calling convention or number of arguments used by
          // the function pointed to.
          // It supplies comparison operators so that it can be stored in STL collections.
          // It cannot be set to anything other than null,   nor invoked directly:
          // it must be converted to a specific delegate.
          
          // Implementation:
          // There are two possible implementations: the Safe method and the Evil method.
          // DelegateMemento - Safe version
          //
          // This implementation is standard-compliant,   but a bit tricky.
          // A static function pointer is stored inside the class.
          // Here are the valid values:
          // +-- Static pointer --+--pThis --+-- pMemFunc-+-- Meaning------+
          // | 0 | 0 | 0 | Empty |
          // | !=0 |(  dontcare )| Invoker | Static function|
          // | 0 | !=0 | !=0* | Method call |
          // +--------------------+----------+------------+----------------+
          // * For Metrowerks,   this can be 0. (  first virtual function in a
          // single_inheritance class ).
          // When stored stored inside a specific delegate,   the 'dontcare' entries are replaced
          // with a reference to the delegate itself. This complicates the = and == operators
          // for the delegate class.
          
          // DelegateMemento - Evil version
          //
          // For compilers where data pointers are at least as big as code pointers,   it is
          // possible to store the function pointer in the this pointer,   using another
          // horrible_cast. In this case the DelegateMemento implementation is simple:
          // +--pThis --+-- pMemFunc-+-- Meaning---------------------+
          // | 0 | 0 | Empty |
          // | !=0 | !=0* | Static function or method call|
          // +----------+------------+-------------------------------+
          // * For Metrowerks,   this can be 0. (  first virtual function in a
          // single_inheritance class ).
          // Note that the Sun C++ and MSVC documentation explicitly state that they
          // support static_cast between void * and function pointers.
          
          class DelegateMemento {
          protected:
           // the data is protected,   not private,   because many
           // compilers have problems with template friends.
           typedef void (  detail::GenericClass::*GenericMemFuncType )(   ); // arbitrary MFP.
           detail::GenericClass *m_pthis;
           GenericMemFuncType m_pFunction;
          
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
           typedef void (  *GenericFuncPtr )(   ); // arbitrary code pointer
           GenericFuncPtr m_pStaticFunction;
          #endif
          
          public:
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
           DelegateMemento(   ) : m_pthis(  0 ),   m_pFunction(  0 ),   m_pStaticFunction(  0 ) {};
           void clear(   ) {
           m_pthis=0; m_pFunction=0; m_pStaticFunction=0;
           }
          #else
           DelegateMemento(   ) : m_pthis(  0 ),   m_pFunction(  0 ) {};
           void clear(   ) { m_pthis=0; m_pFunction=0; }
          #endif
          public:
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
           inline bool IsEqual (  const DelegateMemento &x ) const{
           // We have to cope with the static function pointers as a special case
           if (  m_pFunction!=x.m_pFunction ) return false;
           // the static function ptrs must either both be equal,   or both be 0.
           if (  m_pStaticFunction!=x.m_pStaticFunction ) return false;
           if (  m_pStaticFunction!=0 ) return m_pthis==x.m_pthis;
           else return true;
           }
          #else // Evil Method
           inline bool IsEqual (  const DelegateMemento &x ) const{
           return m_pthis==x.m_pthis && m_pFunction==x.m_pFunction;
           }
          #endif
           // Provide a strict weak ordering for DelegateMementos.
           inline bool IsLess(  const DelegateMemento &right ) const {
           // deal with static function pointers first
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
           if (  m_pStaticFunction !=0 || right.m_pStaticFunction!=0 )
           return m_pStaticFunction < right.m_pStaticFunction;
          #endif
           if (  m_pthis !=right.m_pthis ) return m_pthis < right.m_pthis;
           // There are no ordering operators for member function pointers,  
           // but we can fake one by comparing each byte. The resulting ordering is
           // arbitrary (  and compiler-dependent ),   but it permits storage in ordered STL containers.
           return memcmp(  &m_pFunction,   &right.m_pFunction,   sizeof(  m_pFunction ) ) < 0;
          
           }
           // BUGFIX (  Mar 2006 ):
           // We can't just compare m_pFunction because on Metrowerks,  
           // m_pFunction can be zero even if the delegate is not empty!
           inline bool operator ! (   ) const // Is it bound to anything?
           { return m_pthis==0 && m_pFunction==0; }
           inline bool empty(   ) const // Is it bound to anything?
           { return m_pthis==0 && m_pFunction==0; }
          public:
           DelegateMemento & operator = (  const DelegateMemento &right ) {
           SetMementoFrom(  right );
           return *this;
           }
           inline bool operator <(  const DelegateMemento &right ) {
           return IsLess(  right );
           }
           inline bool operator >(  const DelegateMemento &right ) {
           return right.IsLess(  *this );
           }
           DelegateMemento (  const DelegateMemento &right ) :
           m_pFunction(  right.m_pFunction ),   m_pthis(  right.m_pthis )
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
           ,   m_pStaticFunction (  right.m_pStaticFunction )
          #endif
           {}
          protected:
           void SetMementoFrom(  const DelegateMemento &right ) {
           m_pFunction = right.m_pFunction;
           m_pthis = right.m_pthis;
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
           m_pStaticFunction = right.m_pStaticFunction;
          #endif
           }
          };
          
          
          // ClosurePtr<>
          //
          // A private wrapper class that adds function signatures to DelegateMemento.
          // It's the class that does most of the actual work.
          // The signatures are specified by:
          // GenericMemFunc: must be a type of GenericClass member function pointer.
          // StaticFuncPtr: must be a type of function pointer with the same signature
          // as GenericMemFunc.
          // UnvoidStaticFuncPtr: is the same as StaticFuncPtr,   except on VC6
          // where it never returns void (  returns DefaultVoid instead ).
          
          // An outer class,   FastDelegateN<>,   handles the invoking and creates the
          // necessary typedefs.
          // This class does everything else.
          
          namespace detail {
          
          template < class GenericMemFunc,   class StaticFuncPtr,   class UnvoidStaticFuncPtr>
          class ClosurePtr : public DelegateMemento {
          public:
           // These functions are for setting the delegate to a member function.
          
           // Here's the clever bit: we convert an arbitrary member function into a
           // standard form. XMemFunc should be a member function of class X,   but I can't
           // enforce that here. It needs to be enforced by the wrapper class.
           template < class X,   class XMemFunc >
           inline void bindmemfunc(  X *pthis,   XMemFunc function_to_bind  ) {
           m_pthis = SimplifyMemFunc< sizeof(  function_to_bind ) >
           ::Convert(  pthis,   function_to_bind,   m_pFunction );
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
           m_pStaticFunction = 0;
          #endif
           }
           // For const member functions,   we only need a const class pointer.
           // Since we know that the member function is const,   it's safe to
           // remove the const qualifier from the 'this' pointer with a const_cast.
           // VC6 has problems if we just overload 'bindmemfunc',   so we give it a different name.
           template < class X,   class XMemFunc>
           inline void bindconstmemfunc(  const X *pthis,   XMemFunc function_to_bind ) {
           m_pthis= SimplifyMemFunc< sizeof(  function_to_bind ) >
           ::Convert(  const_cast<X*>(  pthis ),   function_to_bind,   m_pFunction );
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
           m_pStaticFunction = 0;
          #endif
           }
          #ifdef FASTDELEGATE_GCC_BUG_8271 // At present,   GCC doesn't recognize constness of MFPs in templates
           template < class X,   class XMemFunc>
           inline void bindmemfunc(  const X *pthis,   XMemFunc function_to_bind ) {
           bindconstmemfunc(  pthis,   function_to_bind );
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
           m_pStaticFunction = 0;
          #endif
           }
          #endif
           // These functions are required for invoking the stored function
           inline GenericClass *GetClosureThis(   ) const { return m_pthis; }
           inline GenericMemFunc GetClosureMemPtr(   ) const { return reinterpret_cast<GenericMemFunc>(  m_pFunction ); }
          
          // There are a few ways of dealing with static function pointers.
          // There's a standard-compliant,   but tricky method.
          // There's also a straightforward hack,   that won't work on DOS compilers using the
          // medium memory model. It's so evil that I can't recommend it,   but I've
          // implemented it anyway because it produces very nice asm code.
          
          #if !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
          
          // ClosurePtr<> - Safe version
          //
          // This implementation is standard-compliant,   but a bit tricky.
          // I store the function pointer inside the class,   and the delegate then
          // points to itself. Whenever the delegate is copied,   these self-references
          // must be transformed,   and this complicates the = and == operators.
          public:
           // The next two functions are for operator ==,   =,   and the copy constructor.
           // We may need to convert the m_pthis pointers,   so that
           // they remain as self-references.
           template< class DerivedClass >
           inline void CopyFrom (  DerivedClass *pParent,   const DelegateMemento &x ) {
           SetMementoFrom(  x );
           if (  m_pStaticFunction!=0 ) {
           // transform self references...
           m_pthis=reinterpret_cast<GenericClass *>(  pParent );
           }
           }
           // For static functions,   the 'static_function_invoker' class in the parent
           // will be called. The parent then needs to call GetStaticFunction(   ) to find out
           // the actual function to invoke.
           template < class DerivedClass,   class ParentInvokerSig >
           inline void bindstaticfunc(  DerivedClass *pParent,   ParentInvokerSig static_function_invoker,  
           StaticFuncPtr function_to_bind  ) {
           if (  function_to_bind==0 ) { // cope with assignment to 0
           m_pFunction=0;
           } else {
           bindmemfunc(  pParent,   static_function_invoker );
           }
           m_pStaticFunction=reinterpret_cast<GenericFuncPtr>(  function_to_bind );
           }
           inline UnvoidStaticFuncPtr GetStaticFunction(   ) const {
           return reinterpret_cast<UnvoidStaticFuncPtr>(  m_pStaticFunction );
           }
          #else
          
          // ClosurePtr<> - Evil version
          //
          // For compilers where data pointers are at least as big as code pointers,   it is
          // possible to store the function pointer in the this pointer,   using another
          // horrible_cast. Invocation isn't any faster,   but it saves 4 bytes,   and
          // speeds up comparison and assignment. If C++ provided direct language support
          // for delegates,   they would produce asm code that was almost identical to this.
          // Note that the Sun C++ and MSVC documentation explicitly state that they
          // support static_cast between void * and function pointers.
          
           template< class DerivedClass >
           inline void CopyFrom (  DerivedClass *pParent,   const DelegateMemento &right ) {
           SetMementoFrom(  right );
           }
           // For static functions,   the 'static_function_invoker' class in the parent
           // will be called. The parent then needs to call GetStaticFunction(   ) to find out
           // the actual function to invoke.
           // ******** EVIL,   EVIL CODE! *******
           template < class DerivedClass,   class ParentInvokerSig>
           inline void bindstaticfunc(  DerivedClass *pParent,   ParentInvokerSig static_function_invoker,  
           StaticFuncPtr function_to_bind ) {
           if (  function_to_bind==0 ) { // cope with assignment to 0
           m_pFunction=0;
           } else {
           // We'll be ignoring the 'this' pointer,   but we need to make sure we pass
           // a valid value to bindmemfunc(   ).
           bindmemfunc(  pParent,   static_function_invoker );
           }
          
           // WARNING! Evil hack. We store the function in the 'this' pointer!
           // Ensure that there's a compilation failure if function pointers
           // and data pointers have different sizes.
           // If you get this error,   you need to #undef FASTDELEGATE_USESTATICFUNCTIONHACK.
           typedef int ERROR_CantUseEvilMethod[sizeof(  GenericClass * )==sizeof(  function_to_bind ) ? 1 : -1];
           m_pthis = horrible_cast<GenericClass *>(  function_to_bind );
           // MSVC,   SunC++ and DMC accept the following (  non-standard ) code:
          // m_pthis = static_cast<GenericClass *>(  static_cast<void *>(  function_to_bind ) );
           // BCC32,   Comeau and DMC accept this method. MSVC7.1 needs __int64 instead of long
          // m_pthis = reinterpret_cast<GenericClass *>(  reinterpret_cast<long>(  function_to_bind ) );
           }
           // ******** EVIL,   EVIL CODE! *******
           // This function will be called with an invalid 'this' pointer!!
           // We're just returning the 'this' pointer,   converted into
           // a function pointer!
           inline UnvoidStaticFuncPtr GetStaticFunction(   ) const {
           // Ensure that there's a compilation failure if function pointers
           // and data pointers have different sizes.
           // If you get this error,   you need to #undef FASTDELEGATE_USESTATICFUNCTIONHACK.
           typedef int ERROR_CantUseEvilMethod[sizeof(  UnvoidStaticFuncPtr )==sizeof(  this ) ? 1 : -1];
           return horrible_cast<UnvoidStaticFuncPtr>(  this );
           }
          #endif // !defined(  FASTDELEGATE_USESTATICFUNCTIONHACK )
          
           // Does the closure contain this static function?
           inline bool IsEqualToStaticFuncPtr(  StaticFuncPtr funcptr ){
           if (  funcptr==0 ) return empty(   );
           // For the Evil method,   if it doesn't actually contain a static function,   this will return an arbitrary
           // value that is not equal to any valid function pointer.
           else return funcptr==reinterpret_cast<StaticFuncPtr>(  GetStaticFunction(   ) );
           }
          };
          
          
          } // namespace detail
          
          ////////////////////////////////////////////////////////////////////////////////
          // Fast Delegates,   part 3:
          //
          // Wrapper classes to ensure type safety
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          
          // Once we have the member function conversion templates,   it's easy to make the
          // wrapper classes. So that they will work with as many compilers as possible,  
          // the classes are of the form
          // FastDelegate3<int,   char *,   double>
          // They can cope with any combination of parameters. The max number of parameters
          // allowed is 8,   but it is trivial to increase this limit.
          // Note that we need to treat const member functions seperately.
          // All this class does is to enforce type safety,   and invoke the delegate with
          // the correct list of parameters.
          
          // Because of the weird rule about the class of derived member function pointers,  
          // you sometimes need to apply a downcast to the 'this' pointer.
          // This is the reason for the use of "implicit_cast<X*>(  pthis )" in the code below.
          // If CDerivedClass is derived from CBaseClass,   but doesn't override SimpleVirtualFunction,  
          // without this trick you'd need to write:
          // MyDelegate(  static_cast<CBaseClass *>(  &d ),   &CDerivedClass::SimpleVirtualFunction );
          // but with the trick you can write
          // MyDelegate(  &d,   &CDerivedClass::SimpleVirtualFunction );
          
          // RetType is the type the compiler uses in compiling the template. For VC6,  
          // it cannot be void. DesiredRetType is the real type which is returned from
          // all of the functions. It can be void.
          
          // Implicit conversion to "bool" is achieved using the safe_bool idiom,  
          // using member data pointers (  MDP ). This allows "if (  dg )..." syntax
          // Because some compilers (  eg codeplay ) don't have a unique value for a zero
          // MDP,   an extra padding member is added to the SafeBool struct.
          // Some compilers (  eg VC6 ) won't implicitly convert from 0 to an MDP,   so
          // in that case the static function constructor is not made explicit; this
          // allows "if (  dg==0 ) ..." to compile.
          
          //N=0
          template<class RetType=detail::DefaultVoid>
          class FastDelegate0 {
          private:
           typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
           typedef DesiredRetType (  *StaticFunctionPtr )(   );
           typedef RetType (  *UnvoidStaticFunctionPtr )(   );
           typedef RetType (  detail::GenericClass::*GenericMemFn )(   );
           typedef detail::ClosurePtr<GenericMemFn,   StaticFunctionPtr,   UnvoidStaticFunctionPtr> ClosureType;
           ClosureType m_Closure;
          public:
           // Typedefs to aid generic programming
           typedef FastDelegate0 type;
          
           // Construction and comparison functions
           FastDelegate0(   ) { clear(   ); }
           FastDelegate0(  const FastDelegate0 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           void operator = (  const FastDelegate0 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           bool operator ==(  const FastDelegate0 &x ) const {
           return m_Closure.IsEqual(  x.m_Closure ); }
           bool operator !=(  const FastDelegate0 &x ) const {
           return !m_Closure.IsEqual(  x.m_Closure ); }
           bool operator <(  const FastDelegate0 &x ) const {
           return m_Closure.IsLess(  x.m_Closure ); }
           bool operator >(  const FastDelegate0 &x ) const {
           return x.m_Closure.IsLess(  m_Closure ); }
           // Binding to non-const member functions
           template < class X,   class Y >
           FastDelegate0(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(   )  ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(   ) ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           // Binding to const member functions.
           template < class X,   class Y >
           FastDelegate0(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(   ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(   ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X *>(  pthis ),   function_to_bind ); }
           // Static functions. We convert them into a member function call.
           // This constructor also provides implicit conversion
           FastDelegate0(  DesiredRetType (  *function_to_bind )(   )  ) {
           bind(  function_to_bind ); }
           // for efficiency,   prevent creation of a temporary
           void operator = (  DesiredRetType (  *function_to_bind )(   )  ) {
           bind(  function_to_bind ); }
           inline void bind(  DesiredRetType (  *function_to_bind )(   ) ) {
           m_Closure.bindstaticfunc(  this,   &FastDelegate0::InvokeStaticFunction,  
           function_to_bind ); }
           // Invoke the delegate
           RetType operator(   ) (   ) const {
           return (  m_Closure.GetClosureThis(   )->*(  m_Closure.GetClosureMemPtr(   ) ) )(   ); }
           // Implicit conversion to "bool" using the safe_bool idiom
          private:
           typedef struct SafeBoolStruct {
           int a_data_pointer_to_this_is_0_on_buggy_compilers;
           StaticFunctionPtr m_nonzero;
           } UselessTypedef;
           typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
          public:
           operator unspecified_bool_type(   ) const {
           return empty(   )? 0: &SafeBoolStruct::m_nonzero;
           }
           // necessary to allow ==0 to work despite the safe_bool idiom
           inline bool operator==(  StaticFunctionPtr funcptr ) {
           return m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator!=(  StaticFunctionPtr funcptr ) {
           return !m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator ! (   ) const { // Is it bound to anything?
           return !m_Closure; }
           inline bool empty(   ) const {
           return !m_Closure; }
           void clear(   ) { m_Closure.clear(   );}
           // Conversion to and from the DelegateMemento storage class
           const DelegateMemento & GetMemento(   ) { return m_Closure; }
           void SetMemento(  const DelegateMemento &any ) { m_Closure.CopyFrom(  this,   any ); }
          
          private: // Invoker for static functions
           RetType InvokeStaticFunction(   ) const {
           return (  *(  m_Closure.GetStaticFunction(   ) ) )(   ); }
          };
          
          //N=1
          template<class Param1,   class RetType=detail::DefaultVoid>
          class FastDelegate1 {
          private:
           typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
           typedef DesiredRetType (  *StaticFunctionPtr )(  Param1 p1 );
           typedef RetType (  *UnvoidStaticFunctionPtr )(  Param1 p1 );
           typedef RetType (  detail::GenericClass::*GenericMemFn )(  Param1 p1 );
           typedef detail::ClosurePtr<GenericMemFn,   StaticFunctionPtr,   UnvoidStaticFunctionPtr> ClosureType;
           ClosureType m_Closure;
          public:
           // Typedefs to aid generic programming
           typedef FastDelegate1 type;
          
           // Construction and comparison functions
           FastDelegate1(   ) { clear(   ); }
           FastDelegate1(  const FastDelegate1 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           void operator = (  const FastDelegate1 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           bool operator ==(  const FastDelegate1 &x ) const {
           return m_Closure.IsEqual(  x.m_Closure ); }
           bool operator !=(  const FastDelegate1 &x ) const {
           return !m_Closure.IsEqual(  x.m_Closure ); }
           bool operator <(  const FastDelegate1 &x ) const {
           return m_Closure.IsLess(  x.m_Closure ); }
           bool operator >(  const FastDelegate1 &x ) const {
           return x.m_Closure.IsLess(  m_Closure ); }
           // Binding to non-const member functions
           template < class X,   class Y >
           FastDelegate1(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1 )  ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1 ) ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           // Binding to const member functions.
           template < class X,   class Y >
           FastDelegate1(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X *>(  pthis ),   function_to_bind ); }
           // Static functions. We convert them into a member function call.
           // This constructor also provides implicit conversion
           FastDelegate1(  DesiredRetType (  *function_to_bind )(  Param1 p1 )  ) {
           bind(  function_to_bind ); }
           // for efficiency,   prevent creation of a temporary
           void operator = (  DesiredRetType (  *function_to_bind )(  Param1 p1 )  ) {
           bind(  function_to_bind ); }
           inline void bind(  DesiredRetType (  *function_to_bind )(  Param1 p1 ) ) {
           m_Closure.bindstaticfunc(  this,   &FastDelegate1::InvokeStaticFunction,  
           function_to_bind ); }
           // Invoke the delegate
           RetType operator(   ) (  Param1 p1 ) const {
           return (  m_Closure.GetClosureThis(   )->*(  m_Closure.GetClosureMemPtr(   ) ) )(  p1 ); }
           // Implicit conversion to "bool" using the safe_bool idiom
          private:
           typedef struct SafeBoolStruct {
           int a_data_pointer_to_this_is_0_on_buggy_compilers;
           StaticFunctionPtr m_nonzero;
           } UselessTypedef;
           typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
          public:
           operator unspecified_bool_type(   ) const {
           return empty(   )? 0: &SafeBoolStruct::m_nonzero;
           }
           // necessary to allow ==0 to work despite the safe_bool idiom
           inline bool operator==(  StaticFunctionPtr funcptr ) {
           return m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator!=(  StaticFunctionPtr funcptr ) {
           return !m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator ! (   ) const { // Is it bound to anything?
           return !m_Closure; }
           inline bool empty(   ) const {
           return !m_Closure; }
           void clear(   ) { m_Closure.clear(   );}
           // Conversion to and from the DelegateMemento storage class
           const DelegateMemento & GetMemento(   ) { return m_Closure; }
           void SetMemento(  const DelegateMemento &any ) { m_Closure.CopyFrom(  this,   any ); }
          
          private: // Invoker for static functions
           RetType InvokeStaticFunction(  Param1 p1 ) const {
           return (  *(  m_Closure.GetStaticFunction(   ) ) )(  p1 ); }
          };
          
          //N=2
          template<class Param1,   class Param2,   class RetType=detail::DefaultVoid>
          class FastDelegate2 {
          private:
           typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
           typedef DesiredRetType (  *StaticFunctionPtr )(  Param1 p1,   Param2 p2 );
           typedef RetType (  *UnvoidStaticFunctionPtr )(  Param1 p1,   Param2 p2 );
           typedef RetType (  detail::GenericClass::*GenericMemFn )(  Param1 p1,   Param2 p2 );
           typedef detail::ClosurePtr<GenericMemFn,   StaticFunctionPtr,   UnvoidStaticFunctionPtr> ClosureType;
           ClosureType m_Closure;
          public:
           // Typedefs to aid generic programming
           typedef FastDelegate2 type;
          
           // Construction and comparison functions
           FastDelegate2(   ) { clear(   ); }
           FastDelegate2(  const FastDelegate2 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           void operator = (  const FastDelegate2 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           bool operator ==(  const FastDelegate2 &x ) const {
           return m_Closure.IsEqual(  x.m_Closure ); }
           bool operator !=(  const FastDelegate2 &x ) const {
           return !m_Closure.IsEqual(  x.m_Closure ); }
           bool operator <(  const FastDelegate2 &x ) const {
           return m_Closure.IsLess(  x.m_Closure ); }
           bool operator >(  const FastDelegate2 &x ) const {
           return x.m_Closure.IsLess(  m_Closure ); }
           // Binding to non-const member functions
           template < class X,   class Y >
           FastDelegate2(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2 )  ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2 ) ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           // Binding to const member functions.
           template < class X,   class Y >
           FastDelegate2(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X *>(  pthis ),   function_to_bind ); }
           // Static functions. We convert them into a member function call.
           // This constructor also provides implicit conversion
           FastDelegate2(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2 )  ) {
           bind(  function_to_bind ); }
           // for efficiency,   prevent creation of a temporary
           void operator = (  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2 )  ) {
           bind(  function_to_bind ); }
           inline void bind(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2 ) ) {
           m_Closure.bindstaticfunc(  this,   &FastDelegate2::InvokeStaticFunction,  
           function_to_bind ); }
           // Invoke the delegate
           RetType operator(   ) (  Param1 p1,   Param2 p2 ) const {
           return (  m_Closure.GetClosureThis(   )->*(  m_Closure.GetClosureMemPtr(   ) ) )(  p1,   p2 ); }
           // Implicit conversion to "bool" using the safe_bool idiom
          private:
           typedef struct SafeBoolStruct {
           int a_data_pointer_to_this_is_0_on_buggy_compilers;
           StaticFunctionPtr m_nonzero;
           } UselessTypedef;
           typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
          public:
           operator unspecified_bool_type(   ) const {
           return empty(   )? 0: &SafeBoolStruct::m_nonzero;
           }
           // necessary to allow ==0 to work despite the safe_bool idiom
           inline bool operator==(  StaticFunctionPtr funcptr ) {
           return m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator!=(  StaticFunctionPtr funcptr ) {
           return !m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator ! (   ) const { // Is it bound to anything?
           return !m_Closure; }
           inline bool empty(   ) const {
           return !m_Closure; }
           void clear(   ) { m_Closure.clear(   );}
           // Conversion to and from the DelegateMemento storage class
           const DelegateMemento & GetMemento(   ) { return m_Closure; }
           void SetMemento(  const DelegateMemento &any ) { m_Closure.CopyFrom(  this,   any ); }
          
          private: // Invoker for static functions
           RetType InvokeStaticFunction(  Param1 p1,   Param2 p2 ) const {
           return (  *(  m_Closure.GetStaticFunction(   ) ) )(  p1,   p2 ); }
          };
          
          //N=3
          template<class Param1,   class Param2,   class Param3,   class RetType=detail::DefaultVoid>
          class FastDelegate3 {
          private:
           typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
           typedef DesiredRetType (  *StaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3 );
           typedef RetType (  *UnvoidStaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3 );
           typedef RetType (  detail::GenericClass::*GenericMemFn )(  Param1 p1,   Param2 p2,   Param3 p3 );
           typedef detail::ClosurePtr<GenericMemFn,   StaticFunctionPtr,   UnvoidStaticFunctionPtr> ClosureType;
           ClosureType m_Closure;
          public:
           // Typedefs to aid generic programming
           typedef FastDelegate3 type;
          
           // Construction and comparison functions
           FastDelegate3(   ) { clear(   ); }
           FastDelegate3(  const FastDelegate3 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           void operator = (  const FastDelegate3 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           bool operator ==(  const FastDelegate3 &x ) const {
           return m_Closure.IsEqual(  x.m_Closure ); }
           bool operator !=(  const FastDelegate3 &x ) const {
           return !m_Closure.IsEqual(  x.m_Closure ); }
           bool operator <(  const FastDelegate3 &x ) const {
           return m_Closure.IsLess(  x.m_Closure ); }
           bool operator >(  const FastDelegate3 &x ) const {
           return x.m_Closure.IsLess(  m_Closure ); }
           // Binding to non-const member functions
           template < class X,   class Y >
           FastDelegate3(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3 )  ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3 ) ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           // Binding to const member functions.
           template < class X,   class Y >
           FastDelegate3(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X *>(  pthis ),   function_to_bind ); }
           // Static functions. We convert them into a member function call.
           // This constructor also provides implicit conversion
           FastDelegate3(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3 )  ) {
           bind(  function_to_bind ); }
           // for efficiency,   prevent creation of a temporary
           void operator = (  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3 )  ) {
           bind(  function_to_bind ); }
           inline void bind(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3 ) ) {
           m_Closure.bindstaticfunc(  this,   &FastDelegate3::InvokeStaticFunction,  
           function_to_bind ); }
           // Invoke the delegate
           RetType operator(   ) (  Param1 p1,   Param2 p2,   Param3 p3 ) const {
           return (  m_Closure.GetClosureThis(   )->*(  m_Closure.GetClosureMemPtr(   ) ) )(  p1,   p2,   p3 ); }
           // Implicit conversion to "bool" using the safe_bool idiom
          private:
           typedef struct SafeBoolStruct {
           int a_data_pointer_to_this_is_0_on_buggy_compilers;
           StaticFunctionPtr m_nonzero;
           } UselessTypedef;
           typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
          public:
           operator unspecified_bool_type(   ) const {
           return empty(   )? 0: &SafeBoolStruct::m_nonzero;
           }
           // necessary to allow ==0 to work despite the safe_bool idiom
           inline bool operator==(  StaticFunctionPtr funcptr ) {
           return m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator!=(  StaticFunctionPtr funcptr ) {
           return !m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator ! (   ) const { // Is it bound to anything?
           return !m_Closure; }
           inline bool empty(   ) const {
           return !m_Closure; }
           void clear(   ) { m_Closure.clear(   );}
           // Conversion to and from the DelegateMemento storage class
           const DelegateMemento & GetMemento(   ) { return m_Closure; }
           void SetMemento(  const DelegateMemento &any ) { m_Closure.CopyFrom(  this,   any ); }
          
          private: // Invoker for static functions
           RetType InvokeStaticFunction(  Param1 p1,   Param2 p2,   Param3 p3 ) const {
           return (  *(  m_Closure.GetStaticFunction(   ) ) )(  p1,   p2,   p3 ); }
          };
          
          //N=4
          template<class Param1,   class Param2,   class Param3,   class Param4,   class RetType=detail::DefaultVoid>
          class FastDelegate4 {
          private:
           typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
           typedef DesiredRetType (  *StaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 );
           typedef RetType (  *UnvoidStaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 );
           typedef RetType (  detail::GenericClass::*GenericMemFn )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 );
           typedef detail::ClosurePtr<GenericMemFn,   StaticFunctionPtr,   UnvoidStaticFunctionPtr> ClosureType;
           ClosureType m_Closure;
          public:
           // Typedefs to aid generic programming
           typedef FastDelegate4 type;
          
           // Construction and comparison functions
           FastDelegate4(   ) { clear(   ); }
           FastDelegate4(  const FastDelegate4 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           void operator = (  const FastDelegate4 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           bool operator ==(  const FastDelegate4 &x ) const {
           return m_Closure.IsEqual(  x.m_Closure ); }
           bool operator !=(  const FastDelegate4 &x ) const {
           return !m_Closure.IsEqual(  x.m_Closure ); }
           bool operator <(  const FastDelegate4 &x ) const {
           return m_Closure.IsLess(  x.m_Closure ); }
           bool operator >(  const FastDelegate4 &x ) const {
           return x.m_Closure.IsLess(  m_Closure ); }
           // Binding to non-const member functions
           template < class X,   class Y >
           FastDelegate4(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 )  ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 ) ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           // Binding to const member functions.
           template < class X,   class Y >
           FastDelegate4(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X *>(  pthis ),   function_to_bind ); }
           // Static functions. We convert them into a member function call.
           // This constructor also provides implicit conversion
           FastDelegate4(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 )  ) {
           bind(  function_to_bind ); }
           // for efficiency,   prevent creation of a temporary
           void operator = (  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 )  ) {
           bind(  function_to_bind ); }
           inline void bind(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 ) ) {
           m_Closure.bindstaticfunc(  this,   &FastDelegate4::InvokeStaticFunction,  
           function_to_bind ); }
           // Invoke the delegate
           RetType operator(   ) (  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 ) const {
           return (  m_Closure.GetClosureThis(   )->*(  m_Closure.GetClosureMemPtr(   ) ) )(  p1,   p2,   p3,   p4 ); }
           // Implicit conversion to "bool" using the safe_bool idiom
          private:
           typedef struct SafeBoolStruct {
           int a_data_pointer_to_this_is_0_on_buggy_compilers;
           StaticFunctionPtr m_nonzero;
           } UselessTypedef;
           typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
          public:
           operator unspecified_bool_type(   ) const {
           return empty(   )? 0: &SafeBoolStruct::m_nonzero;
           }
           // necessary to allow ==0 to work despite the safe_bool idiom
           inline bool operator==(  StaticFunctionPtr funcptr ) {
           return m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator!=(  StaticFunctionPtr funcptr ) {
           return !m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator ! (   ) const { // Is it bound to anything?
           return !m_Closure; }
           inline bool empty(   ) const {
           return !m_Closure; }
           void clear(   ) { m_Closure.clear(   );}
           // Conversion to and from the DelegateMemento storage class
           const DelegateMemento & GetMemento(   ) { return m_Closure; }
           void SetMemento(  const DelegateMemento &any ) { m_Closure.CopyFrom(  this,   any ); }
          
          private: // Invoker for static functions
           RetType InvokeStaticFunction(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 ) const {
           return (  *(  m_Closure.GetStaticFunction(   ) ) )(  p1,   p2,   p3,   p4 ); }
          };
          
          //N=5
          template<class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class RetType=detail::DefaultVoid>
          class FastDelegate5 {
          private:
           typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
           typedef DesiredRetType (  *StaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 );
           typedef RetType (  *UnvoidStaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 );
           typedef RetType (  detail::GenericClass::*GenericMemFn )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 );
           typedef detail::ClosurePtr<GenericMemFn,   StaticFunctionPtr,   UnvoidStaticFunctionPtr> ClosureType;
           ClosureType m_Closure;
          public:
           // Typedefs to aid generic programming
           typedef FastDelegate5 type;
          
           // Construction and comparison functions
           FastDelegate5(   ) { clear(   ); }
           FastDelegate5(  const FastDelegate5 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           void operator = (  const FastDelegate5 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           bool operator ==(  const FastDelegate5 &x ) const {
           return m_Closure.IsEqual(  x.m_Closure ); }
           bool operator !=(  const FastDelegate5 &x ) const {
           return !m_Closure.IsEqual(  x.m_Closure ); }
           bool operator <(  const FastDelegate5 &x ) const {
           return m_Closure.IsLess(  x.m_Closure ); }
           bool operator >(  const FastDelegate5 &x ) const {
           return x.m_Closure.IsLess(  m_Closure ); }
           // Binding to non-const member functions
           template < class X,   class Y >
           FastDelegate5(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 )  ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 ) ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           // Binding to const member functions.
           template < class X,   class Y >
           FastDelegate5(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X *>(  pthis ),   function_to_bind ); }
           // Static functions. We convert them into a member function call.
           // This constructor also provides implicit conversion
           FastDelegate5(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 )  ) {
           bind(  function_to_bind ); }
           // for efficiency,   prevent creation of a temporary
           void operator = (  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 )  ) {
           bind(  function_to_bind ); }
           inline void bind(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 ) ) {
           m_Closure.bindstaticfunc(  this,   &FastDelegate5::InvokeStaticFunction,  
           function_to_bind ); }
           // Invoke the delegate
           RetType operator(   ) (  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 ) const {
           return (  m_Closure.GetClosureThis(   )->*(  m_Closure.GetClosureMemPtr(   ) ) )(  p1,   p2,   p3,   p4,   p5 ); }
           // Implicit conversion to "bool" using the safe_bool idiom
          private:
           typedef struct SafeBoolStruct {
           int a_data_pointer_to_this_is_0_on_buggy_compilers;
           StaticFunctionPtr m_nonzero;
           } UselessTypedef;
           typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
          public:
           operator unspecified_bool_type(   ) const {
           return empty(   )? 0: &SafeBoolStruct::m_nonzero;
           }
           // necessary to allow ==0 to work despite the safe_bool idiom
           inline bool operator==(  StaticFunctionPtr funcptr ) {
           return m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator!=(  StaticFunctionPtr funcptr ) {
           return !m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator ! (   ) const { // Is it bound to anything?
           return !m_Closure; }
           inline bool empty(   ) const {
           return !m_Closure; }
           void clear(   ) { m_Closure.clear(   );}
           // Conversion to and from the DelegateMemento storage class
           const DelegateMemento & GetMemento(   ) { return m_Closure; }
           void SetMemento(  const DelegateMemento &any ) { m_Closure.CopyFrom(  this,   any ); }
          
          private: // Invoker for static functions
           RetType InvokeStaticFunction(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 ) const {
           return (  *(  m_Closure.GetStaticFunction(   ) ) )(  p1,   p2,   p3,   p4,   p5 ); }
          };
          
          //N=6
          template<class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class RetType=detail::DefaultVoid>
          class FastDelegate6 {
          private:
           typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
           typedef DesiredRetType (  *StaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 );
           typedef RetType (  *UnvoidStaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 );
           typedef RetType (  detail::GenericClass::*GenericMemFn )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 );
           typedef detail::ClosurePtr<GenericMemFn,   StaticFunctionPtr,   UnvoidStaticFunctionPtr> ClosureType;
           ClosureType m_Closure;
          public:
           // Typedefs to aid generic programming
           typedef FastDelegate6 type;
          
           // Construction and comparison functions
           FastDelegate6(   ) { clear(   ); }
           FastDelegate6(  const FastDelegate6 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           void operator = (  const FastDelegate6 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           bool operator ==(  const FastDelegate6 &x ) const {
           return m_Closure.IsEqual(  x.m_Closure ); }
           bool operator !=(  const FastDelegate6 &x ) const {
           return !m_Closure.IsEqual(  x.m_Closure ); }
           bool operator <(  const FastDelegate6 &x ) const {
           return m_Closure.IsLess(  x.m_Closure ); }
           bool operator >(  const FastDelegate6 &x ) const {
           return x.m_Closure.IsLess(  m_Closure ); }
           // Binding to non-const member functions
           template < class X,   class Y >
           FastDelegate6(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 )  ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 ) ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           // Binding to const member functions.
           template < class X,   class Y >
           FastDelegate6(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X *>(  pthis ),   function_to_bind ); }
           // Static functions. We convert them into a member function call.
           // This constructor also provides implicit conversion
           FastDelegate6(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 )  ) {
           bind(  function_to_bind ); }
           // for efficiency,   prevent creation of a temporary
           void operator = (  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 )  ) {
           bind(  function_to_bind ); }
           inline void bind(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 ) ) {
           m_Closure.bindstaticfunc(  this,   &FastDelegate6::InvokeStaticFunction,  
           function_to_bind ); }
           // Invoke the delegate
           RetType operator(   ) (  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 ) const {
           return (  m_Closure.GetClosureThis(   )->*(  m_Closure.GetClosureMemPtr(   ) ) )(  p1,   p2,   p3,   p4,   p5,   p6 ); }
           // Implicit conversion to "bool" using the safe_bool idiom
          private:
           typedef struct SafeBoolStruct {
           int a_data_pointer_to_this_is_0_on_buggy_compilers;
           StaticFunctionPtr m_nonzero;
           } UselessTypedef;
           typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
          public:
           operator unspecified_bool_type(   ) const {
           return empty(   )? 0: &SafeBoolStruct::m_nonzero;
           }
           // necessary to allow ==0 to work despite the safe_bool idiom
           inline bool operator==(  StaticFunctionPtr funcptr ) {
           return m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator!=(  StaticFunctionPtr funcptr ) {
           return !m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator ! (   ) const { // Is it bound to anything?
           return !m_Closure; }
           inline bool empty(   ) const {
           return !m_Closure; }
           void clear(   ) { m_Closure.clear(   );}
           // Conversion to and from the DelegateMemento storage class
           const DelegateMemento & GetMemento(   ) { return m_Closure; }
           void SetMemento(  const DelegateMemento &any ) { m_Closure.CopyFrom(  this,   any ); }
          
          private: // Invoker for static functions
           RetType InvokeStaticFunction(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 ) const {
           return (  *(  m_Closure.GetStaticFunction(   ) ) )(  p1,   p2,   p3,   p4,   p5,   p6 ); }
          };
          
          //N=7
          template<class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class Param7,   class RetType=detail::DefaultVoid>
          class FastDelegate7 {
          private:
           typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
           typedef DesiredRetType (  *StaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 );
           typedef RetType (  *UnvoidStaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 );
           typedef RetType (  detail::GenericClass::*GenericMemFn )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 );
           typedef detail::ClosurePtr<GenericMemFn,   StaticFunctionPtr,   UnvoidStaticFunctionPtr> ClosureType;
           ClosureType m_Closure;
          public:
           // Typedefs to aid generic programming
           typedef FastDelegate7 type;
          
           // Construction and comparison functions
           FastDelegate7(   ) { clear(   ); }
           FastDelegate7(  const FastDelegate7 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           void operator = (  const FastDelegate7 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           bool operator ==(  const FastDelegate7 &x ) const {
           return m_Closure.IsEqual(  x.m_Closure ); }
           bool operator !=(  const FastDelegate7 &x ) const {
           return !m_Closure.IsEqual(  x.m_Closure ); }
           bool operator <(  const FastDelegate7 &x ) const {
           return m_Closure.IsLess(  x.m_Closure ); }
           bool operator >(  const FastDelegate7 &x ) const {
           return x.m_Closure.IsLess(  m_Closure ); }
           // Binding to non-const member functions
           template < class X,   class Y >
           FastDelegate7(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 )  ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 ) ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           // Binding to const member functions.
           template < class X,   class Y >
           FastDelegate7(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X *>(  pthis ),   function_to_bind ); }
           // Static functions. We convert them into a member function call.
           // This constructor also provides implicit conversion
           FastDelegate7(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 )  ) {
           bind(  function_to_bind ); }
           // for efficiency,   prevent creation of a temporary
           void operator = (  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 )  ) {
           bind(  function_to_bind ); }
           inline void bind(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 ) ) {
           m_Closure.bindstaticfunc(  this,   &FastDelegate7::InvokeStaticFunction,  
           function_to_bind ); }
           // Invoke the delegate
           RetType operator(   ) (  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 ) const {
           return (  m_Closure.GetClosureThis(   )->*(  m_Closure.GetClosureMemPtr(   ) ) )(  p1,   p2,   p3,   p4,   p5,   p6,   p7 ); }
           // Implicit conversion to "bool" using the safe_bool idiom
          private:
           typedef struct SafeBoolStruct {
           int a_data_pointer_to_this_is_0_on_buggy_compilers;
           StaticFunctionPtr m_nonzero;
           } UselessTypedef;
           typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
          public:
           operator unspecified_bool_type(   ) const {
           return empty(   )? 0: &SafeBoolStruct::m_nonzero;
           }
           // necessary to allow ==0 to work despite the safe_bool idiom
           inline bool operator==(  StaticFunctionPtr funcptr ) {
           return m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator!=(  StaticFunctionPtr funcptr ) {
           return !m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator ! (   ) const { // Is it bound to anything?
           return !m_Closure; }
           inline bool empty(   ) const {
           return !m_Closure; }
           void clear(   ) { m_Closure.clear(   );}
           // Conversion to and from the DelegateMemento storage class
           const DelegateMemento & GetMemento(   ) { return m_Closure; }
           void SetMemento(  const DelegateMemento &any ) { m_Closure.CopyFrom(  this,   any ); }
          
          private: // Invoker for static functions
           RetType InvokeStaticFunction(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 ) const {
           return (  *(  m_Closure.GetStaticFunction(   ) ) )(  p1,   p2,   p3,   p4,   p5,   p6,   p7 ); }
          };
          
          //N=8
          template<class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class Param7,   class Param8,   class RetType=detail::DefaultVoid>
          class FastDelegate8 {
          private:
           typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
           typedef DesiredRetType (  *StaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 );
           typedef RetType (  *UnvoidStaticFunctionPtr )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 );
           typedef RetType (  detail::GenericClass::*GenericMemFn )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 );
           typedef detail::ClosurePtr<GenericMemFn,   StaticFunctionPtr,   UnvoidStaticFunctionPtr> ClosureType;
           ClosureType m_Closure;
          public:
           // Typedefs to aid generic programming
           typedef FastDelegate8 type;
          
           // Construction and comparison functions
           FastDelegate8(   ) { clear(   ); }
           FastDelegate8(  const FastDelegate8 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           void operator = (  const FastDelegate8 &x ) {
           m_Closure.CopyFrom(  this,   x.m_Closure ); }
           bool operator ==(  const FastDelegate8 &x ) const {
           return m_Closure.IsEqual(  x.m_Closure ); }
           bool operator !=(  const FastDelegate8 &x ) const {
           return !m_Closure.IsEqual(  x.m_Closure ); }
           bool operator <(  const FastDelegate8 &x ) const {
           return m_Closure.IsLess(  x.m_Closure ); }
           bool operator >(  const FastDelegate8 &x ) const {
           return x.m_Closure.IsLess(  m_Closure ); }
           // Binding to non-const member functions
           template < class X,   class Y >
           FastDelegate8(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 )  ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 ) ) {
           m_Closure.bindmemfunc(  detail::implicit_cast<X*>(  pthis ),   function_to_bind ); }
           // Binding to const member functions.
           template < class X,   class Y >
           FastDelegate8(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X*>(  pthis ),   function_to_bind ); }
           template < class X,   class Y >
           inline void bind(  const Y *pthis,   DesiredRetType (  X::* function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 ) const ) {
           m_Closure.bindconstmemfunc(  detail::implicit_cast<const X *>(  pthis ),   function_to_bind ); }
           // Static functions. We convert them into a member function call.
           // This constructor also provides implicit conversion
           FastDelegate8(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 )  ) {
           bind(  function_to_bind ); }
           // for efficiency,   prevent creation of a temporary
           void operator = (  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 )  ) {
           bind(  function_to_bind ); }
           inline void bind(  DesiredRetType (  *function_to_bind )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 ) ) {
           m_Closure.bindstaticfunc(  this,   &FastDelegate8::InvokeStaticFunction,  
           function_to_bind ); }
           // Invoke the delegate
           RetType operator(   ) (  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 ) const {
           return (  m_Closure.GetClosureThis(   )->*(  m_Closure.GetClosureMemPtr(   ) ) )(  p1,   p2,   p3,   p4,   p5,   p6,   p7,   p8 ); }
           // Implicit conversion to "bool" using the safe_bool idiom
          private:
           typedef struct SafeBoolStruct {
           int a_data_pointer_to_this_is_0_on_buggy_compilers;
           StaticFunctionPtr m_nonzero;
           } UselessTypedef;
           typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
          public:
           operator unspecified_bool_type(   ) const {
           return empty(   )? 0: &SafeBoolStruct::m_nonzero;
           }
           // necessary to allow ==0 to work despite the safe_bool idiom
           inline bool operator==(  StaticFunctionPtr funcptr ) {
           return m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator!=(  StaticFunctionPtr funcptr ) {
           return !m_Closure.IsEqualToStaticFuncPtr(  funcptr ); }
           inline bool operator ! (   ) const { // Is it bound to anything?
           return !m_Closure; }
           inline bool empty(   ) const {
           return !m_Closure; }
           void clear(   ) { m_Closure.clear(   );}
           // Conversion to and from the DelegateMemento storage class
           const DelegateMemento & GetMemento(   ) { return m_Closure; }
           void SetMemento(  const DelegateMemento &any ) { m_Closure.CopyFrom(  this,   any ); }
          
          private: // Invoker for static functions
           RetType InvokeStaticFunction(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 ) const {
           return (  *(  m_Closure.GetStaticFunction(   ) ) )(  p1,   p2,   p3,   p4,   p5,   p6,   p7,   p8 ); }
          };
          
          
          ////////////////////////////////////////////////////////////////////////////////
          // Fast Delegates,   part 4:
          //
          // FastDelegate<> class (  Original author: Jody Hagins )
          // Allows boost::function style syntax like:
          // FastDelegate< double (  int,   long ) >
          // instead of:
          // FastDelegate2< int,   long,   double >
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          #ifdef FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
          
          // Declare FastDelegate as a class template. It will be specialized
          // later for all number of arguments.
          template <typename Signature>
          class FastDelegate;
          
          //N=0
          // Specialization to allow use of
          // FastDelegate< R (    ) >
          // instead of
          // FastDelegate0 < R >
          template<typename R>
          class FastDelegate< R (    ) >
           // Inherit from FastDelegate0 so that it can be treated just like a FastDelegate0
           : public FastDelegate0 < R >
          {
          public:
           // Make using the base type a bit easier via typedef.
           typedef FastDelegate0 < R > BaseType;
          
           // Allow users access to the specific type of this delegate.
           typedef FastDelegate SelfType;
          
           // Mimic the base class constructors.
           FastDelegate(   ) : BaseType(   ) { }
          
           template < class X,   class Y >
           FastDelegate(  Y * pthis,  
           R (  X::* function_to_bind )(    ) )
           : BaseType(  pthis,   function_to_bind ) { }
          
           template < class X,   class Y >
           FastDelegate(  const Y *pthis,  
           R (  X::* function_to_bind )(    ) const )
           : BaseType(  pthis,   function_to_bind )
           { }
          
           FastDelegate(  R (  *function_to_bind )(    ) )
           : BaseType(  function_to_bind ) { }
           void operator = (  const BaseType &x ) {
           *static_cast<BaseType*>(  this ) = x; }
          };
          
          //N=1
          // Specialization to allow use of
          // FastDelegate< R (   Param1  ) >
          // instead of
          // FastDelegate1 < Param1,   R >
          template<typename R,   class Param1>
          class FastDelegate< R (   Param1  ) >
           // Inherit from FastDelegate1 so that it can be treated just like a FastDelegate1
           : public FastDelegate1 < Param1,   R >
          {
          public:
           // Make using the base type a bit easier via typedef.
           typedef FastDelegate1 < Param1,   R > BaseType;
          
           // Allow users access to the specific type of this delegate.
           typedef FastDelegate SelfType;
          
           // Mimic the base class constructors.
           FastDelegate(   ) : BaseType(   ) { }
          
           template < class X,   class Y >
           FastDelegate(  Y * pthis,  
           R (  X::* function_to_bind )(   Param1 p1  ) )
           : BaseType(  pthis,   function_to_bind ) { }
          
           template < class X,   class Y >
           FastDelegate(  const Y *pthis,  
           R (  X::* function_to_bind )(   Param1 p1  ) const )
           : BaseType(  pthis,   function_to_bind )
           { }
          
           FastDelegate(  R (  *function_to_bind )(   Param1 p1  ) )
           : BaseType(  function_to_bind ) { }
           void operator = (  const BaseType &x ) {
           *static_cast<BaseType*>(  this ) = x; }
          };
          
          //N=2
          // Specialization to allow use of
          // FastDelegate< R (   Param1,   Param2  ) >
          // instead of
          // FastDelegate2 < Param1,   Param2,   R >
          template<typename R,   class Param1,   class Param2>
          class FastDelegate< R (   Param1,   Param2  ) >
           // Inherit from FastDelegate2 so that it can be treated just like a FastDelegate2
           : public FastDelegate2 < Param1,   Param2,   R >
          {
          public:
           // Make using the base type a bit easier via typedef.
           typedef FastDelegate2 < Param1,   Param2,   R > BaseType;
          
           // Allow users access to the specific type of this delegate.
           typedef FastDelegate SelfType;
          
           // Mimic the base class constructors.
           FastDelegate(   ) : BaseType(   ) { }
          
           template < class X,   class Y >
           FastDelegate(  Y * pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2  ) )
           : BaseType(  pthis,   function_to_bind ) { }
          
           template < class X,   class Y >
           FastDelegate(  const Y *pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2  ) const )
           : BaseType(  pthis,   function_to_bind )
           { }
          
           FastDelegate(  R (  *function_to_bind )(   Param1 p1,   Param2 p2  ) )
           : BaseType(  function_to_bind ) { }
           void operator = (  const BaseType &x ) {
           *static_cast<BaseType*>(  this ) = x; }
          };
          
          //N=3
          // Specialization to allow use of
          // FastDelegate< R (   Param1,   Param2,   Param3  ) >
          // instead of
          // FastDelegate3 < Param1,   Param2,   Param3,   R >
          template<typename R,   class Param1,   class Param2,   class Param3>
          class FastDelegate< R (   Param1,   Param2,   Param3  ) >
           // Inherit from FastDelegate3 so that it can be treated just like a FastDelegate3
           : public FastDelegate3 < Param1,   Param2,   Param3,   R >
          {
          public:
           // Make using the base type a bit easier via typedef.
           typedef FastDelegate3 < Param1,   Param2,   Param3,   R > BaseType;
          
           // Allow users access to the specific type of this delegate.
           typedef FastDelegate SelfType;
          
           // Mimic the base class constructors.
           FastDelegate(   ) : BaseType(   ) { }
          
           template < class X,   class Y >
           FastDelegate(  Y * pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3  ) )
           : BaseType(  pthis,   function_to_bind ) { }
          
           template < class X,   class Y >
           FastDelegate(  const Y *pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3  ) const )
           : BaseType(  pthis,   function_to_bind )
           { }
          
           FastDelegate(  R (  *function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3  ) )
           : BaseType(  function_to_bind ) { }
           void operator = (  const BaseType &x ) {
           *static_cast<BaseType*>(  this ) = x; }
          };
          
          //N=4
          // Specialization to allow use of
          // FastDelegate< R (   Param1,   Param2,   Param3,   Param4  ) >
          // instead of
          // FastDelegate4 < Param1,   Param2,   Param3,   Param4,   R >
          template<typename R,   class Param1,   class Param2,   class Param3,   class Param4>
          class FastDelegate< R (   Param1,   Param2,   Param3,   Param4  ) >
           // Inherit from FastDelegate4 so that it can be treated just like a FastDelegate4
           : public FastDelegate4 < Param1,   Param2,   Param3,   Param4,   R >
          {
          public:
           // Make using the base type a bit easier via typedef.
           typedef FastDelegate4 < Param1,   Param2,   Param3,   Param4,   R > BaseType;
          
           // Allow users access to the specific type of this delegate.
           typedef FastDelegate SelfType;
          
           // Mimic the base class constructors.
           FastDelegate(   ) : BaseType(   ) { }
          
           template < class X,   class Y >
           FastDelegate(  Y * pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4  ) )
           : BaseType(  pthis,   function_to_bind ) { }
          
           template < class X,   class Y >
           FastDelegate(  const Y *pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4  ) const )
           : BaseType(  pthis,   function_to_bind )
           { }
          
           FastDelegate(  R (  *function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4  ) )
           : BaseType(  function_to_bind ) { }
           void operator = (  const BaseType &x ) {
           *static_cast<BaseType*>(  this ) = x; }
          };
          
          //N=5
          // Specialization to allow use of
          // FastDelegate< R (   Param1,   Param2,   Param3,   Param4,   Param5  ) >
          // instead of
          // FastDelegate5 < Param1,   Param2,   Param3,   Param4,   Param5,   R >
          template<typename R,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5>
          class FastDelegate< R (   Param1,   Param2,   Param3,   Param4,   Param5  ) >
           // Inherit from FastDelegate5 so that it can be treated just like a FastDelegate5
           : public FastDelegate5 < Param1,   Param2,   Param3,   Param4,   Param5,   R >
          {
          public:
           // Make using the base type a bit easier via typedef.
           typedef FastDelegate5 < Param1,   Param2,   Param3,   Param4,   Param5,   R > BaseType;
          
           // Allow users access to the specific type of this delegate.
           typedef FastDelegate SelfType;
          
           // Mimic the base class constructors.
           FastDelegate(   ) : BaseType(   ) { }
          
           template < class X,   class Y >
           FastDelegate(  Y * pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5  ) )
           : BaseType(  pthis,   function_to_bind ) { }
          
           template < class X,   class Y >
           FastDelegate(  const Y *pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5  ) const )
           : BaseType(  pthis,   function_to_bind )
           { }
          
           FastDelegate(  R (  *function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5  ) )
           : BaseType(  function_to_bind ) { }
           void operator = (  const BaseType &x ) {
           *static_cast<BaseType*>(  this ) = x; }
          };
          
          //N=6
          // Specialization to allow use of
          // FastDelegate< R (   Param1,   Param2,   Param3,   Param4,   Param5,   Param6  ) >
          // instead of
          // FastDelegate6 < Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   R >
          template<typename R,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6>
          class FastDelegate< R (   Param1,   Param2,   Param3,   Param4,   Param5,   Param6  ) >
           // Inherit from FastDelegate6 so that it can be treated just like a FastDelegate6
           : public FastDelegate6 < Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   R >
          {
          public:
           // Make using the base type a bit easier via typedef.
           typedef FastDelegate6 < Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   R > BaseType;
          
           // Allow users access to the specific type of this delegate.
           typedef FastDelegate SelfType;
          
           // Mimic the base class constructors.
           FastDelegate(   ) : BaseType(   ) { }
          
           template < class X,   class Y >
           FastDelegate(  Y * pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6  ) )
           : BaseType(  pthis,   function_to_bind ) { }
          
           template < class X,   class Y >
           FastDelegate(  const Y *pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6  ) const )
           : BaseType(  pthis,   function_to_bind )
           { }
          
           FastDelegate(  R (  *function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6  ) )
           : BaseType(  function_to_bind ) { }
           void operator = (  const BaseType &x ) {
           *static_cast<BaseType*>(  this ) = x; }
          };
          
          //N=7
          // Specialization to allow use of
          // FastDelegate< R (   Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7  ) >
          // instead of
          // FastDelegate7 < Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   R >
          template<typename R,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class Param7>
          class FastDelegate< R (   Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7  ) >
           // Inherit from FastDelegate7 so that it can be treated just like a FastDelegate7
           : public FastDelegate7 < Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   R >
          {
          public:
           // Make using the base type a bit easier via typedef.
           typedef FastDelegate7 < Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   R > BaseType;
          
           // Allow users access to the specific type of this delegate.
           typedef FastDelegate SelfType;
          
           // Mimic the base class constructors.
           FastDelegate(   ) : BaseType(   ) { }
          
           template < class X,   class Y >
           FastDelegate(  Y * pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7  ) )
           : BaseType(  pthis,   function_to_bind ) { }
          
           template < class X,   class Y >
           FastDelegate(  const Y *pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7  ) const )
           : BaseType(  pthis,   function_to_bind )
           { }
          
           FastDelegate(  R (  *function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7  ) )
           : BaseType(  function_to_bind ) { }
           void operator = (  const BaseType &x ) {
           *static_cast<BaseType*>(  this ) = x; }
          };
          
          //N=8
          // Specialization to allow use of
          // FastDelegate< R (   Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   Param8  ) >
          // instead of
          // FastDelegate8 < Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   Param8,   R >
          template<typename R,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class Param7,   class Param8>
          class FastDelegate< R (   Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   Param8  ) >
           // Inherit from FastDelegate8 so that it can be treated just like a FastDelegate8
           : public FastDelegate8 < Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   Param8,   R >
          {
          public:
           // Make using the base type a bit easier via typedef.
           typedef FastDelegate8 < Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   Param8,   R > BaseType;
          
           // Allow users access to the specific type of this delegate.
           typedef FastDelegate SelfType;
          
           // Mimic the base class constructors.
           FastDelegate(   ) : BaseType(   ) { }
          
           template < class X,   class Y >
           FastDelegate(  Y * pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8  ) )
           : BaseType(  pthis,   function_to_bind ) { }
          
           template < class X,   class Y >
           FastDelegate(  const Y *pthis,  
           R (  X::* function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8  ) const )
           : BaseType(  pthis,   function_to_bind )
           { }
          
           FastDelegate(  R (  *function_to_bind )(   Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8  ) )
           : BaseType(  function_to_bind ) { }
           void operator = (  const BaseType &x ) {
           *static_cast<BaseType*>(  this ) = x; }
          };
          
          
          #endif //FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
          
          ////////////////////////////////////////////////////////////////////////////////
          // Fast Delegates,   part 5:
          //
          // MakeDelegate(   ) helper function
          //
          // MakeDelegate(  &x,   &X::func ) returns a fastdelegate of the type
          // necessary for calling x.func(   ) with the correct number of arguments.
          // This makes it possible to eliminate many typedefs from user code.
          //
          ////////////////////////////////////////////////////////////////////////////////
          
          // Also declare overloads of a MakeDelegate(   ) global function to
          // reduce the need for typedefs.
          // We need seperate overloads for const and non-const member functions.
          // Also,   because of the weird rule about the class of derived member function pointers,  
          // implicit downcasts may need to be applied later to the 'this' pointer.
          // That's why two classes (  X and Y ) appear in the definitions. Y must be implicitly
          // castable to X.
          
          // Workaround for VC6. VC6 needs void return types converted into DefaultVoid.
          // GCC 3.2 and later won't compile this unless it's preceded by 'typename',  
          // but VC6 doesn't allow 'typename' in this context.
          // So,   I have to use a macro.
          
          #ifdef FASTDLGT_VC6
          #define FASTDLGT_RETTYPE detail::VoidToDefaultVoid<RetType>::type
          #else
          #define FASTDLGT_RETTYPE RetType
          #endif
          
          //N=0
          template <class X,   class Y,   class RetType>
          FastDelegate0<FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(   ) ) {
           return FastDelegate0<FASTDLGT_RETTYPE>(  x,   func );
          }
          
          template <class X,   class Y,   class RetType>
          FastDelegate0<FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(   ) const ) {
           return FastDelegate0<FASTDLGT_RETTYPE>(  x,   func );
          }
          
          //N=1
          template <class X,   class Y,   class Param1,   class RetType>
          FastDelegate1<Param1,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1 ) ) {
           return FastDelegate1<Param1,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          template <class X,   class Y,   class Param1,   class RetType>
          FastDelegate1<Param1,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1 ) const ) {
           return FastDelegate1<Param1,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          //N=2
          template <class X,   class Y,   class Param1,   class Param2,   class RetType>
          FastDelegate2<Param1,   Param2,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2 ) ) {
           return FastDelegate2<Param1,   Param2,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          template <class X,   class Y,   class Param1,   class Param2,   class RetType>
          FastDelegate2<Param1,   Param2,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2 ) const ) {
           return FastDelegate2<Param1,   Param2,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          //N=3
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class RetType>
          FastDelegate3<Param1,   Param2,   Param3,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3 ) ) {
           return FastDelegate3<Param1,   Param2,   Param3,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class RetType>
          FastDelegate3<Param1,   Param2,   Param3,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3 ) const ) {
           return FastDelegate3<Param1,   Param2,   Param3,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          //N=4
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class RetType>
          FastDelegate4<Param1,   Param2,   Param3,   Param4,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 ) ) {
           return FastDelegate4<Param1,   Param2,   Param3,   Param4,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class RetType>
          FastDelegate4<Param1,   Param2,   Param3,   Param4,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4 ) const ) {
           return FastDelegate4<Param1,   Param2,   Param3,   Param4,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          //N=5
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class RetType>
          FastDelegate5<Param1,   Param2,   Param3,   Param4,   Param5,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 ) ) {
           return FastDelegate5<Param1,   Param2,   Param3,   Param4,   Param5,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class RetType>
          FastDelegate5<Param1,   Param2,   Param3,   Param4,   Param5,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5 ) const ) {
           return FastDelegate5<Param1,   Param2,   Param3,   Param4,   Param5,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          //N=6
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class RetType>
          FastDelegate6<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 ) ) {
           return FastDelegate6<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class RetType>
          FastDelegate6<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6 ) const ) {
           return FastDelegate6<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          //N=7
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class Param7,   class RetType>
          FastDelegate7<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 ) ) {
           return FastDelegate7<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class Param7,   class RetType>
          FastDelegate7<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7 ) const ) {
           return FastDelegate7<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          //N=8
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class Param7,   class Param8,   class RetType>
          FastDelegate8<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   Param8,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 ) ) {
           return FastDelegate8<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   Param8,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          template <class X,   class Y,   class Param1,   class Param2,   class Param3,   class Param4,   class Param5,   class Param6,   class Param7,   class Param8,   class RetType>
          FastDelegate8<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   Param8,   FASTDLGT_RETTYPE> MakeDelegate(  Y* x,   RetType (  X::*func )(  Param1 p1,   Param2 p2,   Param3 p3,   Param4 p4,   Param5 p5,   Param6 p6,   Param7 p7,   Param8 p8 ) const ) {
           return FastDelegate8<Param1,   Param2,   Param3,   Param4,   Param5,   Param6,   Param7,   Param8,   FASTDLGT_RETTYPE>(  x,   func );
          }
          
          
           // clean up after ourselves...
          #undef FASTDLGT_RETTYPE
          
          } // namespace fastdelegate
          
          #endif // !defined(  FASTDELEGATE_H )
          

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeCamera.h

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright © 2000-2004 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          PagingLandScapeCamera.h - description
          -------------------
          begin : Fri Sep 27 2004
          copyright : (  C ) 2006 by Tuan Kuranes
          email : tuan.kuranes@free.fr
          
          ***************************************************************************/
          
          #ifndef PagingLandScapeCamera_H
          #define PagingLandScapeCamera_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeCamera.h"
          
          namespace Ogre
          {
           /** Specialized viewpoint from which an part of LandScape can be rendered.
           @remarks
           This class contains several specializations of the Ogre::Camera class. It
           implements the getRenderOperation method in order to return displayable geometry
           for debugging purposes. It also implements a visibility function that is more granular
           than the default.
           */
      49   class PagingLandScapeCamera : public PagingLandScapeOctreeCamera
           {
      51   friend class PagingLandScapePageManager;
          
           public:
          
           /* Standard Constructor */
      56   PagingLandScapeCamera(  const String& name,   SceneManager* sm );
           /* Standard destructor */
      58   ~PagingLandScapeCamera(  void );
          
           /** Returns the visibility of the box
           */
      62   bool isVisible(  const AxisAlignedBox &bounds ) const;
          
      64   void updatePaging(  const unsigned int x,   const unsigned int z );
          
      66   void resetPaging(  void );
          
           unsigned int mCurrentCameraPageX;
           unsigned int mCurrentCameraPageZ;
          
           unsigned int mCurrentCameraTileX;
           unsigned int mCurrentCameraTileZ;
          
           private:
           unsigned int mIniX;
           unsigned int mFinX;
          
           unsigned int mIniZ;
           unsigned int mFinZ;
          
           unsigned int mPreIniX;
           unsigned int mPreFinX;
          
           unsigned int mPreIniZ;
           unsigned int mPreFinZ;
          
      87   Vector3 mLastCameraPos;
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2D.h

       1  /***************************************************************************
           OgrePagingLandScapeData2D.h - description
           -------------------
           begin : Wen Mar 5 2003
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeDATA2D_H
          #define PAGINGLandScapeDATA2D_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeOptions.h"
          
          namespace Ogre
          {
           /**
           * Encapsulating 2D Data reading.
           */
      31   class PagingLandScapeData2D
           {
           public:
      34   PagingLandScapeData2D(  PagingLandScapeData2DManager *pageMgr );
          
      36   virtual ~PagingLandScapeData2D(  void );
          
      38   virtual PagingLandScapeData2D* newPage(   ) = 0;
          
      40   virtual String getName(   ) const= 0;
      41   virtual bool load(  const unsigned int mX,   const unsigned int mZ );
          
      43   virtual void load(  void );
          
      45   virtual void init(  void );
      46   virtual void uninit(  void );
          
      48   virtual void unload(  void );
          
          #ifndef _MAPSPLITTER
           /**
           * deform Height Data of the terrain.
           * \param &deformationPoint
           * Where modification is,   in world coordinates
           * \param &modificationHeight
           * What modification do to terrain
           * \param info
           * Give some info on tile to
           * help coordinate system change
           */
      61   const bool deformHeight(  const Vector3& deformationPoint,   Real &modificationHeight );
          
           /**
           *
           * deform Height Data of the terrain.
           * \param &x
           * x Position on 2d height grid
           * \param &z
           * z Position on 2d height grid
           * \param &modificationHeight
           * What modification do to terrain
           */
      73   const bool deformHeight(  const unsigned int x,   const unsigned int z,   Real &modificationHeight );
          
          
      76   bool setHeight(  const unsigned int x,   const unsigned int z,   const Real h );
      77   bool setHeight(  const unsigned int x,   const unsigned int z,   const unsigned int Pos,   const Real h );
           /**
           *
           * get smallest rectangle containing all deformation
           * done before an update. (  where rectangle is reseted. )
           *
           * \return Box struct describing rectangle
           *
           */
      86   Image::Box getDeformationRectangle(  void );
          
           /**
           *
           * Adjust smallest rectangle to make it contain the point
           * \param &x
           * x Position on 2d height grid
           * \param &z
           * z Position on 2d height grid
           */
      96   void adjustDeformationRectangle(  const unsigned int x,   const unsigned int z );
          
           /**
           *
           * Reset Deformation rectangle
           */
     102   void resetDeformationRectangle(  void );
          #endif // _MAPSPLITTER
          
     105   virtual const Vector3 getNormal(  const Real mX,   const Real mZ );
     106   virtual const ColourValue getBase(  const Real mX,   const Real mZ ) const
           {
           return ColourValue::White;
           };
          
     111   virtual const ColourValue getCoverage(  const Real mX,   const Real mZ ) const
           {
           return ColourValue::White;
           };
          
     116   virtual const Real getShadow(  const Real mX,   const Real mZ,   const bool& positive ) const
           {
           return 0.0f;
           };
           //-----------------------------------------------------------------------
     121   const Real getShiftX(   ) const
           {
           return mShiftX;
           }
           //-----------------------------------------------------------------------
     126   const Real getShiftZ(   ) const
           {
           return mShiftZ;
           }
           //-----------------------------------------------------------------------
     131   inline const Real getHeightAbsolute(  const Real x,   const Real z ) const
           {
           const Vector3 &invScale = mParent->getOptions(   )->invScale;
          
           // adjust x and z to be local to page
           int i_x = static_cast<int> (  x * invScale.x - mShiftX );
           int i_z = static_cast<int> (  z * invScale.z - mShiftZ );
          
           // due to Real imprecision on Reals,   we have to use boundaries here
           // otherwise we'll hit asserts.
           int size = static_cast<int> (  mSize-1 );
           if (  i_x > size )
           i_x = size;
           else if (  i_x < 0 )
           i_x = 0;
          
           if (  i_z > size )
           i_z = size;
           else if (  i_z < 0 )
           i_z = 0;
          
           const unsigned int u_x = static_cast<unsigned int> (  i_x );
           const unsigned int u_z = static_cast<unsigned int> (  i_z );
          
           const size_t arraypos = u_z * mSize + u_x;
           assert (  mHeightData && arraypos < mMaxArrayPos );
           return mHeightData[arraypos];
           }
          
          
     161   inline const Real getHeight(  const Real x,   const Real z ) const
           {
           assert (  z < mSize && x < mSize );
           assert (  mHeightData );
           const unsigned int Pos = static_cast< unsigned int > (  z * mSize + x );
           assert (  mMaxArrayPos > Pos );
           return mHeightData[ Pos ];
           };
          
     170   inline const Real getHeight(  const unsigned int x,   const unsigned int z ) const
           {
           assert (  mHeightData );
           assert (  z < mSize && x < mSize );
           const unsigned int Pos = static_cast <unsigned int> (  z * mSize + x );
           assert (  mMaxArrayPos > Pos );
           return mHeightData[ Pos ];
           };
          
     179   inline const Real getHeight(  const int x,   const int z ) const
           {
           assert (  mHeightData );
           assert (  static_cast< unsigned int >(  z ) < mSize && static_cast< unsigned int >(  x ) < mSize );
           const unsigned int Pos = static_cast< unsigned int >(  z * mSize + x );
           assert (  mMaxArrayPos > Pos );
           return mHeightData[ Pos ];
           };
          
     188   inline const Real getHeight(  const unsigned int pos ) const
           {
           assert (  mHeightData );
           assert (  mMaxArrayPos > pos );
           return mHeightData[ pos ];
           };
     194   inline const Real getMaxHeight(  void ) const
           {
           return mMaxheight;
           };
           // useful to know max height before data is loaded.
     199   virtual const Real getMaxAbsoluteHeight(  void ) const = 0;
          
     201   Real* getHeightData(  void )
           {
           return mHeightData;
           };
          
     206   bool isLoaded(  void ) const {return mIsLoaded;};
          
     208   void computePowerof2PlusOneSize(  void );
          
     210   virtual size_t getXDimension(  void ) const
           {
           return mXDimension;
           };
          
     215   virtual size_t getZDimension(  void ) const
           {
           return mZDimension;
           };
          
     220   virtual size_t getSize(  void ) const
           {
           return mSize;
           };
          
     225   void getCoordinates(  unsigned int& X,   unsigned int& Z ) const
           {
           X = mPageX;
           Z = mPageZ;
           };
     230   inline bool isCoord(  const unsigned int x,   const unsigned int z ) const {return (  mPageX == x && mPageZ == z );};
          
          
           protected:
     234   virtual void _save(  void ) = 0;
     235   virtual bool _load(  const unsigned int x,   const unsigned int z ) = 0;
     236   virtual void _load(  void ) = 0;
     237   virtual void _unload(  void ) = 0;
     238   bool _checkSize(  const size_t s );
          
           // computed Height Data (  scaled )
     241   Real *mHeightData;
           // maximum position in Array
           unsigned int mMaxArrayPos;
           // data side maximum size
     245   size_t mSize;
           // data source width
     247   size_t mXDimension;;
           // data source height
     249   size_t mZDimension;
           // image data maximum size
           unsigned int mMax;
           // maximum page/data2d height. (  scaled )
     253   Real mMaxheight;
           // if data loaded or not
     255   bool mIsLoaded;
          
           // if data modified or not
     258   bool mIsModified;
           // if data modified but not yet
           // readied by other objects (  texture or renderable )
           // to get modification to rect only once per frame.
     262   bool mIsRectModified;
          
           // page number
           unsigned int mPageX;
           // page number
           unsigned int mPageZ;
          
           // coordinate shift based on page number
     270   Real mShiftX;
           // coordinate shift based on page number
     272   Real mShiftZ;
     273   PagingLandScapeData2DManager *mParent;
          
           private :
     276   Image::Box mRect;
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2DManager.h

       1  /***************************************************************************
           OgrePagingLandScapeData2DManager.h - description
           -------------------
           begin : Mon Jun 16 2003
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeDATA2DMANAGER_H
          #define PAGINGLandScapeDATA2DMANAGER_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
      26   class PagingLandScapeData2DManager
           {
           public:
      29   PagingLandScapeData2DManager(  PagingLandScapeSceneManager * scnMgr,  
      30   PagingLandScapeOptions * opt  );
          
      32   ~PagingLandScapeData2DManager(  void );
          
      34   void load(  void );
      35   void clear(  void );
      36   void WorldDimensionChange(  void );
      37   void reset(  void );
          
      39   PagingLandScapeData2D* allocateData2D(   ) const;
          
      41   bool load(  const unsigned int dataX,   const unsigned int dataZ );
          
      43   bool reload(  const unsigned int dataX,   const unsigned int dataZ );
          
      45   void unload(  const unsigned int dataX,   const unsigned int dataZ );
          
      47   bool isLoaded(  const unsigned int dataX,   const unsigned int dataZ );
          
      49   const Real getHeight(  const unsigned int dataX,   const unsigned int dataZ,   const Real x,   const Real z );
          
      51   const Real getHeight(  const unsigned int dataX,   const unsigned int dataZ,   const unsigned int x,   const unsigned int z );
          
      53   const Real getHeightAtPage(  const unsigned int dataX,   const unsigned int dataZ,   const Real x,   const Real z );
          
      55   const Real getHeightAtPage(  const unsigned int dataX,   const unsigned int dataZ,   const int x,   const int z );
          
      57   bool setHeight(  const Vector3& deformationPoint,   const Real modificationHeight,   const PagingLandScapeTileInfo* info );
      58   bool deformHeight(  const Vector3& deformationPoint,   const Real modificationHeight,   const PagingLandScapeTileInfo* info );
          
          // bool addNewHeight(  const Sphere newSphere );
          //
          // bool removeNewHeight(  const Sphere oldSphere );
          
           //This function will return the max possible value of height base on the current 2D Data implementation
      65   const Real getMaxHeight(  const unsigned int x,   const unsigned int z );
          
      67   const Real getMaxHeight(  void ) const;
          
           /** Get the real world height at a particular position
           @remarks
           Method is used to get the terrain height at a world position based on x and z.
           This method just figures out what page the position is on and then asks the page node
           to do the dirty work of getting the height.
          
           @par
           the Real returned is the real world height based on the scale of the world. If the height could
           not be determined then -1 is returned and this would only occur if the page was not preloaded or loaded
          
           @param x x world position
           @param z z world position
           */
      82   const Real getInterpolatedWorldHeight(  const Real x,   const Real z,   Real *slope = NULL );
      83   const Real getWorldHeight(  const Real x,   const Real z );
          
      85   const ColourValue getCoverageAt(  const unsigned int dataX,   const unsigned int dataZ,   const Real x,   const Real z );
          
      87   const ColourValue getBaseAt(  const unsigned int dataX,   const unsigned int dataZ,   const Real x,   const Real z );
          
      89   const Real getShadowAt(  const unsigned int dataX,   const unsigned int dataZ,   const unsigned int x,   const unsigned int z,   const bool& positive );
          
      91   const Vector3 getNormalAt(  const unsigned int pageX,   const unsigned int pageZ,   const unsigned int x,   const unsigned int z );
      92   const Real getRealWorldSlope(  const Real x,   const Real z );
      93   const Vector3 getNormalAt(  const unsigned int pageX,   const unsigned int pageZ,   const unsigned int x,   const unsigned int z,   const unsigned int Lod );
          
      95   void setPageManager(  PagingLandScapeSceneManager *scnMgr );
          
          
      98   void registerDataType(  PagingLandScapeData2D* source )
           {
           mData2DTypeMap.push_back(  source );
          // LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,  
          // "PagingLandScape: Registered a new Data2DType for "
          // "type " + typeName );
           }
           // Walk the heightfield from location1 to location2 and find the max slope.
           // If maxSlope > 0 and a slope of greater than maxSlopeIn is found,   maxSlope is returned.
           // This is an expensive operation,   so use sparingly.
     108   Real getMaxSlope(  Vector3 location1,   Vector3 location2,   Real maxSlopeIn );
          
     110   PagingLandScapeData2D* getData2D(  const unsigned int i ,   const unsigned int j,  
     111   const bool alwaysReturn = true );
     112   PagingLandScapeData2D* getNewData2D(  const unsigned int i ,   const unsigned int j );
     113   void releaseData2D (  PagingLandScapeData2D*p  );
          
     115   PagingLandScapeOptions* getOptions(   ){return mOptions;}
     116   PagingLandScapeSceneManager *getSceneManager(   ){return mScnMgr;}
           protected:
     118   PagingLandScapeSceneManager * mScnMgr;
     119   PagingLandScapeOptions* mOptions;
          
          
           unsigned int mData2DType;
     123   String mData2DFormat;
          
           unsigned int mWidth;
           unsigned int mHeight;
          
          
     129   Real mMaxHeight;
           //PagingLandScapeData2DPages mData2D;
     131   PagingLandScapePageManager* mPageManager;
          
           /// Map of Data2d source type
     134   PagingLandScapeData2DMap mData2DTypeMap;
           /// The currently active page Data2d source
     136   PagingLandScapeData2D* mActiveData2DType;
          
     138   PagingLandScapeData2DList mActiveData2Ds;
     139   PagingLandScapeData2DList mFreeData2Ds;
     140   PagingLandScapeData2DArray mData2DPool;
           };
          
          } //namespace
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2D_HeightField.h

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightField.h - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeDATA2D_HEIGHTFIELD_H
          #define PAGINGLandScapeDATA2D_HEIGHTFIELD_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          
          namespace Ogre
          {
          
          /**
           * A specialized class for loading 2D Data from a HeightField file.
           */
          
      31  class PagingLandScapeData2D_HeightField: public PagingLandScapeData2D
          {
          public:
      34   PagingLandScapeData2D_HeightField(  PagingLandScapeData2DManager *dataMgr );
      35   virtual String getName(   ) const{return String(  "HeightField" );}
      36   virtual ~PagingLandScapeData2D_HeightField(  void );
          
      38   virtual const Vector3 getNormal(  const Real mX,   const Real mZ );
      39   virtual const ColourValue getBase(  const Real mX,   const Real mZ );
      40   virtual const ColourValue getCoverage(  const Real mX,   const Real mZ );
      41   virtual const Real getShadow(  const Real mX,   const Real mZ,   const bool& positive );
          
      43   const Real getMaxAbsoluteHeight(  void ) const;
      44   virtual PagingLandScapeData2D* newPage(   );
          protected:
          
      47   virtual void _save(  void );
      48   virtual bool _load(  const unsigned int x,   const unsigned int z );
      49   virtual void _load(  void );
      50   virtual void _unload(  void );
          
          private:
      53   Real getScale(   ) const;
      54   Real getInvScale(   ) const;
          
      56   Image* mImage;
      57   Image* mBase;
      58   Image* mShadow;
      59   Image* mCoverage;
          
           /// should be 4 bytes (  mImage is RGBA )
      62   size_t mBpp;
          };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2D_HeightFieldBlendNeighbor.h

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldBlendNeighbor.h - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeData2D_HeightFieldBlendNeighbor_H
          #define PagingLandScapeData2D_HeightFieldBlendNeighbor_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
           /**
           * A specialized class for loading 2D Data from a HeightField file.
           */
      29   class PagingLandScapeData2D_HeightFieldBlendNeighbor: public PagingLandScapeData2D
           {
           public:
      32   PagingLandScapeData2D_HeightFieldBlendNeighbor(  PagingLandScapeData2DManager *dataMgr );
      33   virtual String getName(   ) const{return String(  "HeightFieldBlendNeighbor" );}
      34   virtual ~PagingLandScapeData2D_HeightFieldBlendNeighbor(  void );
          
      36   virtual const Real getShadow(  const Real mX,   const Real mZ,   const bool& positive );
          
      38   virtual PagingLandScapeData2D* newPage(   );
      39   const Real getMaxAbsoluteHeight(  void ) const;
          
           protected:
      42   virtual void _save(  void );
      43   virtual bool _load(  const unsigned int x,   const unsigned int z );
      44   virtual void _load(  void );
      45   virtual void _unload(  void );
          
           private:
      48   Image * mShadow;
           unsigned int mBpp;// should be 2 bytes (  mImage is 16 bits )
           };
          
          }
          
          #endif //PagingLandScapeData2D_HeightFieldBlendNeighbor_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2D_HeightFieldN.h

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldN.h - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeData2D_HeightFieldN_H
          #define PagingLandScapeData2D_HeightFieldN_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          
          namespace Ogre
          {
          
          /**
           * A specialized class for loading 2D Data from a HeightField file.
           */
          
      31  class PagingLandScapeData2D_HeightFieldN: public PagingLandScapeData2D
          {
           public:
      34   PagingLandScapeData2D_HeightFieldN(  PagingLandScapeData2DManager *dataMgr );
      35   virtual String getName(   ) const{return String(  "HeightFieldN" );}
      36   virtual ~PagingLandScapeData2D_HeightFieldN(  void );
          
      38   virtual const Vector3 getNormal(  const Real mX,   const Real mZ );
      39   virtual const ColourValue getBase(  const Real mX,   const Real mZ );
      40   virtual const ColourValue getCoverage(  const Real mX,   const Real mZ );
      41   virtual const Real getShadow(  const Real mX,   const Real mZ,   const bool& positive );
          
      43   virtual PagingLandScapeData2D* newPage(   );
      44   const Real getMaxAbsoluteHeight(  void ) const;
          
           protected:
      47   virtual void _save(  void );
      48   virtual bool _load(  const unsigned int x,   const unsigned int z );
      49   virtual void _load(  void );
      50   virtual void _unload(  void );
          
           private:
      53   Image* mImage;
      54   Image* mBase;
      55   Image* mShadow;
      56   Image* mCoverage;
          
      58   size_t mBpp;// should be 4 bytes (  mImage is RGBA )
          };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2D_HeightFieldNTC.h

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldNTC.h - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeDATA2D_HEIGHTFIELDNTC_H
          #define PAGINGLandScapeDATA2D_HEIGHTFIELDNTC_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          
          namespace Ogre
          {
          
           /**
           * A specialized class for loading 2D Data from a compressed HeightField file.
           */
      30   class PagingLandScapeData2D_HeightFieldNTC: public PagingLandScapeData2D
           {
           public:
      33   PagingLandScapeData2D_HeightFieldNTC(  PagingLandScapeData2DManager *dataMgr );
      34   virtual String getName(   ) const{return String(  "HeightFieldNTC" );}
          
      36   ~PagingLandScapeData2D_HeightFieldNTC(  void );
          
          
      39   virtual const Vector3 getNormalAt(  const Real mX,   const Real mZ );
      40   virtual const ColourValue getBase(  const Real mX,   const Real mZ );
      41   virtual const ColourValue getCoverage(  const Real mX,   const Real mZ );
          
      43   virtual PagingLandScapeData2D* newPage(   );;
      44   const Real getMaxAbsoluteHeight(  void ) const;
          
           protected:
      47   virtual void _save(  void );
          
      49   virtual bool _load(  const unsigned int x,   const unsigned int z );
          
      51   virtual void _load(  void );
          
      53   virtual void _unload(  void );
          
           private:
      56   inline Real _decodeTC(  const Real encoded ) const;
      57   inline uchar _encodeTC(  const Real decoded ) const;
          
      59   Real input_max,   input_min;
          
      61   Image* mImage;
      62   size_t mBpp;// should be 4 bytes (  mImage is RGBA )
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2D_HeightFieldRaw.h

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldRaw.h - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeData2D_HeightFieldRaw_H
          #define PagingLandScapeData2D_HeightFieldRaw_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
           /**
           * A specialized class for loading 2D Data from a HeightField file.
           */
      29   class PagingLandScapeData2D_HeightFieldRaw: public PagingLandScapeData2D
           {
           public:
      32   PagingLandScapeData2D_HeightFieldRaw(  PagingLandScapeData2DManager *dataMgr );
      33   virtual String getName(   ) const{return String(  "HeightFieldRaw" );}
      34   virtual ~PagingLandScapeData2D_HeightFieldRaw(  void );
          
      36   virtual const Real getShadow(  const Real mX,   const Real mZ,   const bool& positive );
          
      38   virtual PagingLandScapeData2D* newPage(   );
      39   const Real getMaxAbsoluteHeight(  void ) const;
          
           protected:
      42   virtual void _save(  void );
      43   virtual bool _load(  const unsigned int x,   const unsigned int z );
      44   virtual void _load(  void );
      45   virtual void _unload(  void );
          
           private:
      48   Image * mShadow;
           unsigned int mBpp;// should be 2 bytes (  mImage is 16 bits )
           };
          
          }
          
          #endif //PagingLandScapeData2D_HeightFieldRaw_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2D_HeightFieldRawTC.h

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldRawTC.h - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeDATA2D_HEIGHTFIELDRawTC_H
          #define PAGINGLandScapeDATA2D_HEIGHTFIELDRawTC_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
           /**
           * A specialized class for loading 2D Data from a compressed HeightField file.
           */
      28   class PagingLandScapeData2D_HeightFieldRawTC: public PagingLandScapeData2D
           {
           public:
      31   PagingLandScapeData2D_HeightFieldRawTC(  PagingLandScapeData2DManager *dataMgr );
      32   virtual String getName(   ) const{return String(  "HeightFieldRawTC" );}
          
      34   virtual ~PagingLandScapeData2D_HeightFieldRawTC(  void );
          
      36   virtual const Vector3 getNormalAt(  const Real mX,   const Real mZ );
      37   virtual const ColourValue getBase(  const Real mX,   const Real mZ );
      38   virtual const ColourValue getCoverage(  const Real mX,   const Real mZ );
      39   virtual PagingLandScapeData2D* newPage(   );;
      40   const Real getMaxAbsoluteHeight(  void ) const;
          
          
           protected:
      44   virtual void _save(  void );
      45   virtual bool _load(  const unsigned int x,   const unsigned int z );
      46   virtual void _load(  void );
      47   virtual void _unload(  void );
          
           private:
      50   inline Real _decodeRawTC(  const Real encoded ) const;
      51   inline ushort _encodeRawTC(  const Real decoded ) const;
          
      53   Real input_max,   input_min;
      54   Image* mImage;
           unsigned int mBpp;// should be 4 bytes (  mImage is RGBA )
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2D_HeightFieldTC.h

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldTC.h - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeDATA2D_HEIGHTFIELDTC_H
          #define PAGINGLandScapeDATA2D_HEIGHTFIELDTC_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          
          namespace Ogre
          {
          
           /**
           * A specialized class for loading 2D Data from a compressed HeightField file.
           */
          
      31   class PagingLandScapeData2D_HeightFieldTC: public PagingLandScapeData2D
           {
           public:
      34   PagingLandScapeData2D_HeightFieldTC(  PagingLandScapeData2DManager *dataMgr );
          
      36   virtual ~PagingLandScapeData2D_HeightFieldTC(  void );
      37   virtual String getName(   ) const{return String(  "HeightFieldTC" );}
          
      39   virtual const ColourValue getBase(  const Real mX,   const Real mZ );
      40   virtual const ColourValue getCoverage(  const Real mX,   const Real mZ );
          
      42   virtual PagingLandScapeData2D* newPage(   );
      43   const Real getMaxAbsoluteHeight(  void ) const;
          
           protected:
      46   virtual void _save(  void );
      47   virtual bool _load(  const unsigned int x,   const unsigned int z );
      48   virtual void _load(  void );
      49   virtual void _unload(  void );
          
           private:
      52   inline Real _decodeTC(  const Real encoded ) const;
      53   inline uchar _encodeTC(  const Real decoded ) const;
          
      55   Real input_max,   input_min;
          
      57   Image* mImage;
      58   size_t mBpp;// should be 4 bytes (  mImage is RGBA )
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeData2D_Spline.h

       1  /***************************************************************************
           OgrePagingLandScapeData2D_Spline.h
           Header for a NURBS-based heightfield generator
           -------------------
           begin : Sat Nov 9 2003
           copyright : (  C ) 2003 Chris "Antiarc" Heald
           email : antiarc@captionthis.com
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeDATA2D_SPLINE_H
          #define PAGINGLandScapeDATA2D_SPLINE_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          #include "DRGNURBSSurface.h"
          
          namespace Ogre
          {
          
           /**
           * A specialized class for loading 2D Data from a Spline file.
           */
          
      33   class PagingLandScapeData2D_Spline: public PagingLandScapeData2D
           {
           public:
      36   PagingLandScapeData2D_Spline(  PagingLandScapeData2DManager *dataMgr );
          
      38   ~PagingLandScapeData2D_Spline(  void );
          
      40   virtual PagingLandScapeData2D* newPage(   );
      41   virtual String getName(   ) const{return String(  "Spline" );}
      42   const Real getMaxAbsoluteHeight(  void ) const;
          
           protected:
      45   virtual void _save(  void );
          
      47   virtual bool _load(  const unsigned int x,   const unsigned int z );
          
      49   virtual void _load(  void );
          
      51   virtual void _unload(  void );
          
           private:
           int degree;
          
      56   CDRGNURBSSurface* mSurface;
           Point4D* mPoints;
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeHorizon.h

       1  /***************************************************************************
           OgrePagingLandScapeHorizon.h - description
           -------------------
           begin : Sat Mar 08 2003
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeHorizon_H
          #define PagingLandScapeHorizon_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeHorizon
           {
           public:
      28   PagingLandScapeHorizon(  const PagingLandScapeOptions * const options );
      29   ~PagingLandScapeHorizon(  void );
          
      31   void registerMinMaxHeightPage(  const unsigned int pageX,   const unsigned int pageZ,   const Real minHeight,   const Real maxHeight );
          
      33   void registerMinMaxHeightTile(  const PagingLandScapeTileInfo* info,   const Real minHeight,   const Real maxHeight );
          
      35   bool IsPageVisible(  const PagingLandScapeCamera* cam,   const unsigned int destpageX,   const unsigned int destpageZ );
          
           /**
           *
           * \param cam Give info on current tile and camera height
           * \param *destinfo info on the tile we want to test visibility on,  
           * \return
           */
      43   bool IsTileVisible(  const PagingLandScapeCamera* cam,   const PagingLandScapeTileInfo* destinfo );
          
          
      46   MaterialPtr getVisibilityMaterial(  void );
          
      48   void AddVisibleTile(  const unsigned int Tilex,   const unsigned int Tilez,   const bool visible );
      49   void AddVisibleTile(  const PagingLandScapeTileInfo* info,   const bool visible );
          
      51   void update(  void );
      52   void prepare(  const PagingLandScapeCamera* cam );
          
           private :
          
           const PagingLandScapeOptions * const mOptions;
          
           bool calcVis(  const Vector3& src,   const Vector3& dest,   const Real* const heightMap,   const unsigned int mapWidth,   const unsigned int mapHeight );
          
           Real* mMaxPageHeights;
           Real* mMinPageHeights;
           unsigned int mPageWidth;
           unsigned int mPageHeight;
          
           unsigned int mNumTilesPage;
          
           Real* mMaxTileHeights;
           Real* mMinTileHeights;
           unsigned int mTileWidth;
           unsigned int mTileHeight;
          
           MaterialPtr mVisibilityMaterial;
           uchar* mVisData;
           Image mVisImage;
           TexturePtr mVisTex;
          
           bool material_enabled;
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeIndexBuffer.h

       1  /***************************************************************************
           OgrePagingLandScapeIndexBufferManager.h - description
           -------------------
           begin : Fri Feb 28 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeINDEXBUFFER_H
          #define PAGINGLandScapeINDEXBUFFER_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
      26   class PagingLandScapeIndexBufferManager
           {
           public:
          
          
      31   PagingLandScapeIndexBufferManager(  PagingLandScapeSceneManager * scnMgr );
          
      33   ~PagingLandScapeIndexBufferManager(  void );
          
      35   IndexData *getIndex(  const int LOD );
          
      37   void load(   );
      38   void clear(   );
          
          
           /** Utility method to generate stitching indexes on the edge of a tile
           @param neighbor The neighbor direction to stitch
           @param hiLOD The LOD of this tile
           @param loLOD The LOD of the neighbor
           @param omitFirstTri Whether the first triangle of the stitch (  always clockwise
           relative to the center of this tile ) is to be omitted because an
           adjoining edge is also being stitched
           @param omitLastTri Whether the last triangle of the stitch (  always clockwise
           relative to the center of this tile ) is to be omitted because an
           adjoining edge is also being stitched
           @param pIdx Pointer to a pointer to the index buffer to push the results
           into (  this pointer will be updated )
           @returns The number of indexes added
           */
      55   unsigned int stitchEdge(  const Neighbor neighbor,   const int hiLOD,   const int loLOD,   const bool omitFirstTri,   const bool omitLastTri,   void** ppIdx,   const bool is32bits ) const;
          
           /// Gets the index data for this tile based on current settings
      58   IndexData* getIndexData(  const int RenderLevel,   PagingLandScapeRenderable** Neighbors );
          
           /// Internal method for generating triangle list terrain indexes
      61   IndexData* generateTriListIndexes(  const bool northStitch,   const bool southStitch,   const bool eastStitch,   const bool westStitch,   const int RenderLevel,   PagingLandScapeRenderable** Neighbors ) const;
          
           //*******************
           //Added by Fiesch adapted from a post by tonyhnz
      65   IndexData* getRawIndexes(  int renderLevel );
          
      67   PagingLandScapeSceneManager *getSceneManager(   ){return mScnMgr;}
           protected:
          
      70   PagingLandScapeSceneManager *mScnMgr;
          
           /** Returns the index into the height array for the given coordinates. */
      73   inline ushort _index16(  int x,   int z ) const
           {
           return (  x + z * mTileSize );
           };
           /** Returns the index into the height array for the given coordinates. */
      78   inline unsigned int _index32(  int x,   int z ) const
           {
           return (  x + z * mTileSize );
           };
          
           unsigned int mTileSize;
          
      85   IndexArray mCache;
           /// Shared array of IndexData (  reuse indexes across tiles )
      87   LevelArray mLevelIndex;
           // Store the indexes for every combination
           unsigned int mNumIndexes;
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeIntersectionSceneQuery.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeIntersectionSceneQuery.h - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004 by Jon Anderson
          email : janders@users.sf.net
          ***************************************************************************/
          
          #ifndef PagingLandScapeIntersectionSCENEQUERY_H
          #define PagingLandScapeIntersectionSCENEQUERY_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeIntersectionSceneQuery.h"
          #include "OgreSceneManager.h"
          
          namespace Ogre
          {
          
          /** PagingLandScapeOctree implementation of IntersectionSceneQuery. */
          class _OgrePagingLandScapeExport PagingLandScapeIntersectionSceneQuery :
           public PagingLandScapeOctreeIntersectionSceneQuery
          {
          public:
      48   PagingLandScapeIntersectionSceneQuery(  SceneManager* creator );
           virtual ~PagingLandScapeIntersectionSceneQuery(  void );
          
           /** See IntersectionSceneQuery. */
           void execute(  IntersectionSceneQueryListener* listener );
          };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeListener.h

          /*-----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright � 2000-2004 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------*/
          #ifndef __PagingLandScapePageSourceListener_H__
          #define __PagingLandScapePageSourceListener_H__
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
           /** Abstract class which classes can override to receive notifications
           when a page is ready to be added to the terrain manager.
           */
           class _OgrePagingLandScapeExport PagingLandScapeListener
           {
          
           public:
      37   PagingLandScapeListener(   ){};
           virtual ~PagingLandScapeListener(   ){};
           /** Listener method called when a new page is about to be constructed.
           @param pagex,   pagez The index of the page being constructed
           @param heightData Array of normalised height data (  0..1 ). The size of
           this buffer will conform to the scene manager page size. The listener
           may modify the data if it wishes.
           */
           virtual void pagePreloaded(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox ){};
           virtual void pageLoaded(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox ){};
           virtual void pageUnloaded(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox ){};
           virtual void pagePostunloaded(  const size_t pagex,   const size_t pagez ){};
           virtual void pageShow(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox ){};
           virtual void pageHide(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox ) {};
           virtual void tileLoaded(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox ){};
           virtual void tileUnloaded(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox ){};
           virtual void tileDeformed(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox ){};
           virtual void tileShow(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox ){};
           virtual void tileHide(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox ){};
           virtual void terrainReady(  void ) {};
          
           };
          }
          #endif //__PagingLandScapePageSourceListener_H__
          

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeListenerManager.h

          /*-----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright � 2000-2004 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------*/
          #ifndef __PagingLandScapePageSourceListenerManager_H__
          #define __PagingLandScapePageSourceListenerManager_H__
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeListener.h"
          #include "OgreSingleton.h"
          
          #include "OgrePagingLandScapeCallBackEvent.h"
          
          namespace Ogre
          {
           /** Simple manager class to hold onto a list of page source listeners
           across all sources.
           */
           class _OgrePagingLandScapeExport PagingLandScapeListenerManager
           {
           public:
      40   PagingLandScapeListenerManager(  PagingLandScapeSceneManager * scnMgr );
      41   ~PagingLandScapeListenerManager(  void );
          
           /** Register a class which will be called back whenever a new page is
           available.
           @remarks
           Since this method is static,   it applies to any page source which
           is in active use; there is no need to register one per source.
           */
      49   void addListener(  PagingLandScapeListener* pl );
          
           /** Unregister a class which will be called back whenever a new page is
           available.
           */
      54   void removeListener(  PagingLandScapeListener* pl );
          
           /// Fire event when Heightmap page Loaded Event
      57   void firePagePreloaded(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox );
          
           /// Fire event when Loaded is when page is textured and loaded in GPU.
      60   void firePageLoaded(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox );
          
           /// Fire event when Loaded is when page is untextured and unloaded in GPU.
      63   void firePageUnloaded(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox );
          
           /// Fire event when Heightmap page is unloaded
      66   void firePagePostunloaded(  const size_t pagex,   const size_t pagez );
          
           /// Fire event when page is visible
      69   void firePageShow(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox );
          
           /// Fire event when page is no more visible
      72   void firePageHide(  const size_t pagex,   const size_t pagez,   const Real* heightData,   const AxisAlignedBox &Bbox );
          
           /// Fire event when tile is Loaded in GPU
      75   void fireTileLoaded(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox );
          
           /// Fire event when tile is unLoaded in GPU
      78   void fireTileUnloaded(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox );
          
           /// Fire event when tile is deformed
      81   void fireTileDeformed(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox );
          
           /// Fire event when tile is visible
      84   void fireTileShow(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox );
          
           /// Fire event when tile is invisible
      87   void fireTileHide(  const size_t pagex,   const size_t pagez,   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox );
          
           /// Fire event when all tiles and page needed are loaded
      90   void fireTerrainReady(  void );
          
          
      93   bool setOption(  const String& strKey,   const void* pValue );
          
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
      97   void addTerrainListener(  PagingLandscapeDelegate* pl );
      98   void removeTerrainListener(  PagingLandscapeDelegate* pl );
          
          
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     103   void addPreloadPageListener(  PagingLandscapeDelegate* pl );
     104   void removePreloadPageListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     107   void addShowPageListener(  PagingLandscapeDelegate* pl );
     108   void removeShowPageListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     111   void addHidePageListener(  PagingLandscapeDelegate* pl );
     112   void removeHidePageListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     115   void addLoadPageListener(  PagingLandscapeDelegate* pl );
     116   void removeLoadPageListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     119   void addModifyPageListener(  PagingLandscapeDelegate* pl );
     120   void removeModifyPageListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     123   void addPostunloadPageListener(  PagingLandscapeDelegate* pl );
     124   void removePostunloadPageListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     127   void addUnloadPageListener(  PagingLandscapeDelegate* pl );
     128   void removeUnloadPageListener(  PagingLandscapeDelegate* pl );
          
          
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     133   void addShowTileListener(  PagingLandscapeDelegate* pl );
     134   void removeShowTileListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     137   void addHideTileListener(  PagingLandscapeDelegate* pl );
     138   void removeHideTileListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     141   void addLoadTileListener(  PagingLandscapeDelegate* pl );
     142   void removeLoadTileListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     145   void addModifyTileListener(  PagingLandscapeDelegate* pl );
     146   void removeModifyTileListener(  PagingLandscapeDelegate* pl );
           /** Register a delegate method which will be called back whenever terrain is ready (  no more queued objects. )
           */
     149   void addUnloadTileListener(  PagingLandscapeDelegate* pl );
     150   void removeUnloadTileListener(  PagingLandscapeDelegate* pl );
          
          
          
          
           protected:
          
           std::list<PagingLandscapeDelegate *> mTerrainReadyListeners;
          
           std::list<PagingLandscapeDelegate *> mShowPageListeners;
           std::list<PagingLandscapeDelegate *> mHidePageListeners;
           std::list<PagingLandscapeDelegate *> mPreloadPageListeners;
           std::list<PagingLandscapeDelegate *> mLoadPageListeners;
           std::list<PagingLandscapeDelegate *> mUnloadPageListeners;
           std::list<PagingLandscapeDelegate *> mPostunloadPageListeners;
           std::list<PagingLandscapeDelegate *> mModifyPageListeners;
          
          
           std::list<PagingLandscapeDelegate *> mShowTileListeners;
           std::list<PagingLandscapeDelegate *> mHideTileListeners;
           std::list<PagingLandscapeDelegate *> mLoadTileListeners;
           std::list<PagingLandscapeDelegate *> mUnloadTileListeners;
           std::list<PagingLandscapeDelegate *> mModifyTileListeners;
          
          
           };
          
          }
          
          #endif //__PagingLandScapePageSourceListener_H__

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeMeshDecal.h

          /*-----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright � 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------*/
          #ifndef __PagingLandScapeMeshDecal_H__
          #define __PagingLandScapeMeshDecal_H__
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
           /** Factory object for creating PagingLandScapeMeshDecal instances */
      31   class PagingLandScapeMeshDecalFactory : public MovableObjectFactory
           {
           protected:
      34   MovableObject* createInstanceImpl(   const String& name,   const NameValuePairList* params  );
           public:
      36   PagingLandScapeMeshDecalFactory(   ) {}
      37   ~PagingLandScapeMeshDecalFactory(   ) {}
          
      39   static String FACTORY_TYPE_NAME;
          
      41   const String& getType(  void ) const;
      42   void destroyInstance(   MovableObject* obj  );
           };
          
      45   class PagingLandScapeMeshDecal : public Renderable,   public MovableObject,   public SceneQueryListener
           {
           private:
      48   SceneManager* sceneMgr_;
      49   Vector3 position_;
      50   Quaternion orientation_;
      51   Vector2 size_;
      52   MaterialPtr material_;
          
      54   AxisAlignedBox AABB_;
      55   Real radius_;
          
      57   LightList lightList_;
          
      59   RenderOperation renderOp_;
      60   RaySceneQuery* rayQuery_;
      61   AxisAlignedBoxSceneQuery* AABBquery_;
          
      63   size_t declSize_;
          
           struct Vertex
           {
           Vertex(   Real x,   Real y,   Real z,   bool included  )
           : vertex_(   x,   y,   z  )
           ,   included_(   included  ) {}
           Vector3 vertex_;
           bool included_;
           };
          
           typedef std::vector<Vertex> VertexContainer;
           typedef std::vector<VertexContainer> SubSectionContainer;
      76   SubSectionContainer subSections_;
          
           struct SubExtent
           {
           int width_;
           int height_;
           int renderLevel_;
           };
          
           typedef std::vector<SubExtent> SubExtentContainer;
      86   SubExtentContainer subExtents_;
          
           unsigned int currentSubX_;
           unsigned int currentSubZ_;
          
           int width_;
           int height_;
          
           /**
           We'll use this flag to prevent rebuilding of the geometry every frame,   instead only rebuilding when the LOD has changed.
           */
      97   bool mDirty;
          
           /**
           A copy of the subextents from the last geometry generation,   to allow for dirty checks.
           */
     102   SubExtentContainer mOldSubExtents;
          
           public:
     105   PagingLandScapeMeshDecal(   const String& name,  
     106   const String& materialName,  
     107   const Vector2& size,  
     108   const String& sceneMgrInstanceName  );
     109   virtual ~PagingLandScapeMeshDecal(   );
          
           // Main public interface
     112   void SetSize(   const Vector2& size  );
          
     114   virtual void _notifyAttached(  Node* parent,   bool isTagPoint = false );
           private:
     116   void CreateGeometry(   );
     117   size_t GetNumVertices(   ) const;
     118   size_t GetNumIndices(   ) const;
     119   int GetRenderLevel(   int x,   int z  ) const
           {
           assert(   x >= 0 && x < width_  );
           assert(   z >= 0 && z < height_  );
           return subExtents_[z * width_ + x].renderLevel_;
           }
           template<class T> int CreateIndices(   HardwareIndexBufferSharedPtr ibuf  );
           template<class T> int MeshSubSection(   int x,   int z,   T*& indices,   int& indexOffset  );
           template<class T> int StitchEdge(   T*& indices,  
           const SubExtent& extents,  
           const int hiLOD,  
           const int loLOD,  
           const bool horizontal,  
           const bool forward,  
           const bool omitFirstTri,  
           const bool omitLastTri,  
           const int indexOffset  );
           // From MovableObject
           const String& getMovableType(   ) const
           {
           return PagingLandScapeMeshDecalFactory::FACTORY_TYPE_NAME;
           }
           const AxisAlignedBox& getBoundingBox(   ) const
           {
           return AABB_;
           }
     145   Real getBoundingRadius(   ) const
           {
           return radius_;
           }
     149   void _updateRenderQueue(   RenderQueue* queue  );
          
           // From Renderable
     152   const MaterialPtr& getMaterial(   ) const
           {
           return material_;
           }
           virtual void getRenderOperation(   RenderOperation& op  );
           virtual void getWorldTransforms(   Matrix4* xform  ) const;
           const Quaternion& getWorldOrientation(   ) const;
           const Vector3& getWorldPosition(   ) const;
           Real getSquaredViewDepth(   const Camera* cam  ) const;
           const LightList& getLights(   ) const
           {
           return lightList_;
           }
          
           // From SceneQueryListener
           bool queryResult(  MovableObject* object )
           {
           return false;
           }
           bool queryResult(  SceneQuery::WorldFragment* fragment );
           };
          }
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusion.h

       1  #ifndef __PagingLandScapeOcclusion_H
          #define __PagingLandScapeOcclusion_H
          
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          #include <stack>
          #include <list>
          
          #include "OgrePagingLandScapeOcclusionQuerySet.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          
          namespace Ogre
          {
          
      19   class Occlusion
           {
          
           public:
      23   Occlusion(  unsigned int visibilityThsd = 0 );
      24   ~Occlusion(   )
           {
           mQueryPool.deletePool (   );
           }
           //this is the algorithm from the paper
      29   void CHCtraversal(  PagingLandScapeOctree *octree,   VisibleObjectsBoundsInfo * const visibleBounds );
      30   void CHCtraversalConservative (  PagingLandScapeOctree *octree,   VisibleObjectsBoundsInfo * const visibleBounds );
          
      32   bool insideViewFrustum (  OcclusionElement& node );
      33   void pullUpVisibility(  OcclusionElement& n );
      34   bool isQueryResultIsVisible(  OcclusionElement& node );
      35   bool issueDrawQuery(  PagingLandScapeOctreeNode& n );
      36   void issueBboxQuery(  OcclusionElement& n );
      37   void queueDraw(  PagingLandScapeOctreeNode& n );
          
      39   const unsigned int getNodeCount(   ) const { return nodeCount; }
      40   unsigned int getFrame(   ) const {return mFrameId;};
      41   PagingLandScapeOctreeCamera *getCamera(   ) const {return mCurrentCam;};
          
          
           #ifdef _VISIBILITYDEBUG
           unsigned int object_cnt;
           unsigned int triangle_cnt;
           unsigned int traversed_nodes_cnt;
           unsigned int frustum_culled_nodes_cnt;
           unsigned int query_cnt;
           #endif //_VISIBILITYDEBUG
          
      52   bool nextFrame (  PagingLandScapeOctreeCamera *cam,  
      53   MovableObjectList *camInProgressVisibles,  
      54   bool onlyshadowcaster,  
      55   RenderQueue *q );
          
      57   void init (  PagingLandScapeOctreeSceneManager *scnMngr )
           {
           mScnMngr = scnMngr;
           };
          
      62   void initQueryPool(   )
           {
           if (  mIsQueryPoolNotInitiated )
           {
           mQueryPool.setRenderSystem (   );
           mQueryPool.setAutoextend (  true );
           mQueryPool.setPoolSize (  300 );
           mIsQueryPoolNotInitiated = false;
           }
           };
          
           #ifdef _VISIBILITYDEBUG
      74   void TreeOverlayDebugView(  PagingLandScapeOctree *octree,  
      75   PagingLandScapeOctreeSceneManager *mScnMgr );
           #endif //_VISIBILITYDEBUG
          
      78   PagingLandScapeOctreeSceneManager *mScnMngr;
          
      80   PagingLandScapeOctreeCamera *mCurrentCam;
      81   RenderQueue *mCurrentRenderQueue;
      82   bool mOnlyShadowCaster;
           unsigned int mFrameId;
          
      85   void setIfNotSolidScene(  const bool isNotSolid ) {mIsNotSolidScene = isNotSolid;};
      86   bool isNotSolidScene (   ) const {return mIsNotSolidScene;};
      87   void setNumberOfConservativeFrames (  const unsigned int frames ){mFrameConservativeVisibility = frames;}
      88   unsigned int getNumberOfConservativeFrames (   ) const {return mFrameConservativeVisibility;}
           private:
          
      91   bool mIsNotSolidScene;
           ///Keep a set of pre-allocated HW queries
      93   QuerySet mQueryPool;
           /// As it's initiated on first HW query use
      95   bool mIsQueryPoolNotInitiated;
          
           ///culling mode from frustum culling to coherent hierarchical Occlusion
           unsigned int mode;
          
           /// number of frame we consider a node visible after a query set it visible once.
           unsigned int mFrameConservativeVisibility;
           /// Number of pixel upon which a node is considered as visible
           unsigned int mVisibilityTreshold;
           /// store number of nodes in Tree
           unsigned int nodeCount;
          
           /// store queried elements that didn't return results
     108   QueriedOcclusionElement m_queryQueue;
          
           };
          
          }
          #endif //__PagingLandScapeOcclusion_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionCHCTraversal.h

       1  #ifndef __PagingLandScapeOcclusionCHCTraversal_H
          #define __PagingLandScapeOcclusionCHCTraversal_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeCamera.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
           // TREE TRAVERSAL classes
           // a OctreeNode with Geometry objects in the leaves
           // and a TreeNodeData struct at every node
      15   class CHCTraversal : public TraversalConst
           {
           public:
      18   virtual void onTree(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const;
      19   virtual void onLeaf(  PagingLandScapeOctreeNode& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const ;
          
      21   CHCTraversal(  FrontToBackNodeSorterPriorityQueue& vStack,   Occlusion& o );
          
           private:
      24   FrontToBackNodeSorterPriorityQueue& stack;
      25   Occlusion& occlusion;
           const unsigned int frameId;
      27   const bool mIsNotSolidScene;
           };
          }
          #endif //PagingLandScapeOcclusionCHCTraversal

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionCameraTraversal.h

       1  #ifndef __PagingLandScapeOcclusionCameraTraversal_H
          #define __PagingLandScapeOcclusionCameraTraversal_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeCamera.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
           //
      11   class RegisterCameraTraversal : public TraversalConst
           {
           private:
      14   PagingLandScapeOctreeCamera *cam;
          
           public:
      17   RegisterCameraTraversal(  PagingLandScapeOctreeCamera *c ) : cam (  c ) {};
      18   virtual void onTree(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const ;
      19   virtual void onLeaf(  PagingLandScapeOctreeNode& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const ;
           };
           //-----------------------------------------------------------------------
           //
      23   class UnregisterCameraTraversal : public TraversalConst
           {
           private:
      26   PagingLandScapeOctreeCamera *cam;
          
           public:
      29   UnregisterCameraTraversal(  PagingLandScapeOctreeCamera *c ) : cam (  c ) {};
      30   virtual void onTree(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const ;
      31   virtual void onLeaf(  PagingLandScapeOctreeNode& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const ;
           };
          
          }
          #endif //PagingLandScapeOcclusionCameraTraversal

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionDebugTraversal.h

       1  #ifndef __PagingLandScapeOcclusionTreeOverlayDebugTraversal_H
          #define __PagingLandScapeOcclusionTreeOverlayDebugTraversal_H
          
          
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          #ifdef _VISIBILITYDEBUG
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          
          namespace Ogre
          {
           //------------------------------------------------------
           //
      18   class TreeOverlayDebug : public TraversalConst
           {
           public:
      21   TreeOverlayDebug(  Occlusion& o,   PagingLandScapeOctreeSceneManager *scnMgr );
      22   virtual void onTree(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const ;
      23   virtual void onLeaf(  PagingLandScapeOctreeNode& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const ;
          
           private:
      26   Occlusion& occlusion;
      27   PagingLandScapeOctreeSceneManager *mScnMrg;
          
           };
          }
          
          #endif //_VISIBILITYDEBUG
          
          #endif //__PagingLandScapeOcclusionTreeOverlayDebugTraversal_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionElement.h

       1  #ifndef __PagingLandScapeOcclusionElement_H
          #define __PagingLandScapeOcclusionElement_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          
          namespace Ogre
          {
           struct VisibleObjectsBoundsInfo;
      10   class OcclusionElement
           {
           public :
      13   OcclusionElement(   );
      14   virtual ~OcclusionElement(   );
          
      16   VisibilityData *getNodeData(  PagingLandScapeOctreeCamera *cam );
      17   void addCamNodeData (  PagingLandScapeOctreeCamera *cam );
      18   void removeCamNodeData (  PagingLandScapeOctreeCamera *cam );
          
      20   virtual OcclusionElement* getParent (   ) = 0;
      21   virtual OcclusionBoundingBox* getOcclusionBoundingBox(   ) = 0;
      22   virtual bool isLeaf(   ) const = 0;
          
           //virtual void _addToRenderQueue(  Camera* cam,   RenderQueue* const q,   const bool onlyShadowCasters ) = 0;
           //virtual void _addAlreadyNotifiedToVisibles(  Camera* cam,   RenderQueue* const q,   const bool onlyShadowCasters ) = 0;
           //virtual void notifyNodeObjects(  Camera* cam ) = 0;
          
      28   virtual void traversal(  Traversal&,   VisibleObjectsBoundsInfo * const visibleBounds ) = 0;
      29   virtual void traversal(  const TraversalConst&,   VisibleObjectsBoundsInfo * const visibleBounds ) = 0;
      30   virtual void traversal(  const ConstTraversalConst&,   VisibleObjectsBoundsInfo * const visibleBounds ) const = 0;
          
      32   virtual const AxisAlignedBox &getCullBoundingBox(   ) const = 0;
      33   virtual const Vector3 &getHalfSize(   ) const = 0;
          
           #ifdef _VISIBILITYDEBUG
      36   DebugRectangle2D *getRectangle2d(  SceneManager *scnMgr );
           #endif //_VISIBILITYDEBUG
          
      39   void setRegisteredtoCam(  const bool flag )
           {
           mIsRegisteredToCam = flag;
           };
          
          
      45   virtual bool isOccluder (   ) const = 0;
          
           protected :
           /// if node has all camera information about occlusion
      49   bool mIsRegisteredToCam;
          
          
           private :
          
           typedef std::map<unsigned int,   VisibilityData* > NodeDataPerCamMap;
           typedef NodeDataPerCamMap::iterator NodeDataPerCamMapiterator;
      56   NodeDataPerCamMap nodeDataPerCam;
           #ifdef _VISIBILITYDEBUG
      58   DebugRectangle2D *mDebugRectangle2d;
           #endif //_VISIBILITYDEBUG
           };
          
          }//namespace Ogre
          
          #endif //__PagingLandScapeOcclusionElement_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionQuerySet.h

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
           (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          
          #ifndef __OgrePagingLandScapeOcclusionQuerySet_H__
          #define __OgrePagingLandScapeOcclusionQuerySet_H__
          
          #include "OgrePrerequisites.h"
          #include "OgreRenderSystem.h"
          #include "OgreRoot.h"
          
          #include "OgrePagingLandScapePoolSet.h"
          
          namespace Ogre
          {
          
           /** A collection of pre-allocated queries
           */
      40   class QuerySet : public PoolSet<HardwareOcclusionQuery>
           {
           protected:
          
      44   HardwareOcclusionQuery* allocate (   )
           {
           return mRenderSystem->createHardwareOcclusionQuery(   );
           }
      48   void deallocate (  HardwareOcclusionQuery *p )
           {
           mRenderSystem->destroyHardwareOcclusionQuery (  p );
           }
          
           public:
          
      55   void setRenderSystem (   )
           {
           mRenderSystem = Root::getSingleton (   ).getRenderSystem (   );
           }
          
           private:
      61   RenderSystem *mRenderSystem;
          
           };
          }
          
          #endif//__OgrePagingLandScapeOcclusionQuerySet_H__

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionSWTraversal.h

       1  #ifndef __PagingLandScapeOcclusionSWTraversal_H
          #define __PagingLandScapeOcclusionSWTraversal_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeCamera.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
           // TREE TRAVERSAL classes
           // a OctreeNode with Geometry objects in the leaves
           // and a TreeNodeData struct at every node
           //-----------------------------------------------------------------------
           // Basic Occlusion query use : stop and wait query result Culling
      17   class SWTraversal : public Traversal
           {
           private:
          
      21   Occlusion& occlusion;
           PagingLandScapeOctreeCamera::Visibility mCurrentVisibility;
      23   Vector3 camPos;
          
           public:
          
      27   SWTraversal (  Occlusion& o );
          
      29   virtual void onTree(  PagingLandScapeOctree&,   VisibleObjectsBoundsInfo * const visibleBounds  );
      30   virtual void onLeaf(  PagingLandScapeOctreeNode&,   VisibleObjectsBoundsInfo * const visibleBounds  );
      31   bool isVisible(  OcclusionElement & n );
      32   void traverseChildren(  PagingLandScapeOctree & n,   VisibleObjectsBoundsInfo * const visibleBounds  );
           };
          
          }
          #endif //PagingLandScapeOcclusionSWTraversal

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionSorter.h

       1  #ifndef _PagingLandScapeOcclusionSorterH
          #define _PagingLandScapeOcclusionSorterH
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          
          namespace Ogre
          {
          
           //comparator for priority queue
      11   class FrontToBackNodeSorterOperator
           {
          
           public:
      15   FrontToBackNodeSorterOperator(  const Vector3& position ) : pos(  position ) {};
           //-----------------------------------------------------------------------
      17   inline bool operator(   )(  OcclusionElement*& a,   OcclusionElement*& b ) const
           {
           // could check if both distance == 0 then order visible first// ?
           return vectorToBoxDistance (  *a,   pos ) > vectorToBoxDistance (  *b,   pos );
           }
           //-----------------------------------------------------------------------
      23   inline bool operator(   )(  const OcclusionElement*& a,   const OcclusionElement*& b ) const
           {
           // could check if both distance == 0 then order visible first ?
           return vectorToBoxDistance (  *a,   pos ) > vectorToBoxDistance (  *b,   pos );
           }
           //-----------------------------------------------------------------------
      29   Real vectorToBoxDistance(  const OcclusionElement &a,   const Vector3& point ) const
           {
           const Vector3 &boxMin = a.getCullBoundingBox (   ).getMinimum (   );
           const Vector3 halfSize (  (  a.getCullBoundingBox (   ).getMaximum (   ) - boxMin ) * 0.5 );
           // work in the box's coordinate system
           const Vector3 kDiff (  point - (  halfSize + boxMin ) );
           // compute squared distance and closest point on box
           Real fSqrDistance (  0.0 );
           for (  unsigned int i = 0; i < 3; i++ )
           {
           const Real kClosest = kDiff[i];
           const Real khalfSize = halfSize[i];
           if (  kClosest < -khalfSize )
           {
           const Real fDelta = kClosest + khalfSize;
           fSqrDistance += fDelta * fDelta;
           }
           else if (  kClosest > khalfSize )
           {
           const Real fDelta = kClosest - khalfSize;
           fSqrDistance += fDelta * fDelta;
           }
           }
           return fSqrDistance;
           }
          
           private:
      56   const Vector3 pos;
           };
          }//namespace Ogre
          
          #endif //_PagingLandScapeOcclusionSorterH

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionTraversal.h

       1  #ifndef __PagingLandScapeOcclusionTraversal_H
          #define __PagingLandScapeOcclusionTraversal_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include <OgreSceneManager.h>
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      11   class ConstTraversalConst
           {
          
           public:
      15   virtual ~ConstTraversalConst(   ) {}
      16   virtual void onTree(  const PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const = 0;
      17   virtual void onLeaf(  const PagingLandScapeOctreeNode&,   VisibleObjectsBoundsInfo * const visibleBounds  ) const = 0;
          
           protected:
      20   virtual void traverseChildren(  const PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds ) const;
           };
           //-----------------------------------------------------------------------
      23   class TraversalConst
           {
          
           public:
      27   virtual ~TraversalConst(   ) {}
      28   virtual void onTree(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) const = 0;
      29   virtual void onLeaf(  PagingLandScapeOctreeNode&,   VisibleObjectsBoundsInfo * const visibleBounds  ) const = 0;
          
           protected:
      32   virtual void traverseChildren(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds ) const ;
           };
           //-----------------------------------------------------------------------
      35   class Traversal
           {
          
           public:
      39   virtual ~Traversal(   ) {}
      40   virtual void onTree(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds  ) = 0;
      41   virtual void onLeaf(  PagingLandScapeOctreeNode&,   VisibleObjectsBoundsInfo * const visibleBounds  ) = 0;
          
           protected:
      44   virtual void traverseChildren(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds  );
           };
          }
          #endif //PagingLandScapeOcclusionTraversal

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionVFTraversal.h

       1  #ifndef __PagingLandScapeOcclusionViewFrustumCullingTraversal_H
          #define __PagingLandScapeOcclusionViewFrustumCullingTraversal_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeCamera.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
           // Basic View Frustum Culling using hierarchy info
           // as if an octree is fully in frustum,   all children are for sure visible
      14   class ViewFrustumCullingTraversal : public Traversal
           {
           public:
          
      18   ViewFrustumCullingTraversal (  Occlusion& o );
          
      20   virtual void onTree(  PagingLandScapeOctree&,   VisibleObjectsBoundsInfo * const visibleBounds  );
      21   virtual void onLeaf(  PagingLandScapeOctreeNode&,   VisibleObjectsBoundsInfo * const visibleBounds  );
           private:
          
      24   Occlusion& occlusion;
           PagingLandScapeOctreeCamera::Visibility mCurrentVisibility;
          
           };
          
           //-----------------------------------------------------------------------
           // Basic View Frustum Culling
      31   class ViewFrustumCullingTraversalDirect : public Traversal
           {
          
           public:
          
      36   ViewFrustumCullingTraversalDirect (  Occlusion& o );
          
      38   virtual void onTree(  PagingLandScapeOctree&,   VisibleObjectsBoundsInfo * const visibleBounds  );
      39   virtual void onLeaf(  PagingLandScapeOctreeNode&,   VisibleObjectsBoundsInfo * const visibleBounds  );
           private:
          
      42   Occlusion& occlusion;
           };
          }
          #endif //__PagingLandScapeOcclusionViewFrustumCullingTraversal_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOcclusionVisibilityData.h

       1  #ifndef __VisibilityData_H
          #define __VisibilityData_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
           //contains the additional data needed for the
           // Coherent Hierarchical Culling
      10   class VisibilityData
           {
           public:
           // ctor
      14   VisibilityData(   ):
           #ifdef _VISIBILITYDEBUG
           viewFrustumVisible (  false ),  
           #endif //_VISIBILITYDEBUG
           queryVisible (  true ),  
           lastQueryFrameId (  0 ),  
           frameID (  0 ),  
           query (  0 ),  
           notified (  false )
           {};
           //dtor
      25   ~VisibilityData(   ){assert (  query == 0 );};
          
           #ifdef _VISIBILITYDEBUG
           // frustum culled
      29   bool viewFrustumVisible;
           #endif //_VISIBILITYDEBUG
          
           // Visible on screen,   as certified by query result
      33   bool queryVisible;
           //last query result
           unsigned int lastQueryFrameId;
           //last render
           unsigned int frameID;
           // query associated to node
      39   HardwareOcclusionQuery *query;
           // Has been checked against renderer
           // (  if not too far,   or outside this render like shadows...  )
      42   bool notified;
           };
          }
          #endif //__VisibilityData_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOctree.h

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          PagingLandScapeOctree.h - description
          -------------------
          begin : Mon Sep 30 2002
          copyright : (  C ) 2002 by Jon Anderson
          email : janders@users.sf.net
          
          Enhancements 2003 - 2004 (  C ) The OGRE Team
          ***************************************************************************/
          
          #ifndef __PagingLandScapeOctree_H
          #define __PagingLandScapeOctree_H
          
          
          #include "OgreAxisAlignedBox.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          
          #include <list>
          
          namespace Ogre
          {
          
      48   class PagingLandScapeOctreeNode;
          
           typedef std::list < PagingLandScapeOctreeNode* > NodeList;
          
          
           /** PagingLandScapeOctree data structure for managing scene nodes.
           @remarks
           This is a loose PagingLandScapeOctree implementation,   meaning that each
           octant child of the PagingLandScapeOctree actually overlaps it's siblings by a factor
           of .5. This guarantees that any thing that is half the size of the parent will
           fit completely into a child,   with no splitting necessary.
           */
          
      61   class PagingLandScapeOctree : public OcclusionElement
           {
          
           public:
      65   PagingLandScapeOctree(   );
      66   ~PagingLandScapeOctree(  void );
          
      68   void reset(   );
          
      70   void setParent(  PagingLandScapeOctree * parent );
      71   void setSceneManager(  PagingLandScapeOctreeSceneManager * scn );
          
           /** Adds an PagingLandScapeOctree scene node to this PagingLandScapeOctree level.
           @remarks
           This is called by the PagingLandScapeOctreeSceneManager after
           it has determined the correct PagingLandScapeOctree to insert the node into.
           */
      78   void _addNode(  PagingLandScapeOctreeNode* nod );
          
           /** Removes an PagingLandScapeOctree scene node to this PagingLandScapeOctree level.
           */
      82   void _removeNode(  PagingLandScapeOctreeNode* nod );
          
           /** Returns the number of scene nodes attached to this PagingLandScapeOctree
           */
      86   inline size_t numNodes(  void ) const
           {
           return mNumNodes;
           };
          
          
          
           /** creates the wire frame bounding box for this octant
           */
      95   WireBoundingBox* getWireBoundingBox(  void );
          
           /** creates the opaque Cull bounding box (  bbox*2 ) for this octant
           */
      99   OcclusionBoundingBox* getOcclusionBoundingBox(   );
          
          
           /** 3D array of children of this PagingLandScapeOctree.
           @remarks
           Children are dynamically created as needed when nodes are inserted in the PagingLandScapeOctree.
           If,   later,   the all the nodes are removed from the child,   it is still kept around.
           */
           PagingLandScapeOctree* mChildren[ 2 ][ 2 ][ 2 ];
          
           /** Determines if this PagingLandScapeOctree is twice as big as the given box.
           @remarks
           This method is used by the PagingLandScapeOctreeSceneManager to determine if the given
           box will fit into a child of this PagingLandScapeOctree.
           */
     114   bool _isTwiceSize(  const AxisAlignedBox& box ) const;
          
           /** Determines if this PagingLandScapeOctree is twice as big as the given box.
           @remarks
           This method is used by the PagingLandScapeOctreeSceneManager to determine if the given
           box will fit into a child of this PagingLandScapeOctree.
           */
     121   bool _isTwiceCullSize(  const AxisAlignedBox& box ) const;
          
     123   bool _isNotCrossingAxes(  const AxisAlignedBox& box ) const;
          
           /** Returns the appropriate indexes for the child of this PagingLandScapeOctree into which the box will fit.
           @remarks
           This is used by the PagingLandScapeOctreeSceneManager to determine which child to traverse next when
           finding the appropriate PagingLandScapeOctree to insert the box. Since it is a loose PagingLandScapeOctree,   only the
           center of the box is checked to determine the octant.
           */
     131   PagingLandScapeOctree* _getChildWhereBoxFits(  const AxisAlignedBox& bx,   PagingLandScapeOctreeSceneManager *scn );
           /** Returns the appropriate indexes for the child of this PagingLandScapeOctree into which the box will fit.
           @remarks
           This is used by the PagingLandScapeOctreeSceneManager to determine which child to traverse next when
           finding the appropriate PagingLandScapeOctree to insert the box. Since it is a loose PagingLandScapeOctree,   only the
           center of the box is checked to determine the octant.
           */
     138   PagingLandScapeOctree *_getCullChildWhereBoxFits(  const AxisAlignedBox& bx,   PagingLandScapeOctreeSceneManager *scn );
           /** Creates the AxisAlignedBox used for culling this PagingLandScapeOctree.
           @remarks
           Since it's a loose PagingLandScapeOctree,   the culling bounds can be different than the actual bounds of the PagingLandScapeOctree.
           */
     143   void _getCullBounds(  AxisAlignedBox* bound ) const;
          
           /** Public list of SceneNodes attached to this particular PagingLandScapeOctree
           */
     147   NodeList mNodes;
     148   NodeList mMovingNodes;
     149   NodeList mStaticNodes;
          
     151   inline OcclusionElement* getParent (   ) {return mParent;};
          
     153   inline bool isLeaf(   ) const {return false;};
          
     155   inline void traversal(  Traversal &tr,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           tr.onTree (  *this,   visibleBounds );
           };
     159   inline void traversal(  const TraversalConst &tr,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           tr.onTree(  *this,   visibleBounds );
           };
     163   inline void traversal(  const ConstTraversalConst &tr,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           tr.onTree (  *this,   visibleBounds );
           };
          
           // check if need to traverse it.
     169   inline bool hasChildren(   ) const
           {
           return (  mNumNodes != 0 );
           };
          
     174   void setBoundingBox(  const Vector3 &min,   const Vector3 &max );
          
           #ifdef _VISIBILITYDEBUG
     177   void setDebugCorners(  PagingLandScapeOctreeSceneManager *scnMgr );
           #endif //_VISIBILITYDEBUG
          
     180   inline const AxisAlignedBox &getCullBoundingBox(   ) const {return mCullBox;};
     181   inline const AxisAlignedBox &getBoundingBox(   ) const {return mBox;};
     182   inline const Vector3 &getHalfSize(   ) const {return mHalfSize;};
     183   inline const Vector3 &getCullHalfSize(   ) const {return mCullHalfSize;};
          
     185   inline bool isOccluder (   ) const { return true; }
          
           protected:
          
           /** The bounding box of the PagingLandScapeOctree
           @remarks
           This is used for octant index determination and rendering,   but not culling
           */
     193   AxisAlignedBox mBox;
           /// Octree double size bounding box
     195   AxisAlignedBox mCullBox;
     196   WireBoundingBox* mWireBoundingBox;
           /** Vector containing the dimensions of this PagingLandScapeOctree
           */
     199   Vector3 mHalfSize;
           /** Vector containing the dimensions of this PagingLandScapeOctree / 2
           */
     202   Vector3 mCullHalfSize;
          
          
           /** Increments the overall node count of this PagingLandScapeOctree and all it's parents
           */
     207   inline void _ref(  void )
           {
           ++mNumNodes;
           if (  mParent != 0 )
           {
           mParent->_ref(   );
           }
           };
          
           /** Decrements the overall node count of this PagingLandScapeOctree and all it's parents
           */
     218   void _unref(  const bool removeChildren );
          
           ///number of SceneNodes in this PagingLandScapeOctree and all it's children.
     221   size_t mNumNodes;
           ///parent PagingLandScapeOctree
           PagingLandScapeOctree* mParent;
     224   PagingLandScapeOctreeSceneManager *mSceneMgr;
     225   OcclusionBoundingBox* mOcclusionBoundingBox;
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOctreeAxisAlignedBoxSceneQuery.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreeAxisAlignedBoxSceneQuery.h - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004 by Jon Anderson
          email : janders@users.sf.net
          ***************************************************************************/
          
          #ifndef PagingLandScapeOctreeAxisAlignedBoxSCENEQUERY_H
          #define PagingLandScapeOctreeAxisAlignedBoxSCENEQUERY_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgreSceneManager.h"
          
          namespace Ogre
          {
          
          /** PagingLandScapeOctree implementation of AxisAlignedBoxSceneQuery. */
          class _OgrePagingLandScapeExport PagingLandScapeOctreeAxisAlignedBoxSceneQuery : public DefaultAxisAlignedBoxSceneQuery
          {
          public:
      46   PagingLandScapeOctreeAxisAlignedBoxSceneQuery(  SceneManager* creator );
           virtual ~PagingLandScapeOctreeAxisAlignedBoxSceneQuery(  void );
          
           /** See RayScenQuery. */
           /** Finds any entities that intersect the AAB for the query. */
           void execute(  SceneQueryListener* listener );
          };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOctreeCamera.h

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          PagingLandScapeOctreecamera.h - description
          -------------------
          begin : Fri Sep 27 2002
          copyright : (  C ) 2002 by Jon Anderson
          email : janders@users.sf.net
          
          Enhancements 2003 - 2004 (  C ) The OGRE Team
          ***************************************************************************/
          
          #ifndef PagingLandScapeOctreeCAMERA_H
          #define PagingLandScapeOctreeCAMERA_H
          
          #include "OgreCamera.h"
          #include "OgreHardwareBufferManager.h"
          #include "OgreSimpleRenderable.h"
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          /**
          *@author Jon Anderson
          */
          
          namespace Ogre
          {
          
      51   class PagingLandScapeOctree;
          
          
           /** Specialized viewpoint from which an PagingLandScapeOctree can be rendered.
           @remarks
           This class contains several specializations of the Ogre::Camera class. It
           implements the getRenderOperation method in order to return displayable geometry
           for debugging purposes. It also implements a visibility function that is more granular
           than the default.
           */
          
      62   class PagingLandScapeOctreeCamera : public Camera
           {
          
           public:
          
           /** Visibility types */
           enum Visibility
           {
           NONE,  
           PARTIAL,  
           FULL
           };
          
           /* Standard Constructor */
      76   PagingLandScapeOctreeCamera(  const String& name,   SceneManager* sm );
           /* Standard destructor */
      78   virtual ~PagingLandScapeOctreeCamera(  void );
          
           /** Returns the visibility of the box
           */
      82   Visibility getVisibility(  const AxisAlignedBox& bound ) const;
          
      84   bool isRegisteredInOcclusionSystem(   ) const;
      85   void setRegisteredInOcclusionSystem(  const bool registered );
          
      87   void updateRegistrationInOcclusionSystem(   );
          
      89   void setNextOcclusionMode(   );
      90   culling_modes getOcclusionMode(   ) const {return mOcclusionMode;};
      91   bool needRegistrationInOcclusionSystem(   ) const;
      92   void setOcclusionMode(  culling_modes occlusionMode );
          
      94   void setOcclusionModeAsString(  const String &cullingModeAsString );
      95   String getOcclusionModeAsString(   ) const;
          
      97   unsigned int getId(   )const {return mUniqueIdentification;}
      98   unsigned int getFrameId(   )const {return mFrameId;}
      99   bool nextFrame(  const unsigned int framesSceneId );
          
     101   void _addCHCRenderedFaces(  unsigned int numfaces )
           {
           mVisFacesLastCHCRender = numfaces;
           }
          
           private:
     107   void changeOcclusionMode(  culling_modes nextOcclusionMode );
          
           unsigned int mVisFacesLastCHCRender;
     110   bool isOcclusionSystemRegistered;
           unsigned int mUniqueIdentification;
           culling_modes mOcclusionMode;
          
           /// last rendered frame
           unsigned int mFrameId;
           unsigned int mFrameSceneId;
          
           static unsigned int s_camId;
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOctreeIntersectionSceneQuery.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreeIntersectionSceneQuery.h - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004 by Jon Anderson
          email : janders@users.sf.net
          ***************************************************************************/
          
          #ifndef PagingLandScapeOctreeIntersectionSCENEQUERY_H
          #define PagingLandScapeOctreeIntersectionSCENEQUERY_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgreSceneManager.h"
          
          namespace Ogre
          {
          
          /** PagingLandScapeOctree implementation of IntersectionSceneQuery. */
          class _OgrePagingLandScapeExport PagingLandScapeOctreeIntersectionSceneQuery :
           public DefaultIntersectionSceneQuery
          {
          public:
      47   PagingLandScapeOctreeIntersectionSceneQuery(  SceneManager* creator );
           virtual ~PagingLandScapeOctreeIntersectionSceneQuery(  void );
          
           /** See IntersectionSceneQuery. */
           void execute(  IntersectionSceneQueryListener* listener );
          };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOctreeNode.h

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          PagingLandScapeOctreenode.h - description
          -------------------
          begin : Fri Sep 27 2002
          copyright : (  C ) 2002 by Jon Anderson
          email : janders@users.sf.net
          
          Enhancements 2003 - 2004 (  C ) The OGRE Team
          ***************************************************************************/
          #ifndef __PagingLandScapeOctreeNODE_H
          #define __PagingLandScapeOctreeNODE_H
          
          #include "OgreSceneNode.h"
          #include "OgrePagingLandScapePrerequisites.h"
          
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          
          namespace Ogre
          {
          
           /** Specialized SceneNode that is customized for working within an PagingLandScapeOctree. Each node
           * maintains it's own bounding box,   rather than merging it with all the children.
           *
           */
      51   class PagingLandScapeOctreeNode : public SceneNode,   public OcclusionElement
           {
           public:
           /** Standard constructor */
      55   PagingLandScapeOctreeNode(  SceneManager* creator );
           /** Standard constructor */
      57   PagingLandScapeOctreeNode(  SceneManager* creator,   const String& name );
           /** Standard destructor */
      59   ~PagingLandScapeOctreeNode(  void );
          
           /** Returns the PagingLandScapeOctree in which this PagingLandScapeOctreeNode resides
           */
      63   PagingLandScapeOctree* getOctant(  void )
           {
           return mOctant;
           };
          
           /** Sets the PagingLandScapeOctree in which this PagingLandScapeOctreeNode resides
           */
      70   void setOctant(  PagingLandScapeOctree* o )
           {
           mOctant = o;
           };
          
           /** Determines if the center of this node is within the given box
           */
      77   bool _isIn(  const AxisAlignedBox& box ) const;
          
           /** Adds all the attached scene nodes to the render queue
           */
      81   virtual void _addToRenderQueue(  Camera* cam,   RenderQueue* const q,   const bool onlyShadowCasters,   VisibleObjectsBoundsInfo * const visibleBounds );
          
      83   MovableObjectList *getVisibleNotifiedNodeObjects(  Camera* cam,  
      84   const bool onlyShadowCasters );
          
      86   bool notifyNodeObjects(  Camera* cam,  
      87   const bool onlyShadowCasters );
           /** Adds all the attached scene nodes to the render queue
           * with the particularity that it has already been notified by camera.
           */
      91   void _addAlreadyNotifiedToVisibles(   );
      92   void _addToVisibles(  Camera* cam,   const bool onlyShadowCasters );
           /** Sets up the LegacyRenderOperation for rendering this scene node as geometry.
           @remarks
           This will render the scene node as a bounding box.
           */
           //virtual void getRenderOperation(  RenderOperation& op );
          
           /** Returns the local bounding box of this PagingLandScapeOctreeNode.
           @remarks
           This is used to render the bounding box,   rather then the global.
           */
     103   AxisAlignedBox& _getLocalAABB(  void )
           {
           return mLocalAABB;
           };
           /** Adds a (  pre-created ) child scene node to this node. If it is attached to another node,  
           it must be detached first.
           @param child The Node which is to become a child node of this one
           */
     111   virtual void addChild(  Node* child );
           /** Drops the specified child from this node.
           @remarks
           Does not delete the node,   just detaches it from
           this parent,   potentially to be reattached elsewhere.
           There is also an alternate version which drops a named
           child from this node.
           */
     119   virtual Node* removeChild(  unsigned short index );
           /** Drops the specified child from this node.
           @remarks
           Does not delete the node,   just detaches it from
           this parent,   potentially to be reattached elsewhere.
           There is also an alternate version which drops a named
           child from this node.
           */
     127   virtual Node* removeChild(  Node* child );
          
           /** Drops the named child from this node.
           @remarks
           Does not delete the node,   just detaches it from
           this parent,   potentially to be reattached elsewhere.
           */
     134   virtual Node* removeChild(  const String& name );
           /** Removes all child Nodes attached to this node. Does not delete the nodes,   just detaches them from
           this parent,   potentially to be reattached elsewhere.
           */
     138   virtual void removeAllChildren(  void );
          
          
          
     142   virtual OcclusionElement* getParent (   ) {return mOctant;};
          
          
     145   inline const AxisAlignedBox &getCullBoundingBox(   ) const
           {
           return _getWorldAABB(   );
           };
          
          
     151   virtual const Vector3 &getHalfSize(   ) const
           {
           return mHalfSize;
           };
          
     156   virtual bool isLeaf(   ) const {return true;};
          
     158   virtual void traversal(  Traversal&tr,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           tr.onLeaf (  *this,   visibleBounds );
           };
     162   virtual void traversal(  const TraversalConst &tr,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           tr.onLeaf(  *this,   visibleBounds );
           };
     166   virtual void traversal(  const ConstTraversalConst &tr,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           tr.onLeaf (  *this,   visibleBounds );
           };
           /** creates the opaque bounding box for this octant
           */
     172   OcclusionBoundingBox* getOcclusionBoundingBox(   );
          
           #ifdef _VISIBILITYDEBUG
     175   void setDebugCorners(  PagingLandScapeOctreeSceneManager *scnMgr );
           #endif //_VISIBILITYDEBUG
          
           /** Adds an instance of a scene object to this node.
           @remarks
           Scene objects can include Entity objects,   Camera objects,   Light objects,  
           ParticleSystem objects etc. Anything that subclasses from MovableObject.
           */
     183   virtual void attachObject(  MovableObject* obj );
           /** Detaches the indexed object from this scene node.
           @remarks
           Detaches by index,   see the alternate version to detach by name. Object indexes
           may change as other objects are added / removed.
           */
     189   virtual MovableObject* detachObject(  unsigned short index );
           /** Detaches an object by pointer. */
     191   virtual void detachObject(  MovableObject* obj );
          
           /** Detaches the named object from this node and returns a pointer to it. */
     194   virtual MovableObject* detachObject(  const String& name );
          
           /** Detaches all objects attached to this node.
           */
     198   virtual void detachAllObjects(  void );
          
     200   virtual bool isOccluder (   ) const { return mIsOccluder; }
          
     202   bool isStaticNode(   ) const { return mIsStaticNode; }
          
     204   void setStaticCulling (  const bool staticNode ) { mIsStaticNode = staticNode; };
          
          
           protected:
           /** Internal method for updating the bounds for this PagingLandScapeOctreeNode.
           @remarks
           This method determines the bounds solely from the attached objects,   not
           any children. If the node has changed it's bounds,   it is removed from its
           current PagingLandScapeOctree,   and reinserted into the tree.
           */
     214   void _updateBounds(  void );
          
     216   void _removeNodeAndChildren(  void );
          
           ///local bounding box
     219   AxisAlignedBox mLocalAABB;
          
           ///PagingLandScapeOctree this node is attached to.
     222   PagingLandScapeOctree* mOctant;
     223   OcclusionBoundingBox* mOcclusionBoundingBox;
     224   Vector3 mHalfSize;
           /// if node need to in loose octree or normal octree
     226   bool mIsStaticNode;
           /// if node need to be drawn during query phase
     228   bool mIsOccluder;
           // if a pre-notified object is visible.
     230   MovableObjectList mNotifiedVisibles;
          
           };
          
          }
          
          
          #endif //__PagingLandScapeOctreeNODE_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOctreePlaneBoundedVolumeListSceneQuery.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreePlaneBoundedVolumeListSceneQuery.h - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004 by Jon Anderson
          email : janders@users.sf.net
          ***************************************************************************/
          
          #ifndef PagingLandScapeOctreePlaneBoundedVolumeListSCENEQUERY_H
          #define PagingLandScapeOctreePlaneBoundedVolumeListSCENEQUERY_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgreSceneManager.h"
          
          namespace Ogre
          {
          
          /** PagingLandScapeOctree implementation of PlaneBoundedVolumeListSceneQuery. */
          class _OgrePagingLandScapeExport PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery : public DefaultPlaneBoundedVolumeListSceneQuery
          {
          public:
      46   PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery(  SceneManager* creator );
           virtual ~PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery(  void );
          
           /** See SceneQuery. */
           void execute(  SceneQueryListener* listener );
          };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOctreeRaySceneQuery.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreeRaySceneQuery.h - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004 by Jon Anderson
          email : janders@users.sf.net
          ***************************************************************************/
          
          #ifndef PagingLandScapeOctreeRaySCENEQUERY_H
          #define PagingLandScapeOctreeRaySCENEQUERY_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgreSceneManager.h"
          
          namespace Ogre
          {
          
          /** PagingLandScapeOctree implementation of RaySceneQuery. */
          class _OgrePagingLandScapeExport PagingLandScapeOctreeRaySceneQuery : public DefaultRaySceneQuery
          {
          public:
      46   PagingLandScapeOctreeRaySceneQuery(  SceneManager* creator );
           virtual ~PagingLandScapeOctreeRaySceneQuery(  void );
          
           /** See RayScenQuery. */
           void execute(  RaySceneQueryListener* listener );
          };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOctreeSceneManager.h

       1  /***************************************************************************
          PagingLandScapeOctreescenemanager.h - description
          -------------------
          begin : Fri Sep 27 2002
          copyright : (  C ) 2002 by Jon Anderson
          email : janders@users.sf.net
          ***************************************************************************/
          
          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          
          #ifndef PagingLandScapeOctreeSCENEMANAGER_H
          #define PagingLandScapeOctreeSCENEMANAGER_H
          
          #include "OgreSceneManager.h"
          #include "OgreRenderOperation.h"
          #include "OgreSphere.h"
          
          #include <list>
          #include <algorithm>
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOcclusion.h"
          #include "OgreRenderable.h"
          
          #include "OgrePagingLandScapePoolSet.h"
          
          namespace Ogre
          {
          
           /// Factory for OctreeSceneManager
      56   class PagingLandScapeOctreeSceneManagerFactory : public SceneManagerFactory
           {
           protected:
      59   void initMetaData(  void ) const;
           public:
      61   PagingLandScapeOctreeSceneManagerFactory(   ) {}
      62   ~PagingLandScapeOctreeSceneManagerFactory(   ) {}
           /// Factory type name
      64   static const String FACTORY_TYPE_NAME;
      65   SceneManager* createInstance(  const String& instanceName );
      66   void destroyInstance(  SceneManager* instance );
           };
          
      69   class PagingLandScapeOctreeNode;
          
      71   class PagingLandScapeOctreeCamera;
      72   class PagingLandScapeOctreeIntersectionSceneQuery;
      73   class PagingLandScapeOctreeRaySceneQuery;
      74   class PagingLandScapeOctreeSphereSceneQuery;
      75   class PagingLandScapeOctreeAxisAlignedBoxSceneQuery;
      76   class PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery;
          
           /** A collection of pre-allocated octrees
           */
      80   class OctreeSet : public PoolSet<PagingLandScapeOctree>
           {
           protected:
      83   virtual PagingLandScapeOctree* allocate (   )
           {
           return new PagingLandScapeOctree(   );
           }
      87   virtual void deallocate (  PagingLandScapeOctree *p )
           {
           delete p;
           }
           };
          
          
           //typedef std::list < WireBoundingBox* > BoxList;
           //typedef std::list < OcclusionBoundingBox* > BoxList;
          
           //typedef std::list < unsigned long > ColorList;
           //typedef std::list < SceneNode* > SceneNodeList;
          
          
           /** Specialized SceneManager that divides the geometry into an PagingLandScapeOctree in order to facilitate spatial queries.
           @remarks
           For debugging purposes,   a special "CullCamera" can be defined. To use it,   call setUseCallCamera(  true ),  
           and create a camera named "CullCamera". All culling will be performed using that camera,   instead of the viewport
           camera,   allowing you to fly around and examine culling.
           */
          
     108   class PagingLandScapeOctreeSceneManager : public SceneManager
           {
     110   friend class PagingLandScapeOctreeIntersectionSceneQuery;
     111   friend class PagingLandScapeOctreeRaySceneQuery;
     112   friend class PagingLandScapeOctreeSphereSceneQuery;
     113   friend class PagingLandScapeOctreeAxisAlignedBoxSceneQuery;
     114   friend class PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery;
          
           public:
           static int intersect_call;
           /** Standard Constructor. Initializes the PagingLandScapeOctree to -500,  -500,  -500 to 500,  500,  500 with unlimited depth. */
     119   PagingLandScapeOctreeSceneManager(  const String &name );
           /** Standard Constructor */
     121   PagingLandScapeOctreeSceneManager(  const String &name,   AxisAlignedBox& box,   int max_depth );
           /** Standard destructor */
     123   virtual ~PagingLandScapeOctreeSceneManager(  void );
          
     125   inline PagingLandScapeOctree * getNewOctree(   )
           {
           return mOctreeSet.getPoolable(   );
           }
     129   inline void deleteOctree(  PagingLandScapeOctree * p )
           {
           p->reset (   );
           mOctreeSet.removePoolable (  p );
           }
          
     135   void shutdown(   );
           /// @copydoc SceneManager::getTypeName
     137   const String& getTypeName(  void ) const;
          
           /** Initializes the manager to the given box and depth.
           */
     141   void init(  const AxisAlignedBox& box,   int d );
          
           /** Creates a specialized PagingLandScapeOctreeNode */
     144   virtual SceneNode* createSceneNode(  void );
           /** Creates a specialized PagingLandScapeOctreeNode */
     146   virtual SceneNode* createSceneNode(  const String& name );
           /** Creates a specialized PagingLandScapeOctreeCamera */
     148   virtual Camera* createCamera(  const String& name );
     149   virtual void destroyCamera(  Camera *cam );
     150   virtual void destroyCamera(  const String& name );
     151   virtual void destroyAllCameras(  void );
          
     153   void addCamera(  Camera *cam );
          
           /** Deletes a scene node */
     156   virtual void destroySceneNode(  const String& name );
          
           /** Does nothing more */
     159   virtual void _updateSceneGraph(  Camera* cam );
          
           /** Recurses through the PagingLandScapeOctree determining which nodes are visible. */
          #ifdef PLSM2_EIHORT
     163   virtual void _findVisibleObjects(  Camera* cam,   VisibleObjectsBoundsInfo *visibleBounds,   bool onlyShadowCasters );
          #else
     165   virtual void _findVisibleObjects(  Camera* cam,   bool onlyShadowCasters );
          #endif
          
           /** Alerts each un-culled object,   notifying it that it will be drawn.
           * Useful for doing calculations only on nodes that will be drawn,   prior
           * to drawing them...
           */
           //virtual void _alertVisibleObjects(  void );
          
           /** Walks through the PagingLandScapeOctree,   adding any visible objects to the render queue.
           @remarks
           If any octant in the PagingLandScapeOctree if completely within the the view frustum,  
           all sub-children are automatically added with no visibility tests.
           */
     179   void walkPagingLandScapeOctree(  PagingLandScapeOctreeCamera * camera,   RenderQueue * const queue,  
           PagingLandScapeOctree * const octant,   const bool foundvisible,   const bool onlyShadowCasters );
          
           /** Checks the given PagingLandScapeOctreeNode,   and determines if it needs to be moved
           * to a different octant.
           */
     185   void _updatePagingLandScapeOctreeNode(  PagingLandScapeOctreeNode* nod );
          
           /** Removes the given PagingLandScapeOctree node */
     188   void _removePagingLandScapeOctreeNode(  PagingLandScapeOctreeNode* nod );
          
           /** Adds the PagingLandScapeOctree Node,   starting at the given PagingLandScapeOctree,   and recursing at max to the specified depth.
           */
     192   void _addPagingLandScapeOctreeNode(  PagingLandScapeOctreeNode* ocnod,   PagingLandScapeOctree* PagingLandScapeOctree,   int depth = 0 );
          
           /** Adds the PagingLandScapeOctree Node,   starting at the given PagingLandScapeOctree,   and recursing at max to the specified depth.
           */
     196   void _addPagingLandScapeOctreeMovableNode(  PagingLandScapeOctreeNode* ocnod,   PagingLandScapeOctree* PagingLandScapeOctree,   int depth = 0 );
          
           /** Adds the PagingLandScapeOctree Node,   starting at the given PagingLandScapeOctree,   and recursing at max to the specified depth.
           */
     200   void _addPagingLandScapeOctreeStaticNode(  PagingLandScapeOctreeNode* ocnod,   PagingLandScapeOctree* PagingLandScapeOctree,   int depth = 0 );
          
           /** Recurses the PagingLandScapeOctree,   adding any nodes intersecting with the box into the given list.
           It ignores the exclude scene node.
           */
     205   void findNodesIn(  const AxisAlignedBox& box,   std::list < SceneNode* > &list,  
           const SceneNode* const exclude = 0 );
          
           /** Recurses the PagingLandScapeOctree,   adding any nodes intersecting with the sphere into the given list.
           It ignores the exclude scene node.
           */
     211   void findNodesIn(  const Sphere& sphere,   std::list < SceneNode* > &list,  
           const SceneNode* const exclude = 0 );
          
           /** Recurses the PagingLandScapeOctree,   adding any nodes intersecting with the volume into the given list.
           It ignores the exclude scene node.
           */
     217   void findNodesIn(  const PlaneBoundedVolume& volume,   std::list < SceneNode* > &list,  
           const SceneNode* const exclude=0 );
          
           /** Recurses the PagingLandScapeOctree,   adding any nodes intersecting with the ray into the given list.
           It ignores the exclude scene node.
           */
     223   void findNodesIn(  const Ray& ray,   std::list < SceneNode* > &list,  
           const SceneNode* const exclude=0 );
          
           /** Sets the box visibility flag */
     227   void setShowBoxes(  bool b )
           {
           #ifdef _VISIBILITYDEBUG
           mShowBoxes = b;
           #endif //_VISIBILITYDEBUG
           };
          
           /** Sets the cull camera flag */
     235   void setUseCullCamera(  bool b )
           {
           #ifdef _VISIBILITYDEBUG
           mCullCamera = b;
           #endif //_VISIBILITYDEBUG
           };
          
           /** Resizes the PagingLandScapeOctree to the given size */
     243   void resize(  const AxisAlignedBox& box );
     244   void resize(  const AxisAlignedBox &box,   const int depth );
          
           /** Sets the given option for the SceneManager
           @remarks
           Options are:
           "Size",   AxisAlignedBox *;
           "CullCamera",   bool *;
           "Depth",   int *;
           "ShowPagingLandScapeOctree",   bool *;
           */
          
     255   virtual bool setOption(  const String& key,   const void* value );
          
           /** Gets the given option for the Scene Manager.
           @remarks
           See setOption
           */
     261   virtual bool getOption(  const String& key,   void* value );
          
     263   bool getOptionValues(  const String& key,   StringVector& refValueList );
     264   bool getOptionKeys(  StringVector& refKeys );
           /** Overridden from SceneManager */
     266   void clearScene(  void );
          
     268   AxisAlignedBoxSceneQuery* createAABBQuery(  const AxisAlignedBox& box,   unsigned long mask );
     269   SphereSceneQuery* createSphereQuery(  const Sphere& sphere,   unsigned long mask );
     270   PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(  const PlaneBoundedVolumeList& volumes,   unsigned long mask );
     271   RaySceneQuery* createRayQuery(  const Ray& ray,   unsigned long mask );
     272   IntersectionSceneQuery* createIntersectionQuery(  unsigned long mask );
          
     274   void directRenderSingleQueue(  RenderQueue *queue );
     275   void directRenderSingleObject(  Renderable *mo );
          
     277   void addVisible(  MovableObject *mo );
          
     279   const AxisAlignedBox &getBoundingBox(   )const {return mBox;};
          
     281   void registeredNodeInCamera(  OcclusionElement *on );
     282   void unregisteredNodeInCamera(  OcclusionElement *on );
          
     284   void registerCamera (  PagingLandScapeOctreeCamera *c );
     285   void unregisterCamera(  PagingLandScapeOctreeCamera *c );
          
           protected:
          
           /// The root PagingLandScapeOctree
     290   PagingLandScapeOctree* mPagingLandScapeOctree;
          
           typedef std::map<unsigned int,   MovableObjectList * > VisiblesPerCam;
     293   VisiblesPerCam mVisibles;
     294   MovableObjectList * mCamInProgressVisibles;
     295   PolygonMode mCamDetail;
     296   bool mCamClear;
          
           /// number of rendered objects
           int mNumObjects;
          
           /// max depth for the tree.
           int mMaxDepth;
          
           /// Size of the PagingLandScapeOctree
     305   AxisAlignedBox mBox;
          
          
           // OCCLUSION
     309   Occlusion mOcclusion;
          
           //DEBUG INFO
           #ifdef _VISIBILITYDEBUG
           /// box visibility flag
     314   bool mShowBoxes;
           /// list of boxes to be rendered
     316   MovableObjectList mBoxes;
           /// cull camera flag
     318   bool mCullCamera;
           /// cull camera flag
     320   bool mCullDebug;
          
     322   String mDebugText;
           #endif //_VISIBILITYDEBUG
          
          
     326   PagingLandScapeOctreeCamera *mCurrentOptionCamera;
          
     328   RenderTexture *mOcclusionDepth;
     329   Camera *mOcclusionCamera;
          
     331   void enableHardwareOcclusionTests(   );
     332   void disableHardwareOcclusionTests(   );
          
     334   OctreeSet mOctreeSet;
          
          
           };
          
          
          }
          
          #endif
          

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOctreeSphereSceneQuery.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreeSphereSceneQuery.h - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004 by Jon Anderson
          email : janders@users.sf.net
          ***************************************************************************/
          
          #ifndef PagingLandScapeOctreeSphereSCENEQUERY_H
          #define PagingLandScapeOctreeSphereSCENEQUERY_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgreSceneManager.h"
          
          namespace Ogre
          {
          
          /** PagingLandScapeOctree implementation of SphereSceneQuery. */
          class _OgrePagingLandScapeExport PagingLandScapeOctreeSphereSceneQuery : public DefaultSphereSceneQuery
          {
          public:
      46   PagingLandScapeOctreeSphereSceneQuery(  SceneManager* creator );
           virtual ~PagingLandScapeOctreeSphereSceneQuery(  void );
          
           /** See SceneQuery. */
           void execute(  SceneQueryListener* listener );
          };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeOptions.h

       1  /***************************************************************************
           OgrePagingLandScapeOptions.h - description
           -------------------
           begin : Sun Mar 02 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeOPTIONS_H
          #define PAGINGLandScapeOPTIONS_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgreStringVector.h"
          #include "OgreConfigFile.h"
          #include "OgreMaterial.h"
          
          namespace Ogre
          {
           /**
           * A simple class for encapsulating parameters passed in when initializing *
           * a LandScapeRenderable
           */
      32   class PagingLandScapeOptions
           {
           public:
      35   PagingLandScapeOptions(  PagingLandScapeSceneManager * scnMgr );
          
      37   ~PagingLandScapeOptions(  void );
          
      39   void init(   );
      40   void setDefault(   );
          
      42   bool load(  DataStreamPtr& stream );
      43   bool load(  const String &filename,   ConfigFile& config );
      44   bool load(  const String &filename );
          
      46   void loadMap(  const String& mapName );
      47   void loadMapOptions(  const String& mapName );
      48   void insertMap(  const String& mapName );
          
      50   LandScapeFileNames* getLandScapeFileNames(  void )
           {
           return &mMapList;
           };
          
      55   bool setOption(  const String& strKey,   const void* pValue );
      56   bool getOption(  const String& strKey,   void* pDestValue );
          
      58   bool hasOption(  const String& strKey ) const ;
          
      60   bool getOptionValues(  const String & key,   StringVector &refValueList );
      61   bool getOptionKeys(  StringVector &refKeys );
          
      63   void getAvgColors(  void );
          
      65   LandScapeFileNames& getMapList(  void );
          
      67   const String& getMapFilename(  const String &currMapName ) const;
      68   const String& getPreviousMapName(  void ) const;
      69   const String& getNextMapName(  void ) const;
      70   const String& getCurrentMapName(  void ) const;
          
      72   void setCurrentMapName(  const String& mapName );
          
      74   const String& getCurrentTextureFormat(  void ) const;
      75   void setTextureFormat(  const String& format );
      76   void insertTextureFormat (  const String &format ) ;
          
      78   void setPrimaryCamera(  PagingLandScapeCamera* cam );
      79   void calculateCFactor(  void );
          
      81   String data2DFormat;
      82   String textureFormat;
          
      84   String TerrainName;
          
      86   String LandScape_filename;
      87   String LandScape_extension;
      88   String LandScape_export_filename;
      89   String LandScape_export_extension;
          
      91   String image_filename;
      92   bool ImageNameLoad;
          
          
           // MAP TOOL OPTIONS
      96   String OutDirectory;
      97   String TextureExtension;
      98   String TextureExportExtension;
          
     100   bool Paged;
     101   bool BaseMap;
     102   bool MiniMap;
     103   bool ColorMapSplit;
     104   bool ColorMapGenerate;
     105   bool LightMap;
     106   bool NormalMap;
     107   bool HeightMap;
     108   bool AlphaMaps;
     109   bool LitBaseMap;
     110   bool LitColorMapSplit;
     111   bool LitColorMapGenerate;
     112   bool InfiniteMap;
     113   bool CoverageMap;
     114   bool HeightNormalMap;
          
     116   Real HeightMapBlurFactor;
          
     118   String ColorMapName;
          
     120   bool lightmoved;
     121   Vector3 Sun;
     122   Real SunAngle;
     123   Real Amb;
     124   Real Diff;
          
     126   bool mUseLodMapCache;
          
           unsigned int Blur;
           // end of MAP TOOL OPTIONS
          
           unsigned int maxValue; //Compression range for the TC height field
           unsigned int minValue;
          
           unsigned int TileSize;
           unsigned int PageSize; //size of the page.
     136   Real invTileSizeMinusOne;
     137   Real invPageSizeMinusOne;
           unsigned int NumTiles;
           unsigned int NumPages;
          
           unsigned int world_height; //world page height,   from 0 to height,   in page number
           unsigned int world_width; //world page width,   from 0 to width,   in page number
          
     144   Real maxScaledZ; //world page height,   scaled
     145   Real maxScaledX; //world page width,   scaled
          
     147   Real maxUnScaledZ; //world page height,   scaled
     148   Real maxUnScaledX; //world page width,   scaled
          
          
     151   Real change_factor; //Determines the value of the change factor for loading/unloading LandScape Pages
           unsigned int max_adjacent_pages;
           unsigned int max_preload_pages;
     154   Real visible_renderables; //Numbers of visible renderables surrounding the camera
     155   Real renderable_factor; //Determines the distance of loading and unloading of renderables in renderable numbers
          
     157   Vector3 position; //Startup position of the terrain surface
     158   Vector3 scale;
     159   Vector3 invScale;
          
     161   Material::LodDistanceList lodMaterialDistanceList; //Distance for the material LOD change
     162   Real distanceLOD; //Distance for the LOD change
     163   Real LOD_factor;
     164   bool roughnessLod;
          
           unsigned int num_renderables; //Max number of renderables to use.
           unsigned int num_renderables_increment; //Number of renderables to add in case we run out of renderables
           unsigned int num_tiles; //Max number of tiles to use.
           unsigned int num_tiles_increment; //Number of renderables to add in case we run out of renderables
          
     171   Real cameraThreshold; //If the last camera position is >= the the scene is transverse again.
          
           unsigned int num_renderables_loading; //Max number of renderable to load in a single Frame.
           unsigned int maxRenderLevel;
          
           unsigned int NumMatHeightSplat;
     177   std::vector <ColourValue> matColor;
     178   std::vector <Real> matHeight;
     179   std::vector<String> SplatDetailMapNames;
          
     181   bool VertexCompression;
          
     183   bool hasVertexShader;
     184   bool hasFragmentShader;
     185   bool hasFragmentShader2;
           unsigned int numTextureUnits;
     187   bool isRenderGL;
          
     189   Real ScaledPageSizeX;
     190   Real ScaledPageSizeZ;
     191   Real ScaledHeightY;
          
          
           /// used to test all texture format without
           /// restrictions (  renderer or capabilities )
     196   bool TextureFormatDebug;
           /// Can terrain be deformed real-time
     198   bool Deformable;
           /// are deformation saved?
     200   bool saveDeformation;
          
          
           //used to get screen height...
           // should find another way...
     205   PagingLandScapeCamera* primaryCamera;
          
           /// At what point (  parametric ) should LOD morphing start
     208   Real lodMorphStart;
     209   bool lodMorph;
           unsigned int maxPixelError;
     211   Real CFactor;
          
           // MapSplitter Tool
           unsigned int RawHeight;
           unsigned int RawWidth;
          
     217   bool isRaw;
     218   bool Equalize;
     219   bool ZHorizon;
     220   bool SRTM_water;
          
           unsigned int MiniMapHeight;
           unsigned int MiniMapWidth;
          
           // Generate one or all maps ?
     226   bool mBatchMode;
          
           // Both
          
           /// ResourceGroupName
     231   String groupName;
     232   String cfgGroupName;
          
     234   bool lit;
     235   bool normals;
     236   bool colored;
          
     238   bool coverage_vertex_color;
     239   bool base_vertex_color;
     240   bool vertex_shadowed;
     241   bool vertex_instant_colored;
          
     243   bool BigImage;
     244   bool VisMap;
     245   bool MaxLodUnderCam;
          
     247   Real TextureStretchFactor;
          
           unsigned int RenderableLoadInterval;
           unsigned int PageLoadInterval;
          
           unsigned int TileInvisibleUnloadFrames;
           unsigned int PageInvisibleUnloadFrames;
          
           unsigned int NumSplatMapToSplit;
     256   std::vector<String> SplatMapNames;
          
           unsigned int NumTextureFormatSupported;
     259   std::vector<String> TextureFormatSupported;
          
     261   bool queryNoInterpolation;
     262   Real queryResolutionFactor;
          
     264   bool materialPerPage;
     265   bool textureModifiable;
          
     267   Vector3 BaseCameraViewpoint;
     268   Vector3 Baselookat;
          
     270   bool setUint (  unsigned int &u,   const String &ValuetoGet );
     271   bool setBool (  bool &b,   const String &ValuetoGet );
     272   bool setReal (  Real &r,  const String &ValuetoGet );
     273   bool setColourValue(  ColourValue &r,  const String &ValuetoGet );
     274   bool setString (  String &s,   const String &ValuetoGet );
          
     276   StringVector mResourceFilesystem;
     277   StringVector mResourceZip;
          
     279   PagingLandScapeSceneManager *mScnMgr;
          
     281   void setTileInfo(  PagingLandScapeTileInfo *t );
     282   PagingLandScapeTileInfo *getTileInfo(  const uint pageX,   const uint pageZ,  
     283   const uint tileX,   const uint tileZ );
     284   void loadMapInfo(   );
     285   void clearTileInfo(   );
     286   void saveMapInfo(   );
          
           private:
          
     290   void loadcfg (  const String &filename,   ConfigFile& config );
     291   ColourValue _getAvgColor(  const String& tex ) const;
     292   String mCurrentMap;
     293   LandScapeFileNames mMapList;
     294   StringVector mTextureFormats;
     295   bool isInit;
     296   ConfigFile *mConfig;
          
     298   std::deque<PagingLandScapeTileInfo*> mTileInfoCache;
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapePage.h

          /***************************************************************************
           OgrePagingLandScapePage.h - description
           -------------------
           begin : Sat Mar 08 2003
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapePAGE_H
          #define PAGINGLandScapePAGE_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
          
           class _OgrePagingLandScapeExport PagingLandScapePage
           {
           public:
           /** Sets the appropriate neighbor for this TerrainRenderable. Neighbors are necessary
           to know when to bridge between LODs.
           */
      33   void _setNeighbor(  const Neighbor& n,   PagingLandScapePage* p );
          
           /** Returns the page's scene node
           */
      37   SceneNode* getPageNode(   ) const { return mPageNode; }
          
           /** Returns the neighbor TerrainRenderable.
           */
      41   PagingLandScapePage* _getNeighbor(  const Neighbor& n ) const
           {
           return mNeighbors[ n ];
           };
          
      46   PagingLandScapeTile* getTile(  const unsigned int i ,   const unsigned int j ) const;
          
      48   PagingLandScapeTile* getTile(  const Vector3& pos );
      49   PagingLandScapePage(  PagingLandScapePageManager *pageMgr );
          
           virtual ~PagingLandScapePage(  void );
          
           /** Whole Map changes */
           void init(  const unsigned int tableX,   const unsigned int tableZ );
          
           /** Release the page,   but keep it reusable if Whole Map changes */
           void uninit(  void );
          
           /** Pre-loads the LandScape data using parameters int he given in the constructor. */
           void preload(  void );
          
           /** Loads the LandScape tiles using parameters int he given in the constructor. */
           void load(  void );
          
           /** Unloads the LandScape data,   then reloads it */
           void reload(  void );
          
           /** Loads the LandScape texture using parameters int he given in the constructor. */
           void loadTexture(  void );
          
           /** Unloads the LandScape texture,   but doesn't destroy the LandScape data. */
           void unloadTexture(  void );
          
           /** Unloads the LandScape data,   but doesn't destroy the LandScape page. */
           void unload(  void );
          
           /** Post Unloads the LandScape data,   but doesn't destroy the LandScape page. */
           void postUnload(  void );
          
           void unsetLoading(  void )
           {
           mIsLoading = false;
           };
          
           void unsetPreLoading(  void )
           {
           mIsPreLoading = false;
           };
          
           void unsetTextureLoading(  void )
           {
           mIsTextureLoading = false;
           };
          
           void unsetUnloading(  void )
           {
           mIsUnloading = false;
           };
          
           void unsetPostUnloading(  void )
           {
           mIsPostUnloading = false;
           };
          
           void unsetTextureunloading(  void )
           {
           mIsTextureunloading = false;
           };
          
           const bool isLoaded(  void ) const
           {
           return mIsLoaded;
           };
          
           const bool isPreLoaded(  void ) const
           {
           return mIsPreLoaded;
           };
          
           const bool isTextureLoaded(  void ) const
           {
           return mIsTextureLoaded;
           };
          
           const bool isLoadable(  void ) const
           {
           return mIsLoadable;
           };
          
           const bool unloadUntouched(  void );
           void touch(  void );
          
           bool isVisible(  void ) const
           {
           return mVisible;
           }
          
           /** Returns if the camera is over this LandScape page.
           */
           int isCameraIn(  const Vector3& pos ) const;
          
           bool _Notify(  const Vector3 &pos,   const PagingLandScapeCamera * const Cam );
           void _Show(  const bool do_show );
          
           void getCoordinates(  unsigned int& X,   unsigned int& Z ) const
           {
           X = mTableX;
           Z = mTableZ;
           };
          
          
           bool mIsLoading;
           bool mIsPreLoading;
           bool mIsTextureLoading;
          
          
           bool mIsUnloading;
           bool mIsPostUnloading;
           bool mIsTextureunloading;
          
           /** Sets the render queue group which the tiles should be rendered in. */
           void setRenderQueue(  uint8 qid );
          
           void _updateLod(  void );
          
           void setMapMaterial(  void );
          
           inline bool isCoord(  const unsigned int x,   const unsigned int z ){return (  mTableZ == z && mTableX == x );};
          
           SceneNode *getSceneNode(   ){return mPageNode;};
           const AxisAlignedBox &getWorldBbox(   ) const {return mBounds;};
           const Vector3 &getCenter(  void ) const {return mWorldPosition;};
          
           protected:
           SceneNode* mPageNode;
          
           PagingLandScapeTiles mTiles;
          
           bool mIsLoaded;
           bool mIsPreLoaded;
           bool mIsTextureLoaded;
          
           // if data needed for this page doesn't exists
           bool mIsLoadable;
          
           bool mVisible;
           // ensure page is not flickering due to shadow passes
           // as it unload instantly
           // but loading is queued
           // if not page not showed until mVisibletouch==0 it becomes invisible
           //size_t mVisibletouch;
          
           // Position of this Terrain Page in the Terrain Page Array
           unsigned int mTableX;
           unsigned int mTableZ;
          
           unsigned int mNumTiles;
          
           Real mIniX; //,   mEndX; // Max and Min values of the terrain
           Real mIniZ; //,   mEndZ;
          
           PagingLandScapePage* mNeighbors[4];
          
           // Change Zone values
           AxisAlignedBox mBounds;
           AxisAlignedBox mBoundsInt;
           AxisAlignedBox mBoundsExt;
           Vector3 mWorldPosition;
          
           PagingLandScapePageRenderable* mRenderable;
          
           unsigned int mTimeUntouched;
          
           PageState pageState;
           PageQueuingState pageQueingState;
           PagingLandScapePageManager *mParent;
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapePageManager.h

          /***************************************************************************
           OgrePagingLandScapePageManager.h - description
           -------------------
           begin : Sat May 01 2004
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapePAGEMANAGER_H
          #define PAGINGLandScapePAGEMANAGER_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgreSingleton.h"
          #include "OgreFrameListener.h"
          #include "OgrePagingLandScapeQueue.h"
          
          #include "OgrePagingLandScapePage.h"
          
          namespace Ogre
          {
           class _OgrePagingLandScapeExport PagingLandScapePageManager : public FrameListener
           {
           public:
          
           ///ctor
      35   PagingLandScapePageManager(  PagingLandScapeSceneManager * scnMgr );
           ///dtor
      37   ~PagingLandScapePageManager(  void );
          
           /// upon new landscape
      40   void load(  void );
           /// empty before loading a landscape or final deletion
      42   void clear(  void );
           /// reset paging but keep page pool in memory
      44   void reset(  void );
          
           /// used to load first page earlier than first updatePaging(   ) call
           /// say like just after scene manager setWorldGeom(   )
      48   void LoadFirstPage(  PagingLandScapeCamera* cam );
           /// Make sure page under camera is loaded,  
           /// that neighbor pages are preLoaded,   preLoading
           /// and process queues accordingly
      52   void updatePaging(  PagingLandScapeCamera* cam );
          
           // recursively call LOD update on all page and tiles
      55   void _updateLod(  void );
          
           // load everything around camera just now.
      58   void loadNow(  PagingLandScapeCamera *cam );
           // Make sure page gets into loaded page list when loaded from outside
           // ie "LoadNow" getOption
      61   void addLoadedPage(  PagingLandScapePage *p );
          
           /// if page is already instantiated get page at this pos,  
           /// otherwise allocate one,   if alwaysReturn is set true.
      65   PagingLandScapePage* getPage(  const unsigned int i ,   const unsigned int j,  
           const bool alwaysReturn = true );
           /// Instantiate a new page from pool.
      68   PagingLandScapePage* getNewPage(  const unsigned int i ,   const unsigned int j );
           /// Return a page to the pool.
      70   void releasePage (  PagingLandScapePage*p  );
          
           /// get Tile at absolute position in space,   return answer even when position is outside landscape
           /// when alwaysAnswer is true
      74   PagingLandScapeTile* getTile(  const Real posx,   const Real posz,   bool alwaysAnswer );
           /// get Tile at absolute position but unscaled by landscape scale in space,  
           /// return answer even when position is outside landscape
           /// when alwaysAnswer is true
      78   PagingLandScapeTile* getTileUnscaled(  const Real posx,   const Real posz,   bool alwaysAnswer );
           // get Tile at relative position (  in the page containing the tile page coordinate system ) in space,  
           /// return answer even when position is outside landscape
           /// when alwaysAnswer is true
      82   PagingLandScapeTile* getTile(  const Real posx,   const Real posz,  
           const unsigned int pagex,   const unsigned int pagez,  
           bool alwaysAnswer );
           // get Tile at relative position but unscaled by landscape scale (  in the page containing the tile page coordinate system ) in space,  
           /// return answer even when position is outside landscape
           /// when alwaysAnswer is true
      88   PagingLandScapeTile* getTileUnscaled(  const Real posx,   const Real posz,  
           const unsigned int pagex,   const unsigned int pagez,  
           bool alwaysAnswer );
           // get Tile at relative position but unscaled by landscape scale (  in the page containing the tile page coordinate system ) in space,  
           /// return answer even when position is outside landscape
           /// when alwaysAnswer is true
      94   PagingLandScapeTile* getTilePage (  unsigned int &posx,   unsigned int &posz,   const unsigned int pagex,   const unsigned int pagez );
          
      96   void getGlobalToPage(  Real& x,   Real& z ) const;
           /** Get the Page indices from a position
           @param posx the world position vector.
           @param posz the world position vector.
           @param x result placed in reference to the x index of the page
           @param z result placed in reference to the z index of the page
           */
     103   inline bool getPageIndices(  const Real posx,   const Real posz,   unsigned int& x,   unsigned int& z,   bool alwaysAnswer ) const
           {
           if (  alwaysAnswer )
           {
           getNearestPageIndicesUnscaled(  posx * mOptions->invScale.x,   posz* mOptions->invScale.z,   x,   z );
           return true;
           }
           else
           {
           return getRealPageIndicesUnscaled(  posx * mOptions->invScale.x,   posz* mOptions->invScale.z,   x,   z );
           }
           }
           /** Get the Page indices from a position,   returning page only if position is in.
           @param posx the world position vector but unscaled.
           @param posz the world position vector but unscaled.
           @param x result placed in reference to the x index of the page
           @param z result placed in reference to the z index of the page
           */
     121   inline bool getRealPageIndicesUnscaled(  const Real posx,   const Real posz,  
           unsigned int& x,   unsigned int& z )
           const
           {
           const Real lx = (  (  posx + mOptions->maxUnScaledX ) * mOptions->invPageSizeMinusOne );
           const Real lz = (  (  posz + mOptions->maxUnScaledZ ) * mOptions->invPageSizeMinusOne );
          
           // make sure indices are not negative or outside range of number of pages
           if (  lx >= mOptions->world_width || lx < static_cast <Real> (  0.0 ) ||
           lz >= mOptions->world_height || lz < static_cast <Real> (  0.0 )  )
           {
           return false;
           }
           else
           {
           x = static_cast< unsigned int > (  lx );
           z = static_cast< unsigned int > (  lz );
           return true;
           }
           }
           /** Get the Page indices from a position,   always returning a page.
           @param posx the world position vector but unscaled.
           @param posz the world position vector but unscaled.
           @param x result placed in reference to the x index of the page
           @param z result placed in reference to the z index of the page
           */
     147   void getNearestPageIndicesUnscaled(  const Real posx,   const Real posz,   unsigned int& x,   unsigned int& z ) const;
          
           /** Get the Tile indices from a position
           @param posx the world position vector.
           @param posz the world position vector.
           @param pagex the world position page number.
           @param pagez the world position page number.
           @param x result placed in reference to the x index of the page
           @param z result placed in reference to the z index of the page
           */
     157   bool getTileIndices(  const Real posx,   const Real posz,   const unsigned int pagex,   const unsigned int pagez,   unsigned int& x,   unsigned int& z,   bool alwaysAnswer ) const;
          
           /** Get the Tile indices from a position,   returning tile only if position is in.
           @param posx the world position vector but unscaled.
           @param posz the world position vector but unscaled.
           @param x result placed in reference to the x index of the page
           @param z result placed in reference to the z index of the page
           */
     165   inline bool getRealTileIndicesUnscaled(  const Real posx,   const Real posz,  
           const unsigned int pagex,   const unsigned int pagez,  
           unsigned int& x,   unsigned int& z ) const
           {
           // adjust x and z to be local to page
           const int pSize = mOptions->PageSize - 1;
           const int tilex = static_cast< int >(  (  posx - (  (  pagex * pSize ) - mOptions->maxUnScaledX ) ) * mOptions->invTileSizeMinusOne );
           const int tilez = static_cast< int >(  (  posz - (  (  pagez * pSize ) - mOptions->maxUnScaledZ ) ) * mOptions->invTileSizeMinusOne );
          
          
           const int tilesPerPage = static_cast< int >(  mOptions->NumTiles );
           //const int tilesPerPage = static_cast< int >(  mOptions->NumTiles(  pSize * inv_tSize ) - 1 );
          
           if (  tilex > tilesPerPage || tilex < 0 ||
           tilez > tilesPerPage || tilez < 0 )
           {
           return false;
           }
           else
           {
           x = static_cast< unsigned int >(  tilex );
           z = static_cast< unsigned int >(  tilez );
           return true;
           }
           }
          
           /** Get the Tile indices from a position,   returning tile only if position is in.
           @param posx the world position vector but unscaled.
           @param posz the world position vector but unscaled.
           @param x result placed in reference to the x index of the page
           @param z result placed in reference to the z index of the page
           */
     197   void getNearestTileIndicesUnscaled(  const Real posx,   const Real posz,   const unsigned int pagex,   const unsigned int pagez,   unsigned int& x,   unsigned int& z ) const;
          
     199   void setTerrainReady(  bool isready )
           {
           mTerrainReady = isready;
           };
          
          
     205   void removeFromQueues(  PagingLandScapePage* p );
          
     207   bool frameStarted(  const FrameEvent& evt );
     208   bool frameEnded(  const FrameEvent& evt );
          
     210   void setWorldGeometryRenderQueue(  uint8 qid );
     211   RenderQueueGroupID getRenderQueueGroupID(  void )
           {
           return mRenderQueueGroupID;
           };
          
     216   void setMapMaterial(  void );
     217   void WorldDimensionChange(  void );
          
          
          
           /// getter
     222   unsigned int getCurrentCameraPageX(  void ) const;
           /// getter
     224   unsigned int getCurrentCameraPageZ(  void ) const;
           /// getter
     226   unsigned int getCurrentCameraTileX(  void ) const;
           /// getter
     228   unsigned int getCurrentCameraTileZ(  void ) const;
           /// getter
     230   int getPagePreloadQueueSize(  void ) const;
           /// getter
     232   int getPageLoadQueueSize(  void ) const;
           /// getter
     234   int getPageTextureloadQueueSize(  void ) const;
           /// getter
     236   int getLoadedPageSize(  void ) const;
           /// getter
     238   int getPreLoadedPageSize(  void ) const;
           /// getter
     240   int getTextureLoadedPageSize(  void ) const;
           /// getter
     242   int getUnloadedPagesSize(  void ) const;
          
     244   RenderQueueGroupID getPageRenderQueue(   ){return mRenderQueueGroupID;};
          
     246   PagingLandScapeOptions* getOptions(   ){return mOptions;}
     247   PagingLandScapeSceneManager* getSceneManager(   ){return mSceneManager;}
          
     249   bool isEnabled (   )const {return mEnabled;}
     250   void setEnabled (  const bool enabled ){mEnabled = enabled;}
          
           protected:
          
           PagingLandScapeOptions* mOptions;
           PagingLandScapeSceneManager *mSceneManager;
          
          
          
           void processUnloadQueues(   );
           void processLoadQueues(   );
           void updateLoadedPages(   );
           void queuePageNeighbors (   );
          
           void makePageLoadedNow(  PagingLandScapePage* p );
           PagingLandScapePage* find_nearest(  const Vector3& pos,   const unsigned int x,   const unsigned int z,   PagingLandScapePageList& mQueue ) const;
          
           PagingLandScapeData2DManager* mData2d;
           PagingLandScapeTextureManager* mTexture;
           PagingLandScapeRenderableManager* mRenderablesMgr;
          
           /** LandScape pages for the terrain.
           */
           //PagingLandScapePages mPages;
          
           PagingLandScapeQueue <PagingLandScapePage> mPageLoadQueue;
           PagingLandScapeQueue <PagingLandScapePage> mPagePreloadQueue;
           PagingLandScapeQueue <PagingLandScapePage> mPageTextureloadQueue;
          
           PagingLandScapePageList mLoadedPages;
           PagingLandScapePageList mPreLoadedPages;
           PagingLandScapePageList mTextureLoadedPages;
          
           PagingLandScapePageList mActivePages;
           PagingLandScapePageList mFreePages;
           PagingLandScapePageArray mPagePool;
          
           unsigned int mWidth;
           unsigned int mHeight;
          
           int mNextQueueFrameCount;
           int mTimePreLoaded;
          
           int mPause;
          
           PagingLandScapeCamera* mCurrentcam;
           bool mTerrainReady;
           bool mOnFrame;
          
           unsigned int mRenderableLoadInterval;
           unsigned int mPageLoadInterval;
          
           RenderQueueGroupID mRenderQueueGroupID;
          
           //if not queued to be removed from frame listener
           //or SM is in paused State
           bool mEnabled;
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapePageRenderable.h

       1  /***************************************************************************
           OgrePagingLandScapePageRenderable.h - description
           -------------------
           begin : Thu Feb 27 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
           * *
           * This program is free software; you can redistribute it and/or modify *
           * it under the terms of the GNU General Public License as published by *
           * the Free Software Foundation; either version 2 of the License,   or *
           * (  at your option ) any later version. *
           * *
           ***************************************************************************/
          
          #ifndef PagingLandScapePageRenderable_H
          #define PagingLandScapePageRenderable_H
          
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          
          namespace Ogre
          {
          
           /** Represents a LandScape page in terms of vertexes.
           @remarks
           A LandScapeRenderable represents a Page used to render a
           block of LandScape using the procedural terrain approach for LOD.
           */
      33   class PagingLandScapePageRenderable : public Renderable,   public MovableObject
           {
           public:
          
           /** Initializes the LandScapeRenderable with the given options and the starting coordinates of this block.
           */
      39   PagingLandScapePageRenderable(  PagingLandScapePageManager *pageMgr,   const String& name,   const unsigned int pageX,   const unsigned int pageZ,   const AxisAlignedBox& bounds );
          
      41   virtual ~PagingLandScapePageRenderable(  void );
          
      43   void load(  void );
          
      45   void setMaterial(  const MaterialPtr& mat );
          
      47   const Real getMaxHeight(  void )
           {
           return (  mBounds.getMaximum(   ) ).y;
           };
          
      52   static PagingLandScapeOptions* mOpt;
          
           /////////Movable overridden object methods
          
           /** Updates the level of detail to be used for rendering this TerrainRenderable based on the passed in Camera */
      57   inline void _notifyCurrentCamera(  Camera* cam )
           {
           //if (  static_cast<PagingLandScapeCamera*> (  cam )->isVisible (  mBounds.getAllCorners(   ) ) )
           //{
           mVisible = true;
           // MovableObject::_notifyCurrentCamera(  cam );
           //}
           //else
           // mVisible = false;
           }
      67   void _updateRenderQueue(  RenderQueue* queue );
          
           /** Returns the type of the movable. */
      70   virtual const String& getMovableType(  void ) const
           {
           return mType;
           };
          
           /** Returns the bounding box of this TerrainRenderable */
      76   const AxisAlignedBox& getBoundingBox(  void ) const
           {
           return mBounds;
           };
          
           /////////Renderable object methods
           /**
           Constructs a RenderOperation to render the TerrainRenderable.
           @remarks
           Each TerrainRenderable has a block of vertices that represent the terrain. Index arrays are dynamically
           created for mipmap level,   and then cached.
           */
      88   virtual void getRenderOperation(  RenderOperation& rend );
          
      90   virtual const MaterialPtr& getMaterial(  void ) const
           {
           return mMaterial;
           };
          
      95   virtual void getWorldTransforms(  Matrix4* xform ) const;
          
      97   virtual const Quaternion& getWorldOrientation(  void ) const;
      98   virtual const Vector3& getWorldPosition(  void ) const;
          
           /** @copydoc Renderable::getLights */
     101   const LightList& getLights(  void ) const;
          
     103   virtual Technique* getTechnique(  void ) const;
          
     105   virtual Real getSquaredViewDepth(  const Camera* cam ) const;
          
     107   virtual Real getBoundingRadius(  void ) const;
          
           /// @see MovableObject
     110   uint32 getTypeFlags(  void ) const;
          
           protected:
          
     114   PagingLandScapePageManager *mParent;
          
     116   VertexData* mCurrVertexes;
     117   IndexData* mCurrIndexes;
          
           /// Bounding box of this tile
     120   AxisAlignedBox mBounds;
           /// The center point of this tile
     122   Vector3 mCenter;
           /// The MovableObject type
     124   static String mType;
           /// Current material used by this tile
     126   MaterialPtr mMaterial;
          
           unsigned int mX;
           unsigned int mZ;
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapePoolSet.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          
          #ifndef __OgrePagingLandScapePoolSet_H__
          #define __OgrePagingLandScapePoolSet_H__
          
          #include <list>
          #include <vector>
          
          
          namespace Ogre
          {
           /** A collection of pre-allocated object instance of a same base class
           */
      37   template <class T> class PoolSet
           {
           protected:
          
           typedef std::list<T*> ActivePoolableList;
           typedef std::list<T*> FreePoolableList;
           typedef std::vector<T*> PoolablePool;
          
           public:
          
           /** Usual constructor
           @param
           poolSize The initial size of the object pool. Estimate of the number of objects
           which will be required,   and pass it using this parameter. The set will
           preallocate this number to avoid memory fragmentation. The default behaviour
           once this pool has run out is to double it.
           @see
           PoolSet::setAutoextend
           */
           PoolSet(  unsigned int poolSize = 0,   bool autoExtendPool = true ):
           mAutoExtendPool(  autoExtendPool ),  
           mAutoExtendFactor(  2.0f ),  
           mPoolSize(  poolSize )
           {
           assert (  mFreePoolables.empty(   ) );
           assert (  mActivePoolables.empty(   ) );
           assert (  mPoolablePool.empty(   ) );
          
           setPoolSize(  poolSize );
           }
           /**
           dtor
           */
           virtual ~PoolSet(   )
           {
           assert (  mPoolSize == 0 && mPoolablePool.empty(   ) );
           }
           /**
           empty totally the pool.
           */
      77   void deletePool(   )
           {
           // Free pool items
           for (  typename PoolablePool::iterator i = mPoolablePool.begin(   );
           i != mPoolablePool.end(   ); ++i )
           {
           deallocate (  *i );
           }
           mPoolablePool.clear(   );
           mFreePoolables.clear(   );
           mActivePoolables.clear(   );
           mPoolSize = 0;
           }
           /** Creates a new pooled object and adds it to this set.
           @remarks
           Behavior once the query pool has been exhausted depends on the
           PoolSet::setAutoextendPool option.
           @returns
           On success,   a pointer to a newly created Poolable is
           returned.
           @par
           On failure (  i.e. no more space and can't autoextend ),  
           <b>NULL</b> is returned.
           @see
           PoolSet::setAutoextend
           */
     103   T* getPoolable(   )
           {
           if (  mFreePoolables.empty(   ) )
           {
           if (  mAutoExtendPool )
           {
           autoExtend (   );
           }
           else
           {
           return 0;
           }
           }
           // Get a new Object
           T* newPoolable = mFreePoolables.front(   );
           mFreePoolables.pop_front(   );
           mActivePoolables.push_back(  newPoolable );
          
           return newPoolable;
           }
           /*
           Extend the pool Size by a mAutoExtendFactor factor (  default 2.0f )
           */
     126   void autoExtend(   )
           {
           unsigned int newSize = (  unsigned int )(  mPoolSize * mAutoExtendFactor );
           if (  newSize <= mPoolSize )
           newSize = mPoolSize + 1;
           setPoolSize (  newSize );
           }
           /*
           Extend the pool Size by this factor (  default is 2.0f )
           */
     136   void setExtendFactor(  const float factor )
           {
           assert(  factor >= 1.0f );// otherwise you'll make it smaller
           mAutoExtendFactor = factor;
           }
           /** Removes a pooled object from the set.
           @note
           This version is more efficient than removing by index.
           */
     145   void removePoolable(  T * const pPoolable )
           {
           mActivePoolables.remove (  pPoolable );
           mFreePoolables.push_back (  pPoolable );
           }
           /** Returns the number of active object which currently make up this set.
           */
     152   size_t getActivePoolablesSize(  void ) const
           {
           return static_cast< size_t >(  mActivePoolables.size(   ) );
           }
     156   ActivePoolableList &getActivePoolables(  void )
           {
           return mActivePoolables;
           }
           /** Tells the set whether to allow automatic extension of the pool of objects.
           @remarks
           A PoolSet stores a pool of pre-constructed queries which are used as needed when
           a new object is requested. This allows applications to create / remove objects efficiently
           without incurring construction / destruction costs. This method allows you to configure
           the behavior when a new object is requested but the object pool has been exhausted.
           @par
           The default behavior is to allow the pool to extend (  typically this allocates double the current
           pool of queries when the pool is expended ),   equivalent to calling this method with
           autoExtend = true. If you set the parameter to false however,   any attempt to create a new pooled object
           when the pool has expired will simply fail silently,   returning a null pointer.
           @param autoextend true to double the pool every time it runs out,   false to fail silently.
           */
     173   void setAutoextend(  bool autoextend )
           {
           mAutoExtendPool = autoextend;
           }
           /** Returns true if the object pool automatically extends.
           @see
           PoolSet::setAutoextend
           */
     181   bool getAutoextend(  void ) const
           {
           return mAutoExtendPool;
           }
           /** Adjusts the size of the pool of object available in this set.
           @remarks
           See the PoolSet::setAutoextend method for full details of the query pool. This method adjusts
           the preallocated size of the pool. If you try to reduce the size of the pool,   the set has the option
           of ignoring you if too many objects are already in use. Bear in mind that calling this method will
           incur significant construction / destruction calls so should be avoided in time-critical code. The same
           goes for auto-extension,   try to avoid it by estimating the pool size correctly up-front.
           @param
           size The new size for the pool.
           */
     195   void setPoolSize(  const unsigned int size )
           {
           // Never shrink below size(   )
           const size_t currSize = mPoolablePool.size(   );
          
           if(  currSize < size )
           {
           increasePool(  size );
           for (  size_t i = currSize; i < size; ++i )
           {
           // Add new items to the queue
           mFreePoolables.push_back (  mPoolablePool[i] );
           }
           mPoolSize = size;
           }
           }
           /** Returns the current size of the object pool.
           @returns
           The current size of the object pool.
           @see
           PoolSet::setAutoextend
           */
     217   unsigned int getPoolSize(  void ) const
           {
           return static_cast< unsigned int >(  mPoolablePool.size(   ) );
           }
           /** Empties this set of all Actives object (  but do not delete them ).
           */
     223   void clear(   )
           {
           // Insert actives into free list
           mFreePoolables.insert(  mFreePoolables.end(   ),   mActivePoolables.begin(   ),   mActivePoolables.end(   ) );
          
           // Remove all active instances
           mActivePoolables.clear(   );
           }
          
           protected:
           /** Active object list.
           @remarks
           This is a linked list of pointers to objects in the object pool.
           @par
           This allows very fast insertions and deletions from anywhere in the list to activate / deactivate objects
           (  required for particle systems etc ) as well as reuse of Poolable instances in the pool
           without construction & destruction which avoids memory thrashing.
           */
           ActivePoolableList mActivePoolables;
           /** Free object queue.
           @remarks
           This contains a list of the objects free for use as new instances
           as required by the set. Poolable instances are pre-constructed up to the estimated size in the
           mPoolablePool vector and are referenced on this deque at startup. As they get used this deque
           reduces,   as they get released back to to the set they get added back to the deque.
           */
           FreePoolableList mFreePoolables;
           /** Pool of objects instances for use and reuse in the active query list.
           @remarks
           This vector will be preallocated with the estimated size of the set,  and will extend as required.
           */
           PoolablePool mPoolablePool;
           /// The number of query in the pool.
           unsigned int mPoolSize;
           /// Flag indicating whether to auto extend pool
           bool mAutoExtendPool;
           // by how much we will auto extend current pool
           Real mAutoExtendFactor;
          
           /// method for increasing pool size
           void increasePool(  unsigned int size )
           {
           assert (  size > 0 );
           const size_t oldSize = mPoolablePool.size(   );
          
           // Increase size
           mPoolablePool.reserve(  size );
           mPoolablePool.resize(  size );
          
           // Create new queries
           for (  size_t i = oldSize; i < size; ++i )
           mPoolablePool[i] = allocate(   );
           }
           protected :
           virtual T* allocate(   ) = 0;
           virtual void deallocate(  T* p ) = 0;
          
           };
          
          }
          
          #endif//__OgrePagingLandScapePoolSet_H__

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapePrecompiledHeaders.h

       1  /***************************************************************************
          OgrePagingLandScapePrecompiledHeaders.cpp - description
          -------------------
          copyright : (  C ) 2006 Tuan Kuranes
          email : tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          #ifndef _PRECOMP_HEADERS
          #define _PRECOMP_HEADERS
          
          #ifdef _PRECOMPILED_HEADERS
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          // -------------------------------------------------------
          // Octree Scene Manager (   occlusion management inside  )
          // -------------------------------------------------------
          
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeCamera.h"
          
          #include "OgrePagingLandScapeOctreeAxisAlignedBoxSceneQuery.h"
          #include "OgrePagingLandScapeOctreeIntersectionSceneQuery.h"
          #include "OgrePagingLandScapeOctreePlaneBoundedVolumeListSceneQuery.h"
          #include "OgrePagingLandScapeOctreeRaySceneQuery.h"
          #include "OgrePagingLandScapeOctreeSphereSceneQuery.h"
          
          //hardware occlusion management
          
          
          #include "OgreOcclusionBoundingBox.h"
          #include "OgrePagingLandScapeOcclusionQuerySet.h"
          #include "OgrePagingLandScapeOcclusionSorter.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          #include "OgrePagingLandScapeOcclusionCameraTraversal.h"
          #include "OgrePagingLandScapeOcclusionDebugTraversal.h"
          
          #include "OgrePagingLandScapeOcclusionCHCTraversal.h"
          #include "OgrePagingLandScapeOcclusionSWTraversal.h"
          #include "OgrePagingLandScapeOcclusionVFTraversal.h"
          
          
          #include "OgrePagingLandScapeOcclusion.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          #include "OgrePagingLandScapeOcclusionVisibilityData.h"
          
          
          // -------------------------------------------------------
          // Paging Scene Manager
          // -------------------------------------------------------
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          
          #include "OgrePagingLandScapeRaySceneQuery.h"
          #include "OgrePagingLandScapeIntersectionSceneQuery.h"
          #include "OgrePagingLandScapeAxisAlignedBoxSceneQuery.h"
          
          // Horizon Culling
          #include "OgrePagingLandScapeHorizon.h"
          
          // Queues
          
          
          // pages
          #include "OgrePagingLandScapePage.h"
          #include "OgrePagingLandScapePageRenderable.h"
          #include "OgrePagingLandScapePageManager.h"
          
          
          // Tile Management (  page is constituted of tiles. )
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapeTileInfo.h"
          #include "OgrePagingLandScapeTileManager.h"
          
          // IndexBuffer Caching to share it across tiles and LOD
          #include "OgrePagingLandScapeIndexBuffer.h"
          // Texture coordinates buffer cache to share it across pages
          #include "OgrePagingLandScapeTextureCoordinatesManager.h"
          
          // Renderable that constitutes tiles
          #include "OgrePagingLandScapeRenderable.h"
          #include "OgrePagingLandScapeRenderableManager.h"
          
          
          // Terrain Data Source management
          #include "OgrePagingLandScapeData2D.h"
          
          #include "OgrePagingLandScapeData2D_HeightField.h"
          #include "OgrePagingLandScapeData2D_HeightFieldTC.h"
          #include "OgrePagingLandScapeData2D_HeightFieldN.h"
          #include "OgrePagingLandScapeData2D_HeightFieldNTC.h"
          
          #include "OgrePagingLandScapeData2D_HeightFieldRaw.h"
          #include "OgrePagingLandScapeData2D_HeightFieldRawTC.h"
          
          #include "OgrePagingLandScapeData2D_Spline.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          
          
          // Terrain Texture Source management
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTexture_Splatting.h"
          #include "OgrePagingLandScapeTexture_BaseTexture.h"
          
          #include "OgrePagingLandScapeTextureManager.h"
          
          // User Call back system using listener pattern
          #include "OgrePagingLandScapeListenerManager.h"
          #include "OgrePagingLandScapeListener.h"
          #include "OgrePagingLandScapeCallback.h"
          #include "OgrePagingLandScapeCallbackEvent.h"
          
          //decals
          
          #include "OgrePagingLandScapeMeshDecal.h"
          
          //utils
          
          #include "OgrePagingLandscapePoolSet.h"
          #include "OgrePagingLandscapeQueue.h"
          
          #include "OgreDebugRectangle2D.h"
          #include "fileutils.h"
          
          #endif
          #endif //_PRECOMP_HEADERS

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapePrerequisites.h

       1  /***************************************************************************
           OgrePagingLandScapePrerequisites.h - description
           -------------------
           begin : Sun Oct 26 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
           * *
           * This program is free software; you can redistribute it and/or modify *
           * it under the terms of the GNU General Public License as published by *
           * the Free Software Foundation; either version 2 of the License,   or *
           * (  at your option ) any later version. *
           * *
           ***************************************************************************/
          
          #ifndef __PagingLandScapePrerequisites_H__
          #define __PagingLandScapePrerequisites_H__
          
          
          #include <OgrePrerequisites.h>
          
          #include <OgreHardwareBufferManager.h>
          #include <OgreTextureManager.h>
          #include <OgreHardwarePixelBuffer.h>
          #include <OgreAxisAlignedBox.h>
          
          //-----------------------------------------------------------------------
          // Options
          //-----------------------------------------------------------------------
          
          //#define _VISIBILITYDEBUG
          
          #if !(  OGRE_VERSION < (  (  1 << 16 ) | (  3 << 8 ) | 0 ) )
           #define PLSM2_EIHORT 1
          #endif
          
          //-----------------------------------------------------------------------
          // Forward declarations
          //-----------------------------------------------------------------------
          
          #include <vector>
          #include <map>
          #include <queue>
          #include <list>
          #include <stack>
          #include <limits>
          
          
          namespace Ogre
          {
          
          
           // Octree Scene management
          
           typedef std::list < MovableObject* > MovableObjectList;
           typedef std::list < Renderable* > RenderableList;
          
      60   class PagingLandScapeOctreeSceneManager;
      61   class PagingLandScapeOctreeNode;
           typedef std::list<PagingLandScapeOctreeNode*> NodeList;
      63   class PagingLandScapeOctree;
      64   class PagingLandScapeOctreeCamera;
          
           #ifdef _VISIBILITYDEBUG
      67   class DebugRectangle2D;
           #endif //_VISIBILITYDEBUG
          
           // hardware occlusion management
      71   class QuerySet;
      72   class Occlusion;
      73   class VisibilityData;
      74   class OcclusionElement;
      75   class Between;
      76   class Leaf;
          
          
           typedef enum culling_modes
           {
           // STANDARD_WALK = 0,  
           // VIEW_FRUSTUM,  
           VIEW_FRUSTUM_DIRECT,  
           //STOP_AND_WAIT,  
           CHC,  
           CHC_CONSERVATIVE,  
           NUM_CULLING_MODE
           };
      89   class OcclusionBoundingBox;
           typedef std::list<OcclusionElement*> OcclusionElementList;
           typedef std::list<PagingLandScapeOctreeNode*> PagingLandScapeOctreeNodeList;
          
      93   class FrontToBackNodeSorterOperator;
           //priority queue for the nodes to traversal
           typedef std::priority_queue<OcclusionElement*,  std::vector<OcclusionElement*>,  FrontToBackNodeSorterOperator> FrontToBackNodeSorterPriorityQueue;
           //queue for the nodes with running occlusion queries
           typedef std::queue<OcclusionElement*> QueriedOcclusionElement; //queue for the nodes with running occlusion queries
          
          
     100   class Traversal;
     101   class TraversalConst;
     102   class ConstTraversalConst;
          
     104   class CHCTraversal;
     105   class SWTraversal;
     106   class ViewFrustumCullingTraversal;
     107   class ViewFrustumCullingTraversalDirect;
     108   class TreeOverlayDebug;
          
          
          
          
          
           // Paging Scene Management
          
     116   class PagingLandScapeSceneManager;
     117   class PagingLandScapeOptions;
     118   class PagingLandScapeCamera;
           typedef std::list< PagingLandScapeCamera* > PagingLandScapeCameraList;
          
     121   class PagingLandScapeRaySceneQuery;
          
           // Basic Horizon Culling (  based on tile max and min height )
     124   class PagingLandScapeHorizon;
          
           // Page Scene Management
     127   class PagingLandScapePage;
     128   class PagingLandScapePageRenderable;
     129   class PagingLandScapePageManager;
          
          #define PAGE_INSIDE 0x00000001
          #define PAGE_CHANGE 0x00000002
          #define PAGE_OUTSIDE 0x00000004
          
          
          typedef enum PageState
          {
           inited,  
           Preloaded,  
           Textureloaded,  
           Loaded
          };
          
          typedef enum PageQueuingState
          {
           queuednone,  
           queuedPreload,  
           queuedTextureLoad,  
           queuedLoad
          };
          
           typedef std::list< PagingLandScapePage* > PagingLandScapePageList;
           typedef std::vector< PagingLandScapePage* > PagingLandScapePageArray;
           typedef PagingLandScapePageArray PagingLandScapePageRow;
           typedef std::vector< PagingLandScapePageRow > PagingLandScapePages;
          
           // Tile Management (  page is constituted of tiles. )
     158   class PagingLandScapeTile;
     159   class PagingLandScapeTileInfo;
     160   class PagingLandScapeTileManager;
           typedef std::list< PagingLandScapeTile* > PagingLandScapeTileList;
           typedef std::vector< PagingLandScapeTile* > PagingLandScapeTileRow;
           typedef std::vector< PagingLandScapeTileRow > PagingLandScapeTiles;
          
          
           // IndexBuffer Caching to share it across tiles and LOD
     167   class PagingLandScapeIndexBufferManager;
           typedef std::map< unsigned int,   IndexData* > IndexMap;
           typedef std::vector< IndexData* > IndexArray;
           typedef std::vector< IndexMap* > LevelArray;
          
           // Renderable that constitutes tiles
     173   class PagingLandScapeRenderable;
     174   class PagingLandScapeRenderableSet;
     175   class PagingLandScapeRenderableManager;
           typedef std::vector< PagingLandScapeRenderable* > PagingLandScapeRenderableVector;
          
           // Texture coordinates buffer cache
     179   class PagingLandScapeTextureCoordinatesManager;
          
           // Terrain Data Source management
     182   class PagingLandScapeData2D;
     183   class PagingLandScapeData2DManager;
           typedef std::vector< PagingLandScapeData2D* > PagingLandScapeData2DArray;
           typedef std::list< PagingLandScapeData2D* > PagingLandScapeData2DList;
          
           typedef std::vector< PagingLandScapeData2D* > PagingLandScapeData2DRow;
           typedef std::vector< PagingLandScapeData2DRow > PagingLandScapeData2DPages;
          
           typedef std::vector<PagingLandScapeData2D*> PagingLandScapeData2DMap;
          
           // Terrain Texture Source management
     193   class PagingLandScapeTexture;
     194   class PagingLandScapeTextureManager;
          
           typedef std::vector< PagingLandScapeTexture* > PagingLandScapeTextureArray;
           typedef std::list< PagingLandScapeTexture* > PagingLandScapeTextureList;
          
           typedef std::vector< PagingLandScapeTexture* > PagingLandScapeTextureRow;
           typedef std::vector< PagingLandScapeTextureRow > PagingLandScapeTexturePages;
          
           typedef std::vector<PagingLandScapeTexture*> PagingLandScapeTextureMap;
          
          
           typedef std::vector< HardwareVertexBufferSharedPtr> HardwareTextureBuffersRow;
           typedef std::vector< HardwareTextureBuffersRow> HardwareTextureBuffersCol;
          
           // User Call back system using listener pattern
     209   class PagingLandScapeListenerManager;
     210   class PagingLandScapeListener;
     211   class PagingLandscapeEvent;
          
           // Multi-map management
           typedef std::map< String,   String > LandScapeFileNames;
          
           // Vertex Shader Hardware Morphing
           #define MORPH_CUSTOM_PARAM_ID 77
          
           // LOD
           enum Neighbor
           {
           NORTH = 0,  
           SOUTH,  
           EAST,  
           WEST
           };
          
           #define STITCH_NORTH_SHIFT 0
           #define STITCH_SOUTH_SHIFT 8
           #define STITCH_WEST_SHIFT 16
           #define STITCH_EAST_SHIFT 24
          
           #define STITCH_NORTH 128 << STITCH_NORTH_SHIFT
           #define STITCH_SOUTH 128 << STITCH_SOUTH_SHIFT
           #define STITCH_WEST 128 << STITCH_WEST_SHIFT
           #define STITCH_EAST 128 << STITCH_EAST_SHIFT
          
          }
          //-----------------------------------------------------------------------
          // Windows Settings
          //-----------------------------------------------------------------------
          
          #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
          # ifdef PLUGIN_PAGINGLANDSCAPE2_EXPORTS
          # define _OgrePagingLandScapeExport __declspec(  dllexport )
          # else
          # define _OgrePagingLandScapeExport __declspec(  dllimport )
          # endif
          #else
          # define _OgrePagingLandScapeExport
          #endif
          
          //STL trick to call delete in a for_each
          struct delete_object
          {
     256   template <typename T>
           void operator(   )(  T *ptr ){ delete ptr; ptr = 0;}
          };
          
          
          #ifndef ogre_restrict
          #ifdef __INTEL_COMPILER
          #define ogre_restrict restrict
          #elif _MSC_VER >= 1400
          #define ogre_restrict __restrict
          #else
          #define ogre_restrict
          #endif
          #endif
          
          
          // DEBUGGING
          
          #ifdef _PLSM2_RELEASE_ASSERT
           #undef assert
           extern "C"
           {
     278   _CRTIMP void __cdecl _assert(  const char*,   const char*,   unsigned );
           }
           #define assert(  exp ) (  void )(  (  exp ) || (  _assert(  #exp,   __FILE__,   __LINE__ ),   0 ) )
          #endif //_PLSM2_RELEASE_ASSERT
          
          #endif //__PagingLandScapePrerequisites_H__

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeQueue.h

          /***************************************************************************
           OgrePagingLandScapeQueue.h - description
           -------------------
           begin : Mon Aug 04 2003
           copyright : (  C ) 2003 by Jose A. Milan
           email : spoke2@supercable.es
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLANDSCAPEQUEUE_H
          #define PAGINGLANDSCAPEQUEUE_H
          
          #include <queue>
          #include <list>
          
          #include "Ogre.h"
          #include "OgreSceneNode.h"
          #include "OgreVector3.h"
          
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      32   inline Real vectorToBoxDistance(  const AxisAlignedBox &bbox,   const Vector3& point )
           {
           const Vector3 &boxMin = bbox.getMinimum (   );
           const Vector3 halfSize (  (  bbox.getMaximum (   ) - boxMin ) * 0.5 );
           // work in the box's coordinate system
           const Vector3 kDiff (  point - (  halfSize + boxMin ) );
           // compute squared distance and closest point on box
           Real fSqrDistance (  0.0 );
           for (  unsigned int i = 0; i < 3; i++ )
           {
           const Real kClosest = kDiff[i];
           const Real khalfSize = halfSize[i];
           if (  kClosest < -khalfSize )
           {
           const Real fDelta = kClosest + khalfSize;
           fSqrDistance += fDelta * fDelta;
           }
           else if (  kClosest > khalfSize )
           {
           const Real fDelta = kClosest - khalfSize;
           fSqrDistance += fDelta * fDelta;
           }
           }
           return fSqrDistance;
           }
           //-----------------------------------------------------------------------
           template <class T>
      59   class distanceToBoxSort
           {
           public:
           //-----------------------------------------------------------------------
      63   distanceToBoxSort(  const Vector3 &camPos ) : mCamPos(  camPos )
           {};
           //-----------------------------------------------------------------------
      66   bool operator(   )(  T* x,   T* y )
           {
          
           return (  x->getCenter(   ) - mCamPos ).squaredLength(   ) <
           (  y->getCenter(   ) - mCamPos ).squaredLength(   );
          
           //return vectorToBoxDistance (  x->getWorldBbox(   ),   mCamPos ) <
           // vectorToBoxDistance (  y->getWorldBbox(   ),   mCamPos );
           }
           private:
      76   const Vector3 mCamPos;
           };
           //-----------------------------------------------------------------------
           /** This class holds classes T given to it by the plugin in a FIFO queue. */
           template<class T>
      81   class PagingLandScapeQueue
           {
          
           public:
          
           //typedef std::queue<T *,   std::list<T *> > MsgQueType;
           typedef std::list<T *> MsgQueType;
          
           //-----------------------------------------------------------------------
      90   PagingLandScapeQueue(    )
           {
           };
           //-----------------------------------------------------------------------
      94   virtual ~PagingLandScapeQueue(    )
           {
           mQueue.clear (   );
           };
           //-----------------------------------------------------------------------
      99   void clear (   )
           {
           mQueue.clear (   );
           };
           //-----------------------------------------------------------------------
     104   void push(   T* e  )
           {
           assert (   std::find(  mQueue.begin(   ),   mQueue.end(   ),   e ) == mQueue.end(   ) );
           // Insert the element at the end of the queue
           mQueue.push_back (   e  );
           };
           //-----------------------------------------------------------------------
           typename MsgQueType::iterator begin(   )
           {
           return mQueue.begin (   );
           };
           //-----------------------------------------------------------------------
           typename MsgQueType::iterator end(   )
           {
     118   return mQueue.end (   );
           };
           //-----------------------------------------------------------------------
           typename MsgQueType::iterator erase(  typename MsgQueType::iterator it )
           {
     123   return mQueue.erase (  it );
           };
           //-----------------------------------------------------------------------
           void remove (  T* e )
           {
           mQueue.remove (  e );
           };
           //-----------------------------------------------------------------------
           void sortNearest(  const Vector3 &pos )
           {
           mQueue.sort (  distanceToBoxSort <T>(  pos ) );
           };
           //-----------------------------------------------------------------------
           T *find_nearest(  const Vector3 &pos )
           {
           T *p = 0;
           Real mindist = std::numeric_limits<Real>::max (   );
           typename MsgQueType::iterator q,   qend = mQueue.end (   );
           for (  q = mQueue.begin (   );
           q != qend;
           ++q )
           {
           const Real res = (  pos - (  *q )->getCenter(   ) ).squaredLength(   );
           //const Real res = vectorToBoxDistance (  (  *q )->getSceneNode(   )->_getWorldAABB(   ),   pos );
           if (  res < mindist )
           {
           mindist = res;
           p = (  *q );
           }
           }
           if (  p )
           mQueue.remove (  p );
           return p;
           };
           //-----------------------------------------------------------------------
           T *find_nearest(  const unsigned int x,   const unsigned int z )
           {
           T *p = 0;
           unsigned int mindist = 0;
           typename MsgQueType::iterator q,   qend = mQueue.end (   );
           for (  q = mQueue.begin (   );
           q != qend;
           ++q )
           {
           unsigned int lx,   lz;
           (  *q )->getCoordinates(  lx,   lz );
          
           const unsigned int res = abs (  static_cast <int> (  lx - x ) ) + abs (  static_cast <int> (  lz - z ) );
           if (  res < mindist )
           {
           mindist = res;
           p = (  *q );
           }
           }
           if (  p )
           mQueue.remove (  p );
           return p;
           };
           //-----------------------------------------------------------------------
           T *find_farest(  const unsigned int x,   const unsigned int z )
           {
           T *p = 0;
           unsigned int maxdist = -1;
           typename MsgQueType::iterator q,   qend = mQueue.end (   );
           for (  q = mQueue.begin (   );
           q != qend;
           ++q )
           {
           unsigned int lx,   lz;
           (  *q )->getCoordinates(  lx,   lz );
          
           const unsigned int res = abs (  (  int )(  lx - x ) ) + abs (  (  int )(  lz - z ) );
           if (  res > maxdist )
           {
           maxdist = res;
           p = (  *q );
           }
           }
          
           if (  p )
           mQueue.remove (  p );
           return p;
           };
           //-----------------------------------------------------------------------
           T* pop(    )
           {
           T* tmp = 0;
           if (   !mQueue.empty (   )  )
           {
           // Queue is not empty so get a pointer to the
           // first message in the queue
           tmp = mQueue.front(    );
          
           // Now remove the pointer from the message queue
           mQueue.pop_front(    );
           }
           return tmp;
           };
           //-----------------------------------------------------------------------
           size_t getSize(   ) const
           {
           return mQueue.size (   );
           };
           //-----------------------------------------------------------------------
           bool empty(   ) const
           {
           return mQueue.empty(    );
           };
           //-----------------------------------------------------------------------
           MsgQueType *getQueue(   )
           {
           return &mQueue;
           }
          
           protected:
           MsgQueType mQueue;
          
           };
          
          } //namespace
          
          #endif //PAGINGLANDSCAPEQUEUE_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeRaySceneQuery.h

       1  /***************************************************************************
          OgrePagingLandScapeRaySceneQuery.h - description
          -------------------
          begin : Fri Sep 10 2003
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeRAYSCENEQUERY_H
          #define PAGINGLandScapeRAYSCENEQUERY_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeRaySceneQuery.h"
          
          namespace Ogre
          {
          
          
           /** PagingLandScape's specialisation of RaySceneQuery.
           if RSQ_Height bit mask is set,   RSQ_Terrain and RSQ_Entity bits will be ignored
           Otherwise data will be returned based on the mask
           */
      32   class PagingLandScapeRaySceneQuery : public PagingLandScapeOctreeRaySceneQuery
           {
          
           public:
      36   PagingLandScapeRaySceneQuery(  SceneManager* creator ) : PagingLandScapeOctreeRaySceneQuery(  creator )
           {
           mSupportedWorldFragments.insert(  SceneQuery::WFT_SINGLE_INTERSECTION );
           //mLastResult = new RaySceneQueryResult(   );
           }
          
          // virtual ~PagingLandScapeRaySceneQuery(  void )
          // {
          // clearFragmentList(   );
          // //delete mLastResult;
          // //mLastResult = 0;
          // }
          
           /** See RaySceneQuery. */
      50   void execute(  RaySceneQueryListener * listener );
           /** Executes the query,   returning the results back in one list.
           @remarks
           This method executes the scene query as configured,   gathers the results
           into one structure and returns a reference to that structure. These
           results will also persist in this query object until the next query is
           executed,   or clearResults(   ) is called. An more lightweight version of
           this method that returns results through a listener is also available.
           */
           //virtual RaySceneQueryResult& execute(  void );
          
           //void clearResults(  void );
          
           protected:
           //JEFF
           //PagingLandScapeTile* getNonDividedTile(  PagingLandScapeTile* tile,   const Vector3& origin );
      66   inline Vector3 getHeightAt(  const Vector3& origin ) const;
          
           //std::vector< SceneQuery::WorldFragment* > fragmentList;
          
          // void clearFragmentList(  void )
          // {
          // std::vector< SceneQuery::WorldFragment* >::iterator cur,   end = fragmentList.end(   );
          // for (  cur = fragmentList.begin(   ); cur < end; ++cur )
          // {
          // SceneQuery::WorldFragment* frag = (  *cur );
          // if (  frag )
          // {
          // delete frag;
          // frag = 0;
          // }
          // }
          // fragmentList.clear(   );
           // }
          
           private:
      86   WorldFragment mWorldFrag;
          
           };
          
          } // namespace Ogre
          
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeRenderable.h

       1  /***************************************************************************
           OgrePagingLandScapeRenderable.h - description
           -------------------
           begin : Thu Feb 27 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
           * *
           * This program is free software; you can redistribute it and/or modify *
           * it under the terms of the GNU General Public License as published by *
           * the Free Software Foundation; either version 2 of the License,   or *
           * (  at your option ) any later version. *
           * *
           ***************************************************************************/
          
          #ifndef PAGINGLandScapeRENDERABLE_H
          #define PAGINGLandScapeRENDERABLE_H
          
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          
          namespace Ogre
          {
          
           /** Represents a LandScape tile in terms of vertexes.
           @remarks
           A LandScapeRenderable represents a tile used to render a
           block of LandScape using the procedural terrain approach for LOD.
           */
      33   class PagingLandScapeRenderable : public Renderable,   public MovableObject
           {
           public:
          
           /** Sets the appropriate neighbor for this TerrainRenderable. Neighbors are necessary
           to know when to bridge between LODs.
           */
      40   void _setNeighbor(  Neighbor n,   PagingLandScapeRenderable* t )
           {
           mNeighbors[ n ] = t;
           };
          
           /** Returns the neighbor TerrainRenderable.
           */
      47   PagingLandScapeRenderable* _getNeighbor(  Neighbor n ) const
           {
           return mNeighbors[ n ];
           }
          
           /** Returns RenderLevel of current TerrainRenderable.
           */
      54   int getRenderLevel(   ) const
           {
           return mRenderLevel < 0 ? 0 : mRenderLevel;
           }
          
           /// The current LOD level
           int mRenderLevel;
          
           // if a neighbour changes its RenderLevel.
           // get a new Index buffer.
      64   void update(   );
          
           /** Initializes the LandScapeRenderable with the given options and the starting coordinates of this block.
           */
      68   PagingLandScapeRenderable(  PagingLandScapeRenderableManager *renderableMgr );
          
      70   ~PagingLandScapeRenderable(  void );
          
      72   void init(  PagingLandScapeTileInfo* info );
      73   void uninit(  void );
          
      75   bool load(  void );
          
      77   void setNeedUpdate(  void )
           {
           mNeedReload = true;
           };
      81   void adjustDeformationRectangle(  unsigned int x,   unsigned int z );
          
      83   void unload(  void );
          
      85   void setMaterial(  const MaterialPtr& mat );
          
      87   const bool isLoaded(  void )
           {
           assert (  (  mIsLoaded && mParentNode ) || (  !mIsLoaded && mParentNode == 0 )  );
           return mIsLoaded;
           };
          
      93   const Real getMaxHeight(  void )
           {
           return (  mBounds.getMaximum(   ) ).y;
           };
          
      98   inline void setInUse (  bool InUse )
           {
           mInUse = InUse;
           }
          
           /////////Movable overridden object methods
          
           /** Updates the level of detail to be used for rendering this TerrainRenderable based on the passed in Camera */
     106   virtual void _notifyCurrentCamera(  Camera* cam );
          
     108   virtual void _updateRenderQueue(  RenderQueue* queue );
          
           /** Returns the type of the movable. */
     111   virtual const String& getMovableType(  void ) const
           {
           return mType;
           };
          
           /** Returns the bounding box of this TerrainRenderable */
     117   const AxisAlignedBox& getBoundingBox(  void ) const
           {
           return mBounds;
           };
          
           /////////Renderable object methods
           /**
           Constructs a RenderOperation to render the TerrainRenderable.
           @remarks
           Each TerrainRenderable has a block of vertices that represent the terrain. Index arrays are dynamically
           created for mipmap level,   and then cached.
           */
     129   virtual void getRenderOperation(  RenderOperation& rend );
          
     131   virtual const MaterialPtr& getMaterial(  void ) const
           {
           return mMaterial;
           };
          
     136   virtual void getWorldTransforms(  Matrix4* xform ) const;
          
     138   virtual const Quaternion& getWorldOrientation(  void ) const;
     139   virtual const Vector3& getWorldPosition(  void ) const;
          
           /** @copydoc Renderable::getLights */
     142   const LightList& getLights(  void ) const;
          
     144   virtual Technique* getTechnique(  void ) const;
          
     146   virtual Real getSquaredViewDepth(  const Camera* cam ) const;
          
           /** Overridden from MovableObject */
     149   Real getBoundingRadius(  void ) const { return mBoundingRadius; }
          
           /// Overridden from Renderable to allow the morph LOD entry to be set
     152   void _updateCustomGpuParameter(  const GpuProgramParameters::AutoConstantEntry& constantEntry,   GpuProgramParameters* params ) const;
          
     154   void setMaxLod (  const bool setmaxlod ) {mForcedMaxLod = setmaxlod;};
          
           /// @see MovableObject
     157   uint32 getTypeFlags(  void ) const;
          
           /** Internal method called to notify the object that it has been attached to a node.
           */
     161   virtual void _notifyAttached(  Node* parent,   bool isTagPoint = false );
          
     163   bool isInUse(   ) const {return mInUse;};
          
     165   IndexData* getRawIndexData(  const int renderlevel );
     166   void getRawVertexData(  Vector3* pVerts );
     167   const unsigned int getVertexCount(   );
          
     169   bool mQueued;
     170   PagingLandScapeTile *mParentTile;
          
          
           protected:
          
     175   VertexData* mCurrVertexes;
     176   IndexData* mCurrIndexes;
          
           /// Bounding box of this tile
     179   AxisAlignedBox mBounds;
           /// The center point of this tile
     181   Vector3 mCenter;
           /// The MovableObject type
     183   static String mType;
           /// Current material used by this tile
     185   MaterialPtr mMaterial;
          
           /// Connection to tiles four neighbors
           PagingLandScapeRenderable* mNeighbors [ 4 ];
          
     190   IndexData*mIndex;
           unsigned int mNumIndex;
          
     193   bool mInUse;
     194   bool mIsLoaded;
     195   bool mNeedReload;
          
     197   ushort mMaterialLODIndex;
          
           // for loading
     200   PagingLandScapeTileInfo* mInfo;
          
           // Morph
           /** Returns the vertex coord for the given coordinates */
     204   inline Real _vertex(  const int x,   const int z,   const int n ) const;
     205   Real* mHeightfield;
           /// The previous 'next' LOD level down,   for frame coherency
           int mLastNextLevel;
           /// The morph factor between this and the next LOD level down
     209   Real mLODMorphFactor;
          
           /// List of squared distances at which LODs change
     212   std::vector<Real>* mMinLevelDistSqr;
          
           /// Optional set of delta buffers,   used to morph from one LOD to the next
     215   HardwareVertexBufferSharedPtr* mDeltaBuffers;
          
           /// Array of LOD indexes specifying which LOD is the next one down
           /// (  deals with clustered error metrics which cause LODs to be skipped )
           int mNextLevelDown[10];
          
           // distance between center renderable and camera.
     222   Real mDistanceToCam;
          
     224   void fillNextLevelDown(   );
     225   void _calculateMinLevelDist2(  const Real C );
           /// Create a blank delta buffer for use in morphing
     227   HardwareVertexBufferSharedPtr createDeltaBuffer(  void ) const;
          
           // did LOD level changes this frame
     230   bool mChangedRenderLevel;
          
     232   Vector3 _getvertex(  const int x,   const int z ) const;
          
     234   PagingLandScapeRenderableManager *mParent;
          
           /// The bounding radius of this renderable
     237   Real mBoundingRadius;
           private :
          
          
     241   Image::Box mRect;
     242   bool mIsRectModified;
     243   bool mForcedMaxLod;
     244   Vector4 mCustomGpuParameters;
          
           /// Whether light list need to re-calculate
           mutable bool mLightListDirty;
           /// Cached light list
           mutable LightList mLightList;
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeRenderableManager.h

       1  /***************************************************************************
          OgrePagingLandScapeRenderableManager.h - description
          -------------------
          begin : Mon Jun 16 2003
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeRENDERABLEMANAGER_H
          #define PAGINGLandScapeRENDERABLEMANAGER_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeQueue.h"
          #include "OgrePagingLandScapeIndexBuffer.h"
          
          #include "OgrePagingLandScapeTileInfo.h"
          
          #include "OgrePagingLandScapePoolSet.h"
          
          namespace Ogre
          {
          
          
          
           /** Class to manage A collection of pre-allocated PagingLandScapeRenderable
           */
      36   class PagingLandScapeRenderableSet : public PoolSet<PagingLandScapeRenderable>
           {
           public:
          
      40   PagingLandScapeRenderableSet(   );
      41   void setRenderableManager (  PagingLandScapeRenderableManager *rMgr )
           {
           mRenderableManager = rMgr;
           }
           protected:
          
      47   PagingLandScapeRenderable* allocate (   );
      48   void deallocate (  PagingLandScapeRenderable *r );
          
          
           private:
      52   PagingLandScapeRenderableManager *mRenderableManager;
          
           };
           /** Class to manage the PagingLandScapeRenderables (  Pool and Loading Queue )
           @remarks
           This class is used as a store of PagingLandScapeRenderables and the are reference and dereference in order to not being created and
           destroyed every time the plug-in need to change the LOD.
           */
      60   class PagingLandScapeRenderableManager
           {
           public:
           /** Initializes the PagingLandScapeRenderableManager with the
           * given options and allocate the necessary memory.
           */
      66   PagingLandScapeRenderableManager (  PagingLandScapeSceneManager * scnMgr );
          
      68   virtual ~PagingLandScapeRenderableManager(  void );
          
           /** Retrieve a free renderable.
           */
      72   PagingLandScapeRenderable* getRenderable(  void );
          
           /** Make a renderable free.
           */
      76   void freeRenderable(  PagingLandScapeRenderable* rend );
          
           /** Set this renderable to be loaded
           */
      80   void queueRenderableLoading(  PagingLandScapeTile* tile );
          
           /** Set this renderable to be unloaded
           */
      84   void unqueueRenderable(  PagingLandScapeTile* tile );
          
           /** Load a set of renderables
           */
      88   bool executeRenderableLoading(  const Vector3 &Cameraposition );
          
      90   size_t numRenderables(  void ) const;
      91   size_t numFree(  void ) const;
      92   size_t numLoading(  void ) const;
          
      94   void InitTextureCoordinatesBuffers(  void );
      95   void freeTextureCoordinatesBuffers(  void );
      96   HardwareVertexBufferSharedPtr getTextureCoordinatesBuffers(  const unsigned int tilex,   const unsigned int tilez );
      97   void setTextureCoordinatesBuffers(  const unsigned int tilex,   const unsigned int tilez,   const HardwareVertexBufferSharedPtr& data );
          
      99   unsigned int numVisibles(  void ) const
           {
           return mLastRenderablesVisibles;
           };
     103   void resetVisibles(  void )
           {
           mLastRenderablesVisibles = mRenderablesVisibles;
           mRenderablesVisibles = 0;
           };
     108   void addVisible(  void )
           {
           mRenderablesVisibles++;
           };
          
          
     114   void load(  void );
     115   void clear(  void );
          
           /// unload some Tiles/renderables if no more in use
     118   void processTileUnload(   );
          
     120   inline PagingLandScapeOptions* getOptions(   ){return mOptions;}
     121   inline PagingLandScapeSceneManager* getSceneManager(   ){return mSceneManager;}
           protected:
          
     124   PagingLandScapeOptions* mOptions;
     125   PagingLandScapeSceneManager *mSceneManager;
          
          
     128   void _addBatch(  const unsigned int num );
          
          
           ///Keep a set of pre-allocated PagingLandscapeRenderables.
     132   PagingLandScapeRenderableSet mRenderablePool;
          
           /** Queue to batch the process of loading the Renderables.
           This avoid the plug-in to load a lot of renderables in a single Frame,  
           dropping the FPS.
           */
     138   PagingLandScapeQueue< PagingLandScapeTile > mTilesLoadRenderableQueue;
          
           unsigned int mRenderablesVisibles;
           unsigned int mLastRenderablesVisibles;
           unsigned int mNumRenderablesIncrement;
           unsigned int mNumRenderableLoading;
          
           unsigned int mRenderableLoadInterval;
           int mLoadInterval;
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeSceneManager.h

          /***************************************************************************
           OgrePagingLandScapeSceneManager.h - description
           -------------------
           begin : Mon May 12 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeSCENEMANAGER_H
          #define PAGINGLandScapeSCENEMANAGER_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgreStringVector.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          
          namespace Ogre
          {
          
           /// Factory for OctreeSceneManager
      32   class PagingLandScapeSceneManagerFactory : public SceneManagerFactory
           {
           protected:
      35   void initMetaData(  void ) const;
           public:
      37   PagingLandScapeSceneManagerFactory(   ) {}
      38   ~PagingLandScapeSceneManagerFactory(   ) {}
           /// Factory type name
      40   static const String FACTORY_TYPE_NAME;
      41   SceneManager* createInstance(  const String& instanceName );
      42   void destroyInstance(  SceneManager* instance );
           };
          
          
          
           /** This is a basic SceneManager for organizing PagingLandScapeRenderables into a total LandScape.
           It loads a LandScape from a .cfg file that specifies what textures/scale/mipmaps/etc to use.
           */
      50   class PagingLandScapeSceneManager : public PagingLandScapeOctreeSceneManager
           {
      52   friend class PagingLandScapeRaySceneQuery;
           public:
      54   PagingLandScapeSceneManager(  const String &name );
      55   ~PagingLandScapeSceneManager(  void );
          
      57   void shutdown(   );
           /// @copydoc SceneManager::getTypeName
      59   const String& getTypeName(  void ) const;
          
           /** Creates a specialized Camera */
      62   virtual Camera * createCamera(  const String &name );
      63   virtual void destroyCamera(  Camera *cam );
      64   virtual void destroyCamera(  const String& name );
      65   virtual void destroyAllCameras(  void );
          
           /** Sets the source of the 'world' geometry,   i.e. the large,   mainly static geometry
           making up the world e.g. rooms,   LandScape etc.
           @remarks
           Depending on the type of SceneManager (  subclasses will be specialised
           for particular world geometry types ) you have requested via the Root or
           SceneManagerEnumerator classes,   you can pass a filename to this method and it
           will attempt to load the world-level geometry for use. If you try to load
           an inappropriate type of world data an exception will be thrown. The default
           SceneManager cannot handle any sort of world geometry and so will always
           throw an exception. However subclasses like BspSceneManager can load
           particular types of world geometry e.g. "q3dm1.bsp".
           */
      79   virtual void setWorldGeometry(  const String& filename );
          
           /** Sets the source of the 'world' geometry,   i.e. the large,   mainly
           static geometry making up the world e.g. rooms,   LandScape etc.
           @remarks
           Depending on the type of SceneManager (  subclasses will be
           specialised for particular world geometry types ) you have
           requested via the Root or SceneManagerEnumerator classes,   you
           can pass a stream to this method and it will attempt to load
           the world-level geometry for use. If the manager can only
           handle one input format the typeName parameter is not required.
           The stream passed will be read (  and it's state updated ).
           @param stream Data stream containing data to load
           @param typeName String identifying the type of world geometry
           contained in the stream - not required if this manager only
           supports one type of world geometry.
           */
      96   virtual void setWorldGeometry(  DataStreamPtr& stream,  
           const String& typeName = StringUtil::BLANK );
          
          
           /** Things that need to be allocated once
           */
     102   void InitScene(  void );
          
           /** Empties the entire scene,   including all SceneNodes,   Cameras,   Entities and Lights etc.
           */
     106   void clearScene(  void );
          
           /** Empties only the Terrain Scene pages,   tiles,   textures and so on
           */
     110   void resetScene(  void );
          
           /** Loads the LandScape using current parameters
           */
     114   void loadScene(  void );
          
           /** Method for setting a specific option of the Scene Manager. These options are usually
           specific for a certain implementation of the Scene Manager class,   and may (  and probably
           will ) not exist across different implementations.
           @param
           strKey The name of the option to set
           @param
           pValue A pointer to the value - the size should be calculated by the scene manager
           based on the key
           @return
           On success,   true is returned.
           @par
           On failure,   false is returned.
           */
     129   bool setOption(  const String& strKey,   const void* pValue );
          
           /** Method for getting the value of an implementation-specific Scene Manager option.
           @param
           strKey The name of the option
           @param
           pDestValue A pointer to a memory location where the value will
           be copied. Currently,   the memory will be allocated by the
           scene manager,   but this may change
           @return
           On success,   true is returned and pDestValue points to the value of the given
           option.
           @par
           On failiure,   false is returned and pDestValue is set to NULL.
           */
     144   bool getOption(  const String& strKey,   void* pDestValue );
          
           /** Method for verifying wether the scene manager has an implementation-specific
           option.
           @param
           strKey The name of the option to check for.
           @return
           If the scene manager contains the given option,   true is returned.
           @remarks
           If it does not,   false is returned.
           */
     155   bool hasOption(  const String& strKey ) const;
          
           /** Method for getting all possible values for a specific option. When this list is too large
           (  i.e. the option expects,   for example,   aOgre::Real ),   the return value will be true,   but the
           list will contain just one element whose size will be set to 0.
           Otherwise,   the list will be filled with all the possible values the option can
           accept.
           @param
           strKey The name of the option to get the values for.
           @param
           refValueList A reference to a list that will be filled with the available values.
           @return
           On success (  the option exists ),   true is returned.
           @par
           On failiure,   false is returned.
           */
     171   bool getOptionValues(  const String& key,   StringVector& refValueList );
          
           /** Method for getting all the implementation-specific options of the scene manager.
           @param
           refKeys A reference to a list that will be filled with all the available options.
           @return
           On success,   true is returned.
           On failiure,   false is returned.
           */
     180   bool getOptionKeys(  StringVector &refKeys );
          
           /** Internal method for updating the scene graph ie the tree of SceneNode instances managed by this class.
           @remarks
           This must be done before issuing objects to the rendering pipeline,   since derived transformations from
           parent nodes are not updated until required. This SceneManager is a basic implementation which simply
           updates all nodes from the root. This ensures the scene is up to date but requires all the nodes
           to be updated even if they are not visible. Subclasses could trim this such that only potentially visible
           nodes are updated.
           */
     190   void _updateSceneGraph(  Camera* cam );
          
           /** Sends visible objects found in _findVisibleObjects to the rendering engine.
           */
           //void _renderVisibleObjects(  void );
          
           /** Internal method which parses the scene to find visible objects to render.
           @remarks
           If you're implementing a custom scene manager,   this is the most important method to
           override since it's here you can apply your custom world partitioning scheme. Once you
           have added the appropriate objects to the render queue,   you can let the default
           SceneManager objects _renderVisibleObjects handle the actual rendering of the objects
           you pick.
           @par
           Any visible objects will be added to a rendering queue,   which is indexed by material in order
           to ensure objects with the same material are rendered together to minimise render state changes.
           */
           //void _findVisibleObjects(  Camera * cam,   bool onlyShadowCasters );
          
           /** Creates an AxisAlignedBoxSceneQuery for this scene manager.
           @remarks
           This method creates a new instance of a query object for this scene manager,  
           for an axis aligned box region. See SceneQuery and AxisAlignedBoxSceneQuery
           for full details.
           Currently this only supports custom geometry results. It ignores the y
           coords of the AABB.
           @par
           The instance returned from this method must be destroyed by calling
           SceneManager::destroyQuery when it is no longer required.
           @param box Details of the box which describes the region for this query.
           @param mask The query mask to apply to this query; can be used to filter out
           certain objects; see SceneQuery for details.
           */
     223   AxisAlignedBoxSceneQuery* createAABBQuery(  const AxisAlignedBox& box,   unsigned long mask = 0xFFFFFFFF );
          
          
           /** Creates a RaySceneQuery for this scene manager.
           @remarks
           This method creates a new instance of a query object for this scene manager,  
           looking for objects which fall along a ray. See SceneQuery and RaySceneQuery
           for full details.
           @par
           The instance returned from this method must be destroyed by calling
           SceneManager::destroyQuery when it is no longer required.
           @param ray Details of the ray which describes the region for this query.
           @param mask The query mask to apply to this query; can be used to filter out
           certain objects; see SceneQuery for details.
           */
     238   RaySceneQuery* createRayQuery(  const Ray& ray,   unsigned long mask = 0xFFFFFFFF );
          
           /** Creates an IntersectionSceneQuery for this scene manager.
           @remarks
           This method creates a new instance of a query object for locating
           intersecting objects. See SceneQuery and IntersectionSceneQuery
           for full details.
           @par
           The instance returned from this method must be destroyed by calling
           SceneManager::destroyQuery when it is no longer required.
           @param mask The query mask to apply to this query; can be used to filter out
           certain objects; see SceneQuery for details.
           */
           //IntersectionSceneQuery* createIntersectionQuery(  unsigned long mask );
          
           /** intersectSegment
           @remarks
           Intersect mainly with LandScape
           @param start
           begining of the segment
           @param end
           where it ends
           @param result
           where it intersects with terrain
           */
     263   bool intersectSegment(  const Ogre::Vector3& start,   const Ogre::Vector3& end,   Ogre::Vector3* result );
          
           /** intersectSegment
           @remarks
           Intersect mainly with LandScape
           @param start
           begining of the segment
           @param dir
           direction of the ray
           @param result
           where it intersects with terrain
           */
     275   bool intersectSegmentTerrain(  const Ogre::Vector3& begin,   const Ogre::Vector3& dir,   Ogre::Vector3* result );
           /** load
           * @remarks load heights only LandScape,   need brush and brush scale to be set before
           * @param &impact where load take place,   where BrushArray is centered
           */
     280   void setHeight (  const Ogre::Vector3 &impact );
           /** deform
           * @remarks deform only LandScape,   need brush and brush scale to be set before
           * @param &impact where deformation take place,   where BrushArray is centered
           */
     285   void deformHeight(  const Ogre::Vector3& impact );
           /** paint
           * @remarks paint only LandScape,   need channel,   brush and brush scale to be set before
           * @param impact where painting take place
           * @param isAlpha if we want to paint alpha or color
           */
     291   void paint (  const Ogre::Vector3 &impact );
           /** getAreaHeight
           * @remarks used to fill user allocated array with values.
           * @param impact where array is centered
           */
     296   void getAreaHeight(  const Ogre::Vector3& impact );
          
           /** renderBaseTextures(   )
           * @remarks Performs render to texture for all pages to create base textures from
           * splatting shader. If alternate material is specified,   will use it instead of
           * the actual material assigned to the page. This is necessary when terrain is lit
           * and/or compressed.
           */
     304   void renderBaseTextures(  const String& alternateMatName );
          
           /** Overridden from SceneManager */
     307   void setWorldGeometryRenderQueue(  uint8 qid );
          
     309   void PagingLandScapeOctreeResize(  void );
          
     311   void WorldDimensionChange(  void );
          
           //-----------------------------------------------------------------------
           inline Ogre::Real _OgrePagingLandScapeExport getHeightAt(  const Ogre::Real x,   const Ogre::Real z )
           {
           return mData2DManager->getInterpolatedWorldHeight(  x,   z );
           }
           //-----------------------------------------------------------------------
           inline Ogre::Real _OgrePagingLandScapeExport getSlopeAt(  const Ogre::Real x,   const Ogre::Real z )
           {
           Ogre::Real slope;
           // return mData2DManager->getRealWorldSlope(  x,   z );
     323   mData2DManager->getInterpolatedWorldHeight(  x,   z,   &slope );
           return slope;
           }
          
     327   _OgrePagingLandScapeExport void getWorldSize(  Real *worldSizeX,  Ogre::Real *worldSizeZ );
     328   _OgrePagingLandScapeExport float getMaxSlope(  Vector3 location1,   Ogre::Vector3 location2,   float maxSlopeIn );
          
     330   inline PagingLandScapeOptions * getOptions(   )
           {
           assert(  mOptions );
           return mOptions;
           }
          
     336   inline PagingLandScapeHorizon * getHorizon(   )
           {
           assert(  mHorizon );
           return mHorizon;
           }
     341   inline PagingLandScapeTileManager * getTileManager(   )
           {
           assert(  mTileManager );
           return mTileManager;
           }
     346   inline PagingLandScapePageManager * getPageManager(   )
           {
           assert(  mPageManager );
           return mPageManager;
           }
     351   inline PagingLandScapeData2DManager * getData2DManager(   )
           {
           assert(  mData2DManager );
           return mData2DManager;
           }
     356   inline PagingLandScapeListenerManager * getListenerManager(   )
           {
           assert(  mListenerManager );
           return mListenerManager;
           }
     361   inline PagingLandScapeTextureManager * getTextureManager(   )
           {
           assert(  mTextureManager );
           return mTextureManager;
           }
     366   inline PagingLandScapeIndexBufferManager * getIndexesManager(   )
           {
           assert(  mIndexesManager );
           return mIndexesManager;
           }
     371   inline PagingLandScapeRenderableManager * getRenderableManager(   )
           {
           assert(  mRenderableManager );
           return mRenderableManager;
           }
     376   inline PagingLandScapeTextureCoordinatesManager* getTextureCoordinatesManager(   )
           {
           assert(  mTexCoordManager );
           return mTexCoordManager;
           }
     381   inline PagingLandScapeIndexBufferManager* getIndexBufferManager(   )
           {
           assert(  mIndexesManager );
           return mIndexesManager;
           }
          
          
           protected:
          // EntityList& getEntities(  void )
          // {
          // return mEntities;
          // }
          
           /** All the plugin options are handle here.
           */
           PagingLandScapeOptions* mOptions;
          
           /** LandScape 2D Data manager.
           This class encapsulate the 2d data loading and unloading
           */
           PagingLandScapeData2DManager* mData2DManager;
          
           /** LandScape Texture manager.
           This class encapsulate the texture loading and unloading
           */
           PagingLandScapeTextureManager* mTextureManager;
          
           /** LandScape tiles manager to avoid creating a deleting terrain tiles.
           They are created at the plugin start and destroyed at the plugin unload.
           */
           PagingLandScapeTileManager* mTileManager;
          
           /** LandScape Renderable manager to avoid creating a deleting renderables.
           They are created at the plugin start and destroyed at the plug in unload.
           */
           PagingLandScapeRenderableManager* mRenderableManager;
           /** LandScape pages Index Buffer sharing across pages for the terrain.
           */
           PagingLandScapeIndexBufferManager* mIndexesManager;
           /** LandScape pages texture coordinates sharing across pages for the terrain.
           */
           PagingLandScapeTextureCoordinatesManager* mTexCoordManager;
           /** LandScape pages for the terrain.
           */
           PagingLandScapePageManager* mPageManager;
          
           /** Horizon visibility testing.
           */
           PagingLandScapeHorizon* mHorizon;
          
           /** Dispatch scene manager events.
           */
           PagingLandScapeListenerManager* mListenerManager;
          
           bool mNeedOptionsUpdate;
          
           //JEFF - flag to indicate if the world geometry was setup
           bool mWorldGeomIsSetup;
           bool mWorldGeomIsInit;
          
           PagingLandScapeTileInfo* mImpactInfo;
           Ogre::Vector3 mImpact;
           Ogre::Vector3 mBrushCenter;
           unsigned int mBrushSize;
           Ogre::Real mBrushScale;
          
           Ogre::Real* mCraterArray;
           Ogre::Real* mBrushArray;
          
           unsigned int mBrushArrayHeight;
           unsigned int mBrushArrayWidth;
          
           bool textureFormatChanged;
          
           MovableObjectFactory* mMeshDecalFactory;
          
           // re-create the default Crater brush.
           void resizeCrater (   );
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture.h

       1  /***************************************************************************
           OgrePagingLandScapeTexture.h - description
           -------------------
           begin : Fri Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE_H
          #define PAGINGLandScapeTEXTURE_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
          # define SAND 0
          # define GRASS 1
          # define ROCK 2
          # define SNOW 3
          
           /**
           * A simple class for encapsulating Texture generation.
           */
      34   class PagingLandScapeTexture
           {
           public:
      37   PagingLandScapeTexture(  PagingLandScapeTextureManager *pageMgr,  
      38   const String materialName,  
           const unsigned int numTexture = 0,  
      40   bool isSplatMode = false );
          
           // Method that must be overridden
      43   virtual String getName (  void ) const {return mMaterialBaseName;};
      44   virtual PagingLandScapeTexture *newTexture(   )
           {
           return new PagingLandScapeTexture(  mParent,   mMaterialBaseName );
           };
          
           // Method that can be overridden
      50   virtual ~PagingLandScapeTexture(  void );
          
      52   virtual void bindCompressionSettings(  GpuProgramParametersSharedPtr params );
      53   virtual void bindCompressionSettings(   );
          
      55   virtual void load(  unsigned int mX,   unsigned int mZ );
      56   virtual void update(  void );
      57   virtual void unload(  void );
          
      59   virtual bool isMaterialSupported(  bool recursive = true );
      60   virtual void setOptions(  void );
          
          
      63   virtual const unsigned int getNumChannels (  void ) const
           {
           return mNumTexture;
           };
      67   virtual const unsigned int getNumChannelsperTexture (  const size_t i ) const
           {
           return static_cast<unsigned int>(  mNumChannelperTexture[i] );
           };
          
           // Real Method
      73   bool getCastsShadows(  void ) const {return false;}
          
      75   bool isLoaded(  void ) const;
          
      77   void setNeedUpdate(  void );
      78   void updated(  void );
      79   bool needUpdate(  void ) const;
          
      81   const MaterialPtr& getMaterial(  void ) const;
          
      83   void paint (  const unsigned int x,  
           const unsigned int z,  
      85   const Real paintForce );
          
          
      88   void adjustDeformationRectangle(  unsigned int x,   unsigned int z );
      89   void adjustPaintRectangle(  unsigned int x,   unsigned int z );
          
      91   virtual void lightUpdate(   );
          
      93   void getCoordinates(  unsigned int& X,   unsigned int& Z )
           {
           X = mDataX;
           Z = mDataZ;
           };
      98   inline bool isCoord(  const unsigned int x,   const unsigned int z )
           {
           return (  mDataX == x && mDataZ == z );
           };
          
     103   const String &getMaterialName(   );
          
           protected:
          
     107   void compute(  PagingLandScapeData2D* data,  
     108   const Image::Box& dataRect,  
     109   const Image::Box& textureRect );
          
          
     112   void computePointAlpha(  const unsigned int imagePos,  
     113   const Real height,  
     114   const Real slope ) ;
          
     116   void computePointColor(  const unsigned int imagePos,  
     117   const Real height,  
     118   const Real slope ) ;
          
     120   void paintPoint (  const unsigned int imagePos,  
     121   const Real paintForce );
          
     123   void upload(  const Image::Box& textureRect );
          
     125   void setNumTexture(   );
          
           // Method that can be overridden
     128   virtual void _loadMaterial(  void );
           // Method that can be overridden
     130   virtual void _unloadMaterial(  void );
           // Method that can be overridden
     132   virtual void _save(  void );
          
          
          
           // properties that can be accessed from children
          
     138   bool mIsSplatMode;
     139   bool mIsBaseMode;
          
          
     142   bool mIsLoaded;
     143   bool mIsModified;
           //! Pointer to ogre material
     145   MaterialPtr mMaterial;
           //! what page it correspond to
           unsigned int mDataX,   mDataZ;
          
     149   Image::Box mPaintRect;
     150   bool mIsPaintRectModified;
     151   Image::Box mDeformRect;
     152   bool mIsDeformRectModified;
     153   PagingLandScapeTextureManager *mParent;
          
           // Edit,   deform and update
           unsigned int mNumTexture;
     157   std::vector<unsigned int> mNumChannelperTexture;
     158   std::vector<Image> mImages;
     159   std::vector<TexturePtr> mTextures;
     160   std::vector<HardwarePixelBufferSharedPtr> mBuffers;
     161   std::vector<bool> doTextureNeedUpdate;
     162   std::vector<bool> isTextureModified;
          
           // special case alpha loading Image as A8 only.
     165   void loadAlphaTexture(  const String& filename,   const unsigned int channel );
           // loading Image,   buffer and texture in channels
     167   void loadColorTexture(  const String& TexName,   const unsigned int channel );
           // loading Image,   buffer and texture.
     169   void loadTexture(  const String &filename,   Image &img );
           // Dynamic Lighting
     171   void computeLightMap (   ) const;
     172   Image mShadow;
     173   Image mLightImage;
     174   TexturePtr mLightTexture;
     175   HardwarePixelBufferSharedPtr mLightBuffer;
     176   bool mPositiveShadow;
     177   bool mIsShaderShadowed;
     178   bool mIsShadowed;
          
           // Name that helps building textures names on each page
     181   String mMaterialBaseName;
          
           private :
     184   void loadTexturesToModify(   );
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTextureCoordinatesManager.h

       1  /***************************************************************************
          OgrePagingLandScapeRenderableManager.h - description
          -------------------
          begin : Mon Jun 16 2003
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTextureCoordinatesMANAGER_H
          #define PAGINGLandScapeTextureCoordinatesMANAGER_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
           /** Class to manage the creation,   destruction and use of PagingLandScapeRenderables.
           @remarks
           This class is used as a store of PagingLandScapeTexturecoordinatesBuffer shared between Page
           */
      29   class PagingLandScapeTextureCoordinatesManager
           {
           public:
           /** Initializes the PagingLandScapeTextureCoordinatesManager with the
           * given options and allocate the necessary memory.
           */
      35   PagingLandScapeTextureCoordinatesManager(  PagingLandScapeSceneManager * scnMgr );
      36   virtual ~PagingLandScapeTextureCoordinatesManager(  void );
      37   void load(  void );
      38   void clear(  void );
          
      40   HardwareVertexBufferSharedPtr getBuffer(  const unsigned int tilex,   const unsigned int tilez );
          
      42   PagingLandScapeOptions* getOptions(   ){return mOptions;}
           protected:
          
      45   PagingLandScapeOptions* mOptions;
          
           unsigned int mPageSize;
           unsigned int mTileSize;
          
      50   HardwareTextureBuffersCol mTexBuffs;
           };
          
          }
          
          #endif //PAGINGLandScapeTextureCoordinatesMANAGER_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTextureManager.h

       1  /***************************************************************************
           OgrePagingLandScapeTextureManager.h - description
           -------------------
           begin : Fri Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTUREMANAGER_H
          #define PAGINGLandScapeTEXTUREMANAGER_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
      26   class PagingLandScapeTextureManager
           {
           public:
          
      30   PagingLandScapeTextureManager(  PagingLandScapeSceneManager * scnMgr );
          
      32   virtual ~PagingLandScapeTextureManager(  void );
          
      34   void load(  void );
      35   void clear(  void );
      36   void WorldDimensionChange(  void );
      37   PagingLandScapeTexture* allocateTexture(   ) const;
      38   void reset(  void );
          
      40   void load(  const unsigned int texX,   const unsigned int texZ );
      41   void reload(  const unsigned int dataX,   const unsigned int dataZ );
      42   void unload(  const unsigned int texX,   const unsigned int texZ );
          
      44   bool isLoaded(  const unsigned int texX,   const unsigned int texZ );
          
          
      47   const MaterialPtr& getMaterial(  const unsigned int texX,   const unsigned int texZ );
          
          
      50   MaterialPtr getMapMaterial(  void );
      51   void setMapMaterial(  void );
          
      53   void setPaintChannelValues (  const std::vector<Real> *theChannelModifList )
           {
           channelModifList = theChannelModifList;
           };
      57   void paint (  const Vector3 &currpoint,  
      58   const Real paintForce,  
      59   const PagingLandScapeTileInfo *info );
          
      61   void deformHeight (  const Vector3 &currpoint,  
      62   const PagingLandScapeTileInfo *info );
          
      64   String getNextTextureFormat(   );
      65   String getCurrentTextureFormat(   );
          
      67   void registerTextureFormats(   );
      68   void clearTextureFormats (   );
      69   void registerTextureType(  PagingLandScapeTexture* source )
           {
           mTextureTypeMap.push_back(  source );
           }
          
      74   PagingLandScapeTexture* getTexture(  const unsigned int i,   const unsigned int j,  
      75   const bool alwaysReturn = true );
      76   PagingLandScapeTexture* getNewTexture(  const unsigned int i,   const unsigned int j );
      77   void releaseTexture (  PagingLandScapeTexture*p  );
          
      79   unsigned int getNumChannels(   );
      80   unsigned int getNumChannelsperTexture(  const size_t i );
          
          
      83   inline PagingLandScapeSceneManager *getSceneManager(   ){return mSceneManager;}
      84   inline PagingLandScapeOptions* getOptions(   ){return mOptions;}
          
          
           unsigned int mPageSize;
      88   Image mImage;
      89   std::vector<Real> heights;
      90   std::vector<Real> dividers;
      91   std::vector<ColourValue> colors;
          
      93   const std::vector<Real> *channelModifList;
           protected:
          
           // Common var for all textures
      97   void setPageSize(   );
      98   void clearData (   );
          
           //
          
     102   PagingLandScapeSceneManager *mSceneManager;
     103   PagingLandScapeOptions* mOptions;
          
          
           unsigned int mTextureType;
     107   String mTextureFormat;
          
           unsigned int mWidth;
           unsigned int mHeight;
          
           unsigned int mTexturePageSize;
          
           //PagingLandScapeTexturePages mTexture;
          
     116   MaterialPtr mMapMaterial;
          
           unsigned int mPaintChannel;
     119   ColourValue mPaintColor;
          
          
          
     123   PagingLandScapeTextureMap mTextureTypeMap;
           /// The currently active page Data2d source
     125   PagingLandScapeTexture* mActiveTextureType;
          
     127   PagingLandScapeTextureList mActiveTextures;
     128   PagingLandScapeTextureList mFreeTextures;
     129   PagingLandScapeTextureArray mTexturePool;
           };
          
          } //namespace
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_BaseTexture.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_BaseTexture.h - description
           -------------------
           begin : Mon Apr 26 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE_BASETEXTURE_H
          #define PAGINGLandScapeTEXTURE_BASETEXTURE_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_BaseTexture : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_BaseTexture(  PagingLandScapeTextureManager *textureMgr );
      29   String getName(   ) const{return String(  "BaseTexture" );}
      30   void setOptions(  void );
      31   ~PagingLandScapeTexture_BaseTexture(  void );
          
      33   PagingLandScapeTexture* newTexture(   );
      34   bool isMaterialSupported(   );
          
           protected:
      37   void _loadMaterial(  void );
          
           private:
      40   Image BaseImage;
      41   uchar *_BuildBaseTexture(   ) const;
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_BaseTexture2.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_BaseTexture2.h - description
           -------------------
           begin : Mon Apr 26 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeTexture_BaseTexture2_H
          #define PagingLandScapeTexture_BaseTexture2_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_BaseTexture2 : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_BaseTexture2(  PagingLandScapeTextureManager *textureMgr );
      29   String getName(   ) const{return String(  "BaseTexture2" );}
      30   void setOptions(  void );
      31   ~PagingLandScapeTexture_BaseTexture2(  void );
          
      33   PagingLandScapeTexture* newTexture(   );
      34   bool isMaterialSupported(   );
          
           };
          }
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Image.h

       1  /***************************************************************************
           OgrePagingLandScapeTexture_Image.h - description
           -------------------
           begin : Fri Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE_IMAGE_H
          #define PAGINGLandScapeTEXTURE_IMAGE_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_Image : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_Image(  PagingLandScapeTextureManager *textureMgr );
      29   ~PagingLandScapeTexture_Image(  void );
          
      31   String getName(   ) const
           {
           return String(  "ImagePaging" );
           }
          
      36   PagingLandScapeTexture* newTexture(   );
      37   bool isMaterialSupported(   );
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_InstantBaseTexture.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_InstantBaseTexture.h - description
           -------------------
           begin : Mon Apr 26 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeTexture_InstantBaseTexture_H
          #define PagingLandScapeTexture_InstantBaseTexture_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
      26   class PagingLandScapeTexture_InstantBaseTexture : public PagingLandScapeTexture
           {
           public:
          
      30   PagingLandScapeTexture_InstantBaseTexture(  PagingLandScapeTextureManager *textureMgr );
      31   ~PagingLandScapeTexture_InstantBaseTexture(  void );
          
      33   String getName(   ) const{return String(  "InstantBaseTexture" );}
          
          
      36   void paint (  const unsigned int x,   const unsigned int z,  
      37   const Real paintForce,   const ColourValue &mPaintColor );
          
      39   PagingLandScapeTexture* newTexture(   );
      40   bool isMaterialSupported(   );
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_InstantBaseTextureEdit.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_InstantBaseTextureEdit.h - description
           -------------------
           begin : Mon Apr 26 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeTexture_InstantBaseTextureEdit_H
          #define PagingLandScapeTexture_InstantBaseTextureEdit_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
          
      27   class PagingLandScapeTexture_InstantBaseTextureEdit : public PagingLandScapeTexture
           {
           public:
          
      31   PagingLandScapeTexture_InstantBaseTextureEdit(  PagingLandScapeTextureManager *textureMgr );
      32   virtual ~PagingLandScapeTexture_InstantBaseTextureEdit(  void );
          
      34   virtual String getName(   ) const{return String(  "InstantBaseTextureEdit" );}
          
      36   virtual PagingLandScapeTexture* newTexture(   );
      37   virtual bool isMaterialSupported(   );
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_InstantBaseTextureShadowed.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_InstantBaseTexture.h - description
           -------------------
           begin : Mon Apr 26 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeTexture_InstantBaseTextureShadowed_H
          #define PagingLandScapeTexture_InstantBaseTextureShadowed_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
          
      26   class PagingLandScapeTexture_InstantBaseTextureShadowed : public PagingLandScapeTexture
           {
           public:
          
      30   PagingLandScapeTexture_InstantBaseTextureShadowed(  PagingLandScapeTextureManager *textureMgr );
      31   ~PagingLandScapeTexture_InstantBaseTextureShadowed(  void );
          
      33   String getName(   ) const{return String(  "InstantBaseTextureShadowed" );}
          
      35   void paint (  const unsigned int x,   const unsigned int z,  
      36   const Real paintForce,   const ColourValue &mPaintColor );
          
          
      39   PagingLandScapeTexture* newTexture(   );
      40   bool isMaterialSupported(   );
          
           protected:
      43   void _loadMaterial(  void );
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_None.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_SplattingShader.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2005 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE_NONE_H
          #define PAGINGLandScapeTEXTURE_NONE_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeTexture.h"
          
          namespace Ogre
          {
          
      27   class PagingLandScapeTexture_None : public PagingLandScapeTexture
           {
           public:
      30   PagingLandScapeTexture_None(  PagingLandScapeTextureManager *textureMgr ) :
           PagingLandScapeTexture(  textureMgr,   "None",   0,   false )
           {
           mIsLoaded = true;
           mIsModified = false;
           };
      36   ~PagingLandScapeTexture_None(  void )
           {
           };
          
      40   String getName(   ) const
           {
           return String(  "None" );
           }
      44   PagingLandScapeTexture* newTexture(   )
           {
           return new PagingLandScapeTexture_None(  mParent );
           };
      48   void load(  uint mX,   uint mZ )
           {
           mDataX = mX;
           mDataZ = mZ;
           mIsLoaded = true;
           mIsModified = false;
           };
      55   void unload(  void ) { };
          
           protected:
      58   void _loadMaterial(  void ) { };
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Splatting.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE_SPLATTING_H
          #define PAGINGLandScapeTEXTURE_SPLATTING_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_Splatting : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_Splatting(  PagingLandScapeTextureManager *textureMgr );
      29   String getName(   ) const{return String(  "Splatting" );}
          
      31   void setOptions(  void );
      32   ~PagingLandScapeTexture_Splatting(  void );
          
      34   PagingLandScapeTexture* newTexture(   );
      35   bool isMaterialSupported(   );
          
           protected:
          
      39   void _loadMaterial(  void );
          
           private:
          
      43   void _BuildPoint(  const unsigned int i,   const int j,  
      44   ColourValue& out,   std::vector<Real> &alpha );
          
      46   inline void _InterpolateAlpha(  std::vector<Real> &alpha,   const Real percentaje,  
           const int index1,   const int index2 );
          
      49   bool bAlpha1NotUsed,   bAlpha2NotUsed,   bAlpha3NotUsed,   bAlpha4NotUsed;
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Splatting2.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE_SPLATTING2_H
          #define PAGINGLandScapeTEXTURE_SPLATTING2_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_Splatting2 : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_Splatting2(  PagingLandScapeTextureManager *textureMgr );
      29   String getName(   ) const{return String(  "Splatting2" );}
          
      31   ~PagingLandScapeTexture_Splatting2(  void );
          
      33   void setOptions(  void );
          
      35   PagingLandScapeTexture* newTexture(   );
      36   bool isMaterialSupported(   );
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Splatting2Edit.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeTexture_Splatting2Edit_H
          #define PagingLandScapeTexture_Splatting2Edit_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_Splatting2Edit : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_Splatting2Edit(  PagingLandScapeTextureManager *textureMgr );
          
      30   String getName(   ) const{return String(  "Splatting2Edit" );}
      31   ~PagingLandScapeTexture_Splatting2Edit(  void );
      32   void setOptions(  void );
          
      34   PagingLandScapeTexture* newTexture(   );
      35   bool isMaterialSupported(   );
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Splatting3.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PagingLandScapeTexture_Splatting3_H
          #define PagingLandScapeTexture_Splatting3_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_Splatting3 : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_Splatting3(  PagingLandScapeTextureManager *textureMgr );
      29   String getName(   ) const{return String(  "Splatting3" );}
          
      31   void setOptions(  void );
          
      33   ~PagingLandScapeTexture_Splatting3(   );
          
      35   PagingLandScapeTexture* newTexture(   );
      36   bool isMaterialSupported(   );
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Splatting4.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting4.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE4_SPLATTING_H
          #define PAGINGLandScapeTEXTURE4_SPLATTING_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_Splatting4 : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_Splatting4(  PagingLandScapeTextureManager *textureMgr );
      29   String getName(   ) const{return String(  "Splatting4" );}
      30   void setOptions(  void );
      31   ~PagingLandScapeTexture_Splatting4(  void );
          
      33   PagingLandScapeTexture* newTexture(   );
      34   bool isMaterialSupported(   );
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Splatting5.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting5.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE5_SPLATTING_H
          #define PAGINGLandScapeTEXTURE5_SPLATTING_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeTexture.h"
          
          namespace Ogre
          {
          
      27   class PagingLandScapeTexture_Splatting5 : public PagingLandScapeTexture
           {
           public:
      30   PagingLandScapeTexture_Splatting5(  PagingLandScapeTextureManager *textureMgr );
      31   String getName(   ) const{return String(  "Splatting5" );}
      32   void setOptions(  void );
      33   ~PagingLandScapeTexture_Splatting5(  void );
          
      35   PagingLandScapeTexture* newTexture(   );
      36   bool isMaterialSupported(   );
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Splatting6.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting4.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE6_SPLATTING_H
          #define PAGINGLandScapeTEXTURE6_SPLATTING_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_Splatting6 : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_Splatting6(  PagingLandScapeTextureManager *textureMgr );
      29   String getName(   ) const{return String(  "Splatting6" );}
      30   void setOptions(  void );
      31   ~PagingLandScapeTexture_Splatting6(  void );
          
      33   PagingLandScapeTexture* newTexture(   );
      34   bool isMaterialSupported(   );
          
           };
          
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Splatting7.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting7.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE7_SPLATTING_H
          #define PAGINGLandScapeTEXTURE7_SPLATTING_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_Splatting7 : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_Splatting7(  PagingLandScapeTextureManager *textureMgr );
          
      30   ~PagingLandScapeTexture_Splatting7(  void );
      31   String getName(   ) const{return String(  "Splatting7" );}
      32   PagingLandScapeTexture* newTexture(   );
      33   bool isMaterialSupported(   );
          
      35   void setOptions(  void );
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_Splatting7Edit.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting7Edit.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE7Edit_SPLATTING_H
          #define PAGINGLandScapeTEXTURE7Edit_SPLATTING_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          namespace Ogre
          {
      25   class PagingLandScapeTexture_Splatting7Edit : public PagingLandScapeTexture
           {
           public:
      28   PagingLandScapeTexture_Splatting7Edit(  PagingLandScapeTextureManager *textureMgr );
          
      30   String getName(   ) const{return String (  "Splatting7Edit" );};
          
      32   void setOptions(  void );
          
      34   ~PagingLandScapeTexture_Splatting7Edit(  void );
          
      36   PagingLandScapeTexture* newTexture(   );
      37   bool isMaterialSupported(   );
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_SplattingShader.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_SplattingShader.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE_SPLATTINGSHADER_H
          #define PAGINGLandScapeTEXTURE_SPLATTINGSHADER_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeTexture.h"
          
          namespace Ogre
          {
          
      27   class PagingLandScapeTexture_SplattingShader : public PagingLandScapeTexture
           {
           public:
      30   PagingLandScapeTexture_SplattingShader(  PagingLandScapeTextureManager *textureMgr );
      31   String getName(   ) const{return String(  "SplattingShader" );}
          
      33   ~PagingLandScapeTexture_SplattingShader(  void );
          
      35   PagingLandScapeTexture* newTexture(   );
      36   bool isMaterialSupported(   );
          
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTexture_SplattingShaderEdit.h

       1  /***************************************************************************
          OgrePagingLandScapeTexture_SplattingShader.h - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTEXTURE_SPLATTINGSHADEREDIT_H
          #define PAGINGLandScapeTEXTURE_SPLATTINGSHADEREDIT_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeTexture.h"
          
          namespace Ogre
          {
          
      27   class PagingLandScapeTexture_SplattingShaderEdit : public PagingLandScapeTexture
           {
           public:
      30   PagingLandScapeTexture_SplattingShaderEdit(  PagingLandScapeTextureManager *textureMgr );
      31   String getName(   ) const{return String(  "SplattingShaderEdit" );}
          
      33   ~PagingLandScapeTexture_SplattingShaderEdit(  void );
      34   PagingLandScapeTexture* newTexture(   );
      35   bool isMaterialSupported(   );
           };
          }
          
          #endif //PAGINGLandScapeTEXTURE_SPLATTINGSHADEREDIT_H

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTile.h

          /***************************************************************************
           OgrePagingLandScapeTile.h - description
           -------------------
           begin : Sun Jun 08 2003
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTILE_H
          #define PAGINGLandScapeTILE_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeTileInfo.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTileManager.h"
          #include "OgrePagingLandScapeRenderable.h"
          
          namespace Ogre
          {
          
          class _OgrePagingLandScapeExport PagingLandScapeTile
          {
          public:
      34   inline PagingLandScapeTileInfo* getInfo(  void )
           {
           return mInfo;
           };
          
           /** Sets the appropriate neighbor for this TerrainRenderable. Neighbors are necessary
           to know when to bridge between LODs.
           */
      42   void _setNeighbor(  Neighbor n,   PagingLandScapeTile* t );
          
           /** Returns the neighbor TerrainRenderable.
           */
      46   inline PagingLandScapeTile* _getNeighbor(  Neighbor n )
           {
           return mNeighbors[ n ];
           };
          
           /** intersectSegment
           @remarks
           Intersect mainly with LandScape
           @param start
           beginning of the segment
           @param end
           where it ends
           @param result
           where it intersects with terrain
           */
      61   bool intersectSegmentFromAbove(  const Vector3& start,   const Vector3& dir,   Vector3* result );
      62   bool intersectSegmentFromBelow(  const Vector3& start,   const Vector3& dir,   Vector3* result );
          
           /** updateTerrain
           @remarks
           Make the Tile reload its vertices and normals
           (  upon a modification of the height data )
           */
      69   void updateTerrain(  void );
          
      71   inline PagingLandScapeRenderable* getRenderable(  void )
           {
           return mRenderable;
           }
          
      76   void _linkRenderableNeighbor(  void );
      77   void _updateLod(  void );
          
      79   PagingLandScapeTile(  PagingLandScapeTileManager *pageMgr );
          
      81   ~PagingLandScapeTile(  void );
          
      83   void init(  SceneNode* PageNode,   const int tableX,   const int tableZ,   const int tileX,   const int tileZ );
      84   void load(  void );
      85   void unload(  void );
      86   void uninit(  void );
          
      88   void _Notify(  const Vector3 &pos,   const PagingLandScapeCamera * const Cam );
          
      90   inline bool isLoaded(  void )
           {
           return mLoaded;
           };
      94   inline bool isLoading(  void )
           {
           return mLoading;
           };
      98   inline void setLoading(  bool value )
           {
           mLoading = value;
           };
          
     103   void setInUse (  bool InUse )
           {
           assert (  mInit );
           if (  mRenderable )
           mRenderable->setInUse (  InUse );
           }
          
     110   inline bool isVisible(  void )
           {
           return mVisible;
           }
          
           /// make tile visible not being unload or invisible until a certain time.
     116   inline void touch (   )
           {
           mTimeUntouched = mParent->getOptions(   )->TileInvisibleUnloadFrames;
           }
          
     121   void setRenderQueueGroup(  uint8 qid );
          
     123   SceneNode *getSceneNode(   )
           {
           return mTileSceneNode;
           };
     127   const AxisAlignedBox &getWorldBbox(   ) const
           {
           return mWorldBounds;
           };
     131   inline const AxisAlignedBox &getCullWorldBbox(   ) const
           {
           return mWorldBoundsExt;
           };
     135   inline const Vector3 &getCenter(  void ) const
           {
           return mWorldPosition;
           };
          
     140   const bool unloadUntouched (   );
          
          protected:
           //movable object variables
           AxisAlignedBox mWorldBounds;
           AxisAlignedBox mWorldBoundsExt;
           Vector3 mWorldPosition;
          
           // if the tile is initialized
           bool mInit;
           // if the renderable is loaded
           bool mLoaded;
           // if the renderable is loading
           bool mLoading;
          
           PagingLandScapeRenderable* mRenderable;
          
           SceneNode* mTileSceneNode;
           SceneNode* mParentSceneNode;
          
           PagingLandScapeTile* mNeighbors[4];
          
           PagingLandScapeTileInfo *mInfo;
           bool mVisible;
           unsigned int mTimeUntouched;
          
           PagingLandScapeTileManager *mParent;
          };
          
          } //namespace
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTileInfo.h

       1  /***************************************************************************
          OgrePagingLandScapeTileInfo.h - description
          -------------------
          begin : Sat Jan 31 2004
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTILEINFO_H
          #define PAGINGLandScapeTILEINFO_H
          
          namespace Ogre
          {
           /** This class holds the Tile info
           @remarks
           This will avoid to pass a lot of data to the Renderable class.
           */
      27   class
           PagingLandScapeTileInfo
           {
           public:
      31   PagingLandScapeTileInfo(  const uint pageX,   const uint pageZ,  
      32   const uint tileX,   const uint tileZ )
           :
           mMinLevelDistSqr(  0 ),  
           mPageX (  pageX ),  
           mPageZ (  pageZ ),  
           mTileX (  tileX ),  
           mTileZ (  tileZ )
           {
           }
      41   ~PagingLandScapeTileInfo(   )
           {
           delete mMinLevelDistSqr;
           }
          
           //This is the Page Index in the Page Array
           unsigned short int mPageX;
           unsigned short int mPageZ;
          
           //This is the tile Index in the Tile Array
           unsigned short int mTileX;
           unsigned short int mTileZ;
          
           /// List of squared distances at which LODs change
           // costly to compute,   so we cache it there.
      56   std::vector<Real>* mMinLevelDistSqr;
           };
          }
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapeTileManager.h

       1  /***************************************************************************
           OgrePagingLandScapeTileManager.h - description
           -------------------
           begin : Mon Jun 16 2003
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #ifndef PAGINGLandScapeTILEMANAGER_H
          #define PAGINGLandScapeTILEMANAGER_H
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeQueue.h"
          
          namespace Ogre
          {
          
          
      28   class PagingLandScapeTileManager
           {
           public:
          
      32   PagingLandScapeTileManager(  PagingLandScapeSceneManager * scnMgr );
          
      34   virtual ~PagingLandScapeTileManager(  void );
          
           /** Retrieve a free tile.
           */
      38   PagingLandScapeTile* getTile(  void );
          
           /** Make a tile free.
           */
      42   void freeTile(  PagingLandScapeTile* tile );
          
      44   void reset(  void );
          
      46   unsigned int numTiles(  void ) const;
          
      48   size_t numFree(  void ) const;
          
          
      51   void load(  void );
      52   void clear(  void );
          
           // unload invisible tiles after option::mTileInvisibleUnloadFrames tick
           // without being visible.
      56   void unloadUntouched(   );
          
      58   inline PagingLandScapeOptions* getOptions(   )
           {
           return mOptions;
           }
          
      63   inline PagingLandScapeSceneManager* getSceneManager(   )
           {
           return mSceneManager;
           }
          
           protected:
          
      70   PagingLandScapeOptions* mOptions;
      71   PagingLandScapeSceneManager *mSceneManager;
          
      73   void _addBatch(  const unsigned int num );
          
      75   PagingLandScapeTileRow mTiles;
          
      77   PagingLandScapeQueue< PagingLandScapeTile > mQueue;
          
           unsigned int mNumTiles;
          
           };
          
          } //namespace
          
          #endif

./components/ogre/SceneManagers/EmberPagingSceneManager/include/fileutils.h

       1  /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          /**
          @file
          fileutils.h
          @brief
          Utility function to manage directories
          */
          #ifndef fileutils_H
          #define fileutils_H
          
          #ifdef __cplusplus
          extern "C" {
          #endif
          /**
          * check if directory exists or not*
          * \param *Dirname name of the directory
          * \return true if exists
          */
      26  bool DirExists(  const char *Dirname );
          /**
           * change the current directory and return old one
           * as a MALLOC'ED by system ONE
           * \param *Dirname
           * \return
           */
      33  char* ChangeToDir(  const char* Dirname );
          /**
           * Reestablish directory to current one before changing
           * and free the char* MALLOC'ED by system when changing.
           * \param *oldDirname
           */
      39  void RetablishDir(  char* oldDirname );
          
          #ifdef __cplusplus
          }/* end extern C definitions */
          #endif
          
          #endif //fileutils_H

./components/ogre/SceneManagers/EmberPagingSceneManager/src/DRGNURBSSurface.cpp

       1  // DRGNURBSSurface.cpp: implementation of the CDRGNURBSSurface class.
          // ------------------------------------------------------------------------------------
          // Copyright © 1999 Intel Corporation
          // All Rights Reserved
          //
          // Permission is granted to use,   copy,   distribute and prepare derivative works of this
          // software for any purpose and without fee,   provided,   that the above copyright notice
          // and this statement appear in all copies. Intel makes no representations about the
          // suitability of this software for any purpose. This software is provided "AS IS."
          //
          // Intel specifically disclaims all warranties,   express or implied,   and all liability,  
          // including consequential and other indirect damages,   for the use of this software,  
          // including liability for infringement of any proprietary rights,   and including the
          // warranties of merchantability and fitness for a particular purpose. Intel does not
          // assume any responsibility for any errors which may appear in this software nor any
          // responsibility to update it.
          // ------------------------------------------------------------------------------------
          //
          // PURPOSE:
          //
          // Implementation of the CDRGNURBSSurface class for rendering NURBS surfaces.
          // Accompanies the article "Rendering NURBS Surfaces in float-Time". Please refer
          // to the article for an understanding of the methods in this class.
          // ------------------------------------------------------------------------------------
          //
          // Author: Dean Macri - Intel Developer Relations Divison -- Tools and Technology Group
          // Please contact me at dean.p.macri@intel.com with questions,   suggestions,   etc.
          //
          ////////////////////////////////////////////////////////////////////////////////////////
          //
          // Yoinked from http://www.gamasutra.com/features/19991117/macri_pfv.htm
          // Hacked into an unholy mess for use with OGRE by Chris "Antiarc" Heald (  antiarc@captionthis.com )
          // Date: 11/9/2003
          //
          ////////////////////////////////////////////////////////////////////////////////////////
          
          //////////////////////////////////////////////////////////////////////
          // Construction/Destruction
          //////////////////////////////////////////////////////////////////////
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "DRGNURBSSurface.h"
          #include <stdlib.h>
          #include <math.h>
          #include <string.h>
          
      48  CDRGNURBSSurface::CDRGNURBSSurface(   )
          {
          
           m_pControlPoints = NULL;
           m_UKnots = NULL;
           m_VKnots = NULL;
           m_UBasisCoefficients = NULL;
           m_VBasisCoefficients = NULL;
           m_UBasis = NULL;
           m_dUBasis = NULL;
           m_VBasis = NULL;
           m_dVBasis = NULL;
           m_UTemp = NULL;
           m_dUTemp = NULL;
           m_TessUKnotSpan = NULL;
           m_TessVKnotSpan = NULL;
          
           m_iUTessellations = 0;
           m_iVTessellations = 0;
          
           m_pVertices = NULL;
          }
          
          // -----------------------------------------------------------------------
          //
          // Free up anything we've allocated
          //
          // -----------------------------------------------------------------------
      76  void CDRGNURBSSurface::Cleanup(  void )
          {
           ALIGNED_DELETE(  m_pControlPoints );
           ALIGNED_DELETE(  m_UKnots );
           ALIGNED_DELETE(  m_VKnots );
           ALIGNED_DELETE(  m_UBasisCoefficients );
           ALIGNED_DELETE(  m_VBasisCoefficients );
           ALIGNED_DELETE(  m_UBasis );
           ALIGNED_DELETE(  m_dUBasis );
           ALIGNED_DELETE(  m_VBasis );
           ALIGNED_DELETE(  m_dVBasis );
           ALIGNED_DELETE(  m_UTemp );
           ALIGNED_DELETE(  m_dUTemp );
           ALIGNED_DELETE(  m_pVertices );
           SAFE_DELETE(  m_TessUKnotSpan );
           SAFE_DELETE(  m_TessVKnotSpan );
          }
          
      94  CDRGNURBSSurface::~CDRGNURBSSurface(   )
          {
           Cleanup(   ); // Free everything :- )
          }
          
          // -----------------------------------------------------------------------
          //
          // Initialize a CDRGNURBSSurface object. This will normally only be called
          // once for a particular object but it's safe to call it more than once.
          //
          // -----------------------------------------------------------------------
     105  bool CDRGNURBSSurface::Init(  int uDegree,  
           int vDegree,  
           int uControlPoints,  
           int vControlPoints,  
           Point4D *pControlPoints,  
           float *pUKnots,  
           float *pVKnots,  
           int iDefaultUTessellations,  
           int iDefaultVTessellations
            )
          {
           // In case we've already been initialized.
           Cleanup(   );
          
           // Copy the stuff we're given
           //
           m_iUDegree = uDegree;
           m_iVDegree = vDegree;
           m_iUControlPoints = uControlPoints;
           m_iVControlPoints = vControlPoints;
          
           //
           // Compute some other useful quantities
           //
           m_iUOrder = m_iUDegree + 1;
           m_iVOrder = m_iVDegree + 1;
           m_iUKnots = m_iUOrder + m_iUControlPoints;
           m_iVKnots = m_iVOrder + m_iVControlPoints;
          
           // Calculate how many valid spans exist in the Knot vectors
           m_iUBasisSpans = m_iUKnots - 2 * m_iUDegree;
           m_iVBasisSpans = m_iVKnots - 2 * m_iVDegree;
          
          
           //
           // Allocate some memory for the control points,   knots,   and basis stuff
           //
           m_pControlPoints = ALIGNED_NEW(  m_iUControlPoints * m_iVControlPoints,   Point4D );
           m_UKnots = ALIGNED_NEW(  m_iUKnots,   float );
           m_VKnots = ALIGNED_NEW(  m_iVKnots,   float );
          
           // For each span in the knot vector,   there will be m_iUOrder (  and m_iVOrder )
           // Basis polynomials that are non-zero. Each of those polynomials will
           // have m_iUOrder coefficients,   hence m_iUBasisSpans * m_iUOrder * m_iUOrder
           m_UBasisCoefficients = ALIGNED_NEW(  m_iUOrder * m_iUOrder * m_iUBasisSpans,   float );
           m_VBasisCoefficients = ALIGNED_NEW(  m_iVOrder * m_iVOrder * m_iVBasisSpans,   float );
           m_UTemp = ALIGNED_NEW(  m_iVOrder,   Point4D );
           m_dUTemp = ALIGNED_NEW(  m_iVOrder,   Point4D );
          
           //
           // Copy the incoming data to the internal structures. If the incoming control
           // points are NOT stored as pre-weighted points,   then you'll need to loop over
           // the points and multiply x,   y,   and z by the w value (  so that the actual,  
           // stored control point is {x*w,   y*w,   z*w,   w} )
           //
           memcpy(  m_pControlPoints,   pControlPoints,   m_iUControlPoints * m_iVControlPoints * sizeof(  Point4D ) );
           memcpy(  m_UKnots,   pUKnots,   m_iUKnots * sizeof(  float ) );
           memcpy(  m_VKnots,   pVKnots,   m_iVKnots * sizeof(  float ) );
          
           ComputeBasisCoefficients(   );
          
           SetTessellations(  iDefaultUTessellations,   iDefaultVTessellations );
          
           return true;
          }
          
          // -----------------------------------------------------------------------
          //
          // Change the number of tessellations used to render the object
          //
          // -----------------------------------------------------------------------
     176  void CDRGNURBSSurface::SetTessellations(  int iUTessellations,   int iVTessellations )
          {
           if(  (  iUTessellations != m_iUTessellations ) ||
           (  iVTessellations != m_iVTessellations ) )
           {
           m_iUTessellations = iUTessellations;
           m_iVTessellations = iVTessellations;
          
           //
           // Free anything we've already allocated
           //
           ALIGNED_DELETE(  m_UBasis );
           ALIGNED_DELETE(  m_VBasis );
           ALIGNED_DELETE(  m_dUBasis );
           ALIGNED_DELETE(  m_dVBasis );
           SAFE_DELETE(  m_TessUKnotSpan );
           SAFE_DELETE(  m_TessVKnotSpan );
          
           //
           // Allocate memory for the basis functions,   etc
           //
           m_UBasis = ALIGNED_NEW(  m_iUOrder * SIMD_SIZE * (  m_iUTessellations+1 ),   float );
           m_VBasis = ALIGNED_NEW(  m_iVOrder * SIMD_SIZE * (  m_iVTessellations+1 ),   float );
           m_dUBasis = ALIGNED_NEW(  m_iUOrder * SIMD_SIZE * (  m_iUTessellations+1 ),   float );
           m_dVBasis = ALIGNED_NEW(  m_iVOrder * SIMD_SIZE * (  m_iVTessellations+1 ),   float );
          
           m_TessUKnotSpan = new int[ m_iUTessellations+1 ];
           m_TessVKnotSpan = new int[ m_iVTessellations+1 ];
          
           ALIGNED_DELETE(  m_pVertices );
          
           int iVertices = (  (  iUTessellations+1 ) * (  iVTessellations+1 ) ); //2 * (  iVTessellations + 1 );
           m_pVertices = ALIGNED_NEW(  iVertices,   splinePoint );
          
           //
           // Re-evaluate the basis functions
           //
           EvaluateBasisFunctions(   );
           }
          }
          
          // -----------------------------------------------------------------------
          // float CDRGNURBSSurface::ComputeCoefficient(  float *fKnots,   int iInterval,   int i,   int p,   int k )
          //
          //
          // Determines the polynomial coefficients from the knot vector
          //
          // Remember that the b-spline basis functions of degree p on knot interval
          // i = (  Bi,  p ) defined on a knot vector u = {U0,   U1,   ...,   Um} are defined:
          //
          // Bi,  0(  u ) = 1 if Ui <= u < Ui+1
          // 0 otherwise
          //
          // u - Ui Ui+p+1 - u
          // Bi,  p(  u ) = ---------- * Bi,  p-1(  u ) + ------------- * Bi+1,  p-1(  u )
          // Ui+p - Ui Ui+p+1 - Ui+1
          //
          //
          // For some degree p on interval i,   there exist p+1 polynomials of
          // degree p of the form:
          //
          // Ci,  p,  0 + Ci,  p,  1 * u^1 + Ci,  p,  2 * u^2 + ... + Ci,  p,  p * u^p
          //
          // I derived a recursive formula for these constant coefficients as
          //
          // Ci,  0,  0 = Bi,  0(  u ) (  i.e. Ci,  0,  0 will be either 0 or 1 )
          //
          // For p > 0
          // Ui+p+1 * Ci+1,  p-1,  0 UiCi,  p-1,  0
          // Ci,  p,  0 = --------------------- - ------------
          // Ui+p+1 - Ui+1 Ui+p - Ui
          //
          // Ci,  p-1,  p-1 Ci+1,  p-1,  p-1
          // Ci,  p,  p = ------------ - ---------------
          // Ui+p - Ui Ui+p+1 - Ui+1
          //
          // For 0<k<p
          // Ci,  p-1,  k-1 - Ui * Ci,  p-1,  k Ci+1,  p-1,  k-1 - Ui+p+1 * Ci+1,  p-1,  k
          // Ci,  p,  k = ---------------------------- - ------------------------------------
          // Ui+p - Ui Ui+p+1 - Ui+1
          //
          //
          // From this,   for a pth degree b-spline,   for each interval i,   there are
          // p+1 b-spline basis functions that are non-zero and each one has p+1
          // coefficients. Note that Ci,  p,  k is dependent on u only for determining the
          // knot span,   i,   that we're computing the coefficients for.
          // The next two functions compute those coefficients for the various intervals
          // -----------------------------------------------------------------------
     264  float CDRGNURBSSurface::ComputeCoefficient(  float *fKnots,   int iInterval,   int i,   int p,   int k )
          {
           float fResult = 0.0f;
          
           if(  p == 0 )
           {
           if(  i == iInterval )
           fResult = 1.0f;
           }
           else if(  k == 0 )
           {
           if(  fKnots[i+p] != fKnots[i] )
           fResult -= fKnots[i] * ComputeCoefficient(  fKnots,   iInterval,   i,   p-1,   0 ) / (  fKnots[i+p] - fKnots[i] );
           if(  fKnots[i+p+1] != fKnots[i+1] )
           fResult += fKnots[i+p+1] * ComputeCoefficient(  fKnots,   iInterval,   i+1,   p-1,   0 ) / (  fKnots[i+p+1] - fKnots[i+1] );
           }
           else if(  k == p )
           {
           if(  fKnots[i+p] != fKnots[i] )
           fResult += ComputeCoefficient(  fKnots,   iInterval,   i,   p-1,   p-1 ) / (  fKnots[i+p] - fKnots[i] );
           if(  fKnots[i+p+1] != fKnots[i+1] )
           fResult -= ComputeCoefficient(  fKnots,   iInterval,   i+1,   p-1,   p-1 ) / (  fKnots[i+p+1] - fKnots[i+1] );
           }
           else if(  k > p )
           {
           fResult = 0.0f;
           }
           else
           {
           float C1,   C2;
           if(  fKnots[i+p] != fKnots[i] )
           {
           C1 = ComputeCoefficient(  fKnots,   iInterval,   i,   p-1,   k-1 );
           C2 = ComputeCoefficient(  fKnots,   iInterval,   i,   p-1,   k );
           fResult += (  C1 - fKnots[i] * C2 ) / (  fKnots[i+p] - fKnots[i] );
           }
           if(  fKnots[i+p+1] != fKnots[i+1] )
           {
           C1 = ComputeCoefficient(  fKnots,   iInterval,   i+1,   p-1,   k-1 );
           C2 = ComputeCoefficient(  fKnots,   iInterval,   i+1,   p-1,   k );
           fResult -= (  C1 - fKnots[i+p+1] * C2 ) / (  fKnots[i+p+1] - fKnots[i+1] );
           }
          
           }
          
           return fResult;
          }
          
          
          // -----------------------------------------------------------------------
          // void CDRGNURBSSurface::ComputeBasisCoefficients(  void )
          //
          // See the comment from the function above,   ComputeCoefficient(   )
          // -----------------------------------------------------------------------
     318  void CDRGNURBSSurface::ComputeBasisCoefficients(  void )
          {
           int i,   j,   k;
          
           //
           // Start with U. For each Basis span calculate coefficients
           // for m_iUOrder polynomials each having m_iUOrder coefficients
           //
          
           for(  i=0; i<m_iUBasisSpans; i++ )
           {
           for(  j=0; j<m_iUOrder; j++ )
           {
           for(  k=0; k<m_iUOrder; k++ )
           {
           m_UBasisCoefficients[ (  i * m_iUOrder + j ) * m_iUOrder + k ] =
           ComputeCoefficient(  m_UKnots,   i + m_iUDegree,   i + j,   m_iUDegree,   k );
           }
           }
           }
          
           for(  i=0; i<m_iVBasisSpans; i++ )
           {
           for(  j=0; j<m_iVOrder; j++ )
           {
           for(  k=0; k<m_iVOrder; k++ )
           {
           m_VBasisCoefficients[ (  i * m_iVOrder + j ) * m_iVOrder + k ] =
           ComputeCoefficient(  m_VKnots,   i + m_iVDegree,   i + j,   m_iVDegree,   k );
           }
           }
           }
          
          }
          
          // -----------------------------------------------------------------------
          // void CDRGNURBSSurface::EvaluateBasisFunctions(  void )
          //
          // Evaluate the polynomials for the basis functions and store the results.
          // First derivatives are calculated as well.
          // -----------------------------------------------------------------------
     359  void CDRGNURBSSurface::EvaluateBasisFunctions(  void )
          {
           int i,   j,   k,   idx;
           float u,   uinc;
           float v,   vinc;
          
           //
           // First evaluate the U basis functions and derivitives at uniformly spaced u values
           //
           idx = 0;
           u = m_UKnots[idx+m_iUDegree];
           uinc = (  m_UKnots[m_iUKnots-m_iUOrder] - m_UKnots[m_iUDegree] )/(  m_iUTessellations );
          
           for(  i=0; i<=m_iUTessellations; i++ )
           {
           while(  (  idx < m_iUKnots - m_iUDegree*2 - 2 ) && (  u >= m_UKnots[idx+m_iUDegree+1] ) )
           idx++;
          
           m_TessUKnotSpan[i] = idx+m_iUDegree;
          
           //
           // Evaluate using Horner's method
           //
           for(  j=0; j<m_iUOrder; j++ )
           {
           m_UBasis[(  i*m_iUOrder+j ) * SIMD_SIZE] = m_UBasisCoefficients[ (  idx * m_iUOrder + j ) * m_iUOrder + m_iUDegree ];
           m_dUBasis[(  i*m_iUOrder+j ) * SIMD_SIZE] = m_UBasis[(  i*m_iUOrder+j ) * SIMD_SIZE] * m_iUDegree;
           for(  k=m_iUDegree-1; k>=0; k-- )
           {
           m_UBasis[(  i*m_iUOrder+j )*SIMD_SIZE] = m_UBasis[ (  i*m_iUOrder+j )*SIMD_SIZE ] * u +
           m_UBasisCoefficients[ (  idx * m_iUOrder + j ) * m_iUOrder + k ];
           if(  k>0 )
           {
           m_dUBasis[(  i*m_iUOrder+j )*SIMD_SIZE] = m_dUBasis[(  i * m_iUOrder+j )*SIMD_SIZE] * u +
           m_UBasisCoefficients[ (  idx * m_iUOrder + j ) * m_iUOrder + k ] * k;
           }
           }
           //
           // Make three copies. This isn't necessary if we're using straight C
           // code but for the Pentium III optimizations,   it is.
           //
           }
          
           u += uinc;
           }
          
           //
           // Finally evaluate the V basis functions at uniformly spaced v values
           //
           idx = 0;
           v = m_VKnots[idx+m_iVDegree];
           vinc = (  m_VKnots[m_iVKnots-m_iVOrder] - m_VKnots[m_iVDegree] )/(  m_iVTessellations );
          
           for(  i=0; i<=m_iVTessellations; i++ )
           {
           while(  (  idx < m_iVKnots - m_iVDegree*2 - 2 ) && (  v >= m_VKnots[idx+m_iVDegree+1] ) )
           idx++;
          
           m_TessVKnotSpan[i] = idx+m_iVDegree;
          
           //
           // Evaluate using Horner's method
           //
           for(  j=0; j<m_iVOrder; j++ )
           {
           m_VBasis[(  i*m_iVOrder+j )*SIMD_SIZE] = m_VBasisCoefficients[ (  idx * m_iVOrder + j ) * m_iVOrder + m_iVDegree ];
           m_dVBasis[(  i*m_iVOrder+j )*SIMD_SIZE] = m_VBasis[(  i*m_iVOrder+j )*SIMD_SIZE] * m_iVDegree;
           for(  k=m_iVDegree-1; k>=0; k-- )
           {
           m_VBasis[(  i*m_iVOrder+j )*SIMD_SIZE] = m_VBasis[ (  i*m_iVOrder+j )*SIMD_SIZE ] * v +
           m_VBasisCoefficients[ (  idx * m_iVOrder + j ) * m_iVOrder + k ];
           if(  k>0 )
           {
           m_dVBasis[(  i*m_iVOrder+j )*SIMD_SIZE] = m_dVBasis[(  i * m_iVOrder+j )*SIMD_SIZE] * v +
           m_VBasisCoefficients[ (  idx * m_iVOrder + j ) * m_iVOrder + k ] * k;
           }
           }
           }
           v += vinc;
           }
          }
          
          // -----------------------------------------------------------------------
          //
          // Tessellate the surface into triangles and submit them as a triangle
          // strip to Direct3D.
          //
          // -----------------------------------------------------------------------
     447  void CDRGNURBSSurface::TessellateSurface(   )
          {
           int u,   v;
           int k,   l;
           int uKnot,   vKnot;
           Point4D *UTemp = m_UTemp,   *dUTemp = m_dUTemp;
           Point4D Pw;
           float rhw;
           int iVertices;
           Point4D *pControlPoints = m_pControlPoints;
           int iCPOffset;
           float VBasis,   dVBasis;
           int idx,   uidx;
          
           if(  (  m_iUTessellations == 0 ) || (  m_iVTessellations == 0 ) )
           return;
          
           iVertices = 2 * (  m_iVTessellations + 1 );
          
           // Step over the U and V coordinates and generate triangle strips to render
           //
           for(  u=0; u<=m_iUTessellations; u++ )
           {
           // What's the current knot span in the U direction?
           uKnot = m_TessUKnotSpan[u];
          
           // Calculate the offset into the pre-calculated basis functions array
           uidx = u * m_iUOrder * SIMD_SIZE;
           vKnot = -1;
          
           // Create one row of vertices
           for(  v=0; v<=m_iVTessellations; v++ )
           {
           idx = u * m_iUTessellations + v;
           if(  vKnot != m_TessVKnotSpan[v] )
           {
           vKnot = m_TessVKnotSpan[v];
           //
           // If our knot span in the V direction has changed,   then calculate some
           // temporary variables. These are the sum of the U-basis functions times
           // the control points (  times the weights because the control points have
           // the weights factored in ).
           //
           for(  k=0; k<=m_iVDegree; k++ )
           {
           iCPOffset = (  uKnot - m_iUDegree ) * m_iVControlPoints + (  vKnot - m_iVDegree );
           UTemp[k].x = m_UBasis[uidx] * pControlPoints[ iCPOffset + k ].x;
           UTemp[k].y = m_UBasis[uidx] * pControlPoints[ iCPOffset + k ].y;
           UTemp[k].z = m_UBasis[uidx] * pControlPoints[ iCPOffset + k ].z;
           UTemp[k].w = m_UBasis[uidx] * pControlPoints[ iCPOffset + k ].w;
           dUTemp[k].x = m_dUBasis[uidx] * pControlPoints[ iCPOffset + k ].x;
           dUTemp[k].y = m_dUBasis[uidx] * pControlPoints[ iCPOffset + k ].y;
           dUTemp[k].z = m_dUBasis[uidx] * pControlPoints[ iCPOffset + k ].z;
           dUTemp[k].w = m_dUBasis[uidx] * pControlPoints[ iCPOffset + k ].w;
          
           for(  l=1; l<=m_iUDegree; l++ )
           {
           iCPOffset += m_iVControlPoints;
           UTemp[k].x += m_UBasis[uidx+l * SIMD_SIZE] * pControlPoints[ iCPOffset + k].x;
           UTemp[k].y += m_UBasis[uidx+l * SIMD_SIZE] * pControlPoints[ iCPOffset + k].y;
           UTemp[k].z += m_UBasis[uidx+l * SIMD_SIZE] * pControlPoints[ iCPOffset + k].z;
           UTemp[k].w += m_UBasis[uidx+l * SIMD_SIZE] * pControlPoints[ iCPOffset + k].w;
           dUTemp[k].x += m_dUBasis[uidx+l * SIMD_SIZE] * pControlPoints[ iCPOffset + k ].x;
           dUTemp[k].y += m_dUBasis[uidx+l * SIMD_SIZE] * pControlPoints[ iCPOffset + k ].y;
           dUTemp[k].z += m_dUBasis[uidx+l * SIMD_SIZE] * pControlPoints[ iCPOffset + k ].z;
           dUTemp[k].w += m_dUBasis[uidx+l * SIMD_SIZE] * pControlPoints[ iCPOffset + k ].w;
           }
           }
           }
          
           // Compute the point in the U and V directions
           VBasis = m_VBasis[ (  v * m_iVOrder )*SIMD_SIZE ];
           dVBasis = m_dVBasis[ (  v * m_iVOrder )*SIMD_SIZE ];
           Pw.x = VBasis * UTemp[0].x;
           Pw.y = VBasis * UTemp[0].y;
           Pw.z = VBasis * UTemp[0].z;
           Pw.w = VBasis * UTemp[0].w;
           for(  k=1; k<=m_iVDegree; k++ )
           {
           VBasis = m_VBasis[ (  v * m_iVOrder + k )*SIMD_SIZE ];
           dVBasis = m_dVBasis[ (  v * m_iVOrder + k )*SIMD_SIZE ];
           Pw.x += VBasis * UTemp[k].x;
           Pw.y += VBasis * UTemp[k].y;
           Pw.z += VBasis * UTemp[k].z;
           Pw.w += VBasis * UTemp[k].w;
           }
          
           // rhw is the factor to multiply by inorder to bring the 4-D points back into 3-D
           rhw = 1.0f / Pw.w;
           Pw.x = Pw.x * rhw;
           Pw.y = Pw.y * rhw;
           Pw.z = Pw.z * rhw;
          
           // Store the vertex position.
           m_pVertices[idx].x = Pw.x;
           m_pVertices[idx].y = Pw.y;
           m_pVertices[idx].z = Pw.z;
           }
           }
          
          }
          
          // -----------------------------------------------------------------------
     550  splinePoint CDRGNURBSSurface::getData(  int index )
          {
           return m_pVertices[index];
          }
          // -----------------------------------------------------------------------
          //
          // Implementation of the base class method.
          //
          // -----------------------------------------------------------------------
     559  int CDRGNURBSSurface::GetTriangleCount(   )
          {
           return 2 * m_iUTessellations * m_iVTessellations;
          }
          
          // -----------------------------------------------------------------------
          //
          // Change the control points of the surface. This method doesn't do any
          // error checking,   so it assumes the array passed in contains as many
          // control points as where used when the surface was initialized.
          //
          // -----------------------------------------------------------------------
     571  void CDRGNURBSSurface::UpdateControlPoints(  Point4D *pControlPoints )
          {
           memcpy(  m_pControlPoints,   pControlPoints,   m_iUControlPoints * m_iVControlPoints * sizeof(  Point4D ) );
          }
          
          
          

./components/ogre/SceneManagers/EmberPagingSceneManager/src/EmberPagingLandScapeData2D_HeightField.cpp

       1  //
          // C++ Implementation: EmberPagingLandScapeData2D_HeightField
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "EmberOgrePrerequisites.h"
          #include "OgrePagingLandScapeOptions.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          
          #include "EmberPagingLandScapeData2D_HeightField.h"
          #include "EmberPagingSceneManager.h"
          
          #include "EmberOgre.h"
          #include "terrain/TerrainPage.h"
          #include "terrain/TerrainGenerator.h"
          
          
          using namespace Ogre;
          namespace EmberOgre
          {
          
      41  EmberPagingLandScapeData2D_HeightField::EmberPagingLandScapeData2D_HeightField(  Ogre::PagingLandScapeData2DManager *pageMgr )
          : Ogre::PagingLandScapeData2D(  pageMgr ),   mTerrainPage(  0 )
          {
           ///set it to something,   so it doesn't default to a crazy number (  like 5.79555e+022 ) since that will break stuff later on
           ///in regards to calculating the distance to the tile (  especially in PagingLandScapeTile::_Notify )
           mMaxheight = 1;
          }
          
      49  bool EmberPagingLandScapeData2D_HeightField::_load(   const Ogre::uint x,   const Ogre::uint z  )
          {
           assert(  !mTerrainPage );
           Terrain::TerrainGenerator* terrainGenerator = EmberOgre::getSingleton(   ).getTerrainGenerator(   );
           mXDimension = mZDimension = terrainGenerator->getPageSize(   );
          
           mMaxArrayPos = mSize * mSize;
           mHeightData = new Real[mMaxArrayPos];
           mTerrainPage = terrainGenerator->getTerrainPage(  Ogre::Vector2(  x,  z ) );
           //should always return a TerrainPage*
           assert(  mTerrainPage );
          
           mTerrainPage->createHeightData(  mHeightData );
          
          
           ///make sure it's not 0
           mMaxheight = std::max<float>(  mTerrainPage->getMaxHeight(   ),   1.0f );
           mMax = static_cast <unsigned int> (  mSize * mTerrainPage->getMaxHeight(   ) );
           return true;
          }
          
      70  PagingLandScapeData2D* EmberPagingLandScapeData2D_HeightField::newPage(    )
          {
           return new EmberPagingLandScapeData2D_HeightField(  mParent );
          }
          
          
      76  const ColourValue EmberPagingLandScapeData2D_HeightField::getBase (  const Real mX,   const Real mZ )
          {
          
           return ColourValue::White;
          
          }
          
           //-----------------------------------------------------------------------
      84  const ColourValue EmberPagingLandScapeData2D_HeightField::getCoverage (  const Real mX,   const Real mZ )
          {
          
           return ColourValue::Blue;
          }
          
           //-----------------------------------------------------------------------
      91  const Real EmberPagingLandScapeData2D_HeightField::getShadow (  const Real mX,   const Real mZ,  
      92   const bool &positive )
          {
          
           return 0.0f;
          
          }
          
           //-----------------------------------------------------------------------
     100  const Vector3 EmberPagingLandScapeData2D_HeightField::getNormal (  const Real x,   const Real z )
          {
           float height;
           WFMath::Vector<3> normal;
           EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getTerrain(   ).getHeightAndNormal(  x,   -z,   height,   normal );
           return Atlas2Ogre(  normal );
          // return Ogre::PagingLandScapeData2D::getNormal(  x,   z );
          }
           //-----------------------------------------------------------------------
     109  void EmberPagingLandScapeData2D_HeightField::_save(   )
          {
           S_LOG_VERBOSE(  "Saving terrain page at x: " << mPageX << " z:" << mPageZ << "." );
          }
           //-----------------------------------------------------------------------
           //-----------------------------------------------------------------------
     115  void EmberPagingLandScapeData2D_HeightField::_load(   )
          {
           S_LOG_VERBOSE(  "Loading (  _load(   ) ) terrain page at x: " << mPageX << " z:" << mPageZ << "." );
          }
           //-----------------------------------------------------------------------
     120  void EmberPagingLandScapeData2D_HeightField::_unload(   )
          {
           S_LOG_VERBOSE(  "Unloading terrain page at x: " << mPageX << " z:" << mPageZ << "." );
           mTerrainPage = 0;
          }
          
     126  const Ogre::Real EmberPagingLandScapeData2D_HeightField::getMaxAbsoluteHeight(  void ) const
          {
           ///return a totally arbitrary high enough value
           return 250.0f;
           //return mMaxheight;
          }
          
          
          
          };

./components/ogre/SceneManagers/EmberPagingSceneManager/src/EmberPagingLandScapeTexture.cpp

       1  //
          // C++ Implementation: EmberPagingLandScapeTexture
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "EmberPagingLandScapeTexture.h"
          #include "EmberOgre.h"
          #include "terrain/TerrainPage.h"
          #include "terrain/TerrainGenerator.h"
          
          namespace EmberOgre
          {
          
      32   EmberPagingLandScapeTexture::EmberPagingLandScapeTexture(  Ogre::PagingLandScapeTextureManager *pageMgr )
           : Ogre::PagingLandScapeTexture(  pageMgr,   "EmberTexture",   1,   false )
           {
           }
          
      37   EmberPagingLandScapeTexture::~EmberPagingLandScapeTexture(   void  )
           {
           }
          
      41   Ogre::PagingLandScapeTexture* EmberPagingLandScapeTexture::newTexture(    )
           {
           return new EmberPagingLandScapeTexture(  mParent );
           }
          
      46   bool EmberPagingLandScapeTexture::isMaterialSupported(  bool recursive )
           {
           //TODO: check for stuff here
           return true;
           }
          
      52   void EmberPagingLandScapeTexture::setOptions(  void )
           {
           }
          
      56   void EmberPagingLandScapeTexture::_loadMaterial(    )
           {
           Terrain::TerrainGenerator* terrainGenerator = EmberOgre::getSingleton(   ).getTerrainGenerator(   );
           Terrain::TerrainPage* page = terrainGenerator->getTerrainPage(  Ogre::Vector2(  mDataX,   mDataZ ) );
           assert(  page );
           if (  page ) {
           mMaterial = page->getMaterial(   );
           }
          
           }
          
      67   void EmberPagingLandScapeTexture::_unloadMaterial(   )
           {
           S_LOG_VERBOSE(  "Unloading terrain material." );
           }
          
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/EmberPagingSceneManager.cpp

       1  //
          // C++ Implementation: EmberPagingSceneManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "EmberPagingSceneManager.h"
          #include "EmberOgrePrerequisites.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "EmberPagingLandScapeData2D_HeightField.h"
          #include "EmberPagingLandScapeTexture.h"
          #include "model/Model.h"
          
          namespace EmberOgre {
          
           const Ogre::String EmberPagingSceneManagerFactory::FACTORY_TYPE_NAME = "EmberPagingSceneManager";
           //-----------------------------------------------------------------------
      38   void EmberPagingSceneManagerFactory::initMetaData(  void ) const
           {
           mMetaData.typeName = FACTORY_TYPE_NAME;
           mMetaData.description = "Uses the PagingLandscapeSceneManager.";
           mMetaData.sceneTypeMask = Ogre::ST_EXTERIOR_REAL_FAR; // support all types
           mMetaData.worldGeometrySupported = false;
           }
           //-----------------------------------------------------------------------
      46   Ogre::SceneManager* EmberPagingSceneManagerFactory::createInstance(  
      47   const Ogre::String& instanceName )
           {
           return new EmberPagingSceneManager(  instanceName );
           }
           //-----------------------------------------------------------------------
      52   void EmberPagingSceneManagerFactory::destroyInstance(  Ogre::SceneManager* instance )
           {
           delete instance;
           }
          
          
      58   EmberPagingSceneManager::EmberPagingSceneManager(  const Ogre::String &name ): PagingLandScapeSceneManager(  name )
           {
           if (  !mOptions )
           mOptions = new Ogre::PagingLandScapeOptions(  this );
           }
          
          
           //-----------------------------------------------------------------------
      66   void EmberPagingSceneManager::InitScene (   )
           {
           PagingLandScapeSceneManager::InitScene (   );
          
           getData2DManager(   )->registerDataType (  new EmberPagingLandScapeData2D_HeightField (  getData2DManager(   ) ) );
           getTextureManager(   )->registerTextureType (  new EmberPagingLandScapeTexture (  getTextureManager(   ) ) );
          
           }
          
      75   void EmberPagingSceneManager::registerProvider(  IPageDataProvider* provider )
           {
           mProvider = provider;
           }
          
      80   Model::Model* EmberPagingSceneManager::createModel(  
      81   const Ogre::String& modelName,  
      82   const Ogre::String& modelDefinitionName  )
           {
           // delegate to factory implementation
           Ogre::NameValuePairList params;
           params["modeldefinition"] = modelDefinitionName;
           return static_cast<Model::Model*>(  
           createMovableObject(  modelName,   Model::ModelFactory::FACTORY_TYPE_NAME,  
           &params ) );
          
           }
          
          }
          

./components/ogre/SceneManagers/EmberPagingSceneManager/src/EmberPagingSceneManagerAdapter.cpp

       1  //
          // C++ Implementation: EmberPagingSceneManagerAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "EmberPagingSceneManagerAdapter.h"
          
          #include "EmberPagingSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapePageManager.h"
          #include "OgrePagingLandScapePage.h"
          
          namespace EmberOgre {
          
      33   Ogre::PagingLandScapeOptions* EmberPagingSceneManagerAdapter::getOptions(   )
           {
           return mSceneManager->getOptions(   );
           }
          
      38   EmberPagingSceneManagerAdapter::EmberPagingSceneManagerAdapter(  EmberPagingSceneManager* scenemanager ) : mSceneManager(  scenemanager )
           {
           }
          
      42   int EmberPagingSceneManagerAdapter::getPageSize(   )
           {
           return getOptions(   )->PageSize;
           }
          
      47   Ogre::Real EmberPagingSceneManagerAdapter::getHeightAt(  const Ogre::Real x,   const Ogre::Real z )
           {
           return mSceneManager->getHeightAt(  x,   z );
           }
          
          
      53   void EmberPagingSceneManagerAdapter::setWorldPagesDimensions(  int numberOfPagesHeight,   int numberOfPagesWidth,   int heightOffsetInPages,   int widthOffsetInPages )
           {
           ///in order position (  0,  0 ) to be aligned to the centre of the terrain we must offset the position of the terrain a bit
           getOptions(   )->position.z = (  (  numberOfPagesHeight * 0.5f ) - heightOffsetInPages ) * getOptions(   )->PageSize;
           getOptions(   )->position.x = (  (  numberOfPagesWidth * 0.5f ) - widthOffsetInPages ) * getOptions(   )->PageSize;
          
           getOptions(   )->world_height = numberOfPagesHeight;
           getOptions(   )->world_width = numberOfPagesWidth;
          
           ///update the options
           getOptions(   )->NumPages = getOptions(   )->world_height * getOptions(   )->world_width;
           getOptions(   )->maxUnScaledZ = getOptions(   )->world_height * (  getOptions(   )->PageSize - 1 ) * 0.5f;
           getOptions(   )->maxUnScaledX = getOptions(   )->world_width * (  getOptions(   )->PageSize - 1 ) * 0.5f;
          
           getOptions(   )->maxScaledZ = getOptions(   )->scale.z * getOptions(   )->maxUnScaledZ;
           getOptions(   )->maxScaledX = getOptions(   )->scale.x * getOptions(   )->maxUnScaledX;
          
           }
          
      72   void EmberPagingSceneManagerAdapter::resize(  Ogre::AxisAlignedBox newSize,   int levels )
           {
           mSceneManager->resize(  newSize,   levels );
           }
          
      77   void EmberPagingSceneManagerAdapter::setCamera(  Ogre::Camera* camera )
           {
           mSceneManager->setOption(  "primaryCamera",   camera );
           }
          
      82   void EmberPagingSceneManagerAdapter::setResourceGroupName(  const std::string& groupName )
           {
           mSceneManager->setOption(  "GroupName",   &groupName );
           mSceneManager->getOptions(   )->groupName = groupName;
           mSceneManager->getOptions(   )->cfgGroupName = groupName;
           }
          
      89   void EmberPagingSceneManagerAdapter::loadOptions(  const std::string& filePath )
           {
           mSceneManager->getOptions(   )->loadMapOptions(  filePath );
          
           mSceneManager->getOptions(   )->setTextureFormat(  "EmberTexture" );
           }
          
      96   void EmberPagingSceneManagerAdapter::loadScene(   )
           {
           mSceneManager->loadScene(   );
           mSceneManager->getOptions(   )->setOption(  "LoadNow",   0 );
           }
          
     102   void EmberPagingSceneManagerAdapter::setOption(  const std::string& strKey,   const void* pValue )
           {
           mSceneManager->setOption(  strKey,   pValue );
           }
          
     107   void EmberPagingSceneManagerAdapter::getOption(  const std::string& strKey,   void* pDestValue )
           {
           mSceneManager->getOption(  strKey,   pDestValue );
           }
          
     112   Ogre::SceneManager* EmberPagingSceneManagerAdapter::getSceneManager(   ) const
           {
           return mSceneManager;
           }
          
     117   void EmberPagingSceneManagerAdapter::reloadAllPages(   )
           {
           mSceneManager->getPageManager(   )->load(   );
           }
          
     122   void EmberPagingSceneManagerAdapter::reloadPage(  unsigned int x,   unsigned int z )
           {
           Ogre::Vector2 position(  x,  z );
           setOption(  "PageUpdate",   &position );
           Ogre::PagingLandScapePage* page= mSceneManager->getPageManager(   )->getPage(  x,   z,   false );
           if (  page ) {
          // page->reload(   );
           page->unload(   );
           page->load(   );
           }
           }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgreDebugRectangle2D.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreDebugRectangle2D.h"
          #ifdef _VISIBILITYDEBUG
          
          #include "OgreHardwareBufferManager.h"
          #include "OgreCamera.h"
          
          #include "OgreRoot.h"
          
          namespace Ogre {
          #define POSITION_BINDING 0
          
      39   DebugRectangle2D::DebugRectangle2D(   ) : SimpleRenderable (   )
           {
          #ifdef PLSM2_EIHORT
           mUseIdentityProjection = true;
           mUseIdentityView = true;
          #endif
           mRenderOp.indexData = new IndexData(   );
           mRenderOp.vertexData = new VertexData(   );
           mRenderOp.operationType = RenderOperation::OT_LINE_LIST;
           mRenderOp.indexData->indexCount = 8;
           mRenderOp.vertexData->vertexCount = 4;
           mRenderOp.vertexData->vertexStart = 0;
           mRenderOp.useIndexes = true;
          
          
           VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
           VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
          
           decl->addElement(  POSITION_BINDING,   0,   VET_FLOAT3,   VES_POSITION );
           const size_t offset = VertexElement::getTypeSize(  VET_FLOAT3 );
           decl->addElement (  POSITION_BINDING,   offset,   VET_COLOUR,   VES_DIFFUSE );
          
          
           mRenderOp.indexData->indexBuffer = HardwareBufferManager::getSingleton(   ).createIndexBuffer(  
           HardwareIndexBuffer::IT_16BIT,  
           mRenderOp.indexData->indexCount,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
           HardwareVertexBufferSharedPtr vbuf =
           HardwareBufferManager::getSingleton(   ).createVertexBuffer(  
           decl->getVertexSize(  POSITION_BINDING ),  
           mRenderOp.vertexData->vertexCount,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
           // Bind buffer
           bind->setBinding(  POSITION_BINDING,   vbuf );
          
           SimpleRenderable::setBoundingBox(  AxisAlignedBox(  -1000 * Vector3::UNIT_SCALE,  
           1000 * Vector3::UNIT_SCALE ) );
          
           SimpleRenderable::setRenderQueueGroup (  RENDER_QUEUE_OVERLAY );
          
           // set basic white material
           SimpleRenderable::setMaterial(  "BaseWhiteNoLighting" );
           }
          
      85   DebugRectangle2D::~DebugRectangle2D(   )
           {
           delete mRenderOp.vertexData;
           delete mRenderOp.indexData;
           }
          
      91   void DebugRectangle2D::setCorners(  Real left,   Real top,   Real right,   Real bottom )
           {
           VertexDeclaration * const decl = mRenderOp.vertexData->vertexDeclaration;
           const VertexElement* poselem = decl->findElementBySemantic(  VES_POSITION );
           const VertexElement* colorelem = decl->findElementBySemantic(  VES_DIFFUSE );
          
          
           HardwareVertexBufferSharedPtr vbuf =
           mRenderOp.vertexData->vertexBufferBinding->getBuffer(  POSITION_BINDING );
          
          
           const size_t vertexSize = vbuf->getVertexSize (   );
           float *pPos;
           RGBA *pColor;
           Root * const root = Root::getSingletonPtr(   );
          
           uchar* pMain = static_cast<uchar *>(  
           vbuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          
          
          // #define V3(  AX,   AY,   AZ,   ACOLOR ) poselem->baseVertexPointerToElement(  pMain,   &pPos ); \
          // *pPos++ = AX; *pPos++ = AY; *pPos++ = AZ; \
          // pMain += vertexSize;
          
          #define V3(  A_X,   A_Y,   A_Z,   ACOLOR ) poselem->baseVertexPointerToElement(  pMain,   &pPos ); \
           *pPos++ = static_cast <float> (  A_X ); \
           *pPos++ = static_cast <float> (  A_Y ); \
           *pPos++ = static_cast <float> (  A_Z ); \
           colorelem->baseVertexPointerToElement(  pMain,   &pColor ); \
           root->convertColourValue (  ACOLOR,   pColor ); \
           pMain += vertexSize;
          
           V3(  left,   top,   -1.0f,   ColourValue::White )
           V3(  left,   bottom,   -1.0f,   ColourValue::White )
           V3(  right,   bottom,   -1.0f,   ColourValue::White )
           V3(  right,   top,   -1.0f,   ColourValue::White )
          
           vbuf->unlock(   );
          
          
          
           HardwareIndexBufferSharedPtr iBuf = mRenderOp.indexData->indexBuffer;
           ushort* pIdx = static_cast<ushort*>(  
           iBuf->lock(  0,   iBuf->getSizeInBytes(   ),  HardwareBuffer::HBL_DISCARD ) );
          
          
           *pIdx++ = static_cast<ushort> (  0 ); *pIdx++ = static_cast<ushort> (  1 ); // line 1
           *pIdx++ = static_cast<ushort> (  1 ); *pIdx++ = static_cast<ushort> (  2 ); // line 2
           *pIdx++ = static_cast<ushort> (  2 ); *pIdx++ = static_cast<ushort> (  3 ); // line 3
     140   *pIdx++ = static_cast<ushort> (  3 ); *pIdx++ = static_cast<ushort> (  0 ); // line 4
          
           iBuf->unlock(   );
           }
          
           // Override this method to prevent parent transforms (  rotation,  translation,  scale )
     146   void DebugRectangle2D::getWorldTransforms(  Matrix4* xform ) const
           {
           // return identity matrix to prevent parent transforms
           *xform = Matrix4::IDENTITY;
           }
     151   //-----------------------------------------------------------------------
           const Quaternion& DebugRectangle2D::getWorldOrientation(  void ) const
           {
           return Quaternion::IDENTITY;
           }
           //-----------------------------------------------------------------------
           const Vector3& DebugRectangle2D::getWorldPosition(  void ) const
           {
           return Vector3::ZERO;
           }
          
          
          }
          #endif //_VISIBILITYDEBUG

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgreOcclusionBoundingBox.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
           (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "Ogre.h"
          #include "OgreOcclusionBoundingBox.h"
          
          #include "OgreSimpleRenderable.h"
          #include "OgreHardwareBufferManager.h"
          #include "OgreCamera.h"
          
          namespace Ogre {
           #define POSITION_BINDING 0
          
           //-----------------------------------------------------------------------
      39   OcclusionBoundingBox::OcclusionBoundingBox(   )
           {
           mRenderOp.indexData = new IndexData(   );
           mRenderOp.vertexData = new VertexData(   );
           mRenderOp.operationType = RenderOperation::OT_TRIANGLE_LIST;
           mRenderOp.indexData->indexCount = 36;
           mRenderOp.vertexData->vertexCount = 24;
           mRenderOp.vertexData->vertexStart = 0;
           mRenderOp.useIndexes = true;
          
           VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
           VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
          
           decl->addElement(  POSITION_BINDING,   0,   VET_FLOAT3,   VES_POSITION );
           //const size_t offset = VertexElement::getTypeSize(  VET_FLOAT3 );
           //decl->addElement (  POSITION_BINDING,   offset,   VET_COLOUR,   VES_DIFFUSE );
          
          
           mRenderOp.indexData->indexBuffer = HardwareBufferManager::getSingleton(   ).createIndexBuffer(  
           HardwareIndexBuffer::IT_16BIT,  
           mRenderOp.indexData->indexCount,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
           HardwareVertexBufferSharedPtr vbuf =
           HardwareBufferManager::getSingleton(   ).createVertexBuffer(  
           decl->getVertexSize(  POSITION_BINDING ),  
           mRenderOp.vertexData->vertexCount,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
           // Bind buffer
           bind->setBinding(  POSITION_BINDING,   vbuf );
          
           this->setPolygonModeOverrideable (  false );
           //Renderable::getPolygonMode (   );
          
           // set basic white material
           this->setMaterial(  "BaseWhiteNoLightNoDepthCheckWrite" );
           }
           //-----------------------------------------------------------------------
      78   PolygonMode OcclusionBoundingBox:: getRenderDetail(   ) const
           {
           //return PM_WIREFRAME;
           return PM_SOLID;
           }
          
           //-----------------------------------------------------------------------
      85   OcclusionBoundingBox::~OcclusionBoundingBox(   )
           {
           delete mRenderOp.indexData;
           delete mRenderOp.vertexData;
           }
           //-----------------------------------------------------------------------
      91   void OcclusionBoundingBox::setupBoundingBox(  const AxisAlignedBox& aabb )
           {
           // init the vertices to the aabb
           setupBoundingBoxVertices(  aabb );
          
           // setup the bounding box of this SimpleRenderable
           setBoundingBox(  aabb );
          
           }
           //-----------------------------------------------------------------------
           // Override this method to prevent parent transforms (  rotation,  translation,  scale )
     102   void OcclusionBoundingBox::getWorldTransforms(  Matrix4* xform ) const
           {
           // return identity matrix to prevent parent transforms
           *xform = Matrix4::IDENTITY;
           }
           //-----------------------------------------------------------------------
     108   const Quaternion& OcclusionBoundingBox::getWorldOrientation(  void ) const
           {
           return Quaternion::IDENTITY;
           }
           //-----------------------------------------------------------------------
     113   const Vector3& OcclusionBoundingBox::getWorldPosition(  void ) const
           {
           return Vector3::ZERO;
           }
           //-----------------------------------------------------------------------
     118   void OcclusionBoundingBox::setupBoundingBoxVertices(  const AxisAlignedBox& aab )
           {
           const Vector3 &max = aab.getMaximum(   );
           const Vector3 &min = aab.getMinimum(   );
          
           const Real sqLen = std::max(  max.squaredLength(   ),  
           min.squaredLength(   ) );
           mRadius = Math::Sqrt(  sqLen );
          
          
           VertexDeclaration * const decl = mRenderOp.vertexData->vertexDeclaration;
           const VertexElement* poselem = decl->findElementBySemantic(  VES_POSITION );
           //const VertexElement* colorelem = decl->findElementBySemantic(  VES_DIFFUSE );
          
          
           HardwareVertexBufferSharedPtr vbuf =
           mRenderOp.vertexData->vertexBufferBinding->getBuffer(  POSITION_BINDING );
          
           const size_t vertexSize = vbuf->getVertexSize (   );
           float *pPos;
           //RGBA *pColor;
           //Root * const root = Root::getSingletonPtr(   );
          
           uchar* pMain = static_cast<uchar *>(  
           vbuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          
          
           //generate 8 corners of the bbox
           // RightHanded
          
           #define V3(  A_X,   A_Y,   A_Z,   ACOLOR ) poselem->baseVertexPointerToElement(  pMain,   &pPos ); \
           *pPos++ = static_cast <float> (  A_X ); \
           *pPos++ = static_cast <float> (  A_Y ); \
           *pPos++ = static_cast <float> (  A_Z ); \
           pMain += vertexSize;
          
          // #define V3(  AX,   AY,   AZ,   ACOLOR ) poselem->baseVertexPointerToElement(  pMain,   &pPos ); \
          // *pPos++ = AX; *pPos++ = AY; *pPos++ = AZ; \
          // colorelem->baseVertexPointerToElement(  pMain,   &pColor ); \
          // root->convertColourValue (  ACOLOR,   pColor ); \
          // pMain += vertexSize;
          
           V3(  min.x,   max.y,   max.z,   ColourValue::White ) // 1
           V3(  min.x,   min.y,   max.z,   ColourValue::White ) // 2
           V3(  max.x,   max.y,   max.z,   ColourValue::White ) // 3
           V3(  max.x,   min.y,   max.z,   ColourValue::White ) // 4
           V3(  max.x,   max.y,   min.z,   ColourValue::White ) // 5
           V3(  max.x,   min.y,   min.z,   ColourValue::White ) // 6
           V3(  min.x,   max.y,   min.z,   ColourValue::White ) // 7
           V3(  min.x,   min.y,   min.z,   ColourValue::White ) // 8
          
          
           vbuf->unlock(   );
          
          
           HardwareIndexBufferSharedPtr iBuf = mRenderOp.indexData->indexBuffer;
           ushort* pIdx = static_cast<ushort*>(  
           iBuf->lock(  0,   iBuf->getSizeInBytes(   ),  HardwareBuffer::HBL_DISCARD ) );
          
           *pIdx++ = static_cast<ushort> (  0 ); *pIdx++ = static_cast<ushort> (  1 ); *pIdx++ = static_cast<ushort> (  2 );
           *pIdx++ = static_cast<ushort> (  1 ); *pIdx++ = static_cast<ushort> (  3 ); *pIdx++ = static_cast<ushort> (  2 );
           *pIdx++ = static_cast<ushort> (  2 ); *pIdx++ = static_cast<ushort> (  3 ); *pIdx++ = static_cast<ushort> (  4 );
           *pIdx++ = static_cast<ushort> (  3 ); *pIdx++ = static_cast<ushort> (  5 ); *pIdx++ = static_cast<ushort> (  4 );
           *pIdx++ = static_cast<ushort> (  6 ); *pIdx++ = static_cast<ushort> (  5 ); *pIdx++ = static_cast<ushort> (  7 );
           *pIdx++ = static_cast<ushort> (  5 ); *pIdx++ = static_cast<ushort> (  7 ); *pIdx++ = static_cast<ushort> (  6 );
           *pIdx++ = static_cast<ushort> (  6 ); *pIdx++ = static_cast<ushort> (  7 ); *pIdx++ = static_cast<ushort> (  0 );
           *pIdx++ = static_cast<ushort> (  7 ); *pIdx++ = static_cast<ushort> (  1 ); *pIdx++ = static_cast<ushort> (  0 );
           *pIdx++ = static_cast<ushort> (  4 ); *pIdx++ = static_cast<ushort> (  6 ); *pIdx++ = static_cast<ushort> (  0 );
           *pIdx++ = static_cast<ushort> (  4 ); *pIdx++ = static_cast<ushort> (  0 ); *pIdx++ = static_cast<ushort> (  2 );
           *pIdx++ = static_cast<ushort> (  1 ); *pIdx++ = static_cast<ushort> (  7 ); *pIdx++ = static_cast<ushort> (  3 );
           *pIdx++ = static_cast<ushort> (  7 ); *pIdx++ = static_cast<ushort> (  5 ); *pIdx++ = static_cast<ushort> (  3 );
     189  
           iBuf->unlock(   );
           }
           //-----------------------------------------------------------------------
           Real OcclusionBoundingBox::getSquaredViewDepth(  const Camera* cam ) const
           {
           const Vector3 &min = mBox.getMinimum(   );
           const Vector3 &max = mBox.getMaximum(   );
           const Vector3 mid = (  (  max - min ) * 0.5f ) + min;
           const Vector3 dist = cam->getDerivedPosition(   ) - mid;
          
           return dist.squaredLength(   );
           }
          }
          

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeAxisAlignedBoxSceneQuery.cpp

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeAxisAlignedBoxSceneQuery.cpp - description
          -------------------
          begin : Sat Oct 15,   2006
          copyright : (  C ) 2006 by Steven Klug
          email : stevenklug@san.rr.com
          
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeAxisAlignedBoxSceneQuery.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgreEntity.h"
          
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapePage.h"
          #include "OgrePagingLandScapePageManager.h"
          
          using namespace Ogre;
          
          namespace Ogre
          {
           // NOTE: Creating some of my own conversion functions here even though
           // these are somewhat duplicating code in the page manager. It was
           // more for the exercise of getting clear in my head the differences
           // between world coords,   page local coords,   page numbers,   tiles,   etc.
           // May convert back to the ones in the page manager eventually,   though
           // these may offer some speed advantages as some redundant calculations
           // (  invPageSize,   etc. ) are only done once in the main query.
          
           //-----------------------------------------------------------------------
           // Scale a coordinate from world space to page number and coord for local
           // unscaled page space.
           inline
      63   bool WorldToPage(   Real coord,   Real scale,   Real maxUnScaled,   uint pageSize,   Real invPageSize,   uint worldExtent,  
           uint& pageNumber,   Real& localPageCoord  )
           {
           // scale position from world to page scale
           Real unscaled = (  coord / scale ) + maxUnScaled;
          
           // get Page
           Real value = unscaled * invPageSize;
           uint maxPage = static_cast<int>(   worldExtent  );
           // Set output params.
           pageNumber = static_cast<int>(   value  );
           if(   value < 0.0  )
           {
           pageNumber = 0;
           localPageCoord = 0.0;
           return false;
           }
           else if(   pageNumber >= maxPage  )
           {
           pageNumber = maxPage - 1;
           localPageCoord = pageNumber * pageSize + pageSize - 1;
           return false;
           }
           else
           {
           localPageCoord = unscaled - (   pageNumber * pageSize  );
           return true;
           }
           }
          
           //-----------------------------------------------------------------------
           inline
      95   Real PageToWorld(   uint pageNumber,   Real localPageCoord,   Real scale,   Real maxUnScaled,   uint pageSize  )
           {
           Real unscaled = localPageCoord + pageNumber * pageSize;
           return (   unscaled - maxUnScaled  ) * scale;
           }
          
           //-----------------------------------------------------------------------
           // Scale a coordinate from local page space to tile number.
           inline
     104   uint PageToTile(   int localPageCoord,   Real invTileSize,   uint maxNumTiles  )
           {
           // get Tile
           uint value = static_cast< uint > (  localPageCoord * invTileSize );
           return (   value < 0  ) ? 0 : (  value >= maxNumTiles ? maxNumTiles - 1: value );
           }
          
           //-----------------------------------------------------------------------
           //-----------------------------------------------------------------------
           //-----------------------------------------------------------------------
           // Operations and data for render levels (  lod levels ).
     115   class RenderLevel
           {
           int renderLevel_;
           int lodStep_;
     119   uint lodMask_;
           public:
           //-----------------------------------------------------------------------
     122   RenderLevel(   )
           {
           SetRenderLevel(   0  );
           }
           //-----------------------------------------------------------------------
     127   RenderLevel(   int renderLevel  )
           {
           SetRenderLevel(   renderLevel  );
           }
           //-----------------------------------------------------------------------
     132   void SetRenderLevel(   int renderLevel  )
           {
           renderLevel_ = renderLevel;
           lodStep_ = 1 << renderLevel;
           lodMask_ = ~(   lodStep_ - 1  );
           }
           //-----------------------------------------------------------------------
     139   int GetRenderLevel(   ) const
           {
           return renderLevel_;
           }
           //-----------------------------------------------------------------------
     144   int GetLodStep(   ) const
           {
           return lodStep_;
           }
           //-----------------------------------------------------------------------
     149   uint GetLodMask(   ) const
           {
           return lodMask_;
           }
           //-----------------------------------------------------------------------
     154   bool operator < (   const RenderLevel& rhs  ) const
           {
           return renderLevel_ < rhs.renderLevel_;
           }
           //-----------------------------------------------------------------------
           // Step the input coordinate by the lodStep.
     160   int LodStep(   int localPageCoord  ) const
           {
           return localPageCoord + lodStep_;
           }
           //-----------------------------------------------------------------------
           // Return the floor of the passed in coord based on valid LOD.
     166   int Floor(   int localPageCoord  ) const
           {
           return localPageCoord & lodMask_;
           }
           //-----------------------------------------------------------------------
           // Return the ceiling of the passed in coord based on valid LOD.
     172   int Ceil(   int localPageCoord  ) const
           {
           if(   Floor(   localPageCoord  ) == localPageCoord  )
           return localPageCoord; // Already at ceiling.
           else
           return Floor(   localPageCoord + lodStep_  );
           }
           //-----------------------------------------------------------------------
     180   int GetLodLevel(   ) const
           {
           return lodStep_;
           }
           };
          
           //-----------------------------------------------------------------------
           //-----------------------------------------------------------------------
           //-----------------------------------------------------------------------
           // Object responsible for caching tile changes specific to lod stepping.
     190   class LodTracker
           {
     192   const Vector3 scale_;
     193   const Real maxUnScaledX_;
     194   const Real maxUnScaledZ_;
     195   const uint pageSize_;
     196   const Real invPageSize_;
     197   const uint tileSize_;
     198   const Real invTileSize_;
     199   const uint maxNumTiles_;
     200   PagingLandScapePageManager* pageMgr_;
     201   PagingLandScapeData2DManager* dataMgr_;
          
     203   const PagingLandScapePage* page_;
     204   const PagingLandScapeData2D* pageData_;
     205   PagingLandScapeTile* tile_;
     206   RenderLevel renderLevel_;
     207   uint pageX_;
     208   uint pageZ_;
           public:
           //-----------------------------------------------------------------------
           LodTracker(   Vector3 scale,  
           Real maxUnScaledX,  
           Real maxUnScaledZ,  
           uint pageSize,  
           uint tileSize,  
           uint maxNumTiles,  
           PagingLandScapePageManager* pageMgr,  
           PagingLandScapeData2DManager* dataMgr  )
           : scale_(   scale  )
           ,   maxUnScaledX_(   maxUnScaledX  )
           ,   maxUnScaledZ_(   maxUnScaledZ  )
           ,   pageSize_(   pageSize  )
           ,   invPageSize_(   1.0f / pageSize  )
           ,   tileSize_(   tileSize  )
           ,   invTileSize_(   1.0f / tileSize  )
           ,   maxNumTiles_(   maxNumTiles  )
           ,   pageMgr_(   pageMgr  )
           ,   dataMgr_(   dataMgr  )
           ,   page_(   0  )
           ,   pageData_(   0  )
           ,   tile_(   0  )
           ,   pageX_(   0  )
           ,   pageZ_(   0  ) {}
          
           //-----------------------------------------------------------------------
     236   uint GetTileSize(   ) const
           {
           return tileSize_;
           }
           //-----------------------------------------------------------------------
     241   Real GetInvTileSize(   ) const
           {
           return invTileSize_;
           }
           //-----------------------------------------------------------------------
     246   uint GetMaxNumTiles(   ) const
           {
           return maxNumTiles_;
           }
           //-----------------------------------------------------------------------
     251   const RenderLevel& GetRenderLevel(   ) const
           {
           return renderLevel_;
           }
           //-----------------------------------------------------------------------
     256   const PagingLandScapePage* GetPage(   ) const
           {
           return page_;
           }
           //-----------------------------------------------------------------------
     261   uint GetPageX(   ) const
           {
           return pageX_;
           }
           //-----------------------------------------------------------------------
     266   uint GetPageZ(   ) const
           {
           return pageZ_;
           }
           //-----------------------------------------------------------------------
           // Returns true if the vertex is included,   or false if it is removed
           // by LOD. Requires local page coordinates.
     273   bool GetWorldVertex(   int localPageX,   int localPageZ,   Vector3& vertex  )
           {
           UpdateWithLocalPage(   localPageX,   localPageZ  );
           bool included = (   renderLevel_.Floor(   localPageX  ) == localPageX &&
           renderLevel_.Floor(   localPageZ  ) == localPageZ  );
           if(   page_ && page_->isLoaded(   ) && pageData_  )
           {
           // TODO: Do we really need to include the real data when the vertex
           // has been removed by lod? Or can we just stuff a dummy result in
           // here to fill out the array?
           vertex.y = pageData_->getHeight(   localPageX,   localPageZ  );
           page_->getCoordinates(   pageX_,   pageZ_  );
           vertex.x = PageToWorld(   pageX_,   localPageX,   scale_.x,   maxUnScaledX_,   pageSize_  );
           vertex.z = PageToWorld(   pageZ_,   localPageZ,   scale_.z,   maxUnScaledZ_,   pageSize_  );
           }
           return included;
           }
           //-----------------------------------------------------------------------
           // Set the current page. Must be called before Update(   ).
     292   void SetPage(   const PagingLandScapePage* page  )
           {
           page_ = page;
           if(   page_ && page_->isLoaded(   )  )
           {
           page_->getCoordinates(   pageX_,   pageZ_  );
           pageData_ = dataMgr_->getData2D(   pageX_,   pageZ_,   false  );
           }
           }
           //-----------------------------------------------------------------------
           // Sets the page using the page coordinates.
     303   void SetPage(   int pageX,   int pageZ  )
           {
           const PagingLandScapePage* page = pageMgr_->getPage(   pageX,   pageZ,   false  );
           if(   !page || !page->isLoaded(   )  )
           {
           assert(   false  );
           return; // TODO: Currently the AABB must be on the currently loaded landscape.
           }
           SetPage(   page  );
           }
           //-----------------------------------------------------------------------
           // Update using page local tile coordinates.
     315   void UpdateTile(   int tileX,   int tileZ  )
           {
           PagingLandScapeTile* tile = page_->getTile(   tileX,   tileZ  );
           if(   tile != tile_  )
           {
           tile_ = tile;
           bool tileLoaded = tile_ && tile_->isLoaded(   ) && tile_->getRenderable(   );
           renderLevel_.SetRenderLevel(   (  tileLoaded ) ? tile_->getRenderable(   )->getRenderLevel(   ) : 0  );
           }
           }
           //-----------------------------------------------------------------------
           // Update our lodStep and lodMask for the current tile,   given the page
           // local coordinates of a vertex.
     328   void UpdateWithLocalPage(   int localPageX,   int localPageZ  )
           {
           int tileX = PageToTile(   localPageX,   invTileSize_,   maxNumTiles_  );
           int tileZ = PageToTile(   localPageZ,   invTileSize_,   maxNumTiles_  );
          
           UpdateTile(   tileX,   tileZ  );
           }
           };
          
           //-----------------------------------------------------------------------
           // Loop over every edge tile. Determine which the lowest lod on each edge
           // and use that to adjust the extents.
           // TODO: This routine is expensive,   and is only needed when LOD is involved.
           // Optimize? Ironic since LOD is supposed to make things faster.
     342   void AdjustEdgesForLod(   LodTracker& lodTracker,  
           int minPageX,   int minPageZ,   int maxPageX,   int maxPageZ,  
           int& localPageMinX,   int& localPageMinZ,   int& localPageMaxX,   int& localPageMaxZ  )
           {
           int minTileZ = PageToTile(   localPageMinZ,  
           lodTracker.GetInvTileSize(   ),  
           lodTracker.GetMaxNumTiles(   )  );
           int maxTileZ = PageToTile(   localPageMaxZ,  
           lodTracker.GetInvTileSize(   ),  
           lodTracker.GetMaxNumTiles(   )  );
           int minTileX = PageToTile(   localPageMinX,  
           lodTracker.GetInvTileSize(   ),  
           lodTracker.GetMaxNumTiles(   )  );
           int maxTileX = PageToTile(   localPageMaxX,  
           lodTracker.GetInvTileSize(   ),  
           lodTracker.GetMaxNumTiles(   )  );
           int westRenderLevel = 0;
           int eastRenderLevel = 0;
           for(   int pageZ = minPageZ; pageZ <= maxPageZ; ++pageZ  )
           {
           int endTileZ = (   pageZ == maxPageZ  ) ? maxTileZ : lodTracker.GetMaxNumTiles(   ) - 1;
           for(   int tileZ = (   pageZ == minPageZ  ) ? minTileZ : 0;
           tileZ <= endTileZ;
           ++tileZ  )
           {
           // West edge
           lodTracker.SetPage(   minPageX,   pageZ  );
           lodTracker.UpdateTile(   minTileX,   tileZ  );
           int renderLevel = lodTracker.GetRenderLevel(   ).GetRenderLevel(   );
           if(   renderLevel > westRenderLevel  )
           westRenderLevel = renderLevel;
           // East edge
           lodTracker.SetPage(   maxPageX,   pageZ  );
           lodTracker.UpdateTile(   maxTileX,   tileZ  );
           renderLevel = lodTracker.GetRenderLevel(   ).GetRenderLevel(   );
           if(   renderLevel > eastRenderLevel  )
           eastRenderLevel = renderLevel;
           }
           }
          
           int northRenderLevel = 0;
           int southRenderLevel = 0;
           for(   int pageX = minPageX; pageX <= maxPageX; ++pageX  )
           {
           int endTileX = (   pageX == maxPageX  ) ? maxTileX : lodTracker.GetMaxNumTiles(   ) - 1;
           for(   int tileX = (   pageX == minPageX  ) ? minTileX : 0;
           tileX <= endTileX;
           ++tileX  )
           {
           // North edge
           lodTracker.SetPage(   pageX,   minPageZ  );
           lodTracker.UpdateTile(   tileX,   minTileZ  );
           int renderLevel = lodTracker.GetRenderLevel(   ).GetRenderLevel(   );
           if(   renderLevel > northRenderLevel  )
           northRenderLevel = renderLevel;
           // South edge
           lodTracker.SetPage(   pageX,   maxPageZ  );
           lodTracker.UpdateTile(   tileX,   maxTileZ  );
           renderLevel = lodTracker.GetRenderLevel(   ).GetRenderLevel(   );
           if(   renderLevel > southRenderLevel  )
           southRenderLevel = renderLevel;
           }
           }
           // Use the lods we found to adjust the min and max local coords.
           RenderLevel renderLevel(   westRenderLevel  );
           localPageMinX = renderLevel.Floor(   localPageMinX  );
           renderLevel.SetRenderLevel(   eastRenderLevel  );
           localPageMaxX = renderLevel.Ceil(   localPageMaxX  );
           renderLevel.SetRenderLevel(   northRenderLevel  );
           localPageMinZ = renderLevel.Floor(   localPageMinZ  );
           renderLevel.SetRenderLevel(   southRenderLevel  );
           localPageMaxZ = renderLevel.Ceil(   localPageMaxZ  );
           }
          
           //-----------------------------------------------------------------------
     417   void DoTileSubSection(   LodTracker& lodTracker,  
           SceneQuery::WorldFragment& worldFragment,  
           PagingLandScapeAxisAlignedBoxSceneQuery::CustomQueryResult& queryResult,  
           SceneQueryListener* listener,  
           int localPageMinX,   int localPageMinZ,   int localPageMaxX,   int localPageMaxZ,  
           uint subX,   uint subZ  )
           {
           lodTracker.UpdateWithLocalPage(   localPageMinX,   localPageMinZ  );
          
           // Send the width and height of this sub-section.
           queryResult.SetSubsectionExtents(   localPageMaxX - localPageMinX + 1,  
           localPageMaxZ - localPageMinZ + 1,  
           lodTracker.GetRenderLevel(   ).GetRenderLevel(   ),  
           subX,   subZ  );
           listener->queryResult(   &worldFragment  );
          
           for(   int z = localPageMinZ; z <= localPageMaxZ; ++z  )
           {
           for(   int x = localPageMinX; x <= localPageMaxX; ++x  )
           {
           Vector3 vertex;
           bool included = lodTracker.GetWorldVertex(   x,   z,   vertex  );
           queryResult.SetVertex(   vertex,   included  );
           listener->queryResult(   &worldFragment  );
           }
           }
           }
          }
          
          namespace Ogre
          {
          
          //---------------------------------------------------------------------
          PagingLandScapeAxisAlignedBoxSceneQuery::PagingLandScapeAxisAlignedBoxSceneQuery(  SceneManager* creator )
           : DefaultAxisAlignedBoxSceneQuery(  creator )
          {
          }
          
          //---------------------------------------------------------------------
          PagingLandScapeAxisAlignedBoxSceneQuery::~PagingLandScapeAxisAlignedBoxSceneQuery(  void )
          {
          }
          
          //---------------------------------------------------------------------
          // Well return via callbacks a set of rectangular tile sub-sections.
          // All fragments returned via callback use a WFT_CUSTOM_GEOMETRY type.
          // The CustomQueryResult structure defined above is what is passed
          // in the void* geometry field. The type_ field of the CustomQuery
          // result determins what is being sent in the fragment as follows:
          //
          // QUERY_EXTENTS_TYPE: Sent as the first result,   this gives the width
          // and height (  in tile subsections ) of the entire query result. The
          // render level in this case is not defined.
          //
          // SUBSECTION_EXTENTS_TYPE: Sent before each sub-section's vertex
          // data. This contains the height,   width,   and render level of the
          // subsequent vertex data.
          //
          // VERTEX_TYPE: This is the actual vertex data,   and whether the vertex
          // is included when displayed at the tile's current render level.
          //
          // The seemingly complex way of returning the data is so that the same
          // stitching algorithm used by PLSM can be used by the client in
          // creating a mesh out of the data.
          //---------------------------------------------------------------------
          void PagingLandScapeAxisAlignedBoxSceneQuery::execute(  SceneQueryListener* listener )
          {
           if(   !(   getQueryTypeMask(   ) & SceneManager::WORLD_GEOMETRY_TYPE_MASK  )  )
           {
           OGRE_EXCEPT(   Exception::ERR_INVALIDPARAMS,  
           "PagingLandScapeSceneManager only supports WORLD_GEOMETRY_TYPE_MASK for AxisAlignedBoxSceneQueries",  
           "PagingLandScapeAxisAlignedBoxSceneQuery::execute" );
           }
           PagingLandScapeSceneManager* mgr = static_cast< PagingLandScapeSceneManager* >(  mParentSceneMgr );
          
           // Currently we ignore the y coords of the bounding box and assume they
           // want all the vertices in the xz square.
          
           // Determine page that each corner of AABB is on.
           Vector3 min = mAABB.getMinimum(   );
           Vector3 max = mAABB.getMaximum(   );
          
           // Pre-gather some constants.
           const PagingLandScapeOptions* options = mgr->getOptions(   );
           const Vector3& scale = options->scale;
           const Real maxUnScaledX = options->maxUnScaledX;
           const Real maxUnScaledZ = options->maxUnScaledZ;
           const uint pageSize = options->PageSize - 1;
           const Real invPageSize = 1.0f / pageSize;
           const uint tileSize = options->TileSize - 1;
           const Real invTileSize = 1.0f / tileSize;
           const uint maxNumTiles = options->NumTiles;
           const uint worldWidth = options->world_width;
           const uint worldHeight = options->world_height;
           // Note that for efficiency here,   I'm not allocating a new WorldFragment
           // every time,   so clients will have to use the subscribtion mechanism to
           // get the results,   as the execute(   ) that returns the SceneQueryResult
           // will contain a collection of only the last result. TODO: The ogre
           // RegionSceneQuery could be modified to only do heap allocation when
           // the subscription mechanism isn't being used by the client.
           WorldFragment worldFragment;
           worldFragment.fragmentType = SceneQuery::WFT_CUSTOM_GEOMETRY;
           CustomQueryResult result;
           worldFragment.geometry = &result;
          
           // Calculate page min/max.
           uint minPageX;
           Real localPageMinXReal;
           bool minXInWorld;
           uint minPageZ;
           Real localPageMinZReal;
           bool minZInWorld;
           uint maxPageX;
           Real localPageMaxXReal;
           bool maxXInWorld;
           uint maxPageZ;
           Real localPageMaxZReal;
           bool maxZInWorld;
          
           minXInWorld = WorldToPage(   min.x,   scale.x,   maxUnScaledX,   pageSize,   invPageSize,   worldWidth,   minPageX,   localPageMinXReal  );
           minZInWorld = WorldToPage(   min.z,   scale.z,   maxUnScaledZ,   pageSize,   invPageSize,   worldHeight,   minPageZ,   localPageMinZReal  );
           maxXInWorld = WorldToPage(   max.x,   scale.x,   maxUnScaledX,   pageSize,   invPageSize,   worldWidth,   maxPageX,   localPageMaxXReal  );
           maxZInWorld = WorldToPage(   max.z,   scale.z,   maxUnScaledZ,   pageSize,   invPageSize,   worldHeight,   maxPageZ,   localPageMaxZReal  );
          
           // At least one corner of the bounding box must be inside the world,   or
           // we return no results.
           if(   !(   minXInWorld && minZInWorld  ) || !(   maxXInWorld && maxZInWorld  ) ||
           !(   minXInWorld && maxZInWorld  ) || !(   maxXInWorld && minZInWorld  )  )
           return;
          
           // Determine the width and height of the query in terms of tile sub-sections.
           // We need to make sure we return enough vertices so the entire bounding box
           // fits within. That means for lodded tiles we may need to move to the
           // next valid vertex,   however,   satisfying this requirement should never change
           // the query extents because every tile has valid vertices at its edges.
           int localPageMinX = static_cast<int>(   localPageMinXReal  );
           int localPageMinZ = static_cast<int>(   localPageMinZReal  );
           int localPageMaxX = static_cast<int>(   Math::Ceil(   localPageMaxXReal  )  );
           int localPageMaxZ = static_cast<int>(   Math::Ceil(   localPageMaxZReal  )  );
          
           LodTracker lodTracker(   scale,  
           maxUnScaledX,  
           maxUnScaledZ,  
           pageSize,  
           tileSize,  
           maxNumTiles,  
           mgr->getPageManager(   ),  
           mgr->getData2DManager(   )  );
          
           // TODO: Expensive routine. Can we do away with it or optimze it somehow?
           AdjustEdgesForLod(   lodTracker,  
           minPageX,   minPageZ,   maxPageX,   maxPageZ,  
           localPageMinX,   localPageMinZ,   localPageMaxX,   localPageMaxZ  );
          
           // Pre-calculate the width and height of the whole query in terms of how many
           // tile sub-sections we'll have.
           int middleTiles = (   static_cast<int>(   maxPageX  ) - static_cast<int>(   minPageX  ) - 1  ) *
           (   pageSize / tileSize  ); // Get the contribution from the middle pages.
           int leftTiles = (   maxNumTiles - PageToTile(   localPageMinX,  
           invTileSize,  
           maxNumTiles  )  ); // Get contribution from the left side.
           int rightTiles = PageToTile(   localPageMaxX - 1,  
           invTileSize,  
           maxNumTiles  ) + 1; // Get contribution from the right side.
           int calcWidth = leftTiles + middleTiles + rightTiles;
          
           middleTiles = (   static_cast<int>(   maxPageZ  ) - static_cast<int>(   minPageZ  ) - 1  ) *
           (   pageSize / tileSize  ); // Get the contribution from the middle pages.
           leftTiles = (   maxNumTiles - PageToTile(   localPageMinZ,  
           invTileSize,  
           maxNumTiles  )  ); // Get contribution from the left side.
           rightTiles = PageToTile(   localPageMaxZ - 1,  
           invTileSize,  
           maxNumTiles  ) + 1; // Get contribution from the right side.
           int calcHeight = leftTiles + middleTiles + rightTiles;
          
           //Real calcWidth = (   maxPageX == minPageX  ) ? localPageMaxX - localPageMinX + 1 :
           // (   pageSize - localPageMinX  ) + localPageMaxX + 1 +
           // (   maxPageX - minPageX - 1  ) * pageSize;
           //Real calcHeight = (   maxPageZ == minPageZ  ) ? localPageMaxZ - localPageMinZ + 1 :
           // (   pageSize - localPageMinZ  ) + localPageMaxZ + 1 +
           // (   maxPageZ - minPageZ - 1  ) * pageSize;
           // Notify our caller about the width and height,   using custom geometry type.
           result.SetQueryExtents(   calcWidth,   calcHeight  );
           listener->queryResult(   &worldFragment  );
          
           uint subZ = 0;
           for(   uint pageZ = minPageZ; pageZ <= maxPageZ; ++pageZ  )
           {
           // Determine Z tile range on this page.
           uint tileBeginZ = (   pageZ == minPageZ  ) ?
           PageToTile(   localPageMinZ,   invTileSize,   maxNumTiles  ) : 0;
           uint tileEndZ = (   pageZ == maxPageZ  ) ?
           PageToTile(   localPageMaxZ - 1,   invTileSize,   maxNumTiles  ) : maxNumTiles - 1;
           for(   uint tileZ = tileBeginZ; tileZ <= tileEndZ; ++tileZ,   ++subZ  )
           {
           uint subX = 0;
           for(   uint pageX = minPageX; pageX <= maxPageX; ++pageX  )
           {
           lodTracker.SetPage(   pageX,   pageZ  );
          
           // Determine X tile range on this page.
           uint tileBeginX = (   pageX == minPageX  ) ? PageToTile(   localPageMinX,   invTileSize,   maxNumTiles  ) : 0;
           uint tileEndX = (   pageX == maxPageX  ) ? PageToTile(   localPageMaxX - 1,   invTileSize,   maxNumTiles  ) : maxNumTiles - 1;
          
           for(   uint tileX = tileBeginX; tileX <= tileEndX; ++tileX,   ++subX  )
           {
           // Determine the Z local page coord range for this tile.
           uint localPageBeginZ = (   pageZ == minPageZ  ) && (   tileZ == tileBeginZ  ) ?
           localPageMinZ : tileZ * tileSize;
           uint localPageEndZ = (   pageZ == maxPageZ  ) && (   tileZ == tileEndZ  ) ?
           localPageMaxZ : (   tileZ + 1  ) * tileSize;
          
           // Determine the X local page coord range for this tile.
           uint localPageBeginX = (   pageX == minPageX  ) && (   tileX == tileBeginX  ) ?
           localPageMinX : tileX * tileSize;
           uint localPageEndX = (   pageX == maxPageX  ) && (   tileX == tileEndX  ) ?
           localPageMaxX : (   tileX + 1  ) * tileSize;
          
           DoTileSubSection(   lodTracker,   worldFragment,   result,   listener,  
           localPageBeginX,   localPageBeginZ,   localPageEndX,   localPageEndZ,  
           subX,   subZ  );
           }
           }
           }
           }
          }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeCamera.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright © 2000-2004 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          PagingLandScapeCamera.cpp - description
          -------------------
          begin : Fri Sep 27 2002
          copyright : (  C ) 2002 by Jon Anderson
          email : janders@users.sf.net
          
          Enhancements 2003 - 2004 (  C ) The OGRE Team
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          
          
          #include "OgreCamera.h"
          
          #include "OgrePagingLandScapeCamera.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeSceneManager.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      49   PagingLandScapeCamera::PagingLandScapeCamera(  const String& name,   SceneManager* sm ) :
           PagingLandScapeOctreeCamera(  name,   sm ),  
          
           mCurrentCameraPageX(  0 ),  
           mCurrentCameraPageZ(  0 ),  
           mCurrentCameraTileX(  0 ),  
           mCurrentCameraTileZ(  0 ),  
           mIniX(  0 ),  
           mFinX(  0 ),  
           mIniZ(  0 ),  
           mFinZ(  0 ),  
           mPreIniX(  0 ),  
           mPreFinX(  0 ),  
           mPreIniZ(  0 ),  
           mPreFinZ(  0 ),  
           mLastCameraPos (  Vector3(  std::numeric_limits<Real>::max (   ),  
           0.0f,  
           std::numeric_limits<Real>::max (   ) ) )
           {
           // initialized after the Camera::Camera(   ).
           mLastViewport = 0;
           }
           //-----------------------------------------------------------------------
      72   PagingLandScapeCamera::~PagingLandScapeCamera(   )
           {
          
           }
           //-----------------------------------------------------------------------
      77   void PagingLandScapeCamera::resetPaging(   )
           {
           mCurrentCameraPageX = 0;
           mCurrentCameraPageZ = 0;
           mCurrentCameraTileX = 0;
           mCurrentCameraTileZ = 0;
           mIniX = 0;
           mFinX = 0;
           mIniZ = 0;
           mFinZ = 0;
           mPreIniX = 0;
           mPreFinX = 0;
           mPreIniZ = 0;
           mPreFinZ = 0;
           mLastCameraPos = Vector3 (  std::numeric_limits<Real>::max (   ),  
           0.0f,  
           std::numeric_limits<Real>::max (   ) );
           updatePaging (  0,   0 );
          // Real dist = Camera::getDerivedPosition(   ).squaredLength(   )
          // + mParent->getOptions(   )->cameraThreshold
          // mLastCameraPos.x = dist;
          // mLastCameraPos.y = dist;
          // mLastCameraPos.z = dist;
           }
           //-----------------------------------------------------------------------
     102   void PagingLandScapeCamera::updatePaging (  const unsigned int x,   const unsigned int z )
           {
           // We must load the next visible LandScape pages,  
           // check the LandScape boundaries
          
           mCurrentCameraPageX = x;
           mCurrentCameraPageZ = z;
           const PagingLandScapeOptions * const opt =
           static_cast <PagingLandScapeSceneManager*> (  mSceneMgr )->getOptions (   );
           const unsigned int w = opt->world_width;
           const unsigned int h = opt->world_height;
           const unsigned int adjpages = opt->max_adjacent_pages;
           const unsigned int prepages = opt->max_preload_pages;
          
           // Load Windowing
           unsigned int lx = x;
           if (  static_cast<int> (  x - adjpages ) >= 0 )
           {
           mIniX = x - adjpages;
           }
           else
           {
           mIniX = 0;
           lx -= x - adjpages;
           }
           if (  lx + adjpages < w )
           {
           mFinX = lx + adjpages;
           }
           else
           {
           mFinX = w - 1;
           mIniX = (  static_cast <int> (  mIniX + (  w - (  lx + adjpages ) ) ) > 0 )? mIniX + (  w - (  lx + adjpages ) ):0;
           }
          
           unsigned int lz = z;
           if (  static_cast<int> (  z - adjpages ) >= 0 )
           {
           mIniZ = z - adjpages;
           }
           else
           {
           mIniZ = 0;
           lz -= z - adjpages;
           }
           if (  lz + adjpages < h )
           {
           mFinZ = lz + adjpages;
           }
           else
           {
           mFinZ = h - 1;
           mIniZ = (  static_cast <int> (  mIniZ + (  h - (  lz + adjpages ) ) ) > 0 )? mIniZ + (  h - (  lz + adjpages ) ):0;
           }
          
           // Pre-load Windowing
           lx = x;
           if (  static_cast<int> (  x - prepages ) > 0 )
           {
           mPreIniX = x - prepages;
           }
           else
           {
           mPreIniX = 0;
           lx -= x - prepages;
           }
           if (  x + prepages < w )
           {
           mPreFinX = x + prepages;
           }
           else
           {
           mPreFinX = w - 1;
           mPreIniX = (  static_cast <int> (  mPreIniX + (  w - (  lx + prepages ) ) ) > 0 )? mPreIniX + (  w - (  lx + prepages ) ):0;
           }
          
           lz = z;
           if (  static_cast<int> (  z - prepages ) > 0 )
           {
           mPreIniZ = z - prepages;
           }
           else
           {
           mPreIniZ = 0;
           lz -= z - prepages;
           }
           if (  lz + prepages < h )
           {
           mPreFinZ = lz + prepages;
           }
           else
           {
           mPreFinZ = h - 1;
           mPreIniZ = (  static_cast <int> (  mPreIniZ + (  h - (  lz + prepages ) ) ) > 0 )? mPreIniZ + (  h - (  lz + prepages ) ):0;
           }
           //(  static_cast <PagingLandScapeSceneManager*> (  getSceneManager(   ) )->resize(   ) );
           }
           //-----------------------------------------------------------------------
          
     201   bool PagingLandScapeCamera::isVisible(  const AxisAlignedBox &bound ) const
           {
          
           // Null boxes always invisible
           assert (  !bound.isNull(   ) );
           // Infinite boxes always visible
           assert (  !bound.isInfinite(   ) );
          
          
           // Get centre of the box
           const Vector3 &centre (  bound.getCenter(   ) );
           // Get the half-size of the box
           const Vector3 &halfSize =(  bound.getHalfSize(   ) );
          
           // For each plane,   see if all points are on the negative side
           // If so,   object is not visible
           const bool infinite_far_clip = (  mFarDist == 0 );
           for (  unsigned int plane = 0; plane < 6; ++plane )
           {
           // Skip far plane if infinite view frustum
           if (  plane == FRUSTUM_PLANE_FAR && infinite_far_clip )
           continue;
          
           const Plane::Side side = mFrustumPlanes[plane].getSide(  centre,   halfSize );
           if (  side == Plane::NEGATIVE_SIDE )
           {
           // ALL corners on negative side therefore out of view
           return false;
           }
          
           }
           return true;
           }
          
          }
          
          
          
          

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2D.cpp

       1  /***************************************************************************
          OgrePagingLandScapeData2D.cpp - description
          -------------------
          begin : Wen Mar 06 2003
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreSphere.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeOptions.h"
          
          
          #ifndef _MAPSPLITTER
          
          #include "OgreAxisAlignedBox.h"
          #include "OgreMovableObject.h"
          #include "OgreSimpleRenderable.h"
          
          
          #include "OgrePagingLandScapePageManager.h"
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapeRenderable.h"
          
          #endif// _MAPSPLITTER
          
          namespace Ogre
          {
      47   PagingLandScapeData2D::PagingLandScapeData2D(  PagingLandScapeData2DManager *pageMgr ):
           mParent(  pageMgr ),  
           mHeightData (  0 ),  
           mIsLoaded (  false ),  
           mIsModified (  false ),  
           mIsRectModified (  false ),  
           mRect (  0,   0,   0,   0,   0,   1 )
           {
           }
           //-----------------------------------------------------------------------
      57   PagingLandScapeData2D::~PagingLandScapeData2D(   )
           {
           unload (   );
           }
           //-----------------------------------------------------------------------
      62   void PagingLandScapeData2D::init(   )
           {
           //
           }
           //-----------------------------------------------------------------------
      67   void PagingLandScapeData2D::uninit(   )
           {
           PagingLandScapeData2D::unload (   );
           }
           //-----------------------------------------------------------------------
      72   bool PagingLandScapeData2D::load(  const unsigned int x,   const unsigned int z )
           {
           if (  !mIsLoaded )
           {
           mIsModified = false;
           mIsRectModified = false;
           mRect = Image::Box (  0,   0,   0,   0,   0,   1 );
          
           mPageX = x;
           mPageZ = z;
          
           mSize = mParent->getOptions(   )->PageSize;
          
           mShiftX = (  mPageX * (  mSize - 1 ) ) - mParent->getOptions(   )->maxUnScaledX;
           mShiftZ = (  mPageZ * (  mSize - 1 ) ) - mParent->getOptions(   )->maxUnScaledZ;
          
           const bool isLoadable = _load (  x,   z );
           mIsLoaded = true;
           return isLoadable;
           }
           return true;
           }
           //-----------------------------------------------------------------------
      95   void PagingLandScapeData2D::load(   )
           {
           if (  !mIsLoaded )
           {
           _load(   );
           mIsLoaded = true;
           }
           }
           //-----------------------------------------------------------------------
     104   void PagingLandScapeData2D::unload(   )
           {
           if (  mIsLoaded )
           {
           if (  mIsModified && mParent->getOptions(   )->saveDeformation )
           _save (   );
           delete[] mHeightData;
           mHeightData = 0;
           _unload(   );
           mIsLoaded = false;
           #ifndef _MAPSPLITTER
           resetDeformationRectangle (   );
           #endif
           }
           }
           //-----------------------------------------------------------------------
     120   void PagingLandScapeData2D::computePowerof2PlusOneSize(   )
           {
           mSize = mParent->getOptions(   )->PageSize;
           const size_t p2size = mSize - 1;
          
           size_t pagex = mXDimension / p2size;
           if (  mXDimension - (  pagex * p2size ) > 1 )
           pagex++;
           mXDimension = pagex * p2size + 1;
          
           size_t pagez = mZDimension / p2size;
           if (  mZDimension - (  pagez * p2size ) > 1 )
           pagez++;
           mZDimension = pagez * p2size + 1;
           }
           //-----------------------------------------------------------------------
     136   bool PagingLandScapeData2D::_checkSize(  const size_t s )
           {
           // ispow2 - 1
           const int p = static_cast <unsigned int> (  s - 1 );
           // ispow2
           return (  (  p & (  p - 1 ) ) == 0 );
           }
          
          #ifndef _MAPSPLITTER
           //-----------------------------------------------------------------------
     146   void PagingLandScapeData2D::resetDeformationRectangle (   )
           {
           mRect.left = 0;
           mRect.right = 0;
           mRect.top = 0;
           mRect.bottom = 0;
           mIsRectModified = false;
           }
           //-----------------------------------------------------------------------
     155   Image::Box PagingLandScapeData2D::getDeformationRectangle (   )
           {
           return mRect;
           }
           //-----------------------------------------------------------------------
     160   void PagingLandScapeData2D::adjustDeformationRectangle(  const unsigned int x,   const unsigned int z )
           {
           if (  mIsRectModified )
           {
           if (  mRect.left > x )
           mRect.left = x;
           if (  mRect.right < x )
           mRect.right = x;
          
           if (  mRect.top > z )
           mRect.top = z;
           if (  mRect.bottom < z )
           mRect.bottom = z;
           }
           else
           {
           // first modification :
           // deformation rectangle is the point
           mRect.left = x;
           mRect.right = x;
           mRect.top = z;
           mRect.bottom = z;
           mIsRectModified = true;
           mIsModified = true;
           }
           unsigned int tileposx = x;
           unsigned int tileposz = z;
           PagingLandScapeTile *t =
           mParent->getSceneManager(   )->getPageManager(   )->getTilePage(  tileposx,   tileposz,  
           mPageX,   mPageZ );
           if (  t && t->isLoaded (   ) )
           {
           // tells what tile portion needs to be updated.
           PagingLandScapeRenderable * const r = t->getRenderable (   );
           r->adjustDeformationRectangle (  tileposx,   tileposz );
           }
           }
           //-----------------------------------------------------------------------
     198   const bool PagingLandScapeData2D::deformHeight(  const Vector3 &deformationPoint,  
     199   Real &modificationHeight )
           {
           // adjust x and z to be local to page
           const int x = static_cast<int> (  deformationPoint.x - mShiftX );
           const int z = static_cast<int> (  deformationPoint.z - mShiftZ );
           // due to Real imprecision on Reals,   we have to use boundaries here
           // otherwise we'll hit asserts.
           const int size = static_cast<int> (  mSize-1 );
           const unsigned int ux = static_cast<unsigned int> (  std::max(  std::min (  x,   size ),   0 ) );
           const unsigned int uz = static_cast<unsigned int> (  std::max(  std::min (  z,   size ),   0 ) );
           return deformHeight(  ux,   uz,   modificationHeight );
           }
           //-----------------------------------------------------------------------
     212   const bool PagingLandScapeData2D::deformHeight(  const unsigned int x,  
           const unsigned int z,  
     214   Real &modificationHeight )
           {
           const unsigned int arraypos = static_cast <unsigned int> (  z * mSize + x );
           assert (  mHeightData && arraypos < mMaxArrayPos );
          
           const Real maxH = mParent->getMaxHeight(   );
           const Real newH = mHeightData[arraypos] - modificationHeight;
          
           bool did_modif = false;
           if (  newH <= 0.0f )
           {
           if (  mHeightData[arraypos] != 0.0f )
           did_modif = setHeight(  x,   z,   arraypos,   0.0f );
           modificationHeight = 0.0f;
           }
           else if (  newH >= maxH )
           {
           if (  mHeightData[arraypos] != maxH )
           did_modif = setHeight(  x,   z,   arraypos,   maxH );
           modificationHeight = maxH;
           }
           else
           {
           did_modif = setHeight(  x,   z,   arraypos,   newH );
           modificationHeight = newH;
           }
           return did_modif;
          
           }
           //-----------------------------------------------------------------------
     244   bool PagingLandScapeData2D::setHeight(  const unsigned int x,   const unsigned int z,  
     245   const unsigned int Pos,   const Real h )
           {
           if (  mHeightData[Pos] != h )
           {
           mHeightData[ Pos ] = h;
          
           unsigned int tileposx = x;
           unsigned int tileposz = z;
           // Make position local to tiles.
           // and return a Tile.
           PagingLandScapeTile *t =
           mParent->getSceneManager(   )->getPageManager(   )->getTilePage (  tileposx,   tileposz,  
           mPageX,   mPageZ );
           if (  t && t->isLoaded (   ) )
           {
           // tells what tile portion needs to be updated.
           PagingLandScapeRenderable * const r = t->getRenderable (   );
           r->adjustDeformationRectangle (  tileposx,   tileposz );
          
           const unsigned int tSize = mParent->getOptions(   )->TileSize - 1;
           const unsigned int NumTiles = mParent->getOptions(   )->NumTiles;
          
           const PagingLandScapeTileInfo * const info = t->getInfo(   );
           const unsigned int tX = info->mTileX;
           const unsigned int tZ = info->mTileZ;
          
           // If we're on a page edge,   we must duplicate the change on the
           // neighbour tile (  if it has one... )
           // could be a direct neighbour or a diagonal one (  in a corner. )
           const bool left = (  tileposx == 0 && tX != 0 );
           const bool right = (  tileposx == tSize && tX != NumTiles - 1 );
           const bool down = (  tileposz == 0 && tZ != 0 );
           const bool up = (  tileposz == tSize && tZ != NumTiles - 1 );
          
          
           if (  left )
           {
           PagingLandScapeRenderable * const rn = r->_getNeighbor(  WEST );
           if (  rn )
           {
           if (  down )
           {
           PagingLandScapeRenderable * const rnUp = rn->_getNeighbor(  NORTH );
           if (  rnUp && rnUp->isLoaded (   ) )
           {
           rnUp->adjustDeformationRectangle (  tSize,   tSize );
           }
           }
           else if (  up )
           {
           PagingLandScapeRenderable * const rnDown = rn->_getNeighbor(  SOUTH );
           if (  rnDown && rnDown->isLoaded (   ) )
           {
           rnDown->adjustDeformationRectangle (  tSize,   0 );
           }
           }
           if (  rn->isLoaded (   ) )
           {
           rn->adjustDeformationRectangle (  tSize,   tileposz );
           }
           }
           }
           else if (  right )
           {
           PagingLandScapeRenderable * const rn = r->_getNeighbor(  EAST );
           if (  rn )
           {
           if (  down )
           {
           PagingLandScapeRenderable * const rnUp = rn->_getNeighbor(  NORTH );
           if (  rnUp && rnUp->isLoaded (   ) )
           {
           rnUp->adjustDeformationRectangle (  0,   tSize );
           }
           }
           else if (  up )
           {
           PagingLandScapeRenderable * const rnDown = rn->_getNeighbor(  SOUTH );
           if (  rnDown && rnDown->isLoaded (   ) )
           {
           rnDown->adjustDeformationRectangle (  0,   0 );
           }
           }
           if (  rn )
           {
           rn->adjustDeformationRectangle (  0,   tileposz );
           }
           }
           }
           if (  down )
           {
           PagingLandScapeRenderable * const rn = r->_getNeighbor(  NORTH );
           if (  rn && rn->isLoaded (   ) )
           {
           rn->adjustDeformationRectangle (  tileposx,   tSize );
           }
           }
           else if (  up )
           {
           PagingLandScapeRenderable * const rn = r->_getNeighbor(  SOUTH );
           if (  rn && rn->isLoaded (   ) )
           {
           rn->adjustDeformationRectangle (  tileposx,   0 );
           }
           }
           }
          
           adjustDeformationRectangle (  x,   z );
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
     358   bool PagingLandScapeData2D::setHeight(  const unsigned int x,   const unsigned int z,  
     359   const Real h )
           {
           const unsigned int Pos = static_cast <unsigned int> (  (  z * mSize )+ x );
           assert (  mHeightData && mMaxArrayPos > Pos );
           return setHeight(  x,   z,   Pos,   h );
           }
          #endif //_MAPSPLITTER
           //-----------------------------------------------------------------------
     367   const Vector3 PagingLandScapeData2D::getNormal (  const Real mX,   const Real mZ )
           {
           // First General method : (  9 adds and 6 muls + a normalization )
           // *---v3--*
           // | | |
           // | | |
           // v1--X--v2
           // | | |
           // | | |
           // *---v4--*
           //
           // U = v2 - v1;
           // V = v4 - v3;
           // N = Cross(  U,   V );
           // N.normalise;
           //
           // BUT IN CASE OF A HEIGHTMAP :
           //
           // if you do some math by hand before you code,  
           // you can see that N is immediately given by
           // Approximation (  2 adds and a normalization )
           //
           // N = Vector3(  z[x-1][y] - z[x+1][y],   z[x][y-1] - z[x][y+1],   2 );
           // N.normalise(   );
           //
           // or even using SOBEL operator VERY accurate!
           // (  14 adds and a normalization )
           //
           // N = Vector3 (  z[x-1][y-1] + z[x-1][y] + z[x-1][y] + z[x-1][y+1] - z[x+1][y-1] - z[x+1][y] - z[x+1][y] - z[x+1][y+1],  
           // z[x-1][y-1] + z[x][y-1] + z[x][y-1] + z[x+1][y-1] - z[x-1][y+1] - z[x][y+1] - z[x][y+1] - z[x+1][y+1],  
           // 8 );
           // N.normalize(   );
          
          
           // Fast SOBEL filter
          
           const size_t pageSize = mSize - 1;
          
           // the divider make sure we do respect proportion (  height and width proportional to y )
           const Real Divider = static_cast <Real> (  pageSize ) / mParent->getOptions(   )->scale.y;
          
           assert (  mHeightData );
          
           #define getisIn(  a,   b ) (  mHeightData[static_cast<unsigned int> (  a ) + static_cast<unsigned int> (  b ) * mSize] )
          
           if (  mX > 0 && mZ > 0 &&
           mX < pageSize && mZ < pageSize )
           {
          
           // Vector3 result (  getisIn(  x-1,  z-1 ) + getisIn (  x-1,   z ) + getisIn (  x-1,   z ) + getisIn (  x-1,   z+1 ) - getisIn (  x+1,   z-1 ) - getisIn (  x+1,   z ) - getisIn (  x+1,   z ) - getisIn (  x+1,   z+1 ),  
           // 8.0f,  
           // getisIn (  x-1,   z-1 ) + getisIn (  x,   z-1 ) + getisIn (  x,   z-1 ) + getisIn (  x+1,   z-1 ) - getisIn (  x-1,   z+1 ) - getisIn (  x,   z+1 ) - getisIn (  x,   z+1 ) - getisIn (  x+1,   z+1 ) );
          
           Vector3 result(  (  getisIn (  mX - 1 ,   mZ ) - getisIn (  mX + 1 ,   mZ ) ) * Divider,  
           2.0f,  
           (  getisIn (  mX,   mZ - 1 ) - getisIn (  mX ,   mZ + 1 ) ) * Divider );
          
           result.normalise (   );
          
           return result;
           }
           else
           {
           unsigned int x = static_cast <unsigned int> (  mX );
           unsigned int z = static_cast <unsigned int> (  mZ );
           Real a,  b,  c,  d;
          
           if (  x == 0 )
           {
           a = getisIn (  x ,   z );
           b = getisIn (  x + 1,   z );
           }
           else if (  x == pageSize )
           {
           a = getisIn (  x - 1 ,   z );
           b = getisIn (  x ,   z );
           }
           else
           {
           a = getisIn (  x - 1 ,   z );
           b = getisIn (  x + 1,   z );
           }
          
           if (  z == 0 )
           {
           c = getisIn (  x ,   z );
           d = getisIn (  x ,   z + 1 );
           }
           else if (  z == pageSize )
           {
           c = getisIn (  x ,   z - 1 );
           d = getisIn (  x ,   z );
           }
           else
           {
           c = getisIn (  x ,   z - 1 );
           d = getisIn (  x ,   z + 1 );
           }
          
          
           Vector3 result(  (  a - b ) * Divider,  
           2.0f,  
           (  c - d ) * Divider );
           result.normalise (   );
           return result;
          
          #ifdef _NOWAY
          #ifndef _MAPSPLITTER
           #define getisOut(  a,   b ) (  PagingLandScapeData2DManager::getSingleton (   ).getHeightAtPage (  mPageX,   mPageZ,   static_cast<int> (  a ),   static_cast<int> (  b ) ) )
          
          // Vector3 result (  getisOut(  x-1,  z-1 ) + getisOut (  x-1,   z ) + getisOut (  x-1,   z ) + getisOut (  x-1,   z+1 ) - getisOut (  x+1,   z-1 ) - getisOut (  x+1,   z ) - getisOut (  x+1,   z ) - getisOut (  x+1,   z+1 ),  
          // 8.0f,  
          // getisOut (  x-1,   z-1 ) + getisOut (  x,   z-1 ) + getisOut (  x,   z-1 ) + getisOut (  x+1,   z-1 ) - getisOut (  x-1,   z+1 ) - getisOut (  x,   z+1 ) - getisOut (  x,   z+1 ) - getisOut (  x+1,   z+1 ) );
          
           Vector3 result(  (  getisOut (  mX - 1 ,   mZ ) - getisOut (  mX + 1 ,   mZ ) ) * Divider,  
           2.0f,  
           (  getisOut (  mX,   mZ - 1 ) - getisOut (  mX ,   mZ + 1 ) ) * Divider );
          
           result.normalise (   );
          
          
           return result;
          #endif //_MAPSPLITTER
          #endif //
          
           }
           }
          } //namespace
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2DManager.cpp

       1  /***************************************************************************
           OgrePagingLandScapeData2DManager.cpp - description
           -------------------
           begin : Mon Jun 16 2003
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreMath.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreMovableObject.h"
          #include "OgreAxisAlignedBox.h"
          
          #include "OgrePlane.h"
          
          #include "OgreCamera.h"
          
          #include "OgreSimpleRenderable.h"
          #include "OgreException.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          
          // Data loaders implementations
          // #include "OgrePagingLandScapeData2D_HeightField.h"
          // #include "OgrePagingLandScapeData2D_HeightFieldTC.h"
          //
          // #include "OgrePagingLandScapeData2D_HeightFieldN.h"
          // #include "OgrePagingLandScapeData2D_HeightFieldNTC.h"
          //
          // #include "OgrePagingLandScapeData2D_HeightFieldRaw.h"
          // #include "OgrePagingLandScapeData2D_HeightFieldRawTC.h"
          //
          // #include "OgrePagingLandScapeData2D_Spline.h"
          //
          // // load heights from texture.
          // #include "OgrePagingLandScapeData2D_HeightFieldBlendNeighbor.h"
          
          // needed to get RenderLevel for RealHeight
          #include "OgrePagingLandScapeRenderable.h"
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapeTileInfo.h"
          #include "OgrePagingLandScapePage.h"
          #include "OgrePagingLandScapePageManager.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      69   PagingLandScapeData2DManager::PagingLandScapeData2DManager(  PagingLandScapeSceneManager * scnMgr,  
      70   PagingLandScapeOptions * opt  ) :
           mScnMgr(  scnMgr ),  
           mOptions (  opt ),  
           mData2DType (  0 ),  
           mData2DFormat (  "" ),  
           mWidth (  0 ),  
           mHeight (  0 ),  
           mMaxHeight (  0 ),  
           mPageManager (  0 )
           {
          // // Add default texture Types.
          // registerDataType (  new PagingLandScapeData2D_HeightField (  this ) );
          // registerDataType (  new PagingLandScapeData2D_HeightFieldRaw(  this ) );
          // registerDataType (  new PagingLandScapeData2D_HeightFieldTC(  this ) );
          // #ifndef _MAPSPLITTER
          // registerDataType (  new PagingLandScapeData2D_HeightFieldN(  this ) );
          // registerDataType (  new PagingLandScapeData2D_HeightFieldRawTC(  this ) );
          // registerDataType (  new PagingLandScapeData2D_HeightFieldNTC(  this ) );
          // registerDataType (  new PagingLandScapeData2D_HeightFieldBlendNeighbor(  this ) );
          // #endif //_MAPSPLITTER
          // registerDataType (  new PagingLandScapeData2D_Spline(  this ) );
           }
           //-----------------------------------------------------------------------
      93   PagingLandScapeData2D *PagingLandScapeData2DManager::allocateData2D(   ) const
           {
           assert (  !mData2DTypeMap.empty(   ) && mData2DTypeMap[mData2DType] );
           return mData2DTypeMap[mData2DType]->newPage(   );
           }
           //-----------------------------------------------------------------------
      99   PagingLandScapeData2DManager::~PagingLandScapeData2DManager(   )
           {
           reset(   );
           // for all in map delete.
           PagingLandScapeData2DMap::iterator i = mData2DTypeMap.begin(   );
           while (  i != mData2DTypeMap.end(   ) )
           {
           delete (  *i );
           ++i;
           }
           }
           //-----------------------------------------------------------------------
     111   void PagingLandScapeData2DManager::reset(   )
           {
           if (  !mActiveData2Ds.empty(   ) )
           {
           std::for_each(  mActiveData2Ds.begin(   ),   mActiveData2Ds.end(   ),  
           std::mem_fun(  &PagingLandScapeData2D::unload ) );
          
           // Insert actives into free list
           mFreeData2Ds.insert(  mFreeData2Ds.end(   ),   mActiveData2Ds.begin(   ),   mActiveData2Ds.end(   ) );
           // Remove all active instances
           mActiveData2Ds.clear(   );
           }
          
           // could save a delete if data type is the same... ?
           if (  !mData2DPool.empty(   ) )
           {
           std::for_each(  mData2DPool.begin(   ),   mData2DPool.end(   ),   delete_object(   ) );
           mData2DPool.clear(   );
           mFreeData2Ds.clear(   );
           }
          
           mWidth = 0;
           mHeight = 0;
           }
           //-----------------------------------------------------------------------
     136   void PagingLandScapeData2DManager::load (   )
           {
           if (  mOptions->data2DFormat != mData2DFormat )
           {
           reset (   );
           mData2DFormat = mOptions->data2DFormat;
           unsigned int i = 0;
           for (  ; i != mData2DTypeMap.size(   ); ++i )
           {
           if (  StringUtil::endsWith (  mData2DTypeMap[i]->getName (   ),   mData2DFormat,   false ) )
           {
           mData2DType = i;
           break;
           }
           }
           if (  i == mData2DTypeMap.size(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           "PageData2D not supplied or wrong (  check case ) !",  
           " PagingLandScapeData2DManager::load" );
           }
           }
           WorldDimensionChange(   );
           mMaxHeight = mData2DTypeMap[mData2DType]->getMaxAbsoluteHeight (   );
           }
           //-----------------------------------------------------------------------
     162   bool PagingLandScapeData2DManager::reload(  const unsigned int dataX,   const unsigned int dataZ )
           {
          #ifndef _MAPSPLITTER
           PagingLandScapeData2D* data = getData2D (  dataX,   dataZ );
          
           data->unload(   );
           const bool ret = data->load(  dataX,   dataZ );
           const unsigned int tsize = mOptions->TileSize;
           const unsigned int psize = mOptions->PageSize;
           for (  unsigned int z = 0; z <= psize ; z += tsize )
           {
           for (  unsigned int x = 0; x <= psize ; x += tsize )
           {
           data->adjustDeformationRectangle (  x,   z );
           }
           }
           return ret;
          #else //_MAPSPLITTER
           return true;
          #endif //_MAPSPLITTER
           }
           //-----------------------------------------------------------------------
     184   PagingLandScapeData2D *PagingLandScapeData2DManager::getNewData2D(  const unsigned int x,   const unsigned int z )
           {
           PagingLandScapeData2D *newData2D;
           if (  mFreeData2Ds.empty(   ) )
           {
           const size_t pool_size = mData2DPool.size (   );
           const size_t new_pool_size = (  pool_size == 0 ) ? 9 : pool_size * 2;
           mData2DPool.reserve(  new_pool_size );
           mData2DPool.resize(  new_pool_size );
          
           // Create new pages
           for (  size_t i = pool_size; i < new_pool_size; ++i )
           {
           newData2D = allocateData2D(   );
           mData2DPool[i] = newData2D;
           mFreeData2Ds.push_back (  newData2D );
           }
           }
          
           newData2D = mFreeData2Ds.front (   );
           mFreeData2Ds.pop_front (   );
           mActiveData2Ds.push_back (  newData2D );
          
           newData2D->load (  x,   z );
          
           return newData2D;
           }
           //-----------------------------------------------------------------------
     212   void PagingLandScapeData2DManager::releaseData2D(  PagingLandScapeData2D *p )
           {
           mActiveData2Ds.remove(  p );
           mFreeData2Ds.push_back(  p );
           }
           //-----------------------------------------------------------------------
     218   PagingLandScapeData2D *PagingLandScapeData2DManager::getData2D(  const unsigned int x,   const unsigned int z,  
     219   const bool alwaysReturn )
           {
           if (  x < mWidth && z < mHeight )
           {
           PagingLandScapeData2DList::iterator l,   lend = mActiveData2Ds.end(   );
           for (  l = mActiveData2Ds.begin(   ); l != lend; ++l )
           {
           if (  (  *l )->isCoord(  x,   z ) )
           return (  *l );
           }
           if (  alwaysReturn )
           return getNewData2D(  x,   z );
           }
           assert (  !alwaysReturn );
           return 0;
           }
           //-----------------------------------------------------------------------
     236   void PagingLandScapeData2DManager::clear (   )
           {
           }
           //-----------------------------------------------------------------------
     240   void PagingLandScapeData2DManager::WorldDimensionChange(   )
           {
           const unsigned int newWidth = mOptions->world_width;
           const unsigned int newHeight = mOptions->world_height;
          
           reset(   );
          
           mWidth = newWidth;
           mHeight = newHeight;
           }
           //-----------------------------------------------------------------------
     251   void PagingLandScapeData2DManager::setPageManager (  PagingLandScapeSceneManager *scnMgr )
           {
           mPageManager = scnMgr->getPageManager(   );
           }
           //-----------------------------------------------------------------------
     256   bool PagingLandScapeData2DManager::load(  const unsigned int dataX,   const unsigned int dataZ )
           {
           PagingLandScapeData2D* data = getData2D (   dataX ,   dataZ  );
           if (  !data->isLoaded (   ) )
           {
           return data->load (  dataX,   dataZ );
           }
           return true;
           }
           //-----------------------------------------------------------------------
     266   void PagingLandScapeData2DManager::unload(  const unsigned int dataX,   const unsigned int dataZ )
           {
           PagingLandScapeData2D* data = getData2D (   dataX ,   dataZ,   false  );
           if (  data && data->isLoaded (   ) )
           {
           data->unload (   );
           releaseData2D (  data );
           }
           }
          
           //-----------------------------------------------------------------------
     277   bool PagingLandScapeData2DManager::isLoaded(  const unsigned int dataX,   const unsigned int dataZ )
           {
           PagingLandScapeData2D * const data = getData2D (  dataX ,   dataZ,   false );
           return data && data->isLoaded(   );
           }
           //-----------------------------------------------------------------------
     283   const ColourValue PagingLandScapeData2DManager::getCoverageAt(  const unsigned int dataX,  
           const unsigned int dataZ,  
     285   const Real x,  
     286   const Real z )
           {
           PagingLandScapeData2D* data = getData2D (  dataX ,   dataZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           // TODO check it the terrain height is modified
           return data->getCoverage(  x,   z );
           }
           return ColourValue::White;
           }
           //-----------------------------------------------------------------------
     297   const ColourValue PagingLandScapeData2DManager::getBaseAt(  const unsigned int dataX,  
           const unsigned int dataZ,  
     299   const Real x,  
     300   const Real z )
           {
           PagingLandScapeData2D* data = getData2D (  dataX ,   dataZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           // TODO check it the terrain height is modified
           return data->getBase(  x,   z );
           }
           return ColourValue::White;
           }
           //-----------------------------------------------------------------------
     311   const Real PagingLandScapeData2DManager::getShadowAt(  const unsigned int dataX,  
           const unsigned int dataZ,  
           const unsigned int x,  
           const unsigned int z,  
     315   const bool &positive )
           {
           PagingLandScapeData2D* data = getData2D (  dataX ,   dataZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           // TODO check it the terrain height is modified
           return data->getShadow(  x,   z,   positive );
           }
           return 0.0f;
           }
           //-----------------------------------------------------------------------
     326   const Real PagingLandScapeData2DManager::getHeight(  const unsigned int dataX,  
           const unsigned int dataZ,  
     328   const Real x,  
     329   const Real z )
           {
          
           PagingLandScapeData2D* data = getData2D (  dataX ,   dataZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           // TODO check it the terrain height is modified
           return data->getHeight(  x,   z );
           }
           return 0.0f;
           }
           //-----------------------------------------------------------------------
     341   const Real PagingLandScapeData2DManager::getHeight(  const unsigned int dataX,  
           const unsigned int dataZ,  
           const unsigned int x,  
           const unsigned int z )
           {
          
           PagingLandScapeData2D* data = getData2D (  dataX ,   dataZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           return data->getHeight(  x,   z );
           }
           return 0.0f;
           }
          
           //-----------------------------------------------------------------------
          // bool PagingLandScapeData2DManager::addNewHeight(  const Sphere newSphere )
          // {
          // unsigned int x,   z;
          //
          // Vector3 s = newSphere.getCenter(   );
          // // Calculate where is going to be placed the new height
          // PagingLandScapePageManager::getSingleton (   ).getPageIndices(  s.x,   s.z,   x,   z,   true );
          // // TODO: DeScale and add the sphere to all the necessary pages
          //
          // //place it there
          // return mData2D[ x ][ z ]->addNewHeight(  newSphere );
          // }
          
           //-----------------------------------------------------------------------
          // bool PagingLandScapeData2DManager::removeNewHeight(  const Sphere oldSphere )
          // {
          // unsigned int x,   z;
          // Vector3 s = oldSphere.getCenter(   );
          // // Calculate where is going to be placed the new height
          // PagingLandScapePageManager::getSingleton (   ).getPageIndices(  s.x,   s.z,   x,   z,   true );
          // // TODO: DeScale and add the sphere to all the necessary pages
          //
          // //remove it
          // return mData2D[ x ][ z ]->removeNewHeight(  oldSphere );
          // }
           //-----------------------------------------------------------------------
     382   const Real PagingLandScapeData2DManager::getMaxHeight(  const unsigned int x,  
           const unsigned int z )
           {
           PagingLandScapeData2D* data = getData2D (  x,   z,   false );
           if (  data && data->isLoaded(   ) )
           {
           return data->getMaxHeight(   );
           }
           return mMaxHeight;
           }
           //-----------------------------------------------------------------------
     393   const Real PagingLandScapeData2DManager::getMaxHeight(   ) const
           {
           return mMaxHeight;
           }
           //-----------------------------------------------------------------------
     398   bool PagingLandScapeData2DManager::setHeight(  const Vector3 &deformationPoint,  
     399   const Real modificationHeight,  
     400   const PagingLandScapeTileInfo* info )
           {
          #ifndef _MAPSPLITTER
           const unsigned int pX = info->mPageX;
           const unsigned int pZ = info->mPageZ;
           const unsigned int pSize = mOptions->PageSize - 1;
           // adjust x and z to be local to page
           const unsigned int x = static_cast<unsigned int> (  deformationPoint.x
           - pX * pSize
           + mOptions->maxUnScaledX );
           const unsigned int z = static_cast<unsigned int> (  deformationPoint.z
           - pZ * pSize
           + mOptions->maxUnScaledZ );
          
           PagingLandScapeData2D* data = getData2D (  pX ,   pZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           Real heightResult = modificationHeight;
           if (  data->setHeight (  x,   z,   heightResult ) )
           {
           const unsigned int wL = mOptions->world_width;
           const unsigned int hL = mOptions->world_height;
          
           // If we're on a page edge,   we must duplicate the change on the
           // neighbour page (  if it has one... )
           const bool left = (  x == 0 && pX != 0 );
           const bool right = (  x == pSize && pX < wL - 1 );
           const bool down = (  z == 0 && pZ != 0 );
           const bool up = (  z == pSize && pZ < hL - 1 );
          
           assert (  z <= pSize && x <= pSize );
          
           if (  left )
           {
           if (  down )
           {
           // lower left corner
           data = getData2D (  pX - 1,   pZ - 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  pSize,   pSize,   heightResult );
           }
           }
           else if (  up )
           {
           // upper left corner
           data = getData2D (  pX - 1,   pZ + 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  pSize,   0,   heightResult );
           }
           }
          
           // left
           data = getData2D (  pX - 1,   pZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  pSize,   z,   heightResult );
           }
           }
           else if (  right )
           {
           if (  up )
           {
           // upper right corner
           data = getData2D (  pX + 1,   pZ + 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  0,   0,   heightResult );
           }
           }
           else if (  down )
           {
           // lower right corner
           data = getData2D (  pX + 1,   pZ - 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  0,   pSize,   heightResult );
           }
           }
           // right
           data = getData2D (  pX + 1,   pZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  0,   z,   heightResult );
           }
           }
           if (  down )
           {
           // lower (  down only )
           data = getData2D (  pX,   pZ - 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  x,   pSize,   heightResult );
           }
           }
           else if (  up )
           {
           // upper (  up only )
           data = getData2D (  pX,   pZ + 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  x,   0,   heightResult );
           }
           }
           return true;
           } // if (  data->deformHeight (  x,   z,   heightResult ) )
           } // if (  data->isLoaded(   ) )
          #endif
           return false;
           }
           //-----------------------------------------------------------------------
     512   bool PagingLandScapeData2DManager::deformHeight(  const Vector3 &deformationPoint,  
     513   const Real modificationHeight,  
     514   const PagingLandScapeTileInfo* info )
           {
          #ifndef _MAPSPLITTER
           const unsigned int pX = info->mPageX;
           const unsigned int pZ = info->mPageZ;
           const unsigned int pSize = mOptions->PageSize - 1;
           // adjust x and z to be local to page
           const unsigned int x = static_cast<unsigned int> (  deformationPoint.x
           - pX * pSize
           + mOptions->maxUnScaledX );
           const unsigned int z = static_cast<unsigned int> (  deformationPoint.z
           - pZ * pSize
           + mOptions->maxUnScaledZ );
          
           PagingLandScapeData2D* data = getData2D (  pX ,   pZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           Real heightResult = modificationHeight;
           if (  data->deformHeight (  x,   z,   heightResult ) )
           {
           const unsigned int wL = mOptions->world_width;
           const unsigned int hL = mOptions->world_height;
          
           // If we're on a page edge,   we must duplicate the change on the
           // neighbour page (  if it has one... )
           const bool left = (  x == 0 && pX != 0 );
           const bool right = (  x == pSize && pX < wL - 1 );
           const bool down = (  z == 0 && pZ != 0 );
           const bool up = (  z == pSize && pZ < hL - 1 );
          
           assert (  z <= pSize && x <= pSize );
          
           if (  left )
           {
           if (  down )
           {
           // lower left corner
           data = getData2D (  pX - 1,   pZ - 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  pSize,   pSize,   heightResult );
           }
           }
           else if (  up )
           {
           // upper left corner
           data = getData2D (  pX - 1,   pZ + 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  pSize,   0,   heightResult );
           }
           }
          
           // left
           data = getData2D (  pX - 1,   pZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  pSize,   z,   heightResult );
           }
           }
           else if (  right )
           {
           if (  up )
           {
           // upper right corner
           data = getData2D (  pX + 1,   pZ + 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  0,   0,   heightResult );
           }
           }
           else if (  down )
           {
           // lower right corner
           data = getData2D (  pX + 1,   pZ - 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  0,   pSize,   heightResult );
           }
           }
           // right
           data = getData2D (  pX + 1,   pZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  0,   z,   heightResult );
           }
           }
           if (  down )
           {
           // lower (  down only )
           data = getData2D (  pX,   pZ - 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  x,   pSize,   heightResult );
           }
           }
           else if (  up )
           {
           // upper (  up only )
           data = getData2D (  pX,   pZ + 1 ,   false );
           if (  data && data->isLoaded(   ) )
           {
           data->setHeight (  x,   0,   heightResult );
           }
           }
           return true;
           } // if (  data->deformHeight (  x,   z,   heightResult ) )
           } // if (  data->isLoaded(   ) )
           return false;
          #else //_MAPSPLITTER
           return true;
          #endif //_MAPSPLITTER
           }
          
           //-----------------------------------------------------------------------
     629   const Real PagingLandScapeData2DManager::getInterpolatedWorldHeight (  const Real x,   const Real z,   Real *getSlopeAt )
           {
          
          #ifndef _MAPSPLITTER
           Real heightValue;
          
           //#define _DEBUGPOS
           //#define _DEBUGPOSHEIGHTSTICH
          
           // scale position from world to page scale
           const Real unscaledX = (  x * mOptions->invScale.x ) + mOptions->maxUnScaledX;
           const Real unscaledZ = (  z * mOptions->invScale.z ) + mOptions->maxUnScaledZ;
          
           const Real pSize = mOptions->PageSize - 1;
           const Real inv_pSize = 1.0f / pSize;
          
           //get Page
           int value = static_cast< int > (  unscaledX * inv_pSize );
           const int maxPageX = static_cast< int > (  mOptions->world_width );
           const int pageNumberX = (  value < 0  ) ? 0 : (  value >= maxPageX ? maxPageX - 1: value );
           const int maxPageZ = static_cast< int > (  mOptions->world_height );
           value = static_cast< int > (  unscaledZ * inv_pSize );
           const int pageNumberZ = (  value < 0  ) ? 0 : (  value >= maxPageZ ? maxPageZ - 1: value );
          
          
           const PagingLandScapePage * const page = mScnMgr->getPageManager(   )->getPage (  pageNumberX,   pageNumberZ,   false );
           if (  ! (  page && page->isPreLoaded(   ) ) )
           return 0.0f;
          
           // adjust x and z to be local to page
           const Real localPageX = unscaledX - (  pageNumberX*pSize );
           const Real localPageZ = unscaledZ - (  pageNumberZ*pSize );
          
          
           const unsigned int tSize = mOptions->TileSize - 1;
           const Real inv_tSize = 1.0f / tSize;
          
           //get Tile
           value = static_cast< int > (  localPageX * inv_tSize );
           const int maxNumTiles = static_cast< int > (  mOptions->NumTiles );
           const int tileNumberX = (  value < 0  ) ? 0 : (  value >= maxNumTiles? maxNumTiles - 1: value );
           value = static_cast< int > (  localPageZ * inv_tSize );
           const int tileNumberZ = (  value < 0  ) ? 0 : (  value >= maxNumTiles? maxNumTiles - 1: value );
          
           // adjust x and z to be local to tile
           const int localTileX = Math::ICeil (  localPageX - tileNumberX * tSize );
           const int localTileZ = Math::ICeil (  localPageZ - tileNumberZ * tSize );
          
          
           #ifdef _DEBUGPOSHEIGHT
           {
           RenderTarget *t = mOptions->primaryCamera->getViewport(   )->getTarget (   );
           const String debugPos (  " px: " + StringConverter::toString(  pageNumberX ) +
           " pz: " + StringConverter::toString(  pageNumberZ ) +
           " lpx: " + StringConverter::toString(  localPageX ) +
           " lpz: " + StringConverter::toString(  localPageZ ) +
          
           " tx: " + StringConverter::toString(  tileNumberX ) +
           " tz: " + StringConverter::toString(  tileNumberZ ) +
           " ltx: " + StringConverter::toString(  localTileX ) +
           " ltz: " + StringConverter::toString(  localTileZ )
          
            );
           t->setDebugText(  debugPos );
           }
           #endif // _DEBUG
          
          
           PagingLandScapeTile * const tile = page->getTile (  tileNumberX,   tileNumberZ );
           bool tileLoaded = tile && tile->isLoaded(   ) && tile->getRenderable(   );
           const int currentRenderLevel = (  tileLoaded ) ?
           tile->getRenderable(   )->getRenderLevel(   )
           :
           0;
          
          
          
          
           #ifdef _DEBUGPOSHEIGHTSTICH
           String debugStich (   "(  " + StringConverter::toString(  pageNumberX ) +
           ",   " + StringConverter::toString(  pageNumberZ ) +
           " )(  " + StringConverter::toString(  tileNumberX ) +
           ",   " + StringConverter::toString(  tileNumberZ ) +
          
           " )(  " + StringConverter::toString(  localPageX ) +
           ",   " + StringConverter::toString(  localPageZ ) +
          
           " )(  " + StringConverter::toString(  localTileX ) +
           ",   " + StringConverter::toString(  localTileZ ) +
          
           " ) rdl:" + StringConverter::toString(  currentRenderLevel )
          
            );
           #endif // _DEBUGPOSHEIGHTSTICH
          
          
           // find the 4 vertices that surround the point
           // use LOD info to determine vertex data spacing - this is passed into the method
           // determine vertices on left and right of point and top and bottom
           // don't access VBO since a big performance hit when only 4 vertices are needed
          
           // Step from one vertex to another in the level detail algorithm
           const int currentLodStep = 1 << currentRenderLevel;
           //const int currentLodStep = 1;
           const Real inv_currentLodStep = 1.0f / currentLodStep;
          
           // check if can be on a stitched part of tile
           const int tileSizeMinuscurrentLodStep = tSize + 1 - currentLodStep;
           if (  tileLoaded &&
           (  localTileX <= currentLodStep ||
           localTileX >= tileSizeMinuscurrentLodStep ||
           localTileZ <= currentLodStep ||
           localTileZ >= tileSizeMinuscurrentLodStep ) )
           {
          
           // get stitching configuration
           PagingLandScapeRenderable * const r = tile->getRenderable(   );
           PagingLandScapeRenderable * neighbour;
          
           // get each tile LOD and if stitching occurs in this direction.
           neighbour = r->_getNeighbor(  NORTH );
           const bool north = (  neighbour && neighbour->isLoaded(   )
           && neighbour->getRenderLevel(   ) > currentRenderLevel
           && localTileZ <= currentLodStep );//z-1
          
           neighbour = r->_getNeighbor(  SOUTH );
           const bool south = (  neighbour && neighbour->isLoaded(   )
           && neighbour->getRenderLevel(   ) > currentRenderLevel
           && localTileZ >= tileSizeMinuscurrentLodStep );//z+1
           assert (  north != south || (  south == false && north == false ) );
          
           neighbour = r->_getNeighbor(  EAST );
           const bool east = (  neighbour && neighbour->isLoaded(   )
           && neighbour->getRenderLevel(   ) > currentRenderLevel
           && localTileX >= tileSizeMinuscurrentLodStep );//x+1
          
           neighbour = r->_getNeighbor(  WEST );
           const bool west = (  neighbour && neighbour->isLoaded(   )
           && neighbour->getRenderLevel(   ) > currentRenderLevel
           && localTileX <= currentLodStep );//x-1
           assert (  east != west || (  east == false && west == false ) );
          
           if (  north || south || east || west )
           {
          
           // Interpolate at LOD that uses stitching between tiles if needed.
           //
           // lower LOD
           // *-----------*
           // |\ \ 3 / /|
           // |1\2 \ / 4/5|
           // *--*--*--*--*
           // higher LOD
           //
           // we iterate over triangle to find which contains the points.
           // then we launch a ray to triangle intersection query.
           //
           // any simpler suggestion welcome. (  gladly,   this is hell long full of repetition code. )
           //
          
           const Vector2 pos (  localPageX,   localPageZ );
           int bottom_right_x,   bottom_right_z;
           Vector2 a2d,   b2d ,  c2d;
          
           if (  north )
           {
           bool not_found = true;
           if (  east )//northeast
           {
           #ifdef _DEBUGPOSHEIGHTSTICH
           debugStich += " north: " + StringConverter::toString(  r->_getNeighbor(  NORTH )->getRenderLevel(   ) ) +
           " east: " + StringConverter::toString(  r->_getNeighbor(  EAST )->getRenderLevel(   ) );
           #endif //_DEBUGPOSHEIGHTSTICH
          
           // neighbour lod spread
           const int neighbour_currentLodStep = 1 << r->_getNeighbor(  EAST )->getRenderLevel(   );
           // Step half way between low detail steps
           const int halfsuperstep = neighbour_currentLodStep >> 1;
           const unsigned long neighbour_lod_mask = ~(  neighbour_currentLodStep - 1 );
           bottom_right_z = static_cast<int>(  localPageZ ) & neighbour_lod_mask;
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
           bottom_right_x = static_cast<int>(  localPageX ) & lod_mask;
          
           a2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x,   bottom_right_z + halfsuperstep );
           c2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + neighbour_currentLodStep );
          
           // biggest Middle tri
           if (  !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           // all other smalls tri up to middle
           // but omit first triangle
          
           // omit first tri
           a2d = Vector2 (  bottom_right_x,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x,   bottom_right_z + currentLodStep );
           c2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
          
           int step = 1;
           while (  step < halfsuperstep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.y += currentLodStep;
           b2d.y += currentLodStep;
           }
           // stops here,   not looking after middle of higher lod.
           // middle point
           if (  step < halfsuperstep )
           not_found = false;
           }
           else
           {
           not_found = false;
           }
          
           }
           else if (  west )//northwest
           {
           #ifdef _DEBUGPOSHEIGHTSTICH
           debugStich += " north: " + StringConverter::toString(  r->_getNeighbor(  NORTH )->getRenderLevel(   ) ) +
           " west: " + StringConverter::toString(  r->_getNeighbor(  WEST )->getRenderLevel(   ) );
           #endif //_DEBUGPOSHEIGHTSTICH
          
           // neighbour lod spread
           const int neighbour_currentLodStep = 1 << r->_getNeighbor(  WEST )->getRenderLevel(   );
           // Step half way between low detail steps
           const int halfsuperstep = neighbour_currentLodStep >> 1;
           const unsigned long neighbour_lod_mask = ~(  neighbour_currentLodStep - 1 );
           bottom_right_z = static_cast<int>(  localPageZ ) & neighbour_lod_mask;
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
           bottom_right_x = static_cast<int>(  localPageX ) & lod_mask;
          
           a2d = Vector2 (  bottom_right_x,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + halfsuperstep );
           c2d = Vector2 (  bottom_right_x,   bottom_right_z + neighbour_currentLodStep );
          
           // biggest Middle tri
           if (  !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           //all other small tri
          
          
           a2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + currentLodStep );
           c2d = Vector2 (  bottom_right_x,   bottom_right_z );
          
           int step = halfsuperstep;
          
           // begins at middle point
           a2d.y += halfsuperstep;
           b2d.y += halfsuperstep;
           c2d.y += neighbour_currentLodStep;
          
           while (  step < neighbour_currentLodStep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.y += currentLodStep;
           b2d.y += currentLodStep;
           }
           // stops here
           if (  step < neighbour_currentLodStep )
           not_found = false;
           }
           else
           {
           not_found = false;
           }
           }
           if (  not_found )
           {
           // in north stitching
           #ifdef _DEBUGPOSHEIGHTSTICH
           debugStich += " north: " + StringConverter::toString(  r->_getNeighbor(  NORTH )->getRenderLevel(   ) );
           #endif //_DEBUGPOSHEIGHTSTICH
          
           // neighbour lod spread
           const int neighbour_currentLodStep = 1 << r->_getNeighbor(  NORTH )->getRenderLevel(   );
           // Step half way between low detail steps
           const int halfsuperstep = neighbour_currentLodStep >> 1;
           const unsigned long neighbour_lod_mask = ~(  neighbour_currentLodStep - 1 );
           bottom_right_x = static_cast<int>(  localPageX ) & neighbour_lod_mask;
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
           bottom_right_z = static_cast<int>(  localPageZ ) & lod_mask;
          
           a2d = Vector2 (  bottom_right_x,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x + halfsuperstep,   bottom_right_z + currentLodStep );
           c2d = Vector2 (  bottom_right_x + neighbour_currentLodStep,   bottom_right_z );
          
           // biggest Middle tri
           if (  !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           //all other small tri
          
           // could omit first and last tri ?
           int step = 0;
          
           a2d = Vector2 (  bottom_right_x,   bottom_right_z + currentLodStep );
           b2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + currentLodStep );
           c2d = Vector2 (  bottom_right_x,   bottom_right_z );
           while (  step < halfsuperstep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.x += currentLodStep;
           b2d.x += currentLodStep;
           }
           // middle point
           if (  step >= halfsuperstep )
           {
           c2d.x += neighbour_currentLodStep;
          
           while (  step < neighbour_currentLodStep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.x += currentLodStep;
           b2d.x += currentLodStep;
           }
           }
           }
           }
           }
           else if (  south )
           {
           bool not_found = true;
           if (  east )//northeast
           {
           #ifdef _DEBUGPOSHEIGHTSTICH
           debugStich += " south: " + StringConverter::toString(  r->_getNeighbor(  SOUTH )->getRenderLevel(   ) ) +
           " east: " + StringConverter::toString(  r->_getNeighbor(  EAST )->getRenderLevel(   ) );
           #endif //_DEBUGPOSHEIGHTSTICH
          
           // neighbour lod spread
           const int neighbour_currentLodStep = 1 << r->_getNeighbor(  EAST )->getRenderLevel(   );
           // Step half way between low detail steps
           const int halfsuperstep = neighbour_currentLodStep >> 1;
           const unsigned long neighbour_lod_mask = ~(  neighbour_currentLodStep - 1 );
           bottom_right_z = static_cast<int>(  localPageZ ) & neighbour_lod_mask;
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
           bottom_right_x = static_cast<int>(  localPageX ) & lod_mask;
          
           a2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x,   bottom_right_z + halfsuperstep );
           c2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + neighbour_currentLodStep );
          
           // biggest Middle tri
           if (  !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           // all other smalls tri up to middle
           // but omit first triangle
          
           // omit first tri
           a2d = Vector2 (  bottom_right_x,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x,   bottom_right_z + currentLodStep );
           c2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
          
           int step = 1;
           while (  step < halfsuperstep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.y += currentLodStep;
           b2d.y += currentLodStep;
           }
           // stops here,   not looking after middle of higher lod.
           // middle point
           if (  step < halfsuperstep )
           not_found = false;
           }
           else
           {
           not_found = false;
           }
          
           }
           else if (  west )//northwest
           {
           #ifdef _DEBUGPOSHEIGHTSTICH
           debugStich += " south: " + StringConverter::toString(  r->_getNeighbor(  SOUTH )->getRenderLevel(   ) ) +
           " west: " + StringConverter::toString(  r->_getNeighbor(  WEST )->getRenderLevel(   ) );
           #endif //_DEBUGPOSHEIGHTSTICH
          
           // neighbour lod spread
           const int neighbour_currentLodStep = 1 << r->_getNeighbor(  WEST )->getRenderLevel(   );
           // Step half way between low detail steps
           const int halfsuperstep = neighbour_currentLodStep >> 1;
           const unsigned long neighbour_lod_mask = ~(  neighbour_currentLodStep - 1 );
           bottom_right_z = static_cast<int>(  localPageZ ) & neighbour_lod_mask;
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
           bottom_right_x = static_cast<int>(  localPageX ) & lod_mask;
          
           a2d = Vector2 (  bottom_right_x,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + halfsuperstep );
           c2d = Vector2 (  bottom_right_x,   bottom_right_z + neighbour_currentLodStep );
          
           // biggest Middle tri
           if (  !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           //all other small tri
          
          
           a2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + currentLodStep );
           c2d = Vector2 (  bottom_right_x,   bottom_right_z );
          
           int step = halfsuperstep;
          
           // begins at middle point
           a2d.y += halfsuperstep;
           b2d.y += halfsuperstep;
           c2d.y += neighbour_currentLodStep;
          
           while (  step < neighbour_currentLodStep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.y += currentLodStep;
           b2d.y += currentLodStep;
           }
           // stops here
           if (  step < neighbour_currentLodStep )
           not_found = false;
           }
           else
           {
           not_found = false;
           }
           }
           if (  not_found )
           {
           // south
           #ifdef _DEBUGPOSHEIGHTSTICH
           debugStich += " south: " + StringConverter::toString(  r->_getNeighbor(  SOUTH )->getRenderLevel(   ) );
           #endif //_DEBUGPOSHEIGHTSTICH
          
           // neighbour lod spread
           const int neighbour_currentLodStep = 1 << r->_getNeighbor(  SOUTH )->getRenderLevel(   );
           // Step half way between low detail steps
           const int halfsuperstep = neighbour_currentLodStep >> 1;
           const unsigned long neighbour_lod_mask = ~(  neighbour_currentLodStep - 1 );
           bottom_right_x = static_cast<int>(  localPageX ) & neighbour_lod_mask;
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
           bottom_right_z = static_cast<int>(  localPageZ ) & lod_mask;
          
           a2d = Vector2 (  bottom_right_x,   bottom_right_z + currentLodStep );
           b2d = Vector2 (  bottom_right_x + halfsuperstep,   bottom_right_z );
           c2d = Vector2 (  bottom_right_x + neighbour_currentLodStep,   bottom_right_z + currentLodStep );
          
           // biggest Middle tri
           if (  !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           //all other small tri
          
           // could omit first and last tri ?
           int step = 0;
          
           a2d = Vector2 (  bottom_right_x,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
           c2d = Vector2 (  bottom_right_x,   bottom_right_z + currentLodStep );
          
           while (  step < halfsuperstep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.x += currentLodStep;
           b2d.x += currentLodStep;
           }
           // middle point
           if (  step >= halfsuperstep )
           {
           c2d.x += neighbour_currentLodStep;
          
           while (  step < neighbour_currentLodStep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.x += currentLodStep;
           b2d.x += currentLodStep;
           }
           }
           }
           }
           }
           else if (  east ) // just east
           {
           #ifdef _DEBUGPOSHEIGHTSTICH
           debugStich += " east: " + StringConverter::toString(  r->_getNeighbor(  EAST )->getRenderLevel(   ) );
           #endif //_DEBUGPOSHEIGHTSTICH
          
           // neighbour lod spread
           const int neighbour_currentLodStep = 1 << r->_getNeighbor(  EAST )->getRenderLevel(   );
           // Step half way between low detail steps
           const int halfsuperstep = neighbour_currentLodStep >> 1;
           const unsigned long neighbour_lod_mask = ~(  neighbour_currentLodStep - 1 );
           bottom_right_z = static_cast<int>(  localPageZ ) & neighbour_lod_mask;
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
           bottom_right_x = static_cast<int>(  localPageX ) & lod_mask;
          
           a2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x,   bottom_right_z + halfsuperstep );
           c2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + neighbour_currentLodStep );
          
           // biggest Middle tri
           if (  !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           //all other small tri
           a2d = Vector2 (  bottom_right_x,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x,   bottom_right_z + currentLodStep );
           c2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
          
           int step = 0;
           while (  step < halfsuperstep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.y += currentLodStep;
           b2d.y += currentLodStep;
           }
           // middle point
           if (  step >= halfsuperstep )
           {
           c2d.y += neighbour_currentLodStep;
          
           while (  step < neighbour_currentLodStep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.y += currentLodStep;
           b2d.y += currentLodStep;
           }
           }
           }
           }
           else if (  west ) // just west
           {
           #ifdef _DEBUGPOSHEIGHTSTICH
           debugStich += " west: " + StringConverter::toString(  r->_getNeighbor(  WEST )->getRenderLevel(   ) );
           #endif //_DEBUGPOSHEIGHTSTICH
          
           // neighbour lod spread
           const int neighbour_currentLodStep = 1 << r->_getNeighbor(  WEST )->getRenderLevel(   );
           // Step half way between low detail steps
           const int halfsuperstep = neighbour_currentLodStep >> 1;
           const unsigned long neighbour_lod_mask = ~(  neighbour_currentLodStep - 1 );
           bottom_right_z = static_cast<int>(  localPageZ ) & neighbour_lod_mask;
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
           bottom_right_x = static_cast<int>(  localPageX ) & lod_mask;
          
           a2d = Vector2 (  bottom_right_x,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + halfsuperstep );
           c2d = Vector2 (  bottom_right_x,   bottom_right_z + neighbour_currentLodStep );
          
           // biggest Middle tri
           if (  !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           //all other small tri
          
          
           a2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z );
           b2d = Vector2 (  bottom_right_x + currentLodStep,   bottom_right_z + currentLodStep );
           c2d = Vector2 (  bottom_right_x,   bottom_right_z );
          
           int step = 0;
           while (  step < halfsuperstep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.y += currentLodStep;
           b2d.y += currentLodStep;
           }
           // middle point
           if (  step >= halfsuperstep )
           {
           c2d.y += neighbour_currentLodStep;
          
           while (  step < neighbour_currentLodStep &&
           !Math::pointInTri2D (  pos,   a2d,   b2d,   c2d ) )
           {
           step += currentLodStep;
          
           a2d.y += currentLodStep;
           b2d.y += currentLodStep;
           }
           }
           }
           }
          
           const Vector3 a (  a2d.x,   getHeightAtPage (  pageNumberX,   pageNumberZ,   a2d.x,   a2d.y ),   a2d.y );
           const Vector3 b (  b2d.x,   getHeightAtPage (  pageNumberX,   pageNumberZ,   b2d.x,   b2d.y ),   b2d.y );
           const Vector3 c (  c2d.x,   getHeightAtPage (  pageNumberX,   pageNumberZ,   c2d.x,   c2d.y ),   c2d.y );
          
          
           #ifdef _DEBUGPOSHEIGHTSTICH
           const Real shiftx = pageNumberX*pSize - mOptions->maxUnScaledX;
           const Real shiftz = pageNumberZ*pSize - mOptions->maxUnScaledZ;
          
           const Vector3 A (  (  a.x + shiftx ) * mOptions->scale.x,  
           a.y,  
           (  a.z + shiftz ) * mOptions->scale.z );
           const Vector3 B (  (  b.x + shiftx ) * mOptions->scale.x,  
           b.y,  
           (  b.z + shiftz ) * mOptions->scale.z );
           const Vector3 C (  (  c.x + shiftx ) * mOptions->scale.x,  
           c.y,  
           (  c.z + shiftz ) * mOptions->scale.z );
          
           static bool debugged_stitch_none = true;
          
           static SceneNode* Anode = 0;
           static SceneNode* Bnode = 0;
           static SceneNode* Cnode = 0;
          
           if (  debugged_stitch_none )
           {
           const String name(  "TriDebugSphere" );
           Entity* entity = PagingLandScapeSceneManager::getSingleton(   ).createEntity(  name,   "sphere.mesh" );
           SceneNode* Rootnode = PagingLandScapeSceneManager::getSingleton(   ).getRootSceneNode(   );
          
           Entity *e;
           Anode = Rootnode->createChildSceneNode(  name + "A" );
           e = entity->clone(  name + "A" );
           Anode->attachObject(  e );
           Anode->setScale(  0.1f,   0.1f,   0.1f );
           Anode->showBoundingBox(  true );
           e->getMesh(   )->getSubMesh(  0 )->setMaterialName(  "BaseRedNoLightNoDepthCheck" );
          
           Bnode = Rootnode->createChildSceneNode(  name + "B" );
           e = entity->clone(  name + "B" );
           Bnode->attachObject(  e );
           Bnode->setScale(  0.1f,   0.1f,   0.1f );
           Bnode->showBoundingBox(  true );
           e->getMesh(   )->getSubMesh(  0 )->setMaterialName (  "BaseRedNoLightNoDepthCheck" );
          
          
           Cnode = Rootnode->createChildSceneNode(  name + "C" );
           e = entity->clone(  name + "C" );
           Cnode->attachObject(  e );
           Cnode->setScale(  0.1f,   0.1f,   0.1f );
           Cnode->showBoundingBox(  true );
           e->getMesh(   )->getSubMesh(  0 )->setMaterialName (  "BaseRedNoLightNoDepthCheck" );
          
           debugged_stitch_none = false;
           }
          
           Anode->setPosition(  A );
           Bnode->setPosition(  B );
           Cnode->setPosition(  C );
          
           #endif //_DEBUGPOSHEIGHTSTICH
          
          
          
           const Ray triIntersect (  Vector3(  localPageX,   getMaxHeight(   ),   localPageZ ),   Vector3::NEGATIVE_UNIT_Y );
           std::pair<bool,   Real> res = Math::intersects(  triIntersect,   a,   b,   c,   true,   true );
           if (  res.first )
           heightValue = getMaxHeight(   ) - res.second;
           else
           heightValue = 0.0f;
          
           if (  getSlopeAt )
           {
           Vector3 result;
           Vector3 vector1;
           Vector3 vector2;
          
           vector1 = a - b;
           vector2 = b - c;
           result.x = (  vector1.y * vector2.z ) - (  vector1.z * vector2.y );
           result.y = (  vector1.z * vector2.x ) - (  vector1.x * vector2.z );
           result.z = (  vector1.x * vector2.y ) - (  vector1.y * vector2.x );
          
          // result.x = (  (  top_right_y - top_left_y ) * (  -mOptions->scale.z ) );
          // result.y = mOptions->scale.x * (  -mOptions->scale.z );
          // result.z = -mOptions->scale.x * (  bottom_left_y - top_left_y );
          
           result.normalise(   );
           *getSlopeAt = 1.0 + result.y;
           if (  fabs(  *getSlopeAt ) < 0.001f )
           *getSlopeAt = 0.0f;
           }
          
           return heightValue;
           }
           }
          
           // no stitching,   easy life...
           //
           // TL-----TR 1.0
           // | / |
           // | / | .
           // | / | .
           // | / | . ^
           // | / | |
           // BL-----BR 0.0 z
           // 1.0 ... 0.0
           //
           // < - x
           //
           // Where 1.0 is currentLodStep
           //
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
          
           const int bottom_right_x = static_cast<int>(  localPageX ) & lod_mask;
           const int bottom_right_z = static_cast<int>(  localPageZ ) & lod_mask;
           const int top_right_x = bottom_right_x + currentLodStep;
           const int top_right_z = bottom_right_z + currentLodStep;
          
          
           #ifdef _DEBUGPOSHEIGHTSTICH
           if (  1 )
           {
           RenderTarget *t = mOptions->primaryCamera->getViewport(   )->getTarget (   );
           const String Debugtext (  debugStich );
           t->setDebugText (  debugStich );
           }
           #endif //_DEBUGPOSHEIGHTSTICH
          
          
           // find the 4 heights around the point
           const Real bottom_right_y = getHeightAtPage (  pageNumberX,   pageNumberZ,   bottom_right_x ,   bottom_right_z );
           const Real bottom_left_y = getHeightAtPage (  pageNumberX,   pageNumberZ,   top_right_x,   bottom_right_z );
           const Real top_right_y = getHeightAtPage (  pageNumberX,   pageNumberZ,   bottom_right_x,   top_right_z );
           const Real top_left_y = getHeightAtPage (  pageNumberX,   pageNumberZ,   top_right_x,   top_right_z );
          
          
           #ifdef _DEBUGPOSHEIGHTSTICH
           const Real shiftx = pageNumberX*pSize - mOptions->maxUnScaledX;
           const Real shiftz = pageNumberZ*pSize - mOptions->maxUnScaledZ;
          
           const Vector3 BR(  (  bottom_right_x + shiftx ) * mOptions->scale.x,  
           bottom_right_y,  
           (  bottom_right_z + shiftz ) * mOptions->scale.z );
           const Vector3 BL(  (  top_right_x + shiftx ) * mOptions->scale.x,  
           bottom_left_y,  
           (  bottom_right_z + shiftz ) * mOptions->scale.z );
           const Vector3 TR(  (  bottom_right_x + shiftx ) * mOptions->scale.x,  
           top_right_y,  
           (  top_right_z + shiftz ) * mOptions->scale.z );
           const Vector3 TL(  (  top_right_x + shiftx ) * mOptions->scale.x,  
           top_left_y,  
           (  top_right_z + shiftz ) * mOptions->scale.z );
          
           static bool debugged_none = true;
          
           static SceneNode* BRnode = 0;
           static SceneNode* BLnode = 0;
           static SceneNode* TRnode = 0;
           static SceneNode* TLnode = 0;
          
           if (  debugged_none )
           {
           const String name(  "DebugSphere" );
           Entity* entity = PagingLandScapeSceneManager::getSingleton(   ).createEntity(  name,   "sphere.mesh" );
           SceneNode* Rootnode = PagingLandScapeSceneManager::getSingleton(   ).getRootSceneNode(   );
          
           BRnode = Rootnode->createChildSceneNode(  name + "BR" );
           BRnode->attachObject(  entity->clone(  name + "BR" ) );
           BRnode->setScale(  0.1f,   0.1f,   0.1f );
           BRnode->showBoundingBox(  true );
          
           BLnode = Rootnode->createChildSceneNode(  name + "BL" );
           BLnode->attachObject(  entity->clone(  name + "BL" ) );
           BLnode->setScale(  0.1f,   0.1f,   0.1f );
           BLnode->showBoundingBox(  true );
          
          
           TRnode = Rootnode->createChildSceneNode(  name + "TR" );
           TRnode->attachObject(  entity->clone(  name + "TR" ) );
           TRnode->setScale(  0.1f,   0.1f,   0.1f );
           TRnode->showBoundingBox(  true );
          
           TLnode = Rootnode->createChildSceneNode(  name + "TL" );
           TLnode->attachObject(  entity->clone(  name + "TL" ) );
           TLnode->setScale(  0.1f,   0.1f,   0.1f );
           TLnode->showBoundingBox(  true );
          
           debugged_none = false;
           }
          
           BRnode->setPosition(  BR );
           BLnode->setPosition(  BL );
           TRnode->setPosition(  TR );
           TLnode->setPosition(  TL );
          
           if (  0 )
           {
           RenderTarget *t = mOptions->primaryCamera->getViewport(   )->getTarget (   );
           const String Debugtext (  "(  X= " + StringConverter::toString(  localPageX ) + " Z=" +
           StringConverter::toString(  localPageZ ) + " ),   (  br_x=" +
           StringConverter::toString(  bottom_right_x ) + ",   br_z=" +
           StringConverter::toString(  bottom_right_z ) + " ) & spread=" +
           StringConverter::toString(  currentLodStep )+ " ) & lod=" +
           StringConverter::toString(  currentRenderLevel ) );
           t->setDebugText(  Debugtext );
           }
           #endif //_DEBUGPOSHEIGHTSTICH
          
           const Real z_pct = (  localPageZ - bottom_right_z ) * inv_currentLodStep;
           Real x_pct = (  localPageX - bottom_right_x ) * inv_currentLodStep;
          
           if (  x_pct > 1 - z_pct )
           {
           // This point is on the upper-left tri
           const Real y1 = bottom_left_y * (  1-z_pct ) + top_left_y * z_pct;
           const Real y2 = bottom_left_y * (  1-z_pct ) + top_right_y * z_pct;
           if (  z_pct > 0.0f )
           x_pct = (  x_pct - (  1-z_pct ) ) / z_pct;
          
           if (  getSlopeAt )
           {
           Vector3 result(  (  (  top_right_y - top_left_y ) * (  -mOptions->scale.z ) ),  
           mOptions->scale.x * (  -mOptions->scale.z ),  
           -mOptions->scale.x * (  bottom_left_y - top_left_y ) );
           result.normalise(   );
           *getSlopeAt = 1.0 + result.y;
           if (  fabs(  *getSlopeAt ) < 0.001f )
           *getSlopeAt = 0.0f;
           }
          
           return y1 * x_pct + y2 * (  1-x_pct );
           } // if (  x_pct > 1 - z_pct )
           else
           {
           // This point is on the lower-right tri
           const Real y1 = bottom_left_y * (  1-z_pct ) + top_right_y * z_pct;
           const Real y2 = bottom_right_y * (  1-z_pct ) + top_right_y * z_pct;
          
           if (  z_pct < 1.0f )
           x_pct = x_pct / (  1-z_pct );
          
           if (  getSlopeAt )
           {
           Vector3 result(  (  bottom_left_y - bottom_right_y ) * mOptions->scale.z,  
           -mOptions->scale.x * mOptions->scale.z,  
           mOptions->scale.x * (  top_right_y - bottom_right_y ) );
           result.normalise(   );
           *getSlopeAt = 1.0 + result.y;
           if (  fabs(  *getSlopeAt ) < 0.001f )
           *getSlopeAt = 0.0f;
           }
          
           return y1 * x_pct + y2 * (  1-x_pct );
           }
          
          #else //_MAPSPLITTER
           return 0.0f;
          #endif //_MAPSPLITTER
           }
           //-----------------------------------------------------------------------
    1491   const Real PagingLandScapeData2DManager::getWorldHeight(  const Real x,   const Real z )
           {
          #ifndef _MAPSPLITTER
           // figure out which page the point is on
           unsigned int pageX,   pageZ;
           if (  mPageManager->getPageIndices(  x,   z,   pageX,   pageZ,   false ) )
           {
           PagingLandScapeData2D * const data = getData2D (  pageX,   pageZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           // scale position from world to page scale
           Real localX = x * mOptions->invScale.x;
           Real localZ = z * mOptions->invScale.z;
          
           // adjust x and z to be local to page
           const Real pSize = mOptions->PageSize - 1;
          
           localX -= pageX*pSize - mOptions->maxUnScaledX;
           localZ -= pageZ*pSize - mOptions->maxUnScaledZ;
          
           return getHeightAtPage (  pageX,   pageZ,   static_cast<int> (  localX ),   static_cast<int> (  localZ ) );
           }
           }
          
          #endif //_MAPSPLITTER
           return 0.0f;
           }
           //-----------------------------------------------------------------------
    1519   const Real PagingLandScapeData2DManager::getHeightAtPage(  const unsigned int dataX,   const unsigned int dataZ,  
    1520   const Real x,   const Real z )
           {
           PagingLandScapeData2D* data = getData2D (  dataX,   dataZ,   false  );
           if (  data && data->isLoaded(   ) )
           {
           Real lX = x;
           Real lZ = z;
           const Real pSize = mOptions->PageSize - 1;
           PagingLandScapeData2D* srcdata = data;
           //check if we have to change current page
           if (  lX < 0.0f )
           {
           if (  dataX == 0 )
           lX = 0.0f;
           else
           {
           data = getData2D (  dataX - 1 ,   dataZ,   false  );
           if (  data && data->isLoaded(   ) )
           {
           lX = static_cast<Real> (  pSize );
           }
           else
           {
           lX = 0.0f;
           data = srcdata;
           }
           }
          
           }
           else if (  lX > pSize )
           {
           if (  dataX == mOptions->world_width - 1 )
           lX = static_cast<Real> (  pSize );
           else
           {
           data = getData2D (  dataX + 1 ,   dataZ,   false  );
           if (  data && data->isLoaded(   ) )
           {
           lX = 0.0f;
           }
           else
           {
           lX = static_cast<Real> (  pSize );
           data = srcdata;
           }
           }
           }
          
           if (  lZ < 0.0f )
           {
           if (  dataZ == 0 )
           lZ = 0.0f;
           else
           {
           data = getData2D (  dataX,   dataZ - 1,   false  );
           if (  data && data->isLoaded(   ) )
           {
           lZ = static_cast<Real> (  pSize );
           }
           else
           {
           lZ = 0.0f;
           data = srcdata;
           }
           }
           }
           else if (  lZ > pSize )
           {
           if (  dataZ == mOptions->world_height - 1 )
           lZ = static_cast<Real> (  pSize );
           else
           {
           data = getData2D (  dataX,   dataZ + 1,   false  );
           if (  data && data->isLoaded(   ) )
           {
           lZ = 0.0f;
           }
           else
           {
           lZ = static_cast<Real> (  pSize );
           data = srcdata;
           }
           }
           }
           assert (  data );
           return data->getHeight (  lX,   lZ );
           }
           return 0.0f;
           }
           //-----------------------------------------------------------------------
    1610   const Real PagingLandScapeData2DManager::getHeightAtPage(  const unsigned int dataX,   const unsigned int dataZ,  
           const int x,   const int z )
           {
           PagingLandScapeData2D * data = getData2D (  dataX,   dataZ,   false  );
           if (  data && data->isLoaded(   ) )
           {
           int lX = x;
           int lZ = z;
           const int pSize = mOptions->PageSize - 1;
           PagingLandScapeData2D* srcdata = data;
           //check if we have to change current page
           if (  lX < 0 )
           {
           if (  dataX == 0 )
           lX = 0;
           else
           {
           data = getData2D (  dataX - 1,   dataZ,   false  );
           if (  data && data->isLoaded(   ) )
           {
           lX = pSize;
           }
           else
           {
           lX = 0;
           data = srcdata;
           }
           }
          
           }
           else if (  lX > pSize )
           {
           if (  dataX == mOptions->world_width - 1 )
           lX = pSize;
           else
           {
           data = getData2D (  dataX + 1,   dataZ,   false  );
           if (  data && data->isLoaded(   ) )
           {
           lX = 0;
           }
           else
           {
           lX = pSize;
           data = srcdata;
           }
           }
           }
          
           if (  lZ < 0 )
           {
           if (  dataZ == 0 )
           lZ = 0;
           else
           {
           data = getData2D (  dataX,   dataZ - 1,   false  );
           if (  data && data->isLoaded(   ) )
           {
           lZ = pSize;
           }
           else
           {
           lZ = 0;
           data = srcdata;
           }
           }
           }
           else if (  lZ > pSize )
           {
           if (  dataZ == mOptions->world_height - 1 )
           lZ = pSize;
           else
           {
           data = getData2D (  dataX,   dataZ + 1,   false  );
           if (  data && data->isLoaded(   ) )
           {
           lZ = 0;
           }
           else
           {
           lZ = pSize;
           data = srcdata;
           }
           }
           }
           assert (  data );
           return data->getHeight (  lX,   lZ );
           }
           else
           {
           // not a border demand and we do not have the data.
           return 0.0f;
           }
           }
          
          
           //-----------------------------------------------------------------------
    1707   const Vector3 PagingLandScapeData2DManager::getNormalAt(  const unsigned int dataX,   const unsigned int dataZ,  
           const unsigned int x,   const unsigned int z )
           {
           PagingLandScapeData2D* data = getData2D (  dataX,   dataZ,   false  );
           if (  data && data->isLoaded(   ) )
           {
           #ifdef _LOADEDNORM
           // not as precise (  rgb normals gives 8 bits precision Real )
           // and finally nearly as fast.
           return data->getNormalAt (  x,   z );
           #else /*_LOADEDNORM*/
           {
           // First General method : (  9 adds and 6 muls + a normalization )
           // *---v3--*
           // | | |
           // | | |
           // v1--X--v2
           // | | |
           // | | |
           // *---v4--*
           //
           // U = v2 - v1;
           // V = v4 - v3;
           // N = Cross(  U,   V );
           // N.normalise;
           //
           // BUT IN CASE OF A HEIGHTMAP :
           //
           // if you do some math by hand before you code,  
           // you can see that N is immediately given by
           // Approximation (  2 adds and a normalization )
           //
           // N = Vector3(  z[x-1][y] - z[x+1][y],   z[x][y-1] - z[x][y+1],   2 );
           // N.normalise(   );
           //
           // or even using SOBEL operator VERY accurate!
           // (  14 adds and a normalization )
           //
           // N = Vector3 (  z[x-1][y-1] + z[x-1][y] + z[x-1][y] + z[x-1][y+1] - z[x+1][y-1] - z[x+1][y] - z[x+1][y] - z[x+1][y+1],  
           // z[x-1][y-1] + z[x][y-1] + z[x][y-1] + z[x+1][y-1] - z[x-1][y+1] - z[x][y+1] - z[x][y+1] - z[x+1][y+1],  
           // 8 );
           // N.normalize(   );
          
          
           // Fast SOBEL filter
          
           // the divider make sure we do respect proportion (  height and width proportional to y )
           const Real Divider = static_cast <Real> (  mOptions->PageSize - 1 ) / mOptions->scale.y;
          
           #define gH(  a,   b ) (  getHeightAtPage(  dataX,   dataZ,   static_cast<int> (  a ),   static_cast<int> (  b ) ) )
          
          // Vector3 result (  (  gH(  x-1,  z-1 ) + gH (  x-1,   z ) + gH (  x-1,   z ) + gH (  x-1,   z+1 ) - gH (  x+1,   z-1 ) - gH (  x+1,   z ) - gH (  x+1,   z ) - gH (  x+1,   z+1 ) ) * Divider,  
          // 8.0f,  
          // (  gH (  x-1,   z-1 ) + gH (  x,   z-1 ) + gH (  x,   z-1 ) + gH (  x+1,   z-1 ) - gH (  x-1,   z+1 ) - gH (  x,   z+1 ) - gH (  x,   z+1 ) - gH (  x+1,   z+1 ) ) * Divider );
          
           Vector3 result(  (  gH (  x - 1 ,   z ) - gH (  x + 1 ,   z ) ) * Divider,  
           2.0f,  
           (  gH (  x,   z - 1 ) - gH (  x ,   z + 1 ) ) * Divider );
          
           result.normalise (   );
          
           return result;
           }
           #endif //_NOLOAD
           }
           return Vector3::UNIT_Y;
           }
           //----------------------------------------------------------------------------
    1775   const Real PagingLandScapeData2DManager::getRealWorldSlope(  const Real x,   const Real z )
           {
          #ifndef _MAPSPLITTER
           // figure out which page the point is on
           const Vector3 pos(  x,   0,   z );
           unsigned int pageX,   pageZ;
           if (  mPageManager->getPageIndices(  pos.x,   pos.z,   pageX,   pageZ,   false ) )
           {
          
           PagingLandScapeData2D* data = getData2D (  pageX,   pageZ,   false );
           if (  data && data->isLoaded(   ) )
           {
           // figure out which tile the point is on
           PagingLandScapeTile *t = mPageManager->getTile(  pos.x,   pos.z,  
           pageX,   pageZ,  
           false );
           unsigned int Lod = 0;
           if (  t && t->isLoaded(   ) )
           Lod = t->getRenderable(   )->getRenderLevel(   );
           const Vector3 normalVector = getNormalAt(  pageX,   pageZ,   static_cast<unsigned int>(  x ),   static_cast<unsigned int>(  z ),   Lod );
           const Real slope = 1.0f + normalVector.y;
           if (  slope < 0.001f )
           return 0.0f;
           else
           return slope;
           }
           }
          #endif //_MAPSPLITTER
           return 0.0f;
           }
          
           //-----------------------------------------------------------------------
    1807   const Vector3 PagingLandScapeData2DManager::getNormalAt(  const unsigned int pageX,   const unsigned int pageZ,   const unsigned int x,   const unsigned int z,   const unsigned int Lod )
           {
           Vector3 result;
          
           // scale position from world to page scale
           Real localX = x * mOptions->invScale.x;
           Real localZ = z * mOptions->invScale.z;
          
           // adjust x and z to be local to page
           const Real pSize = mOptions->PageSize - 1;
          
           localX -= pageX * pSize - mOptions->maxUnScaledX;
           localZ -= pageZ * pSize - mOptions->maxUnScaledZ;
          
           // make sure x and z do not go outside the world boundaries
           if (  localX < 0 )
           localX = 0;
           else if (  localX >= pSize )
           localX = pSize - 1;
          
           if (  localZ < 0 )
           localZ = 0;
           else if (  localZ >= pSize )
           localZ = pSize - 1;
          
           // find the 4 vertices that surround the point
           // use LOD info to determine vertex data spacing - this is passed into the method
           // determine vertices on left and right of point and top and bottom
           // don't access VBO since a big performance hit when only 4 vertices are needed
           const int currentLodStep = 1 << Lod;
           const Real inv_currentLodStep = 1.0f / currentLodStep;
          
           // find the vertex to the 'bottom right' of the point
           const unsigned long lod_mask = ~(  currentLodStep - 1 );
           const int bottom_right_x = static_cast<int>(  localX ) & lod_mask;
           const int bottom_right_z = static_cast<int>(  localZ ) & lod_mask;
          
           // find the 4 heights around the point
           const Real bottom_right_y = getHeightAtPage(  pageX,   pageZ,   bottom_right_x ,   bottom_right_z );
           const Real bottom_left_y = getHeightAtPage(  pageX,   pageZ,   bottom_right_x + currentLodStep,   bottom_right_z );
           const Real top_right_y = getHeightAtPage(  pageX,   pageZ,   bottom_right_x,   bottom_right_z + currentLodStep );
           const Real top_left_y = getHeightAtPage(  pageX,   pageZ,   bottom_right_x + currentLodStep,   bottom_right_z + currentLodStep );
          
           const Real z_pct = (  localZ - bottom_right_z ) * inv_currentLodStep;
           Real x_pct = (  localX - bottom_right_x ) * inv_currentLodStep;
           // TL-----TR 1.0
           // | / |
           // | / | .
           // | / | .
           // | / | . ^
           // | / | |
           // BL-----BR 0.0 z
           // 1.0 ... 0.0
           //
           // < - x
          
           if (  x_pct > 1 - z_pct )
           {
           // This point is on the upper-left tri
           /*
           Vector3 vector1;
           Vector3 vector2;
          
           vector1.x = -mOptions->scale.x;
           vector1.y = top_right_y - top_left_y;
           vector1.z = 0;
           vector2.x = 0;
           vector2.y = bottom_left_y - top_left_y;
           vector2.z = -mOptions->scale.z;
          
           result.x = (  vector1.y * vector2.z ) - (  vector1.z * vector2.y );
           result.y = (  vector1.z * vector2.x ) - (  vector1.x * vector2.z );
           result.z = (  vector1.x * vector2.y ) - (  vector1.y * vector2.x );
           */
           // The formulas for calculating result are simplified from the above
           // commented-out code for computing the cross product.
           result.x = (  (  top_right_y - top_left_y ) * (  -mOptions->scale.z ) );
           result.y = mOptions->scale.x * (  -mOptions->scale.z );
           result.z = -mOptions->scale.x * (  bottom_left_y - top_left_y );
           }
           else
           {
           // This point is on the lower-right tri
           /*
           Vector3 vector1;
           Vector3 vector2;
          
           vector1.x = mOptions->scale.x;
           vector1.y = bottom_left_y - bottom_right_y;
           vector1.z = 0;
           vector2.x = 0;
           vector2.y = top_right_y - bottom_right_y;
           vector2.z = mOptions->scale.z;
          
           result.x = (  vector1.y * vector2.z ) - (  vector1.z * vector2.y );
           result.y = (  vector1.z * vector2.x ) - (  vector1.x * vector2.z );
           result.z = (  vector1.x * vector2.y ) - (  vector1.y * vector2.x );
           */
           // The formulas for calculating result are simplified from the above
           // commented-out code for computing the cross product.
           result.x = (  bottom_left_y - bottom_right_y ) * mOptions->scale.z;
           result.y = -mOptions->scale.x * mOptions->scale.z;
           result.z = mOptions->scale.x * (  top_right_y - bottom_right_y );
           }
          
           result.normalise(   );
           return result;
           }
           //-----------------------------------------------------------------------
    1916   Real PagingLandScapeData2DManager::getMaxSlope(  Vector3 location1,   Vector3 location2,   Real maxSlopeIn )
           {
           int testCount;
           int testIndex;
           Real maxSlope;
           Real nextSlope;
           Vector3 unitVector;
           Vector3 iterationOffset;
           Vector3 nextLocation;
           Real halfWorldSizeX;
           Real halfWorldSizeZ;
           Real distBetweenPoints;
          
           // worldSizeX = (  float )mOptions->world_width * mOptions->scale.x;
           // worldSizeZ = (  float )mOptions->world_height * mOptions->scale.z;
           halfWorldSizeX = mOptions->maxScaledX;
           halfWorldSizeZ = mOptions->maxScaledZ;
          
           if (  (  location1[0] > halfWorldSizeX ) || (  location1[2] > halfWorldSizeZ ) ||
           (  location2[0] > halfWorldSizeX ) || (  location2[2] > halfWorldSizeZ ) ||
           (  location1[0] < -halfWorldSizeX ) || (  location1[2] < -halfWorldSizeZ ) ||
           (  location2[0] < -halfWorldSizeX ) || (  location2[2] < -halfWorldSizeZ ) )
           {
           // One or both endpoints is off the edge of the world. Return max slope.
           return 1.0f;
           }
          
           getInterpolatedWorldHeight(  location2.x,   location2.z,   &maxSlope );
          // maxSlope = getRealWorldSlope(  location2.x,   location2.z );
           if (  maxSlope > maxSlopeIn )
           return maxSlope;
          
           unitVector.x = location2.x - location1.x;
           unitVector.y = 0.0f;
           unitVector.z = location2.z - location1.z;
          
           // before normalizing our unitVector,   calculate the distance between the endpoints
           distBetweenPoints = (  Real )sqrt(  (  unitVector.x * unitVector.x ) + (  unitVector.z * unitVector.z ) );
          // testCount = (  int )(  distSquared / (  mOptions->scale.x * mOptions->scale.x ) / 16.0f );
           testCount = (  int )(  (  distBetweenPoints / mOptions->scale.x ) * 4.0f );
          
           unitVector.normalise(   );
           iterationOffset.x = unitVector.x * (  mOptions->scale.x / 4.0f );
           iterationOffset.z = unitVector.z * (  mOptions->scale.z / 4.0f );
          
           nextLocation.x = location1.x;
           nextLocation.y = location1.y;
           nextLocation.z = location1.z;
          
           for (  testIndex = 0; testIndex < testCount; testIndex++ )
           {
           getInterpolatedWorldHeight(  nextLocation.x,   nextLocation.z,   &nextSlope );
          // nextSlope = getRealWorldSlope(  nextLocation.x,   nextLocation.z );
           if (  nextSlope > maxSlopeIn )
           return nextSlope;
          
           if (  nextSlope > maxSlope )
           maxSlope = nextSlope;
          
           nextLocation.x += iterationOffset.x;
           nextLocation.z += iterationOffset.z;
           }
          
           return maxSlope;
           }
          
          
          
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2D_HeightField.cpp

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightField.cpp - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreLogManager.h"
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreImage.h"
          #include "OgreImageCodec.h"
          
          #include "OgreArchiveManager.h"
          
          #include "OgreStringConverter.h"
          
          #include "OgreException.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeOptions.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D_HeightField.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      45   PagingLandScapeData2D* PagingLandScapeData2D_HeightField::newPage(   )
           {
           return new PagingLandScapeData2D_HeightField(  mParent );
           }
           //-----------------------------------------------------------------------
      50   PagingLandScapeData2D_HeightField::PagingLandScapeData2D_HeightField(  PagingLandScapeData2DManager *dataMgr ):
           PagingLandScapeData2D(  dataMgr )
           {
           mImage = 0;
           mCoverage = 0;
           mBase = 0;
           mShadow = 0;
           mMaxheight = mParent->getOptions(   )->scale.y;
           }
           //-------------------------------------------------------------------
      60   const Real PagingLandScapeData2D_HeightField::getMaxAbsoluteHeight(  void ) const
           {
           return mParent->getOptions(   )->scale.y;
           }
           //-----------------------------------------------------------------------
      65   PagingLandScapeData2D_HeightField::~PagingLandScapeData2D_HeightField(   )
           {
           }
           //-----------------------------------------------------------------------
      69   const ColourValue PagingLandScapeData2D_HeightField::getBase (  const Real mX,   const Real mZ )
           {
           if (  mBase != 0 )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  mZ * mBase->getWidth(   ) + mX ) * 4 );//4 bytes (  mImage is RGBA )
           if (  mBase->getSize (   ) > Pos )
           {
           const Real divider = 1.0f / 255;
           return ColourValue(  (  Real ) mBase->getData(   )[ Pos + 0] * divider,  
           (  Real ) mBase->getData(   )[ Pos + 1] * divider,  
           (  Real ) mBase->getData(   )[ Pos + 2] * divider,  
           (  Real ) mBase->getData(   )[ Pos + 3] * divider );
           }
           else
           {
           return ColourValue::White;
           }
           }
           else
           {
           return ColourValue::White;
           }
           }
          
           //-----------------------------------------------------------------------
      94   const ColourValue PagingLandScapeData2D_HeightField::getCoverage (  const Real mX,   const Real mZ )
           {
           if (  mCoverage != 0 )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  mZ * mCoverage->getWidth(   ) + mX ) * 4 );//4 bytes (  mImage is RGBA )
           if (  mCoverage->getSize (   ) > Pos )
           {
           const Real divider = 1.0f / 255;
           return ColourValue(  (  Real ) mCoverage->getData(   )[ Pos + 0] * divider,  
           (  Real ) mCoverage->getData(   )[ Pos + 1] * divider,  
           (  Real ) mCoverage->getData(   )[ Pos + 2] * divider,  
           (  Real ) mCoverage->getData(   )[ Pos + 3] * divider );
           }
           else
           {
           return ColourValue::White;
           }
           }
           else
           {
           return ColourValue::White;
           }
           }
          
           //-----------------------------------------------------------------------
     119   const Real PagingLandScapeData2D_HeightField::getShadow (  const Real mX,   const Real mZ,  
     120   const bool &positive )
           {
           if (  mShadow != 0 )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  mZ * mShadow->getWidth(   ) + mX ) * 3 );//3 bytes (  mImage is RGBA )
           if (  mShadow->getSize (   ) > Pos )
           {
           if (  positive )
           return static_cast<Real> (  mShadow->getData(   )[ Pos + 0] ) / 255;
           else
           return static_cast<Real> (  mShadow->getData(   )[ Pos + 1] ) / 255;
           }
           else
           {
           return 0.0f;
           }
           }
           else
           {
           return 0.0f;
           }
           }
          
           //-----------------------------------------------------------------------
     144   const Vector3 PagingLandScapeData2D_HeightField::getNormal (  const Real x,   const Real z )
           {
           #ifndef _LOADEDNORM
           return PagingLandScapeData2D::getNormal(  x,  z );
           #else
           if (  mImage )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  z * mSize + x ) * mBpp );//4 bytes (  mImage is RGBA )
          
           if (  mMax > Pos )
           {
           const Real normalscale = 1.0f / 127.0f;
           return Vector3 (  (  (  Real )(  mImage->getData(   )[Pos + 0] ) - 128.0f ) * normalscale,  
           (  (  Real )(  mImage->getData(   )[Pos + 1] ) - 128.0f ) * normalscale,  
           (  (  Real )(  mImage->getData(   )[Pos + 2] ) - 128.0f ) * normalscale );
           }
           else
           {
           return Vector3::UNIT_Y;
           }
           }
           else
           {
           return Vector3::UNIT_Y;
           }
           #endif //_NOLOAD
           }
           //-----------------------------------------------------------------------
     172   Real PagingLandScapeData2D_HeightField::getScale(   ) const
           {
           Real prescale;
           switch (  mBpp )
           {
           case 1:
           prescale = mParent->getOptions(   )->scale.y / 255;
           break;
           case 2:
           prescale = mParent->getOptions(   )->scale.y / 65535;
           break;
           case 3:
           prescale = mParent->getOptions(   )->scale.y / 16777215;
           break;
           case 4:
           prescale = mParent->getOptions(   )->scale.y / 16777215;
           break;
           default:
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,  
           "unrecongnized number of bpp for data src image.",  
           "PagingLandScapeData2D_HeightField::getScale" );
           break;
           }
           return prescale;
           }
           //-----------------------------------------------------------------------
     198   Real PagingLandScapeData2D_HeightField::getInvScale(   ) const
           {
           Real prescale;
           switch (  mBpp )
           {
           case 1:
           prescale = 255.0 / mParent->getOptions(   )->scale.y;
           break;
           case 2:
           prescale = 65535.0 / mParent->getOptions(   )->scale.y;
           break;
           case 3:
           prescale = 16777215.0 / mParent->getOptions(   )->scale.y;
           break;
           case 4:
           prescale = 16777215.0 / mParent->getOptions(   )->scale.y;
           break;
           default:
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,  
           "unrecongnized number of bpp for data src image.",  
           "PagingLandScapeData2D_HeightField::getScale" );
           break;
           }
           return prescale;
           }
           //-----------------------------------------------------------------------
     224   void PagingLandScapeData2D_HeightField::_save(   )
           {
           const Real scale = getInvScale(   );
           const size_t bpp = mBpp;
          
           size_t j = 0;
           uchar * ogre_restrict data = mImage->getData(   );
           for (  unsigned int i = 0; i < mMaxArrayPos; i++ )
           {
           switch (  bpp )
           {
           case 1:
           data[j] = uchar (  mHeightData[i] * scale );
           break;
           case 2:
           case 3:
           case 4:
           {
           const ushort syn = ushort (  mHeightData[i] * scale );
           #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
           data[j] = uchar (  (  syn >> 8 ) & 0xff );
           data[j+ 1] = uchar (  syn & 0xff );
           #else
           data[j] = uchar (  syn & 0xff );
           data[j+ 1] = uchar (  (  syn >> 8 ) & 0xff );
           #endif
           }
           break;
           default:
           assert(  0 );
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,  
           "unrecognized bpp image.",  
           "PagingLandScapeData2D_HeightField::_save" );
           break;
           }
           j += bpp;
           }
          
           const String fname = mParent->getOptions(   )->LandScape_filename + "." +
           StringConverter::toString(  mPageZ ) + "." +
           StringConverter::toString(  mPageX ) + ".";
           const String extname = mParent->getOptions(   )->LandScape_extension;
          
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           mParent->getOptions(   )->groupName,  
           fname + extname );
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           //FileInfo *inf = &(  *it );
           char *olddir = ChangeToDir (  const_cast< char * > (  (  (  it )->archive->getName(   ) ).c_str(   ) ) );
           //FileSystemArchive::pushDirectory(   )
           mImage->save (  fname + "modif." + extname );
           //FileSystemArchive::pushDirectory(   );
           RetablishDir (  olddir );
           }
           }
           //-----------------------------------------------------------------------
     283   bool PagingLandScapeData2D_HeightField::_load(  const unsigned int mX,   const unsigned int mZ )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
           const String pageName = "." + StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + ".";
           const String &fileExt = opt->LandScape_extension;
           const String &groupName = opt->groupName;
           const String strFileName = opt->LandScape_filename + pageName;
          
           mImage = new Image(   );
           if (  !(  opt->Deformable &&
           ResourceGroupManager::getSingleton(   ).resourceExists(  groupName,   strFileName + "modif." + fileExt ) ) )
           {
           if (  !ResourceGroupManager::getSingleton(   ).resourceExists(  groupName,   strFileName + fileExt ) )
           {
           LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,  
           String(  "PLSM2 : Cannot find map named " ) + strFileName + fileExt );
           return false;
           }
           mImage->load (  strFileName + fileExt,   groupName );
           }
           else
           {
           mImage->load (  strFileName + "modif." + fileExt,   groupName );
           }
          
           //check to make sure it's 2^n + 1 size.
           if (  mImage->getWidth(   ) != mImage->getHeight(   ) ||
           !_checkSize(  mImage->getWidth(   ) ) )
           {
           String err = "Error: Invalid height map size : " +
           StringConverter::toString(  static_cast <unsigned int> (  mImage->getWidth(   ) ) ) +
           ",  " + StringConverter::toString(  static_cast <unsigned int> (  mImage->getHeight(   ) ) ) +
           ". Should be 2^n+1,   2^n+1";
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   err,  
           "PagingLandScapeData2D_HeightField::_load" );
           }
          
           mBpp = PixelUtil::getNumElemBytes (  mImage->getFormat (   ) );
           const unsigned int bpp = static_cast <unsigned int> (  mBpp );
           if (  mSize != mImage->getWidth(   ) )
           {
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,  
           "Error: Declared World size <> Height Map Size.",  
           "PagingLandScapeData2D_HeightField::_load" );
           }
          
           if (  opt->coverage_vertex_color )
           {
           mCoverage = new Image(   );
           mCoverage->load (  opt->LandScape_filename + ".Coverage" + pageName + fileExt,  
           groupName );
          
           }
           if (  opt->base_vertex_color )
           {
           mBase = new Image(   );
           mBase->load(  opt->LandScape_filename + ".Base" + pageName + fileExt,  
           groupName );
           }
          
           if (  opt->vertex_shadowed )
           {
           mShadow = new Image(   );
           mShadow->load(  opt->LandScape_filename + ".HS" + pageName + fileExt,  
           groupName );
           }
          
           mXDimension = mImage->getWidth(   ) * bpp;
           mZDimension = mImage->getHeight(   ) * bpp;
           mMax = static_cast <unsigned int> (  mSize * mSize * bpp );
           mMaxArrayPos = static_cast <unsigned int> (  mSize * mSize );
           mHeightData = new Real[mMaxArrayPos];
          
           const Real scale = getScale(   );
          
           mMaxheight = 0.0f;
           const uchar * const ogre_restrict imagedata = mImage->getData(   );
           const unsigned int maxminusone = mMax;
          
           Real h;
           unsigned int j = 0;
           Real * const ogre_restrict heightField = mHeightData;
           for (  unsigned int src_pos = 0; src_pos < maxminusone; src_pos += bpp )
           {
           switch (  bpp )
           {
           case 1:
           h = imagedata[src_pos] * scale;
           break;
           case 2:
           case 3:
           case 4:
           {
           #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
           ushort val = imagedata[src_pos] << 8;
           val += imagedata[src_pos + 1];
           #else
           ushort val = imagedata[src_pos];
           val += imagedata[src_pos + 1] << 8;
           #endif
           h = val * scale;
           }
           break;
           default:
           assert(  0 );
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,  
           "unrecongnized bpp image.",  
           "PagingLandScapeData2D_HeightField::_load" );
           break;
           }
           mMaxheight = std::max (  h,   mMaxheight );
           heightField[j++] = h;
           }
           return true;
           }
          
           //-----------------------------------------------------------------------
     401   void PagingLandScapeData2D_HeightField::_load(   )
           {
           mImage = new Image(   );
           mImage->load (  mParent->getOptions(   )->LandScape_filename +
           "." + mParent->getOptions(   )->LandScape_extension,   mParent->getOptions(   )->groupName );
           mBpp = PixelUtil::getNumElemBytes (  mImage->getFormat (   ) );
          
           mXDimension = mImage->getWidth(   );
           mZDimension = mImage->getHeight(   );
          
           const size_t sourceHeight = mZDimension;
           const size_t sourceWidth = mXDimension;
          
           computePowerof2PlusOneSize (   );
          
           mSize = mXDimension;
           mMaxArrayPos = static_cast <unsigned int> (  mXDimension * mZDimension );
           mMax = static_cast <unsigned int> (  mMaxArrayPos * mBpp );
           mHeightData = new Real[mMaxArrayPos];
          
          
           const unsigned int bpp = static_cast <unsigned int> (  mBpp );
           const Real scale = getScale(   );
          
           mMaxheight = 0.0f;
           const uchar * ogre_restrict imagedata = mImage->getData(   );
           const unsigned int maxminusone = mMax;
           const unsigned int shift_fill = static_cast <unsigned int> (  mXDimension - sourceWidth );
          
           Real h;
           unsigned int dest_pos = 0;
           unsigned int src_pos = 0;
           Real * const ogre_restrict heightField = mHeightData;
           for (  unsigned int i = 0; i < sourceHeight; ++i )
           {
           for (  unsigned int j = 0; j < sourceWidth; ++j )
           {
           switch (  bpp )
           {
           case 1:
           h = imagedata[src_pos] * scale;
           break;
           case 2:
           case 3:
           case 4:
           {
           #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
           ushort val = imagedata[src_pos] << 8;
           val += imagedata[src_pos + 1];
           #else
           ushort val = imagedata[src_pos];
           val += imagedata[src_pos + 1] << 8;
           #endif
           h = val * scale;
           }
           break;
           default:
           assert(  0 );
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,  
           "unrecongnized bpp image.",  
           "PagingLandScapeData2D_HeightField::_load" );
           break;
           }
           //DEBUG_OUTPUT (   " Bpp " << StringConverter::toString (  h ) << "\n";
           mMaxheight = std::max (  h,   mMaxheight );
           heightField[dest_pos++] = h;
           src_pos += bpp;
           }
           memset (  &heightField[dest_pos],   0,   shift_fill );
           dest_pos += shift_fill;
           }
           }
           //-----------------------------------------------------------------------
     474   void PagingLandScapeData2D_HeightField::_unload(   )
           {
           delete mImage;
           mImage = 0;
           delete mCoverage;
           mCoverage = 0;
           delete mBase;
           mBase = 0;
           delete mShadow;
           mShadow = 0;
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2D_HeightFieldBlendNeighbor.cpp

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldBlendNeighbor.cpp - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreLogManager.h"
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreImage.h"
          #include "OgreStringConverter.h"
          
          #include "OgreResourceManager.h"
          
          
          #include "OgreException.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeOptions.h"
          
          #include "OgrePagingLandScapeData2D_HeightFieldBlendNeighbor.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      44   PagingLandScapeData2D* PagingLandScapeData2D_HeightFieldBlendNeighbor::newPage(   )
           {
           return new PagingLandScapeData2D_HeightFieldBlendNeighbor(  mParent );
           }
           //-----------------------------------------------------------------------
      49   PagingLandScapeData2D_HeightFieldBlendNeighbor::PagingLandScapeData2D_HeightFieldBlendNeighbor(  PagingLandScapeData2DManager *dataMgr )
           : PagingLandScapeData2D(  dataMgr )
           {
           mShadow = 0;
           mMaxheight = mParent->getOptions(   )->scale.y;
           }
          
           //-------------------------------------------------------------------
      57   const Real PagingLandScapeData2D_HeightFieldBlendNeighbor::getMaxAbsoluteHeight(  void ) const
           {
           return mParent->getOptions(   )->scale.y;
           }
           //-----------------------------------------------------------------------
      62   PagingLandScapeData2D_HeightFieldBlendNeighbor::~PagingLandScapeData2D_HeightFieldBlendNeighbor(   )
           {
           PagingLandScapeData2D::unload (   );
           }
          
           //-----------------------------------------------------------------------
      68   const Real PagingLandScapeData2D_HeightFieldBlendNeighbor::getShadow (  const Real mX,   const Real mZ,  
      69   const bool &positive )
           {
           if (  mShadow )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  mZ * mShadow->getWidth(   ) + mX ) * 3 );//3 bytes (  mImage is RGBA )
           if (  mShadow->getSize (   ) > Pos )
           {
           if (  positive )
           return static_cast<Real> (  mShadow->getData(   )[ Pos + 0] ) / 255;
           else
           return static_cast<Real> (  mShadow->getData(   )[ Pos + 1] ) / 255;
           }
           else
           {
           return 0.0f;
           }
           }
           else
           {
           return 0.0f;
           }
           }
           //-----------------------------------------------------------------------
      92   void PagingLandScapeData2D_HeightFieldBlendNeighbor::_save(   )
           {
           // Disabled for now
           return;
           uchar *data = new uchar[ mXDimension * mZDimension * 2 ];
          
           const double divider = 65535.0 / mParent->getOptions(   )->scale.y;
          
           unsigned int j = 0;
           for (  unsigned int i = 0; i < mMaxArrayPos; i++ )
           {
           const ushort syn = ushort (  mHeightData[i] * divider );
           #if OGRE_ENDIAN == ENDIAN_BIG
           data[j] = uchar (  (  syn >> 8 ) & 0xff );
           data[j+ 1] = uchar (  syn & 0xff );
           #else
           data[j] = uchar (  syn & 0xff );
           data[j+ 1] = uchar (  (  syn >> 8 ) & 0xff );
           #endif
           j += 2;
           }
          
           const String fname = mParent->getOptions(   )->LandScape_filename + "." +
           StringConverter::toString(  mPageZ ) + "." +
           StringConverter::toString(  mPageX ) + ".";
           const String extname = mParent->getOptions(   )->LandScape_extension;
          
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           mParent->getOptions(   )->groupName,  
           fname + extname );
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           //FileInfo *inf = &(  *it );
           char *olddir = ChangeToDir (  const_cast< char * > (  (  (  it )->archive->getName(   ) ).c_str(   ) ) );
           //FileSystemArchive::pushDirectory(   )
          
           std::ofstream outfile;
           String FileNameRaw;
          
           DataStreamPtr image_chunk(  new MemoryDataStream (  (  void* )data,  
           mXDimension * mZDimension * 2 * sizeof (  uchar ),  
           true ) );
          
           outfile.open (  const_cast< char * > (  (  fname + "modif." + extname ).c_str(   ) ),  
           std::ios::binary );
           // Write out
           outfile << image_chunk->getAsString (   );
           outfile.close (   );
          
          
           //FileSystemArchive::pushDirectory(   );
           RetablishDir (  olddir );
           }
           }
           //-----------------------------------------------------------------------
     149   bool PagingLandScapeData2D_HeightFieldBlendNeighbor::_load(  const unsigned int mX,   const unsigned int mZ )
           {
           const PagingLandScapeOptions *Options = mParent->getOptions(   );
           const String fileName = Options->LandScape_filename;
           const String ext = Options->LandScape_extension;
           const String extModif = "modif." + ext;
          
           const String pageExtZ = "." + StringConverter::toString(  mZ ) + ".";
           const String pageExtX = StringConverter::toString(  mX ) + ".";
           const String pageExtZone = "." + StringConverter::toString(  mZ + 1 ) + ".";
           const String pageExtXone = StringConverter::toString(  mX + 1 ) + ".";
          
           // Load data
           const String strFileName = fileName + pageExtZ + pageExtX;
           const String strRightName = fileName + pageExtZ + pageExtXone;
           const String strBottomName = fileName + pageExtZone + pageExtX;
           const String strBRName = fileName + pageExtZone + pageExtXone;
          
          
           Image *tex = new Image(   );
           Image *t_right = new Image(   );
           Image *t_bottom = new Image(   );
           Image *t_br = new Image(   );
          
           if (  Options->Deformable &&
           ResourceGroupManager::getSingleton(   ).resourceExists(  Options->groupName,   strFileName + extModif ) )
           {
          
           tex->load (  strFileName + extModif,   Options->groupName );
          
          
           if (  tex->getData(   ) == 0 )
           {
           LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,   String(  "PLSM2 : Cannot find map named " ) + strFileName + extModif );
          
           delete tex;
           delete t_right;
           delete t_bottom;
           delete t_br;
          
           return false;
           }
           if (  ResourceGroupManager::getSingleton(   ).resourceExists(  Options->groupName,   strRightName + extModif ) )
           t_right->load (  strRightName + extModif,   Options->groupName );
          
           if (  ResourceGroupManager::getSingleton(   ).resourceExists(  Options->groupName,   strBottomName + extModif ) )
           t_bottom ->load (  strBottomName + extModif,   Options->groupName );
          
           if (  ResourceGroupManager::getSingleton(   ).resourceExists(  Options->groupName,   strBRName + extModif ) )
           t_br->load (  strBRName + extModif,   Options->groupName );
          
          
           }
           else
           {
           tex->load (  strFileName + ext,   Options->groupName );
          
          
           if (  tex->getData(   ) == 0 )
           {
           LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,   String(  "PLSM2 : Cannot find map named " ) + strFileName + ext );
          
           delete tex;
           delete t_right;
           delete t_bottom;
           delete t_br;
          
           return false;
           }
           if (  ResourceGroupManager::getSingleton(   ).resourceExists(  Options->groupName,   strRightName + extModif ) )
           t_right->load (  strRightName + ext,   Options->groupName );
          
           if (  ResourceGroupManager::getSingleton(   ).resourceExists(  Options->groupName,   strBottomName + extModif ) )
           t_bottom ->load (  strBottomName + ext,   Options->groupName );
          
           if (  ResourceGroupManager::getSingleton(   ).resourceExists(  Options->groupName,   strBRName + extModif ) )
           t_br->load (  strBRName + ext,   Options->groupName );
           }
           //DataStreamPtr RawData;
           //RawData = ResourceGroupManager::getSingleton(   ).openResource(  finalName,  
           //mParent->getOptions(   )->groupName );
          
           // Validate size
           // Image size comes from setting (  since RAW is not self-describing )
           // here 16 bits Raw file
           mXDimension = mSize;
           mZDimension = mXDimension;
           mBpp = (  unsigned int )PixelUtil::getNumElemBytes (  tex->getFormat (   ) );;
           mMaxArrayPos = static_cast <unsigned int> (  mSize * mSize );
           const size_t numBytes = mMaxArrayPos * mBpp;
          
           if (  tex->getWidth(   ) != tex->getHeight(   ) ||
           tex->getWidth(   ) != mSize - 1 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           "Texture size (  " + StringConverter::toString(  static_cast<unsigned int> (  tex->getSize(   ) ) ) +
           " ) does not agree with configuration settings.",  
           "PagingLandScapeData2D_HeightFieldBlendNeighbor::_load" );
           }
          
           uchar *pSrc = tex->getData(   );
           uchar *pRight = t_right->getData(   );
           uchar *pBottom = t_bottom->getData(   );
           uchar *pBr = t_br->getData(   );
          
           mMax = static_cast<unsigned int> (  numBytes ) + 1;
           mHeightData = new Real[mMaxArrayPos];
           const double scale = (  1.0 / 255 ) * Options->scale.y;
           mMaxheight = 0.0f;
          
           unsigned int j = 0;
          
          
           for (  unsigned int y = 0; y < tex->getHeight(   ); y++ )
           {
           for (  unsigned int x = 0; x < tex->getWidth(   ); x++ )
           {
           const uchar val = pSrc[ y * (  mSize-1 ) + x];
          
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
          
           // grab the Right Column
           if (  t_right->getData(   ) == 0 )
           {
           // Copy the pixel if we have no right border
           const uchar val = pSrc[ y * (  mSize-1 ) + (  mSize-2 )];
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
           else
           {
           // Copy the right border
           const uchar val = pRight[ y * (  mSize-1 )];
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
           }
           // Generate the bottom row
           for (  unsigned int x = 0; x < tex->getWidth(   ); x++ )
           {
           if (  t_bottom->getData(   ) == 0 )
           {
           const uchar val = pSrc[ (  mSize-2 ) * (  mSize-1 ) + x];
          
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           } else
           {
           const uchar val = pBottom[ x];
          
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
           }
           // Corner Pixel
           if (  t_br->getData(   ) == 0 )
           {
           const uchar val = pSrc[ (  mSize-2 ) * (  mSize-1 ) + (  mSize-2 )];
          
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
           else
           {
           const uchar val = pBr[0];
          
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
          
           delete tex;
           delete t_right;
           delete t_bottom;
           delete t_br;
          
           if (  Options->vertex_shadowed )
           {
           mShadow = new Image(   );
           mShadow->load(  fileName + ".HS" + pageExtZ + pageExtX + "png",  
           Options->groupName );
           //mParent->getOptions(   )->LandScape_extension );
           }
           return true;
           }
          
           //-----------------------------------------------------------------------
     344   void PagingLandScapeData2D_HeightFieldBlendNeighbor::_load(   )
           {
           // Load data
           DataStreamPtr RawData = ResourceGroupManager::getSingleton(   ).openResource(  mParent->getOptions(   )->LandScape_filename +
           "." +
           mParent->getOptions(   )->LandScape_extension,  
           mParent->getOptions(   )->groupName );
          
           // Validate size
           // Image size comes from setting (  since RAW is not self-describing )
           // here 16 bits Raw file
          
           mXDimension = mParent->getOptions(   )->RawWidth;
           mZDimension = mParent->getOptions(   )->RawHeight;
          
           mBpp = 2;
          
           const size_t sourceHeight = mZDimension;
           const size_t sourceWidth = mXDimension;
          
           computePowerof2PlusOneSize (   );
           mSize = mXDimension;
          
           if (  RawData->size(   ) != sourceHeight*sourceWidth*2 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           "RAW size (  " + StringConverter::toString(  static_cast<unsigned int> (  RawData->size(   ) ) ) +
           " ) does not agree with configuration settings.",  
           "PagingLandScapeData2D_HeightFieldBlendNeighbor::_load" );
           }
          
           mMaxArrayPos = static_cast <unsigned int> (  mXDimension * mZDimension );
           const size_t numBytes = mMaxArrayPos * mBpp;
           mMax = static_cast<unsigned int> (  numBytes ) + 1;
          
           mHeightData = new Real[mMaxArrayPos];
           const double scale = (  1.0f / 65535.0f ) * mParent->getOptions(   )->scale.y;
           mMaxheight = 0.0f;
          
          
           MemoryDataStream dc(  RawData,  
           true );
           const uchar *pSrc = dc.getPtr (   );
          
           const unsigned int shift_fill = static_cast <unsigned int> (  mXDimension - sourceWidth );
           unsigned int dest_pos = 0;
           //for some reason water is 65035 in SRTM files...
           const bool srtm_water = mParent->getOptions(   )->SRTM_water;
           for (  unsigned int i = 0; i < sourceHeight; ++i )
           {
           for (  unsigned int j = 0; j < sourceWidth; ++j )
           {
           #if OGRE_ENDIAN == ENDIAN_BIG
           ushort val = *pSrc++ <<8;
           val += *pSrc++;
           #else
           ushort val = *pSrc++;
           val += *pSrc++ <<8;
           #endif
          
           if (  srtm_water && (  val - 65035 ) > 0 )
           val = 0;
          
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[dest_pos++] = h;
           }
           memset (  &mHeightData[dest_pos],   0,   shift_fill );
           dest_pos+= shift_fill;
           }
           }
           //-----------------------------------------------------------------------
     416   void PagingLandScapeData2D_HeightFieldBlendNeighbor::_unload(   )
           {
           delete mShadow;
           mShadow = 0;
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2D_HeightFieldN.cpp

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldN.cpp - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreLogManager.h"
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreImage.h"
          #include "OgreImageCodec.h"
          
          #include "OgreArchiveManager.h"
          
          #include "OgreStringConverter.h"
          
          #include "OgreException.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeOptions.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D_HeightFieldN.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      45   PagingLandScapeData2D* PagingLandScapeData2D_HeightFieldN::newPage(   )
           {
           return new PagingLandScapeData2D_HeightFieldN(  mParent );
           }
           //-----------------------------------------------------------------------
      50   PagingLandScapeData2D_HeightFieldN::PagingLandScapeData2D_HeightFieldN(  PagingLandScapeData2DManager *dataMgr )
           : PagingLandScapeData2D(  dataMgr )
           {
           mImage = 0;
           mCoverage = 0;
           mBase = 0;
           mShadow = 0;
           mMaxheight = mParent->getOptions(   )->scale.y;
           }
          
           //-----------------------------------------------------------------------
      61   PagingLandScapeData2D_HeightFieldN::~PagingLandScapeData2D_HeightFieldN(   )
           {
           PagingLandScapeData2D::unload (   );
           }
          
           //-------------------------------------------------------------------
      67   const Real PagingLandScapeData2D_HeightFieldN::getMaxAbsoluteHeight(  void ) const
           {
           return mParent->getOptions(   )->scale.y;
           }
           //-----------------------------------------------------------------------
      72   const ColourValue PagingLandScapeData2D_HeightFieldN::getBase (  const Real mX,   const Real mZ )
           {
           if (  mBase != 0 )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  mZ * mBase->getWidth(   ) + mX ) * 4 );//4 bytes (  mImage is RGBA )
           if (  mBase->getSize (   ) > Pos )
           {
           const Real divider = 1.0f / 255;
           return ColourValue(  (  Real ) mBase->getData(   )[ Pos + 0] * divider,  
           (  Real ) mBase->getData(   )[ Pos + 1] * divider,  
           (  Real ) mBase->getData(   )[ Pos + 2] * divider,  
           (  Real ) mBase->getData(   )[ Pos + 3] * divider );
           }
           else
           {
           return ColourValue::White;
           }
           }
           else
           {
           return ColourValue::White;
           }
           }
          
           //-----------------------------------------------------------------------
      97   const ColourValue PagingLandScapeData2D_HeightFieldN::getCoverage (  const Real mX,   const Real mZ )
           {
           if (  mCoverage != 0 )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  mZ * mCoverage->getWidth(   ) + mX ) * 4 );//4 bytes (  mImage is RGBA )
           if (  mCoverage->getSize (   ) > Pos )
           {
           const Real divider = 1.0f / 255;
           return ColourValue(  (  Real ) mCoverage->getData(   )[ Pos + 0] * divider,  
           (  Real ) mCoverage->getData(   )[ Pos + 1] * divider,  
           (  Real ) mCoverage->getData(   )[ Pos + 2] * divider,  
           (  Real ) mCoverage->getData(   )[ Pos + 3] * divider );
           }
           else
           {
           return ColourValue::White;
           }
           }
           else
           {
           return ColourValue::White;
           }
           }
          
           //-----------------------------------------------------------------------
     122   const Real PagingLandScapeData2D_HeightFieldN::getShadow (  const Real mX,   const Real mZ,  
     123   const bool &positive )
           {
           if (  mShadow != 0 )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  mZ * mShadow->getWidth(   ) + mX ) * 3 );//3 bytes (  mImage is RGBA )
           if (  mShadow->getSize (   ) > Pos )
           {
           if (  positive )
           return static_cast<Real> (  mShadow->getData(   )[ Pos + 0] ) / 255;
           else
           return static_cast<Real> (  mShadow->getData(   )[ Pos + 1] ) / 255;
           }
           else
           {
           return 0.0f;
           }
           }
           else
           {
           return 0.0f;
           }
           }
          
           //-----------------------------------------------------------------------
     147   const Vector3 PagingLandScapeData2D_HeightFieldN::getNormal (  const Real x,   const Real z )
           {
           #ifndef _LOADEDNORM
           return PagingLandScapeData2D::getNormal(  x,  z );
           #else
           if (  mImage )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  z * mSize + x ) * mBpp );//4 bytes (  mImage is RGBA )
          
           if (  mMax > Pos )
           {
           const Real normalscale = 1.0f / 127.0f;
           return Vector3 (  (  (  Real )(  mImage->getData(   )[Pos + 0] ) - 128.0f ) * normalscale,  
           (  (  Real )(  mImage->getData(   )[Pos + 1] ) - 128.0f ) * normalscale,  
           (  (  Real )(  mImage->getData(   )[Pos + 2] ) - 128.0f ) * normalscale );
           }
           else
           {
           return Vector3::UNIT_Y;
           }
           }
           else
           {
           return Vector3::UNIT_Y;
           }
           #endif //_NOLOAD
           }
           //-----------------------------------------------------------------------
     175   void PagingLandScapeData2D_HeightFieldN::_save(   )
           {
           const Real scale = 256.0 / mParent->getOptions(   )->scale.y;
          
           uchar *img = mImage->getData(   );
           unsigned int j = 0;
           const unsigned int bpp = static_cast <unsigned int> (  mBpp );
           for (  unsigned int i = 0; i < mMax - 1; i += bpp )
           {
           img[ i + (  mBpp - 1 )] = uchar (  mHeightData[j++] * scale );
           }
           const String fname = mParent->getOptions(   )->LandScape_filename + ".HN." +
           StringConverter::toString(  mPageZ ) + "." +
           StringConverter::toString(  mPageX ) + ".";
           const String extname = mParent->getOptions(   )->LandScape_extension;
          
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           mParent->getOptions(   )->groupName,  
           fname + extname );
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           //FileInfo *inf = &(  *it );
           char *olddir = ChangeToDir (  const_cast< char * > (  (  (  it )->archive->getName(   ) ).c_str(   ) ) );
           //FileSystemArchive::pushDirectory(   )
           mImage->save (  fname + "modif." + extname );
           //FileSystemArchive::pushDirectory(   );
           RetablishDir (  olddir );
           }
           }
           //-----------------------------------------------------------------------
     207   bool PagingLandScapeData2D_HeightFieldN::_load(  const unsigned int mX,   const unsigned int mZ )
           {
           const String strFileName = mParent->getOptions(   )->LandScape_filename + ".HN." +
           StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + ".";
          
           String finalName = strFileName +
           "modif." +
           mParent->getOptions(   )->LandScape_extension;
           if (  !(  mParent->getOptions(   )->Deformable &&
           ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  
           finalName ) ) )
           {
           finalName = strFileName +
           mParent->getOptions(   )->LandScape_extension;
           if (  !ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  
           finalName ) )
           {
           LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,   String(  "PLSM2 : Cannot find map named " ) + finalName );
           return false;
           }
           }
           mImage = new Image(   );
           mImage->load (  finalName,   mParent->getOptions(   )->groupName );
          
          
           //check to make sure it's 2^n + 1 size.
           if (  mImage->getWidth(   ) != mImage->getHeight(   ) || !_checkSize(  mImage->getWidth(   ) ) )
           {
           String err = "Error: Invalid heightmap size : " +
           StringConverter::toString(  static_cast <unsigned int> (  mImage->getWidth(   ) ) ) +
           ",  " + StringConverter::toString(  static_cast <unsigned int> (  mImage->getHeight(   ) ) ) +
           ". Should be 2^n+1,   2^n+1";
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   err,   "PagingLandScapeData2D_HeightFieldN::_load" );
           }
          
           mBpp = PixelUtil::getNumElemBytes (  mImage->getFormat (   ) );
           if (  mBpp != 4 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Error: Image is not a RGBA image.(  4 bytes,   32 bits )",  
           "PagingLandScapeData2D_HeightFieldN::_load" );
           }
          
          
           if (  mSize != mImage->getWidth(   ) )
           {
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,   "Error: Declared World size <> Height Map Size.",   "PagingLandScapeData2D_HeightFieldN::_load" );
           }
           mMax = static_cast <unsigned int> (  mSize * mImage->getHeight(   ) * mBpp + 1 );
          
           if (  mParent->getOptions(   )->coverage_vertex_color )
           {
           mCoverage = new Image(   );
           mCoverage->load(  mParent->getOptions(   )->LandScape_filename +
           ".Coverage." +
           StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + "." +
           mParent->getOptions(   )->LandScape_extension,   mParent->getOptions(   )->groupName );
          
           }
           if (  mParent->getOptions(   )->base_vertex_color )
           {
           mBase = new Image(   );
           mBase->load(  mParent->getOptions(   )->LandScape_filename +
           ".Base." +
           StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + "." +
           mParent->getOptions(   )->LandScape_extension,   mParent->getOptions(   )->groupName );
           }
          
           if (  mParent->getOptions(   )->vertex_shadowed )
           {
           mShadow = new Image(   );
           mShadow->load(  mParent->getOptions(   )->LandScape_filename +
           ".HS." +
           StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + "." +
           mParent->getOptions(   )->LandScape_extension,   mParent->getOptions(   )->groupName );
           }
          
           mXDimension = mImage->getWidth(   );
           mZDimension = mImage->getHeight(   );
           mMaxArrayPos = static_cast <unsigned int> (  mSize * mImage->getHeight(   ) );
           mHeightData = new Real[mMaxArrayPos];
           unsigned int j = 0;
           const double scale = mParent->getOptions(   )->scale.y / 256;
           mMaxheight = 0.0f;
           uchar *imagedata = mImage->getData(   );
           const unsigned int bpp = static_cast <unsigned int> (  mBpp );
           for (  unsigned int i = 0; i < mMax - 1; i += bpp )
           {
           const Real h = imagedata[ i + (  bpp - 1 )] * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
           return true;
           }
          
           //-----------------------------------------------------------------------
     306   void PagingLandScapeData2D_HeightFieldN::_load(   )
           {
          
           mImage = new Image(   );
          
          
           mImage->load (  mParent->getOptions(   )->LandScape_filename +
           "." + mParent->getOptions(   )->LandScape_extension,   mParent->getOptions(   )->groupName );
          
          
           //check to make sure it's 2^n size.
           if (  !_checkSize(  mImage->getHeight(   ) ) || !_checkSize(  mImage->getWidth(   ) ) )
           {
           String err = "Error: Invalid heightmap size : " +
           StringConverter::toString(  static_cast <unsigned int> (  mImage->getWidth(   ) ) ) +
           ",  " + StringConverter::toString(  static_cast <unsigned int> (  mImage->getHeight(   ) ) ) +
           ". Should be 2^n";
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   err,   "PagingLandScapeData2D_HeightFieldN::_load" );
           }
          
           mBpp = static_cast <unsigned int> (  PixelUtil::getNumElemBytes (  mImage->getFormat (   ) ) );
           if (  mBpp != 1 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Error: Image is not a greyscale image.(  1 byte,   8 bits )",  
           "PagingLandScapeData2D_HeightFieldN::_load" );
           }
          
           mXDimension = mImage->getWidth(   );
           mZDimension = mImage->getHeight(   );
           mSize = mImage->getWidth(   );
           mMax = static_cast <unsigned int> (  mSize * mImage->getHeight(   ) * mBpp );
          
           mMaxArrayPos = static_cast <unsigned int> (  mSize * mImage->getHeight(   ) );
           mHeightData = new Real[mMaxArrayPos];
          
           const double scale = mParent->getOptions(   )->scale.y / 256;
           mMaxheight = 0.0f;
           uchar *imagedata = mImage->getData(   );
           for (  unsigned int i = 0; i < mMax; i ++ )
           {
           const Real h = imagedata[i] * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[i] = h;
           }
          
           }
           //-----------------------------------------------------------------------
     353   void PagingLandScapeData2D_HeightFieldN::_unload(   )
           {
           delete mImage;
           mImage = 0;
           delete mCoverage;
           mCoverage = 0;
           delete mBase;
           mBase = 0;
           delete mShadow;
           mShadow = 0;
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2D_HeightFieldNTC.cpp

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldNTC.cpp - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreLogManager.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreImage.h"
          #include "OgreStringConverter.h"
          
          #include "OgreException.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeOptions.h"
          
          #include "OgrePagingLandScapeData2D_HeightFieldNTC.h"
          
          
          #include "fileutils.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      43   PagingLandScapeData2D* PagingLandScapeData2D_HeightFieldNTC::newPage(   )
           {
           return new PagingLandScapeData2D_HeightFieldNTC(  mParent );
           }
           //-----------------------------------------------------------------------
      48   PagingLandScapeData2D_HeightFieldNTC::PagingLandScapeData2D_HeightFieldNTC(  PagingLandScapeData2DManager *dataMgr )
           : PagingLandScapeData2D(  dataMgr )
           {
           mImage = 0;
           input_max = 3000.0f;
           input_min = 0.0f;
           mMaxheight = _decodeTC (  1.0f ) * mParent->getOptions(   )->scale.y;
           }
          
           //-------------------------------------------------------------------
      58   const Real PagingLandScapeData2D_HeightFieldNTC::getMaxAbsoluteHeight(  void ) const
           {
           return _decodeTC (  1.0f ) * mParent->getOptions(   )->scale.y;
           }
           //-----------------------------------------------------------------------
      63   PagingLandScapeData2D_HeightFieldNTC::~PagingLandScapeData2D_HeightFieldNTC(   )
           {
           }
           //-----------------------------------------------------------------------
      67   const ColourValue PagingLandScapeData2D_HeightFieldNTC::getBase (  const Real mX,   const Real mZ )
           {
           return ColourValue::White;
           }
          
           //-----------------------------------------------------------------------
      73   const ColourValue PagingLandScapeData2D_HeightFieldNTC::getCoverage (  const Real mX,   const Real mZ )
           {
           return ColourValue::White;
           }
           //-----------------------------------------------------------------------
      78   const Vector3 PagingLandScapeData2D_HeightFieldNTC::getNormalAt (  const Real x,   const Real z )
           {
           #ifndef _LOADEDNORM
           return PagingLandScapeData2D::getNormal(  x,  z );
           #else
           if (  mImage )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  z * mSize + x ) * mBpp );//4 bytes (  mImage is RGBA )
          
           if (  mMax > Pos )
           {
           const Real normalscale = 1.0f / 127.0f;
           return Vector3 (  (  (  Real )(  mImage->getData(   )[Pos + 0] ) - 128.0f ) * normalscale,  
           (  (  Real )(  mImage->getData(   )[Pos + 1] ) - 128.0f ) * normalscale,  
           (  (  Real )(  mImage->getData(   )[Pos + 2] ) - 128.0f ) * normalscale );
           }
           else
           {
           return Vector3::UNIT_Y;
           }
           }
           else
           {
           return Vector3::UNIT_Y;
           }
           #endif //_NOLOAD
          
           }
           //-----------------------------------------------------------------------
     107   void PagingLandScapeData2D_HeightFieldNTC::_save(   )
           {
          
           const Real scale = 1.0f / mParent->getOptions(   )->scale.y;
          
           uchar *img = mImage->getData(   );
           unsigned int j = 0;
           const unsigned int bpp = static_cast <unsigned int> (  mBpp );
           for (  unsigned int i = 0; i < mMax - 1; i += bpp )
           {
           img[ i + (  mBpp - 1 )] = uchar (  _encodeTC(  mHeightData[j++] ) * scale );
           }
           const String fname = mParent->getOptions(   )->LandScape_filename + ".HN." +
           StringConverter::toString(  mPageZ ) + "." +
           StringConverter::toString(  mPageX ) + ".";
           const String extname = mParent->getOptions(   )->LandScape_extension;
          
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           mParent->getOptions(   )->groupName,  
           fname + extname );
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           //FileInfo *inf = &(  *it );
           char *olddir = ChangeToDir (  const_cast< char * > (  (  (  it )->archive->getName(   ) ).c_str(   ) ) );
           //FileSystemArchive::pushDirectory(   )
           mImage->save (  fname + "modif." + extname );
           //FileSystemArchive::pushDirectory(   );
           RetablishDir (  olddir );
           }
          
           }
           //-----------------------------------------------------------------------
     141   bool PagingLandScapeData2D_HeightFieldNTC::_load(  const unsigned int mX,   const unsigned int mZ )
           {
           const String strFileName = mParent->getOptions(   )->LandScape_filename + ".HN." +
           StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + ".";
          
           String finalName = strFileName +
           "modif." +
           mParent->getOptions(   )->LandScape_extension;
           if (  !(  mParent->getOptions(   )->Deformable &&
           ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  
           finalName ) ) )
           {
           finalName = strFileName +
           mParent->getOptions(   )->LandScape_extension;
           if (  !ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  
           finalName ) )
           {
           LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,   String(  "PLSM2 : Cannot find map named " ) + finalName );
           return false;
           }
           }
           mImage = new Image(   );
           mImage->load (  finalName,   mParent->getOptions(   )->groupName );
          
           //check to make sure it's 2^n + 1 size.
           if (  mImage->getWidth(   ) != mImage->getHeight(   ) || !_checkSize(  mImage->getWidth(   ) ) )
           {
           String err = "Error: Invalid heightmap size : " +
           StringConverter::toString(  static_cast <unsigned int> (  mImage->getWidth(   ) ) ) +
           ",  " + StringConverter::toString(  static_cast <unsigned int> (  mImage->getHeight(   ) ) ) +
           ". Should be 2^n+1,   2^n+1";
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   err,   "PagingLandScapeData2D_HeightField::_load" );
           }
          
           mBpp = PixelUtil::getNumElemBytes (  mImage->getFormat (   ) );
           if (  mBpp != 4 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Error: Image is not a RGBA image.(  4 bytes,   32 bits )",  
           "PagingLandScapeData2D_HeightField::_load" );
           }
          
           if (  mSize != mImage->getWidth(   ) )
           {
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,   "Error: Declared World size <> Height Map Size.",   "PagingLandScapeData2D_HeightField::_load" );
           }
          
           mXDimension = mImage->getWidth(   );
           mZDimension = mImage->getHeight(   );
           mMax = static_cast <unsigned int> (  mSize * mImage->getHeight(   ) * mBpp + 1 );
          
           mMaxArrayPos = static_cast <unsigned int> (  mSize * mImage->getHeight(   ) );
           mHeightData = new Real[mMaxArrayPos];
           unsigned int j = 0;
           const double divider = 1.0 / 255;
           const Real scale = mParent->getOptions(   )->scale.y;
           uchar *data = mImage->getData(   );
           mMaxheight = 0.0f;
           const unsigned int bpp = static_cast <unsigned int> (  mBpp );
           for (  unsigned int i = 0; i < mMax - 1; i += bpp )
           {
           const Real h = _decodeTC(  data[ i + (  mBpp - 1 )] * divider )* scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
           return true;
           }
           //-----------------------------------------------------------------------
     209   void PagingLandScapeData2D_HeightFieldNTC::_load(   )
           {
          
           mImage = new Image(   );
          
           mImage->load(  mParent->getOptions(   )->LandScape_filename +
           "." + mParent->getOptions(   )->LandScape_extension,  
           mParent->getOptions(   )->groupName );
          
           //check to make sure it's 2^n size.
           if (  !_checkSize(  mImage->getHeight(   ) ) || !_checkSize(  mImage->getWidth(   ) ) )
           {
           String err = "Error: Invalid heightmap size : " +
           StringConverter::toString(  static_cast <unsigned int> (  mImage->getWidth(   ) ) ) +
           ",  " + StringConverter::toString(  static_cast <unsigned int> (  mImage->getHeight(   ) ) ) +
           ". Should be 2^n,   2^n";
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   err,   "PagingLandScapeData2D_HeightFieldNTC::_load" );
           }
          
           mBpp = PixelUtil::getNumElemBytes (  mImage->getFormat (   ) );
           if (  mBpp != 1 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Error: Image is not a grayscale image.(  1 byte,   8 bits )",  
           "PagingLandScapeData2D_HeightFieldNTC::_load" );
           }
          
           mSize = static_cast <unsigned int> (  mImage->getWidth(   ) );
           mMax = static_cast <unsigned int> (  mSize * mImage->getHeight(   ) * mBpp + 1 );
          
           mMaxArrayPos = static_cast <unsigned int> (  mSize * mImage->getHeight(   ) );
           mHeightData = new Real[mMaxArrayPos];
           unsigned int j = 0;
           const double divider = 1.0 / 255;
           const Real scale = mParent->getOptions(   )->scale.y;
           uchar *data = mImage->getData(   );
           mMaxheight = 0.0f;
           const unsigned int bpp = static_cast <unsigned int> (  mBpp );
           for (  unsigned int i = 0; i < mMax - 1; i += bpp )
           {
           const Real h = _decodeTC(  data[ i + (  mBpp - 1 )] * divider )* scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
          
           }
          
          
           //-----------------------------------------------------------------------
     257   void PagingLandScapeData2D_HeightFieldNTC::_unload(   )
           {
           delete mImage;
           mImage = 0;
           }
          
           //-----------------------------------------------------------------------
     264   inline Real PagingLandScapeData2D_HeightFieldNTC::_decodeTC(  const Real encoded ) const
           {
           return (  (  Real ) (  encoded + 0.5f ) ) * (  input_max - input_min ) + input_min;
           }
          
           //-----------------------------------------------------------------------
     270   inline uchar PagingLandScapeData2D_HeightFieldNTC::_encodeTC(  const Real decoded ) const
           {
           return static_cast<uchar> (  (  decoded - input_min ) / (  input_max - input_min ) - 0.5f );
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2D_HeightFieldRaw.cpp

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldRaw.cpp - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreLogManager.h"
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreImage.h"
          #include "OgreStringConverter.h"
          
          #include "OgreResourceManager.h"
          
          
          #include "OgreException.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeOptions.h"
          
          #include "OgrePagingLandScapeData2D_HeightFieldRaw.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      44   PagingLandScapeData2D* PagingLandScapeData2D_HeightFieldRaw::newPage(   )
           {
           return new PagingLandScapeData2D_HeightFieldRaw(  mParent );
           }
           //-----------------------------------------------------------------------
      49   PagingLandScapeData2D_HeightFieldRaw::PagingLandScapeData2D_HeightFieldRaw(  PagingLandScapeData2DManager *dataMgr )
           : PagingLandScapeData2D(  dataMgr )
           {
           mShadow = 0;
           mMaxheight = mParent->getOptions(   )->scale.y;
           }
           //-------------------------------------------------------------------
      56   const Real PagingLandScapeData2D_HeightFieldRaw::getMaxAbsoluteHeight(  void ) const
           {
           return mParent->getOptions(   )->scale.y;
           }
           //-----------------------------------------------------------------------
      61   PagingLandScapeData2D_HeightFieldRaw::~PagingLandScapeData2D_HeightFieldRaw(   )
           {
           }
          
           //-----------------------------------------------------------------------
      66   const Real PagingLandScapeData2D_HeightFieldRaw::getShadow (  const Real mX,   const Real mZ,  
      67   const bool &positive )
           {
           if (  mShadow )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  mZ * mShadow->getWidth(   ) + mX ) * 3 );//3 bytes (  mImage is RGBA )
           if (  mShadow->getSize (   ) > Pos )
           {
           if (  positive )
           return static_cast<Real> (  mShadow->getData(   )[ Pos + 0] ) / 255;
           else
           return static_cast<Real> (  mShadow->getData(   )[ Pos + 1] ) / 255;
           }
           else
           {
           return 0.0f;
           }
           }
           else
           {
           return 0.0f;
           }
           }
           //-----------------------------------------------------------------------
      90   void PagingLandScapeData2D_HeightFieldRaw::_save(   )
           {
           uchar *data = new uchar[ mXDimension * mZDimension * 2 ];
          
           const double divider = 65535.0 / mParent->getOptions(   )->scale.y;
          
           unsigned int j = 0;
           for (  unsigned int i = 0; i < mMaxArrayPos; i++ )
           {
           const ushort syn = ushort (  mHeightData[i] * divider );
           #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
           data[j] = uchar (  (  syn >> 8 ) & 0xff );
           data[j+ 1] = uchar (  syn & 0xff );
           #else
           data[j] = uchar (  syn & 0xff );
           data[j+ 1] = uchar (  (  syn >> 8 ) & 0xff );
           #endif
           j += 2;
           }
          
           const String fname = mParent->getOptions(   )->LandScape_filename + "." +
           StringConverter::toString(  mPageZ ) + "." +
           StringConverter::toString(  mPageX ) + ".";
           const String extname = mParent->getOptions(   )->LandScape_extension;
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           mParent->getOptions(   )->groupName,  
           fname + extname );
           //ResourceGroupManager::getSingleton(   ).openResource (   )
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           //FileInfo *inf = &(  *it );
           char *olddir = ChangeToDir (  const_cast< char * > (  (  (  it )->archive->getName(   ) ).c_str(   ) ) );
           //FileSystemArchive::pushDirectory(   )
          
           std::ofstream outfile;
           String FileNameRaw;
          
           DataStreamPtr image_chunk(  new MemoryDataStream (  (  void* )data,  
           mXDimension * mZDimension * 2 * sizeof (  uchar ),  
           true ) );
           outfile.open (  const_cast< char * > (  (  fname + "modif." + extname ).c_str(   ) ),  
           std::ios::binary );
           // Write out
           outfile << image_chunk->getAsString (   );
           outfile.close (   );
          
          
           //FileSystemArchive::pushDirectory(   );
           RetablishDir (  olddir );
           }
           }
           //-----------------------------------------------------------------------
     144   bool PagingLandScapeData2D_HeightFieldRaw::_load(  const unsigned int mX,   const unsigned int mZ )
           {
           // Load data
           const String strFileName = mParent->getOptions(   )->LandScape_filename + "." +
           StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + ".";
          
           String finalName = strFileName +
           "modif." +
           mParent->getOptions(   )->LandScape_extension;
          
           if (  !(  mParent->getOptions(   )->Deformable &&
           ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  finalName ) ) )
           {
           finalName = strFileName + mParent->getOptions(   )->LandScape_extension;
           if (  !ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  finalName ) )
           {
           LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,   String(  "PLSM2 : Cannot find map named " ) + finalName );
           return false;
           }
           }
          
           DataStreamPtr RawData;
           RawData = ResourceGroupManager::getSingleton(   ).openResource(  finalName,  
           mParent->getOptions(   )->groupName );
          
          
           // Validate size
           // Image size comes from setting (  since RAW is not self-describing )
           // here 16 bits Raw file
           mXDimension = mSize;
           mZDimension = mXDimension;
           mBpp = 2;
           mMaxArrayPos = static_cast <unsigned int> (  mSize * mSize );
           const size_t numBytes = mMaxArrayPos * mBpp;
           if (  RawData->size(   ) != numBytes )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           "RAW size (  " + StringConverter::toString(  static_cast<unsigned int> (  RawData->size(   ) ) ) +
           " ) does not agree with configuration settings.",  
           "PagingLandScapeData2D_HeightFieldRaw::_load" );
           }
           mMax = static_cast<unsigned int> (  numBytes ) + 1;
          
           mHeightData = new Real[mMaxArrayPos];
           const double scale = (  double ) mParent->getOptions(   )->scale.y / 65535;
           mMaxheight = 0.0f;
          
           MemoryDataStream dc (  RawData,  
           true );
           const uchar *pSrc = dc.getPtr (   );
          
           unsigned int j = 0;
           for (  unsigned int i = 0; i < mMax - 1; i += mBpp )
           {
           #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
           ushort val = *pSrc++ <<8;
           val += *pSrc++;
           #else
           ushort val = *pSrc++;
           val += *pSrc++ <<8;
           #endif
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
          
          
           if (  mParent->getOptions(   )->vertex_shadowed )
           {
           mShadow = new Image(   );
           mShadow->load(  mParent->getOptions(   )->LandScape_filename +
           ".HS." +
           StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + "." +
           "png",  
           mParent->getOptions(   )->groupName );
           //mParent->getOptions(   )->LandScape_extension );
           }
           return true;
           }
          
           //-----------------------------------------------------------------------
     227   void PagingLandScapeData2D_HeightFieldRaw::_load(   )
           {
           // Load data
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
           const String mName(  opt->LandScape_filename + "." + opt->LandScape_extension );
           const String gName (  opt->groupName );
           ResourceGroupManager *rsm = ResourceGroupManager::getSingletonPtr(   );
           DataStreamPtr RawData = rsm->openResource(  mName,   gName );
          
           // Validate size
           // Image size comes from setting (  since RAW is not self-describing )
           // here 16 bits Raw file
          
           mXDimension = opt->RawWidth;
           mZDimension = opt->RawHeight;
          
           mBpp = 2;
          
           const size_t sourceHeight = mZDimension;
           const size_t sourceWidth = mXDimension;
          
           computePowerof2PlusOneSize (   );
           mSize = mXDimension;
          
           if (  RawData->size(   ) != sourceHeight*sourceWidth*2 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           "RAW size (  " + StringConverter::toString(  static_cast<unsigned int> (  RawData->size(   ) ) ) +
           " ) does not agree with configuration settings.",  
           "PagingLandScapeData2D_HeightFieldRaw::_load" );
           }
          
           mMaxArrayPos = static_cast <unsigned int> (  mXDimension * mZDimension );
           const size_t numBytes = mMaxArrayPos * mBpp;
           mMax = static_cast<unsigned int> (  numBytes ) + 1;
          
           mHeightData = new Real[mMaxArrayPos];
           const Real scale = opt->ScaledHeightY;
           mMaxheight = 0.0f;
          
          
           MemoryDataStream dc(  RawData,  
           true );
           const uchar *pSrc = dc.getPtr (   );
          
           const unsigned int shift_fill = static_cast <unsigned int> (  mXDimension - sourceWidth );
           unsigned int dest_pos = 0;
           //for some reason water is 65035 in SRTM files...
           const bool srtm_water = opt->SRTM_water;
           for (  unsigned int i = 0; i < sourceHeight; ++i )
           {
           for (  unsigned int j = 0; j < sourceWidth; ++j )
           {
           #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
           ushort val = *pSrc++ << 8;
           val += *pSrc++;
           #else
           ushort val = *pSrc++;
           val += *pSrc++ << 8;
           #endif
          
           if (  srtm_water && (  val - 65035 ) > 0 )
           val = 0;
          
           const Real h = val * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[dest_pos++] = h;
           }
           memset (  &mHeightData[dest_pos],   0,   shift_fill );
           dest_pos+= shift_fill;
           }
           }
           //-----------------------------------------------------------------------
     300   void PagingLandScapeData2D_HeightFieldRaw::_unload(   )
           {
           delete mShadow;
           mShadow = 0;
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2D_HeightFieldRawTC.cpp

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldRawTC.cpp - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreLogManager.h"
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreImage.h"
          #include "OgreStringConverter.h"
          
          #include "OgreResourceManager.h"
          
          #include "OgreException.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeOptions.h"
          
          #include "OgrePagingLandScapeData2D_HeightFieldRawTC.h"
          
          #include "fileutils.h"
          
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      44   PagingLandScapeData2D* PagingLandScapeData2D_HeightFieldRawTC::newPage(   )
           {
           return new PagingLandScapeData2D_HeightFieldRawTC(  mParent );
           }
           //-----------------------------------------------------------------------
      49   PagingLandScapeData2D_HeightFieldRawTC::PagingLandScapeData2D_HeightFieldRawTC(  PagingLandScapeData2DManager *dataMgr )
           : PagingLandScapeData2D(  dataMgr )
           {
           mImage = 0;
           input_max = 3000.0f;
           input_min = 0.0f;
           mMaxheight = _decodeRawTC (  1.0f ) * mParent->getOptions(   )->scale.y;
           }
           //-------------------------------------------------------------------
      58   const Real PagingLandScapeData2D_HeightFieldRawTC::getMaxAbsoluteHeight(  void ) const
           {
           return _decodeRawTC (  1.0f ) * mParent->getOptions(   )->scale.y;
           }
          
           //-----------------------------------------------------------------------
      64   PagingLandScapeData2D_HeightFieldRawTC::~PagingLandScapeData2D_HeightFieldRawTC(   )
           {
           }
           //-----------------------------------------------------------------------
      68   const ColourValue PagingLandScapeData2D_HeightFieldRawTC::getBase (  const Real mX,   const Real mZ )
           {
           return ColourValue::White;
           }
          
           //-----------------------------------------------------------------------
      74   const ColourValue PagingLandScapeData2D_HeightFieldRawTC::getCoverage (  const Real mX,   const Real mZ )
           {
           return ColourValue::White;
           }
           //-----------------------------------------------------------------------
      79   const Vector3 PagingLandScapeData2D_HeightFieldRawTC::getNormalAt (  const Real x,   const Real z )
           {
           #ifndef _LOADEDNORM
           return PagingLandScapeData2D::getNormal(  x,  z );
           #else
           if (  mImage )
           {
           unsigned int Pos = static_cast<unsigned int> (  (  z * mSize + x ) * mBpp );//4 bytes (  mImage is RGBA )
          
           if (  mMax > Pos )
           {
           const Real normalscale = 1.0f / 127.0f;
           return Vector3 (  (  (  Real )(  mImage->getData(   )[Pos + 0] ) - 128.0f ) * normalscale,  
           (  (  Real )(  mImage->getData(   )[Pos + 1] ) - 128.0f ) * normalscale,  
           (  (  Real )(  mImage->getData(   )[Pos + 2] ) - 128.0f ) * normalscale );
           }
           else
           {
           return Vector3::UNIT_Y;
           }
           }
           else
           {
           return Vector3::UNIT_Y;
           }
           #endif //_NOLOAD
           }
           //-----------------------------------------------------------------------
     107   void PagingLandScapeData2D_HeightFieldRawTC::_save(   )
           {
           uchar *data = new uchar[ mXDimension * mZDimension * 2 ];
          
           const double divider = 65535.0 / mParent->getOptions(   )->scale.y;
          
           unsigned int j = 0;
           for (  unsigned int i = 0; i < mXDimension*mZDimension; i++ )
           {
           ushort syn = static_cast <ushort> (  _encodeRawTC (  mHeightData[i] ) * divider );
           #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
           data[j] = uchar (  (  syn >> 8 ) & 0xff );
           data[j+ 1] = uchar (  syn & 0xff );
           #else
           data[j] = uchar (  syn & 0xff );
           data[j+ 1] = uchar (  (  syn >> 8 ) & 0xff );
           #endif
           j += 2;
           }
           const String fname = mParent->getOptions(   )->LandScape_filename + "." +
           StringConverter::toString(  mPageZ ) + "." +
           StringConverter::toString(  mPageX ) + ".";
           const String extname = mParent->getOptions(   )->LandScape_extension;
          
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           mParent->getOptions(   )->groupName,  
           fname + extname );
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           //FileInfo *inf = &(  *it );
           char *olddir = ChangeToDir (  const_cast< char * > (  (  (  it )->archive->getName(   ) ).c_str(   ) ) );
           //FileSystemArchive::pushDirectory(   )
          
           std::ofstream outfile;
           String FileNameRaw;
          
           DataStreamPtr image_chunk(  new MemoryDataStream (  (  void* )data,  
           mXDimension * mZDimension * 2 * sizeof (  uchar ),  
           true ) );
          
           outfile.open (  const_cast< char * > (  (  fname + "modif." + extname ).c_str(   ) ),  
           std::ios::binary );
           // Write out
           outfile << image_chunk->getAsString (   );
           outfile.close (   );
          
          
           //FileSystemArchive::pushDirectory(   );
           RetablishDir (  olddir );
           }
           }
           //-----------------------------------------------------------------------
     161   bool PagingLandScapeData2D_HeightFieldRawTC::_load(  const unsigned int mX,   const unsigned int mZ )
           {
           // Load data
           //mRawData.clear(   );
          
           const String strFileName = mParent->getOptions(   )->LandScape_filename + "." +
           StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + ".";
          
          
           String finalName = strFileName +
           "modif." +
           mParent->getOptions(   )->LandScape_extension;
           if (  !(  mParent->getOptions(   )->Deformable &&
           ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  finalName ) ) )
           {
           finalName = strFileName +
           mParent->getOptions(   )->LandScape_extension;
           if (  !ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  finalName ) )
           {
           LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,   String(  "PLSM2 : Cannot find map named " ) + finalName );
           return false;
           }
           }
           DataStreamPtr RawData;
           RawData = ResourceGroupManager::getSingleton(   ).openResource(  finalName,  
           mParent->getOptions(   )->groupName );
          
           // Validate size
           // Image size comes from setting (  since RAW is not self-describing )
           // here 16 bits Raw file
           mXDimension = mSize;
           mZDimension = mXDimension;
           mBpp = 2;
          
           size_t numBytes = mSize * mSize * mBpp;
           if (  RawData->size(   ) != numBytes )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           " ) does not agree with configuration settings.",  
           "PagingLandScapeData2D_HeightFieldRaw::_load" );
           }
           mMax = static_cast<unsigned int> (  numBytes ) + 1;
          
           mMaxArrayPos = static_cast <unsigned int> (  mSize * mSize );
           mHeightData = new Real[mMaxArrayPos];
          
           const Real divider = 1.0f / 65535.0f;
           const Real scale = mParent->getOptions(   )->scale.y;
          
           MemoryDataStream dc (  RawData,  
           true );
           const uchar *pSrc = dc.getPtr (   );
          
           mMaxheight = 0.0f;
           unsigned int j = 0;
           for (  unsigned int i = 0; i < mMax - 1; i += mBpp )
           {
           #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
           ushort val = *pSrc++ <<8;
           val += *pSrc++;
           #else
           ushort val = *pSrc++;
           val += *pSrc++ <<8;
           #endif
           const Real h = _decodeRawTC (  val * divider )* scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
          
          // if (  mParent->getOptions(   )->vertex_shadowed )
          // {
          // mShadow = new Image(   );
          // mShadow->load(  mParent->getOptions(   )->LandScape_filename +
          // ".HS." +
          // StringConverter::toString(  mZ ) + "." +
          // StringConverter::toString(  mX ) + "." +
          // "png" );
          // //mParent->getOptions(   )->LandScape_extension );
          // }
           return true;
           }
           //-----------------------------------------------------------------------
     244   void PagingLandScapeData2D_HeightFieldRawTC::_load(   )
           {
           // Load data
           DataStreamPtr RawData = ResourceGroupManager::getSingleton(   ).openResource(  mParent->getOptions(   )->LandScape_filename +
           "." +
           mParent->getOptions(   )->LandScape_extension,  
           mParent->getOptions(   )->groupName );
          
           // Validate size
           // Image size comes from setting (  since RAW is not self-describing )
           // here 16 bits Raw file
          
           mXDimension = mParent->getOptions(   )->RawWidth;
           mZDimension = mParent->getOptions(   )->RawHeight;
          
           mBpp = 2;
          
           const size_t sourceHeight = mZDimension;
           const size_t sourceWidth = mXDimension;
          
           computePowerof2PlusOneSize (   );
           mSize = mXDimension;
          
           if (  RawData->size(   ) != sourceHeight*sourceWidth*2 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           "RAW size (  " + StringConverter::toString(  static_cast<unsigned int> (  RawData->size(   ) ) ) +
           " ) does not agree with configuration settings.",  
           "PagingLandScapeData2D_HeightFieldRaw::_load" );
           }
          
           mMaxArrayPos = static_cast <unsigned int> (  mXDimension * mZDimension );
           const size_t numBytes = mMaxArrayPos * mBpp;
           mMax = static_cast<unsigned int> (  numBytes ) + 1;
          
           mHeightData = new Real[mMaxArrayPos];
          
           mMaxheight = 0.0f;
          
          
           MemoryDataStream dc(  RawData,  
           true );
           const uchar *pSrc = dc.getPtr (   );
          
           const Real divider = 1.0f / 65535.0f;
           const Real scale = mParent->getOptions(   )->scale.y;
           const unsigned int shift_fill = static_cast <unsigned int> (  mXDimension - sourceWidth );
           unsigned int dest_pos = 0;
           //for some reason water is 65035 in SRTM files...
           const bool srtm_water = mParent->getOptions(   )->SRTM_water;
           for (  unsigned int i = 0; i < sourceHeight; ++i )
           {
           for (  unsigned int j = 0; j < sourceWidth; ++j )
           {
           #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
           ushort val = *pSrc++ <<8;
           val += *pSrc++;
           #else
           ushort val = *pSrc++;
           val += *pSrc++ <<8;
           #endif
          
           if (  srtm_water && (  val - 65035 ) > 0 )
           val = 0;
          
           const Real h = _decodeRawTC (  val * divider ) * scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[dest_pos++] = h;
           }
           memset (  &mHeightData[dest_pos],   0,   shift_fill );
           dest_pos+= shift_fill;
           }
           }
          
          
           //-----------------------------------------------------------------------
     320   void PagingLandScapeData2D_HeightFieldRawTC::_unload(   )
           {
           delete mImage;
           mImage = 0;
           }
          
           //-----------------------------------------------------------------------
     327   inline Real PagingLandScapeData2D_HeightFieldRawTC::_decodeRawTC(  const Real encoded ) const
           {
           return (  (  Real ) (  encoded + 0.5f ) ) * (  input_max - input_min ) + input_min;
           }
           //-----------------------------------------------------------------------
     332   inline ushort PagingLandScapeData2D_HeightFieldRawTC::_encodeRawTC(  const Real decoded ) const
           {
           return static_cast <short> (  (  decoded - input_min ) / (  input_max - input_min ) - 0.5f );
           }
          
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2D_HeightFieldTC.cpp

       1  /***************************************************************************
           OgrePagingLandScapeData2D_HeightFieldTC.cpp - description
           -------------------
           begin : Mon Oct 13 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          
          #include "OgreLogManager.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreImage.h"
          #include "OgreStringConverter.h"
          
          #include "OgreException.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeOptions.h"
          
          #include "OgrePagingLandScapeData2D_HeightFieldTC.h"
          
          
          #include "fileutils.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      44   PagingLandScapeData2D* PagingLandScapeData2D_HeightFieldTC::newPage(   )
           {
           return new PagingLandScapeData2D_HeightFieldTC(  mParent );
           }
           //-----------------------------------------------------------------------
      49   PagingLandScapeData2D_HeightFieldTC::PagingLandScapeData2D_HeightFieldTC(  PagingLandScapeData2DManager *dataMgr )
           : PagingLandScapeData2D(  dataMgr )
           {
           mImage = 0;
           input_max = 3000.0f;
           input_min = 0.0f;
           mMaxheight = _decodeTC (  1.0f ) * mParent->getOptions(   )->scale.y;
           }
           //-------------------------------------------------------------------
      58   const Real PagingLandScapeData2D_HeightFieldTC::getMaxAbsoluteHeight(  void ) const
           {
           return _decodeTC (  1.0f ) * mParent->getOptions(   )->scale.y;
           }
          
           //-----------------------------------------------------------------------
      64   PagingLandScapeData2D_HeightFieldTC::~PagingLandScapeData2D_HeightFieldTC(   )
           {
           }
           //-----------------------------------------------------------------------
      68   const ColourValue PagingLandScapeData2D_HeightFieldTC::getBase (  const Real mX,   const Real mZ )
           {
           return ColourValue::White;
           }
          
           //-----------------------------------------------------------------------
      74   const ColourValue PagingLandScapeData2D_HeightFieldTC::getCoverage (  const Real mX,   const Real mZ )
           {
           return ColourValue::White;
           }
           //-----------------------------------------------------------------------
      79   void PagingLandScapeData2D_HeightFieldTC::_save(   )
           {
          
           const Real scale = 1.0f / mParent->getOptions(   )->scale.y;
          
           uchar *img = mImage->getData(   );
           unsigned int j = 0;
           for (  unsigned int i = 0; i < mMax - 1; i ++ )
           {
           img[ i ] = uchar (  _encodeTC(  mHeightData[j++] ) * scale );
           }
           const String fname = mParent->getOptions(   )->LandScape_filename + "." +
           StringConverter::toString(  mPageZ ) + "." +
           StringConverter::toString(  mPageX ) + ".";
           const String extname = mParent->getOptions(   )->LandScape_extension;
          
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           mParent->getOptions(   )->groupName,  
           fname + extname );
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           //FileInfo *inf = &(  *it );
           char *olddir = ChangeToDir (  const_cast< char * > (  (  (  it )->archive->getName(   ) ).c_str(   ) ) );
           //FileSystemArchive::pushDirectory(   )
           mImage->save (  fname + "modif." + extname );
           //FileSystemArchive::pushDirectory(   );
           RetablishDir (  olddir );
           }
          
           }
           //-----------------------------------------------------------------------
     112   bool PagingLandScapeData2D_HeightFieldTC::_load(  const unsigned int mX,   const unsigned int mZ )
           {
           const String strFileName = mParent->getOptions(   )->LandScape_filename + "." +
           StringConverter::toString(  mZ ) + "." +
           StringConverter::toString(  mX ) + ".";
          
           String finalName = strFileName +
           "modif." +
           mParent->getOptions(   )->LandScape_extension;
           if (  !(  mParent->getOptions(   )->Deformable &&
           ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  
           finalName ) ) )
           {
           finalName = strFileName +
           mParent->getOptions(   )->LandScape_extension;
           if (  !ResourceGroupManager::getSingleton(   ).resourceExists(  mParent->getOptions(   )->groupName,  
           finalName ) )
           {
          
           LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,   String(  "PLSM2 : Cannot find map named " ) + finalName );
           return false;
           }
           }
           mImage = new Image(   );
           mImage->load (  finalName,   mParent->getOptions(   )->groupName );
          
           //check to make sure it's 2^n + 1 size.
           if (  mImage->getWidth(   ) != mImage->getHeight(   ) ||
           !_checkSize(  mImage->getWidth(   ) ) )
           {
           String err = "Error: Invalid heightmap size : " +
           StringConverter::toString(  static_cast<int>(  mImage->getWidth(   ) ) ) +
           ",  " + StringConverter::toString(  static_cast<int>(  mImage->getHeight(   ) ) ) +
           ". Should be 2^n+1,   2^n+1";
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   err,   "PagingLandScapeData2D_HeightField::_load" );
           }
          
           mBpp = PixelUtil::getNumElemBytes (  mImage->getFormat (   ) );
           if (  mBpp != 1 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Error: Image is not a gray image.(  1 bytes,   8 bits )",  
           "PagingLandScapeData2D_HeightField::_load" );
           }
          
           if (  mSize != mImage->getWidth(   ) )
           {
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,   "Error: Declared World size <> Height Map Size.",   "PagingLandScapeData2D_HeightField::_load" );
           }
          
           mXDimension = mImage->getWidth(   );
           mZDimension = mImage->getHeight(   );
           mMax = static_cast <unsigned int> (  mSize * mImage->getHeight(   ) + 1 );
          
           mMaxArrayPos = mMax - 1;
           mHeightData = new Real[mMaxArrayPos];
           unsigned int j = 0;
           const double divider = 1.0 / 255;
           const Real scale = mParent->getOptions(   )->scale.y;
           uchar *data = mImage->getData(   );
           mMaxheight = 0.0f;
           for (  unsigned int i = 0; i < mMax - 1; i++ )
           {
           const Real h = _decodeTC(  data[ i ] * divider )* scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[j++] = h;
           }
           return true;
           }
           //-----------------------------------------------------------------------
     181   void PagingLandScapeData2D_HeightFieldTC::_load(   )
           {
           mImage = new Image(   );
           mImage->load (  mParent->getOptions(   )->LandScape_filename +
           "." + mParent->getOptions(   )->LandScape_extension,   mParent->getOptions(   )->groupName );
           mBpp = PixelUtil::getNumElemBytes (  mImage->getFormat (   ) );
           if (  mBpp != 1 )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Error: Image is not a greyscale image.(  1 byte,   8 bits )",  
           "PagingLandScapeData2D_HeightField::_load" );
           }
          
           mXDimension = mImage->getWidth(   );
           mZDimension = mImage->getHeight(   );
          
           const size_t sourceHeight = mZDimension;
           const size_t sourceWidth = mXDimension;
          
           computePowerof2PlusOneSize (   );
          
           mSize = mXDimension;
           mMaxArrayPos = static_cast <unsigned int> (  mXDimension * mZDimension );
           mMax = static_cast <unsigned int> (  mMaxArrayPos * mBpp );
           mHeightData = new Real[mMaxArrayPos];
          
           const Real divider = 1.0f / 65535.0f;
           const Real scale = mParent->getOptions(   )->scale.y;
           mMaxheight = 0.0f;
           const unsigned int shift_fill = static_cast <unsigned int> (  mXDimension - sourceWidth );
           uchar *imagedata = mImage->getData(   );
           unsigned int dest_pos = 0;
           for (  unsigned int i = 0; i < sourceHeight; ++i )
           {
           for (  unsigned int j = 0; j < sourceWidth; ++j )
           {
           const Real h = _decodeTC(  *imagedata++ * divider )* scale;
           mMaxheight = std::max (  h,   mMaxheight );
           mHeightData[dest_pos++] = h;
           }
           memset (  &mHeightData[dest_pos],   0,   shift_fill );
           dest_pos += shift_fill;
           }
          
          
           }
          
          
           //-----------------------------------------------------------------------
     229   void PagingLandScapeData2D_HeightFieldTC::_unload(   )
           {
           delete mImage;
           mImage = 0;
           }
          
           //-----------------------------------------------------------------------
     236   inline Real PagingLandScapeData2D_HeightFieldTC::_decodeTC(  const Real encoded ) const
           {
           return (  (  Real ) (  encoded + 0.5f ) ) * (  input_max - input_min ) + input_min;
           }
          
           //-----------------------------------------------------------------------
     242   inline uchar PagingLandScapeData2D_HeightFieldTC::_encodeTC(  const Real decoded ) const
           {
           return static_cast<uchar> (  (  decoded - input_min ) / (  input_max - input_min ) - 0.5f );
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeData2D_Spline.cpp

       1  /********************************************************************************
           OgrePagingLandScapeData2D_Spline.cpp
           *****************************************************************************
           A NURBS-based heightfield generator for use with the pagingLandScapeplugin
          
           Note that it could easily be adapted for use as a general NURBS surface
           generator.
           *****************************************************************************
           begin : Sat Nov 9 2003
           copyright : (  C ) 2003 Chris "Antiarc" Heald
           email : antiarc@captionthis.com
          ********************************************************************************/
          
          /********************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ********************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeOptions.h"
          
          #include "OgrePagingLandScapeData2D_Spline.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      39   PagingLandScapeData2D* PagingLandScapeData2D_Spline::newPage(   )
           {
           return new PagingLandScapeData2D_Spline(  mParent );
           }
           //-----------------------------------------------------------------------
      44   PagingLandScapeData2D_Spline::PagingLandScapeData2D_Spline(  PagingLandScapeData2DManager *dataMgr )
           : PagingLandScapeData2D(  dataMgr ),  
           mSurface (  0 ),  
           mPoints (  0 )
           {
           mMaxheight = 256.0f * mParent->getOptions(   )->scale.y;
           }
          
           //-----------------------------------------------------------------------
      53   PagingLandScapeData2D_Spline::~PagingLandScapeData2D_Spline(   )
           {
           delete mSurface;
           delete[] mPoints;
           }
           //-------------------------------------------------------------------
      59   void PagingLandScapeData2D_Spline::_save(   )
           {
          
           }
           //-------------------------------------------------------------------
      64   const Real PagingLandScapeData2D_Spline::getMaxAbsoluteHeight(  void ) const
           {
           return mParent->getOptions(   )->scale.y;
           }
           //-----------------------------------------------------------------------
      69   bool PagingLandScapeData2D_Spline::_load(  const unsigned int mX,   const unsigned int mZ )
           {
           int resolution = mParent->getOptions(   )->PageSize;
           mSize = resolution;
           mMax = static_cast <unsigned int> (  mSize * mSize );
           int pCount = 50;
           int mDegree = 3;
           Real MAX = 500;
           int tessLevel = static_cast <unsigned int> (  mSize );
          
           srand (  time(  NULL ) );
          
           mPoints = new Point4D[pCount * pCount];
           const int knotVecSize = pCount + mDegree + 1;
           float *knots = new float[knotVecSize];
           int i;
           for (  i = 0; i < knotVecSize; i++ )
           {
           if (  i < mDegree )
           {
           knots[i] = 0;
           }
           else if (  i > knotVecSize - mDegree )
           {
           knots[i] = knotVecSize - (  2 * mDegree ) + 1;
           }
           else
           {
           knots[i] = i - mDegree + 1;
           }
           }
           int dataSize = pCount * pCount;
           for (  i = 0; i < dataSize; i++ )
           {
           mPoints[i].x = (  int ) (  i/pCount );
           mPoints[i].y = double (  rand(   ) ) / MAX;
           mPoints[i].w = 1;
           mPoints[i].z = 0;//i % pCount;
           }
           mSurface = new CDRGNURBSSurface(   );
           mSurface->Init(  mDegree,   mDegree,  
           pCount,   pCount,  
           mPoints,  
           knots,   knots,  
           tessLevel,   tessLevel );
           mSurface->TessellateSurface(   );
           delete[] knots;
           delete[] mPoints;
          
           mXDimension = mSize;
           mZDimension = mSize;
           mMaxArrayPos = resolution * resolution;
           mHeightData = new Real[mMaxArrayPos];
           Real scale = mParent->getOptions(   )->scale.y;
           mMaxheight = 0.0f;
           unsigned int k;
           for (  k = 0; k < mMaxArrayPos; k ++ )
           {
           Real h = static_cast<Real> (  mSurface->getData(  k ).y * scale );
           mHeightData[k] = h;
           mMaxheight = std::max (  h,   mMaxheight );
           }
           mIsLoaded = true;
           return true;
           }
           //-----------------------------------------------------------------------
     135   void PagingLandScapeData2D_Spline::_load(   )
           {
          
           }
           //-----------------------------------------------------------------------
     140   void PagingLandScapeData2D_Spline::_unload(   )
           {
           delete mSurface;
           mSurface = 0;
           mIsLoaded = false;
           }
          
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeHorizon.cpp

       1  /***************************************************************************
           OgrePagingLandScapeHorizon.cpp - description
           -------------------
           begin : Sat Mar 08 2003
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreMovableObject.h"
          #include "OgreAxisAlignedBox.h"
          
          #include "OgreCamera.h"
          
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          #include "OgreTextureUnitState.h"
          
          #include "OgrePagingLandScapeTileInfo.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeHorizon.h"
          #include "OgrePagingLandScapeCamera.h"
          
          
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      47   PagingLandScapeHorizon::PagingLandScapeHorizon(  const PagingLandScapeOptions * const options ):
           mOptions(  options )
           {
           mPageWidth = options->world_width;
           mPageHeight = options->world_height;
          
           mNumTilesPage = options->NumTiles;
          
           mTileWidth = mPageWidth * mNumTilesPage;
           mTileHeight = mPageHeight * mNumTilesPage;
          
           size_t p_memssize = mPageWidth*mPageHeight;
          
           mMinPageHeights = new Real[p_memssize];
           memset (  mMinPageHeights,   0,   p_memssize * sizeof(  Real ) );
          
           mMaxPageHeights = new Real[p_memssize];
           memset (  mMaxPageHeights,   0,   p_memssize * sizeof(  Real ) );
          
           size_t t_memssize = mTileWidth*mTileHeight;
          
           mMinTileHeights = new Real[t_memssize];
           memset (  mMinTileHeights,   0,   t_memssize * sizeof(  Real ) );
          
           mMaxTileHeights = new Real[t_memssize];
           memset (  mMaxTileHeights,   0,   t_memssize * sizeof(  Real ) );
          
           material_enabled = false;
           mVisData = 0;
           }
           //-----------------------------------------------------------------------
      78   PagingLandScapeHorizon::~PagingLandScapeHorizon(   )
           {
           delete [] mMinPageHeights;
           delete [] mMaxPageHeights;
          
           delete [] mMinTileHeights;
           delete [] mMaxTileHeights;
          
           mVisibilityMaterial.setNull(   );
           }
           //-----------------------------------------------------------------------
      89   void PagingLandScapeHorizon::prepare(  const PagingLandScapeCamera* cam )
           {
           if (  material_enabled )
           {
           //reset.
           memset (  mVisData,   0,   mTileWidth * mTileHeight * 4 );
          
           //add camera point
           const Real tileX = cam->mCurrentCameraPageX * mNumTilesPage + cam->mCurrentCameraTileX;
           const Real tileZ = cam->mCurrentCameraPageZ * mNumTilesPage + cam->mCurrentCameraTileZ;
           const unsigned int tilePos = static_cast <unsigned int> (  (  tileX + tileZ * mTileWidth ) * 4 );
           mVisData [ tilePos ] = 0;
           mVisData [ tilePos + 1] = 0;
           mVisData [ tilePos + 2] = 255;
           mVisData [ tilePos + 3] = 255;
           }
           }
           //-----------------------------------------------------------------------
     107   void PagingLandScapeHorizon::update(   )
           {
           if (  material_enabled )
           {
           const PixelBox srcBox = mVisImage.getPixelBox(   );
          
           HardwarePixelBufferSharedPtr Texbuffer = mVisTex->getBuffer (  0,   0 );
           const PixelBox lock = Texbuffer->lock (  srcBox,   HardwareBuffer::HBL_DISCARD );
           // lock.data can now be freely accessed
           PixelUtil::bulkPixelConversion(  srcBox,   lock );
          
           Texbuffer->unlock(   );
           }
           }
           //-----------------------------------------------------------------------
     122   MaterialPtr PagingLandScapeHorizon::getVisibilityMaterial(   )
           {
           if (  mVisibilityMaterial.isNull(   ) )
           {
           const PagingLandScapeOptions * const opt = mOptions;
           const String filename = opt->LandScape_filename;
           const String name = filename +
           "Visibility";
           mVisibilityMaterial = MaterialManager::getSingleton(   ).getByName (  name );
           if (  mVisibilityMaterial.isNull(   ) )
           {
           mVisibilityMaterial = MaterialManager::getSingleton(   ).create (  name,  
           opt->groupName );
          
           TextureUnitState *tu0 = mVisibilityMaterial->getTechnique (  0 )->
           getPass (  0 )->createTextureUnitState (   );
          
           tu0->setTextureName (  filename + ".Small." +
           opt->TextureExtension );
          
          
           tu0->setAlphaOperation (  LBX_BLEND_MANUAL,   LBS_MANUAL,   LBS_CURRENT,   0.7,   1,   1 );
           //tu0->setTextureAddressingMode (  TextureUnitState::TextureAddressingMode::TAM_CLAMP );
           tu0->setTextureAddressingMode (  TextureUnitState::TAM_CLAMP );
           mVisibilityMaterial->setSceneBlending (  SBT_TRANSPARENT_ALPHA );
           //mVisibilityMaterial->setDepthCheckEnabled (  false );
           //mVisibilityMaterial->setDepthWriteEnabled (  false );
          
           const size_t s = mTileWidth * mTileHeight * 4;
           uchar *TexData = new uchar [s];
           memset (  TexData,   0,   s * sizeof(  uchar ) );
           // Assign the texture to the alpha map
           mVisImage.loadDynamicImage(  TexData,   mTileWidth,   mTileHeight,   1,   PF_R8G8B8A8,   true );
           mVisData = mVisImage.getData(   );
           const String texname = filename + ".Visibility";
           mVisTex = TextureManager::getSingleton(   ).loadImage(  texname,  
           opt->groupName,  
           mVisImage,  
           TEX_TYPE_2D,   0,   1.0f );
           TextureUnitState *tu1 = mVisibilityMaterial->getTechnique (  0 )->
           getPass (  0 )->createTextureUnitState(  texname );
           tu1->setTextureAddressingMode (  TextureUnitState::TAM_CLAMP );
           }
           else
           {
           const size_t s = mTileWidth * mTileHeight * 4;
           uchar *TexData = new uchar [s];
           memset (  TexData,   0,   s * sizeof(  uchar ) );
           // Assign the texture to the alpha map
           mVisImage.loadDynamicImage(  TexData,   mTileWidth,   mTileHeight,   1,   PF_R8G8B8A8,   true );
           mVisData = mVisImage.getData(   );
           mVisTex = TextureManager::getSingleton(   ).getByName (  filename + ".Visibility" );
           }
           }
           mVisibilityMaterial->load(   );
           material_enabled = true;
           return mVisibilityMaterial;
           }
           //-----------------------------------------------------------------------
     181   void PagingLandScapeHorizon::AddVisibleTile (  const unsigned int Tilex,   const unsigned int Tilez,  
     182   const bool visible )
           {
           if (  material_enabled )
           {
           const unsigned int tilePos = (  Tilex + Tilez * mTileWidth ) * 4;
           if (  visible )
           {
           mVisData [ tilePos ] = 0;
           mVisData [ tilePos + 1] = 255;
           mVisData [ tilePos + 2] = 0;
           mVisData [ tilePos + 3] = 255;
           }
           else
           {
           mVisData [ tilePos ] = 255;
           mVisData [ tilePos + 1] = 0;
           mVisData [ tilePos + 2] = 0;
           mVisData [ tilePos + 3] = 255;
           }
           }
           }
           //-----------------------------------------------------------------------
     204   void PagingLandScapeHorizon::AddVisibleTile (  const PagingLandScapeTileInfo *info,  
     205   const bool visible )
           {
           if (  material_enabled )
           {
           const unsigned int TileX = info->mPageX*mNumTilesPage + info->mTileX;
           const unsigned int TileZ = info->mPageZ*mNumTilesPage + info->mTileZ;
          
           AddVisibleTile (  TileX,   TileZ,   visible );
           }
           }
           //-----------------------------------------------------------------------
     216   void PagingLandScapeHorizon::registerMinMaxHeightPage (  const unsigned int pageX,   const unsigned int pageZ,  
     217   const Real minHeight,   const Real maxHeight )
           {
           const size_t pos = mPageWidth*mPageHeight;
           mMinPageHeights[pos] = minHeight;
           mMaxPageHeights[pos] = maxHeight;
           }
           //-----------------------------------------------------------------------
     224   void PagingLandScapeHorizon::registerMinMaxHeightTile (  const PagingLandScapeTileInfo *info,  
     225   const Real minHeight,   const Real maxHeight )
           {
           const size_t tilePos = (  info->mPageX*mNumTilesPage + info->mTileX
           + (  (  info->mPageZ*mNumTilesPage ) + info->mTileZ ) * mTileWidth );
          
           assert (  tilePos < mTileWidth*mTileHeight );
          
           mMinTileHeights[tilePos] = minHeight;
           mMaxTileHeights[tilePos] = maxHeight;
          
           const size_t pagePos = info->mPageX + info->mPageZ * mPageWidth;
          
           assert (  pagePos < mPageWidth*mPageHeight );
          
           // if tile height is maximum or minimum height page
           if (  mMaxPageHeights[pagePos] < maxHeight )
           mMaxPageHeights[pagePos] = maxHeight;
           if (  mMinPageHeights[pagePos] > minHeight )
           mMinPageHeights[pagePos] = minHeight;
           }
           //-----------------------------------------------------------------------
     246   bool PagingLandScapeHorizon::IsPageVisible(  const PagingLandScapeCamera* cam,  
           const unsigned int destpageX,   const unsigned int destpageZ )
           {
           const Real PageX = cam->mCurrentCameraPageX;
           const Real PageZ = cam->mCurrentCameraPageZ;
          
           // test if there is potential occluders
           if (  fabs (  PageX - destpageX ) < 2 && fabs (  PageZ - destpageZ ) < 2 )
           return true;
          
           assert (  destpageX + destpageZ*mPageWidth < mPageWidth*mPageHeight );
          
           return calcVis(  Vector3 (  PageX,   cam->getDerivedPosition (   ).y,   PageZ ),  
           Vector3 (  destpageX,   mMaxPageHeights[destpageX + destpageZ*mPageWidth],   destpageZ ),  
           mMinPageHeights,   mPageWidth,   mPageHeight );
           }
           //-----------------------------------------------------------------------
     263   bool PagingLandScapeHorizon::IsTileVisible(  const PagingLandScapeCamera* cam,  
     264   const PagingLandScapeTileInfo *destinfo )
           {
          
          
           const Real RsrcTileX = cam->mCurrentCameraPageX * mNumTilesPage + cam->mCurrentCameraTileX;
           const Real RsrcTileZ = cam->mCurrentCameraPageZ * mNumTilesPage + cam->mCurrentCameraTileZ;
          
           const Real RdestTileX = destinfo->mPageX*mNumTilesPage + destinfo->mTileX;
           const Real RdestTileZ = destinfo->mPageZ*mNumTilesPage + destinfo->mTileZ;
          
           // test if there is potential occluders
           if (  fabs (  RsrcTileX - RdestTileX ) < 2.0f && fabs (  RsrcTileZ - RdestTileZ ) < 2.0f )
           return true;
          
           const size_t pos = static_cast <size_t> (  RdestTileX + RdestTileZ*mTileWidth );
          
           assert (  pos < mTileWidth*mTileHeight );
          
           return calcVis(  Vector3 (  RsrcTileX,   cam->getDerivedPosition (   ).y,   RsrcTileZ ),  
           Vector3 (  RdestTileX,   mMaxTileHeights[pos],   RdestTileZ ),  
           mMinTileHeights,   mTileWidth,   mTileHeight );
           }
           //-----------------------------------------------------------------------
     287   bool PagingLandScapeHorizon::calcVis(  const Vector3 &src,   const Vector3 &dest,  
           const Real * const heightMap,  
           const unsigned int mapWidth,   const unsigned int mapHeight )
           {
           /* Make sure the ray is normalised */
           const Real x = dest.x - src.x;
           const Real z = dest.z - src.z;
           /*normalise only on x and z*/
           const Real fLength = Math::Sqrt(  x * x + z * z );
           // Will also work for zero-sized vectors,   but will change nothing
           if (  fLength < 1e-08 )
           return true;
          
           const Real fInvLength = 1.0 / fLength;
           const Vector3 direction (  x * fInvLength,  
           (  dest.y - src.y ) * fInvLength,  
           z * fInvLength );
          
          
           Real lasty = src.y;
          
           Vector3 currpos (  src + direction ); // fetch new tile
          
           /* For each heightmap location in the ray */
           while (  currpos.x >= 0 &&
           currpos.z >= 0 &&
           currpos.x < mapWidth &&
           currpos.z < mapHeight )
           {
           const size_t posx = static_cast <size_t> (  currpos.x + 0.5f );
           const size_t posz = static_cast <size_t> (  currpos.z + 0.5f );
           if (  posx == dest.x && posz == dest.z )
           break;
          
           const Real curry = currpos.y;
           currpos = currpos + direction; // fetch new tile
           const Real nexty = currpos.y; // fetch next tile height
          
           const Real h = heightMap[posx + posz*mapWidth];
           if (  h > nexty && h > lasty )
           {
           AddVisibleTile (  static_cast <unsigned int> (  dest.x ),  
           static_cast <unsigned int> (  dest.z ),  
           false );
           return false; // line of sight is occluded
           }
           lasty = curry;
           }
           AddVisibleTile (  static_cast <unsigned int> (  dest.x ),  
           static_cast <unsigned int> (  dest.z ),  
           true );
           return true;
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeIndexBuffer.cpp

       1  /***************************************************************************
           OgrePagingLandScapeIndexBufferManager.cpp - description
           -------------------
           begin : Fri Feb 28 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreHardwareBufferManager.h"
          #include "OgreVertexIndexData.h"
          
          #include "OgreVector3.h"
          
          #include "OgreSimpleRenderable.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeRenderable.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeIndexBuffer.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      35   PagingLandScapeIndexBufferManager::PagingLandScapeIndexBufferManager(  PagingLandScapeSceneManager * scnMgr ):
           mScnMgr(  scnMgr ),  
           mTileSize (  0 ),  
           mNumIndexes (  0 )
           {
          
           }
           //-----------------------------------------------------------------------
      43   PagingLandScapeIndexBufferManager::~PagingLandScapeIndexBufferManager(   )
           {
           clear(   );
           }
           //-----------------------------------------------------------------------
      48   void PagingLandScapeIndexBufferManager::load(   )
           {
           const unsigned int tileSize = mScnMgr->getOptions(   )->TileSize;
           const unsigned int numIndexes = mScnMgr->getOptions(   )->maxRenderLevel + 1;
          
           if (  tileSize != mTileSize || numIndexes != mNumIndexes )
           {
           // Clear
           mLevelIndex.reserve (  numIndexes );
           mLevelIndex.resize (  numIndexes );
           for (  unsigned int k = 0; k < numIndexes; k++ )
           {
           mLevelIndex[k] = new IndexMap(   );
           }
          
           mNumIndexes = numIndexes;
           mTileSize = tileSize;
           }
           }
           //-----------------------------------------------------------------------
      68   void PagingLandScapeIndexBufferManager::clear(   )
           {
           if (  !mLevelIndex.empty(   ) )
           {
           for (  unsigned int i = 0; i < mNumIndexes; i++ )
           {
           delete mLevelIndex[i];
           }
           mLevelIndex.clear(   );
           }
           if (  !mCache.empty(   ) )
           {
           const size_t cachesize = mCache.size (   );
           for(  size_t j = 0; j < cachesize; j++ )
           {
           delete mCache[j];
           }
           mCache.clear(   );
           }
           }
           //-----------------------------------------------------------------------
      89   IndexData *PagingLandScapeIndexBufferManager::getIndexData(  const int renderLevel,  
      90   PagingLandScapeRenderable **Neighbors )
           {
           assert (  renderLevel < static_cast <int> (  mNumIndexes ) );
           assert (  renderLevel >= 0 ) ;
          
           unsigned int stitchFlags = 0;
          
           bool eastStitch;
           if (  Neighbors[ EAST ] &&
           Neighbors[ EAST ]->isLoaded (   ) && Neighbors[ EAST ]->isVisible (   ) &&
           Neighbors[ EAST ]->mRenderLevel > renderLevel )
           {
           assert (  Neighbors[ EAST ]->mRenderLevel < static_cast <int> (  mNumIndexes ) );
           stitchFlags |= STITCH_EAST;
           stitchFlags |=
           (  Neighbors[ EAST ]->mRenderLevel - renderLevel ) << STITCH_EAST_SHIFT;
           eastStitch = true;
           }
           else
           {
           eastStitch = false;
           }
          
           bool westStitch;
           if (  Neighbors[ WEST ] &&
           Neighbors[ WEST ]->isLoaded (   ) && Neighbors[ WEST ]->isVisible (   ) &&
           Neighbors[ WEST ]->mRenderLevel > renderLevel )
           {
           assert (  Neighbors[ WEST ]->mRenderLevel < static_cast <int> (  mNumIndexes ) );
           stitchFlags |= STITCH_WEST;
           stitchFlags |=
           (  Neighbors[ WEST ]->mRenderLevel - renderLevel ) << STITCH_WEST_SHIFT;
           westStitch = true;
           }
           else
           {
           westStitch = false;
           }
          
           bool northStitch;
           if (  Neighbors[ NORTH ] &&
           Neighbors[ NORTH ]->isLoaded (   ) && Neighbors[ NORTH ]->isVisible (   ) &&
           Neighbors[ NORTH ]->mRenderLevel > renderLevel )
           {
           assert (  Neighbors[ NORTH ]->mRenderLevel < static_cast <int> (  mNumIndexes ) );
           stitchFlags |= STITCH_NORTH;
           stitchFlags |=
           (  Neighbors[ NORTH ]->mRenderLevel - renderLevel ) << STITCH_NORTH_SHIFT;
           northStitch = true;
           }
           else
           {
           northStitch = false;
           }
          
           bool southStitch;
           if (  Neighbors[ SOUTH ] &&
           Neighbors[ SOUTH ]->isLoaded (   ) && Neighbors[ SOUTH ]->isVisible (   ) &&
           Neighbors[ SOUTH ]->mRenderLevel > renderLevel )
           {
           assert (  Neighbors[ SOUTH ]->mRenderLevel < static_cast <int> (  mNumIndexes ) );
           stitchFlags |= STITCH_SOUTH;
           stitchFlags |=
           (  Neighbors[ SOUTH ]->mRenderLevel - renderLevel ) << STITCH_SOUTH_SHIFT;
           southStitch = true;
           }
           else
           {
           southStitch = false;
           }
          
          
           // Check preexisting
           assert (  mLevelIndex.size(   ) > (  unsigned int )renderLevel );
           IndexMap::iterator ii = mLevelIndex[ renderLevel ]->find(  stitchFlags );
           if (  ii == mLevelIndex[ renderLevel ]->end(   ) )
           {
           // Create
           IndexData* indexData = generateTriListIndexes(  northStitch,  
           southStitch,  
           eastStitch,  
           westStitch,  
           renderLevel,  
           Neighbors );
          
           mCache.push_back(  indexData );
           mLevelIndex[ renderLevel ]->insert(  
           IndexMap::value_type(  stitchFlags,   indexData ) );
          
           indexData->optimiseVertexCacheTriList(   );
          
           return indexData;
           }
           else
           {
           return ii->second;
           }
          
           }
          
           //-----------------------------------------------------------------------
     191   IndexData* PagingLandScapeIndexBufferManager::generateTriListIndexes(  const bool northStitch,  
     192   const bool southStitch,  
     193   const bool eastStitch,  
     194   const bool westStitch,  
           const int RenderLevel,  
     196   PagingLandScapeRenderable **Neighbors ) const
           {
           const int step = 1 << RenderLevel;
           assert (  step > 0 );
          
          
           const unsigned int tileSize = mTileSize;
           const unsigned int new_length = (  tileSize / step ) * (  tileSize / step ) * 2 * 2 * 2;
          
           IndexData* indexData = new IndexData(   );
           assert (  indexData );
          
           const bool is32bits = new_length > 65535 ? true : false;
           indexData->indexBuffer =
           HardwareBufferManager::getSingleton(   ).createIndexBuffer(  
           (  is32bits ) ? HardwareIndexBuffer::IT_32BIT : HardwareIndexBuffer::IT_16BIT,  
           new_length,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
          
          
           const unsigned int north = northStitch ? step : 0;
           const unsigned int south = southStitch ? step : 0;
           const unsigned int east = eastStitch ? step : 0;
           const unsigned int west = westStitch ? step : 0;
          
          
           unsigned int numIndexes = 0;
           const unsigned int step_offset = step * tileSize;
           unsigned int height_count = north * tileSize;
           void *idx;
           if (  is32bits )
           {
           /** Returns the index into the height array for the given coordinates. */
           unsigned int * ogre_restrict pIdx = static_cast<unsigned int*>(  indexData->indexBuffer->lock(  0,  
           indexData->indexBuffer->getSizeInBytes(   ),  
           HardwareBuffer::HBL_DISCARD ) );
           assert (  pIdx );
           for (  unsigned int j = north; j < tileSize - 1 - south; j += step )
           {
           for (  unsigned int i = west; i < tileSize - 1 - east; i += step )
           {
           //triangles
           assert (  (  i + step + height_count + step_offset ) < (  tileSize * tileSize ) );
          
          
           *pIdx++ = static_cast<unsigned int> (  i + height_count ); numIndexes++;
           *pIdx++ = static_cast<unsigned int> (  i + height_count + step_offset ); numIndexes++;
           *pIdx++ = static_cast<unsigned int> (  i + step + height_count ); numIndexes++;
          
           *pIdx++ = static_cast<unsigned int> (  i + height_count + step_offset ); numIndexes++;
           *pIdx++ = static_cast<unsigned int> (  i + step + height_count + step_offset ); numIndexes++;
           *pIdx++ = static_cast<unsigned int> (  i + step + height_count ); numIndexes++;
           }
           height_count += step_offset;
           }
           idx = pIdx;
           }
           else
           {
           /** Returns the index into the height array for the given coordinates. */
           ushort * ogre_restrict pIdx = static_cast<ushort*>(  indexData->indexBuffer->lock(  0,  
           indexData->indexBuffer->getSizeInBytes(   ),  
           HardwareBuffer::HBL_DISCARD ) );
           assert (  pIdx );
           for (  unsigned int j = north; j < tileSize - 1 - south; j += step )
           {
           for (  unsigned int i = west; i < tileSize - 1 - east; i += step )
           {
           //triangles
           assert (  (  i + step + height_count + step_offset ) < (  (  tileSize ) * (  tileSize ) ) );
          
          
           *pIdx++ = static_cast<ushort> (  i + height_count ); numIndexes++;
           *pIdx++ = static_cast<ushort> (  i + height_count + step_offset ); numIndexes++;
           *pIdx++ = static_cast<ushort> (  i + step + height_count ); numIndexes++;
          
           *pIdx++ = static_cast<ushort> (  i + height_count + step_offset ); numIndexes++;
           *pIdx++ = static_cast<ushort> (  i + step + height_count + step_offset ); numIndexes++;
           *pIdx++ = static_cast<ushort> (  i + step + height_count ); numIndexes++;
           }
           height_count += step_offset;
           }
           idx = pIdx;
           }
           assert (  numIndexes < new_length );
          
           // North stitching
           assert (  RenderLevel < static_cast <int> (  mNumIndexes ) );
           if (  northStitch )
           {
           assert (  Neighbors[ NORTH ] );
           assert (  Neighbors[ NORTH ]->isLoaded (   ) );
           assert (  Neighbors[ NORTH ]->isVisible (   ) );
           assert (  Neighbors[ NORTH ]->mRenderLevel > RenderLevel );
           assert (  Neighbors[ NORTH ]->mRenderLevel < static_cast <int> (  mNumIndexes ) );
           numIndexes += stitchEdge(  NORTH,   RenderLevel,   Neighbors[NORTH]->mRenderLevel,  
           westStitch ,   eastStitch ,   &idx,   is32bits );
           }
           // East stitching
           if (  eastStitch )
           {
           assert (  Neighbors[ EAST ] );
           assert (  Neighbors[ EAST ]->isLoaded (   ) );
           assert (  Neighbors[ EAST ]->isVisible (   ) );
           assert (  Neighbors[ EAST ]->mRenderLevel > RenderLevel );
           assert (  Neighbors[ EAST ]->mRenderLevel < static_cast <int> (  mNumIndexes ) );
           numIndexes += stitchEdge(  EAST,   RenderLevel,   Neighbors[EAST]->mRenderLevel,  
           northStitch,   southStitch,   &idx,   is32bits );
           }
           // South stitching
           if (  southStitch )
           {
           assert (  Neighbors[ SOUTH ] );
           assert (  Neighbors[ SOUTH ]->isLoaded (   ) );
           assert (  Neighbors[ SOUTH ]->isVisible (   ) );
           assert (  Neighbors[ SOUTH ]->mRenderLevel > RenderLevel );
           assert (  Neighbors[ SOUTH ]->mRenderLevel < static_cast <int> (  mNumIndexes ) );
           numIndexes += stitchEdge(  SOUTH,   RenderLevel,   Neighbors[SOUTH]->mRenderLevel,  
           eastStitch ,   westStitch,   &idx,   is32bits );
           }
           // West stitching
           if (  westStitch )
           {
           assert (  Neighbors[ WEST ] );
           assert (  Neighbors[ WEST ]->isLoaded (   ) );
           assert (  Neighbors[ WEST ]->isVisible (   ) );
           assert (  Neighbors[ WEST ]->mRenderLevel > RenderLevel );
           assert (  Neighbors[ WEST ]->mRenderLevel < static_cast <int> (  mNumIndexes ) );
           numIndexes += stitchEdge(  WEST,   RenderLevel,   Neighbors[WEST]->mRenderLevel,  
           southStitch ,   northStitch,   &idx,   is32bits );
           }
          
           assert (  numIndexes < new_length );
          
           indexData->indexBuffer->unlock(   );
           indexData->indexCount = numIndexes;
           indexData->indexStart = 0;
          
           return indexData;
           }
           //-----------------------------------------------------------------------
     338   unsigned int PagingLandScapeIndexBufferManager::stitchEdge(  const Neighbor neighbor,  
           const int hiLOD,   const int loLOD,  
     340   const bool omitFirstTri,   const bool omitLastTri,  
           void** ppIdx,  
     342   const bool is32bits ) const
           {
           assert(  loLOD > hiLOD );
           /*
           Now do the stitching; we can stitch from any level to any level.
           The stitch pattern is like this for each pair of vertices in the lower LOD
           (  excuse the poor ascii art ):
          
           lower LOD
           *-----------*
           |\ \ 3 / /|
           |1\2 \ / 4/5|
           *--*--*--*--*
           higher LOD
          
           The algorithm is,   for each pair of lower LOD vertices:
           1. Iterate over the higher LOD vertices,   generating tris connected to the
           first lower LOD vertex,   up to and including 1/2 the span of the lower LOD
           over the higher LOD (  tris 1-2 ). Skip the first tri if it is on the edge
           of the tile and that edge is to be stitched itself.
           2. Generate a single tri for the middle using the 2 lower LOD vertices and
           the middle vertex of the higher LOD (  tri 3 ).
           3. Iterate over the higher LOD vertices from 1/2 the span of the lower LOD
           to the end,   generating tris connected to the second lower LOD vertex
           (  tris 4-5 ). Skip the last tri if it is on the edge of a tile and that
           edge is to be stitched itself.
          
           The same algorithm works for all edges of the patch; stitching is done
           clockwise so that the origin and steps used change,   but the general
           approach does not.
           */
          
          
           // Work out the steps ie how to increment indexes
           // Step from one vertex to another in the high detail version
           int step = 1 << hiLOD;
           // Step from one vertex to another in the low detail version
           int superstep = 1 << loLOD;
           // Step half way between low detail steps
           int halfsuperstep = superstep >> 1;
          
           // Work out the starting points and sign of increments
           // We always work the strip clockwise
           int startx,   starty,   endx,   rowstep;
           bool horizontal;
          
           const int tileSize = static_cast <int> (  mTileSize - 1 );
           switch (  neighbor )
           {
           case NORTH:
           startx = starty = 0;
           endx = tileSize;
           rowstep = step;
           horizontal = true;
           break;
           case SOUTH:
           // invert x AND y direction,   helps to keep same winding
           startx = starty = tileSize;
           endx = 0;
           rowstep = -step;
           step = -step;
           superstep = -superstep;
           halfsuperstep = -halfsuperstep;
           horizontal = true;
           break;
           case EAST:
           startx = 0;
           endx = tileSize;
           starty = tileSize;
           rowstep = -step;
           horizontal = false;
           break;
           case WEST:
           startx = tileSize;
           endx = 0;
           starty = 0;
           rowstep = step;
           step = -step;
           superstep = -superstep;
           halfsuperstep = -halfsuperstep;
           horizontal = false;
           break;
           default:
           startx = 0;
           endx = 0;
           starty = 0;
           rowstep = 0;
           step = 0;
           superstep = 0;
           halfsuperstep = 0;
           horizontal = false;
           assert (  0 );
           break;
           };
           assert (  *ppIdx );
           unsigned int numIndexes = 0;
           const bool isHorizontal = horizontal;
           if (  is32bits )
           {
           // Get pointer to be updated
           unsigned int* ogre_restrict pIdx = static_cast <unsigned int*> (  *ppIdx );
           for (  int j = startx; j != endx; j += superstep )
           {
           int k;
           for (  k = 0; k != halfsuperstep; k += step )
           {
           int jk = j + k;
           //skip the first bit of the corner?
           if (  j != startx || k != 0 || !omitFirstTri )
           {
           if (  isHorizontal )
           {
           *pIdx++ = _index32(  j ,   starty ); numIndexes++;
           *pIdx++ = _index32(  jk,   starty + rowstep ); numIndexes++;
           *pIdx++ = _index32(  jk + step,   starty + rowstep ); numIndexes++;
           }
           else
           {
           *pIdx++ = _index32(  starty,   j ); numIndexes++;
           *pIdx++ = _index32(  starty + rowstep,   jk ); numIndexes++;
           *pIdx++ = _index32(  starty + rowstep,   jk + step ); numIndexes++;
           }
           }
           }
          
           // Middle tri
           if (  isHorizontal )
           {
           *pIdx++ = _index32(  j,   starty ); numIndexes++;
           *pIdx++ = _index32(  j + halfsuperstep,   starty + rowstep ); numIndexes++;
           *pIdx++ = _index32(  j + superstep,   starty ); numIndexes++;
           }
           else
           {
           *pIdx++ = _index32(  starty,   j ); numIndexes++;
           *pIdx++ = _index32(  starty + rowstep,   j + halfsuperstep ); numIndexes++;
           *pIdx++ = _index32(  starty,   j + superstep ); numIndexes++;
           }
          
           for (  k = halfsuperstep; k != superstep; k += step )
           {
           int jk = j + k;
           if (  j != endx - superstep || k != superstep - step || !omitLastTri )
           {
           if (  isHorizontal )
           {
           *pIdx++ = _index32(  j + superstep,   starty ); numIndexes++;
           *pIdx++ = _index32(  jk,   starty + rowstep ); numIndexes++;
           *pIdx++ = _index32(  jk + step,   starty + rowstep ); numIndexes++;
           }
           else
           {
           *pIdx++ = _index32(  starty,   j + superstep ); numIndexes++;
           *pIdx++ = _index32(  starty + rowstep,   jk ); numIndexes++;
           *pIdx++ = _index32(  starty + rowstep,   jk + step ); numIndexes++;
           }
           }
           }
           }
           *ppIdx = pIdx;
           }
           else
           {
           // Get pointer to be updated
           ushort* ogre_restrict pIdx = static_cast <ushort*> (  *ppIdx );
           for (  int j = startx; j != endx; j += superstep )
           {
           int k;
           for (  k = 0; k != halfsuperstep; k += step )
           {
           int jk = j + k;
           //skip the first bit of the corner?
           if (  j != startx || k != 0 || !omitFirstTri )
           {
           if (  isHorizontal )
           {
           *pIdx++ = _index16(  j ,   starty ); numIndexes++;
           *pIdx++ = _index16(  jk,   starty + rowstep ); numIndexes++;
           *pIdx++ = _index16(  jk + step,   starty + rowstep ); numIndexes++;
           }
           else
           {
           *pIdx++ = _index16(  starty,   j ); numIndexes++;
           *pIdx++ = _index16(  starty + rowstep,   jk ); numIndexes++;
           *pIdx++ = _index16(  starty + rowstep,   jk + step ); numIndexes++;
           }
           }
           }
          
           // Middle tri
           if (  isHorizontal )
           {
           *pIdx++ = _index16(  j,   starty ); numIndexes++;
           *pIdx++ = _index16(  j + halfsuperstep,   starty + rowstep ); numIndexes++;
           *pIdx++ = _index16(  j + superstep,   starty ); numIndexes++;
           }
           else
           {
           *pIdx++ = _index16(  starty,   j ); numIndexes++;
           *pIdx++ = _index16(  starty + rowstep,   j + halfsuperstep ); numIndexes++;
           *pIdx++ = _index16(  starty,   j + superstep ); numIndexes++;
           }
          
           for (  k = halfsuperstep; k != superstep; k += step )
           {
           int jk = j + k;
           if (  j != endx - superstep || k != superstep - step || !omitLastTri )
           {
           if (  isHorizontal )
           {
           *pIdx++ = _index16(  j + superstep,   starty ); numIndexes++;
           *pIdx++ = _index16(  jk,   starty + rowstep ); numIndexes++;
           *pIdx++ = _index16(  jk + step,   starty + rowstep ); numIndexes++;
           }
           else
           {
           *pIdx++ = _index16(  starty,   j + superstep ); numIndexes++;
           *pIdx++ = _index16(  starty + rowstep,   jk ); numIndexes++;
           *pIdx++ = _index16(  starty + rowstep,   jk + step ); numIndexes++;
           }
           }
           }
           }
           *ppIdx = pIdx;
           }
           return numIndexes;
           }
          
           //*******************
           //Added by Fiesch adapted from a post by tonyhnz
     572   IndexData *PagingLandScapeIndexBufferManager::getRawIndexes(  int renderLevel )
           {
           // no stitching is done
           // used to expose terrain vertex data
          
           if (  renderLevel >= static_cast <int> (  mNumIndexes ) )
           renderLevel = static_cast <int> (  mNumIndexes )-1;
          
           if (  renderLevel < 0 )
           renderLevel =0 ;
          
           const unsigned int stitchFlags = 0;
          
           assert (  mLevelIndex.size(   ) > (  unsigned int )renderLevel );
          
           IndexMap::iterator ii = mLevelIndex[ renderLevel ]->find(   stitchFlags  );
           if (   ii == mLevelIndex[ renderLevel ]->end(   ) )
           {
           // Create
           IndexData* indexData = generateTriListIndexes(   false,  
           false,  
           false,  
           false,  
           renderLevel,  
           0 );
           mLevelIndex[ renderLevel ]->insert(  
           IndexMap::value_type(  stitchFlags,   indexData ) );
          
           return indexData;
           }
           else
           {
           return ii->second;
           }
           }
          } //namespace
          

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeIntersectionSceneQuery.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeIntersectionSceneQuery.cpp - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004by Jon Anderson
          email : janders@users.sf.net
          
          
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeIntersectionSceneQuery.h"
          
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgrePagingLandScapeOctreeIntersectionSceneQuery.h"
          
          #include "OgreEntity.h"
          #include "OgreRoot.h"
          
          namespace Ogre
          {
          
          //---------------------------------------------------------------------
      51  PagingLandScapeIntersectionSceneQuery::PagingLandScapeIntersectionSceneQuery(  SceneManager* creator )
           : PagingLandScapeOctreeIntersectionSceneQuery(  creator )
          {
           // Add bounds fragment type
           mSupportedWorldFragments.insert(  SceneQuery::WFT_SINGLE_INTERSECTION );
           mSupportedWorldFragments.insert(  SceneQuery::WFT_PLANE_BOUNDED_REGION );
          }
          
          //---------------------------------------------------------------------
      60  PagingLandScapeIntersectionSceneQuery::~PagingLandScapeIntersectionSceneQuery(  void )
          {
          }
          
          //---------------------------------------------------------------------
      65  void PagingLandScapeIntersectionSceneQuery::execute(  IntersectionSceneQueryListener* listener )
          {
           if(  mWorldFragmentType == SceneQuery::WFT_SINGLE_INTERSECTION )
           {
           PagingLandScapeOctreeIntersectionSceneQuery::execute(  listener );
           }
           else if (  mWorldFragmentType == SceneQuery::WFT_PLANE_BOUNDED_REGION )
           {
           // We want the whole bounded volume
          // assert(  (  *bi )->fragment.fragmentType == SceneQuery::WFT_PLANE_BOUNDED_REGION );
          // if (  !listener->queryResult(  const_cast<WorldFragment*>(  &(  brush->fragment ) ),  
          // result.second + traceDistance ) )
          // return false;
          
           }
          }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeListenerManager.cpp

       1  /*-----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright � 2000-2004 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------*/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          
          #include "OgrePagingLandScapeListenerManager.h"
          #include "OgrePagingLandScapeSceneManager.h"
          
          namespace Ogre
          {
           //-------------------------------------------------------------------------
      33   PagingLandScapeListenerManager::PagingLandScapeListenerManager(  PagingLandScapeSceneManager * scnMgr )
           {
           };
           //-------------------------------------------------------------------------
      37   PagingLandScapeListenerManager::~PagingLandScapeListenerManager(  void )
           {
           std::for_each(  mTerrainReadyListeners.begin(   ),   mTerrainReadyListeners.end(   ),   delete_object(   ) );
          
           std::for_each(  mShowPageListeners.begin(   ),   mShowPageListeners.end(   ),   delete_object(   ) );
           std::for_each(  mHidePageListeners.begin(   ),   mHidePageListeners.end(   ),   delete_object(   ) );
           std::for_each(  mPreloadPageListeners.begin(   ),   mPreloadPageListeners.end(   ),   delete_object(   ) );
           std::for_each(  mLoadPageListeners.begin(   ),   mLoadPageListeners.end(   ),   delete_object(   ) );
           std::for_each(  mUnloadPageListeners.begin(   ),   mUnloadPageListeners.end(   ),   delete_object(   ) );
           std::for_each(  mPostunloadPageListeners.begin(   ),   mPostunloadPageListeners.end(   ),   delete_object(   ) );
           std::for_each(  mModifyPageListeners.begin(   ),   mModifyPageListeners.end(   ),   delete_object(   ) );
          
          
           std::for_each(  mShowTileListeners.begin(   ),   mShowTileListeners.end(   ),   delete_object(   ) );
           std::for_each(  mHideTileListeners.begin(   ),   mHideTileListeners.end(   ),   delete_object(   ) );
           std::for_each(  mLoadTileListeners.begin(   ),   mLoadTileListeners.end(   ),   delete_object(   ) );
           std::for_each(  mUnloadTileListeners.begin(   ),   mUnloadTileListeners.end(   ),   delete_object(   ) );
           std::for_each(  mModifyTileListeners.begin(   ),   mModifyTileListeners.end(   ),   delete_object(   ) );
          
           };
           //-------------------------------------------------------------------------
      58   void PagingLandScapeListenerManager::firePagePreloaded(  const size_t pagex,  
      59   const size_t pagez,  
      60   const Real* heightData,  
      61   const AxisAlignedBox &Bbox )
           {
           if (  mPreloadPageListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   0,   0,   heightData,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mPreloadPageListeners.begin(   );
           it != mPreloadPageListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
      72   void PagingLandScapeListenerManager::firePageLoaded(  const size_t pagex,   const size_t pagez,  
      73   const Real* heightData,   const AxisAlignedBox &Bbox )
           {
           if (  mLoadPageListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   0,   0,   heightData,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mLoadPageListeners.begin(   );
           it != mLoadPageListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
      84   void PagingLandScapeListenerManager::firePageUnloaded(  const size_t pagex,   const size_t pagez,  
      85   const Real* heightData,   const AxisAlignedBox &Bbox )
           {
           if (  mUnloadPageListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   0,   0,   heightData,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mUnloadPageListeners.begin(   );
           it != mUnloadPageListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
          
           //-------------------------------------------------------------------------
      97   void PagingLandScapeListenerManager::firePagePostunloaded(  const size_t pagex,   const size_t pagez )
           {
           if (  mPostunloadPageListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   0,   0,   0,   AxisAlignedBox(   ) );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mPostunloadPageListeners.begin(   );
           it != mPostunloadPageListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
     108   void PagingLandScapeListenerManager::firePageShow(  const size_t pagex,   const size_t pagez,  
     109   const Real* heightData,   const AxisAlignedBox &Bbox )
           {
           if (  mShowPageListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   0,   0,   heightData,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mShowPageListeners.begin(   );
           it != mShowPageListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
     120   void PagingLandScapeListenerManager::firePageHide(  const size_t pagex,   const size_t pagez,  
     121   const Real* heightData,   const AxisAlignedBox &Bbox )
           {
           if (  mHidePageListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   0,   0,   heightData,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mHidePageListeners.begin(   );
           it != mHidePageListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
     132   void PagingLandScapeListenerManager::fireTileLoaded (  const size_t pagex,   const size_t pagez,  
     133   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox )
           {
           if (  mLoadTileListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   tilex,   tilez,   0,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mLoadTileListeners.begin(   );
           it != mLoadTileListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
     144   void PagingLandScapeListenerManager::fireTileUnloaded(  const size_t pagex,   const size_t pagez,  
     145   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox )
           {
           if (  mUnloadTileListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   tilex,   tilez,   0,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mUnloadTileListeners.begin(   );
           it != mUnloadTileListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
     156   void PagingLandScapeListenerManager::fireTileDeformed(  const size_t pagex,   const size_t pagez,  
     157   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox )
           {
           if (  mModifyTileListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   tilex,   tilez,   0,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mModifyTileListeners.begin(   );
           it != mModifyTileListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
     168   void PagingLandScapeListenerManager::fireTileShow(  const size_t pagex,   const size_t pagez,  
     169   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox )
           {
           if (  mShowTileListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   tilex,   tilez,   0,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mShowTileListeners.begin(   );
           it != mShowTileListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
     180   void PagingLandScapeListenerManager::fireTileHide(  const size_t pagex,   const size_t pagez,  
     181   const size_t tilex,   const size_t tilez,   const AxisAlignedBox &Bbox )
           {
           if (  mHideTileListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  pagex,   pagez,   tilex,   tilez,   0,   Bbox );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mHideTileListeners.begin(   );
           it != mHideTileListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
     192   void PagingLandScapeListenerManager::fireTerrainReady(   )
           {
           if (  mTerrainReadyListeners.empty(   ) )
           return;
          
           PagingLandscapeEvent e (  0,   0,   0,   0,   0,   AxisAlignedBox (   ) );
           for (  std::list<PagingLandscapeDelegate *>::iterator it = mTerrainReadyListeners.begin(   );
           it != mTerrainReadyListeners.end(   ); ++it )
           (  *(  *it ) )(  &e );
           }
           //-------------------------------------------------------------------------
     203   bool PagingLandScapeListenerManager::setOption(  const String& strKey,   const void* pValue )
           {
          
           PagingLandscapeDelegate *d = const_cast < PagingLandscapeDelegate * > (  static_cast < const PagingLandscapeDelegate * >(  pValue ) );
           if (  StringUtil::startsWith(  strKey,   "add",   true ) )
           {
           if (  strKey == "addTerrainListener" )
           {
           addTerrainListener (  d );
           return true;
           }
          
           if (  strKey == "addPreloadPageListener" )
           {
           addPreloadPageListener (  d );
           return true;
           }
           if (  strKey == "addShowPageListener" )
           {
           addShowPageListener (  d );
           return true;
           }
           if (  strKey == "addHidePageListener" )
           {
           addHidePageListener (  d );
           return true;
           }
           if (  strKey == "addLoadPageListener" )
           {
           addLoadPageListener (  d );
           return true;
           }
           if (  strKey == "addModifyPageListener" )
           {
           addModifyPageListener (  d );
           return true;
           }
           if (  strKey == "addPostunloadPageListener" )
           {
           addPostunloadPageListener (  d );
           return true;
           }
           if (  strKey == "addUnloadPageListener" )
           {
           addUnloadPageListener (  d );
           return true;
           }
          
           if (  strKey == "addShowTileListener" )
           {
           addShowTileListener (  d );
           return true;
           }
           if (  strKey == "addHideTileListener" )
           {
           addHideTileListener (  d );
           return true;
           }
           if (  strKey == "addLoadTileListener" )
           {
           addLoadTileListener (  d );
           return true;
           }
           if (  strKey == "addModifyTileListener" )
           {
           addModifyTileListener (  d );
           return true;
           }
           if (  strKey == "addUnloadTileListener" )
           {
           addUnloadTileListener (  d );
           return true;
           }
           }
          
           if (  StringUtil::startsWith(  strKey,   "remove",   true ) )
           {
          
           if (  strKey == "removeTerrainListener" )
           {
           removeTerrainListener (  d );
           return true;
           }
          
           if (  strKey == "removePreloadPageListener" )
           {
           removePreloadPageListener (  d );
           return true;
           }
           if (  strKey == "removeShowPageListener" )
           {
           removeShowPageListener (  d );
           return true;
           }
           if (  strKey == "removeHidePageListener" )
           {
           removeHidePageListener (  d );
           return true;
           }
           if (  strKey == "removeLoadPageListener" )
           {
           removeLoadPageListener (  d );
           return true;
           }
           if (  strKey == "removeModifyPageListener" )
           {
           removeModifyPageListener (  d );
           return true;
           }
           if (  strKey == "removePostunloadPageListener" )
           {
           removePostunloadPageListener (  d );
           return true;
           }
           if (  strKey == "removeUnloadPageListener" )
           {
           removeUnloadPageListener (  d );
           return true;
           }
          
           if (  strKey == "removeShowTileListener" )
           {
           removeShowTileListener (  d );
           return true;
           }
           if (  strKey == "removeHideTileListener" )
           {
           removeHideTileListener (  d );
           return true;
           }
           if (  strKey == "removeLoadTileListener" )
           {
           removeLoadTileListener (  d );
           return true;
           }
           if (  strKey == "removeModifyTileListener" )
           {
           removeModifyTileListener (  d );
           return true;
           }
           if (  strKey == "removeUnloadTileListener" )
           {
           removeUnloadTileListener (  d );
           return true;
           }
           }
           return false;
           }
           //-------------------------------------------------------------------------
     352   void PagingLandScapeListenerManager::addTerrainListener(  PagingLandscapeDelegate* pl )
           {
           mTerrainReadyListeners.push_back(  pl );
           }
           //-------------------------------------------------------------------------
     357   void PagingLandScapeListenerManager::removeTerrainListener(  PagingLandscapeDelegate* pl )
           {
           mTerrainReadyListeners.remove (  pl );
           }
           //-------------------------------------------------------------------------
     362   void PagingLandScapeListenerManager::addPreloadPageListener(  PagingLandscapeDelegate* pl )
           {
           mPreloadPageListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     367   void PagingLandScapeListenerManager::removePreloadPageListener(  PagingLandscapeDelegate* pl )
           {
           mPreloadPageListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     372   void PagingLandScapeListenerManager::addShowPageListener(  PagingLandscapeDelegate* pl )
           {
           mShowPageListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     377   void PagingLandScapeListenerManager::removeShowPageListener(  PagingLandscapeDelegate* pl )
           {
           mShowPageListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     382   void PagingLandScapeListenerManager::addHidePageListener(  PagingLandscapeDelegate* pl )
           {
           mHidePageListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     387   void PagingLandScapeListenerManager::removeHidePageListener(  PagingLandscapeDelegate* pl )
           {
           mHidePageListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     392   void PagingLandScapeListenerManager::addLoadPageListener(  PagingLandscapeDelegate* pl )
           {
           mLoadPageListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     397   void PagingLandScapeListenerManager::removeLoadPageListener(  PagingLandscapeDelegate* pl )
           {
           mLoadPageListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     402   void PagingLandScapeListenerManager::addModifyPageListener(  PagingLandscapeDelegate* pl )
           {
           mModifyPageListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     407   void PagingLandScapeListenerManager::removeModifyPageListener(  PagingLandscapeDelegate* pl )
           {
           mModifyPageListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     412   void PagingLandScapeListenerManager::addPostunloadPageListener(  PagingLandscapeDelegate* pl )
           {
           mPostunloadPageListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     417   void PagingLandScapeListenerManager::removePostunloadPageListener(  PagingLandscapeDelegate* pl )
           {
           mPostunloadPageListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     422   void PagingLandScapeListenerManager::addUnloadPageListener(  PagingLandscapeDelegate* pl )
           {
           mUnloadPageListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     427   void PagingLandScapeListenerManager::removeUnloadPageListener(  PagingLandscapeDelegate* pl )
           {
           mUnloadPageListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     432   void PagingLandScapeListenerManager::addShowTileListener(  PagingLandscapeDelegate* pl )
           {
           mShowTileListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     437   void PagingLandScapeListenerManager::removeShowTileListener(  PagingLandscapeDelegate* pl )
           {
           mShowTileListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     442   void PagingLandScapeListenerManager::addHideTileListener(  PagingLandscapeDelegate* pl )
           {
           mHideTileListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     447   void PagingLandScapeListenerManager::removeHideTileListener(  PagingLandscapeDelegate* pl )
           {
           mHideTileListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     452   void PagingLandScapeListenerManager::addLoadTileListener(  PagingLandscapeDelegate* pl )
           {
           mLoadTileListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     457   void PagingLandScapeListenerManager::removeLoadTileListener(  PagingLandscapeDelegate* pl )
           {
           mLoadTileListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     462   void PagingLandScapeListenerManager::addModifyTileListener(  PagingLandscapeDelegate* pl )
           {
           mModifyTileListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     467   void PagingLandScapeListenerManager::removeModifyTileListener(  PagingLandscapeDelegate* pl )
           {
           mModifyTileListeners.remove (  pl );
           };
           //-------------------------------------------------------------------------
     472   void PagingLandScapeListenerManager::addUnloadTileListener(  PagingLandscapeDelegate* pl )
           {
           mUnloadTileListeners.push_back(  pl );
           };
           //-------------------------------------------------------------------------
     477   void PagingLandScapeListenerManager::removeUnloadTileListener(  PagingLandscapeDelegate* pl )
           {
           mUnloadTileListeners.remove (  pl );
           };
          }//namespace
          

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeMeshDecal.cpp

       1  /*-----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright � 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------*/
          /***************************************************************************
          OgrePagingLandScapeMeshDecal.cpp - description
          -------------------
          begin : Sat Oct 15,   2006
          copyright : (  C ) 2006 by Steven Klug
          email : stevenklug@san.rr.com
          
          
          ***************************************************************************/
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "Ogre.h"
          
          #include "OgrePagingLandScapeMeshDecal.h"
          #include "OgrePagingLandScapeAxisAlignedBoxSceneQuery.h"
          
          #include <numeric>
          
          using namespace Ogre;
          using namespace std;
          
          namespace
          {
           typedef PagingLandScapeAxisAlignedBoxSceneQuery::CustomQueryResult CustomQueryResult;
          
           template<class T>
      49   class IndexCalculator
           {
           int width_;
           int offset_;
           public:
      54   IndexCalculator(   int width,   int offset  )
           : width_(   width  )
           ,   offset_(   offset  ) {}
          
      58   T GetIndex(   int x,   int z  ) const
           {
           return offset_ + x + (   z * width_  );
           }
           };
          }
          
      65  PagingLandScapeMeshDecal::PagingLandScapeMeshDecal(   const String& name,  
      66   const String& materialName,  
      67   const Vector2& size,  
      68   const String& sceneMgrInstanceName  )
           : MovableObject(   name  )
           ,   material_(   MaterialManager::getSingleton(   ).getByName(   materialName  )  )
           ,   size_(   size  )
           ,   sceneMgr_(   Root::getSingleton(   ).getSceneManager(   sceneMgrInstanceName  )  )
           ,   position_(   Vector3::ZERO  )
           ,   mDirty(  true )
          {
           if(   material_.isNull(   )  )
           {
           OGRE_EXCEPT(   Exception::ERR_INVALIDPARAMS,  
           "Invalid material name for mesh decal.",  
           "PagingLandScapeMeshDecal::PagingLandScapeMeshDecal" );
           }
          
           // Create a dummy rayQuery to avoid heap allocation every frame.
           rayQuery_ = sceneMgr_->createRayQuery(   Ray(   Vector3::ZERO,   Vector3::NEGATIVE_UNIT_Y  )  );
           rayQuery_->setQueryTypeMask(   SceneManager::WORLD_GEOMETRY_TYPE_MASK  );
           rayQuery_->setWorldFragmentType(   SceneQuery::WFT_SINGLE_INTERSECTION  );
          
           AABBquery_ = sceneMgr_->createAABBQuery(   AxisAlignedBox(   )  );
          
           // Allocate objects for render op.
           renderOp_.vertexData = new VertexData(   );
           renderOp_.indexData = new IndexData(   );
          
           // Create declaration (  memory format ) of vertex data
           VertexDeclaration* decl = renderOp_.vertexData->vertexDeclaration;
           decl->addElement(   0,   0,   VET_FLOAT3,   VES_POSITION  );
           declSize_ = sizeof(   Vector3  );
           decl->addElement(   0,   declSize_,   VET_FLOAT2,   VES_TEXTURE_COORDINATES,   0 );
           declSize_ += sizeof(   Vector2  );
          
           // Set bounding information
           AABB_.setMinimum(   Vector3(   -size_.x / 2,   1,   -size_.y / 2  )  );
           AABB_.setMaximum(   Vector3(   size_.x / 2,   1,   size_.y / 2  )  );
          
          // CreateGeometry(   );
          }
          
     108  PagingLandScapeMeshDecal::~PagingLandScapeMeshDecal(   )
          {
           sceneMgr_->destroyQuery(   rayQuery_  );
           sceneMgr_->destroyQuery(   AABBquery_  );
           delete renderOp_.vertexData;
           delete renderOp_.indexData;
          }
          
     116  void PagingLandScapeMeshDecal::_notifyAttached(  Node* parent,   bool isTagPoint )
          {
           MovableObject::_notifyAttached(  parent,   isTagPoint );
           CreateGeometry(   );
          }
          
          
     123  void PagingLandScapeMeshDecal::CreateGeometry(   )
          {
           Matrix4 xlate;
           if(   mParentNode  )
           getWorldTransforms(   &xlate  );
           else
           xlate = Matrix4::IDENTITY;
           Matrix4 invXlate = xlate.inverse(   );
          
           // Deterimine approximate size of vertex data from query.
           // Get the scale.
           Real scaleX;
           Real scaleZ;
           sceneMgr_->getOption(   "ScaleX",   &scaleX  );
           sceneMgr_->getOption(   "ScaleZ",   &scaleZ  );
          
           const AxisAlignedBox& box = getWorldBoundingBox(   true  );
           subSections_.clear(   );
           subExtents_.clear(   );
           height_ = 0;
           width_ = 0;
          
           AABBquery_->setBox(   box  );
           AABBquery_->execute(   this  );
          
           if(   !height_ || !width_  )
           return;
          
           //only continue if it's dirty
           if (  !mDirty ) {
           return;
           }
           //make a copy of the subextends for lookup
           mOldSubExtents = subExtents_;
           mDirty = false;
          
           Real xOffset = -size_.x / 2;
           Real zOffset = -size_.y / 2;
          
           // Create vertex data structure for 4 vertices shared between submeshes
           VertexData* vertexData = renderOp_.vertexData;
          
           // Allocate vertex buffer of the requested number of vertices (  vertexCount )
           // and bytes per vertex (  offset )
           HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton(   ).
           createVertexBuffer(   declSize_,  
           GetNumVertices(   ),  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY  );
          // HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE  );
          
           // Set vertex buffer binding so buffer 0 is bound to our vertex buffer
           vertexData->vertexBufferBinding->setBinding(   0,   vbuf  );
          
           Real minY = Math::POS_INFINITY;
           Real maxY = Math::NEG_INFINITY;
           float* buffer = (  float* )vbuf->lock(   HardwareBuffer::HBL_DISCARD  );
           int vertexCount = 0;
          
           SubSectionContainer::const_iterator it = subSections_.begin(   );
           SubSectionContainer::const_iterator itEnd = subSections_.end(   );
           for(   ; it != itEnd; ++it  )
           {
           VertexContainer::const_iterator vertIt = it->begin(   );
           VertexContainer::const_iterator vertItEnd = it->end(   );
           for(   ; vertIt != vertItEnd; ++vertIt  )
           {
           // Copy our vertices into the hardware buffer and calculate
           // texture coords.
           // TODO: Don't transform vertices that aren't included due to LoD.
           Vector3 localVertex = invXlate * vertIt->vertex_; // Convert back to local coordinates.
           *buffer++ = localVertex.x;
           *buffer++ = localVertex.y;
           *buffer++ = localVertex.z;
           // Keep track of height bounds for final AABB.
           if(   localVertex.y < minY  )
           minY = localVertex.y;
           if(   localVertex.y > maxY  )
           maxY = localVertex.y;
           // Calculate texture coordinates based on distances from the
           // edges of our rectangle.
           *buffer++ = (   localVertex.x - xOffset  ) / size_.x;
           *buffer++ = 1.0 - (   (   localVertex.z - zOffset  ) / size_.y  );
           ++vertexCount;
           }
           }
           vbuf->unlock(   );
          
           vertexData->vertexCount = vertexCount;
          
           // Create index data.
           IndexData* indexData = renderOp_.indexData;
           indexData->indexStart = 0;
           size_t maxNumIndices = GetNumIndices(   );
           bool is32bits = maxNumIndices >= 0x10000;
           // Allocate index buffer of the requested number of vertices (  ibufCount )
           HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager::getSingleton(   ).
           createIndexBuffer(   (  is32bits ) ? HardwareIndexBuffer::IT_32BIT : HardwareIndexBuffer::IT_16BIT,  
           maxNumIndices,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY  );
           if(   is32bits  )
           indexData->indexCount = CreateIndices<uint>(   ibuf  );
           else
           indexData->indexCount = CreateIndices<ushort>(   ibuf  );
          
           // Put the hardware index buffer into our render operation object.
           indexData->indexBuffer = ibuf;
           indexData->optimiseVertexCacheTriList(   );
          
           subSections_.clear(   );
           subExtents_.clear(   );
          
           AABB_.setMinimum(   Vector3(   -size_.x / 2,   minY,   -size_.y / 2  )  );
           AABB_.setMaximum(   Vector3(   size_.x / 2,   maxY,   size_.y / 2 )  );
           radius_ = std::max(   size_.x / 2,   size_.y / 2 );
           radius_ = std::max(   radius_,   maxY  );
          }
          
     240  size_t PagingLandScapeMeshDecal::GetNumVertices(   ) const
          {
           size_t vertices = 0;
           SubSectionContainer::const_iterator it = subSections_.begin(   );
           for(   ; it != subSections_.end(   ); ++it  )
           vertices += it->size(   );
           return vertices;
          }
          
     249  size_t PagingLandScapeMeshDecal::GetNumIndices(   ) const
          {
           size_t indices = 0;
           SubExtentContainer::const_iterator it = subExtents_.begin(   );
           for(   ; it != subExtents_.end(   ); ++it  )
           {
           int step = 1 << it->renderLevel_;
           indices += (   it->width_ / step  ) * (   it->height_ / step  ) * 6;
           }
           return indices;
          }
          
          template<class T>
     262  int PagingLandScapeMeshDecal::CreateIndices(   Ogre::HardwareIndexBufferSharedPtr ibuf  )
          {
           T* indices = (  T* )ibuf->lock(   HardwareBuffer::HBL_DISCARD  );
           int indexCount = 0;
           int indexOffset = 0;
           for(   int z = 0; z < height_; ++z  )
           {
           for(   int x = 0; x < width_; ++x  )
           {
           indexCount += MeshSubSection<T>(   x,   z,   indices,   indexOffset  );
           }
           }
           ibuf->unlock(   );
           return indexCount;
          }
          
          template<class T>
     279  int PagingLandScapeMeshDecal::MeshSubSection(   int x,   int z,   T*& indices,   int& indexOffset  )
          {
           int indexCount = 0;
           int offset = indexOffset;
           const SubExtent& extents = subExtents_[z * width_ + x];
           int rl = extents.renderLevel_;
           // Get render levels of neighbors so we can stitch them properly.
           int northRL = z > 0 ? GetRenderLevel(   x,   z - 1  ) : rl;
           int westRL = x > 0 ? GetRenderLevel(   x - 1,   z  ) : rl;
           int southRL = z < height_ - 1 ? GetRenderLevel(   x,   z + 1  ) : rl;
           int eastRL = x < width_ - 1 ? GetRenderLevel(   x + 1,   z  ) : rl;
           // We only stitch if the neighbor's render level is greater than ours.
           bool northStitch = northRL > rl;
           bool westStitch = westRL > rl;
           bool southStitch = southRL > rl;
           bool eastStitch = eastRL > rl;
           // Get extents.
           int height = extents.height_;
           int width = extents.width_;
           int step = 1 << rl;
           int lineStepOffset = width * step;
           int iEnd = height - 1 - (   southStitch ? step : 0  );
           int i = 0;
           if(   northStitch  )
           {
           i = step;
           offset += lineStepOffset;
           }
           for(   ; i < iEnd; i += step  )
           {
           int nextLineOffset = offset + lineStepOffset;
           int jEnd = width - 1 - (   eastStitch ? step : 0  );
           for(   int j = westStitch ? step : 0; j < jEnd; j += step  )
           {
           *indices++ = j + offset; // up-left
           *indices++ = j + nextLineOffset; // low-left
           *indices++ = j + step + offset; // up-right
          
           *indices++ = j + step + offset; // up-right
           *indices++ = j + nextLineOffset; // low-left
           *indices++ = j + step + nextLineOffset; // low-right
          
           indexCount += 6;
           }
           offset = nextLineOffset;
           }
           // Stich any sides that need stiching.
           if(   northStitch  )
           indexCount += StitchEdge(   indices,   extents,   rl,   northRL,   true,   true,   westStitch,   eastStitch,   indexOffset  );
           if(   westStitch  )
           indexCount += StitchEdge(   indices,   extents,   rl,   westRL,   false,   false,   southStitch,   northStitch,   indexOffset  );
           if(   southStitch  )
           indexCount += StitchEdge(   indices,   extents,   rl,   southRL,   true,   false,   eastStitch,   westStitch,   indexOffset  );
           if(   eastStitch  )
           indexCount += StitchEdge(   indices,   extents,   rl,   eastRL,   false,   true,   northStitch,   southStitch,   indexOffset  );
          
           indexOffset += (   width * height  );
           return indexCount;
          }
          
          // Use the same stiching algorithm the landscape renderer does or
          // the decal won't look right. TODO: At some point it would be nice
          // to just use the actual code from the renderer,   but it's made to
          // work specifically with tiles,   not sub-sections of tiles.
          template<class T>
     344  int PagingLandScapeMeshDecal::StitchEdge(   T*& indices,  
           const SubExtent& extents,  
           const int hiLOD,  
           const int loLOD,  
     348   const bool horizontal,  
     349   const bool forward,  
     350   const bool omitFirstTri,  
     351   const bool omitLastTri,  
           const int indexOffset  )
          {
           // Work out the steps ie how to increment indexes
           // Step from one vertex to another in the high detail version
           int step = 1 << hiLOD;
           // Step from one vertex to another in the low detail version
           int superstep = 1 << loLOD;
           // Step half way between low detail steps
           int halfsuperstep = superstep >> 1;
          
           // Work out the starting points and sign of increments
           // We always work the strip clockwise
           int startx,   startz,   endx,   rowstep;
           if(   horizontal  )
           {
           if(   forward  )
           {
           startx = startz = 0;
           endx = extents.width_ - 1;
           rowstep = step;
           }
           else
           {
           startx = extents.width_ - 1;
           startz = extents.height_ - 1;
           endx = 0;
           rowstep = -step;
           step = -step;
           superstep = -superstep;
           halfsuperstep = -halfsuperstep;
           }
           }
           else
           {
           if(   forward  )
           {
           startx = 0;
           endx = extents.height_ - 1;
           startz = extents.width_ - 1;
           rowstep = -step;
           }
           else
           {
           startx = extents.height_ - 1;
           endx = 0;
           startz = 0;
           rowstep = step;
           step = -step;
           superstep = -superstep;
           halfsuperstep = -halfsuperstep;
           }
           }
          
           int indexCount = 0;
           IndexCalculator<T> calc(   extents.width_,   indexOffset  );
           for(   int j = startx; j != endx; j += superstep  )
           {
           int k;
           for(   k = 0; k != halfsuperstep; k += step  )
           {
           int jk = j + k;
           //skip the first bit of the corner?
           if(   j != startx || k != 0 || !omitFirstTri  )
           {
           if(   horizontal  )
           {
           *indices++ = calc.GetIndex(   j ,   startz  );
           *indices++ = calc.GetIndex(   jk,   startz + rowstep  );
           *indices++ = calc.GetIndex(   jk + step,   startz + rowstep  );
           }
           else
           {
           *indices++ = calc.GetIndex(   startz,   j  );
           *indices++ = calc.GetIndex(   startz + rowstep,   jk  );
           *indices++ = calc.GetIndex(   startz + rowstep,   jk + step  );
           }
           indexCount += 3;
           }
           }
          
           // Middle tri
           if(   horizontal  )
           {
           *indices++ = calc.GetIndex(   j,   startz  );
           *indices++ = calc.GetIndex(   j + halfsuperstep,   startz + rowstep  );
           *indices++ = calc.GetIndex(   j + superstep,   startz  );
           }
           else
           {
           *indices++ = calc.GetIndex(   startz,   j  );
           *indices++ = calc.GetIndex(   startz + rowstep,   j + halfsuperstep  );
           *indices++ = calc.GetIndex(   startz,   j + superstep  );
           }
           indexCount += 3;
          
           for(   k = halfsuperstep; k != superstep; k += step  )
           {
           int jk = j + k;
           if(   j != endx - superstep || k != superstep - step || !omitLastTri  )
           {
           if(   horizontal  )
           {
           *indices++ = calc.GetIndex(   j + superstep,   startz  );
           *indices++ = calc.GetIndex(   jk,   startz + rowstep  );
           *indices++ = calc.GetIndex(   jk + step,   startz + rowstep  );
           }
           else
           {
           *indices++ = calc.GetIndex(   startz,   j + superstep  );
           *indices++ = calc.GetIndex(   startz + rowstep,   jk  );
           *indices++ = calc.GetIndex(   startz + rowstep,   jk + step  );
           }
           indexCount += 3;
           }
           }
           }
           return indexCount;
          }
          
          // From Ogre::MovableObject
     472  void PagingLandScapeMeshDecal::_updateRenderQueue(   RenderQueue* queue  )
          {
           queue->addRenderable(   this,   mRenderQueueID,   OGRE_RENDERABLE_DEFAULT_PRIORITY + 1  );
          }
          
          // From Ogre::Renderable
     478  void PagingLandScapeMeshDecal::getRenderOperation(   Ogre::RenderOperation& op  )
          {
           // Update our RenderOperation if necessary.
           const Vector3& position = mParentNode->getWorldPosition(   );
           const Quaternion& orientation = mParentNode->getOrientation(   );
           if(   position != position_ ||
           orientation != orientation_  )
           {
           position_ = position;
           orientation_ = orientation;
           //force a full geometry rebuild
           mDirty = true;
           }
           //calling this every frame will only trigger a full rebuild when the LOD has changed
           CreateGeometry(   );
           op = renderOp_;
          }
          
     496  void PagingLandScapeMeshDecal::getWorldTransforms(   Ogre::Matrix4* xform  ) const
          {
           *xform = mParentNode->_getFullTransform(   );
          }
          
     501  const Quaternion& PagingLandScapeMeshDecal::getWorldOrientation(   ) const
          {
           return mParentNode->_getDerivedOrientation(   );
          }
          
     506  const Vector3& PagingLandScapeMeshDecal::getWorldPosition(   ) const
          {
           return mParentNode->getWorldPosition(   );
          }
          
     511  Real PagingLandScapeMeshDecal::getSquaredViewDepth(   const Camera* cam  ) const
          {
           return (   getWorldPosition(   ) - cam->getDerivedPosition(   )  ).squaredLength(   );
          }
          
          // Receive terrain vertices from our query.
     517  bool PagingLandScapeMeshDecal::queryResult(  SceneQuery::WorldFragment* fragment )
          {
           if(   fragment->fragmentType != SceneQuery::WFT_CUSTOM_GEOMETRY  )
           {
           OGRE_EXCEPT(   Exception::ERR_INTERNAL_ERROR,  
           "SceneQuery flags invalid.",  
           "PagingLandScapeMeshDecal::queryResult" );
           }
          
           CustomQueryResult* result = reinterpret_cast<CustomQueryResult*>(   fragment->geometry  );
           switch(   result->type_  )
           {
           case CustomQueryResult::QUERY_EXTENTS_TYPE:
           {
           // Reserve space for our sub-sections.
           width_ = result->data_.queryExtents_.width_;
           height_ = result->data_.queryExtents_.height_;
           subSections_.resize(   width_ * height_  );
           subExtents_.resize(   width_ * height_  );
           break;
           }
          
           case CustomQueryResult::SUBSECTION_EXTENTS_TYPE:
           {
           currentSubX_ = result->data_.subExtents_.subX_;
           currentSubZ_ = result->data_.subExtents_.subZ_;
           int offset = currentSubX_ + currentSubZ_ * width_;
           SubExtent& subExtent = subExtents_[offset];
           subExtent.width_ = result->data_.subExtents_.width_;
           subExtent.height_ = result->data_.subExtents_.height_;
           subExtent.renderLevel_ = result->data_.subExtents_.renderLevel_;
           // TODO: Optimize! We wouldn't need an intermediate array at all
           // if the scene query gave us all the sub-section extents up front
           // so we could allocate the correct size fo the vertex buffer. It's
           // a bit tricky in the scene query,   so leaving it this way for now.
           // Another option could be to overallocate the vertex buffer assuming
           // that each sub-section was the full tile size,   but that's also
           // pretty wasteful (  though possibly faster,   since no heap allocation ).
           subSections_[offset].reserve(   subExtent.width_ * subExtent.height_  );
          
           //compare with earlier result and see if any LOD has changed
           if (  !mDirty ) {
           if (  mOldSubExtents.size(   ) >= offset ) {
           SubExtent& oldSubExtent = mOldSubExtents[offset];
           if (  oldSubExtent.renderLevel_ != subExtent.renderLevel_ ) {
           mDirty = true;
           }
           } else {
           mDirty = true;
           }
           }
           break;
           }
          
           case CustomQueryResult::VERTEX_TYPE:
           {
           VertexContainer& subSection = subSections_[currentSubX_ + currentSubZ_ * width_];
           Vertex vertex(   result->data_.vertexData_.x_,  
           result->data_.vertexData_.y_,  
           result->data_.vertexData_.z_,  
           result->data_.vertexData_.included_  );
           subSection.push_back(   vertex  );
           break;
           }
          
           default:
           OGRE_EXCEPT(   Exception::ERR_INTERNAL_ERROR,  
           "Result type invalid.",  
           "PagingLandScapeMeshDecal::queryResult" );
           }
           return true;
          }
          
          //-----------------------------------------------------------------------
          String PagingLandScapeMeshDecalFactory::FACTORY_TYPE_NAME = "PagingLandScapeMeshDecal";
          
          #if 0
          //-----------------------------------------------------------------------
     595  PagingLandScapeMeshDecal* PagingLandScapeMeshDecalFactory::create(   SceneManager& sceneMgr,  
     596   const String& name,  
     597   const String& materialName,  
     598   const Vector2& size,  
     599   const String& sceneMgrInstance  )
          {
           NameValuePairList params;
           params["materialName"] = materialName;
           params["width"] = StringConverter::toString(   size.x  );
           params["height"] = StringConverter::toString(   size.y  );
           params["sceneMgrInstance"] = sceneMgrInstance;
          
           return static_cast<PagingLandScapeMeshDecal*>(  
           sceneMgr.createMovableObject(   name,  
           PagingLandScapeMeshDecalFactory::FACTORY_TYPE_NAME,  
           &params  )  );
          }
          #endif
          //-----------------------------------------------------------------------
     614  const String& PagingLandScapeMeshDecalFactory::getType(  void ) const
          {
           return FACTORY_TYPE_NAME;
          }
          //-----------------------------------------------------------------------
     619  MovableObject* PagingLandScapeMeshDecalFactory::createInstanceImpl
          (  
     621   const String& name,  
     622   const NameValuePairList* params
           )
          {
           String materialName;
           Real width = 0.0;
           Real height = 0.0;
           String sceneMgrInstance;
           if(   params != 0  )
           {
           NameValuePairList::const_iterator it = params->find(   "materialName"  );
           if(   it != params->end(   )  )
           {
           materialName = it->second;
           }
           it = params->find(   "width"  );
           if(   it != params->end(   )  )
           {
           width = StringConverter::parseReal(   it->second  );
           }
           it = params->find(   "height"  );
           if(   it != params->end(   )  )
           {
           height = StringConverter::parseReal(   it->second  );
           }
           it = params->find(   "sceneMgrInstance"  );
           if(   it != params->end(   )  )
           {
           sceneMgrInstance = it->second;
           }
           }
          
           return new PagingLandScapeMeshDecal(   name,   materialName,   Vector2(   width,   height  ),   sceneMgrInstance  );
          }
          //-----------------------------------------------------------------------
     656  void PagingLandScapeMeshDecalFactory::destroyInstance(   MovableObject* obj  )
          {
           delete obj;
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusion.cpp

       1  
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "Ogre.h"
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          
          #include "OgrePagingLandScapeOcclusion.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          
          #include "OgrePagingLandScapeOcclusionSorter.h"
          #include "OgrePagingLandScapeOcclusionVisibilityData.h"
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          #include "OgrePagingLandScapeOcclusionCHCTraversal.h"
          #include "OgrePagingLandScapeOcclusionSWTraversal.h"
          #include "OgrePagingLandScapeOcclusionVFTraversal.h"
          #include "OgrePagingLandScapeOcclusionDebugTraversal.h"
          
          #include "OgrePagingLandScapeOcclusionQuerySet.h"
          
          #include "OgreOcclusionBoundingBox.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      31   Occlusion::Occlusion(  unsigned int visibilityThsd ):
           mCurrentCam(  0 ),  
           mVisibilityTreshold(  visibilityThsd ),  
           mIsQueryPoolNotInitiated(  true ),  
           mFrameConservativeVisibility (  300 )
           {
           };
           //-----------------------------------------------------------------------
      39   bool Occlusion::nextFrame(  PagingLandScapeOctreeCamera *cam,  
      40   MovableObjectList *camInProgressVisibles,  
      41   bool onlyshadowcaster,  
      42   RenderQueue *q )
           {
           bool newframe = true;
          
           mCurrentRenderQueue = q;
           mOnlyShadowCaster = onlyshadowcaster;
          
           if (  cam != mCurrentCam )
           {
           mCurrentCam = cam;
           }
           if (  mCurrentCam->nextFrame(  Root::getSingleton(   ).getCurrentFrameNumber (   ) ) )
           {
           // change frame Id counter
           //that identify current frame.
           mFrameId = mCurrentCam->getFrameId(   );
           newframe = true;
           }
          
           if (  newframe )
           {
           camInProgressVisibles->clear(   );
           #ifdef _VISIBILITYDEBUG
           // reset counters.
           triangle_cnt = 0;
           traversed_nodes_cnt = 0;
           frustum_culled_nodes_cnt = 0;
           query_cnt = 0;
           object_cnt = 0;
           #endif //_VISIBILITYDEBUG
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
      77   void Occlusion::queueDraw(  PagingLandScapeOctreeNode& n )
           {
           #ifdef _VISIBILITYDEBUG
           object_cnt++;
           #endif //_VISIBILITYDEBUG
          
           VisibilityData * const vis = n.getNodeData (  mCurrentCam );
           if (  !vis->notified )
           {
           // notify objects handled by this node
           n.notifyNodeObjects (  mCurrentCam,   mOnlyShadowCaster );
           }
           // as it's visible add its attached objects to render queue.
           // note that we know it already has been notified by camera,  
           // when we issued query.
           n._addAlreadyNotifiedToVisibles (   );
          
           // now it had been drawn,   notified should be false.
           vis->notified = false;
           vis->frameID = mFrameId;
           }
           //-----------------------------------------------------------------------
      99   bool Occlusion::issueDrawQuery(  PagingLandScapeOctreeNode& n )
           {
           VisibilityData * const vis = n.getNodeData (  mCurrentCam );
          
           #ifdef _VISIBILITYDEBUG
           query_cnt++;
           traversed_nodes_cnt++;
           assert (  vis->viewFrustumVisible );
           #endif //_VISIBILITYDEBUG
          
           assert (  vis->frameID != mFrameId ) ;
           assert (  vis->query == 0 );
           assert (  n.isOccluder(   ) );
          
           MovableObjectList *moToRender = n.getVisibleNotifiedNodeObjects(  mCurrentCam,   mOnlyShadowCaster );
          
           // Mark that Node already notified by this frame/cam combination
           vis->frameID = mFrameId;
           vis->notified = true;
          
           if (  !moToRender->empty(   ) )
           {
           HardwareOcclusionQuery *query = mQueryPool.getPoolable(   );
           vis->query = query;
          
           // create the render Queue.
           MovableObjectList::iterator it = moToRender->begin(   ),   itend = moToRender->end(   );
           while (  it != itend )
           {
           (  *it )->_updateRenderQueue(  &*mCurrentRenderQueue );
           ++it;
           }
          
           // draw and query.
           query->beginOcclusionQuery (   );
           mScnMngr->directRenderSingleQueue (  &*mCurrentRenderQueue );
           query->endOcclusionQuery (   );
          
           moToRender->clear(   );
          
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
     144   void Occlusion::issueBboxQuery(  OcclusionElement& n )
           {
           #ifdef _VISIBILITYDEBUG
           query_cnt++;
           #endif //_VISIBILITYDEBUG
          
           VisibilityData * const vis = n.getNodeData (  mCurrentCam );
           assert (  vis->query == 0 );
           HardwareOcclusionQuery *query = mQueryPool.getPoolable(   );
           vis->query = query;
          
           query->beginOcclusionQuery(   );
           // render bounding box for object
           mScnMngr->directRenderSingleObject(  n.getOcclusionBoundingBox(   ) );
           query->endOcclusionQuery(   );
          
           //mScnMngr->addVisible (  n.getOcclusionBoundingBox(   ) );
           }
           //-----------------------------------------------------------------------
     163   bool Occlusion::isQueryResultIsVisible(  OcclusionElement& node )
           {
           // check visibility result
           unsigned int visiblePixels = 0;
           //this one wait if result not available
           VisibilityData * const vis = node.getNodeData (  mCurrentCam );
           vis->query->pullOcclusionQuery (  &visiblePixels );
          
           mQueryPool.removePoolable (  vis->query );
           vis->query = 0;
          
           if (  visiblePixels > mVisibilityTreshold )
           {
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
     181   void Occlusion::pullUpVisibility(  OcclusionElement& node )
           {
           OcclusionElement* n = &node;
           VisibilityData *vis = n->getNodeData (  mCurrentCam );
          
           while (  !vis->queryVisible )
           {
           vis->queryVisible = true;
           n = n->getParent(   );
           if (  0 == n )
           return;
           vis = n->getNodeData (  mCurrentCam );
           }
           }
           //-----------------------------------------------------------------------
     196   bool Occlusion::insideViewFrustum(  OcclusionElement& n )
           {
           const bool result = mCurrentCam->isVisible (  n.getCullBoundingBox (   ) );
          
           #ifdef _VISIBILITYDEBUG
           if (  result )
           {
           n.getNodeData (  mCurrentCam )->viewFrustumVisible = true;
           }
           else
           {
           n.getNodeData (  mCurrentCam )->viewFrustumVisible = false;
           frustum_culled_nodes_cnt++;
           }
           #endif
          
           return result;
           }
           //-----------------------------------------------------------------------
           //this is the algorithm from the paper
     216   void Occlusion::CHCtraversal(  PagingLandScapeOctree *octree,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           if (  mIsQueryPoolNotInitiated )
           initQueryPool (   );
          
           const unsigned int visibilityTreshold = mVisibilityTreshold;
           const Vector3 &camPos = mCurrentCam->getDerivedPosition(   );
           FrontToBackNodeSorterPriorityQueue traversalStack = FrontToBackNodeSorterPriorityQueue(  FrontToBackNodeSorterOperator (  camPos ) );
          
           //draw leaves,   stack otherwise
           CHCTraversal toStackTraversal(  traversalStack,   *this );
           const unsigned int frameId = mFrameId;
           const unsigned int lastframeId = mFrameId - 1;
          
           // first Octree
           traversalStack.push (  octree );
           while (  !traversalStack.empty(   ) || !m_queryQueue.empty(   ) )
           {
           //first part
           // get previous frame occlusion results
           while (  traversalStack.empty(   ) &&
           !m_queryQueue.empty(   ) &&
           !m_queryQueue.front(   )->getNodeData (  mCurrentCam )->query->isStillOutstanding(   ) )
           {
           OcclusionElement& node = *(  m_queryQueue.front(   ) );
           m_queryQueue.pop(   );
          
           VisibilityData * const vis = node.getNodeData (  mCurrentCam );
           // should be already frustum culled and flagged as not visible
           assert (  vis->lastQueryFrameId == frameId );
           assert (  !vis->queryVisible );
           #ifdef _VISIBILITYDEBUG
           assert (  vis->viewFrustumVisible );
           #endif //_VISIBILITYDEBUG
          
           // check visibility result
           unsigned int visiblePixels = 0;
           //this one wait if result not available
           vis->query->pullOcclusionQuery(  &visiblePixels );
           mQueryPool.removePoolable(  vis->query );
           vis->query = 0;
           if(  visiblePixels > visibilityTreshold )
           {
           pullUpVisibility (  node );
          
           // Traverse for sure this visible node
           // And therefore check children
           node.traversal (  toStackTraversal,   visibleBounds );
           //node.traversal (  toStackTraversal,   0 );
           }
           }
           //2nd part
           // query visible objects
           while (  !traversalStack.empty(   ) )
           {
           OcclusionElement& node = *traversalStack.top (   );
           traversalStack.pop (   );
          
           // make sure there's no loop of some sort.
           // as we must query a node only once
           assert (  frameId != node.getNodeData (  mCurrentCam )->lastQueryFrameId );
           if (  insideViewFrustum (  node ) )
           {
           VisibilityData * const vis = node.getNodeData (  mCurrentCam );
           // identify visible in the last frame nodes
           const bool wasVisible = vis->queryVisible &&
           lastframeId == vis->lastQueryFrameId;
           if (  node.isLeaf(   ) )
           {
           if (  wasVisible && node.isOccluder(   ) )
           {
           // Draw & query at the same time previously visible nodes
           if (  issueDrawQuery (  static_cast <PagingLandScapeOctreeNode &> (  node ) ) )
           {
           m_queryQueue.push (  &node );
           }
           else
           {
           // skip testing previously visible node
           // that is not visible when notified.
           // make next frame get here again,  
           // saving a box query
           vis->queryVisible = true;
           vis->lastQueryFrameId = frameId;
           continue;
           }
           }
           else
           {
           issueBboxQuery (  node );
           m_queryQueue.push (  &node );
           }
           }
           else
           {
           if (  wasVisible )
           {
           // skip testing previously visible node
           // (  interior nodes in hierarchy )
           node.traversal (  toStackTraversal,   visibleBounds );
           //node.traversal (  toStackTraversal,   0 );
           }
           else
           {
           // only query node that wasn't visible last frame
           issueBboxQuery (  node );
           m_queryQueue.push (  &node );
           }
           }
          
           // reset this node's visibility to false
           // Will be updated by results queries that will pull up results.
           // by children that will be flagged visible and will transmit info
           // to their parent nodes (  pullUpVisibility(   ) )
           vis->queryVisible = false;
           // update node's visited flag to make sure we won't visit 2 times
           // and to "tick" the visible info.
           vis->lastQueryFrameId = frameId;
           }
           }
           }
           }
           //-----------------------------------------------------------------------
           //this is the algorithm from the paper,   conservative way.
     340   void Occlusion::CHCtraversalConservative(  PagingLandScapeOctree *octree,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
          
           const unsigned int frameConservativeVisibility = mFrameConservativeVisibility;
           const unsigned int visibilityTreshold = mVisibilityTreshold;
          
           if (  mIsQueryPoolNotInitiated )
           initQueryPool (   );
          
          
           const Vector3 &camPos = mCurrentCam->getDerivedPosition(   );
           FrontToBackNodeSorterPriorityQueue traversalStack = FrontToBackNodeSorterPriorityQueue(  FrontToBackNodeSorterOperator (  camPos ) );
          
           //draw leaves,   stack otherwise
           CHCTraversal toStackTraversal(  traversalStack,   *this );
           const unsigned int frameId = mFrameId;
           const unsigned int lastframeId = mFrameId - 1;
          
           // first Octree
           traversalStack.push (  octree );
           while (  !traversalStack.empty(   ) || !m_queryQueue.empty(   ) )
           {
           //first part
           // get previous frame occlusion results
           while (  traversalStack.empty(   ) &&
           !m_queryQueue.empty(   ) &&
           !m_queryQueue.front(   )->getNodeData (  mCurrentCam )->query->isStillOutstanding(   ) )
           {
           OcclusionElement& node = *(  m_queryQueue.front(   ) );
           m_queryQueue.pop(   );
          
           VisibilityData * const vis = node.getNodeData (  mCurrentCam );
           // should be already frustum culled and flagged as not visible
           assert (  vis->lastQueryFrameId == frameId );
           assert (  !vis->queryVisible );
           #ifdef _VISIBILITYDEBUG
           assert (  vis->viewFrustumVisible );
           #endif //_VISIBILITYDEBUG
          
           // check visibility result
           unsigned int visiblePixels = 0;
           //this one wait if result not available
           vis->query->pullOcclusionQuery(  &visiblePixels );
           mQueryPool.removePoolable(  vis->query );
           vis->query = 0;
           if(  visiblePixels > visibilityTreshold )
           {
           pullUpVisibility (  node );
          
           // Traverse for sure this visible node
           // And therefore check children
           node.traversal (  toStackTraversal,   visibleBounds );
           //node.traversal (  toStackTraversal,   0 );
           }
           }
           //2nd part
           // query visible objects
           while (  !traversalStack.empty(   ) )
           {
           OcclusionElement& node = *traversalStack.top (   );
           traversalStack.pop (   );
          
           // make sure there's no loop of some sort.
           // as we must query a node only once
           assert (  frameId != node.getNodeData (  mCurrentCam )->lastQueryFrameId );
           if (  insideViewFrustum (  node ) )
           {
           VisibilityData * const vis = node.getNodeData (  mCurrentCam );
          
           // identify visible in the last frame nodes
           const bool wasVisible = vis->queryVisible;
           const bool wasVisibleandQueriedBeforeLastNFrame = wasVisible
           && lastframeId - frameConservativeVisibility < vis->lastQueryFrameId;
           if (  wasVisibleandQueriedBeforeLastNFrame )
           {
           if (  node.isLeaf(   ) && node.isOccluder(   ) )
           {
           MovableObjectList *moToRender = static_cast <PagingLandScapeOctreeNode *> (  &node )->getVisibleNotifiedNodeObjects(  mCurrentCam,   mOnlyShadowCaster );
           // create the render Queue.
           if (  !moToRender->empty(   ) )
           {
           MovableObjectList::iterator it = moToRender->begin(   ),  
           itend = moToRender->end(   );
           while (  it != itend )
           {
           (  *it )->_updateRenderQueue (  &*mCurrentRenderQueue );
           ++it;
           }
           mScnMngr->directRenderSingleQueue (  &*mCurrentRenderQueue );
           }
           vis->notified = true;
           }
           pullUpVisibility (  node );
           node.traversal (  toStackTraversal,   visibleBounds );
           //node.traversal (  toStackTraversal,   0 );
           }
           else
           {
           const bool wasVisibleandQueriedExacltyLastNFrame = wasVisible &&
           lastframeId - frameConservativeVisibility == vis->lastQueryFrameId;
           if (  node.isLeaf(   ) )
           {
           if (  wasVisibleandQueriedExacltyLastNFrame && node.isOccluder(   ) )
           {
           // Draw & query at the same time previously visible nodes
           if (  issueDrawQuery (  static_cast <PagingLandScapeOctreeNode &> (  node ) ) )
           {
           m_queryQueue.push (  &node );
           }
           else
           {
           // skip testing previously visible node
           // that is not visible when notified.
           // make next frame get here again,  
           // saving a box query
           vis->queryVisible = true;
           vis->lastQueryFrameId = frameId;
           continue;
           }
           }
           else
           {
           issueBboxQuery (  node );
           m_queryQueue.push (  &node );
           }
           }
           else
           {
           if (  wasVisibleandQueriedExacltyLastNFrame )
           {
           // skip testing previously visible node
           // (  interior nodes in hierarchy )
           node.traversal (  toStackTraversal,   visibleBounds );
           //node.traversal (  toStackTraversal,   0 );
           }
           else
           {
           // only query node that wasn't visible last frame
           issueBboxQuery (  node );
           m_queryQueue.push (  &node );
           }
           }
           // reset this node's visibility to false
           // Will be updated by results queries that will pull up results.
           // by children that will be flagged visible and will transmit info
           // to their parent nodes (  pullUpVisibility(   ) )
           vis->queryVisible = false;
           // update node's visited flag to make sure we won't visit 2 times
           // and to "tick" the visible info.
           vis->lastQueryFrameId = frameId;
           }
           }
           }
           }
           }
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusionCHCTraversal.cpp

       1  
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          #include "OgrePagingLandScapeOcclusion.h"
          
          #include "OgrePagingLandScapeOcclusionSorter.h"
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          #include "OgrePagingLandScapeOcclusionCHCTraversal.h"
          #include "OgrePagingLandScapeOcclusionVisibilityData.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      19   void CHCTraversal::onTree(  PagingLandScapeOctree& node,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           #ifdef _VISIBILITYDEBUG
           assert (  node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible );
           occlusion.traversed_nodes_cnt++;
           #endif //_VISIBILITYDEBUG
          
           if (  !node.mNodes.empty(   ) )
           {
           PagingLandScapeOctreeNodeList::iterator it = node.mNodes.begin(   );
           while (  it != node.mNodes.end(   ) )
           {
           stack.push (  *it );
           ++it;
           }
           }
          
           PagingLandScapeOctree *n =
           node.mChildren[ 0 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           stack.push(  n );
           n = node.mChildren[ 1 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           stack.push(  n );
           n = node.mChildren[ 0 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           stack.push(  n );
           n = node.mChildren[ 1 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           stack.push(  n );
           n = node.mChildren[ 0 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           stack.push(  n );
           n = node.mChildren[ 1 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           stack.push(  n );
           n = node.mChildren[ 0 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           stack.push(  n );
           n = node.mChildren[ 1 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           stack.push(  n );
           }
           //-----------------------------------------------------------------------
      63   void CHCTraversal::onLeaf(  PagingLandScapeOctreeNode& n,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           #ifdef _VISIBILITYDEBUG
           assert (  n.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible );
           assert (  n.getNodeData (  occlusion.mCurrentCam )->queryVisible );
           occlusion.traversed_nodes_cnt++;
           #endif //_VISIBILITYDEBUG
           if (  !n.isOccluder(   ) || mIsNotSolidScene )
           occlusion.queueDraw (  n );
           }
           //-----------------------------------------------------------------------
      74   CHCTraversal::CHCTraversal(  FrontToBackNodeSorterPriorityQueue& vStack,   Occlusion& o ):
           stack(  vStack ),  
           occlusion(  o ),  
           frameId(  o.getFrame(   ) ),  
           mIsNotSolidScene(  occlusion.isNotSolidScene(   ) )
           {
           }
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusionCameraTraversal.cpp

       1  
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          #include "OgrePagingLandScapeOcclusion.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          #include "OgrePagingLandScapeOcclusionCameraTraversal.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      18   void RegisterCameraTraversal::onTree(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           n.addCamNodeData (  cam );
           traverseChildren (  n,   visibleBounds );
           }
           //-----------------------------------------------------------------------
      24   void RegisterCameraTraversal::onLeaf(  PagingLandScapeOctreeNode& n,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           n.addCamNodeData (  cam );
           }
           //-----------------------------------------------------------------------
      29   void UnregisterCameraTraversal::onTree(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           n.removeCamNodeData (  cam );
           traverseChildren (  n,   visibleBounds );
           }
           //-----------------------------------------------------------------------
      35   void UnregisterCameraTraversal::onLeaf(  PagingLandScapeOctreeNode& n,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           n.removeCamNodeData (  cam );
           }
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusionDebugTraversal.cpp

       1  
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapePrerequisites.h"
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          #include "OgrePagingLandScapeOcclusion.h"
          
          #include "OgrePagingLandScapeOcclusionVisibilityData.h"
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          #include "OgrePagingLandScapeOcclusionDebugTraversal.h"
          
          #include "OgreDebugRectangle2D.h"
          
          #ifdef _VISIBILITYDEBUG
          namespace Ogre
          {
           // Debug Info
           //
           //-----------------------------------------------------------------------
      24   TreeOverlayDebug::TreeOverlayDebug(  Occlusion& o,   PagingLandScapeOctreeSceneManager *scnMgr ):
           occlusion(  o ),  
           mScnMrg (  scnMgr )
           {
           }
           //-----------------------------------------------------------------------
      30   void TreeOverlayDebug::onTree(  PagingLandScapeOctree& n,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           SimpleRenderable * const s = n.getRectangle2d(  mScnMrg );
           if (  n.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible )
           {
           if (  n.getNodeData (  occlusion.mCurrentCam )->queryVisible )
           {
           s->setMaterial (  "BaseWhiteNoLightNoDepthCheck" );
           occlusion.mCurrentRenderQueue->addRenderable (  s,   s->getRenderQueueGroup (   ) );
          
           traverseChildren (  n,   visibleBounds );
           }
           else
           {
           s->setMaterial (  "BaseRedNoLightNoDepthCheck" );
           occlusion.mCurrentRenderQueue->addRenderable (  s,   s->getRenderQueueGroup (   ) );
           }
           }
           else
           {
           s->setMaterial (  "BaseGreenNoLightNoDepthCheck" );
           occlusion.mCurrentRenderQueue->addRenderable (  s,   s->getRenderQueueGroup (   ) );
           }
           }
           //-----------------------------------------------------------------------
      55   void TreeOverlayDebug::onLeaf(  PagingLandScapeOctreeNode& n,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           SimpleRenderable * const s = n.getRectangle2d(  mScnMrg );
           if(  n.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible )
           {
           if(  n.getNodeData (  occlusion.mCurrentCam )->queryVisible )
           {
           s->setMaterial (  "BaseWhiteNoLightNoDepthCheck" );
           occlusion.mCurrentRenderQueue->addRenderable(  s,   s->getRenderQueueGroup (   ) );
           }
           else
           {
           s->setMaterial (  "BaseRedNoLightNoDepthCheck" );
           occlusion.mCurrentRenderQueue->addRenderable(  s,   s->getRenderQueueGroup (   ) );
           }
           }
           else
           {
           s->setMaterial (  "BaseGreenNoLightNoDepthCheck" );
           occlusion.mCurrentRenderQueue->addRenderable(  s,   s->getRenderQueueGroup (   ) );
           }
           }
          }
          #endif //_VISIBILITYDEBUG

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusionElement.cpp

       1  
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include <stack>
          #include <queue>
          
          #include "OgrePagingLandScapeOcclusionElement.h"
          
          #include "OgrePagingLandScapePrerequisites.h"
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include "OgrePagingLandScapeOcclusionVisibilityData.h"
          #include "OgreDebugRectangle2D.h"
          
          
          namespace Ogre
          {
           //---------------------------------------------------------------------
      18   OcclusionElement::OcclusionElement(   ) :
           #ifdef _VISIBILITYDEBUG
           mDebugRectangle2d(  0 ),  
           #endif //_VISIBILITYDEBUG
           mIsRegisteredToCam (  false )
           {
           }
           //---------------------------------------------------------------------
      26   OcclusionElement::~OcclusionElement(   )
           {
           #ifdef _VISIBILITYDEBUG
           delete mDebugRectangle2d;
           #endif //_VISIBILITYDEBUG
          
           NodeDataPerCamMapiterator i = nodeDataPerCam.begin (   );
           while (  i != nodeDataPerCam.end(   ) )
           {
           delete i->second;
           ++i;
           }
           nodeDataPerCam.clear(   );
           }
           //---------------------------------------------------------------------
      41   VisibilityData *OcclusionElement::getNodeData(  PagingLandScapeOctreeCamera *cam )
           {
           if (  nodeDataPerCam.find(  cam->getId(   ) ) == nodeDataPerCam.end(   ) )
           nodeDataPerCam[cam->getId(   )] = new VisibilityData(   );
           //assert (  nodeDataPerCam.find(  cam->getId(   ) ) != nodeDataPerCam.end(   ) );
           return nodeDataPerCam[cam->getId(   )];
           }
           //---------------------------------------------------------------------
      49   void OcclusionElement::addCamNodeData (  PagingLandScapeOctreeCamera *cam )
           {
           if (  nodeDataPerCam.find(  cam->getId(   ) ) == nodeDataPerCam.end(   ) )
           nodeDataPerCam[cam->getId(   )] = new VisibilityData(   );
           }
           //---------------------------------------------------------------------
      55   void OcclusionElement::removeCamNodeData (  PagingLandScapeOctreeCamera *cam )
           {
           NodeDataPerCamMapiterator i = nodeDataPerCam.find (  cam->getId(   ) );
           if (  i != nodeDataPerCam.end(   ) )
           {
           delete i->second;
           nodeDataPerCam.erase (  i );
           }
           }
           #ifdef _VISIBILITYDEBUG
           //---------------------------------------------------------------------
      66   DebugRectangle2D *OcclusionElement::getRectangle2d(  SceneManager *scnMgr )
           {
           if (  !mDebugRectangle2d )
           {
           mDebugRectangle2d = new DebugRectangle2D(   );
           //scnMgr->getRootSceneNode (   )->createChildSceneNode (   )->attachObject (  mDebugRectangle2d );
           }
           return mDebugRectangle2d;
           }
           #endif //_VISIBILITYDEBUG
          }//namespace Ogre

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusionQuerySet.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
           (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2005 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          #include "Ogre.h"
          #include "OgrePagingLandScapeOcclusionQuerySet.h"
          #include "OgreHardwareOcclusionQuery.h"
          
          
          namespace Ogre
          {
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusionSWTraversal.cpp

       1  
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          #include "OgrePagingLandScapeOcclusionSWTraversal.h"
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          
          #include "OgrePagingLandScapeOcclusionSorter.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          #include "OgrePagingLandScapeOcclusion.h"
          #include "OgrePagingLandScapeOcclusionVisibilityData.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      19   SWTraversal::SWTraversal (  Occlusion& o ):
           occlusion(  o ),  
           mCurrentVisibility (  PagingLandScapeOctreeCamera::NONE ),  
           camPos(  occlusion.mCurrentCam->getDerivedPosition (   ) )
           {
          
           }
           //-----------------------------------------------------------------------
      27   void SWTraversal::traverseChildren(  PagingLandScapeOctree & node,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           FrontToBackNodeSorterPriorityQueue myStack = FrontToBackNodeSorterPriorityQueue(  FrontToBackNodeSorterOperator (  camPos ) );
          
           //assert (  node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible );
           if (  !node.mNodes.empty(   ) )
           {
           PagingLandScapeOctreeNodeList::const_iterator it = node.mNodes.begin(   );
           while (  it != node.mNodes.end(   ) )
           {
           myStack.push(  *it );
           ++it;
           }
           }
          
           PagingLandScapeOctree *n =
           node.mChildren[ 0 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           myStack.push (  n );
           n = node.mChildren[ 1 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           myStack.push (  n );
           n = node.mChildren[ 0 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           myStack.push (  n );
           n = node.mChildren[ 1 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           myStack.push (  n );
           n = node.mChildren[ 0 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           myStack.push (  n );
           n = node.mChildren[ 1 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           myStack.push (  n );
           n = node.mChildren[ 0 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           myStack.push (  n );
           n = node.mChildren[ 1 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           myStack.push (  n );
          
           //traverse nearer child first
           while (  !myStack.empty (   ) )
           {
           OcclusionElement& nstacked = *myStack.top (   );
           myStack.pop (   );
           nstacked.traversal(  *this,   visibleBounds );
           }
           }
           //-----------------------------------------------------------------------
      77   bool SWTraversal::isVisible(  OcclusionElement & n )
           {
           // issue query
           if (  n.isLeaf (   ) && n.isOccluder(   )  )
           {
           if (  occlusion.issueDrawQuery (  static_cast <PagingLandScapeOctreeNode &> (  n ) ) )
           {
           // we just wait for result
           return occlusion.isQueryResultIsVisible (  n );
           }
           else
           {
           return false;
           }
           }
           else
           {
           occlusion.issueBboxQuery (  n );
           // we just wait for result
           return occlusion.isQueryResultIsVisible (  n );
           }
          
           }
           //-----------------------------------------------------------------------
     101   void SWTraversal::onLeaf(  PagingLandScapeOctreeNode &n,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           if(  occlusion.mCurrentCam->isVisible (  n.getCullBoundingBox (   ) ) )
           {
          
           #ifdef _VISIBILITYDEBUG
           occlusion.traversed_nodes_cnt++;
           n.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = true;
           #endif //_VISIBILITYDEBUG
          
           const bool isitVisible = isVisible (  n );
           if (  isitVisible )
           {
           #ifdef _VISIBILITYDEBUG
           occlusion.object_cnt++;
           #endif //_VISIBILITYDEBUG
           occlusion.queueDraw (  n );
           }
           #ifdef _VISIBILITYDEBUG
           n.getNodeData (  occlusion.mCurrentCam )->queryVisible = isitVisible;
           #endif //_VISIBILITYDEBUG
          
           }
          
           #ifdef _VISIBILITYDEBUG
           else
           {
           occlusion.traversed_nodes_cnt++;
           n.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = false;
           occlusion.frustum_culled_nodes_cnt++;
           }
           #endif //_VISIBILITYDEBUG
           }
           //-----------------------------------------------------------------------
     135   void SWTraversal::onTree(  PagingLandScapeOctree & n,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           if(  occlusion.mCurrentCam->isVisible(  n.getCullBoundingBox (   ) ) )
           {
          
           #ifdef _VISIBILITYDEBUG
           occlusion.traversed_nodes_cnt++;
           n.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = true;
           #endif //_VISIBILITYDEBUG
          
           const bool isitVisible = isVisible(  n );
          
           if (  isitVisible )
           {
           traverseChildren (  n,   visibleBounds );
           }
          
           #ifdef _VISIBILITYDEBUG
           n.getNodeData (  occlusion.mCurrentCam )->queryVisible = isitVisible;
           #endif //_VISIBILITYDEBUG
          
           }
          
           #ifdef _VISIBILITYDEBUG
           else
           {
           occlusion.traversed_nodes_cnt++;
           n.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = false;
           occlusion.frustum_culled_nodes_cnt++;
           }
           #endif //_VISIBILITYDEBUG
           }
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusionTraversal.cpp

       1  
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          #include "OgrePagingLandScapeOcclusion.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      15   void ConstTraversalConst::traverseChildren(  const PagingLandScapeOctree& node,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           if (  !node.mNodes.empty(   ) )
           {
           //Add stuff to be rendered;
           PagingLandScapeOctreeNodeList::const_iterator it = node.mNodes.begin(   );
           PagingLandScapeOctreeNodeList::const_iterator itEnd = node.mNodes.end(   );
           while (  it != itEnd )
           {
           (  *it )->traversal (  *this,   visibleBounds );
           ++it;
           }
           }
          
           PagingLandScapeOctree *n =
           node.mChildren[ 0 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 1 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 0 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 1 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 0 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 1 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 0 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 1 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           }
           //-----------------------------------------------------------------------
      57   void TraversalConst::traverseChildren(  PagingLandScapeOctree& node,   VisibleObjectsBoundsInfo * const visibleBounds ) const
           {
           if (  !node.mNodes.empty(   ) )
           {
           //Add stuff to be rendered;
           PagingLandScapeOctreeNodeList::iterator it = node.mNodes.begin(   );
           PagingLandScapeOctreeNodeList::iterator itEnd = node.mNodes.end(   );
           while (  it != itEnd )
           {
           (  *it )->traversal(  *this,   visibleBounds );
           ++it;
           }
           }
          
           PagingLandScapeOctree *n =
           node.mChildren[ 0 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 1 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 0 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 1 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 0 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 1 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 0 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
           n = node.mChildren[ 1 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           }
           //-----------------------------------------------------------------------
      99   void Traversal::traverseChildren(  PagingLandScapeOctree& node,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           // hasLocalChildren
           if (  !node.mNodes.empty(   ) )
           {
           //Add stuff to be rendered;
           PagingLandScapeOctreeNodeList::iterator it = node.mNodes.begin(   );
           PagingLandScapeOctreeNodeList::iterator itEnd = node.mNodes.end(   );
           while (  it != itEnd )
           {
           (  *it )->traversal (  *this,   visibleBounds );
           ++it;
           }
           }
          
           PagingLandScapeOctree *n =
           node.mChildren[ 0 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           n = node.mChildren[ 1 ][ 0 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           n = node.mChildren[ 0 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           n = node.mChildren[ 1 ][ 1 ][ 0 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           n = node.mChildren[ 0 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           n = node.mChildren[ 1 ][ 0 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           n = node.mChildren[ 0 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           n = node.mChildren[ 1 ][ 1 ][ 1 ];
           if (  n && n->hasChildren(   ) )
           n->traversal (  *this,   visibleBounds );
          
           }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusionVFTraversal.cpp

       1  
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          #include "OgrePagingLandScapeOcclusionVFTraversal.h"
          
          #include "OgrePagingLandScapeOcclusionVisibilityData.h"
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          #include "OgrePagingLandScapeOcclusionElement.h"
          #include "OgrePagingLandScapeOcclusion.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      18   ViewFrustumCullingTraversal::ViewFrustumCullingTraversal (  Occlusion& o ):
           occlusion(  o ),  
           mCurrentVisibility (  PagingLandScapeOctreeCamera::NONE )
           {
          
           }
           //-----------------------------------------------------------------------
      25   void ViewFrustumCullingTraversal::onTree(  PagingLandScapeOctree& node,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           PagingLandScapeOctreeCamera::Visibility newVis = mCurrentVisibility;
          
           if (  newVis != PagingLandScapeOctreeCamera::FULL )
           {
           // box is not hierarchically culled as inside frustum box
           // so we need to check it.
           newVis = occlusion.mCurrentCam->getVisibility(  node.getCullBoundingBox (   ) );
           // if the octant is invisible
           if (  newVis == PagingLandScapeOctreeCamera::NONE )
           {
           // Culled Octree.
           // outside frustum
          
           #ifdef _VISIBILITYDEBUG
           node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = false;
           node.getNodeData (  occlusion.mCurrentCam )->queryVisible = false;
           occlusion.frustum_culled_nodes_cnt++;
           occlusion.traversed_nodes_cnt++;
           #endif //_VISIBILITYDEBUG
          
           return;
           }
           }
          
           #ifdef _VISIBILITYDEBUG
           node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = true;
           node.getNodeData (  occlusion.mCurrentCam )->queryVisible = true;
           occlusion.traversed_nodes_cnt++;
           #endif //_VISIBILITYDEBUG
          
           // if we get there,   then it's at least partially visible.
           // Store parent Vis
           PagingLandScapeOctreeCamera::Visibility oldVis = mCurrentVisibility;
           mCurrentVisibility = newVis;
          
           traverseChildren (  node,   visibleBounds );
          
           // Restore Parent Vis so that bothers can be pre-culled.
           mCurrentVisibility = oldVis;
           }
           //-----------------------------------------------------------------------
      68   void ViewFrustumCullingTraversal::onLeaf(  PagingLandScapeOctreeNode &node,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           // if this PagingLandScapeOctree is partially visible,   manually cull all
           // scene nodes attached directly to this level.
           PagingLandScapeOctreeCamera::Visibility newVis = mCurrentVisibility;
           if (  newVis != PagingLandScapeOctreeCamera::FULL )
           {
           newVis = occlusion.mCurrentCam->getVisibility(  node.getCullBoundingBox (   ) );
           // if the node is invisible
           if (  newVis == PagingLandScapeOctreeCamera::NONE )
           {
           // Culled Node.
           // outside frustum
          
           #ifdef _VISIBILITYDEBUG
           node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = false;
           node.getNodeData (  occlusion.mCurrentCam )->queryVisible = false;
           occlusion.frustum_culled_nodes_cnt++;
           occlusion.traversed_nodes_cnt++;
           #endif //_VISIBILITYDEBUG
          
           return;
           }
           }
          
           #ifdef _VISIBILITYDEBUG
           node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = true;
           node.getNodeData (  occlusion.mCurrentCam )->queryVisible = true;
           occlusion.traversed_nodes_cnt++;
           occlusion.object_cnt++;
           #endif //_VISIBILITYDEBUG
          
           // if we get there,   then it's at least partially visible.
           // Store parent Vis
           PagingLandScapeOctreeCamera::Visibility oldVis = mCurrentVisibility;
           mCurrentVisibility = newVis;
          
           node._addToRenderQueue (  occlusion.mCurrentCam,  
           occlusion.mCurrentRenderQueue,  
           occlusion.mOnlyShadowCaster,   visibleBounds );
          
          
           // Restore Parent Vis so that bothers can be pre-culled.
           mCurrentVisibility = oldVis;
           }
          
          
           //-----------------------------------------------------------------------
     116   ViewFrustumCullingTraversalDirect::ViewFrustumCullingTraversalDirect (  Occlusion& o ):
           occlusion(  o )
           {
          
           }
           //-----------------------------------------------------------------------
     122   void ViewFrustumCullingTraversalDirect::onTree(  PagingLandScapeOctree& node,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           if (  occlusion.mCurrentCam->isVisible(  node.getCullBoundingBox (   ) ) )
           {
          
           #ifdef _VISIBILITYDEBUG
           occlusion.traversed_nodes_cnt++;
           node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = true;
           node.getNodeData (  occlusion.mCurrentCam )->queryVisible = true;
           #endif //_VISIBILITYDEBUG
          
           // if we get there,   then it's at least partially visible.
           traverseChildren (  node,   visibleBounds );
           }
           #ifdef _VISIBILITYDEBUG
           else
           {
           // Culled Octree.
           // outside frustum
           occlusion.traversed_nodes_cnt++;
           occlusion.frustum_culled_nodes_cnt++;
           node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = false;
           node.getNodeData (  occlusion.mCurrentCam )->queryVisible = false;
           }
           #endif //_VISIBILITYDEBUG
           }
           //-----------------------------------------------------------------------
     149   void ViewFrustumCullingTraversalDirect::onLeaf(  PagingLandScapeOctreeNode &node,   VisibleObjectsBoundsInfo * const visibleBounds )
           {
           // if this PagingLandScapeOctree is partially visible,   manually cull all
           // scene nodes attached directly to this level.
           if (  occlusion.mCurrentCam->isVisible(  node.getCullBoundingBox (   ) ) )
           {
           #ifdef _VISIBILITYDEBUG
           occlusion.traversed_nodes_cnt++;
           node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = true;
           node.getNodeData (  occlusion.mCurrentCam )->queryVisible = true;
           occlusion.object_cnt++;
           #endif //_VISIBILITYDEBUG
          
           // if we get there,   then it's at least partially visible.
           node._addToRenderQueue (  occlusion.mCurrentCam,  
           occlusion.mCurrentRenderQueue,  
           occlusion.mOnlyShadowCaster,   visibleBounds );
          
           }
           #ifdef _VISIBILITYDEBUG
           else
           {
           // Culled Octree.
           // outside frustum
           occlusion.traversed_nodes_cnt++;
           occlusion.frustum_culled_nodes_cnt++;
           node.getNodeData (  occlusion.mCurrentCam )->viewFrustumVisible = false;
           node.getNodeData (  occlusion.mCurrentCam )->queryVisible = false;
           }
           #endif //_VISIBILITYDEBUG
           }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOctree.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later__add
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          PagingLandScapeOctree.cpp - description
          -------------------
          begin : Mon Sep 30 2002
          copyright : (  C ) 2002 by Jon Anderson
          email : janders@users.sf.net
          
          Enhancements 2003 - 2004 (  C ) The OGRE Team
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreWireBoundingBox.h"
          #include "OgreOcclusionBoundingBox.h"
          
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          #include "OgreDebugRectangle2D.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      49   PagingLandScapeOctree::PagingLandScapeOctree(   ) :
           OcclusionElement(   ),  
          
           mWireBoundingBox(  0 ),  
           mHalfSize(  Vector3::ZERO ),  
           mNumNodes (  0 ),  
           mParent (  0 ),  
           mOcclusionBoundingBox(  0 )
           {
           //initialize all children to null.
           for (  unsigned int i = 0; i < 2; i++ )
           {
           for (  unsigned int j = 0; j < 2; j++ )
           {
           for (  unsigned int k = 0; k < 2; k++ )
           {
           mChildren[ i ][ j ][ k ] = 0;
           }
           }
           }
           }
           //-----------------------------------------------------------------------
      71   void PagingLandScapeOctree::reset(   )
           {
           //initialize all children to null.
           PagingLandScapeOctree *o;
           for (  unsigned int i = 0; i < 2; i++ )
           {
           for (  unsigned int j = 0; j < 2; j++ )
           {
           for (  unsigned int k = 0; k < 2; k++ )
           {
           o = mChildren[ i ][ j ][ k ];
           if (  o )
           {
           mSceneMgr->deleteOctree (  mChildren[ i ][ j ][ k ] );
           mChildren[ i ][ j ][ k ] = 0;
           }
           }
           }
           }
           mSceneMgr = 0;
           mParent = 0;
           mNumNodes = 0;
           }
           //-----------------------------------------------------------------------
      95   PagingLandScapeOctree::~PagingLandScapeOctree(   )
           {
           //initialize all children to null.
          #ifdef _DEBUG
           for (  unsigned int i = 0; i < 2; i++ )
           {
           for (  unsigned int j = 0; j < 2; j++ )
           {
           for (  unsigned int k = 0; k < 2; k++ )
           {
           assert (  mChildren[ i ][ j ][ k ] == 0 );
           }
           }
           }
          #endif //_DEBUG
          
           delete mWireBoundingBox;
           delete mOcclusionBoundingBox;
          
           mParent = 0;
           }
           //-----------------------------------------------------------------------
           /** Returns true is the box will fit in a child.
           */
     119   bool PagingLandScapeOctree::_isTwiceSize(  const AxisAlignedBox &box ) const
           {
           // infinite boxes never fit in a child - always root node
           if (  box.isInfinite(   ) )
           return false;
          
           const Vector3 &halfMBoxSize = mBox.getHalfSize(   );
           const Vector3 &boxSize = box.getSize(   );
           return (  (  boxSize.x <= halfMBoxSize.x ) &&
           (  boxSize.y <= halfMBoxSize.y ) &&
           (  boxSize.z <= halfMBoxSize.z ) );
           }
           //-----------------------------------------------------------------------
           /** Returns true is the box will fit in a child.
           */
     134   bool PagingLandScapeOctree::_isTwiceCullSize(  const AxisAlignedBox &box ) const
           {
           // infinite boxes never fit in a child - always root node
           if (  box.isInfinite(   ) )
           return false;
          
           const Vector3 &boxSize = box.getSize(   );
           return(  boxSize.x <= mCullHalfSize.x ) &&
           (  boxSize.y <= mCullHalfSize.y ) &&
           (  boxSize.z <= mCullHalfSize.z ) ;
          
           }
           //-----------------------------------------------------------------------
           /** Returns true is the box will fit in a child.
           */
     149   bool PagingLandScapeOctree::_isNotCrossingAxes(  const AxisAlignedBox &box ) const
           {
           const Vector3 &boxMin = box.getMinimum(   );
           const Vector3 &boxMax = box.getMaximum(   );
          
           const Vector3 octCullCenter = mCullBox.getMinimum(   ) + mCullHalfSize;
          
           return !(  (  boxMin.x <= octCullCenter.x && octCullCenter.x <= boxMax.x ) ||
           (  boxMin.y <= octCullCenter.y && octCullCenter.y <= boxMax.y ) ||
           (  boxMin.z <= octCullCenter.z && octCullCenter.z <= boxMax.z ) );
          
           }
           //-----------------------------------------------------------------------
     162   PagingLandScapeOctree *PagingLandScapeOctree::_getCullChildWhereBoxFits(  const AxisAlignedBox &box,  
     163   PagingLandScapeOctreeSceneManager *scn )
           {
           /** It's assumed the the given box has already been proven to fit into
           * a child. Since it's a loose PagingLandScapeOctree,   only the centers need to be
           * compared to find the appropriate node.
           */
           const Vector3 octCenter = mCullBox.getMinimum(   ) + mCullHalfSize;
           const Vector3 ncenter = box.getMaximum(   ).midPoint(  box.getMinimum(   ) );
          
           unsigned int x;
           if (  ncenter.x > octCenter.x )
           x = 1;
           else
           x = 0;
          
           unsigned int y;
           if (  ncenter.y > octCenter.y )
           y = 1;
           else
           y = 0;
          
           unsigned int z;
           if (  ncenter.z > octCenter.z )
           z = 1;
           else
           z = 0;
          
           if (  mChildren[ x ][ y ][ z ] == 0 )
           {
           const Vector3 &octantMax = mBox.getMaximum(   );
           const Vector3 &octantMin = mBox.getMinimum(   );
          
           Vector3 min,   max;
          
           if (  x == 0 )
           {
           min.x = octantMin.x;
           max.x = octCenter.x;
           }
           else
           {
           min.x = octCenter.x;
           max.x = octantMax.x;
           }
          
           if (  y == 0 )
           {
           min.y = octantMin.y;
           max.y = octCenter.y;
           }
           else
           {
           min.y = octCenter.y;
           max.y = octantMax.y;
           }
          
           if (  z == 0 )
           {
           min.z = octantMin.z;
           max.z = octCenter.z;
           }
           else
           {
           min.z = octCenter.z;
           max.z = octantMax.z;
           }
          
           PagingLandScapeOctree *newChild = scn->getNewOctree(   );
           newChild->setParent (  this );
           newChild->setSceneManager(  scn );
           newChild ->setBoundingBox(  min,   max );
           scn->registeredNodeInCamera (  newChild );
           #ifdef _VISIBILITYDEBUG
           newChild ->setDebugCorners(  scn );
           #endif //_VISIBILITYDEBUG
           mChildren[x][y][z] = newChild;
           }
           return mChildren[x][y][z];
          
           }
           //-----------------------------------------------------------------------
     244   PagingLandScapeOctree *PagingLandScapeOctree::_getChildWhereBoxFits(  const AxisAlignedBox &box,  
     245   PagingLandScapeOctreeSceneManager *scn )
           {
           /** It's assumed the the given box has already been proven to fit into
           * a child. Since it's a loose PagingLandScapeOctree,   only the centers need to be
           * compared to find the appropriate node.
           */
           const Vector3 &octantMax = mBox.getMaximum(   );
           const Vector3 &octantMin = mBox.getMinimum(   );
           const Vector3 octCenter = octantMin + mHalfSize;
          
           const Vector3 ncenter = box.getMaximum(   ).midPoint(  box.getMinimum(   ) );
          
           assert (  octantMax.x >= ncenter.x && octantMax.y >= ncenter.y && octantMax.z >= ncenter.z &&
           octantMin.x <= ncenter.x && octantMin.y <= ncenter.y && octantMin.z <= ncenter.z );
          
           unsigned int x;
           if (  ncenter.x > octCenter.x )
           x = 1;
           else
           x = 0;
          
           unsigned int y;
           if (  ncenter.y > octCenter.y )
           y = 1;
           else
           y = 0;
          
           unsigned int z;
           if (  ncenter.z > octCenter.z )
           z = 1;
           else
           z = 0;
          
           if (  mChildren[ x ][ y ][ z ] == 0 )
           {
           Vector3 min,   max;
          
           if (  x == 0 )
           {
           min.x = octantMin.x;
           max.x = octCenter.x;
           }
           else
           {
           min.x = octCenter.x;
           max.x = octantMax.x;
           }
          
           if (  y == 0 )
           {
           min.y = octantMin.y;
           max.y = octCenter.y;
           }
           else
           {
           min.y = octCenter.y;
           max.y = octantMax.y;
           }
          
           if (  z == 0 )
           {
           min.z = octantMin.z;
           max.z = octCenter.z;
           }
           else
           {
           min.z = octCenter.z;
           max.z = octantMax.z;
           }
          
          #ifdef _DEBUG
           std::cout << "new Child\n";
          #endif
          
           PagingLandScapeOctree *newChild = scn->getNewOctree(   );
           newChild->setParent (  this );
           newChild->setSceneManager(  scn );
           newChild->setBoundingBox(  min,   max );
          
           assert (  max.x >= ncenter.x && max.y >= ncenter.y && max.z >= ncenter.z &&
           min.x <= ncenter.x && min.y <= ncenter.y && min.z <= ncenter.z );
          
          
           scn->registeredNodeInCamera (  newChild );
           #ifdef _VISIBILITYDEBUG
           newChild ->setDebugCorners(  scn );
           #endif //_VISIBILITYDEBUG
           mChildren[x][y][z] = newChild;
           }
           return mChildren[x][y][z];
          
           }
           //-----------------------------------------------------------------------
     338   void PagingLandScapeOctree::setBoundingBox(  const Vector3 &min,  
     339   const Vector3 &max )
           {
           mBox.setExtents(  min,   max );
           mCullHalfSize = max - min;
           const Vector3 halfSize = mCullHalfSize * 0.5f;
           mHalfSize = halfSize;
           mCullBox.setExtents(  min - halfSize,   max + halfSize );
           if(  mWireBoundingBox != 0 )
           mWireBoundingBox->setupBoundingBox(  mBox );
           if(  mOcclusionBoundingBox != 0 )
           mOcclusionBoundingBox->setupBoundingBox(  mBox );
           }
           //-----------------------------------------------------------------------
     352   void PagingLandScapeOctree::_addNode(  PagingLandScapeOctreeNode * n )
           {
           if (  n->isStaticNode (   ) )
           mStaticNodes.push_back (  n );
           else
           mMovingNodes.push_back (  n );
           mNodes.push_back (  n );
           n->setOctant(  this );
           //update total counts.
           _ref(   );
           }
           //-----------------------------------------------------------------------
     364   void PagingLandScapeOctree::_removeNode(  PagingLandScapeOctreeNode * n )
           {
           assert (  !mNodes.empty(   ) );
          
           NodeList::iterator it;
          
           it = std::find (  mNodes.begin (   ),   mNodes.end (   ),   n );
           if (  it != mNodes.end (   ) )
           mNodes.erase (  it );
          
           if (  n->isStaticNode (   ) )
           {
           it = std::find(  mStaticNodes.begin (   ),   mStaticNodes.end (   ),   n );
           if (  it != mStaticNodes.end (   ) )
           mStaticNodes.erase (  it );
           }
           else
           {
           it = std::find(  mMovingNodes.begin (   ),   mMovingNodes.end (   ),   n );
           if (  it != mMovingNodes.end (   ) )
           mMovingNodes.erase (  it );
           }
           n->setOctant(  0 );
           //update total counts.
           _unref(  mNumNodes == 1 );
           }
           //-----------------------------------------------------------------------
     391   void PagingLandScapeOctree::_unref(  const bool removeChildren )
           {
           --mNumNodes;
           if (  removeChildren )
           {
           //remove null children
           PagingLandScapeOctree *child;
           for (  unsigned int i = 0; i < 2; i++ )
           {
           for (  unsigned int j = 0; j < 2; j++ )
           {
           for (  unsigned int k = 0; k < 2; k++ )
           {
           child = mChildren[ i ][ j ][ k ];
           if (  child && !child->hasChildren(   ) )
           {
           mSceneMgr->deleteOctree(  child );
           mChildren[ i ][ j ][ k ] = 0;
           }
           }
           }
           }
           }
           if (  mParent != 0 )
           {
           mParent->_unref(  mNumNodes == 0 );
           }
           };
           //-----------------------------------------------------------------------
     420   void PagingLandScapeOctree::_getCullBounds(  AxisAlignedBox *b ) const
           {
           // const Vector3 * const corners = mBox.getAllCorners(   );
           // b->setExtents(  corners[ 0 ] - mHalfSize,   corners[ 4 ] + mHalfSize );
           *b = mCullBox;
           }
           //-----------------------------------------------------------------------
     427   WireBoundingBox* PagingLandScapeOctree::getWireBoundingBox(   )
           {
           // Create a WireBoundingBox if needed
           if (  mWireBoundingBox == 0 )
           {
           mWireBoundingBox = new WireBoundingBox(   );
           //mWireBoundingBox->setRenderQueueGroup (  RENDER_QUEUE_WORLD_GEOMETRY_2 );
           mWireBoundingBox->setupBoundingBox(  mBox );
           }
          
           return mWireBoundingBox;
           }
           //-----------------------------------------------------------------------
     440   OcclusionBoundingBox* PagingLandScapeOctree::getOcclusionBoundingBox(   )
           {
           // Create an OcclusionBoundingBox only if needed
           if (  mOcclusionBoundingBox == 0 )
           {
           mOcclusionBoundingBox = new OcclusionBoundingBox(   );
           //mOcclusionBoundingBox->setRenderQueueGroup (  RENDER_QUEUE_WORLD_GEOMETRY_2 );
           mOcclusionBoundingBox->setupBoundingBox (  mBox );
           }
           return mOcclusionBoundingBox;
           }
           //-----------------------------------------------------------------------
     452   void PagingLandScapeOctree::setParent(  PagingLandScapeOctree * parent )
           {
           mParent = parent;
           }
           //-----------------------------------------------------------------------
     457   void PagingLandScapeOctree::setSceneManager(  PagingLandScapeOctreeSceneManager * scn )
           {
           mSceneMgr = scn;
           }
          #ifdef _VISIBILITYDEBUG
           //-----------------------------------------------------------------------
     463   void PagingLandScapeOctree::setDebugCorners(  PagingLandScapeOctreeSceneManager *scnMgr )
           {
           // use the ratio (  OCtreeAAB / thisAAB ) / 8
           const Vector3 &max = mBox.getMaximum (   );
           const Vector3 &min = mBox.getMinimum (   );
          
           const Vector3 &sceneMax = scnMgr->getBoundingBox (   ).getMaximum (   );
           const Vector3 &sceneMin = scnMgr->getBoundingBox (   ).getMinimum (   );
          
           const Real width = sceneMax.x - sceneMin.x;
           const Real height = sceneMax.z - sceneMin.z;
           if (  Math::Abs(  width ) > 1e-08 && Math::Abs(  height ) > 1e-08 )
           {
           Real left = 0.0f,   top = 0.0f,   right = 0.0f,   bottom = 0.0f;
          
           const Real toScreenDivider = 1.0f / 3;
          
           const Real xleft = min.x - sceneMin.x;
           if (  Math::Abs(  xleft ) > 1e-08 )
           left = (  xleft / width ) * toScreenDivider;
          
           const Real ztop = min.z - sceneMin.z;
           if (  Math::Abs(  ztop ) > 1e-08 )
           top = (  ztop / height ) * toScreenDivider;
          
           const Real xright = max.x - sceneMin.x;
           if (  Math::Abs(  xright ) > 1e-08 )
           right = (  xright / width ) * toScreenDivider;
          
           const Real zbottom = max.z - sceneMin.z;
           if (  Math::Abs(  zbottom ) > 1e-08 )
           bottom = (  zbottom / height ) * toScreenDivider;
          
           getRectangle2d (  scnMgr )->setCorners (  (  1.0f - toScreenDivider ) + left,  
           (  1.0f - toScreenDivider ) + top,  
           (  1.0f - toScreenDivider ) + right,  
           (  1.0f - toScreenDivider ) + bottom );
           }
           }
          #endif //_VISIBILITYDEBUG
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOctreeAxisAlignedBoxSceneQuery.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreeAxisAlignedBoxSceneQuery.cpp - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004by Jon Anderson
          email : janders@users.sf.net
          
          
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOctreeAxisAlignedBoxSceneQuery.h"
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgreEntity.h"
          
          namespace Ogre
          {
          
          //---------------------------------------------------------------------
      46  PagingLandScapeOctreeAxisAlignedBoxSceneQuery::PagingLandScapeOctreeAxisAlignedBoxSceneQuery(  SceneManager* creator )
           : DefaultAxisAlignedBoxSceneQuery(  creator )
          {
          }
          
          //---------------------------------------------------------------------
      52  PagingLandScapeOctreeAxisAlignedBoxSceneQuery::~PagingLandScapeOctreeAxisAlignedBoxSceneQuery(  void )
          {
          }
          
          //---------------------------------------------------------------------
      57  void PagingLandScapeOctreeAxisAlignedBoxSceneQuery::execute(  SceneQueryListener* listener )
          {
           std::list < SceneNode* > list;
           //find the nodes that intersect the AAB
           static_cast< PagingLandScapeOctreeSceneManager* >(  mParentSceneMgr )->findNodesIn(  mAABB,   list,   0 );
          
           //grab all moveables from the node that intersect...
           std::list < SceneNode* >::iterator it = list.begin(   );
           while (  it != list.end(   ) )
           {
           SceneNode::ObjectIterator oit = (  *it )->getAttachedObjectIterator(   );
           while (  oit.hasMoreElements(   ) )
           {
           MovableObject* m = oit.getNext(   );
           if (  (  m->getQueryFlags(   ) & mQueryMask ) && m->isInScene(   ) && mAABB.intersects(  m->getWorldBoundingBox(   ) ) )
           {
           listener->queryResult(  m );
           }
           }
           ++it;
           }
          }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOctreeCamera.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          PagingLandScapeOctreecamera.cpp - description
          -------------------
          begin : Fri Sep 27 2002
          copyright : (  C ) 2002 by Jon Anderson
          email : janders@users.sf.net
          
          Enhancements 2003 - 2004 (  C ) The OGRE Team
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreMath.h"
          #include "OgreAxisAlignedBox.h"
          #include "OgreRoot.h"
          #include "OgreViewport.h"
          #include "OgreRenderSystem.h"
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          
          namespace Ogre
          {
           unsigned int PagingLandScapeOctreeCamera::s_camId = 0;
           //-----------------------------------------------------------------------
      51   PagingLandScapeOctreeCamera::PagingLandScapeOctreeCamera(  const String& name,   SceneManager* sm ) :
           Camera(  name,   sm ),  
           mVisFacesLastCHCRender(  0 ),  
           isOcclusionSystemRegistered (  false ),  
           mOcclusionMode (  VIEW_FRUSTUM_DIRECT ),  
           mFrameId(  0 ),  
           mFrameSceneId(  0 )
           {
           mUniqueIdentification = s_camId++;
           updateRegistrationInOcclusionSystem (   );
           }
           //-----------------------------------------------------------------------
      63   PagingLandScapeOctreeCamera::~PagingLandScapeOctreeCamera(   )
           {
           }
           //-----------------------------------------------------------------------
      67   bool PagingLandScapeOctreeCamera::nextFrame(  const unsigned int framesSceneId )
           {
           if (  framesSceneId != mFrameSceneId )
           {
           // change frame Id counter
           //that identify current frame.
           mFrameSceneId = framesSceneId;
           mFrameId += 1;
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
      80   bool PagingLandScapeOctreeCamera::isRegisteredInOcclusionSystem(   ) const
           {
           return isOcclusionSystemRegistered;
           }
           //-----------------------------------------------------------------------
      85   void PagingLandScapeOctreeCamera::setRegisteredInOcclusionSystem(  const bool registered )
           {
           isOcclusionSystemRegistered = registered;
           }
           //-----------------------------------------------------------------------
      90   void PagingLandScapeOctreeCamera::changeOcclusionMode(  culling_modes nextOcclusionMode )
           {
           if (  nextOcclusionMode != mOcclusionMode )
           {
           if (  nextOcclusionMode == VIEW_FRUSTUM_DIRECT )
           {
           if (  mLastViewport )
           mLastViewport->setClearEveryFrame (  true );
           }
           else
           {
           if (  !getSceneManager (   )->getDestinationRenderSystem (   )->getCapabilities(   )->hasCapability(  RSC_HWOCCLUSION ) )
           {
           OGRE_EXCEPT(  1,  
           "Your card does not support HWOCCLUSION ",  
           "PagingLandScapeOctreeCamera::setNextOcclusionMode" );
           }
           if (  mLastViewport )
           mLastViewport->setClearEveryFrame (  false );
           }
          
           mOcclusionMode = nextOcclusionMode;
           updateRegistrationInOcclusionSystem(   );
           }
           }
           //-----------------------------------------------------------------------
     116   void PagingLandScapeOctreeCamera::updateRegistrationInOcclusionSystem(   )
           {
           if (  needRegistrationInOcclusionSystem(   ) && !isRegisteredInOcclusionSystem(   ) )
           {
           static_cast <PagingLandScapeOctreeSceneManager *> (  getSceneManager (   ) )->registerCamera(  this );
           setRegisteredInOcclusionSystem (  true );
           }
           else if (  !needRegistrationInOcclusionSystem(   ) && isRegisteredInOcclusionSystem(   ) )
           {
           static_cast <PagingLandScapeOctreeSceneManager *> (  getSceneManager (   ) )->unregisterCamera(  this );
           setRegisteredInOcclusionSystem (  false );
           }
           }
           //-----------------------------------------------------------------------
     130   void PagingLandScapeOctreeCamera::setNextOcclusionMode(   )
           {
           culling_modes nextOcclusionMode = static_cast <culling_modes> (  (  mOcclusionMode + 1 ) % NUM_CULLING_MODE );
          
           changeOcclusionMode (  nextOcclusionMode );
           }
           //-----------------------------------------------------------------------
     137   bool PagingLandScapeOctreeCamera::needRegistrationInOcclusionSystem(   ) const
           {
           #ifdef _VISIBILITYDEBUG
           return true;
           #endif //_VISIBILITYDEBUG
          
           if (  mOcclusionMode == CHC ||
           mOcclusionMode == CHC_CONSERVATIVE )
           return true;
           else
           return false;
           };
           //-----------------------------------------------------------------------
     150   void PagingLandScapeOctreeCamera::setOcclusionMode(  culling_modes occlusionMode )
           {
           changeOcclusionMode (  occlusionMode );
           };
           //-----------------------------------------------------------------------
     155   void PagingLandScapeOctreeCamera::setOcclusionModeAsString(  const String &cullingModeAsString )
           {
           culling_modes cullingmode (  VIEW_FRUSTUM_DIRECT );
           if (  cullingModeAsString == "VIEW_FRUSTUM_DIRECT" )
           cullingmode = VIEW_FRUSTUM_DIRECT;
           else if (  cullingModeAsString == "CHC" )
           cullingmode = CHC;
           else if (  cullingModeAsString == "CHC_CONSERVATIVE" )
           cullingmode = CHC_CONSERVATIVE;
           setOcclusionMode(  cullingmode );
           };
           //-----------------------------------------------------------------------
     167   String PagingLandScapeOctreeCamera::getOcclusionModeAsString(   ) const
           {
           switch (  getOcclusionMode(   ) )
           {
           case CHC: return String(  "CHC" );
           case CHC_CONSERVATIVE: return String(  "CHC_CONSERVATIVE" );
           case VIEW_FRUSTUM_DIRECT:
           default:
           return String(  "VIEW_FRUSTUM_DIRECT" );
           }
           }
           //-----------------------------------------------------------------------
     179   PagingLandScapeOctreeCamera::Visibility PagingLandScapeOctreeCamera::getVisibility(  const AxisAlignedBox &bound ) const
           {
           // Null boxes always invisible
           if (   bound.isNull(   )  )
           return NONE;
           // Infinite boxes always visible
           if (  bound.isInfinite(   ) )
           return FULL;
          
           // Get centre of the box
           const Vector3 &centre (  bound.getCenter(   ) );
           // Get the half-size of the box
           const Vector3 &halfSize (  bound.getHalfSize(   ) );
          
           bool all_inside = true;
          
           const bool infinite_far_clip = (  mFarDist == 0 );
           for (  unsigned int plane = 0; plane < 6; ++plane )
           {
          
           // Skip far plane if infinite view frustum
           if (  plane == FRUSTUM_PLANE_FAR && infinite_far_clip )
           continue;
          
           // This updates frustum planes and deals with cull frustum
           const Plane::Side side = getFrustumPlane(  plane ).getSide(  centre,   halfSize );
           if (  side == Plane::NEGATIVE_SIDE )
           return NONE;
           // We can't return now as the box could be later on the negative side of a plane.
           if (  side == Plane::BOTH_SIDE )
           all_inside = false;
           }
          
           if (   all_inside  )
           return FULL;
           else
           return PARTIAL;
          
           }
          
          }
          
          
          
          

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOctreeIntersectionSceneQuery.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreeIntersectionSceneQuery.cpp - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004by Jon Anderson
          email : janders@users.sf.net
          
          
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOctreeIntersectionSceneQuery.h"
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgreEntity.h"
          #include "OgreRoot.h"
          
          namespace Ogre
          {
          
          //---------------------------------------------------------------------
      47  PagingLandScapeOctreeIntersectionSceneQuery::PagingLandScapeOctreeIntersectionSceneQuery(  SceneManager* creator )
           : DefaultIntersectionSceneQuery(  creator )
          {
          
          }
          
          //---------------------------------------------------------------------
      54  PagingLandScapeOctreeIntersectionSceneQuery::~PagingLandScapeOctreeIntersectionSceneQuery(  void )
          {
          }
          
          //---------------------------------------------------------------------
      59  void PagingLandScapeOctreeIntersectionSceneQuery::execute(  IntersectionSceneQueryListener* listener )
          {
           typedef std::pair<MovableObject *,   MovableObject *> MovablePair;
           typedef std::set
           < std::pair<MovableObject *,   MovableObject *> > MovableSet;
          
           MovableSet set;
          
           // Iterate over all movable types
           Root::MovableObjectFactoryIterator factIt =
           Root::getSingleton(   ).getMovableObjectFactoryIterator(   );
           while(  factIt.hasMoreElements(   ) )
           {
           SceneManager::MovableObjectIterator it =
           mParentSceneMgr->getMovableObjectIterator(  
           factIt.getNext(   )->getType(   ) );
           while(   it.hasMoreElements(   )  )
           {
          
           MovableObject * e = it.getNext(   );
          
           std::list < SceneNode * > list;
           //find the nodes that intersect the AAB
           static_cast<PagingLandScapeOctreeSceneManager*>(   mParentSceneMgr  ) -> findNodesIn(   e->getWorldBoundingBox(   ),   list,   0  );
           //grab all movables from the node that intersect...
           std::list < SceneNode * >::iterator itscn = list.begin(   );
           while(   itscn != list.end(   )  )
           {
           SceneNode::ObjectIterator oit = (  *itscn ) -> getAttachedObjectIterator(   );
           while(   oit.hasMoreElements(   )  )
           {
           MovableObject * m = oit.getNext(   );
          
           if(   m != e &&
           set.find(   MovablePair(  e,  m ) ) == set.end(   ) &&
           set.find(   MovablePair(  m,  e ) ) == set.end(   ) &&
           (  m->getQueryFlags(   ) & mQueryMask ) &&
           (  m->getTypeFlags(   ) & mQueryTypeMask ) &&
           m->isInScene(   ) &&
           e->getWorldBoundingBox(   ).intersects(   m->getWorldBoundingBox(   )  )  )
           {
           listener -> queryResult(   e,   m  );
           // deal with attached objects,   since they are not directly attached to nodes
           if (  m->getMovableType(   ) == "Entity" )
           {
           Entity* e2 = static_cast<Entity*>(  m );
           Entity::ChildObjectListIterator childIt = e2->getAttachedObjectIterator(   );
           while(  childIt.hasMoreElements(   ) )
           {
           MovableObject* c = childIt.getNext(   );
           if (  c->getQueryFlags(   ) & mQueryMask &&
           e->getWorldBoundingBox(   ).intersects(   c->getWorldBoundingBox(   )  ) )
           {
           listener->queryResult(  e,   c );
           }
           }
           }
           }
           set.insert(   MovablePair(  e,  m )  );
          
           }
           ++itscn;
           }
          
           }
           }
          }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOctreeNode.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          PagingLandScapeOctreenode.cpp - description
          -------------------
          begin : Fri Sep 27 2002
          copyright : (  C ) 2002 by Jon Anderson
          email : janders@users.sf.net
          
          Enhancements 2003 - 2004 (  C ) The OGRE Team
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreRoot.h"
          
          #include "OgrePagingLandScapeOctreeNode.h"
          #include "OgreOcclusionBoundingBox.h"
          #include "OgreWireBoundingBox.h"
          #include "OgreRenderQueue.h"
          
          #include "OgreDebugRectangle2D.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      50   PagingLandScapeOctreeNode::PagingLandScapeOctreeNode(  SceneManager* creator ) :
           SceneNode(  creator ),  
           OcclusionElement(   ),  
          
           mOctant(  0 ),  
           mOcclusionBoundingBox(  0 ),  
           mIsStaticNode(  true ),  
           mIsOccluder(  true )
           {
          
           }
           //-----------------------------------------------------------------------
      62   PagingLandScapeOctreeNode::PagingLandScapeOctreeNode(  SceneManager* creator,   const String& name ) :
           SceneNode(  creator,   name ),  
           OcclusionElement(   ),  
          
           mOctant(  0 ),  
           mOcclusionBoundingBox(  0 ),  
           mIsStaticNode(  true ),  
           mIsOccluder(  true )
           {
          
           }
           //-----------------------------------------------------------------------
      74   PagingLandScapeOctreeNode::~PagingLandScapeOctreeNode(   )
           {
           removeAllChildren(   );
           if (  mParent )
           mParent->removeChild(  this );
           assert (  !mParent );
           delete mOcclusionBoundingBox;
           }
           //-----------------------------------------------------------------------
           //same as SceneNode,   only it doesn't care about children...
      84   void PagingLandScapeOctreeNode::_updateBounds(  void )
           {
           mWorldAABB.setNull(   );
           mLocalAABB.setNull(   );
          
           // Update bounds from own attached objects
           ObjectMap::const_iterator i = mObjectsByName.begin(   );
           while (  i != mObjectsByName.end(   ) )
           {
           const MovableObject * const mo = i->second;
           // Get local bounds of object
           mLocalAABB.merge(  mo->getBoundingBox(   ) );
           // Get World bounds of object
           mWorldAABB.merge(  mo->getWorldBoundingBox(  true ) );
          
           ++i;
           }
          
           //update the PagingLandScapeOctreeSceneManager that things might have moved.
           // if it hasn't been added to the PagingLandScapeOctree,   add it,   and if has moved
           // enough to leave it's current node,   we'll update it.
          
           if (  ! mWorldAABB.isNull(   ) )
           {
           assert (  mCreator );
           static_cast < PagingLandScapeOctreeSceneManager * > (  mCreator )->_updatePagingLandScapeOctreeNode(  this );
           }
           mHalfSize = (  mWorldAABB.getMaximum (   ) - mWorldAABB.getMinimum (   ) ) * 0.5;
           if (  mOcclusionBoundingBox )
           mOcclusionBoundingBox->setupBoundingBox(  mWorldAABB );
           if (  mWireBoundingBox )
           mWireBoundingBox->setupBoundingBox(  mWorldAABB );
           if (  !mIsRegisteredToCam )
           static_cast< PagingLandScapeOctreeSceneManager * > (  mCreator )->
           registeredNodeInCamera (  this );
           }
           //-----------------------------------------------------------------------
           /** Since we are loose,   only check the center.
           */
     123   bool PagingLandScapeOctreeNode::_isIn(  const AxisAlignedBox &box ) const
           {
           // Always fail if not in the scene graph or box is null
           if (  !mIsInSceneGraph || box.isNull(   ) )
           return false;
           // Always succeed if AABB is infinite
           if (  box.isInfinite(   ) )
           return true;
          
           // Object Bounding Box Center
           const Vector3 center = mWorldAABB.getMaximum(   ).midPoint(  mWorldAABB.getMinimum(   ) );
          
           // Min and Max of Octree BBox
           const Vector3 &bmin = box.getMinimum(   );
           const Vector3 &bmax = box.getMaximum(   );
          
           // Object Bbox center is IN Octree BBox ?
          
           const bool centre = bmax.x >= center.x && bmax.y >= center.y && bmax.z >= center.z &&
           bmin.x <= center.x && bmin.y <= center.y && bmin.z <= center.z;
           if (  !centre )
           return false;
          
           // Even if covering the centre line,   need to make sure this BB is not large
           // enough to require being moved up into parent. When added,   bboxes would
           // end up in parent due to cascade but when updating need to deal with
           // bbox growing too large for this child
           const Vector3 octreeSize (  bmax - bmin );
           const Vector3 nodeSize (  mWorldAABB.getMaximum(   ) - mWorldAABB.getMinimum(   ) );
          
           return (  nodeSize < octreeSize );
          
           }
           //-----------------------------------------------------------------------
           /** Adds the attached objects of this PagingLandScapeOctreeScene node into the queue. */
     158   void PagingLandScapeOctreeNode::_addToRenderQueue(  Camera* cam,  
           RenderQueue * const queue,  
           const bool onlyShadowCasters,  
           VisibleObjectsBoundsInfo* visibleBounds )
           {
           ObjectMap::iterator mit = mObjectsByName.begin(   );
          
           while (  mit != mObjectsByName.end(   ) )
           {
           MovableObject * const mo = mit->second;
          
           mo->_notifyCurrentCamera(  cam );
          
           if (  mo->isVisible(   ) &&
           (  !onlyShadowCasters || mo->getCastShadows(   ) ) )
           {
           mo->_updateRenderQueue(  queue );
          
           if (  visibleBounds )
           {
           visibleBounds->merge(  mo->getWorldBoundingBox(  true ),  
           mo->getWorldBoundingSphere(  true ),   cam );
           }
           }
           ++mit;
           }
          
           // check if the scene manager or this node wants the bounding box shown.
           if (  getShowBoundingBox(   ) || mCreator->getShowBoundingBoxes(   ) )
           _addBoundingBoxToQueue(  queue );
          
           if (   mCreator->getDisplaySceneNodes(   ) )
           queue -> addRenderable(   this  );
          
           }
           //-----------------------------------------------------------------------
     194   void PagingLandScapeOctreeNode::attachObject(  MovableObject* obj )
           {
           if (  mIsStaticNode )
           {
           const String movableType = obj->getMovableType(   );
           if (  movableType == "Entity" || movableType == "StaticGeometry" )
           {
           if (  StringUtil::startsWith(  obj->getName(   ),   "Static",   false ) )
           {
           if (  mIsOccluder && !StringUtil::startsWith(  obj->getName(   ),   "StaticOccluder",   false ) )
           {
           mIsOccluder = false;
           }
           }
           else
           {
           mIsStaticNode = false;
           mIsOccluder = false;
           }
           }
           else if (  movableType != "PagingLandScapeRenderable"
           && movableType != "TerrainMipMap" )
           {
           mIsStaticNode = false;
           mIsOccluder = false;
           }
           }
           SceneNode::attachObject (  obj );
           }
           //-----------------------------------------------------------------------
     224   MovableObject* PagingLandScapeOctreeNode::detachObject(  unsigned short index )
           {
           // if we detach 1 object,   after the return,  
           // there's none left so we reset the thing.
           if (  !mObjectsByName.empty(   ) && 1 == mObjectsByName.size(   ) )
           {
           mIsStaticNode = true;
           mIsOccluder = true;
           }
           return SceneNode::detachObject (  index );
          
           }
           //-----------------------------------------------------------------------
     237   MovableObject* PagingLandScapeOctreeNode::detachObject(  const String& name )
           {
           if (  !mObjectsByName.empty(   ) && 1 == mObjectsByName.size(   ) )
           {
           mIsStaticNode = true;
           mIsOccluder = true;
           }
           return SceneNode::detachObject (  name );
           }
           //-----------------------------------------------------------------------
     247   void PagingLandScapeOctreeNode::detachObject(  MovableObject* obj )
           {
           if (  !mObjectsByName.empty(   ) && 1 == mObjectsByName.size(   ) )
           {
           mIsStaticNode = true;
           mIsOccluder = true;
           }
           SceneNode::detachObject (  obj );
           }
           //-----------------------------------------------------------------------
     257   void PagingLandScapeOctreeNode::detachAllObjects(  void )
           {
           SceneNode::detachAllObjects (   );
           mIsStaticNode = true;
           mIsOccluder = true;
           }
           //-----------------------------------------------------------------------
     264   void PagingLandScapeOctreeNode::_addAlreadyNotifiedToVisibles(   )
           {
           if (  !mNotifiedVisibles.empty(   ) )
           {
           PagingLandScapeOctreeSceneManager * const osm = static_cast < PagingLandScapeOctreeSceneManager * > (  mCreator );
          
           // create the render Queue.
           MovableObjectList::iterator it = mNotifiedVisibles.begin(   ),  
           itend = mNotifiedVisibles.end(   );
           while (  it != itend )
           {
           assert (  (  *it )->isVisible (   ) );
           osm->addVisible (  *it );
           ++it;
           }
           mNotifiedVisibles.clear(   );
           }
           }
           //-----------------------------------------------------------------------
     283   void PagingLandScapeOctreeNode::_addToVisibles(  Camera* cam,  
     284   const bool onlyShadowCasters )
           {
           if (  !mNotifiedVisibles.empty(   ) )
           {
           PagingLandScapeOctreeSceneManager * const osm = static_cast < PagingLandScapeOctreeSceneManager * > (  mCreator );
          
           // create the render Queue.
           ObjectMap::iterator mit = mObjectsByName.begin (   );
           while (  mit != mObjectsByName.end (   ) )
           {
           MovableObject * const mo = mit->second;
           mo->_notifyCurrentCamera (  cam );
           if (  mo->isVisible (   ) &&
           (  !onlyShadowCasters || mo->getCastShadows (   ) ) )
           {
           osm->addVisible (  mo );
           }
           ++mit;
           }
           mNotifiedVisibles.clear (   );
           }
           }
           //-----------------------------------------------------------------------
     307   bool PagingLandScapeOctreeNode::notifyNodeObjects(  Camera* cam,  
     308   const bool onlyShadowCasters )
           {
           // if at least one is visible.
           bool isVisible = false;
           mNotifiedVisibles.clear(   );
           ObjectMap::iterator mit = mObjectsByName.begin (   );
           while (  mit != mObjectsByName.end (   ) )
           {
           MovableObject * const mo = mit->second;
           mo->_notifyCurrentCamera (  cam );
           if (  mo->isVisible (   ) &&
           (  !onlyShadowCasters || mo->getCastShadows (   ) ) )
           {
           mNotifiedVisibles.push_back (  mo );
           isVisible = true;
           }
           ++mit;
           }
           return isVisible;
           }
           //-----------------------------------------------------------------------
     329   MovableObjectList *PagingLandScapeOctreeNode::getVisibleNotifiedNodeObjects(  Camera* cam,  
     330   const bool onlyShadowCasters )
           {
           notifyNodeObjects(  cam,   onlyShadowCasters );
           return &mNotifiedVisibles;
           }
           //-----------------------------------------------------------------------
     336   OcclusionBoundingBox* PagingLandScapeOctreeNode::getOcclusionBoundingBox(   )
           {
           // Create an OcclusionBoundingBox if needed
           if(  mOcclusionBoundingBox == 0 )
           {
           mOcclusionBoundingBox = new OcclusionBoundingBox(   );
           //mOcclusionBoundingBox->setRenderQueueGroup (  RENDER_QUEUE_WORLD_GEOMETRY_2 );
           mOcclusionBoundingBox->setupBoundingBox(  mWorldAABB );
           }
           return mOcclusionBoundingBox;
           }
           //-----------------------------------------------------------------------
     348   void PagingLandScapeOctreeNode::addChild(  Node* child )
           {
           mIsRegisteredToCam = false;
           static_cast< PagingLandScapeOctreeSceneManager * > (  mCreator )->registeredNodeInCamera(  this );
           // call superclass method
           Node::addChild (  child );
           }
           //-----------------------------------------------------------------------
     356   void PagingLandScapeOctreeNode::_removeNodeAndChildren(   )
           {
           assert (  mCreator );
           static_cast< PagingLandScapeOctreeSceneManager * > (  mCreator )->unregisteredNodeInCamera (  this );
           mIsRegisteredToCam = false;
          
           PagingLandScapeOctree * oct = getOctant(   );
           if (  oct )
           oct->_removeNode(  this );
           setOctant (  0 );
          
           //remove all the children nodes as well from the PagingLandScapeOctree.
           ChildNodeMap::iterator it = mChildren.begin(   );
           while(  it != mChildren.end(   ) )
           {
           static_cast<PagingLandScapeOctreeNode *>(  it->second )->_removeNodeAndChildren(   );
           ++it;
           }
           }
           //-----------------------------------------------------------------------
     376   void PagingLandScapeOctreeNode::removeAllChildren(  void )
           {
           ChildNodeMap::iterator i,   iend = mChildren.end(   );
           for (  i = mChildren.begin(   ); i != iend; ++i )
           {
           static_cast <PagingLandScapeOctreeNode* > (  i->second )->_removeNodeAndChildren(   );
           }
           Node::removeAllChildren(   );
           }
           //-----------------------------------------------------------------------
     386   Node * PagingLandScapeOctreeNode::removeChild(  unsigned short index )
           {
           PagingLandScapeOctreeNode *on = static_cast<PagingLandScapeOctreeNode* >(  SceneNode::removeChild(  index ) );
           on->_removeNodeAndChildren(   );
           return on;
           }
           //-----------------------------------------------------------------------
     393   Node * PagingLandScapeOctreeNode::removeChild(  Node* child )
           {
           PagingLandScapeOctreeNode *on = static_cast<PagingLandScapeOctreeNode* >(  SceneNode::removeChild(  child ) );
           on->_removeNodeAndChildren(   );
           return on;
           }
           //-----------------------------------------------------------------------
     400   Node * PagingLandScapeOctreeNode::removeChild(  const String & name )
           {
           PagingLandScapeOctreeNode *on = static_cast< PagingLandScapeOctreeNode * >(  SceneNode::removeChild(  name ) );
           on->_removeNodeAndChildren(   );
           return on;
           }
           #ifdef _VISIBILITYDEBUG
           //-----------------------------------------------------------------------
     408   void PagingLandScapeOctreeNode::setDebugCorners(  PagingLandScapeOctreeSceneManager *scnMgr )
           {
           // use the ratio (  OCtreeAAB / thisAAB ) / 8
           const Vector3 &max = mWorldAABB.getMaximum (   );
           const Vector3 &min = mWorldAABB.getMinimum (   );
          
           Real left = 0,   top = 0,   right = 0,   bottom = 0;
          
          
           const Vector3 &sceneMax = scnMgr->getBoundingBox (   ).getMaximum (   );
           const Vector3 &sceneMin = scnMgr->getBoundingBox (   ).getMinimum (   );
          
           const Real width = sceneMax.x - sceneMin.x;
           const Real height = sceneMax.z - sceneMin.z;
           if (  Math::Abs(  width ) > 1e-08 && Math::Abs(  height ) > 1e-08 )
           {
           const Real toScreenDivider = 1.0f / 3;
          
           const Real xleft = min.x - sceneMin.x;
           if (  Math::Abs(  xleft ) > 1e-08 )
           left = (  xleft / width ) * toScreenDivider;
          
           const Real ztop = min.z - sceneMin.z;
           if (  Math::Abs(  ztop ) > 1e-08 )
           top = (  ztop / height ) * toScreenDivider;
          
           const Real xright = max.x - sceneMin.x;
           if (  Math::Abs(  xright ) > 1e-08 )
           right = (  xright / width ) * toScreenDivider;
          
           const Real zbottom = max.z - sceneMin.z;
           if (  Math::Abs(  zbottom ) > 1e-08 )
           bottom = (  zbottom / height ) * toScreenDivider;
          
           getRectangle2d (  scnMgr )->setCorners (  (  1.0f - toScreenDivider ) + left,  
           (  1.0f - toScreenDivider ) + top,  
           (  1.0f - toScreenDivider ) + right,  
           (  1.0f - toScreenDivider ) + bottom );
           }
           }
           #endif //_VISIBILITYDEBUG
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOctreePlaneBoundedVolumeListSceneQuery.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreePlaneBoundedVolumeListSceneQuery.cpp - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004by Jon Anderson
          email : janders@users.sf.net
          
          
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOctreePlaneBoundedVolumeListSceneQuery.h"
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgreEntity.h"
          
          namespace Ogre
          {
          
          //---------------------------------------------------------------------
      46  PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery::PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery(  SceneManager* creator )
           : DefaultPlaneBoundedVolumeListSceneQuery(  creator )
          {
          }
          
          //---------------------------------------------------------------------
      52  PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery::~PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery(  void )
          {
          }
          
          //---------------------------------------------------------------------
      57  void PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery::execute(  SceneQueryListener* listener )
          {
           PlaneBoundedVolumeList::iterator pi,   piend;
           piend = mVolumes.end(   );
           for (  pi = mVolumes.begin(   ); pi != piend; ++pi )
           {
           std::list < SceneNode* > list;
           //find the nodes that intersect the AAB
           static_cast< PagingLandScapeOctreeSceneManager* >(  mParentSceneMgr )->findNodesIn(  *pi,   list,   0 );
          
           //grab all moveables from the node that intersect...
           std::list < SceneNode* >::iterator it = list.begin(   );
           while (  it != list.end(   ) )
           {
           SceneNode::ObjectIterator oit = (  *it )->getAttachedObjectIterator(   );
           while (  oit.hasMoreElements(   ) )
           {
           MovableObject* m = oit.getNext(   );
           if (  (  m->getQueryFlags(   ) & mQueryMask ) && m->isInScene(   ) && (  *pi ).intersects(  m->getWorldBoundingBox(   ) ) )
           {
           listener->queryResult(  m );
           }
           }
           ++it;
           }
           }
          }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOctreeRaySceneQuery.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreeRaySceneQuery.cpp - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004by Jon Anderson
          email : janders@users.sf.net
          
          
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOctreeRaySceneQuery.h"
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgreEntity.h"
          
          namespace Ogre
          {
          
          //---------------------------------------------------------------------
      46  PagingLandScapeOctreeRaySceneQuery::PagingLandScapeOctreeRaySceneQuery(  SceneManager* creator )
           : DefaultRaySceneQuery(  creator )
          {
          }
          
          //---------------------------------------------------------------------
      52  PagingLandScapeOctreeRaySceneQuery::~PagingLandScapeOctreeRaySceneQuery(  void )
          {
          }
          
          //---------------------------------------------------------------------
      57  void PagingLandScapeOctreeRaySceneQuery::execute(  RaySceneQueryListener* listener )
          {
           // if anything else is queried,   ask Octree Scene Manager.
           if (  getQueryTypeMask(   ) != SceneManager::WORLD_GEOMETRY_TYPE_MASK )
           {
           std::list < SceneNode* > list;
           //find the nodes that intersect the AAB
           static_cast< PagingLandScapeOctreeSceneManager* >(  mParentSceneMgr )->findNodesIn(  mRay,   list,   0 );
          
           //grab all movables from the node that intersect...
           std::list < SceneNode* >::iterator it = list.begin(   );
           while (  it != list.end(   ) )
           {
           SceneNode::ObjectIterator oit = (  *it )->getAttachedObjectIterator(   );
           while (  oit.hasMoreElements(   ) )
           {
           MovableObject* m = oit.getNext(   );
           if (  (  m->getQueryFlags(   ) & mQueryMask ) && m->isInScene(   ) )
           {
           std::pair< bool,   Real > result = mRay.intersects(  m->getWorldBoundingBox(   ) );
          
           if (  result.first )
           {
           listener->queryResult(  m,   result.second );
           }
           }
           }
           ++it;
           }
           }
           //else
           // { //if we want to handle static scene geometry inside the scene manager ?
           //
           // }
          }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOctreeSceneManager.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          PagingLandScapeOctreescenemanager.cpp - description
          -------------------
          begin : Fri Sep 27 2002
          copyright : (  C ) 2002 by Jon Anderson
          email : janders@users.sf.net
          
          Enhancements 2003 - 2004 (  C ) The OGRE Team
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          
          #include "OgrePagingLandScapeOctreeAxisAlignedBoxSceneQuery.h"
          #include "OgrePagingLandScapeOctreeIntersectionSceneQuery.h"
          #include "OgrePagingLandScapeOctreePlaneBoundedVolumeListSceneQuery.h"
          #include "OgrePagingLandScapeOctreeRaySceneQuery.h"
          #include "OgrePagingLandScapeOctreeSphereSceneQuery.h"
          #include "OgreRenderSystem.h"
          #include "OgreWireBoundingBox.h"
          #include "OgreRenderOperation.h"
          #include "OgreStringConverter.h"
          
          #include "OgreOverlayManager.h"
          #include "OgreOverlayElement.h"
          
          #include "OgrePagingLandScapeOctreeCamera.h"
          #include "OgrePagingLandScapeOctree.h"
          #include "OgrePagingLandScapeOctreeNode.h"
          
          #include "OgreOcclusionBoundingBox.h"
          #include "OgrePagingLandScapeOcclusionSorter.h"
          #include "OgrePagingLandScapeOcclusionVisibilityData.h"
          #include "OgrePagingLandScapeOcclusionTraversal.h"
          #include "OgrePagingLandScapeOcclusionCameraTraversal.h"
          #include "OgrePagingLandScapeOcclusionVFTraversal.h"
          #include "OgrePagingLandScapeOcclusionSWTraversal.h"
          #include "OgrePagingLandScapeOcclusionDebugTraversal.h"
          
          
          
          extern "C"
          {
      70   void findNodesInBox(  Ogre::SceneManager *sm,  
           const Ogre::AxisAlignedBox &box,  
           std::list < Ogre::SceneNode * > &list,  
           const Ogre::SceneNode * const exclude )
           {
           static_cast<Ogre::PagingLandScapeOctreeSceneManager*>(  sm )->findNodesIn(  box,   list,   exclude );
           }
      77   void findNodesInSphere(  Ogre::SceneManager *sm,  
           const Ogre::Sphere &sphere,  
           std::list < Ogre::SceneNode * > &list,  
           const Ogre::SceneNode * const exclude )
           {
           static_cast<Ogre::PagingLandScapeOctreeSceneManager*>(  sm )->findNodesIn(  sphere,   list,   exclude );
           }
          }
          
          namespace Ogre
          {
           //---------------------------------------------------------------------
           enum Intersection
           {
           OUTSIDE=0,  
           INSIDE=1,  
           INTERSECT=2
           };
           int PagingLandScapeOctreeSceneManager::intersect_call = 0;
           //---------------------------------------------------------------------
      97   Intersection intersect(  const Ray &ray,   const AxisAlignedBox &box )
           {
           // Null box?
           if (  box.isNull(   ) )
           return OUTSIDE;
           // Infinite box?
           if (  box.isInfinite(   ) )
           return INTERSECT;
          
           const Vector3& min = box.getMinimum(   );
           const Vector3& max = box.getMaximum(   );
           const Vector3& rayorig = ray.getOrigin(   );
          
           // Check origin inside first
           if (   rayorig > min && rayorig < max  )
           return INSIDE;
          
           const Vector3& raydir = ray.getDirection(   );
          
           Real lowt = 0.0f;
           Real t;
           bool hit = false;
           Vector3 hitpoint;
          
           // Check each face in turn,   only check closest 3
           // Min x
           if (  rayorig.x < min.x && raydir.x > 0 )
           {
           t = (  min.x - rayorig.x ) / raydir.x;
           if (  t > 0 )
           {
           // Substitute t back into ray and check bounds and dist
           hitpoint = rayorig + raydir * t;
           if (  hitpoint.y >= min.y && hitpoint.y <= max.y &&
           hitpoint.z >= min.z && hitpoint.z <= max.z &&
           (  !hit || t < lowt ) )
           {
           return INTERSECT;
           }
           }
           }
           // Max x
           if (  rayorig.x > max.x && raydir.x < 0 )
           {
           t = (  max.x - rayorig.x ) / raydir.x;
           if (  t > 0 )
           {
           // Substitute t back into ray and check bounds and dist
           hitpoint = rayorig + raydir * t;
           if (  hitpoint.y >= min.y && hitpoint.y <= max.y &&
           hitpoint.z >= min.z && hitpoint.z <= max.z &&
           (  !hit || t < lowt ) )
           {
           return INTERSECT;
           }
           }
           }
           // Min y
           if (  rayorig.y < min.y && raydir.y > 0 )
           {
           t = (  min.y - rayorig.y ) / raydir.y;
           if (  t > 0 )
           {
           // Substitute t back into ray and check bounds and dist
           hitpoint = rayorig + raydir * t;
           if (  hitpoint.x >= min.x && hitpoint.x <= max.x &&
           hitpoint.z >= min.z && hitpoint.z <= max.z &&
           (  !hit || t < lowt ) )
           {
           return INTERSECT;
           }
           }
           }
           // Max y
           if (  rayorig.y > max.y && raydir.y < 0 )
           {
           t = (  max.y - rayorig.y ) / raydir.y;
           if (  t > 0 )
           {
           // Substitute t back into ray and check bounds and dist
           hitpoint = rayorig + raydir * t;
           if (  hitpoint.x >= min.x && hitpoint.x <= max.x &&
           hitpoint.z >= min.z && hitpoint.z <= max.z &&
           (  !hit || t < lowt ) )
           {
           return INTERSECT;
           }
           }
           }
           // Min z
           if (  rayorig.z < min.z && raydir.z > 0 )
           {
           t = (  min.z - rayorig.z ) / raydir.z;
           if (  t > 0 )
           {
           // Substitute t back into ray and check bounds and dist
           hitpoint = rayorig + raydir * t;
           if (  hitpoint.x >= min.x && hitpoint.x <= max.x &&
           hitpoint.y >= min.y && hitpoint.y <= max.y &&
           (  !hit || t < lowt ) )
           {
           return INTERSECT;
           }
           }
           }
           // Max z
           if (  rayorig.z > max.z && raydir.z < 0 )
           {
           t = (  max.z - rayorig.z ) / raydir.z;
           if (  t > 0 )
           {
           // Substitute t back into ray and check bounds and dist
           hitpoint = rayorig + raydir * t;
           if (  hitpoint.x >= min.x && hitpoint.x <= max.x &&
           hitpoint.y >= min.y && hitpoint.y <= max.y &&
           (  !hit || t < lowt ) )
           {
           return INTERSECT;
           }
           }
           }
           return OUTSIDE;
           }
          
           //---------------------------------------------------------------------
     222   Intersection intersect2(  const Ray &one,   const AxisAlignedBox &two )
           {
           PagingLandScapeOctreeSceneManager::intersect_call++;
          
           // Null box?
           if (  two.isNull(   ) )
           return OUTSIDE;
           // Infinite box?
           if (  two.isInfinite(   ) )
           return INTERSECT;
          
           const Vector3* const pCorners = two.getAllCorners(   );
           const Vector3 origin = one.getOrigin(   );
           const Vector3 dir = one.getDirection(   );
          
           Vector3 maxT (  -1.0f,   -1.0f,   -1.0f );
          
           unsigned int i = 0;
           bool inside = true;
           for (  i = 0; i < 3; i++ )
           {
           if (  origin[i] < pCorners[0][i] )
           {
           inside = false;
           if(  dir[i] > 0 )
           maxT[i] = (  pCorners[0][i] - origin[i] ) / dir[i];
           }
           else if (  origin[i] > pCorners[4][i] )
           {
           inside = false;
           if(  dir[i] < 0 )
           maxT[i] = (  pCorners[4][i] - origin[i] ) / dir[i];
           }
           }
          
           if(  inside )
           {
           return INTERSECT;
           }
           int whichPlane = 0;
           if(  maxT[1] > maxT[whichPlane] )
           whichPlane = 1;
           if(  maxT[2] > maxT[whichPlane] )
           whichPlane = 2;
          
           if(  (  (  int )maxT[whichPlane] ) & 0x80000000 )
           {
           return OUTSIDE;
           }
           const Real maxTThisPlane = maxT[whichPlane];
           for(  i = 0; i < 3; i++ )
           {
           if(  i != whichPlane )
           {
           const Real f = origin[i] + maxTThisPlane * dir[i];
           if (  f < (  pCorners[0][i] - 0.00001f ) ||
           f > (  pCorners[4][i] + 0.00001f ) )
           {
           return OUTSIDE;
           }
           }
           }
          
           return INTERSECT;
          
           }
           //---------------------------------------------------------------------
           /** Checks how the second box intersects with the first.
           */
     291   Intersection intersect(  const PlaneBoundedVolume &one,   const AxisAlignedBox &two )
           {
           PagingLandScapeOctreeSceneManager::intersect_call++;
           // Null box?
           if (  two.isNull(   ) )
           return OUTSIDE;
           if (  two.isInfinite(   ) )
           return INTERSECT;
          
           // Get corners of the box
           const Vector3 * const pCorners = two.getAllCorners(   );
          
           // For each plane,   see if all points are on the negative side
           // If so,   object is not visible.
           // If one or more are,   it's partial.
           // If all aren't,   full
           static const int corners[ 8 ] = {0,   4,   3,   5,   2,   6,   1,   7};
          
           bool all_inside = true;
           PlaneList::const_iterator i,   iend = one.planes.end(   );
           for (  i = one.planes.begin(   ); i != iend; ++i )
           {
           const Plane& plane = *i;
           bool all_outside = true;
           for (  unsigned int corner = 0; corner < 8; ++corner )
           {
           const Real distance = plane.getDistance(  pCorners[ corners[ corner ] ] );
           all_outside = all_outside && (  distance < 0 );
           all_inside = all_inside && (  distance >= 0 );
          
           if (  !all_outside && !all_inside )
           break;
           }
          
           if (  all_outside )
           return OUTSIDE;
           }
          
           if (  all_inside )
           return INSIDE;
           else
           return INTERSECT;
          
           }
           //---------------------------------------------------------------------
           /** Checks how the second box intersects with the first.
           */
     338   Intersection intersect(  const AxisAlignedBox &one,   const AxisAlignedBox &two )
           {
           PagingLandScapeOctreeSceneManager::intersect_call++;
          
           // Null box?
           if (  one.isNull(   ) || two.isNull(   ) )
           return OUTSIDE;
           if (  one.isInfinite(   ) )
           return INSIDE;
           if (  two.isInfinite(   ) )
           return INTERSECT;
          
           const Vector3 * outside = one.getAllCorners(   );
           const Vector3 *inside = two.getAllCorners(   );
          
           if (  inside[ 4 ].x < outside[ 0 ].x ||
           inside[ 4 ].y < outside[ 0 ].y ||
           inside[ 4 ].z < outside[ 0 ].z ||
           inside[ 0 ].x > outside[ 4 ].x ||
           inside[ 0 ].y > outside[ 4 ].y ||
           inside[ 0 ].z > outside[ 4 ].z )
           {
           return OUTSIDE;
           }
          
           const bool full = (  inside[ 0 ].x > outside[ 0 ].x &&
           inside[ 0 ].y > outside[ 0 ].y &&
           inside[ 0 ].z > outside[ 0 ].z &&
           inside[ 4 ].x < outside[ 4 ].x &&
           inside[ 4 ].y < outside[ 4 ].y &&
           inside[ 4 ].z < outside[ 4 ].z );
          
           if (  full )
           return INSIDE;
           else
           return INTERSECT;
          
           }
           //---------------------------------------------------------------------
           /** Checks how the box intersects with the sphere.
           */
     379   Intersection intersect(  const Sphere &one,   const AxisAlignedBox &two )
           {
           PagingLandScapeOctreeSceneManager::intersect_call++;
          
           // Null box?
           if (  two.isNull(   ) )
           return OUTSIDE;
           if (  two.isInfinite(   ) )
           return INTERSECT;
          
          
           const Real sradius = Math::Sqr (  one.getRadius(   ) );
           const Vector3 scenter = one.getCenter(   );
           const Vector3 * const corners = two.getAllCorners(   );
          
           const Vector3 mndistance = (  corners[ 0 ] - scenter );
           const Vector3 mxdistance = (  corners[ 4 ] - scenter );
          
          
           if (  mndistance.squaredLength(   ) < sradius &&
           mxdistance.squaredLength(   ) < sradius )
           {
           return INSIDE;
           }
          
           //find the square of the distance
           //from the sphere to the box
           Real d = 0;
           for (  unsigned int i = 0 ; i < 3 ; i++ )
           {
           const Real sCenteri = scenter[ i ];
           if (  sCenteri < corners[ 0 ][ i ] )
           {
           const Real s = sCenteri - corners[ 0 ][ i ];
           d += s * s;
           }
           else if (  sCenteri > corners[ 4 ][ i ] )
           {
           const Real s = sCenteri - corners[ 4 ][ i ];
           d += s * s;
           }
          
           }
          
           const bool partial = (  d <= sradius );
          
           if (  !partial )
           {
           return OUTSIDE;
           }
          
           else
           {
           return INTERSECT;
           }
          
          
           }
           //-----------------------------------------------------------------------
           //-----------------------------------------------------------------------
           //-----------------------------------------------------------------------
           const String PagingLandScapeOctreeSceneManagerFactory::FACTORY_TYPE_NAME = "PagingLandScapeOctreeSceneManager";
           //-----------------------------------------------------------------------
     442   void PagingLandScapeOctreeSceneManagerFactory::initMetaData(  void ) const
           {
           mMetaData.typeName = FACTORY_TYPE_NAME;
           mMetaData.description = "Scene manager organising the scene on the basis of an octree,   possibly using occlusion culling.";
           mMetaData.sceneTypeMask = ST_EXTERIOR_REAL_FAR; // support all types
           mMetaData.worldGeometrySupported = false;
           }
           //-----------------------------------------------------------------------
     450   SceneManager* PagingLandScapeOctreeSceneManagerFactory::createInstance(  
     451   const String& instanceName )
           {
           return new PagingLandScapeOctreeSceneManager(  instanceName );
           }
           //-----------------------------------------------------------------------
     456   void PagingLandScapeOctreeSceneManagerFactory::destroyInstance(  SceneManager* instance )
           {
           delete instance;
           }
           //---------------------------------------------------------------------
     461   PagingLandScapeOctreeSceneManager::PagingLandScapeOctreeSceneManager(  const String& name ):
           SceneManager(  name ),  
           mPagingLandScapeOctree(  0 ),  
           mCurrentOptionCamera(  0 )
           {
           mOctreeSet.setPoolSize (  64 );
           AxisAlignedBox b(  -10000,   -10000,   -10000,   10000,   10000,   10000 );
           int depth = 8;
           init(  b,   depth );
           }
           //---------------------------------------------------------------------
     472   PagingLandScapeOctreeSceneManager::PagingLandScapeOctreeSceneManager(  const String& name,   AxisAlignedBox &box,   int max_depth ) :
           SceneManager(  name ),  
           mPagingLandScapeOctree(  0 )
           {
           init(  box,   max_depth );
           }
           //---------------------------------------------------------------------
     479   const String& PagingLandScapeOctreeSceneManager::getTypeName(  void ) const
           {
           return PagingLandScapeOctreeSceneManagerFactory::FACTORY_TYPE_NAME;
           }
           //---------------------------------------------------------------------
     484   void PagingLandScapeOctreeSceneManager::init(  const AxisAlignedBox &box,   int depth )
           {
           delete mSceneRoot; //get rid of old root.
          
           // -- Changes by Steve
           // Don't do it this way,   it will add it to the mSceneNodes which we don't want
           //mSceneRoot = createSceneNode(  "SceneRoot" );
           mSceneRoot = new PagingLandScapeOctreeNode(  this,   "SceneRoot" );
           mSceneRoot->_notifyRootNode(   );
           // -- End changes by Steve
          
          
           if (  mPagingLandScapeOctree )
           deleteOctree (  mPagingLandScapeOctree );
           mPagingLandScapeOctree = mOctreeSet.getPoolable(   );
           assert (  mPagingLandScapeOctree );
           mPagingLandScapeOctree->setSceneManager (  this );
          
           mMaxDepth = depth;
           mBox = box;
          
           //mSceneRoot isn't put into the PagingLandScapeOctree since it has no volume.
           mPagingLandScapeOctree->setBoundingBox (  box.getMinimum(   ),   box.getMaximum(   ) );
          
           #ifdef _VISIBILITYDEBUG
           mShowBoxes = false;
           mCullCamera = false;
           // setDisplaySceneNodes(  true );
           #endif //_VISIBILITYDEBUG
          
          
           mOcclusion.init (  this );
           mOcclusionDepth = 0;
          
           }
           //---------------------------------------------------------------------
     520   PagingLandScapeOctreeSceneManager::~PagingLandScapeOctreeSceneManager(   )
           {
           // -- Changed by Steve
           // Don't do this here,   SceneManager will do it
           /*
           if(  mSceneRoot )
           delete mSceneRoot;
           */
           // --End Changes by Steve
          
           if (  mPagingLandScapeOctree )
           {
           deleteOctree (  mPagingLandScapeOctree );
           mPagingLandScapeOctree = 0;
           }
           VisiblesPerCam::iterator i = mVisibles.begin (   );
           while (  i != mVisibles.end(   ) )
           {
           delete (  i->second );
           ++i;
           }
           mVisibles.clear(   );
           mOctreeSet.deletePool (   );
           }
           //---------------------------------------------------------------------
     545   Camera * PagingLandScapeOctreeSceneManager::createCamera(  const String &name )
           {
           if (  mCameras.find(  name ) != mCameras.end(   ) )
           {
           OGRE_EXCEPT(  
           Exception::ERR_DUPLICATE_ITEM,  
           "A camera with the name " + name + " already exists",  
           "PagingLandScapeSceneManager::createCamera" );
           }
           Camera * c = new PagingLandScapeOctreeCamera(  name,   this );
           mCameras.insert(  CameraList::value_type(  name,   c ) );
           addCamera (  c );
           return c;
           }
           //-----------------------------------------------------------------------
     560   void PagingLandScapeOctreeSceneManager::addCamera(  Camera *cam )
           {
           PagingLandScapeOctreeCamera *c = static_cast <PagingLandScapeOctreeCamera *> (  cam );
           mVisibles[c->getId (   )] = new MovableObjectList(   );
           if (  !c->isRegisteredInOcclusionSystem(   )
           && c->needRegistrationInOcclusionSystem(   ) )
           {
           mPagingLandScapeOctree->traversal(  RegisterCameraTraversal(  c ),   0 );
           c->setRegisteredInOcclusionSystem(  true );
           }
           if (  !mCurrentOptionCamera )
           mCurrentOptionCamera = c;
           }
           //-----------------------------------------------------------------------
     574   void PagingLandScapeOctreeSceneManager::unregisterCamera(  PagingLandScapeOctreeCamera *c )
           {
           VisiblesPerCam::iterator i = mVisibles.find (  c->getId (   ) );
           if (  i != mVisibles.end(   ) )
           {
           delete (  i->second );
           mVisibles.erase(  i );
           }
           if (  c->isRegisteredInOcclusionSystem (   ) )
           {
           mPagingLandScapeOctree->traversal (  UnregisterCameraTraversal(  c ),   0 );
           c->setRegisteredInOcclusionSystem (  false );
           }
           if (  mCurrentOptionCamera == c )
           c = 0;
           }
           //-----------------------------------------------------------------------
     591   void PagingLandScapeOctreeSceneManager::destroyCamera(  Camera *cam )
           {
           SceneManager::destroyCamera(  cam );
           }
           //-----------------------------------------------------------------------
     596   void PagingLandScapeOctreeSceneManager::destroyCamera(  const String& name )
           {
           // Find in list
           CameraList::iterator i = mCameras.find(  name );
           if (  i != mCameras.end(   ) )
           {
           unregisterCamera (  static_cast <PagingLandScapeOctreeCamera *> (  i->second ) );
           SceneManager::destroyCamera (  name );
           }
           }
           //-----------------------------------------------------------------------
     607   void PagingLandScapeOctreeSceneManager::destroyAllCameras(  void )
           {
           CameraList::iterator i = mCameras.begin(   );
           for (  ; i != mCameras.end(   ); ++i )
           {
           unregisterCamera (  static_cast <PagingLandScapeOctreeCamera *> (  i->second ) );
           // Notify render system
           mDestRenderSystem->_notifyCameraRemoved(  i->second );
           delete i->second;
           }
           mCameras.clear (   );
           }
           //---------------------------------------------------------------------
     620   void PagingLandScapeOctreeSceneManager::destroySceneNode(  const String &name )
           {
           PagingLandScapeOctreeNode * on = static_cast < PagingLandScapeOctreeNode* > (  SceneManager::getSceneNode(  name ) );
          
           if (  on != 0 )
           _removePagingLandScapeOctreeNode(  on );
          
           SceneManager::destroySceneNode(  name );
           }
           //---------------------------------------------------------------------
     630   bool PagingLandScapeOctreeSceneManager::getOptionValues(  const String & key,   StringVector &refValueList )
           {
           return SceneManager::getOptionValues(  key,   refValueList );
           }
           //---------------------------------------------------------------------
     635   bool PagingLandScapeOctreeSceneManager::getOptionKeys(  StringVector & refKeys )
           {
           SceneManager::getOptionKeys(  refKeys );
          
           refKeys.push_back(  "CullCamera" );
           refKeys.push_back(  "Size" );
           refKeys.push_back(  "ShowPagingLandScapeOctree" );
           refKeys.push_back(  "Depth" );
          
           return true;
           }
           //---------------------------------------------------------------------
     647   void PagingLandScapeOctreeSceneManager::_updatePagingLandScapeOctreeNode(  PagingLandScapeOctreeNode * onode )
           {
           const AxisAlignedBox box = onode->_getWorldAABB(   );
          
           if (  box.isNull(   ) )
           return ;
          
           // Skip if octree has been destroyed (  shutdown conditions )
           if (  !mPagingLandScapeOctree )
           return;
          
           if (  onode->getOctant(   ) == 0 )
           {
           //if outside the PagingLandScapeOctree,   force into the root node.
           if (  ! onode->_isIn(  mPagingLandScapeOctree->getBoundingBox(   ) ) )
           mPagingLandScapeOctree->_addNode(  onode );
           else
           _addPagingLandScapeOctreeNode(  onode,   mPagingLandScapeOctree );
           return ;
           }
          
           if (  ! onode->_isIn(  onode->getOctant(   )->getBoundingBox(   ) ) )
           {
           _removePagingLandScapeOctreeNode(  onode );
          
           //if outside the PagingLandScapeOctree,   force into the root node.
           if (  ! onode->_isIn(  mPagingLandScapeOctree->getBoundingBox(   ) ) )
           mPagingLandScapeOctree->_addNode(  onode );
           else
           _addPagingLandScapeOctreeNode(  onode,   mPagingLandScapeOctree );
           }
           }
           //---------------------------------------------------------------------
           /** Only removes the node from the PagingLandScapeOctree. It leaves the PagingLandScapeOctree,   even if it's empty.
           */
     682   void PagingLandScapeOctreeSceneManager::_removePagingLandScapeOctreeNode(  PagingLandScapeOctreeNode * n )
           {
           assert (  n );
          
           // Skip if octree has been destroyed (  shutdown conditions )
           if (  !mPagingLandScapeOctree )
           return;
          
           PagingLandScapeOctree * oct = n->getOctant(   );
           if (  oct )
           oct->_removeNode (  n );
           n->setOctant (  0 );
           unregisteredNodeInCamera (  n );
           }
           //---------------------------------------------------------------------
     697   void PagingLandScapeOctreeSceneManager::_addPagingLandScapeOctreeMovableNode(  PagingLandScapeOctreeNode * n,  
     698   PagingLandScapeOctree *octant,  
           int depth )
           {
           const AxisAlignedBox bx = n->_getWorldAABB(   );
          
           //if the PagingLandScapeOctree is twice as big as the scene node,  
           //we will add it to a child.
           if (  (  depth < mMaxDepth ) && octant->_isTwiceSize (  bx ) )
           {
           _addPagingLandScapeOctreeMovableNode(  n,  
           octant->_getChildWhereBoxFits(  bx,   this ),  
           ++depth );
           }
           else
           {
           #ifdef _VISIBILITYDEBUG
           n ->setDebugCorners(  this );
           #endif //_VISIBILITYDEBUG
          
           #ifdef _DEBUG
           std::cout << "Depth Placement "
           << StringConverter::toString (  depth )
           << " \n";
           #endif //_DEBUG
          
           octant->_addNode(  n );
           }
           }
           //---------------------------------------------------------------------
     727   void PagingLandScapeOctreeSceneManager::_addPagingLandScapeOctreeStaticNode(  PagingLandScapeOctreeNode * n,  
     728   PagingLandScapeOctree *octant,  
           int depth )
           {
           const AxisAlignedBox bx = n->_getWorldAABB(   );
          
           //if the PagingLandScapeOctree is twice as big as the scene node,  
           //we will add it to a child.
           if (  (  depth < mMaxDepth ) && octant->_isTwiceCullSize (  bx ) )
           {
           if (  octant->_isNotCrossingAxes(  bx ) )
           {
           _addPagingLandScapeOctreeStaticNode(  n,  
           octant->_getCullChildWhereBoxFits(  bx,   this ),  
           ++depth );
           }
           else
           {
           // re-insert it as a moving node,   therefore avoiding crossing problem.
           n->setStaticCulling (  false );
           _addPagingLandScapeOctreeMovableNode(  n,  
           mPagingLandScapeOctree,  
           0 );
           }
           }
           else
           {
           #ifdef _VISIBILITYDEBUG
           n ->setDebugCorners(  this );
           #endif //_VISIBILITYDEBUG
           octant->_addNode(  n );
           }
           }
           //---------------------------------------------------------------------
     761   void PagingLandScapeOctreeSceneManager::_addPagingLandScapeOctreeNode(  PagingLandScapeOctreeNode * n,   PagingLandScapeOctree *octant,   int depth )
           {
           assert (  n && octant );
           if (  n->isStaticNode (   ) )
           _addPagingLandScapeOctreeStaticNode(  n,   octant,   depth );
           else
           _addPagingLandScapeOctreeMovableNode(  n,   octant,   depth );
           registeredNodeInCamera (  n );
           }
           //---------------------------------------------------------------------
     771   SceneNode * PagingLandScapeOctreeSceneManager::createSceneNode(  void )
           {
           PagingLandScapeOctreeNode * on = new PagingLandScapeOctreeNode(  this );
           mSceneNodes[ on->getName(   ) ] = on;
           return on;
           }
           //---------------------------------------------------------------------
     778   SceneNode * PagingLandScapeOctreeSceneManager::createSceneNode(  const String &name )
           {
           // Check name not used
           if (  mSceneNodes.find(  name ) != mSceneNodes.end(   ) )
           {
           OGRE_EXCEPT(  
           Exception::ERR_DUPLICATE_ITEM,  
           "A scene node with the name " + name + " already exists",  
           "PagingLandScapeOctreeSceneManager::createSceneNode"  );
           }
           PagingLandScapeOctreeNode * on = new PagingLandScapeOctreeNode(  this,   name );
           mSceneNodes[ on->getName(   ) ] = on;
           return on;
           }
           //---------------------------------------------------------------------
     793   void PagingLandScapeOctreeSceneManager::registeredNodeInCamera(  OcclusionElement *on )
           {
           // register existing camera in nodes
           bool isRegistered = false;
           for (  CameraList::iterator it = mCameras.begin(   ); it != mCameras.end(   ); ++it )
           {
           // Notify occlusion system
           PagingLandScapeOctreeCamera *c = static_cast <PagingLandScapeOctreeCamera *> (  it->second );
           assert (  c );
           if (  c->isRegisteredInOcclusionSystem (   ) )
           {
           on->traversal (  RegisterCameraTraversal(  c ),   0 );
           isRegistered = true;
           }
           }
           on->setRegisteredtoCam (  isRegistered );
           }
           //---------------------------------------------------------------------
     811   void PagingLandScapeOctreeSceneManager::unregisteredNodeInCamera(  OcclusionElement *on )
           {
           // register existing camera in nodes
           for (  CameraList::iterator it = mCameras.begin(   );it != mCameras.end(   ); ++it )
           {
           // Notify occlusion system
           PagingLandScapeOctreeCamera *c = static_cast <PagingLandScapeOctreeCamera *> (  it->second );
           assert (  c );
           if (  c->isRegisteredInOcclusionSystem (   ) )
           on->traversal (  UnregisterCameraTraversal(  c ),   0 );
           }
           on->setRegisteredtoCam (  false );
           }
           //---------------------------------------------------------------------
     825   void PagingLandScapeOctreeSceneManager::_updateSceneGraph(  Camera * cam )
           {
           SceneManager::_updateSceneGraph(  cam );
           }
           //---------------------------------------------------------------------
     830   void PagingLandScapeOctreeSceneManager::enableHardwareOcclusionTests(   )
           {
           Camera * const c_cam = mCameraInProgress;
          
           // make sure we always occlude in SOLID MODE
           mCamDetail = c_cam->getPolygonMode (   );
           if (  mCamDetail != PM_SOLID )
           {
           mOcclusion.setIfNotSolidScene (  true );
           c_cam->setPolygonMode (  PM_SOLID );
           }
           else
           {
           mOcclusion.setIfNotSolidScene (  false );
           }
          
           //#define HWOCCLUSIONRTT
           #ifdef HWOCCLUSIONRTT
          
           const Viewport * const c_camViewPort = c_cam->getViewport(   );
           assert (  c_camViewPort );
           if (  mOcclusionDepth == 0 )
           {
           mOcclusionDepth = mDestRenderSystem->
           createRenderTexture(  
           "OcclusionDepthTexture",  
           c_camViewPort->getActualWidth(   ) / 8,  
           c_camViewPort->getActualHeight(   ) / 8,  
           TEX_TYPE_2D,  
           PF_DEPTH );
          
          
           mOcclusionDepth->setAutoUpdated (  false );
           mOcclusionDepth->setActive (  false );
          
           mOcclusionCamera = createCamera (  "OcclusionDepthTextureCamera" );
           Viewport * const v = mOcclusionDepth->addViewport(  mOcclusionCamera );
           assert (  v );
           v->setOverlaysEnabled (  false );
           v->setClearEveryFrame(  false );
           v->setBackgroundColour(  ColourValue::Black );
          
          #define RENDERCOLOR
          #ifdef RENDERCOLOR
           MaterialPtr mat = MaterialManager::getSingleton(   ).create (  
           "OcclusionDepthTextureMat",  
           ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
           mat->getTechnique(  0 )->getPass(  0 )->createTextureUnitState(  "OcclusionDepthTexture" );
          
           Overlay *OcclusionDepthOverlay = OverlayManager::getSingleton (   ).create(  "OcclusionDepthOverlay" );
           OverlayElement *OcclusionDepthPanel =
           OverlayManager::getSingleton (   ).createOverlayElement (  "Panel",  
           "OcclusionDepthPanel",  
           false );
           OcclusionDepthPanel->setMaterialName (  "OcclusionDepthTextureMat" );
           OcclusionDepthOverlay->add2D (  (  OverlayContainer * )OcclusionDepthPanel );
           OcclusionDepthOverlay->show (   );
          
           //OcclusionDepthOverlay->setScale (  0.5f,   0.5f );
           OcclusionDepthPanel->setPosition (  0.8,   0.8 );
          #endif //RENDERCOLOR
          
           mOcclusionCamera->setNearClipDistance(  c_cam->getNearClipDistance(   ) );
           mOcclusionCamera->setFarClipDistance(  c_cam->getFarClipDistance(   ) );
           mOcclusionCamera->setAspectRatio(  
           (  Real )c_camViewPort->getActualWidth(   ) / c_camViewPort->getActualHeight(   ) );
           }
          
           // copy camera characteristics to occlusion camera.
           mOcclusionCamera->setPosition (  c_cam->getWorldPosition (   ) );
           mOcclusionCamera->setOrientation (  c_cam->getWorldOrientation (   ) );
           mOcclusionCamera->setNearClipDistance(  c_cam->getNearClipDistance(   ) );
           mOcclusionCamera->setFarClipDistance(  c_cam->getFarClipDistance(   ) );
          
          
           mDestRenderSystem->_setViewport(  mOcclusionCamera->getViewport (   ) );
           mDestRenderSystem->_setWorldMatrix(  Matrix4::IDENTITY );
           mDestRenderSystem->_setViewMatrix(  c_cam->getViewMatrix(   ) );
           mDestRenderSystem->_setProjectionMatrix(  c_cam->getProjectionMatrix(   ) );
          
           mDestRenderSystem->_beginFrame(   );
          
           mDestRenderSystem->clearFrameBuffer (  FBT_DEPTH | FBT_COLOUR,  
           mOcclusionCamera->getViewport (   )->getBackgroundColour (   ) );
          
           #else //HWOCCLUSIONRTT
          
           assert (  c_cam->getViewport(   ) );
           mDestRenderSystem->_setViewport(  c_cam->getViewport(   ) );
           mDestRenderSystem->clearFrameBuffer (  FBT_DEPTH | FBT_COLOUR,  
           c_cam->getViewport (   )->getBackgroundColour (   ),  //color
           1.0f,  //depth
           0 );//stencil
           mDestRenderSystem->_beginFrame(   );
           assert (  c_cam->getViewport(   )->getClearEveryFrame (   ) == false );
           #endif //HWOCCLUSIONRTT
          
           mDestRenderSystem->_beginGeometryCount(   );
          
           }
           //---------------------------------------------------------------------
     931   void PagingLandScapeOctreeSceneManager::disableHardwareOcclusionTests(   )
           {
           PagingLandScapeOctreeCamera * const octreeCam = static_cast <PagingLandScapeOctreeCamera *> (  mCameraInProgress );
          
           assert (  octreeCam->getViewport (   ) );
           #ifdef HWOCCLUSIONRTT
          
           mDestRenderSystem->_endFrame(   );
           mDestRenderSystem->_setViewport(  octreeCam->getViewport (   ) );
          
           #else //HWOCCLUSIONRTT
           mDestRenderSystem->_endFrame(   );
           #endif //HWOCCLUSIONRTT
          
           if (  mCamDetail != PM_SOLID )
           {
           mDestRenderSystem->clearFrameBuffer (  FBT_DEPTH | FBT_COLOUR,  
           octreeCam->getViewport (   )->getBackgroundColour (   ),  //color
           1.0f,  //depth
           0 );//stencil
           }
          
           // make sure we restore previous detail level.
           octreeCam->setPolygonMode (  mCamDetail );
          
           // Notify camera or vis faces
           octreeCam->_addCHCRenderedFaces(  mDestRenderSystem->_getFaceCount(   ) );
           }
           //---------------------------------------------------------------------
          #ifdef PLSM2_EIHORT
     961   void PagingLandScapeOctreeSceneManager::_findVisibleObjects(  Camera* cam,   VisibleObjectsBoundsInfo * visibleBounds,   bool onlyShadowCasters )
          #else
           void PagingLandScapeOctreeSceneManager::_findVisibleObjects(  Camera * cam,   bool onlyShadowCasters )
          #endif
           {
           RenderQueue *q = SceneManager::getRenderQueue(   );
          
          
           PagingLandScapeOctreeCamera * const octreeCam = static_cast <PagingLandScapeOctreeCamera *> (  cam );
          
           assert (  mVisibles.find(  octreeCam->getId(   ) ) != mVisibles.end(   ) );
           mCamInProgressVisibles = mVisibles[octreeCam->getId(   )];
           assert (  mCamInProgressVisibles );
          
           #ifdef _VISIBILITYDEBUG
           /*
           if (  !octreeCam->isRegisteredInOcclusionSystem(   ) )
           {
           mPagingLandScapeOctree->traversal(  RegisterCameraTraversal(  octreeCam ) );
           octreeCam->setRegisteredInOcclusionSystem(  true );
           }
           */
           mBoxes.clear(   );
           if (  mCullCamera )
           {
           if (  getCamera(  "CullCamera" ) )
           cam = getCamera(  "CullCamera" );
           }
           #endif // _VISIBILITYDEBUG
          
           if (  mPagingLandScapeOctree->hasChildren (   ) )
           {
           mNumObjects = 0;
          
           // should find a way to be sure that
           // it's a new frame,   and not just a camera change or something.
           if (  mOcclusion.nextFrame (  static_cast < PagingLandScapeOctreeCamera * > (  cam ),  
           mCamInProgressVisibles,  
           onlyShadowCasters,  
           q ) )
           {
           switch (  octreeCam->getOcclusionMode(   ) )
           {
           case CHC:
           {
           enableHardwareOcclusionTests(   );
           mOcclusion.CHCtraversal (  mPagingLandScapeOctree,   visibleBounds );
           disableHardwareOcclusionTests(   );
           q->clear(   );
           #ifdef _VISIBILITYDEBUG
           if (  mCullDebug && cam->getViewport (   ) )
           {
           mDebugText =(  
           "CHC = " + StringConverter::toString(  mOcclusion.object_cnt ) + ",   t=" +
           StringConverter::toString(  mOcclusion.traversed_nodes_cnt ) + ",   f=" +
           StringConverter::toString(  mOcclusion.frustum_culled_nodes_cnt ) + ",   q=" +
           StringConverter::toString(  mOcclusion.query_cnt )
            );
           }
           #endif //_VISIBILITYDEBUG
           }
           break;
           case CHC_CONSERVATIVE:
           {
           enableHardwareOcclusionTests(   );
           mOcclusion.CHCtraversalConservative (  mPagingLandScapeOctree,   visibleBounds );
           disableHardwareOcclusionTests(   );
           q->clear(   );
          
           #ifdef _VISIBILITYDEBUG
           if (  mCullDebug && cam->getViewport (   ) )
           {
           mDebugText =(  
           "CHC Conservative = " + StringConverter::toString(  mOcclusion.object_cnt ) + ",   t=" +
           StringConverter::toString(  mOcclusion.traversed_nodes_cnt ) + ",   f=" +
           StringConverter::toString(  mOcclusion.frustum_culled_nodes_cnt ) + ",   q=" +
           StringConverter::toString(  mOcclusion.query_cnt )
            );
           }
           #endif //_VISIBILITYDEBUG
           }
           break;
          // case STOP_AND_WAIT:
          // {
          // enableHardwareOcclusionTests(   );
          // mOcclusion.initQueryPool (   );
          // mPagingLandScapeOctree->traversal (  SWTraversal (  mOcclusion ),   visibleBounds );
          // disableHardwareOcclusionTests(   ); q->clear(   );
          //
          // #ifdef _VISIBILITYDEBUG
          // if (  mCullDebug && cam->getViewport (   ) ) {cam->getViewport (   )->getTarget (   )->setDebugText(  
          // "SnW = " + StringConverter::toString(  mOcclusion.object_cnt ) + ",   t=" +
          // StringConverter::toString(  mOcclusion.traversed_nodes_cnt ) + ",   f=" +
          // StringConverter::toString(  mOcclusion.frustum_culled_nodes_cnt ) + ",   q=" +
          // StringConverter::toString(  mOcclusion.query_cnt )
          //  );}
          //
          // #endif //_VISIBILITYDEBUG
          //
          // }
          // break;
          // case VIEW_FRUSTUM:
          // {
          // mPagingLandScapeOctree->traversal (  ViewFrustumCullingTraversal (  mOcclusion ),   visibleBounds );
          // q->clear(   );
          // #ifdef _VISIBILITYDEBUG
          // if (  mCullDebug && cam->getViewport (   ) )
          // { cam->getViewport (   )->getTarget (   )->setDebugText(  
          // "VF = " + StringConverter::toString(  mOcclusion.object_cnt ) + ",   t=" +
          // StringConverter::toString(  mOcclusion.traversed_nodes_cnt ) + ",   f=" +
          // StringConverter::toString(  mOcclusion.frustum_culled_nodes_cnt ) + ",   q=" +
          // StringConverter::toString(  mOcclusion.query_cnt )
          //  );}
          //
          // #endif //_VISIBILITYDEBUG
          // }
          // break;
           case VIEW_FRUSTUM_DIRECT:
           {
           ViewFrustumCullingTraversalDirect temp (  mOcclusion );
           mPagingLandScapeOctree->traversal (  temp,   visibleBounds );
          
           #ifdef _VISIBILITYDEBUG
           if (  mCullDebug && cam->getViewport (   ) )
           {
           mDebugText =(  
           "VFD = " + StringConverter::toString(  mOcclusion.object_cnt ) + ",   t=" +
           StringConverter::toString(  mOcclusion.traversed_nodes_cnt ) + ",   f=" +
           StringConverter::toString(  mOcclusion.frustum_culled_nodes_cnt ) + ",   q=" +
           StringConverter::toString(  mOcclusion.query_cnt )
            );
           }
           #endif // _VISIBILITYDEBUG
           }
           break;
          
           default:
           assert (  0 );
           break;
           }
           }
          
           if (  !mCamInProgressVisibles->empty(   ) )
           {
           MovableObjectList::iterator movableIt = mCamInProgressVisibles->begin(   );
           MovableObjectList::iterator mitend = mCamInProgressVisibles->end(   );
           while (  movableIt != mitend )
           {
           (  *movableIt )->_updateRenderQueue (  q );
           ++movableIt;
           }
           }
          
           #ifdef _VISIBILITYDEBUG
           if (  mCullDebug )
           {
           mPagingLandScapeOctree->traversal (  TreeOverlayDebug (  mOcclusion,   this ),   visibleBounds );
           }
           #endif // _VISIBILITYDEBUG
           }
           }
           //---------------------------------------------------------------------
    1123   void PagingLandScapeOctreeSceneManager::addVisible(  MovableObject *mo )
           {
           mCamInProgressVisibles->push_back (  mo );
           }
           //---------------------------------------------------------------------
    1128   void PagingLandScapeOctreeSceneManager::directRenderSingleQueue(  RenderQueue *queue )
           {
           RenderQueue *oldQueue = mRenderQueue;
           mRenderQueue = queue;
          
           SceneManager::_renderVisibleObjects (   );
          
           queue->clear (   );
           mRenderQueue = oldQueue;
           }
           //---------------------------------------------------------------------
    1139   void PagingLandScapeOctreeSceneManager::directRenderSingleObject(  Renderable *r )
           {
           const Camera * const c_cam = mCameraInProgress;
           mDestRenderSystem->_setWorldMatrix(  Matrix4::IDENTITY );
          // mDestRenderSystem->_setViewMatrix(  c_cam->getViewMatrix(   ) );
          // mDestRenderSystem->_setProjectionMatrix(  c_cam->getProjectionMatrix(   ) );
          
           mDestRenderSystem->setCurrentPassIterationCount(  1 );
           _setPass(  r->getMaterial(   )->getBestTechnique(   )->getPass(  0 ) );
           useRenderableViewProjMode (  r );
          
           RenderOperation ro;
           r->getRenderOperation (  ro );
           mDestRenderSystem->_render(  ro );
          
           }
           //---------------------------------------------------------------------
    1156   void PagingLandScapeOctreeSceneManager::registerCamera (  PagingLandScapeOctreeCamera *c )
           {
           mPagingLandScapeOctree->traversal(  RegisterCameraTraversal(  c ),   0 );
           }
           //---------------------------------------------------------------------
           // --- non template versions
    1162   void _findNodes(  const AxisAlignedBox &t,   std::list < SceneNode * > &list,  
           const Ogre::SceneNode * const exclude,   const bool full,   PagingLandScapeOctree *octant )
           {
          
           bool isFull = full;
           if (  !full )
           {
           AxisAlignedBox obox;
           octant->_getCullBounds(  &obox );
          
           const Intersection isect = intersect(  t,   obox );
          
           if (  isect == OUTSIDE )
           return ;
          
           isFull = (  isect == INSIDE );
           }
          
          
           const bool b_full = isFull;
           NodeList::iterator it = octant->mNodes.begin(   );
          
           while (  it != octant->mNodes.end(   ) )
           {
           PagingLandScapeOctreeNode * const on = (  *it );
          
           if (  on != exclude )
           {
           if (  b_full )
           {
           list.push_back(  on );
           }
          
           else
           {
           const Intersection nsect = intersect(  t,   on->_getWorldAABB(   ) );
          
           if (  nsect != OUTSIDE )
           {
           list.push_back(  on );
           }
           }
          
           }
          
           ++it;
           }
          
          
          
           if (  octant->mChildren[ 0 ][ 0 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 0 ][ 0 ] );
          
           if (  octant->mChildren[ 1 ][ 0 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 0 ][ 0 ] );
          
           if (  octant->mChildren[ 0 ][ 1 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 1 ][ 0 ] );
          
           if (  octant->mChildren[ 1 ][ 1 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 1 ][ 0 ] );
          
           if (  octant->mChildren[ 0 ][ 0 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 0 ][ 1 ] );
          
           if (  octant->mChildren[ 1 ][ 0 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 0 ][ 1 ] );
          
           if (  octant->mChildren[ 0 ][ 1 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 1 ][ 1 ] );
          
           if (  octant->mChildren[ 1 ][ 1 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 1 ][ 1 ] );
          
           }
           //---------------------------------------------------------------------
    1238   void _findNodes(  const Sphere &t,   std::list < SceneNode * > &list,  
           const SceneNode * const exclude,  
           const bool full,   PagingLandScapeOctree *octant )
           {
           bool isFull = full;
           if (  !full )
           {
           AxisAlignedBox obox;
           octant->_getCullBounds(  &obox );
          
           const Intersection isect = intersect(  t,   obox );
          
           if (  isect == OUTSIDE )
           return ;
          
           isFull = (  isect == INSIDE );
           }
          
           const bool b_full = isFull;
           NodeList::iterator it = octant->mNodes.begin(   );
          
           while (  it != octant->mNodes.end(   ) )
           {
           PagingLandScapeOctreeNode * const on = (  *it );
          
           if (  on != exclude )
           {
           if (  b_full )
           {
           list.push_back(  on );
           }
          
           else
           {
           const Intersection nsect = intersect(  t,   on->_getWorldAABB(   ) );
          
           if (  nsect != OUTSIDE )
           {
           list.push_back(  on );
           }
           }
          
           }
          
           ++it;
           }
          
          
          
           if (  octant->mChildren[ 0 ][ 0 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 0 ][ 0 ] );
          
           if (  octant->mChildren[ 1 ][ 0 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 0 ][ 0 ] );
          
           if (  octant->mChildren[ 0 ][ 1 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 1 ][ 0 ] );
          
           if (  octant->mChildren[ 1 ][ 1 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 1 ][ 0 ] );
          
           if (  octant->mChildren[ 0 ][ 0 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 0 ][ 1 ] );
          
           if (  octant->mChildren[ 1 ][ 0 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 0 ][ 1 ] );
          
           if (  octant->mChildren[ 0 ][ 1 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 1 ][ 1 ] );
          
           if (  octant->mChildren[ 1 ][ 1 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 1 ][ 1 ] );
          
           }
           //---------------------------------------------------------------------
    1313   void _findNodes(  const PlaneBoundedVolume &t,   std::list < SceneNode * > &list,  
           const Ogre::SceneNode * const exclude,   const bool full,   PagingLandScapeOctree *octant )
           {
          
           bool isFull = full;
           if (  !full )
           {
           AxisAlignedBox obox;
           octant->_getCullBounds(  &obox );
          
           const Intersection isect = intersect(  t,   obox );
          
           if (  isect == OUTSIDE )
           return ;
          
           isFull = (  isect == INSIDE );
           }
          
          
           const bool b_full = isFull;
           NodeList::iterator it = octant->mNodes.begin(   );
          
           while (  it != octant->mNodes.end(   ) )
           {
           PagingLandScapeOctreeNode * const on = (  *it );
           if (  on != exclude )
           {
           if (  b_full )
           {
           list.push_back(  on );
           }
           else
           {
           const Intersection nsect = intersect(  t,   on->_getWorldAABB(   ) );
          
           if (  nsect != OUTSIDE )
           {
           list.push_back(  on );
           }
           }
           }
           ++it;
           }
          
           if (  octant->mChildren[ 0 ][ 0 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 0 ][ 0 ] );
          
           if (  octant->mChildren[ 1 ][ 0 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 0 ][ 0 ] );
          
           if (  octant->mChildren[ 0 ][ 1 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 1 ][ 0 ] );
          
           if (  octant->mChildren[ 1 ][ 1 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 1 ][ 0 ] );
          
           if (  octant->mChildren[ 0 ][ 0 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 0 ][ 1 ] );
          
           if (  octant->mChildren[ 1 ][ 0 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 0 ][ 1 ] );
          
           if (  octant->mChildren[ 0 ][ 1 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 1 ][ 1 ] );
          
           if (  octant->mChildren[ 1 ][ 1 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 1 ][ 1 ] );
          
           }
           //---------------------------------------------------------------------
    1383   void _findNodes(  const Ray &t,   std::list < SceneNode * > &list,  
           const Ogre::SceneNode * const exclude,  
           const bool full,   PagingLandScapeOctree *octant )
           {
           bool isFull = full;
           if (  !full )
           {
           AxisAlignedBox obox;
           octant->_getCullBounds(  &obox );
          
           const Intersection isect = intersect(  t,   obox );
          
           if (  isect == OUTSIDE )
           return ;
          
           isFull = (  isect == INSIDE );
           }
          
          
           const bool b_full = isFull;
           if (  !octant->mNodes.empty (   ) )
           {
           NodeList::iterator it = octant->mNodes.begin(   );
           while (  it != octant->mNodes.end(   ) )
           {
           PagingLandScapeOctreeNode * const on = (  *it );
           if (  on != exclude )
           {
           if (  b_full )
           {
           list.push_back(  on );
           }
           else
           {
           const Intersection nsect = intersect(  t,   on->_getWorldAABB(   ) );
           if (  nsect != OUTSIDE )
           list.push_back(  on );
           }
           }
           ++it;
           }
           }
           if (  octant->hasChildren (   ) )
           {
           if (  octant->mChildren[ 0 ][ 0 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 0 ][ 0 ] );
          
           if (  octant->mChildren[ 1 ][ 0 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 0 ][ 0 ] );
          
           if (  octant->mChildren[ 0 ][ 1 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 1 ][ 0 ] );
          
           if (  octant->mChildren[ 1 ][ 1 ][ 0 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 1 ][ 0 ] );
          
           if (  octant->mChildren[ 0 ][ 0 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 0 ][ 1 ] );
          
           if (  octant->mChildren[ 1 ][ 0 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 0 ][ 1 ] );
          
           if (  octant->mChildren[ 0 ][ 1 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 0 ][ 1 ][ 1 ] );
          
           if (  octant->mChildren[ 1 ][ 1 ][ 1 ] != 0 )
           _findNodes(  t,   list,   exclude,   b_full,   octant->mChildren[ 1 ][ 1 ][ 1 ] );
           }
           }
           //---------------------------------------------------------------------
    1453   void PagingLandScapeOctreeSceneManager::findNodesIn(  const AxisAlignedBox &box,   std::list < SceneNode * > &list,   const SceneNode* const exclude )
           {
           _findNodes(  box,   list,   exclude,   false,   mPagingLandScapeOctree );
           }
           //---------------------------------------------------------------------
    1458   void PagingLandScapeOctreeSceneManager::findNodesIn(  const Sphere &sphere,   std::list < SceneNode * > &list,   const SceneNode* const exclude )
           {
           _findNodes(  sphere,   list,   exclude,   false,   mPagingLandScapeOctree );
           }
           //---------------------------------------------------------------------
    1463   void PagingLandScapeOctreeSceneManager::findNodesIn(  const PlaneBoundedVolume &volume,   std::list < SceneNode * > &list,   const SceneNode* const exclude )
           {
           _findNodes(  volume,   list,   exclude,   false,   mPagingLandScapeOctree );
           }
           //---------------------------------------------------------------------
    1468   void PagingLandScapeOctreeSceneManager::findNodesIn(  const Ray &r,   std::list < SceneNode * > &list,   const SceneNode* const exclude )
           {
           _findNodes(  r,   list,   exclude,   false,   mPagingLandScapeOctree );
           }
           //---------------------------------------------------------------------
    1473   void PagingLandScapeOctreeSceneManager::resize(  const AxisAlignedBox &box,   const int depth )
           {
           mMaxDepth = depth;
           resize(  box );
           }
           //---------------------------------------------------------------------
    1479   void PagingLandScapeOctreeSceneManager::resize(  const AxisAlignedBox &box )
           {
           std::list < SceneNode * > nodes;
          
           _findNodes(  mPagingLandScapeOctree->getBoundingBox (   ),   nodes,   0,   true,   mPagingLandScapeOctree );
          
           if (  mPagingLandScapeOctree )
           deleteOctree (  mPagingLandScapeOctree );
          
           mBox = box;
           mPagingLandScapeOctree = mOctreeSet.getPoolable(   );
           assert (  mPagingLandScapeOctree );
           mPagingLandScapeOctree->setSceneManager (  this );
           mPagingLandScapeOctree ->setBoundingBox (  box.getMinimum(   ),   box.getMaximum(   ) );
           registeredNodeInCamera (  mPagingLandScapeOctree );
          
           if (  !nodes.empty(   ) )
           {
           std::list < SceneNode * > ::iterator it;
           it = nodes.begin(   );
          
           while (  it != nodes.end(   ) )
           {
           PagingLandScapeOctreeNode * const on = static_cast < PagingLandScapeOctreeNode * > (  *it );
           on->setOctant(  0 );
           _updatePagingLandScapeOctreeNode(  on );
           ++it;
           } // while (  it != nodes.end(   ) )
           }
           }
           //---------------------------------------------------------------------
    1510   bool PagingLandScapeOctreeSceneManager::setOption(  const String & key,   const void * val )
           {
           if (  key == "Size" )
           {
           resize(  * static_cast < const AxisAlignedBox * > (  val ) );
           return true;
           }
          
           else if (  key == "Depth" )
           {
           assert (  mPagingLandScapeOctree );
           mMaxDepth = * static_cast < const int * > (  val );
           // copy the box since resize will delete mOctree and reference won't work
           AxisAlignedBox box = mPagingLandScapeOctree->getBoundingBox(   );
           resize(  box );
           return true;
           }
           else if (  key == "NextCullMode" )
           {
           if (  val )
           {
           CameraList::iterator it = mCameras.find (  static_cast < const PagingLandScapeOctreeCamera * > (  val )->getName(   ) );
           if (  it != mCameras.end(   ) )
           {
           static_cast < PagingLandScapeOctreeCamera * > (  it->second )->setNextOcclusionMode(   );
           return true;
           }
           }
           return false;
           }
           else if (  key == "setNumberOfConservativeFrames" )
           {
           mOcclusion.setNumberOfConservativeFrames(  *(  static_cast < const unsigned int * > (  val ) ) );
           }
           else if (  key == "CurrentOptionCamera" )
           {
           if (  val )
           {
           CameraList::iterator it = mCameras.find (  static_cast < const PagingLandScapeOctreeCamera * > (  val )->getName(   ) );
           if (  it != mCameras.end(   ) )
           {
           mCurrentOptionCamera = static_cast < PagingLandScapeOctreeCamera * > (  it->second );
           }
           return true;
           }
           }
           else if (  key == "setCullingMode" )
           {
           assert (  mCurrentOptionCamera );
           mCurrentOptionCamera->setOcclusionModeAsString(  * static_cast < const String * > (  val ) );
           return true;
           }
           #ifdef _VISIBILITYDEBUG
           else if (  key == "ShowPagingLandScapeOctree" )
           {
           mShowBoxes = * static_cast < const bool * > (  val );
           return true;
           }
           else if (  key == "CullDebug" )
           {
           mCullDebug = * static_cast < const bool * > (  val );
           return true;
           }
           else if (  key == "CullCamera" )
           {
           mCullCamera = * static_cast < const bool * > (  val );
           return true;
           }
           #endif //_VISIBILITYDEBUG
           return SceneManager::setOption(  key,   val );
          
          
           }
           //---------------------------------------------------------------------
    1584   bool PagingLandScapeOctreeSceneManager::getOption(  const String & key,   void *val )
           {
           if (  key == "Size" )
           {
           AxisAlignedBox * b = static_cast < AxisAlignedBox * > (  val );
           b->setExtents(  mPagingLandScapeOctree->getBoundingBox (   ).getMinimum(   ),   mPagingLandScapeOctree->getBoundingBox(   ).getMaximum(   ) );
           return true;
           }
          
           else if (  key == "Depth" )
           {
           * static_cast < int * > (  val ) = mMaxDepth;
           return true;
           }
           else if (  key == "setNumberOfConservativeFrames" )
           {
           * static_cast < unsigned int * > (  val ) = mOcclusion.getNumberOfConservativeFrames(   );
           return true;
           }
           else if (  key == "CurrentOptionCamera" )
           {
           *static_cast < String * > (  val ) = mCurrentOptionCamera->getName(   );
           return true;
           }
           else if (  key == "getCullingMode" )
           {
           assert (  mCurrentOptionCamera );
           *static_cast < String * > (  val ) = mCurrentOptionCamera->getOcclusionModeAsString(   );
           return true;
           }
          
           #ifdef _VISIBILITYDEBUG
           else if (  key == "ShowPagingLandScapeOctree" )
           {
          
           * static_cast < bool * > (  val ) = mShowBoxes;
           return true;
           }
           else if (  key == "CullCamera" )
           {
           * static_cast < bool * > (  val ) = mCullCamera;
           return true;
           }
           else if (  key == "CullDebug" )
           {
           * static_cast < bool * > (  val ) = mCullDebug;
           return true;
           }
           else if (  key == "DebugText" )
           {
           * static_cast < String * > (  val ) = mDebugText;
           return true;
           }
           #endif //_VISIBILITYDEBUG
          
           return SceneManager::getOption(  key,   val );
           }
           //---------------------------------------------------------------------
    1642   void PagingLandScapeOctreeSceneManager::clearScene(  void )
           {
           SceneManager::clearScene(   );
          
           // reset cameras
           //CameraList::iterator iCam = mCameras.begin(   );
           //for (  ; iCam != mCameras.end(   ); ++iCam )
           //{
           // PagingLandScapeOctreeCamera *cam = static_cast <PagingLandScapeOctreeCamera *> (  iCam->second );
           // if (  cam->isRegisteredInOcclusionSystem (   ) )
           // {
           // mPagingLandScapeOctree->traversal (  UnregisterCameraTraversal(  cam ) );
           // cam->setRegisteredInOcclusionSystem (  false );
           // }
           //}
          
           init(  mBox,   mMaxDepth );
          
           }
           //---------------------------------------------------------------------
           AxisAlignedBoxSceneQuery*
    1663   PagingLandScapeOctreeSceneManager::createAABBQuery(  const AxisAlignedBox& box,   unsigned long mask )
           {
           PagingLandScapeOctreeAxisAlignedBoxSceneQuery* q = new PagingLandScapeOctreeAxisAlignedBoxSceneQuery(  this );
           q->setBox(  box );
           q->setQueryMask(  mask );
           return q;
           }
           //---------------------------------------------------------------------
           SphereSceneQuery*
    1672   PagingLandScapeOctreeSceneManager::createSphereQuery(  const Sphere& sphere,   unsigned long mask )
           {
           PagingLandScapeOctreeSphereSceneQuery* q = new PagingLandScapeOctreeSphereSceneQuery(  this );
           q->setSphere(  sphere );
           q->setQueryMask(  mask );
           return q;
           }
           //---------------------------------------------------------------------
           PlaneBoundedVolumeListSceneQuery*
    1681   PagingLandScapeOctreeSceneManager::createPlaneBoundedVolumeQuery(  const PlaneBoundedVolumeList& volumes,  
           unsigned long mask )
           {
           PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery* q = new PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery(  this );
           q->setVolumes(  volumes );
           q->setQueryMask(  mask );
           return q;
           }
          
           //---------------------------------------------------------------------
           RaySceneQuery*
    1692   PagingLandScapeOctreeSceneManager::createRayQuery(  const Ray& ray,   unsigned long mask )
           {
           PagingLandScapeOctreeRaySceneQuery* q = new PagingLandScapeOctreeRaySceneQuery(  this );
           q->setRay(  ray );
           q->setQueryMask(  mask );
           return q;
           }
           //---------------------------------------------------------------------
           IntersectionSceneQuery*
    1701   PagingLandScapeOctreeSceneManager::createIntersectionQuery(  unsigned long mask )
           {
          
           // PagingLandScapeOctree implementation performs WORSE for < 500 objects
           // TODO: optimize it so it's better in all cases
           //PagingLandScapeOctreeIntersectionSceneQuery* q = new PagingLandScapeOctreeIntersectionSceneQuery(  this );
           DefaultIntersectionSceneQuery* q;
           if (  mPagingLandScapeOctree->numNodes (   ) > 500 )
           q = new PagingLandScapeOctreeIntersectionSceneQuery(  this );
           else
           q = new DefaultIntersectionSceneQuery(  this );
           q->setQueryMask(  mask );
           return q;
           }
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOctreeSphereSceneQuery.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright 2000-2006 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          /***************************************************************************
          OgrePagingLandScapeOctreeSphereSceneQuery.cpp - description
          -------------------
          begin : Tues July 20,   2004
          copyright : (  C ) 2004by Jon Anderson
          email : janders@users.sf.net
          
          
          
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeOctreeSphereSceneQuery.h"
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          #include "OgreEntity.h"
          
          namespace Ogre
          {
          
          //---------------------------------------------------------------------
      46  PagingLandScapeOctreeSphereSceneQuery::PagingLandScapeOctreeSphereSceneQuery(  SceneManager* creator )
           : DefaultSphereSceneQuery(  creator )
          {
          }
          
          //---------------------------------------------------------------------
      52  PagingLandScapeOctreeSphereSceneQuery::~PagingLandScapeOctreeSphereSceneQuery(  void )
          {
          }
          
          //---------------------------------------------------------------------
      57  void PagingLandScapeOctreeSphereSceneQuery::execute(  SceneQueryListener* listener )
          {
           std::list < SceneNode* > list;
           //find the nodes that intersect the AAB
           static_cast< PagingLandScapeOctreeSceneManager* >(  mParentSceneMgr )->findNodesIn(  mSphere,   list,   0 );
          
           //grab all moveables from the node that intersect...
           std::list< SceneNode* >::iterator it = list.begin(   );
           while(  it != list.end(   ) )
           {
           SceneNode::ObjectIterator oit = (  *it )->getAttachedObjectIterator(   );
           while (  oit.hasMoreElements(   ) )
           {
           MovableObject* m = oit.getNext(   );
           if (  (  m->getQueryFlags(   ) & mQueryMask )
           && m->isInScene(   )
           && mSphere.intersects(  m->getWorldBoundingBox(   ) ) )
           {
           listener->queryResult(  m );
           }
           }
           ++it;
           }
          }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOptions.cpp

       1  /***************************************************************************
           OgrePagingLandScapeOptions.cpp - description
           -------------------
           begin : Sun Mar 02 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreRoot.h"
          #include "OgreSceneManager.h"
          #include "OgreRenderSystem.h"
          #include "OgreGpuProgramManager.h"
          
          #include "OgreStringConverter.h"
          #include "OgreVector2.h"
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          #include "OgreConfigFile.h"
          
          #include "OgreImage.h"
          #include "OgreMaterialManager.h"
          #include "OgreMaterial.h"
          #include "OgreTechnique.h"
          
          #include "OgreCamera.h"
          #include "OgreViewport.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeCamera.h"
          #include "OgrePagingLandScapeTileInfo.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      49   PagingLandScapeOptions::PagingLandScapeOptions(  PagingLandScapeSceneManager * scnMgr ):
           mScnMgr(  scnMgr )
           {
           cfgGroupName = "";
           primaryCamera = 0;
           isInit = false;
           setDefault(   );
           };
          
           //-----------------------------------------------------------------------
      59   PagingLandScapeOptions::~PagingLandScapeOptions(   )
           {
           clearTileInfo(   );
           }
           //-----------------------------------------------------------------------
      64   void PagingLandScapeOptions::setDefault(   )
           {
          
           mUseLodMapCache = false;
           materialPerPage = false;
           textureModifiable = true;
           roughnessLod = true;
          
           data2DFormat = "HeightField";
           textureFormat = "Image";
          
           image_filename = "";
           ImageNameLoad = false;
           LandScape_filename = "";
           LandScape_export_filename = "";
           ColorMapName = "";
          
           groupName = cfgGroupName;
          
           LandScape_extension = "png";
           LandScape_export_extension = "png";
           TextureExtension = "png";
          
           maxValue = 5000;
           minValue = 0;
          
           PageSize = 513;
           TileSize = 65;
           maxRenderLevel = 100;
          
           world_width = 0;
           world_height = 0;
          
           maxScaledZ = 0;
           maxScaledX = 0;
           maxUnScaledZ = 0;
           maxUnScaledX = 0;
          
           max_adjacent_pages = 2;
           max_preload_pages = 3;
           PageLoadInterval = 30;
          
           change_factor = 1;
           distanceLOD = 4;
           LOD_factor = 10;
          
           scale = Ogre::Vector3::UNIT_SCALE;
           invScale = Ogre::Vector3::UNIT_SCALE;
           position = Ogre::Vector3::ZERO;
          
           num_renderables = 64;
           num_renderables_increment = 64;
           num_tiles = 64;
           num_tiles_increment = 64;
          
           visible_renderables = 75;
           cameraThreshold = 5;
          
           num_renderables_loading = 10;
           RenderableLoadInterval = 3;
          
           normals = false;
           lit = false;
          
           colored = false;
           vertex_shadowed = false;
           base_vertex_color = false;
           coverage_vertex_color = false;
           vertex_instant_colored = false;
          
           RawHeight = 0;
           RawWidth = 0;
          
           lightmoved = false;
          
           Deformable = false;
           saveDeformation = true;
           VertexCompression = false;
          
           BigImage = false;
          
           lodMorphStart = 0.2f;
           lodMorph = false;
          
           maxPixelError = 0;
          
           TextureStretchFactor = 1.0f;
          
           NumMatHeightSplat = 0;
           matHeight.reserve (  0 );
           matHeight.resize (  0 );
           matColor.reserve (  0 );
           matColor.resize (  0 );
          
           NumSplatMapToSplit = 0;
           SplatMapNames.reserve (  0 );
           SplatMapNames.resize (  0 );
          
           NumTextureFormatSupported = 0;
           TextureFormatSupported.reserve (  0 );
           TextureFormatSupported.resize (  0 );
          
           MaxLodUnderCam = false;
           VisMap = false;
           BigImage = false;
          
           PageInvisibleUnloadFrames = 300;
           TileInvisibleUnloadFrames = 300;
          
           lodMaterialDistanceList.clear(   );
           lodMaterialDistanceList.push_back (  80000.0f );
          
           mResourceFilesystem.clear (   );
           mResourceZip.clear(   );
          
           queryNoInterpolation = false;
           queryResolutionFactor = 1.0f;
          #ifdef _MAPSPLITTER
          
           Blur = 0.0f;
           Amb = 0.5f;
           Diff = 0.5f;
          
           Blur = 0.0f;
           HeightMapBlurFactor = 0.0f;
           Paged = true;
           MiniMap = false;
           BaseMap = false;
           ColorMapGenerate = false;
           ColorMapSplit = false;
           LightMap = false;
           NormalMap = false;
           HeightMap = false;
           AlphaMaps = false;
           LitBaseMap = false;
           InfiniteMap = false;
           CoverageMap = false;
           LitColorMapGenerate = false;
           LitColorMapSplit = false;
           HeightNormalMap = false;
           Equalize = false;
           ZHorizon = false;
           SRTM_water = false;
          
          #endif
           }
           //-----------------------------------------------------------------------
     211   void PagingLandScapeOptions::init(   )
           {
           // sets options that doesn't depend on maps.
           if (  !isInit )
           {
           const RenderSystem *renderer = Root::getSingleton(   ).getRenderSystem(   );
           if (  renderer )
           {
           const RenderSystemCapabilities* caps = renderer->getCapabilities(   );
           hasVertexShader = caps->hasCapability(  RSC_VERTEX_PROGRAM ) && !(  StringUtil::startsWith(  caps->getMaxFragmentProgramVersion (   ),   "vs_1_0",   true ) );
           hasVertexShader = caps->hasCapability(  RSC_BLENDING ) && !(  StringUtil::startsWith(  caps->getMaxFragmentProgramVersion (   ),   "vs_1_0",   true ) );
           hasFragmentShader = caps->hasCapability(  RSC_FRAGMENT_PROGRAM );
           const String &maxShaderVersion = caps->getMaxFragmentProgramVersion (   );
           hasFragmentShader2 = hasFragmentShader && !(  maxShaderVersion == "ps_1_1" || maxShaderVersion == "ps_1_0" );
           numTextureUnits = caps->getNumTextureUnits (   );
           isRenderGL = StringUtil::startsWith(  renderer->getName(   ),   "OpenGL",   false );
           isInit = true;
           }
           }
           }
           //-----------------------------------------------------------------------
     232   void PagingLandScapeOptions::loadcfg (  const String &filename,   ConfigFile& config )
           {
           std::ifstream fs;
           fs.open(  filename.c_str(   ),   std::ios::in | std::ios::binary );
           if (  fs )
           {
           // Wrap as a stream
           DataStreamPtr stream(  
           new FileStreamDataStream(  filename,   &fs,   false ) );
          
           config.load(  stream );
          
           }
           else
           {
           // otherwise try resource system
           DataStreamPtr stream =
           ResourceGroupManager::getSingleton(   ).openResource(  filename );
          
           config.load(  stream );
           }
           }
           //-----------------------------------------------------------------------
     255   bool PagingLandScapeOptions::load(  const String &filename )
           {
           ConfigFile config;
           loadcfg(  filename,   config );
           return load(  filename,   config );
           }
           //-----------------------------------------------------------------------
     262   bool PagingLandScapeOptions::load(  DataStreamPtr &stream )
           {
           ConfigFile config;
           config.load(  stream );
           return load(  stream->getName (   ),   config );
           }
           //-----------------------------------------------------------------------
     269   bool PagingLandScapeOptions::load(  const String &filename,   ConfigFile& config )
           {
           init(   );
          
           // Set up the options :
           // List of map associated with map names.
           // or directly a map.
          
          
           if (  config.getSetting (  "DefaultMap" ).empty(   ) )
           {
           mConfig = &config;
           mCurrentMap = filename;
           loadMapOptions (  filename );
           return true;
           }
           else
           {
           // Go through all sections & settings in the file
           ConfigFile::SettingsIterator setIt = config.getSettingsIterator(   );
           while (  setIt.hasMoreElements(   ) )
           {
           const String name = setIt.peekNextKey(   );
           const String value = setIt.getNext(   );
           mMapList.insert(  LandScapeFileNames::value_type(  name,   value ) );
           }
          
           LandScapeFileNames::iterator i = mMapList.find(  "GroupName" );
           if (  i == mMapList.end(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,  
           "You need to define a GroupName where to find the map definition file ",  
           "PagingLandScapeOptions::load" );
           }
           cfgGroupName = i->second;
           mMapList.erase (  i );
          
          
           i = mMapList.find(  "BatchMode" );
           if (  (  i != mMapList.end(   ) ) && (  i->second == "yes" ) )
           {
           mBatchMode = true;
           mMapList.erase (  i );
           }
           else
           {
           mBatchMode = false;
           }
          
           i = mMapList.find(  "TextureFormatDebug" );
           if (  i != mMapList.end(   ) )
           {
           TextureFormatDebug = config.getSetting(  "TextureFormatDebug" ) == "yes";
           mMapList.erase (  i );
           }
          
          
          
           i = mMapList.find(  "DefaultMap" );
           if (  i == mMapList.end(   ) )
           {
           if(   mBatchMode == false )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,  
           "You need to define a DefaultMap= ",  
           "PagingLandScapeOptions::load" );
           }
           }
           else
           {
           mCurrentMap = i->second;
           }
           if (  i != mMapList.end(   ) )
           mMapList.erase (  i );
          
          
          #ifndef _MAPSPLITTER
           ResourceGroupManager * const rgsm = ResourceGroupManager::getSingletonPtr(   );
          
           rgsm->initialiseResourceGroup (  cfgGroupName );
          
           LandScapeFileNames::iterator iend = mMapList.end(   );
           LandScapeFileNames::iterator itCheck = mMapList.begin(   );
           const String cfgExt(  ".cfg" );
           for (  ; itCheck != iend;  )
           {
           const String mapName (  itCheck->first );
           const String mapFileName (  itCheck->second );
           if (  
           !rgsm->resourceExists(  cfgGroupName,   mapFileName )
           &&
           !rgsm->resourceExists(  cfgGroupName,   mapFileName + cfgExt )
           &&
           !rgsm->resourceExists(  cfgGroupName,   mapName + cfgExt )
           &&
           !rgsm->resourceExists(  cfgGroupName,   mapName )
            )
           {
           mMapList.erase (  itCheck++ );
           }
           else
           {
           ++itCheck;
           }
           }
          #endif //_MAPSPLITTER
          
           if (  !mBatchMode && !StringUtil::startsWith(  mCurrentMap,   "none",   true ) )
           {
           loadMap(  mCurrentMap );
           return true;
           }
           }
          
           return false;
           }
           //-----------------------------------------------------------------------
     386   const String &PagingLandScapeOptions::getCurrentTextureFormat(   ) const
           {
           return textureFormat;
           }
           //-----------------------------------------------------------------------
     391   void PagingLandScapeOptions::setTextureFormat (  const String &format )
           {
           if (  TextureFormatSupported.end(   ) == std::find(  TextureFormatSupported.begin(   ),  
           TextureFormatSupported.end(   ),  
           format ) )
           {
           TextureFormatSupported.push_back (  format );
           }
           textureFormat = format;
           // sort of debugging hack til BigImage itself becomes a chunked Lod thing.
           BigImage = BigImage && textureFormat == "Image";
           }
           //-----------------------------------------------------------------------
     404   void PagingLandScapeOptions::insertTextureFormat (  const String &format )
           {
           if (  TextureFormatSupported.end(   ) == std::find(  TextureFormatSupported.begin(   ),  
           TextureFormatSupported.end(   ),  
           format ) )
           {
           TextureFormatSupported.push_back (  format );
           }
           }
          
           //-----------------------------------------------------------------------
     415   LandScapeFileNames& PagingLandScapeOptions::getMapList(   )
           {
           return mMapList;
           }
           //-----------------------------------------------------------------------
     420   const String& PagingLandScapeOptions::getPreviousMapName(   ) const
           {
           if (  !mMapList.empty (   ) )
           {
           if (  StringUtil::startsWith(  mCurrentMap,   "none",   true ) )
           return mMapList.rbegin(   )->first;
           LandScapeFileNames::const_reverse_iterator iend = mMapList.rend(   );
           LandScapeFileNames::const_reverse_iterator i = mMapList.rbegin(   );
           for (  ; i != iend; ++i )
           {
           if (  i->first == mCurrentMap || i->second == mCurrentMap )
           {
           ++i;
           if (  i == iend )
           i = mMapList.rbegin(   );
           return i->first;
           }
           }
           }
           return StringUtil::BLANK;
           }
           //-----------------------------------------------------------------------
     442   const String& PagingLandScapeOptions::getNextMapName(   ) const
           {
           if (  !mMapList.empty (   ) )
           {
           if (  StringUtil::startsWith(  mCurrentMap,   "none",   true ) )
           return mMapList.begin(   )->first;
          
           LandScapeFileNames::const_iterator iend = mMapList.end(   );
           LandScapeFileNames::const_iterator i = mMapList.begin(   );
           for (  ; i != iend; ++i )
           {
           if (  i->first == mCurrentMap || i->second == mCurrentMap )
           {
           ++i;
           if (  i == iend )
           i = mMapList.begin(   );
           return i->first;
           }
           }
           }
           return StringUtil::BLANK;
           }
           //-----------------------------------------------------------------------
     465   const String& PagingLandScapeOptions::getCurrentMapName(   ) const
           {
           return mCurrentMap;
           }
           //-----------------------------------------------------------------------
     470   void PagingLandScapeOptions::setCurrentMapName(  const String& mapName )
           {
           if (  StringUtil::BLANK != mapName )
           {
           LandScapeFileNames::iterator ifind = mMapList.find (  mapName );
           if (  ifind == mMapList.end(   ) )
           {
           mMapList.insert(  LandScapeFileNames::value_type(  mapName,   mapName ) );
           }
           mCurrentMap = mapName;
           }
           loadMap(  mapName );
           }
           //-----------------------------------------------------------------------
     484   void PagingLandScapeOptions::loadMap(  const String& mapName )
           {
           ConfigFile config;
           mConfig = &config;
           const String fileMapName (  getMapFilename(  mapName ) +
           (  StringUtil::endsWith(  mapName,   ".cfg",   true ) ? StringUtil::BLANK : String(  ".cfg" ) ) );
           if (  !cfgGroupName.empty (   ) )
           {
           std::vector<Ogre::String>::iterator itFileSystem = mResourceFilesystem.begin(   );
           for(  ; itFileSystem != mResourceFilesystem.end(   ); ++itFileSystem )
           {
           ResourceGroupManager::getSingleton(   ).removeResourceLocation(  
           *itFileSystem,   cfgGroupName );
           }
           std::vector<Ogre::String>::iterator itZip = mResourceZip.begin(   );
           for(  ; itZip != mResourceZip.end(   ); ++itZip )
           {
           ResourceGroupManager::getSingleton(   ).removeResourceLocation(  
           *itZip,   cfgGroupName );
           }
           // Set up the options For a Map
           mConfig->load (  fileMapName,   cfgGroupName,   String(  "=" ),   true );
           }
           else
           {
           mConfig->load (  fileMapName,   ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,   String(  "=" ),   true );
           }
           /* Set up the options For a Map*/
           loadMapOptions (  fileMapName );
           }
           //-----------------------------------------------------------------------
     515   const String &PagingLandScapeOptions::getMapFilename(  const String &currMapName ) const
           {
           LandScapeFileNames::const_iterator i = mMapList.find(  currMapName );
           LandScapeFileNames::const_iterator iEnd = mMapList.end(   );
           if (  i != iEnd )
           return i->second;
          
          
           for (  i = mMapList.begin(   ); i != iEnd; ++i )
           {
           if (  StringUtil::match(  i->second,   currMapName,   false ) ||
           StringUtil::match(  i->first,   currMapName,   false ) )
           {
           return i->second;
           }
           }
           return currMapName;
           }
           //-----------------------------------------------------------------------
     534   void PagingLandScapeOptions::insertMap(  const String& mapName )
           {
           LandScapeFileNames::iterator ifind = mMapList.find (  mapName );
           if (  ifind == mMapList.end(   ) )
           {
           mMapList.insert(  LandScapeFileNames::value_type(  mapName,   mapName ) );
           }
           }
           //-----------------------------------------------------------------------
     543   bool PagingLandScapeOptions::setUint (  unsigned int &u,   const String &ValuetoGet )
           {
           const String valString = mConfig->getSetting(  ValuetoGet );
           if (  !valString.empty(   ) )
           {
           u = static_cast<unsigned int> (  StringConverter::parseReal(  valString ) );
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
     554   bool PagingLandScapeOptions::setBool (  bool &b,   const String &ValuetoGet )
           {
           const String valString = mConfig->getSetting (  ValuetoGet );
           if (  !valString.empty(   ) )
           {
           b = StringUtil::startsWith(  valString,   "yes",   true );
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
     565   bool PagingLandScapeOptions::setReal (  Real &r,   const String &ValuetoGet )
           {
           const String valString = mConfig->getSetting(  ValuetoGet );
           if (  !valString.empty(   ) )
           {
           const Ogre::Real val = StringConverter::parseReal(  valString );
           r = val;
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
     577   bool PagingLandScapeOptions::setColourValue(  ColourValue &r,   const String &ValuetoGet )
           {
           const String valString = mConfig->getSetting(  ValuetoGet );
           if (  !valString.empty(   ) )
           {
           const ColourValue val = StringConverter::parseColourValue(  valString );
           r = val;
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
     589   bool PagingLandScapeOptions::setString (  String &s,   const String &ValuetoGet )
           {
           const String val = mConfig->getSetting (  ValuetoGet );
           if (  !val.empty(   ) )
           {
           s = val;
           return true;
           }
           return false;
           }
           //-----------------------------------------------------------------------
     600   void PagingLandScapeOptions::loadMapOptions(  const String& mapName )
           {
           unsigned int i;
          
           init (   );
           setDefault (   );
          
           ///By Ember start
           // Set up the options For a Map
           ConfigFile config;
           config.load (  mapName,   cfgGroupName,   String(  "=" ),   true );
           mConfig = &config;
           ///By Ember end
          
          
           // Set up the dimensions For a Map
           #if !defined(  _MAPSPLITTER ) && !defined(  _MAPEDITOR )
          
           setUint (  world_height,   "Height" );
           setUint (  world_width,   "Width" );
           if (  world_width == 0 || world_height == 0 )
           {
           OGRE_EXCEPT(  1,  
           "Your map must at least have a width and height defined in the config file ",  
           "PagingLandScapeOptions::loadMapOptions" );
           }
           #endif // !defined(  _MAPSPLITTER ) && !defined(  _MAPEDITOR )
          
          
           setUint (  PageSize,   "PageSize" );
           setUint (  TileSize,   "TileSize" );
          
           invPageSizeMinusOne = 1.0 / (  PageSize - 1 );
           invTileSizeMinusOne = 1.0 / (  TileSize - 1 );
          
           NumTiles = static_cast<unsigned int> (  static_cast <Real> (  PageSize ) / (  TileSize - 1 ) );
           NumPages = static_cast<unsigned int> (  static_cast <Real> (  world_height * world_width ) );
           const unsigned int totalNumTiles = NumPages * (  NumTiles*NumTiles ) + 1;
          
           ///EMBER: added for ember,   since we never want the scale to be different from the page size
           scale.x = scale.z = PageSize;
           scale.y = 1;
          // setReal (  scale.x,   "ScaleX" );
          // setReal (  scale.y,   "ScaleY" );
          // setReal (  scale.z,   "ScaleZ" );
          
           setReal(   position.x,   "PositionX" );
           setReal(   position.y,   "PositionY" );
           setReal(   position.z,   "PositionZ" );
          
           // secret tweak helping joining tile using vertex compression
           // leads to texture distortion at page breaks otherwise.
           const double scalemodif = 1.0f;//static_cast <double> (  PageSize - 1 ) / PageSize;
           ScaledPageSizeX = scale.x * scalemodif;
           ScaledPageSizeZ = scale.z * scalemodif;
           ScaledHeightY = scale.y / 65535;
          
           setReal (  TextureStretchFactor,   "TextureStretchFactor" );
          
          #if !defined(  _MAPSPLITTER ) && !defined(  _MAPEDITOR )
          
           // Scale x/z relative to page size
           scale.x /= (  PageSize - 1 );
           scale.z /= (  PageSize - 1 );
          
          #else// defined(  _MAPSPLITTER ) || defined(  _MAPEDITOR )
           //scale.y = scale.y;
           scale.x /= (  PageSize - 1 ) * TextureStretchFactor;
           scale.z /= (  PageSize - 1 ) * TextureStretchFactor;
          
          #endif// defined(  _MAPSPLITTER ) || defined(  _MAPEDITOR )
          
           invScale.x = 1 / scale.x;
           invScale.y = 1 / scale.y;
           invScale.z = 1 / scale.z;
          
           maxUnScaledZ = world_height * (  PageSize - 1 ) * 0.5f;
           maxUnScaledX = world_width * (  PageSize - 1 ) * 0.5f;
          
           maxScaledZ = scale.z * maxUnScaledZ;
           maxScaledX = scale.x * maxUnScaledX;
          
          
           // Set up the names For a Map
          
           setString (  groupName,   "GroupName" );
          
           if (  !setString (  LandScape_filename,   "HeightMapFileName" ) )
           setString (  LandScape_filename,   "LandScapeFileName" );
          
           if (  !setString (  TerrainName,   "TerrainName" ) )
           TerrainName = LandScape_filename;
          
           //add Resources Group to Ogre if needed.
           StringVector mResourceFilesystem = mConfig->getMultiSetting(  "FileSystem" );
           std::vector<Ogre::String>::iterator itFileSystem = mResourceFilesystem.begin(   );
           for(  ; itFileSystem != mResourceFilesystem.end(   ); ++itFileSystem )
           {
           String resourceFileSystem = *itFileSystem;
           String BasePath,   FilePath;
           StringUtil::splitFilename(  resourceFileSystem,   BasePath,   FilePath );
           if (  StringUtil::endsWith (  BasePath,   "terrainname",   true ) )
           {
           BasePath = TerrainName;
           }
           else if (  StringUtil::endsWith (  BasePath,   "landscapefilename",   true ) )
           {
           BasePath = LandScape_filename;
           }
           else if (  StringUtil::endsWith (  BasePath,   "landscapeexportfilename",   true ) )
           {
           BasePath = LandScape_export_filename;
           }
          
           if (  !cfgGroupName.empty(   ) && FilePath.empty (   ) && !mapName.empty(   ) )
           {
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo(  
           cfgGroupName,  
           mapName );
           FilePath = (  finfo->begin(   ) != finfo->end(   ) )? (  finfo->begin(   ) )->archive->getName(   ) : ".";
           }
           if (  !FilePath.empty (   ) )
           {
          
           FilePath = FilePath + "/";
           }
          
           ResourceGroupManager::getSingleton(   ).addResourceLocation(  
           FilePath + BasePath,   "FileSystem",   groupName );
           }
          
          
           StringVector mResourceZip = mConfig->getMultiSetting(  "Zip" );
           std::vector<Ogre::String>::iterator itZip = mResourceZip.begin(   );
           for(  ; itZip != mResourceZip.end(   ); ++itZip )
           {
           String resourceZip = *itZip;
          
           if (  resourceZip != StringUtil::BLANK )
           {
           ResourceGroupManager::getSingleton(   ).addResourceLocation(  
           resourceZip,   "Zip",   groupName );
           }
           }
          
           if (  !setString (  LandScape_filename,   "HeightMapFileName" ) )
           setString (  LandScape_filename,   "LandScapeFileName" );
          
           if (  !setString (  LandScape_export_filename,   "LandScapeExportFileName" ) )
           LandScape_export_filename = LandScape_filename;
          
           if (  !setString (  LandScape_extension,   "HeightMapExtension" ) )
           setString (  LandScape_extension,   "LandScapeExtension" );
          
           if (  !setString (  LandScape_export_extension,   "HeightMapExportExtension" ) )
           setString (  LandScape_export_extension,   "LandScapeExportExtension" );
          
          
           if (  !setString (  TextureExtension,   "ImageExtension" ) )
           if (  !setString (  TextureExtension,   "ColorMapExtension" ) )
           setString (  TextureExtension,   "TextureExtension" );
          
           if (  !setString (  TextureExportExtension,   "ImageExportExtension" ) )
           if (  !setString (  TextureExportExtension,   "ColorMapExportExtension" ) )
           setString (  TextureExportExtension,   "TextureExportExtension" );
          
           ImageNameLoad = setString (  image_filename,   "ImageFilename" );
           if (  !ImageNameLoad )
           ImageNameLoad = setString (  image_filename,   "ColorMapFileName" );
          
           // Set up the data source For a Map
          
           setString (  data2DFormat,   "Data2DFormat" );
          
           bool HeightField = StringUtil::endsWith(  data2DFormat,   "HeightField",   false );
           bool HeightFieldN = StringUtil::endsWith(  data2DFormat,   "HeightFieldN",   false );
           bool HeightFieldTC = StringUtil::endsWith(  data2DFormat,   "HeightFieldTC",   false );
           bool HeightFieldNTC = StringUtil::endsWith(  data2DFormat,   "HeightFieldNTC",   false );
           bool HeightFieldRawTC = StringUtil::endsWith(  data2DFormat,   "HeightFieldRawC",   false );
           bool HeightFieldRaw = StringUtil::endsWith(  data2DFormat,   "HeightFieldRaw",   false );
          
          
           if (  StringUtil::endsWith(  LandScape_extension,   "raw",   true ) )
           {
           isRaw = true;
           setUint (  RawHeight,   "RawHeight" );
           setUint (  RawWidth,   "RawWidth" );
          
           if (  HeightField || HeightFieldN )
           {
           data2DFormat = "HeightFieldRaw";
           HeightField = false;
           HeightFieldN = false;
           HeightFieldRaw = true;
           }
           else if (  HeightFieldTC || HeightFieldNTC )
           {
           data2DFormat = "HeightFieldRawTC";
           HeightFieldTC = false;
           HeightFieldNTC = false;
           HeightFieldRawTC = true;
           }
           }
           else
           isRaw = false;
          
           if (  HeightFieldRawTC
           || HeightFieldTC
           || HeightFieldNTC )
           {
           setUint (  maxValue,   "MaxValue" );
           maxValue *= static_cast<unsigned int>(  scale.y );
           setUint (  minValue,   "MinValue" );
           minValue *= static_cast<unsigned int>(  scale.y );
           }
           else
           {
           maxValue = static_cast<unsigned int> (  scale.y );
           minValue = 0;
           }
          
           setBool (  materialPerPage,   "MaterialPerPage" );
           setBool (  textureModifiable,   "TextureModifiable" );
           setBool(  mUseLodMapCache,   "UseLodMapCache" );
          
           setBool(  roughnessLod,   "RoughnessLod" );
          
          
          
           // Set up the splatting options For a Map
          
           setUint (  NumMatHeightSplat,   "NumMatHeightSplat" );
           matHeight.reserve (  NumMatHeightSplat );
           matHeight.resize (  NumMatHeightSplat );
           matColor.reserve (  NumMatHeightSplat );
           matColor.resize (  NumMatHeightSplat );
           SplatDetailMapNames.reserve (  NumMatHeightSplat );
           SplatDetailMapNames.resize (  NumMatHeightSplat );
          
           // Init to 0.0f for lazy config files omitting some.
           for (  i = 0; i < NumMatHeightSplat; i++ )
           {
           matHeight[i] = 0.0f;
           }
           const Ogre::Real divider = (  maxValue - minValue ) / (  100.0f );
           for (  i = 0; i < NumMatHeightSplat; i++ )
           {
           setReal (  matHeight[i],  
           "MaterialHeight" + StringConverter::toString(  i ) );
           matHeight[i] *= divider;
           }
          
           const String baseSplatName (  "SplatFilename" );
           for (  i = 0; i < NumMatHeightSplat; i++ )
           setString (  SplatDetailMapNames[i],  
           baseSplatName + StringConverter::toString (  i ) );
           getAvgColors (   );
          
           Ogre::Real MaterialDistanceLod = 0.0f;
           setReal (  MaterialDistanceLod,  "MaterialDistanceLod" );
           if (  MaterialDistanceLod != 0.0f )
           {
           lodMaterialDistanceList.clear(   );
           lodMaterialDistanceList.push_back (  MaterialDistanceLod );
           }
          
          #ifndef _MAPSPLITTER
          
           // PLUGIN OPTIONS ONLY
          
           // Set up the vertexes options For a Map
          
           setBool (  colored,   "VertexColors" );
           setBool (  coverage_vertex_color,   "CoverageVertexColor" );
           setBool (  base_vertex_color,   "BaseVertexColor" );
           setBool (  vertex_shadowed,   "BaseVertexShadow" );
           setBool (  vertex_instant_colored,   "BaseVertexInstantColor" );
          
           // ensure combination are correct
           if (  vertex_shadowed )
           vertex_instant_colored = true;
          
           if (  coverage_vertex_color || base_vertex_color
            )// || vertex_shadowed || vertex_instant_colored )
           colored = true;
          
           // Set up the paging options For a Map
          
           setUint (  num_renderables,   "MaxNumRenderables" );
           num_renderables = (  totalNumTiles < num_renderables )?totalNumTiles:num_renderables;
           setUint (  num_renderables_increment,   "IncrementRenderables" );
          
           setUint (  num_tiles,   "MaxNumTiles" );
           num_tiles = (  totalNumTiles < num_tiles )? totalNumTiles : num_tiles;
           setUint (  num_tiles_increment,   "IncrementTiles" );
          
          
           setUint (  num_renderables_loading,   "NumRenderablesLoading" );
           setUint (  RenderableLoadInterval,   "RenderableLoadInterval" );
          
           setUint (  max_adjacent_pages,   "MaxAdjacentPages" );
           setUint (  max_preload_pages,   "MaxPreloadedPages" );
           setUint (  PageLoadInterval,   "PageLoadInterval" );
          
           // Set up the LOD options For a Map
           setUint (  maxRenderLevel,   "MaxRenderLevel" );
           if (  maxRenderLevel == 100 )
           {
           maxRenderLevel = 0;
           const unsigned int halftileSize = static_cast<unsigned int>(  TileSize * 0.5f );
           while (  static_cast<unsigned int> (  (  1 << maxRenderLevel ) ) < halftileSize  )
           maxRenderLevel++;
           }
          
          
           setReal (  change_factor,   "ChangeFactor" );
           change_factor *= (  static_cast <Real> (  PageSize * (  scale.z + scale.x ) * 0.5f ) / 9 );
          
           // Set up the distance options For a Map
          
           setReal (  visible_renderables,   "VisibleRenderables" );
          
           // compute the actual distance as a square
           // Factor is a Tile distance squared
           const Ogre::Real Factor = TileSize * scale.x * TileSize * scale.z;
          
          
           // max distance upon which renderables are not rendered anymore
           renderable_factor = visible_renderables * Factor;
           //renderable_factor *= renderable_factor;
          
           //setReal (  cameraThreshold,   "CameraThreshold" );
           // To avoid the use of a square root.
           //cameraThreshold *= cameraThreshold;
           cameraThreshold = (  (  scale.x < scale.z  ) ? TileSize * scale.x : TileSize * scale.z ) * 0.25;
          
           setReal (  distanceLOD,   "DistanceLOD" );
           // Compute the actual distance as a square
           LOD_factor = distanceLOD * Factor;
           loadMapInfo(   );
          
           setBool (  lit,   "VertexLit" );
           setBool (  normals,   "VertexNormals" );
          
           setBool (  Deformable,   "Deformable" );
           if (  !Deformable )
           saveDeformation = false;
           else
           setBool (  saveDeformation,   "SaveDeformation" );
          
           //Morphing
           if (  maxRenderLevel > 1 )
           {
           setBool (  lodMorph,   "VertexProgramMorph" );
           setReal (  lodMorphStart,   "LODMorphStart" );
           }
           setUint (  maxPixelError,   "MaxPixelError" );
          
          
           setBool (  BigImage,   "BigImage" );
           setBool (  VisMap,   "HorizonVisibilityComputing" );
           setBool (  MaxLodUnderCam,   "MaxLodUnderCam" );
           setBool (  VertexCompression,   "VertexCompression" );
           VertexCompression = VertexCompression && hasVertexShader;
          
          
           setUint (  NumTextureFormatSupported,   "NumTextureFormatSupported" );
           TextureFormatSupported.reserve (  NumTextureFormatSupported );
           TextureFormatSupported.resize (  NumTextureFormatSupported );
           for (  i = 0; i < NumTextureFormatSupported; i++ )
           {
           setString (  TextureFormatSupported[i],   "TextureFormatSupported" + StringConverter::toString(  i ) );
           }
           String tempTexformat;
           setString (  tempTexformat,   "TextureFormat" );
           // must be after getting supported formats
           setTextureFormat (  tempTexformat );
          
           setUint (  TileInvisibleUnloadFrames,   "TileInvisibleUnloadFrames" );
           setUint (  PageInvisibleUnloadFrames,   "PageInvisibleUnloadFrames" );
          
          
           setReal (  BaseCameraViewpoint.x,   "BaseCameraViewpoint.x" );
           setReal (  BaseCameraViewpoint.y,   "BaseCameraViewpoint.y" );
           setReal (  BaseCameraViewpoint.z,   "BaseCameraViewpoint.z" );
          
           setReal (  Baselookat.x,   "Baselookat.x" );
           setReal (  Baselookat.y,   "Baselookat.y" );
           setReal (  Baselookat.z,   "Baselookat.z" );
          
          
           ResourceGroupManager::getSingleton(   ).initialiseResourceGroup (  groupName );
          #else
          
           // MAP TOOL OPTIONS ONLY
          
           setBool (  Paged,   "Paged" );
          
           setString (  OutDirectory,   "OutDirectory" );
          
           String BasePath,   FilePath;
           StringUtil::splitFilename(  OutDirectory,   BasePath,   FilePath );
           if (  StringUtil::endsWith (  BasePath,   "landscapefilename",   true ) )
           {
           BasePath = LandScape_filename;
           }
           if (  StringUtil::endsWith (  BasePath,   "landscapeexportfilename",   true ) )
           {
           BasePath = LandScape_export_filename;
           }
           if (  FilePath.empty(   ) )
           {
           //Get cfg current Directory
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           cfgGroupName,   mapName );
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           FilePath = (  it )->archive->getName(   );
           }
           }
           if (  StringUtil::endsWith (  FilePath,   "/",   true ) )
           {
           FilePath.resize (  FilePath.size(   ) - 1 );
           }
           OutDirectory = FilePath + "/" + BasePath;
          
           setBool (  MiniMap,   "MiniMap" );
           setBool (  BaseMap,   "BaseMap" );
          
          
           setBool (  ColorMapGenerate,   "ColorMapGenerate" );
          
           if (  !setBool (  ColorMapSplit,   "ImageSplit" ) )
           setBool (  ColorMapSplit,   "ColorMapSplit" );
          
           setBool (  LightMap,   "LightMap" );
           setBool (  NormalMap,   "NormalMap" );
           setBool (  HeightMap,   "HeightMap" );
           setBool (  AlphaMaps,   "AlphaMaps" );
           setBool (  LitBaseMap,   "LitBaseMap" );
           setBool (  InfiniteMap,   "InfiniteMap" );
           setBool (  CoverageMap,   "CoverageMap" );
           setBool (  LitColorMapGenerate,   "LitColorMapGenerate" );
          
           if (  !setBool (  LitColorMapSplit,   "LitImageSplit" ) )
           setBool (  LitColorMapSplit,   "LitColorMapSplit" );
          
           setBool (  HeightNormalMap,   "HeightNormalMap" );
          
           if (  !setString (  ColorMapName,   "ImageFileName" ) )
           if (  !setString (  ColorMapName,   "ColorMapFileName" ) )
           setString (  ColorMapName,   "ColorMapName" );
          
           if (  (  BaseMap || CoverageMap || AlphaMaps )
           && NumMatHeightSplat == 0 )
           OGRE_EXCEPT (  Exception::ERR_INVALIDPARAMS,  
           "Generating a texture set from a heightmap needs some MaterialHeights in cfg file.",  
           "PagingLandScapeData2D_HeightField::getScale" );
          
           setReal (  HeightMapBlurFactor,   "HeightMapBlurFactor" );
          
           setReal (  Sun.x,   "Sunx" );
           setReal (  Sun.y,   "Suny" );
           setReal (  Sun.z,   "Sunz" );
          
          
           setReal (  Amb,   "Ambient" );
           setReal (  Diff,   "Diffuse" );
           setUint (  Blur,   "Blur" );
          
           setBool (  Equalize,   "Equalize" );
           setBool (  ZHorizon,   "ZHorizon" );
          
           setBool (  SRTM_water,   "SRTM_water" );
          
           setUint (  MiniMapHeight,   "MiniMapHeight" );
           setUint(  MiniMapWidth,   "MiniMapWidth" );
          
          
           setUint (  NumSplatMapToSplit,   "NumSplatMapToSplit" );
           SplatMapNames.reserve (  NumSplatMapToSplit );
           SplatMapNames.resize (  NumSplatMapToSplit );
          
           for (  i = 0; i < NumSplatMapToSplit; i++ )
           {
           setString (  SplatMapNames[i],   "SplatMapName" + StringConverter::toString(  i ) );
           }
           #endif
           }
           //-----------------------------------------------------------------------
    1092   void PagingLandScapeOptions::calculateCFactor(   )
           {
           // ConstOgre::Real A = 1 / Math::Tan(  Math::AngleUnitsToRadians(  opts.primaryCamera->getFOVy(   ) ) );
           // Turn off detail compression at higher FOVs
           const Ogre::Real A = 1.0f;
          
           assert (  primaryCamera );
           const Viewport *v = primaryCamera->getViewport(   );
           if (  v )
           {
           const int vertRes = v->getActualHeight(   );
          
           assert (  vertRes != 0 );
          
           const Ogre::Real T = 2 * static_cast <Ogre::Real > (  maxPixelError ) / vertRes;
          
           if (  T != 0 )
           CFactor = A / T;
           else
           CFactor = A * vertRes * 0.5f;
           }
           }
           //-----------------------------------------------------------------------
    1115   void PagingLandScapeOptions::setPrimaryCamera(  PagingLandScapeCamera *cam )
           {
           primaryCamera = cam;
           if (  cam && cam->getViewport(   ) )
           calculateCFactor (   );
           }
           //-----------------------------------------------------------------------
    1122   bool PagingLandScapeOptions::setOption(  const String& strKey,   const void* pValue )
           {
           if (  strKey == "saveDeformation" )
           {
           saveDeformation = * static_cast < const bool * > (  pValue );
           return true;
           }
           if (  strKey == "MaxLodUnderCam" )
           {
           MaxLodUnderCam = * static_cast < const bool * > (  pValue );
           return true;
           }
          // if (  strKey == "VisibleRenderables" )
          // {
          // visible_renderables = * static_cast < const int * > (  pValue );
          // // compute the actual distance as a square
          // Ogre::Real Factor = TileSize;
          // Factor = Factor * scale.x * Factor * scale.z;
          //
          // renderable_factor = visible_renderables * Factor;
          // return true;
          // }
           if (  strKey == "DistanceLOD" )
           {
           distanceLOD = * static_cast < const Ogre::Real * > (  pValue );
           // Compute the actual distance as a square
           Ogre::Real Factor = TileSize;
           Factor = Factor * scale.x * Factor * scale.z;
           LOD_factor = distanceLOD * Factor;
           return true;
           }
           if (  strKey == "Sun" )
           {
           Sun = * static_cast < const Ogre::Vector3 * > (  pValue );
           lightmoved = true;
           return true;
           }
           if (  strKey == "SunAngle" )
           {
           SunAngle = * static_cast < const Ogre::Real * > (  pValue );
           lightmoved = true;
           return true;
           }
           if (  strKey == "Width" )
           {
           world_width = * static_cast < const unsigned int * > (  pValue ) ;
          #ifndef _MAPSPLITTER
          #ifndef _MAPEDITOR
           assert (  primaryCamera );
           static_cast <PagingLandScapeSceneManager *> (  primaryCamera->getSceneManager(   ) )->WorldDimensionChange(   );
          
          #endif //_MAPEDITOR
          #endif //_MAPSPLITTER
           return true;
           }
           if (  strKey == "Height" )
           {
           world_height = * static_cast < const unsigned int * > (  pValue );
          #ifndef _MAPSPLITTER
          #ifndef _MAPEDITOR
           assert (  primaryCamera );
           static_cast <PagingLandScapeSceneManager *> (  primaryCamera->getSceneManager(   ) )->WorldDimensionChange(   );
          #endif //_MAPEDITOR
          #endif //_MAPSPLITTER
           return true;
           }
           if (  strKey == "WorldDimension" )
           {
           Vector2 dim = * static_cast < const Vector2 * > (  pValue );
           world_height = static_cast < unsigned int > (  dim.x );
           world_width = static_cast < unsigned int > (  dim.y );
           #ifndef _MAPSPLITTER
           #ifndef _MAPEDITOR
           assert (  primaryCamera );
           static_cast <PagingLandScapeSceneManager *> (  primaryCamera->getSceneManager(   ) )->WorldDimensionChange(   );
           #endif //_MAPEDITOR
           #endif //_MAPSPLITTER
           return true;
           }
           if (  strKey == "primaryCamera" )
           {
           setPrimaryCamera (  const_cast < PagingLandScapeCamera * > (  static_cast < const PagingLandScapeCamera * > (  pValue ) ) );
           return true;
           }
          
           if (  strKey == "TextureNameLayer0" )
           {
           SplatDetailMapNames[0] = * static_cast < const String * > (  pValue );
           return true;
           }
           if (  strKey == "TextureNameLayer1" )
           {
           SplatDetailMapNames[1] = * static_cast < const String * > (  pValue );
           return true;
           }
           if (  strKey == "TextureNameLayer2" )
           {
           SplatDetailMapNames[2] = * static_cast < const String * > (  pValue );
           return true;
           }
           if (  strKey == "TextureNameLayer3" )
           {
           SplatDetailMapNames[3] = * static_cast < const String * > (  pValue );
           return true;
           }
          
          
           if (  strKey == "MaxAdjacentPages" )
           {
           max_adjacent_pages = * static_cast < const unsigned int * > (  pValue );
           return true;
           }
           if (  strKey == "MaxPreloadedPages" )
           {
           max_preload_pages = * static_cast < const unsigned int * > (  pValue );
           return true;
           }
           if (  strKey == "PositionX" )
           {
           position.x = * static_cast < const Ogre::Real * > (  pValue );
           return true;
           }
           if (  strKey == "PositionY" )
           {
           position.y = * static_cast < const Ogre::Real * > (  pValue );
           return true;
           }
           if (  strKey == "PositionZ" )
           {
           position.z = * static_cast < const Ogre::Real * > (  pValue );
           return true;
           }
          
           if (  strKey == "ConfigGroupName" )
           {
           cfgGroupName = * static_cast < const String * > (  pValue );
           return true;
           }
           if (  strKey == "queryNoInterpolation" )
           {
           queryNoInterpolation = * static_cast < const bool * > (  pValue );
           return true;
           }
           if (  strKey == "queryResolutionFactor" )
           {
           queryResolutionFactor = * static_cast < const Ogre::Real * > (  pValue );
           return true;
           }
           return false;
           }
          
           //-----------------------------------------------------------------------
    1274   bool PagingLandScapeOptions::getOption(  const String& strKey,   void* pDestValue )
           {
           if (  strKey == "saveDeformation" )
           {
           * static_cast < bool * > (  pDestValue ) = saveDeformation;
           return true;
           }
           if (  strKey == "VisibleRenderables" )
           {
           * static_cast < int * > (  pDestValue ) = static_cast<int> (  visible_renderables );
           return true;
           }
           if (  strKey == "DistanceLOD" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = static_cast<Real> (  distanceLOD );
           return true;
           }
           if (  strKey == "VisibleDistance" )
           {
           // we need to return the square root of the distance
           * static_cast <Ogre::Real * > (  pDestValue ) = Math::Sqrt (  renderable_factor );
           return true;
           }
           if (  strKey == "VisibleLOD" )
           {
           // we need to return the square root of the distance
           * static_cast <Ogre::Real * > (  pDestValue ) = Math::Sqrt (  LOD_factor );
           return true;
           }
           // Some options proposed by Praetor
           if (  strKey == "Width" )
           {
           * static_cast < int * > (  pDestValue ) = world_width;
           return true;
           }
           if (  strKey == "Height" )
           {
           * static_cast < int * > (  pDestValue ) = world_height;
           return true;
           }
           if (  strKey == "MaxHeight" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = scale.y;
           return true;
           }
           if (  strKey == "PageSize" )
           {
           * static_cast < int * > (  pDestValue ) = PageSize;
           return true;
           }
           if (  strKey == "Scale" )
           {
           * static_cast < Ogre::Vector3 * > (  pDestValue ) = scale;
           return true;
           }
           if (  strKey == "ScaleX" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = scale.x;
           return true;
           }
           if (  strKey == "ScaleY" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = scale.y;
           return true;
           }
           if (  strKey == "ScaleZ" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = scale.z;
           return true;
           }
           if (  strKey == "PositionX" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = position.x;
           return true;
           }
           if (  strKey == "PositionY" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = position.y;
           return true;
           }
           if (  strKey == "PositionZ" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = position.z;
           return true;
           }
          
           if (  strKey == "TextureNameLayer0" )
           {
           * static_cast < String * > (  pDestValue ) = SplatDetailMapNames[0];
           return true;
           }
           if (  strKey == "TextureNameLayer1" )
           {
           * static_cast < String * > (  pDestValue ) = SplatDetailMapNames[1];
           return true;
           }
           if (  strKey == "TextureNameLayer2" )
           {
           * static_cast < String * > (  pDestValue ) = SplatDetailMapNames[2];
           return true;
           }
           if (  strKey == "TextureNameLayer3" )
           {
           * static_cast < String * > (  pDestValue ) = SplatDetailMapNames[3];
           return true;
           }
          
           if (  strKey == "GroupName" )
           {
           * static_cast < String * > (  pDestValue ) = groupName;
           return true;
           }
          
           if (  strKey == "BaseCameraViewpoint" )
           {
           * static_cast < Ogre::Vector3 * > (  pDestValue ) = BaseCameraViewpoint;
           return true;
           }
          
           if (  strKey == "Baselookat" )
           {
           * static_cast < Ogre::Vector3 * > (  pDestValue ) = Baselookat;
           return true;
           }
          
           if (  strKey == "MaxAdjacentPages" )
           {
           * static_cast < unsigned int * > (  pDestValue ) = max_adjacent_pages;
           return true;
           }
           if (  strKey == "MaxPreloadedPages" )
           {
           * static_cast < unsigned int * > (  pDestValue ) = max_preload_pages;
           return true;
           }
           if (  strKey == "ConfigGroupName" )
           {
           * static_cast < String * > (  pDestValue ) = cfgGroupName;
           return true;
           }
           if (  strKey == "queryNoInterpolation" )
           {
           * static_cast < bool * > (  pDestValue ) = queryNoInterpolation;
           return true;
           }
           if (  strKey == "queryResolutionFactor" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = queryResolutionFactor;
           return true;
           }
           return false;
           }
          
           //-----------------------------------------------------------------------
    1428   bool PagingLandScapeOptions::hasOption(  const String& strKey ) const
           {
           if (  strKey == "VisibleRenderables" )
           {
           return true;
           }
           if (  strKey == "DistanceLOD" )
           {
           return true;
           }
           if (  strKey == "VisibleDistance" )
           {
           return true;
           }
           if (  strKey == "VisibleLOD" )
           {
           return true;
           }
           // Some options proposed by Praetor
           if (  strKey == "Width" )
           {
           return true;
           }
           if (  strKey == "Height" )
           {
           return true;
           }
           if (  strKey == "PageSize" )
           {
           return true;
           }
           if (  strKey == "ScaleX" )
           {
           return true;
           }
           if (  strKey == "ScaleY" )
           {
           return true;
           }
           if (  strKey == "ScaleZ" )
           {
           return true;
           }
           if (  strKey == "PositionX" )
           {
           return true;
           }
           if (  strKey == "PositionY" )
           {
           return true;
           }
           if (  strKey == "PositionZ" )
           {
           return true;
           }
           return false;
           }
          
           //-----------------------------------------------------------------------
    1487   bool PagingLandScapeOptions::getOptionValues(  const String & key,   StringVector &refValueList )
           {
           // if (  key == "VisibleRenderables" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           // if (  key == "DistanceLOD" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           // if (  key == "VisibleDistance" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           // if (  key == "VisibleLOD" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           // if (  key == "Width" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           // if (  key == "Height" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           // if (  key == "PageSize" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           // if (  key == "ScaleX" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           // if (  key == "ScaleY" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           // if (  key == "ScaleZ" )
           // {
           // refValueList.push_back(  DataStreamPtr(   ) );
           // return true;
           // }
           return false;
           }
          
           //-----------------------------------------------------------------------
    1543   bool PagingLandScapeOptions::getOptionKeys(  StringVector &refKeys )
           {
           refKeys.push_back(  "VisibleRenderables" );
           refKeys.push_back(  "DistanceLOD" );
           refKeys.push_back(  "VisibleDistance" );
           refKeys.push_back(  "VisibleLOD" );
           // Some options from Praetor
           refKeys.push_back(  "Width" );
           refKeys.push_back(  "Height" );
           refKeys.push_back(  "PageSize" );
           refKeys.push_back(  "ScaleX" );
           refKeys.push_back(  "ScaleY" );
           refKeys.push_back(  "ScaleZ" );
           refKeys.push_back(  "PositionX" );
           refKeys.push_back(  "PositionY" );
           refKeys.push_back(  "PositionZ" );
           return true;
           }
           //-----------------------------------------------------------------------
    1562   void PagingLandScapeOptions::getAvgColors(   )
           {
           bool AvgColorsExists = false;
           setBool (  AvgColorsExists,   "AvgColorsExists" );
           if (  AvgColorsExists )
           {
           const String baseName (  "MaterialColor" );
           for (  unsigned int i = 0; i < NumMatHeightSplat; i++ )
           {
           const String matColorString (  baseName + StringConverter::toString (  i ) );
           setColourValue (  matColor[i],   matColorString );
           }
           }
           else
           {
           for (  unsigned int i = 0; i < NumMatHeightSplat; i++ )
           matColor[i] = _getAvgColor(  SplatDetailMapNames[i] );
           }
           }
           //-----------------------------------------------------------------------
    1582   ColourValue PagingLandScapeOptions::_getAvgColor(  const String &tex ) const
           {
           if (  tex.empty(   ) )
           return ColourValue::White;
          
           Image img;
          
           img.load (  tex,   groupName );
           const uchar * const ogre_restrict data = img.getData(   );
           if (  !data )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,  
           "You need to define SplatFilename that has at least 3 or 4 bytes componennts (  RGB or RGBA )",  
           "PagingLandScapeOptions::_getAvgColor" );
           }
           size_t bpp = PixelUtil::getNumElemBytes (  img.getFormat (   ) );
           if (  bpp < 3 )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,  
           "You need to define SplatFilename that has at least 3 or 4 bytes componennts (  RGB or RGBA )",  
           "PagingLandScapeOptions::_getAvgColor" );
           }
           int cr = 0,   cg = 0,   cb = 0,   s = 0;
           const size_t imgSize = img.getSize(   );
           for (  size_t i = 0; i < imgSize; i += bpp )
           {
           cr += data[i];
           cg += data[i+1];
           cb += data[i+2];
          
           s++;
           }
           assert (  s > 0 );
           Ogre::Real divider = 1.0f / (  s * 255 );
           return ColourValue (  cr * divider,   cg * divider,   cb * divider,   1.0f );
           }
           //-----------------------------------------------------------------------
    1619   void PagingLandScapeOptions::clearTileInfo(   )
           {
           if (  !mTileInfoCache.empty(   ) )
           {
           ///don't do thses things when run in Ember
           //assert (  mCurrentMap != "" );
           //saveMapInfo(   );
           std::for_each(  mTileInfoCache.begin (   ),  
           mTileInfoCache.end (   ),  
           delete_object(   ) );
           mTileInfoCache.clear(   );
           }
           }
           //-----------------------------------------------------------------------
    1633   PagingLandScapeTileInfo *PagingLandScapeOptions::getTileInfo(  const uint pageX,   const uint pageZ,  
    1634   const uint tileX,   const uint tileZ )
           {
           PagingLandScapeTileInfo *t = 0;
          
           std::deque<PagingLandScapeTileInfo*>::iterator q = mTileInfoCache.begin (   );
           std::deque<PagingLandScapeTileInfo*>::iterator qend = mTileInfoCache.end (   );
           while (  q != qend )
           {
           t = *q;
           if (  pageX == t->mPageX &&
           pageZ == t->mPageZ &&
           tileX == t->mTileX &&
           tileZ == t->mTileZ )
           {
           return t;
           }
           ++q;
           }
           // no info in cache.
           t = new PagingLandScapeTileInfo(  pageX,   pageZ,   tileX,   tileZ );
           setTileInfo (  t );
           return t;
           }
           //-----------------------------------------------------------------------
    1658   void PagingLandScapeOptions::setTileInfo(  PagingLandScapeTileInfo *t )
           {
           mTileInfoCache.push_back (  t );
           }
           //-----------------------------------------------------------------------
    1663   void PagingLandScapeOptions::loadMapInfo(   )
           {
           // load terrain.info.cfg into the deque.
           if (  mUseLodMapCache )
           {
           assert (  !mCurrentMap.empty (   ) );
           const String fName (  mCurrentMap + ".info.cfg" );
           if (  ResourceGroupManager::getSingleton(   ).resourceExists(  groupName,   fName ) )
           {
           ConfigFile config;
          
           config.load (  fName,   cfgGroupName,   String(  "=" ),   true );
          
           // those info are dependent of Pagesize and Tilesize.
           // if not the same as when generated...
           // we must recompute them.
           const String pageSizeString = config.getSetting(  String(  "PageSize" ) );
           if (  pageSizeString.empty(   ) || PageSize != StringConverter::parseUnsignedInt (  pageSizeString ) )
           return;
          
           const String tileSizeString = config.getSetting(  String(  "TileSize" ) );
           if (  tileSizeString.empty(   ) || TileSize != StringConverter::parseUnsignedInt (  tileSizeString ) )
           return;
          
           ConfigFile::SettingsIterator setIt = config.getSettingsIterator(   );
           const size_t numLod = maxRenderLevel;
           PagingLandScapeTileInfo *t;
           while (  setIt.hasMoreElements(   ) )
           {
           const String name = setIt.peekNextKey(   );
           const String value = setIt.getNext(   );
           if (  name != "PageSize" && name != "TileSize" )
           {
           // name to pageX,   uint pageZ,   uint tileX,   uint tileZ
           {
           std::vector<String> coordinates = StringUtil::split(  name,   "_" );
          
           const uint pageX = StringConverter::parseUnsignedInt(  coordinates[0] );
           const uint pageZ = StringConverter::parseUnsignedInt(  coordinates[1] );
           const uint tileX = StringConverter::parseUnsignedInt(  coordinates[2] );
           const uint tileZ = StringConverter::parseUnsignedInt(  coordinates[3] );
          
           t = new PagingLandScapeTileInfo(  pageX,   pageZ,   tileX,   tileZ );
           }
          
           // name to LOD roughness value.
           {
           std::vector<String> minLevelDistSqr = StringUtil::split(  value,   "_" );
           assert (  minLevelDistSqr.size (   ) == numLod );
          
           t->mMinLevelDistSqr = new std::vector<Real>(   );
          
           t->mMinLevelDistSqr->reserve(  numLod );
           t->mMinLevelDistSqr->resize(  numLod );
          
           for (  size_t i = 0; i < numLod; i++ )
           {
           (  *(  t->mMinLevelDistSqr ) )[i] = StringConverter::parseReal(  minLevelDistSqr[i] );
           }
           }
           mTileInfoCache.push_back(  t );
           }
          
           }
           }
           }
           }
           //-----------------------------------------------------------------------
    1731   void PagingLandScapeOptions::saveMapInfo(   )
           {
           if (  mUseLodMapCache )
           {
           //if(  modif ||was_empty when loaded. ) ??
          
           assert (  !mCurrentMap.empty (   ) );
           const String fInfoName (  getMapFilename(  mCurrentMap ) + ".cfg" );
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           groupName,   fInfoName );
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           // save deque into terrain.info.cfg
           const size_t numLod = maxRenderLevel;
           const String eol(  "\n" );
           const String coordinateSeparator(  "_" );
           const String valueSeparator(  "=" );
           PagingLandScapeTileInfo *t;
          
           String tilesInfo(  "" );
          
           // those info are dependent of Pagesize and Tilesize.
           // if not the same as when generated...
           // we must recompute them.
           tilesInfo += String(  "PageSize=" )+StringConverter::toString(  PageSize ) + eol;
           tilesInfo += String(  "TileSize=" )+StringConverter::toString(  TileSize ) + eol;
          
           std::deque<PagingLandScapeTileInfo*>::iterator q = mTileInfoCache.begin (   );
           std::deque<PagingLandScapeTileInfo*>::iterator qend = mTileInfoCache.end (   );
           while (  q != qend )
           {
           t = *q;
          
           if (  t->mMinLevelDistSqr )
           {
           bool notEmpty = false;
           for (  size_t i = 0; i < numLod; i++ )
           {
           if (  (  *(  t->mMinLevelDistSqr ) )[i] != 0.0f )
           {
           notEmpty = true;
           break;
           }
           }
           if (  notEmpty )
           {
           tilesInfo += StringConverter::toString(  t->mPageX ) + coordinateSeparator;
           tilesInfo += StringConverter::toString(  t->mPageZ ) + coordinateSeparator;
           tilesInfo += StringConverter::toString(  t->mTileX ) + coordinateSeparator;
           tilesInfo += StringConverter::toString(  t->mTileZ );
          
           tilesInfo += valueSeparator;
          
           for (  size_t i = 0; i < numLod; i++ )
           {
           tilesInfo += StringConverter::toString(  (  *(  t->mMinLevelDistSqr ) )[i] ) + coordinateSeparator;
           }
           tilesInfo += eol;
           }
           }
           ++q;
           }
          
          
           const String fConfigName (  mCurrentMap + ".info.cfg" );
          
           char *olddir = ChangeToDir (  const_cast< char * > (  (  (  it )->archive->getName(   ) ).c_str(   ) ) );
           std::ofstream outfile;
           outfile.open (  const_cast< char * > (  fConfigName.c_str(   ) )
           //,  std::ios:binary
            );
           // Write out
           outfile << tilesInfo;
           outfile.close (   );
          
           RetablishDir (  olddir );
           }
           }
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapePage.cpp

       1  /***************************************************************************
           OgrePagingLandScapePage.cpp - description
           -------------------
           begin : Sat Mar 08 2003
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreMovableObject.h"
          #include "OgreAxisAlignedBox.h"
          
          #include "OgreCamera.h"
          
          #include "OgreStringConverter.h"
          #include "OgreSceneNode.h"
          #include "OgreException.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          #include "OgrePagingLandScapePageManager.h"
          #include "OgrePagingLandScapeRenderableManager.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeTileInfo.h"
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapeTileManager.h"
          #include "OgrePagingLandScapeTextureManager.h"
          
          #include "OgrePagingLandScapePage.h"
          #include "OgrePagingLandScapePageRenderable.h"
          #include "OgrePagingLandScapeListenerManager.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          
          #include "OgrePagingLandScapeHorizon.h"
          
          namespace Ogre
          {
      53   PagingLandScapePage::PagingLandScapePage(  PagingLandScapePageManager *pageMgr ) :
           mParent (  pageMgr ),  
           mIsLoading (  false ),  
           mIsPreLoading (  false ),  
           mIsTextureLoading (  false ),  
           mIsUnloading (  false ),  
           mIsPostUnloading (  false ),  
           mIsTextureunloading (  false ),  
           mIsLoaded (  false ),  
           mIsTextureLoaded (  false ),  
           mIsPreLoaded (  false ),  
           mIsLoadable(  true ),  
           mPageNode (  0 ),  
           mRenderable(  0 )
           {
           for (  unsigned int i = 0; i < 4; i++ )
           {
           mNeighbors[i] = 0;
           }
           }
           //-----------------------------------------------------------------------
      74   PagingLandScapePage::~PagingLandScapePage(   )
           {
           }
           //-----------------------------------------------------------------------
      78   void PagingLandScapePage::init (  const unsigned int tableX,   const unsigned int tableZ )
           {
           assert (  !mIsLoading );
           assert (  !mIsPreLoading );
           assert (  !mIsTextureLoading );
           assert (  !mIsUnloading );
          
           assert (  !mIsPostUnloading );
           assert (  !mIsTextureunloading );
           assert (  !mIsLoaded );
           assert (  !mIsTextureLoaded );
           assert (  !mIsPreLoaded );
           assert (  mIsLoadable );
          
          
          
           mTableX = tableX;
           mTableZ = tableZ;
           //create a LandScape node that handles pages and tiles
           const String NodeName = "PagingLandScapePage."
           + StringConverter::toString(  mTableX ) + "." +
           StringConverter::toString(  mTableZ );
          
           mPageNode = mParent->getSceneManager(   )->createSceneNode (  NodeName + ".Node" );
          
          
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
           mNumTiles = opt->NumTiles;
          
           const unsigned int size = opt->PageSize - 1;
           // Boundaries of this page
           // the middle page is at world coordinates 0,  0
           const Real factorX = size * opt->scale.x;
           const Real factorZ = size * opt->scale.z;
          
           mIniX = static_cast<Real> (  static_cast<int> (  mTableX + mTableX - opt->world_width ) ) * 0.5f * factorX + opt->position.x;
           mIniZ = static_cast<Real> (  static_cast<int> (  mTableZ + mTableZ - opt->world_height ) ) * 0.5f * factorZ + opt->position.z;
          
           // Set node position
           mPageNode->setPosition(  static_cast<Real> (  mIniX ) ,  
           opt->position.y,  
           static_cast<Real> (  mIniZ ) );
          
           const Real EndX = mIniX + factorX;
           const Real EndZ = mIniZ + factorZ;
           const Real MaxHeight = mParent->getSceneManager(   )->getData2DManager(   )->getMaxHeight(  mTableX,   mTableZ );
           const Real chgfactor = opt->change_factor;
          
           mBounds.setExtents(  mIniX ,  
           0.0f,  
           mIniZ ,  
           EndX ,  
           MaxHeight,  
           EndZ );
          
           //Change Zone of this page
           mBoundsInt.setExtents(  mIniX + chgfactor,  
           0.0f,  
           mIniZ + chgfactor,  
           EndX - chgfactor,  
           MaxHeight,  
           EndZ - chgfactor  );
          
          
           mBoundsExt.setExtents(  mIniX - factorX * 1.5f,  
           - MaxHeight * 1.5f,  
           mIniZ - factorZ * 1.5f,  
          
           mIniX + factorX * 1.5f,  
           MaxHeight * 1.5f ,  
           mIniZ + factorZ * 1.5f );
          
           mWorldPosition = mBounds.getCenter(   );
          
          
          
           if (  opt->BigImage )
           {
           mRenderable = new PagingLandScapePageRenderable(  mParent,  
           mPageNode->getName (   ) + "rend",  
           mTableX,   mTableZ,  
           mBounds );
           mPageNode->attachObject(  mRenderable );
           mRenderable->load (   );
           }
          
           PagingLandScapePageManager * const pageMgr = mParent;
           PagingLandScapePage *n;
           n = pageMgr->getPage (  tableX,   tableZ + 1,   false );
           _setNeighbor(  SOUTH,   n );
           if (  n )
           n->_setNeighbor(  NORTH,   this );
          
           n = pageMgr->getPage (  tableX,   tableZ - 1,   false );
           _setNeighbor(  NORTH,   n );
           if (  n )
           n->_setNeighbor(  SOUTH,   this );
          
           n = pageMgr->getPage (  tableX + 1,   tableZ,   false );
           _setNeighbor(  EAST,   n );
           if (  n )
           n->_setNeighbor(  WEST,   this );
          
           n = pageMgr->getPage (  tableX - 1,   tableZ,   false );
           _setNeighbor(  WEST,   n );
           if (  n )
           n->_setNeighbor(  EAST,   this );
          
           mVisible = false;
          
           touch (   );
           }
           //-----------------------------------------------------------------------
     191   void PagingLandScapePage::uninit (   )
           {
           postUnload (   );
           assert (  mTiles.empty(   ) );
          
           if (  mParent->getOptions(   )->BigImage )
           {
           mPageNode->detachObject (  mRenderable->getName(   ) );
           delete mRenderable;
           }
          
           assert (  mPageNode );
           mPageNode->removeAndDestroyAllChildren (   );
           mParent->getSceneManager(   )->destroySceneNode (  mPageNode->getName (   ) );
           mPageNode = 0;
          
          
           PagingLandScapePage *n = mNeighbors[NORTH];
           if (  n )
           {
           n->_setNeighbor(  SOUTH,   0 );
           mNeighbors[NORTH] = 0;
           }
           n = mNeighbors[SOUTH];
           if (  n )
           {
           n->_setNeighbor(  NORTH,   0 );
           mNeighbors[SOUTH] = 0;
           }
           n = mNeighbors[EAST];
           if (  n )
           {
           n->_setNeighbor(  WEST,   0 );
           mNeighbors[EAST] = 0;
           }
           n = mNeighbors[WEST];
           if (  n )
           {
           n->_setNeighbor(  EAST,   0 );
           mNeighbors[WEST] = 0;
           }
           // restore init state.
           mIsLoading = false;
           mIsPreLoading = false;
           mIsTextureLoading = false;
          
           mIsUnloading = false;
           mIsPostUnloading = false;
           mIsTextureunloading = false;
          
           mIsLoaded = false;
           mIsTextureLoaded = false;
           mIsPreLoaded = false;
          
           mIsLoadable = true;
           }
           //-----------------------------------------------------------------------
     248   void PagingLandScapePage::_setNeighbor(  const Neighbor& n,   PagingLandScapePage* p )
           {
           mNeighbors[ n ] = p;
          
           const bool thisLoaded = mIsLoaded;
           const bool neighLoaded = p && p->isLoaded(   ) && p->isLoadable(   );
          
           if (  !thisLoaded && !neighLoaded )
           return;
          
           assert (  !thisLoaded || (  thisLoaded && !mTiles.empty(   ) ) );
           const unsigned int numTiles = mNumTiles;
           switch (  n )
           {
           case EAST:
           {
           const unsigned int i = numTiles - 1;
           for (  unsigned int j = 0; j < numTiles; j++ )
           {
           PagingLandScapeTile *t_nextpage = 0;
           PagingLandScapeTile *t_currpage = 0;
           if (  thisLoaded )
           t_currpage = mTiles[ i ][ j ];
           if (  neighLoaded )
           t_nextpage = p->getTile (  0 ,   j );
           if (  thisLoaded )
           t_currpage->_setNeighbor(  EAST,   t_nextpage );
           if (  neighLoaded )
           t_nextpage->_setNeighbor(  WEST,   t_currpage );
           }
          
           }
           break;
           case WEST:
           {
           const unsigned int i = numTiles - 1;
           for (  unsigned int j = 0; j < numTiles; j++ )
           {
           PagingLandScapeTile *t_nextpage = 0;
           PagingLandScapeTile *t_currpage = 0;
           if (  thisLoaded )
           t_currpage = mTiles[ 0 ][ j ];
           if (  neighLoaded )
           t_nextpage = p->getTile (  i ,   j );
           if (  thisLoaded )
           t_currpage->_setNeighbor(  WEST,   t_nextpage );
           if (  neighLoaded )
           t_nextpage->_setNeighbor(  EAST,   t_currpage );
           }
           }
           break;
           case NORTH:
           {
           const unsigned int j = numTiles - 1;
           for (  unsigned int i = 0; i < numTiles; i++ )
           {
           PagingLandScapeTile *t_nextpage = 0;
           PagingLandScapeTile *t_currpage = 0;
           if (  thisLoaded )
           t_currpage = mTiles[ i ][ 0 ];
           if (  neighLoaded )
           t_nextpage = p->getTile (  i ,   j );
           if (  thisLoaded )
           t_currpage->_setNeighbor(  NORTH,   t_nextpage );
           if (  neighLoaded )
           t_nextpage->_setNeighbor(  SOUTH,   t_currpage );
           }
           }
           break;
           case SOUTH:
           {
           const unsigned int j = numTiles - 1;
           for (  unsigned int i = 0; i < numTiles; i++ )
           {
           PagingLandScapeTile *t_nextpage = 0;
           PagingLandScapeTile *t_currpage = 0;
           if (  thisLoaded )
           t_currpage = mTiles[ i ][ j ];
           if (  neighLoaded )
           t_nextpage = p->getTile (  i ,   0 );
           if (  thisLoaded )
           t_currpage->_setNeighbor(  SOUTH,   t_nextpage );
           if (  neighLoaded )
           t_nextpage->_setNeighbor(  NORTH,   t_currpage );
           }
           }
           break;
           default:
           break;
           }
           }
           //-----------------------------------------------------------------------
     340   void PagingLandScapePage::setMapMaterial(   )
           {
           if (  mParent->getOptions(   )->BigImage )
           {
           mRenderable->setMaterial (  mParent->getSceneManager(   )->getTextureManager(   )->getMapMaterial(   ) );
           }
           }
           //-----------------------------------------------------------------------
     348   void PagingLandScapePage::touch (   )
           {
           mTimeUntouched = mParent->getOptions(   )->PageInvisibleUnloadFrames;
           }
           //-----------------------------------------------------------------------
     353   const bool PagingLandScapePage::unloadUntouched (   )
           {
           if (  mTimeUntouched == 0 )
           return true;
           mTimeUntouched--;
           return false;
           }
           //-----------------------------------------------------------------------
     361   void PagingLandScapePage::preload(   )
           {
           touch (   );
          
           if (  mIsPreLoaded )
           return;
          
           mIsLoadable = mParent->getSceneManager(   )->getData2DManager(   )->load (  mTableX,   mTableZ );
          
           mIsPreLoaded = true;
          
           mParent->getSceneManager(   )->getListenerManager(   )->firePagePreloaded(  mTableX,   mTableZ,  
           mParent->getSceneManager(   )->getData2DManager(   )->getData2D(  mTableX,   mTableZ )->getHeightData(   ),  
           mBounds );
           }
           //-----------------------------------------------------------------------
     377   void PagingLandScapePage::loadTexture(   )
           {
           touch (   );
           if (  !mIsPreLoaded )
           preload (   );
           if (  !mIsTextureLoaded )
           {
           if (  mIsLoadable )
           mParent->getSceneManager(   )->getTextureManager(   )->load(  mTableX,   mTableZ );
           mIsTextureLoaded = true;
           }
           }
           //-----------------------------------------------------------------------
     390   void PagingLandScapePage::load(   )
           {
           touch (   );
           if (  mIsLoaded )
           return;
           if (  !mIsPreLoaded )
           preload (   );
           if (  !mIsTextureLoaded )
           loadTexture (   );
          
           assert (  mTiles.empty(   ) );
          
           //mVisibletouch = 0;
           mIsLoaded = true;
           //mPageNode->showBoundingBox (  true ) ;
           if (  mIsLoadable )
           {
           const unsigned int numTiles = mNumTiles;
           unsigned int i,   j;
          
           mTiles.reserve (  numTiles );
           mTiles.resize (  numTiles );
          
           for (  i = 0; i < numTiles; ++i )
           {
           mTiles[i].reserve (  numTiles );
           mTiles[i].resize (  numTiles );
           }
          
           PagingLandScapeTile *tile;
           PagingLandScapeTileManager * const tileMgr = mParent->getSceneManager(   )->getTileManager(   );
           for (  i = 0; i < numTiles; ++i )
           {
           for (  j = 0; j < numTiles; ++j )
           {
           //char name[ 24 ];
           //sprintf(  name,   "page[%d,  %d][%d,  %d]",   mTableX,   mTableZ,   i,   j );
          
           tile = tileMgr->getTile (   );
           assert (  tile );
           mTiles[ i ][ j ] = tile;
           tile->init (  mPageNode,   mTableX,   mTableZ,   i,   j );
           }
           }
           for (  i = 0; i < numTiles; ++i )
           {
           for (  j = 0; j < numTiles; ++j )
           {
           if (  j != numTiles - 1 )
           {
           mTiles[ i ][ j ]-> _setNeighbor(  SOUTH,   mTiles[ i ][ j + 1 ] );
           mTiles[ i ][ j + 1 ] ->_setNeighbor(  NORTH,   mTiles[ i ][ j ] );
           }
           if (  i != numTiles - 1 )
           {
           mTiles[ i ][ j ]->_setNeighbor(  EAST,   mTiles[ i + 1 ][ j ] );
           mTiles[ i + 1 ][ j ]->_setNeighbor(  WEST,   mTiles[ i ][ j ] );
           }
           }
           }
          
           PagingLandScapePageManager * const pageMgr = mParent;
           PagingLandScapePage *n;
          
           n = pageMgr->getPage (  mTableX,   mTableZ + 1,   false );
           _setNeighbor(  SOUTH,   n );
           if (  n )
           n->_setNeighbor(  NORTH,   this );
          
           n = pageMgr->getPage (  mTableX,   mTableZ - 1,   false );
           _setNeighbor(  NORTH,   n );
           if (  n )
           n->_setNeighbor(  SOUTH,   this );
          
           n = pageMgr->getPage (  mTableX + 1,   mTableZ,   false );
           _setNeighbor(  EAST,   n );
           if (  n )
           n->_setNeighbor(  WEST,   this );
          
           n = pageMgr->getPage (  mTableX - 1,   mTableZ,   false );
           _setNeighbor(  WEST,   n );
           if (  n )
           n->_setNeighbor(  EAST,   this );
          
           }
          
           mParent->getSceneManager(   )->getListenerManager(   )->firePageLoaded(  mTableX,   mTableZ,  
           mParent->getSceneManager(   )->getData2DManager(   )->getData2D(  mTableX,   mTableZ )->getHeightData(   ),  
           mBounds );
          
           _Show(  true );
           }
          
           //-----------------------------------------------------------------------
     484   void PagingLandScapePage::unload(   )
           {
           if (  mIsLoaded )
           {
          
           assert (  !mTiles.empty(   ) );
          
           // must be 0 to make sure page is really set as non visible
           //mVisibletouch = 0;
           //if (  mVisible )
           _Show (  false );
          
           // Unload the Tiles
           PagingLandScapeTiles::iterator iend = mTiles.end(   );
           for (  PagingLandScapeTiles::iterator it = mTiles.begin(   );
           it != iend;
           ++it )
           {
          
           std::for_each(  it->begin (   ),  
           it->end (   ),  
           std::mem_fun(  &PagingLandScapeTile::uninit ) );
          
           it->clear(   );
           }
           mTiles.clear(   );
           assert (  mTiles.empty(   ) );
          
           mIsLoaded = false;
          
           mParent->getSceneManager(   )->getListenerManager(   )->firePageUnloaded(  mTableX,   mTableZ,  
           mParent->getSceneManager(   )->getData2DManager(   )->getData2D(  mTableX,   mTableZ )->getHeightData(   ),  
           mBounds );
           assert (  mPageNode );
           assert (  mPageNode->getParent (   ) == 0 );
          
           }
           }
           //-----------------------------------------------------------------------
     523   void PagingLandScapePage::unloadTexture(   )
           {
           unload(   );
           if (  mIsTextureLoaded )
           {
           if (  mIsLoadable )
           mParent->getSceneManager(   )->getTextureManager(   )->unload(  mTableX,   mTableZ );
           mIsTextureLoaded = false;
           }
           }
           //-----------------------------------------------------------------------
     534   void PagingLandScapePage::postUnload(   )
           {
           unloadTexture (   );
           if (  mIsPreLoaded )
           {
           mIsPreLoaded = false;
          
           if (  mIsLoadable )
           mParent->getSceneManager(   )->getData2DManager(   )->unload(  mTableX,   mTableZ );
          
           mParent->getSceneManager(   )->getListenerManager(   )->firePagePostunloaded (  mTableX,   mTableZ );
           }
           }
          
           //-----------------------------------------------------------------------
     549   int PagingLandScapePage::isCameraIn(  const Vector3 & pos ) const
           {
           if (  mBounds.intersects(  pos ) )
           {
           if (  mBoundsInt.intersects(  pos ) )
           {
           // Full into this page
           return PAGE_INSIDE;
           }
           else
           {
           // Over the change zone
           return PAGE_CHANGE;
           }
           }
           else
           {
           // Not in this page
           return PAGE_OUTSIDE;
           }
           }
           //-----------------------------------------------------------------------
     571   void PagingLandScapePage::_Show(  const bool do_show )
           {
           assert (  mPageNode );
           if (  do_show )
           {
           assert (  !mVisible );
          
           if (  !mPageNode->getParent (   ) )
           mParent->getSceneManager(   )->getRootSceneNode(   )->addChild (  mPageNode );
          
           mParent->getSceneManager(   )->getListenerManager(   )->firePageShow (  mTableX,   mTableZ,  
           mParent->getSceneManager(   )->getData2DManager(   )->getData2D(  mTableX,   mTableZ )->getHeightData(   ),  
           mBounds );
          
           if (  mIsLoadable )
           {
           unsigned int i,  k;
           for (  i = 0; i < mNumTiles; ++i )
           {
           PagingLandScapeTileRow &tr = mTiles[ i ];
           for (  k = 0; k < mNumTiles; ++k )
           {
           tr[ k ]->setInUse(  true );
           }
           }
           }
           mVisible = true;
           }
           else if (  mVisible )
           {
           assert (  do_show == false );
           //if (  mVisibletouch == 0 )
           {
           if (  mPageNode->getParent (   ) )
           mParent->getSceneManager(   )->getRootSceneNode(   )->removeChild (  mPageNode->getName (   ) );
          
           mParent->getSceneManager(   )->getListenerManager(   )->firePageHide (  mTableX,   mTableZ,  
           mParent->getSceneManager(   )->getData2DManager(   )->getData2D(  mTableX,   mTableZ )->getHeightData(   ),  
           mBounds );
           if (  mIsLoadable )
           {
           unsigned int i,  k;
           for (  i = 0; i < mNumTiles; ++i )
           {
           PagingLandScapeTileRow &tr = mTiles[ i ];
           for (  k = 0; k < mNumTiles; ++k )
           {
           tr[ k ]->setInUse (  false );
           }
           }
           }
           mVisible = false;
           }
           //else
           //{
           // mVisibletouch--;
           //}
           }
           }
           //-----------------------------------------------------------------------
     631   bool PagingLandScapePage::_Notify(  const Vector3 &pos,   const PagingLandScapeCamera * const Cam )
           {
           if (  mIsLoaded && mIsLoadable )
           {
           // (  (  pos - mWorldPosition ).squaredLength(   ) < mParent->getOptions(   )->page_factor ?
           if (  
           1
           //Cam->isVisible (  mBoundsExt )
           //&&
           // if we use an Horizon Visibility Map
           //(   !(  mParent->getOptions(   )->VisMap )
           // || (  mParent->getOptions(   )->VisMap
           // && mParent->getSceneManager(   )->getHorizon(   )->IsPageVisible (  Cam,   mTableX,   mTableZ ) ) )
          
            )
           {
           touch(   );
           //if (  !mVisible )
           // _Show (  true );
           //mVisibletouch = 30;
           for (  unsigned int i = 0; i < mNumTiles; i++ )
           {
           PagingLandScapeTileRow &tr = mTiles[ i ];
           for (  unsigned int k = 0; k < mNumTiles; k++ )
           {
           tr[ k ]->_Notify(  pos,   Cam );
           }
           }
           return true;
           }
           else if (  mVisible )
           {
           // if it was visible it needs to change its state
           //_Show (  false );
           return false;
           }
           }
           return false;
           }
          
           //-----------------------------------------------------------------------
     672   PagingLandScapeTile *PagingLandScapePage::getTile(  const Vector3& pos )
           {
           if (  mIsLoaded && mIsLoadable )
           {
           const unsigned int x = static_cast<unsigned int> (  pos.x / mParent->getOptions(   )->scale.x / (  mParent->getOptions(   )->TileSize ) );
           const unsigned int z = static_cast<unsigned int> (  pos.z / mParent->getOptions(   )->scale.z / (  mParent->getOptions(   )->TileSize ) );
          
           assert (  mTiles[x][z] && mTiles[x][z]-> isLoaded (   ) );
           return mTiles[x][z];
           }
           return 0;
           }
           //-------------------------------------------------------------------------
     685   void PagingLandScapePage::_updateLod(   )
           {
           if (  mIsLoaded && mIsLoadable )
           {
           unsigned int i,  k;
           for (  i = 0; i < mNumTiles; ++i )
           {
           PagingLandScapeTileRow &tr = mTiles[ i ];
           for (  k = 0; k < mNumTiles; ++k )
           {
           PagingLandScapeTile *t = tr[ k ];
           if (  t->isVisible(   ) )
           t->_updateLod(   );
           }
           }
           }
           }
           //-------------------------------------------------------------------------
     703   void PagingLandScapePage::setRenderQueue(  uint8 qid )
           {
           if (  mVisible &&
           mIsLoadable )
           {
           unsigned int i,  k;
           for (  i = 0; i < mNumTiles; ++i )
           {
           PagingLandScapeTileRow &tr = mTiles[ i ];
           for (  k = 0; k < mNumTiles; ++k )
           {
           PagingLandScapeTile *t = tr[ k ];
           if (  t->isVisible(   ) )
           t->setRenderQueueGroup(  qid );
           }
           }
           }
           }
           //-------------------------------------------------------------------------
     722   PagingLandScapeTile* PagingLandScapePage::getTile(  const unsigned int i ,   const unsigned int j ) const
           {
           if (  mIsLoaded )
           {
           assert (  !mTiles.empty(   ) );
          
           assert (  i < mParent->getOptions(   )->NumTiles );
           assert (  j < mParent->getOptions(   )->NumTiles );
          
           assert (  i < mTiles.size(   ) );
           assert (  j < mTiles[i].size(   ) );
          
           return mTiles[i][j];
           }
           return 0;
           }
          
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapePageManager.cpp

       1  /***************************************************************************
           OgrePagingLandScapePageManager.cpp - description
           -------------------
           begin : Sat May 01 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreMovableObject.h"
          #include "OgreAxisAlignedBox.h"
          
          #include "OgreCamera.h"
          
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          #include "OgrePagingLandScapePage.h"
          #include "OgrePagingLandScapePageManager.h"
          #include "OgrePagingLandScapeTileManager.h"
          #include "OgrePagingLandScapeRenderableManager.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTileInfo.h"
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapeRenderable.h"
          #include "OgrePagingLandScapeListenerManager.h"
          #include "OgrePagingLandScapePageRenderable.h"
          #include "OgrePagingLandScapeHorizon.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      49   PagingLandScapePageManager::PagingLandScapePageManager(  PagingLandScapeSceneManager * scnMgr ) :
           mSceneManager(  scnMgr ),  
           mOptions(  scnMgr->getOptions(   ) ),  
           mData2d(  scnMgr->getData2DManager(   ) ),  
           mTexture(  scnMgr->getTextureManager(   ) ),  
           mRenderablesMgr(  scnMgr->getRenderableManager(   ) ),  
           mWidth(  0 ),  
           mHeight(  0 ),  
           mNextQueueFrameCount(  0 ),  
           mPause(  99 ),  
           mCurrentcam(  0 ),  
           mTerrainReady(  false ),  
           mTimePreLoaded(  0 ),  
           mRenderQueueGroupID (  static_cast<Ogre::RenderQueueGroupID>(  scnMgr->getWorldGeometryRenderQueue(   ) ) ),  
           //mRenderQueueGroupID (  RENDER_QUEUE_WORLD_GEOMETRY_2 ),  
           mPageLoadInterval (  mOptions->PageLoadInterval ),  
           mOnFrame(  false ),  
           mEnabled(  false )
           {
           mPagePool.clear(   );
           mActivePages.clear(   );
           mFreePages.clear(   );
           }
           //-----------------------------------------------------------------------
      73   PagingLandScapePageManager::~PagingLandScapePageManager(  void )
           {
           reset(   );
           // could save a delete if texture type is the same... ?
           if (  !mPagePool.empty(   ) )
           {
           std::for_each (  mPagePool.begin (   ),   mPagePool.end (   ),  
           delete_object (   ) );
           mPagePool.clear(   );
           mFreePages.clear(   );
           }
           }
           //-----------------------------------------------------------------------
      86   void PagingLandScapePageManager::reset(  void )
           {
           std::for_each(  mActivePages.begin(   ),   mActivePages.end(   ),  
           std::mem_fun(  &PagingLandScapePage::uninit ) );
          
           // Insert actives into free list
           mFreePages.insert(  mFreePages.end(   ),   mActivePages.begin(   ),   mActivePages.end(   ) );
           // Remove all active instances
           mActivePages.clear(   );
          
           mPageLoadQueue.clear(   );
           mPagePreloadQueue.clear(   );
           mPageTextureloadQueue.clear(   );
          
           mLoadedPages.clear(   );
           mTextureLoadedPages.clear(   );
           mPreLoadedPages.clear(   );
          
           mWidth = 0;
           mHeight = 0;
           mOnFrame = false;
           mEnabled = false;
           }
           //-----------------------------------------------------------------------
     110   void PagingLandScapePageManager::load(  void )
           {
           WorldDimensionChange (   );
           mEnabled = true;
           }
           //-----------------------------------------------------------------------
     116   void PagingLandScapePageManager::clear(  void )
           {
           // before calling the scene manager node clearing
           reset(   );
           }
           //-----------------------------------------------------------------------
     122   void PagingLandScapePageManager::WorldDimensionChange(  void )
           {
           const unsigned int newWidth = mOptions->world_width;
           const unsigned int newHeight = mOptions->world_height;
          
           reset(   );
          
           mPageLoadInterval = mOptions->PageLoadInterval;
           mWidth = newWidth;
           mHeight = newHeight;
           }
           //-----------------------------------------------------------------------
     134   void PagingLandScapePageManager::setMapMaterial(  void )
           {
           std::for_each(  mActivePages.begin(   ),   mActivePages.end(   ),  
           std::mem_fun(  &PagingLandScapePage::setMapMaterial ) );
           }
           //-----------------------------------------------------------------------
     140   void PagingLandScapePageManager::_updateLod(  void )
           {
           PagingLandScapePageList::iterator lend = mLoadedPages.end(   );
           for (  PagingLandScapePageList::iterator l = mLoadedPages.begin(   ); l != lend; ++l )
           {
           (  *l )->_updateLod(   );
           }
           }
           //-----------------------------------------------------------------------
     149   bool PagingLandScapePageManager::frameStarted(  const FrameEvent& evt )
           {
           if (  mEnabled )//if not queued to be removed from framelistener or Paused
           {
           --mTimePreLoaded;
           if (  mOptions->VisMap )
           {
           mSceneManager->getHorizon (   )->prepare(  static_cast< PagingLandScapeCamera* >(  mOptions->primaryCamera ) );
           }
           mOnFrame = false;
           }
           return true;
           }
           //-----------------------------------------------------------------------
     163   bool PagingLandScapePageManager::frameEnded(  const FrameEvent& evt )
           {
           // mOnFrame If This Frame has seen any Camera,  
           // We won't unload anything.
           // since un-focusing rendering may make this method unload all renderables.
           // mEnabled sm paused or frame listener queued for deletion
           if (  !mOnFrame || !mEnabled )
           return true;
          
           // unload some pages if no more in use
           processUnloadQueues(   );
           // load some pages that are still queued
           processLoadQueues(   );
          
           if (  !mTerrainReady &&
           mPagePreloadQueue.empty(   ) &&
           mPageLoadQueue.empty(   ) &&
           mPageTextureloadQueue.empty(   ) )
           {
           mSceneManager->getListenerManager(   )->fireTerrainReady(   );// no more to load
           mTerrainReady = true;
           }
          
           if (  mOptions->VisMap )
           mSceneManager->getHorizon(   )->update(   );
          
           mSceneManager->getTileManager(   )->unloadUntouched(   );
           mRenderablesMgr->resetVisibles(   );
           return true;
           }
           //-----------------------------------------------------------------------
     194   PagingLandScapePage *PagingLandScapePageManager::getNewPage(  const unsigned int x,   const unsigned int z )
           {
           PagingLandScapePage *p;
          
           // should we resize page pool
           if (  mFreePages.empty(   ) )
           {
           const size_t pool_size = mPagePool.size (   );
           const size_t new_pool_size = (  pool_size == 0 ) ? 9 : pool_size * 2;
          
           mPagePool.reserve(  new_pool_size );
           mPagePool.resize(  new_pool_size );
          
           // Create new pages
           for (  size_t i = pool_size; i < new_pool_size; ++i )
           {
           p = new PagingLandScapePage (  this );
           mPagePool[i] = p;
           mFreePages.push_back (  p );
           }
           }
          
           // Get a pre-allocated new page.
           p = mFreePages.front (   );
           mFreePages.pop_front (   );
           mActivePages.push_back (  p );
          
           p->init (  x,   z );
          
           return p;
           }
           //-----------------------------------------------------------------------
     226   void PagingLandScapePageManager::releasePage(  PagingLandScapePage *p )
           {
           removeFromQueues (  p );
           p->uninit (   );
           mActivePages.remove (  p );
           mFreePages.push_back (  p );
           }
           //-----------------------------------------------------------------------
     234   PagingLandScapePage *PagingLandScapePageManager::getPage(  const unsigned int x,   const unsigned int z,  
     235   const bool alwaysReturn )
           {
           if (  x < mWidth && z < mHeight )
           {
           if (  !mActivePages.empty(   ) )
           {
           PagingLandScapePageList::iterator l,   lend = mActivePages.end(   );
           for (  l = mActivePages.begin(   ); l != lend; ++l )
           {
           if (  (  *l )->isCoord(  x,   z ) )
           return (  *l );
           }
           }
           if (  alwaysReturn )
           return getNewPage(  x,   z );
           }
           assert (  !alwaysReturn );
           return 0;
           }
           //-----------------------------------------------------------------------
     255   void PagingLandScapePageManager::LoadFirstPage(  PagingLandScapeCamera* cam )
           {
          
           const Vector3 CamPos = cam->getDerivedPosition(   );
           //gets page indices (  if outside Terrain gets nearest page )
           unsigned int i,   j;
           getPageIndices (  CamPos.x,   CamPos.z,   i,   j,   true );
           // update the camera page position
           // does modify mIniX,   mFinX,   mIniZ,   mFinZ
          
           PagingLandScapePage *p = getPage (  i,   j );
           makePageLoadedNow (  p );
           }
           //-----------------------------------------------------------------------
     269   void PagingLandScapePageManager::makePageLoadedNow(  PagingLandScapePage * p )
           {
           // Have the current page be loaded now !
           if (  !p->isLoaded(   ) )
           {
           // remove from lists it does belongs to
           if (  p->isTextureLoaded(   ) )
           mTextureLoadedPages.remove (  p );
           else if (  p->isPreLoaded(   ) )
           mPreLoadedPages.remove (  p );
           // remove from queue it does belongs to
           removeFromQueues (  p );
          
           p->load(   );
           assert (   std::find(  mLoadedPages.begin(   ),   mLoadedPages.end(   ),   p ) == mLoadedPages.end(   ) );
           mLoadedPages.push_back (  p );
           // make sure this brutal loading doesn't impact on fps
           mNextQueueFrameCount = mPageLoadInterval;
           }
           else
           {
           p->touch (   );
           }
           }
          
           //-----------------------------------------------------------------------
     295   void PagingLandScapePageManager::updateLoadedPages(   )
           {
           PagingLandScapeCamera * const cam = mCurrentcam;
          
           // Make any pending updates to the calculated frustum
           cam->updateView(   );
          
           const Vector3 pos (  cam->getDerivedPosition(   ).x,   127.0f,  cam->getDerivedPosition(   ).z );
           // hide page not visible by this Camera
           // Notify those Page (  update tile vis/ rend load on cam distance )
           // update Page Texture if needed
          
           const unsigned int iniX = cam->mIniX;
           const unsigned int finX = cam->mFinX;
          
           const unsigned int iniZ = cam->mIniZ;
           const unsigned int finZ = cam->mFinZ;
          
           PagingLandScapePage *p;
           const bool lightchange = mOptions->lightmoved;
           PagingLandScapePageList::iterator l,   lend = mLoadedPages.end (   );
           for (  l = mLoadedPages.begin (   ); l != lend; ++l )
           {
           p = (  *l );
           unsigned int x,   z;
           p->getCoordinates (  x,   z );
           if (  (  z >= iniZ ) && (  z <= finZ ) && (  x >= iniX ) && (  x <= finX ) )
           {
           // inform pages we are near Camera on next render.
           if (  p->_Notify (  pos,   cam ) )
           {
           // get pages that needs modification and Are visible..
           PagingLandScapeTexture * const tex = mTexture->getTexture(  x,   z );
           assert(  tex );
           if (  lightchange )
           tex->lightUpdate(   );
           if (  tex->needUpdate(   ) )
           tex->update(   );
           }
           }
           else
           {
           p->_Show (  false );
           }
           }
          
          
          
           if (  lightchange )
           mOptions->lightmoved = false;
           }
           //-----------------------------------------------------------------------
     347   void PagingLandScapePageManager::loadNow(  PagingLandScapeCamera *cam )
           {
           updatePaging (  cam );
           const Vector3 pos (  cam->getDerivedPosition(   ).x,   127.0f,   cam->getDerivedPosition(   ).z );
           while (  !mTerrainReady ||
           !mPagePreloadQueue.empty(   ) ||
           !mPageLoadQueue.empty(   ) ||
           !mPageTextureloadQueue.empty(   ) )
           {
           processLoadQueues(   );// fill pages queues
           updateLoadedPages(   );// fill tiles queues
           mTerrainReady = mRenderablesMgr->executeRenderableLoading(  pos ); // load renderables
           mNextQueueFrameCount = -1;
           }
           //assert (   )
           }
           //-----------------------------------------------------------------------
     364   void PagingLandScapePageManager::queuePageNeighbors(   )
           {
           const PagingLandScapeCamera * const cam = mCurrentcam;
           // Queue the rest
           // Loading must be done one by one to avoid FPS drop,   so they are queued.
           // We must load the next visible LandScape pages,  
           // check the LandScape boundaries
          
           const unsigned int preIniX = cam->mPreIniX;
           const unsigned int preFinX = cam->mPreFinX;
          
           const unsigned int preIniZ = cam->mPreIniZ;
           const unsigned int preFinZ = cam->mPreFinZ;
          
           const unsigned int iniX = cam->mIniX;
           const unsigned int finX = cam->mFinX;
          
           const unsigned int iniZ = cam->mIniZ;
           const unsigned int finZ = cam->mFinZ;
          
           PagingLandScapePage *p;
           for (  unsigned int i = preIniX; i <= preFinX; i++ )
           {
           for (  unsigned int j = preIniZ; j <= preFinZ; j++ )
           {
           // pages here,   in this zone around camera,  
           // must be at least preloading.
           // that means they can be loaded too.
           p = getPage (  i,   j,   true );
          
           if (  !(  p->mIsLoading || p->isLoaded(   ) ) )
           {
           if(  (  j >= iniZ ) && (  j <= finZ ) && (  i >= iniX ) && (  i <= finX ) )
           {
           // pages here,   in this tighter zone around camera,  
           // must be Loading or Loaded as they may
           // be below camera very soon.
           removeFromQueues (  p );
           mPageLoadQueue.push (  p );
           p->mIsLoading = true;
           }
           else if (  !p->mIsTextureLoading &&
           !p->isTextureLoaded(   ) &&
           !p->mIsPreLoading &&
           !p->isPreLoaded(   ) )
           {
           // must be at least preloading.
           removeFromQueues (  p );
           mPagePreloadQueue.push (  p );
           p->mIsPreLoading = true;
           }
           }
           p->touch (   );
           }
           }
           mTimePreLoaded = mPageLoadInterval;
           }
           //-----------------------------------------------------------------------
     422   void PagingLandScapePageManager::updatePaging(  PagingLandScapeCamera *cam )
           {
           mCurrentcam = cam;
           // Here we have to look if we have to load,   unload any of the LandScape Pages
           // Fix from Praetor,   so the camera used gives you "world-relative" coordinates
           // make sure in the bounding box of LandScape
           const Vector3 pos (  cam->getDerivedPosition(   ).x,  
           127.0f,  
           cam->getDerivedPosition(   ).z );
          
           //updateStats(  pos );
          
           bool need_touch = false;//(  mTimePreLoaded < 0 );
          
           if (  mWidth == 0 && mHeight == 0 ) {
           //just return if we haven't got any world yet
           return;
           }
          
           if (  cam->mLastCameraPos != pos
           && (  mOptions->cameraThreshold < fabs (  cam->mLastCameraPos.x - pos.x ) ||
           mOptions->cameraThreshold < fabs (  cam->mLastCameraPos.z - pos.z ) ) )
           {
           // Update only if the camera was moved
           PagingLandScapePage * const oldPage = getPage (  cam->mCurrentCameraPageX,   cam->mCurrentCameraPageZ,   false );
           PagingLandScapeTile * const oldTile = (  oldPage && oldPage->isLoaded(   ) ?
           oldPage->getTile (  cam->mCurrentCameraTileX,   cam->mCurrentCameraTileZ ) : 0 );
          
           unsigned int i,   j;
          
           //gets page indices (  if outside Terrain gets nearest page )
           getPageIndices (  pos.x,   pos.z,   i,   j,   true );
           PagingLandScapePage *p = getPage (  i,   j );
          
           if (  !p ) {
           return;
           }
           makePageLoadedNow (  p );
          
           // update current Cam Page info
           if (  oldPage != p )
           {
           // update the camera info :
           cam->updatePaging(  i,   j );
           // need to inform neighbors pages
           need_touch = true;
           }
          
           // Update current Cam Tile info.
           if (  p->isLoadable(   ) )
           {
           PagingLandScapeTile * const t = getTile (  pos.x,   pos.z,   i,   j,   true );
           if (  t && t != oldTile )
           {
           if (  mOptions->MaxLodUnderCam )
           {
           // reset previous tile at normal LOD mechanism.
           if (  oldTile && oldTile->isLoaded(   ) )
           {
           assert (  oldTile->getRenderable(   ) );
           oldTile->getRenderable(   )->setMaxLod (  false );
           }
           // set current tile at max LOD whatever complexity it is.
           if (  t->isLoaded(   ) )
           {
           assert (  t->getRenderable(   ) );
           t->getRenderable(   )->setMaxLod (  true );
           }
           }
          
           PagingLandScapeTileInfo * const CurrentTileInfo = t->getInfo(   );
           cam->mCurrentCameraTileX = CurrentTileInfo->mTileX;
           cam->mCurrentCameraTileZ = CurrentTileInfo->mTileZ;
           }
           }
           // Update the last camera position
           if (  mOptions->cameraThreshold < fabs (  cam->mLastCameraPos.x - pos.x ) )
           cam->mLastCameraPos.x = pos.x;
           if (  mOptions->cameraThreshold < fabs (  cam->mLastCameraPos.z - pos.z ) )
           cam->mLastCameraPos.z = pos.z;
           }
          
           if (  need_touch )
           queuePageNeighbors(   );
           updateLoadedPages(   );
           //if (  mNextQueueFrameCount < 0 )
           mRenderablesMgr->executeRenderableLoading(  pos );
          
           // This Frame has seen a Camera.
           mOnFrame = true;
           }
           //-----------------------------------------------------------------------
     514   void PagingLandScapePageManager::processUnloadQueues(   )
           {
           // Check for pages that need to be unloaded.
           // if touched,   that means they didn't have been touch by any cameras
           // for several frames and thus need to be unloaded.
           PagingLandScapePage *p;
           // LIST CHECKS
           PagingLandScapePageList::iterator itl;
           for (  itl = mPreLoadedPages.begin (   ); itl != mPreLoadedPages.end (   ); )
           {
           if (  (  *itl )->unloadUntouched (   ) )
           {
           p = *itl;
           releasePage (  p );
           itl = mPreLoadedPages.erase (  itl );
           }
           else
           {
           ++itl;
           }
           }
           for (  itl = mTextureLoadedPages.begin (   ); itl != mTextureLoadedPages.end (   ); )
           {
           if (  (  *itl )->unloadUntouched (   ) )
           {
           p = *itl;
           releasePage (  p );
           itl = mTextureLoadedPages.erase (  itl );
           }
           else
           {
           ++itl;
           }
           }
           for (  itl = mLoadedPages.begin (   ); itl != mLoadedPages.end (   ); )
           {
           if (  (  *itl )->unloadUntouched (   ) )
           {
           p = *itl;
           releasePage (  p );
           itl = mLoadedPages.erase (  itl );
           }
           else
           {
           ++itl;
           }
           }
          
           // QUEUES CHECKS
           // check queues for page that need to be excluded from queues
           PagingLandScapeQueue<PagingLandScapePage>::MsgQueType::iterator itq;
           for (  itq = mPagePreloadQueue.begin (   ); itq != mPagePreloadQueue.end (   ); )
           {
           assert (  !(  *itq )->isLoaded(   ) && !(  *itq )->isPreLoaded(   ) && !(  *itq )->isTextureLoaded(   ) );
           assert (  !(  *itq )->mIsLoading && !(  *itq )->mIsTextureLoading );
           if (  (  *itq )->unloadUntouched (   ) )
           {
           p = *itq;
           // remove from queue
           p->mIsPreLoading = false;
           itq = mPagePreloadQueue.erase (  itq );
           // remove from active pages
           //(  must be removed from queue first )
           releasePage (  p );
           }
           else
           {
           ++itq;
           }
           }
           for (  itq = mPageTextureloadQueue.begin(   ); itq != mPageTextureloadQueue.end(   ); )
           {
           assert (  !(  *itq )->isLoaded(   ) && (  *itq )->isPreLoaded(   ) && !(  *itq )->isTextureLoaded(   ) );
           assert (  !(  *itq )->mIsLoading && (  *itq )->mIsTextureLoading && !(  *itq )->mIsPreLoading );
           if (  (  *itq )->unloadUntouched (   ) )
           {
           p = *itq;
           // remove from queue
           p->mIsTextureLoading = false;
           itq = mPageTextureloadQueue.erase (  itq );
           // remove from active pages
           //(  must be removed from queue first )
           releasePage (  p );
           }
           else
           {
           ++itq;
           }
           }
           for (  itq = mPageLoadQueue.begin (   ); itq != mPageLoadQueue.end (   ); )
           {
           assert (  !(  *itq )->isLoaded(   ) );
           assert (  (  *itq )->mIsLoading && !(  *itq )->mIsTextureLoading && !(  *itq )->mIsPreLoading );
           if (  (  *itq )->unloadUntouched (   ) )
           {
           p = *itq;
           // remove from queue
           p->mIsLoading = false;
           itq = mPageLoadQueue.erase (  itq );
           // remove from active pages
           //(  must be removed from queue first )
           releasePage (  p );
           }
           else
           {
           ++itq;
           }
           }
           }
           //-----------------------------------------------------------------------
     624   void PagingLandScapePageManager::processLoadQueues(   )
           {
           // Should be called every count frame only
           // to minimize fps impact
           if (  mNextQueueFrameCount-- < 0 )
           {
           SceneManager::CameraIterator camIt = mSceneManager->getCameraIterator(   );
           while (  camIt.hasMoreElements(   ) )
           {
           Camera const * const currentCamera = camIt.getNext(   );
           const Vector3 pos (  currentCamera->getDerivedPosition(   ).x,  
           127.0f,  
           currentCamera->getDerivedPosition(   ).z );
          
           // We to Load nearest page in non-empty queue
           if (  !mPageLoadQueue.empty (   ) )
           {
           // We to Load nearest page in non-empty queue
           PagingLandScapePage *p = mPageLoadQueue.find_nearest (  pos );
           assert (  p && !p->isLoaded (   ) );
           assert (  !p->mIsTextureLoading && !p->mIsPreLoading );
           p->load (   );
          
           p->mIsLoading = false;
           mLoadedPages.push_back (  p );
           mTextureLoadedPages.remove (  p );
           mNextQueueFrameCount = mPageLoadInterval;
           }
           else if (  !mPageTextureloadQueue.empty (   ) )
           {
           // We TextureLoad nearest page in non-empty queue
           PagingLandScapePage *p = mPageTextureloadQueue.find_nearest (  pos );
           assert (  p && !p->isTextureLoaded(   ) );
           assert (  !p->mIsLoading && !p->mIsPreLoading );
           p->loadTexture (   );
          
           p->mIsTextureLoading = false;
           mTextureLoadedPages.push_back (  p );
           mPreLoadedPages.remove (  p );
           // do not automatically push to level up.
           //mPageLoadQueue.push (  p );
           mNextQueueFrameCount = mPageLoadInterval;
           }
           else if (  !mPagePreloadQueue.empty (   ) )
           {
           // We PreLoad nearest page in non-empty queue
           PagingLandScapePage *p = mPagePreloadQueue.find_nearest (  pos );
           assert (  p && !p->isPreLoaded(   ) );
           assert (  !p->mIsLoading && !p->mIsTextureLoading );
           p->preload (   );
          
           p->mIsPreLoading = false;
           mPreLoadedPages.push_back (  p );
           mPageTextureloadQueue.push (  p );
           p->mIsTextureLoading = true;
           mNextQueueFrameCount = mPageLoadInterval;
           }
           }
           } // if (  mNextQueueFrameCount-- < 0 )
           }
           //-----------------------------------------------------------------------
     685   void PagingLandScapePageManager::removeFromQueues(  PagingLandScapePage* p )
           {
           assert (  p );
           if (  p->mIsLoading )
           {
           p->mIsLoading = false;
           mPageLoadQueue.remove (  p );
           }
           else if (  p->mIsTextureLoading )
           {
           p->mIsTextureLoading = false;
           mPageTextureloadQueue.remove (  p );
           }
           else if (  p->mIsPreLoading )
           {
           p->mIsPreLoading = false;
           mPagePreloadQueue.remove (  p );
           }
           assert (  !p->mIsLoading && !p->mIsTextureLoading && !p->mIsPreLoading );
           }
           //-----------------------------------------------------------------------
     706   unsigned int PagingLandScapePageManager::getCurrentCameraPageX(  void ) const
           {
           if (  mCurrentcam )
           {
          
           return mCurrentcam->mCurrentCameraPageX;
           }
           return 0;
           }
          
           //-----------------------------------------------------------------------
     717   unsigned int PagingLandScapePageManager::getCurrentCameraPageZ(  void ) const
           {
           if (  mCurrentcam )
           {
           return mCurrentcam->mCurrentCameraPageZ;
           }
           return 0;
           }
          
           //-----------------------------------------------------------------------
     727   unsigned int PagingLandScapePageManager::getCurrentCameraTileX(  void ) const
           {
           if (  mCurrentcam )
           {
           return mCurrentcam->mCurrentCameraTileX;
           }
           return 0;
           }
          
           //-----------------------------------------------------------------------
     737   unsigned int PagingLandScapePageManager::getCurrentCameraTileZ(  void ) const
           {
           if (  mCurrentcam )
           {
           return mCurrentcam->mCurrentCameraTileZ;
           }
           return 0;
           }
           //-----------------------------------------------------------------------
     746   void PagingLandScapePageManager::addLoadedPage(  PagingLandScapePage *p )
           {
           mLoadedPages.push_back (  p );
           }
           //-----------------------------------------------------------------------
     751   int PagingLandScapePageManager::getLoadedPageSize(  void ) const
           {
           return static_cast< int >(  mLoadedPages.size(   ) );
           }
           //-----------------------------------------------------------------------
     756   int PagingLandScapePageManager::getUnloadedPagesSize(  void ) const
           {
           return static_cast< int >(  mWidth*mHeight - mLoadedPages.size(   ) );
           }
           //-----------------------------------------------------------------------
     761   int PagingLandScapePageManager::getTextureLoadedPageSize(  void ) const
           {
           return static_cast< int >(  mTextureLoadedPages.size(   ) );
           }
          
           //-----------------------------------------------------------------------
     767   int PagingLandScapePageManager::getPreLoadedPageSize(  void ) const
           {
           return static_cast< int >(  mPreLoadedPages.size(   ) );
           }
           //-----------------------------------------------------------------------
     772   int PagingLandScapePageManager::getPagePreloadQueueSize(  void ) const
           {
           return static_cast< int >(  mPagePreloadQueue.getSize(   ) );
           }
          
           //-----------------------------------------------------------------------
     778   int PagingLandScapePageManager::getPageTextureloadQueueSize(  void ) const
           {
           return static_cast< int >(  mPageTextureloadQueue.getSize(   ) );
           }
          
           //-----------------------------------------------------------------------
     784   int PagingLandScapePageManager::getPageLoadQueueSize(  void ) const
           {
           return static_cast< int >(  mPageLoadQueue.getSize(   ) );
           }
          
           //-----------------------------------------------------------------------
     790   void PagingLandScapePageManager::getGlobalToPage(  Real& x,   Real& z ) const
           {
           const Real inv_pSize = 1.0f / (  mOptions->PageSize - 1 );
          
           x = static_cast< int >(  (  (  x / mOptions->scale.x ) + mOptions->maxUnScaledX ) * inv_pSize );
           z = static_cast< int >(  (  (  z / mOptions->scale.z ) + mOptions->maxUnScaledZ ) * inv_pSize );
           }
          
           //-----------------------------------------------------------------------
     799   void PagingLandScapePageManager::getNearestPageIndicesUnscaled(  const Real posx,   const Real posz,   unsigned int& x,   unsigned int& z ) const
           {
           // adjust x and z to be local to page
           const Real inv_pSize = 1.0f / (  mOptions->PageSize - 1 );
          
           const int lx = static_cast< int >(  (  posx + mOptions->maxUnScaledX ) * inv_pSize );
           const int lz = static_cast< int >(  (  posz + mOptions->maxUnScaledZ ) * inv_pSize );
          
           const int w = static_cast< int >(  mOptions->world_width );
           const int h = static_cast< int >(  mOptions->world_height );
          
           // make sure indices are not negative or outside range of number of pages
           if (  lx >= w )
           {
           x = static_cast< unsigned int >(  w - 1 );
           }
           else if (  lx < 0 )
           {
           x = 0;
           }
           else
           {
           x = static_cast< unsigned int >(  lx );
           }
          
           if (  lz >= h )
           {
           z = static_cast< unsigned int >(  h - 1 );
           }
           else if (  lz < 0 )
           {
           z = 0;
           }
           else
           {
           z = static_cast< unsigned int >(  lz );
           }
           }
          
          
          
           //-----------------------------------------------------------------------
     841   void PagingLandScapePageManager::getNearestTileIndicesUnscaled(  const Real posx,   const Real posz,  
           const unsigned int pagex,   const unsigned int pagez,  
           unsigned int& x,   unsigned int& z ) const
           {
           // adjust x and z to be local to page
           const Real inv_tSize = 1.0f / (  mOptions->TileSize - 1 );
           const int pSize = mOptions->PageSize - 1;
          
           const int tilex = static_cast< int >(  (  posx - (  (  pagex * pSize ) - mOptions->maxUnScaledX ) ) * inv_tSize );
           //- mOptions->maxUnScaledX
          
           const int tilez = static_cast< int >(  (  posz - (  (  pagez * pSize ) - mOptions->maxUnScaledZ ) ) * inv_tSize );
           //- mOptions->maxUnScaledZ
          
           const int tilesPerPage = static_cast< int >(  (  pSize * inv_tSize ) - 1 );
          
           if (  tilex > tilesPerPage )
           {
           x = static_cast< unsigned int >(  tilesPerPage );
           }
           else if (  tilex < 0 )
           {
           x = 0;
           }
           else
           {
           x = static_cast< unsigned int >(  tilex );
           }
          
           if (  tilez > tilesPerPage )
           {
           z = static_cast< unsigned int >(  tilesPerPage );
           }
           else if(  tilez < 0 )
           {
           z = 0;
           }
           else
           {
           z = static_cast< unsigned int >(  tilez );
           }
           }
           //-----------------------------------------------------------------------
     884   bool PagingLandScapePageManager::getTileIndices(  const Real posx,   const Real posz,  
           const unsigned int pagex,   const unsigned int pagez,  
     886   unsigned int& x,   unsigned int& z,   bool alwaysAnswer ) const
           {
           if (  alwaysAnswer )
           {
           getNearestTileIndicesUnscaled(  posx / mOptions->scale.x,   posz / mOptions->scale.z,   pagex,   pagez,   x,   z );
           return true;
           }
           else
           {
           return getRealTileIndicesUnscaled(  posx / mOptions->scale.x,   posz / mOptions->scale.z,   pagex,   pagez,   x,   z );
           }
           }
           //-----------------------------------------------------------------------
     899   PagingLandScapeTile* PagingLandScapePageManager::getTileUnscaled(  const Real posx,   const Real posz,   const unsigned int pagex,   const unsigned int pagez,   bool alwaysAnswer )
           {
           unsigned int tilex,   tilez;
           if (  alwaysAnswer )
           {
           getNearestTileIndicesUnscaled(  posx,   posz,   pagex,   pagez,   tilex,   tilez );
           PagingLandScapePage * const p = getPage (  pagex ,   pagez,   false );
           if (  p )
           return p->getTile(  tilex,   tilez );
           }
           else
           {
           if (  getRealTileIndicesUnscaled(  posx,   posz,   pagex,   pagez,   tilex,   tilez ) )
           {
           PagingLandScapePage * const p = getPage (  pagex ,   pagez,   false );
           if (  p )
           return p->getTile(  tilex,   tilez );
           }
           }
           return 0;
           }
           //-----------------------------------------------------------------------
     921   PagingLandScapeTile* PagingLandScapePageManager::getTile(  const Real posx,   const Real posz,   const unsigned int pagex,   const unsigned int pagez,   bool alwaysAnswer )
           {
           return getTileUnscaled(  posx / mOptions->scale.x,   posz / mOptions->scale.z,   pagex,   pagez,   alwaysAnswer );
           }
           //-----------------------------------------------------------------------
     926   PagingLandScapeTile* PagingLandScapePageManager::getTile(  const Real posx,   const Real posz,   bool alwaysAnswer )
           {
           return getTileUnscaled(  posx / mOptions->scale.x,   posz / mOptions->scale.z,   alwaysAnswer );
           }
           //-----------------------------------------------------------------------
     931   PagingLandScapeTile* PagingLandScapePageManager::getTileUnscaled(  const Real posx,   const Real posz,   bool alwaysAnswer )
           {
           unsigned int pagex,   pagez;
           if (  alwaysAnswer )
           {
           unsigned int tilex,   tilez;
           getNearestPageIndicesUnscaled(  posx,   posz,   pagex,   pagez );
           getNearestTileIndicesUnscaled(  posx,   posz,   pagex,   pagez,   tilex,   tilez );
           return getPage (  pagex ,   pagez )->getTile(  tilex,   tilez );
           }
           else
           {
           if (  getRealPageIndicesUnscaled(  posx,   posz,   pagex,   pagez ) )
           {
           unsigned int tilex,   tilez;
           if (  getRealTileIndicesUnscaled(  posx,   posz,   pagex,   pagez,   tilex,   tilez ) )
           {
           PagingLandScapePage * const p = getPage (  pagex ,   pagez,   false );
           if (  p )
           return p->getTile(  tilex,   tilez );
           }
           }
           }
           return 0;
           }
           //-------------------------------------------------------------------------
     957   PagingLandScapeTile* PagingLandScapePageManager::getTilePage (  unsigned int &posx,   unsigned int &posz,  
           const unsigned int pagex,   const unsigned int pagez )
           {
           const Real tSize = mOptions->TileSize - 1;
           const Real inv_tSize = 1.0f / tSize;
           const int tilex = static_cast< int >(  posx * inv_tSize );
           const int tilez = static_cast< int >(  posz * inv_tSize );
          
           const int pSize = mOptions->PageSize - 1;
           const int tilesPerPage = static_cast< int > (  mOptions->NumTiles - 1 );
          
           unsigned int x;
           if (  tilex > tilesPerPage )
           {
           x = static_cast< unsigned int >(  tilesPerPage );
           }
           else if (  tilex < 0 )
           {
           x = 0;
           }
           else
           {
           x = static_cast< unsigned int >(  tilex );
           }
          
           unsigned int z;
           if (  tilez > tilesPerPage )
           {
           z = static_cast< unsigned int >(  tilesPerPage );
           }
           else if(  tilez < 0 )
           {
           z = 0;
           }
           else
           {
           z = static_cast< unsigned int >(  tilez );
           }
           posx = posx - static_cast< unsigned int > (  x * tSize );
           posz = posz - static_cast< unsigned int > (  z * tSize );
           PagingLandScapePage *p = getPage (  pagex ,   pagez );
           if (  p )
           return p->getTile(  x,   z );
           return 0;
           }
           //-------------------------------------------------------------------------
    1003   void PagingLandScapePageManager::setWorldGeometryRenderQueue(  uint8 qid )
           {
           PagingLandScapePageList::iterator l,   lend = mLoadedPages.end(   );
           for (  l = mLoadedPages.begin(   ); l != lend; ++l )
           {
           PagingLandScapePage *p = (  *l );
           {
           p->setRenderQueue(  qid );
           }
           }
           }
          
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapePageRenderable.cpp

       1  /***************************************************************************
           OgrePagingLandScapePageRenderable.cpp - description
           -------------------
           begin : Thu Feb 27 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreRoot.h"
          #include "OgreHardwareBufferManager.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreMovableObject.h"
          #include "OgreAxisAlignedBox.h"
          
          #include "OgreCamera.h"
          #include "OgreViewport.h"
          
          #include "OgreSceneNode.h"
          
          #include "OgreSimpleRenderable.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          
          #include "OgrePagingLandScapePageRenderable.h"
          
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapeTileInfo.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeData2DManager.h"
          
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapePageManager.h"
          
          namespace Ogre
          {
          
          
          // Renderable Buffer definitions
          #define MAIN_BINDING 0
          
           PagingLandScapeOptions *PagingLandScapePageRenderable::mOpt;
           String PagingLandScapePageRenderable::mType = "PagingLandScapePageBillBoard";
          
           //-----------------------------------------------------------------------
      61   PagingLandScapePageRenderable::PagingLandScapePageRenderable(  PagingLandScapePageManager *pageMgr,   const String& name,   const unsigned int pageX,   const unsigned int pageZ,  
      62   const AxisAlignedBox &bounds ) :
           Renderable(   ),  
           MovableObject(  name ),  
           mParent(  pageMgr ),  
           mX(  pageX ),  
           mZ(  pageZ ),  
           mBounds(  bounds ),  
           mCurrVertexes (  0 ),  
           mCurrIndexes (  0 )
           {
           // No shadow projection
           MovableObject::mCastShadows = false;
           // Default query flags to top bit so users can exclude it if they wish
           //MovableObject::mQueryFlags = SceneManager::WORLD_GEOMETRY_QUERY_MASK;
          
           // Setup render op
           mCurrIndexes = new IndexData(   );
          
           const unsigned int Numtiles = mParent->getOptions(   )->NumTiles + 1;
           const size_t new_length = (  (  Numtiles - 1 ) * (  Numtiles - 1 ) * 2 * 2 * 2 );
           mCurrIndexes->indexCount = new_length;
           mCurrIndexes->indexStart = 0;
           mCurrIndexes->indexBuffer =
           HardwareBufferManager::getSingleton(   ).createIndexBuffer(  
           HardwareIndexBuffer::IT_16BIT,  
           new_length,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
          
           mCurrVertexes = new VertexData(   );
           mCurrVertexes->vertexStart = 0;
           mCurrVertexes->vertexCount = Numtiles * Numtiles + 1;
          
          
           // Vertex declaration
           VertexDeclaration* decl = mCurrVertexes->vertexDeclaration;
           VertexBufferBinding* bind = mCurrVertexes->vertexBufferBinding;
          
           // Vertex buffer #1,   position
           // positions
           size_t offset = 0;
           decl->addElement(  MAIN_BINDING,   0,   VET_FLOAT3,   VES_POSITION );
           offset += VertexElement::getTypeSize (  VET_FLOAT3 );
           decl->addElement(  MAIN_BINDING,   offset,   VET_FLOAT2,   VES_TEXTURE_COORDINATES,   0 );
           offset += VertexElement::getTypeSize(  VET_FLOAT2 );
          
           HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton (   ).createVertexBuffer(  
           decl->getVertexSize (  MAIN_BINDING ),  
           mCurrVertexes->vertexCount,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
           bind->setBinding(  MAIN_BINDING,   vbuf );
          
          
           }
          
           //-----------------------------------------------------------------------
     119   PagingLandScapePageRenderable::~PagingLandScapePageRenderable(   )
           {
           delete mCurrVertexes;
           delete mCurrIndexes;
          
           mMaterial.setNull(   );
           }
          
           //-----------------------------------------------------------------------
     128   void PagingLandScapePageRenderable::load(   )
           {
          
           // case renderable was queued before page was unloaded
           // when loaded,   page exists no more.
          
           VertexDeclaration* decl = mCurrVertexes->vertexDeclaration;
           VertexBufferBinding* bind = mCurrVertexes->vertexBufferBinding;
          
           const VertexElement* poselem = decl->findElementBySemantic(  VES_POSITION );
           const VertexElement* texelem = decl->findElementBySemantic(  VES_TEXTURE_COORDINATES,   0 );
          
          
           HardwareVertexBufferSharedPtr vVertices = bind->getBuffer(  MAIN_BINDING );
           uchar* pMain = static_cast<uchar*>(  vVertices->lock(  HardwareBuffer::HBL_DISCARD ) );
          
           const unsigned int Numtiles = mParent->getOptions(   )->NumTiles + 1;
          
           const Real invpagesizeX = 1.0f / (  (  Numtiles - 1 ) * mParent->getOptions(   )->world_width );
           const Real invpagesizeZ = 1.0f / (  (  Numtiles - 1 )* mParent->getOptions(   )->world_height );
          
           const Real texOffsetX = mX * (  Numtiles - 1 ) * invpagesizeX;
           const Real texOffsetZ = mZ * (  Numtiles - 1 ) * invpagesizeZ;
          
          
           const Real scale_x = mOpt->scale.x * (  mOpt->TileSize - 1 );
           const Real scale_z = mOpt->scale.z * (  mOpt->TileSize - 1 );
           unsigned int i,   j;
           for (  j = 0; j < Numtiles ; j ++ )
           {
           // This allow to reuse the variables in the loop
           const Real h_pos = j * scale_z;
           const Real Tex_pos = texOffsetZ + j * invpagesizeZ;
          
           for (  i = 0; i < Numtiles; i ++ )
           {
           // vertices are relative to the scene node
          
           float *pPos;
          
           poselem->baseVertexPointerToElement(  pMain,   &pPos );
          
           *pPos++ = static_cast <float> (  i * scale_x ); //X
           *pPos++ = static_cast <float> (  0.0 ); //Y
           *pPos = static_cast <float> (  h_pos ); //Z
          
           float *pTex;
           texelem->baseVertexPointerToElement(  pMain,   &pTex );
          
           *pTex++ = static_cast <float> (  texOffsetX + i * invpagesizeX );
           *pTex = static_cast <float> (  Tex_pos );
          
           pMain += vVertices->getVertexSize (   );
          
           }
           }
           // Unlock the buffers
           vVertices->unlock(   );
          
          
           ushort* pIdx = static_cast<ushort*>(  mCurrIndexes->indexBuffer->lock(  0,  
           mCurrIndexes->indexBuffer->getSizeInBytes(   ),  
           HardwareBuffer::HBL_DISCARD ) );
           unsigned int height_count = 0;
           unsigned int NumIndexes = 0;
           for (  j = 0; j < Numtiles - 1; j ++ )
           {
           for (  i = 0; i < Numtiles - 1; i ++ )
           {
           // Indexes
           *pIdx++ = static_cast<ushort> (  i + height_count ); NumIndexes++;
           *pIdx++ = static_cast<ushort> (  i + height_count + Numtiles ); NumIndexes++;
           *pIdx++ = static_cast<ushort> (  i + 1 + height_count ); NumIndexes++;
          
           *pIdx++ = static_cast<ushort> (  i + height_count + Numtiles ); NumIndexes++;
           *pIdx++ = static_cast<ushort> (  i + 1 + height_count + Numtiles ); NumIndexes++;
           *pIdx++ = static_cast<ushort> (  i + 1 + height_count ); NumIndexes++;
          
           }
           height_count += Numtiles;
           }
          
           mCurrIndexes->indexBuffer->unlock(   );
          
           assert (  NumIndexes < mCurrIndexes->indexCount );
          
          
           const Real max =
           mParent->getSceneManager(   )->getData2DManager(   )->getMaxHeight(  mX,  
           mZ );
          
           // Calculate the bounding box for this renderable
           mBounds.setExtents(  0.0f,  
           0.0f,  
           0.0f,  
           0.0f + Numtiles * scale_x,  
           max,  
           0.0f + Numtiles * scale_z );
          
           assert (  mParentNode );
           mCenter = mBounds.getCenter(   ) + mParentNode->getWorldPosition(   );
           mWorldBoundingSphere.setCenter(  mCenter );
           mWorldBoundingSphere.setRadius(  mBounds.getMaximum(   ).length(   ) );
          
           mParentNode->needUpdate(   );
          
          
           MovableObject::setRenderQueueGroup(  mParent->getSceneManager(   )->getPageManager(   )->getRenderQueueGroupID(   ) );
          
           }
           //-----------------------------------------------------------------------
     239   void PagingLandScapePageRenderable::_updateRenderQueue(  RenderQueue* queue )
           {
           queue->addRenderable(  this );
           }
           //-----------------------------------------------------------------------
     244   Technique* PagingLandScapePageRenderable::getTechnique(  void ) const
           {
           return mMaterial->getBestTechnique (   );
           }
           //-----------------------------------------------------------------------
     249   const LightList& PagingLandScapePageRenderable::getLights(  void ) const
           {
          #ifdef PLSM2_EIHORT
           return queryLights(   );
          #else
           return MovableObject::getParentSceneNode(   )->findLights(  this->getBoundingRadius(   ) );
          #endif
           }
           //-----------------------------------------------------------------------
     258   Real PagingLandScapePageRenderable::getSquaredViewDepth(  const Camera* cam ) const
           {
           // Use squared length to avoid square root
           return (  mCenter -
           cam->getDerivedPosition (   ) ).squaredLength(   );
           }
          
           //-----------------------------------------------------------------------
     266   Real PagingLandScapePageRenderable::getBoundingRadius(  void ) const
           {
           return mWorldBoundingSphere.getRadius(   );
           }
           //-----------------------------------------------------------------------
     271   void PagingLandScapePageRenderable::getRenderOperation(  RenderOperation& op )
           {
           //setup indexes for vertices and uvs...
           op.useIndexes = true;
           op.operationType = RenderOperation::OT_TRIANGLE_LIST;
           op.vertexData = mCurrVertexes;
           op.indexData = mCurrIndexes;
          
           }
           //-----------------------------------------------------------------------
     281   void PagingLandScapePageRenderable::getWorldTransforms(  Matrix4* xform ) const
           {
           *xform = mParentNode->_getFullTransform(   );
           }
           //-----------------------------------------------------------------------
     286   const Quaternion& PagingLandScapePageRenderable::getWorldOrientation(  void ) const
           {
           return mParentNode->_getDerivedOrientation(   );
           }
           //-----------------------------------------------------------------------
     291   const Vector3& PagingLandScapePageRenderable::getWorldPosition(  void ) const
           {
           return mCenter;
           }
           //-----------------------------------------------------------------------
     296   void PagingLandScapePageRenderable::setMaterial(  const MaterialPtr &mat )
           {
           mMaterial = mat;
           }
           //-----------------------------------------------------------------------
     301   uint32 PagingLandScapePageRenderable::getTypeFlags(  void ) const
           {
           // return world flag
           return SceneManager::WORLD_GEOMETRY_TYPE_MASK;
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapePrecompiledHeaders.cpp

       1  /***************************************************************************
          OgrePagingLandScapePrecompiledHeaders.cpp - description
          -------------------
          copyright : (  C ) 2006 Tuan Kuranes
          email : tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeRaySceneQuery.cpp

       1  /***************************************************************************
          OgrePagingLandScapeRaySceneQuery.cpp - description
          -------------------
          begin : Fri Sep 10 2003
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreEntity.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreSceneManager.h"
          #include "OgrePagingLandScapeOctreeSceneManager.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeRaySceneQuery.h"
          
          namespace Ogre
          {
          
          //----------------------------------------------------------------------------
          // This function return the vertex interpolated height.
          // Supplied by Praetor. Thanks a lot. ]: )
      39  void PagingLandScapeRaySceneQuery::execute(  RaySceneQueryListener* listener )
          {
           ///Ember start
           ///Make sure that there really is some world geometry first
           if (  (  static_cast<PagingLandScapeSceneManager*>(  mParentSceneMgr )->mWorldGeomIsSetup ) && (  getQueryTypeMask(   ) & SceneManager::WORLD_GEOMETRY_TYPE_MASK ) )
           ///Ember end
           {
           mWorldFrag.fragmentType = SceneQuery::WFT_SINGLE_INTERSECTION;
          
           const Vector3& dir = mRay.getDirection(   );
           const Vector3& origin = mRay.getOrigin(   );
          
           PagingLandScapeSceneManager* mSceneMgr = static_cast<PagingLandScapeSceneManager*>(  mParentSceneMgr );
           if (  mWorldFragmentType & WFT_SINGLE_INTERSECTION )
           {
           if (  dir == Vector3::UNIT_Y ||
           dir == Vector3::NEGATIVE_UNIT_Y )
           {
           Real height;
           if (  mSceneMgr->getOptions(   )->queryNoInterpolation )
           height = mSceneMgr->getData2DManager(   )->getWorldHeight(  origin.x,   origin.z );
           else
           height = mSceneMgr->getData2DManager(   )->getInterpolatedWorldHeight(  origin.x,   origin.z );
          
           mWorldFrag.singleIntersection.x = origin.x;
           mWorldFrag.singleIntersection.z = origin.z;
           mWorldFrag.singleIntersection.y = height;
          
           mWorldFrag.singleIntersection += mSceneMgr->getOptions(   )->position; //consider terrain offset
          
           listener->queryResult(  &mWorldFrag,   (  Math::Abs(  mWorldFrag.singleIntersection.y - origin.y ) ) );
           return;
           }
           else if (  mSceneMgr->intersectSegmentTerrain(  
           origin,  
           dir * mSceneMgr->getOptions(   )->queryResolutionFactor,  
           &mWorldFrag.singleIntersection ) )
           {
           listener->queryResult(  &mWorldFrag,   (  mWorldFrag.singleIntersection - origin ).length(   ) );
           ///Ember start
           PagingLandScapeOctreeRaySceneQuery::execute(  listener );
           ///Ember end
           return;
           }
           }
           else
           {
           // multiple terrain intersection
           const Vector3 raydir (  mRay.getDirection(   ) );
           const Vector3 raymove (  raydir * mSceneMgr->getOptions(   )->queryResolutionFactor );
           const Real distmove = mSceneMgr->getOptions(   )->queryResolutionFactor;
           const Real maxHeight = mSceneMgr->getData2DManager(   )->getMaxHeight (   );
           const Real MaxTerrainX = mSceneMgr->getOptions(   )->maxScaledX;
           const Real MaxTerrainZ = mSceneMgr->getOptions(   )->maxScaledZ;
          
           Vector3 ray (  mRay.getOrigin(   ) );
           Real dist = 0.0f;
          
           // while ray is inside or ray is outside but raydir going inside
           while (  (  ray.y < 0 && raydir.y > 0 ) ||
           (  ray.y > maxHeight && raydir.y < 0 ) ||
           (  ray.x < -MaxTerrainX && raydir.x > 0 ) ||
           (  ray.x > MaxTerrainX && raydir.x < 0 ) ||
           (  ray.z < -MaxTerrainZ && raydir.z > 0 ) ||
           (  ray.z > MaxTerrainZ && raydir.z < 0 ) )
           {
           ray += raymove;
           dist += distmove;
           if (  ray.y < maxHeight )// no need to do complex tests
           {
           const Vector3 land (  getHeightAt(  ray ) );
           if (  ray.y < land.y )
           {
           WorldFragment* frag = new WorldFragment(   );
           //fragmentList.push_back(  frag );
          
           frag->fragmentType = SceneQuery::WFT_SINGLE_INTERSECTION;
           frag->singleIntersection = land;
          
           if (  !listener->queryResult(  frag,   dist ) )
           return;
           }
           }
           }
           }
          
           }
           // if anything else is queried,   ask underlying Octree Scene Manager.
           PagingLandScapeOctreeRaySceneQuery::execute(  listener );
          }
          //----------------------------------------------------------------------------
     130  Vector3 PagingLandScapeRaySceneQuery::getHeightAt(  const Vector3& origin ) const
          {
          
           PagingLandScapeSceneManager * mSceneMgr = static_cast<PagingLandScapeSceneManager*>(  mParentSceneMgr );
           return Vector3(  origin.x,   mSceneMgr->getData2DManager(   )->getInterpolatedWorldHeight(  origin.x,   origin.z ),   origin.z );
          
          }
          
          } // namespace Ogre

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeRenderable.cpp

          /***************************************************************************
           OgrePagingLandScapeRenderable.cpp - description
           -------------------
           begin : Thu Feb 27 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreRoot.h"
          #include "OgreHardwareBufferManager.h"
          
          #include "OgreLogManager.h"
          
          #include "OgreStringConverter.h"
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreMovableObject.h"
          #include "OgreAxisAlignedBox.h"
          
          
          #include "OgreSceneNode.h"
          
          #include "OgreSimpleRenderable.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          
          #include "OgrePagingLandScapeRenderable.h"
          #include "OgrePagingLandScapeRenderableManager.h"
          
          //caches
          #include "OgrePagingLandScapeIndexBuffer.h"
          #include "OgrePagingLandScapeTextureCoordinatesManager.h"
          
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapeTileInfo.h"
          
          #include "OgrePagingLandScapeData2D.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeListenerManager.h"
          
          #include "OgrePagingLandScapePageManager.h"
          #include "OgrePagingLandScapeHorizon.h"
          
          namespace Ogre
          {
          
          
          // Renderable Buffer definitions
          #define MAIN_BINDING 0
          #define DELTA_BINDING 2
          #define TEXTURE_BINDING 1
          
           String PagingLandScapeRenderable::mType = "PagingLandScapeRenderable";
          
           //-----------------------------------------------------------------------
           //-----------------------------------------------------------------------
      70   PagingLandScapeRenderable::PagingLandScapeRenderable(  PagingLandScapeRenderableManager *renderableMgr ) :
           Renderable(   ),  
           MovableObject(   ),  
           mParent(  renderableMgr ),  
           mCurrVertexes (  0 ),  
           mCurrIndexes (  0 ),  
           mInfo (  0 ),  
           mMaterialLODIndex (  0 ),  
           mInUse (  false ),  
           mIsLoaded (  false ),  
           mDeltaBuffers (  0 ),  
           mLastNextLevel (  -1 ),  
           mLODMorphFactor (  0.0f ),  
      83   mHeightfield (  0 ),  
           mMinLevelDistSqr (  0 ),  
           mRenderLevel (  -1 ),  
           mIsRectModified (  false ),  
           mRect (  0,   0,   0,   0,   0,   1 ),  
           mForcedMaxLod (  false )
           ///Ember added start
           ,   mNeedReload(  false )
           ///Ember added stop
          
           {
           // No shadow projection
           MovableObject::mCastShadows = false;
          
           // Default query flags to top bit so users can exclude it if they wish
           MovableObject::mQueryFlags = SceneManager::WORLD_GEOMETRY_TYPE_MASK;
           MovableObject::setRenderQueueGroup(  
           mParent->getSceneManager(   )->getPageManager(   )->getRenderQueueGroupID(   ) );
          
           for (  unsigned int i = 0; i < 4; i++ )
           mNeighbors[ i ] = 0;
          
           // Setup render op
           mCurrVertexes = new VertexData(   );
           mCurrVertexes->vertexStart = 0;
           const unsigned int tileSize = mParent->getOptions (   )->TileSize;
           mCurrVertexes->vertexCount = tileSize * tileSize;
          
           // Vertex declaration
           VertexDeclaration* decl = mCurrVertexes->vertexDeclaration;
           VertexBufferBinding* bind = mCurrVertexes->vertexBufferBinding;
          
          
           // Vertex buffer #1,   position
           // positions
           size_t offset = 0;
           VertexElementType t;
           if (  mParent->getOptions(   )->VertexCompression )
           {
           t = VET_SHORT2;
           }
           else
           {
           t = VET_FLOAT3;
           }
           decl->addElement(  MAIN_BINDING,   0,   t,   VES_POSITION );
           offset += VertexElement::getTypeSize (  t );
           if (  mParent->getOptions(   )->normals )
           {
           decl->addElement(  MAIN_BINDING,   offset,   VET_FLOAT3,   VES_NORMAL );
           offset += VertexElement::getTypeSize (  VET_FLOAT3 );
           }
           if (  mParent->getOptions(   )->colored )
           {
           decl->addElement (  MAIN_BINDING,   offset,   VET_COLOUR,   VES_DIFFUSE );
           offset += VertexElement::getTypeSize (  VET_COLOUR );
           }
          
          
           HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton (   ).createVertexBuffer(  
           decl->getVertexSize (  MAIN_BINDING ),  
           mCurrVertexes->vertexCount,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
           //HardwareBuffer::HBU_STATIC );
          
           bind->setBinding(  MAIN_BINDING,   vbuf );
          
           if (  mParent->getOptions (   )->lodMorph )
           {
           // Create delta buffer for all except the lowest mipmap
           assert (  mParent->getOptions (   )->maxRenderLevel > 1 );
           const unsigned int maxmip = mParent->getOptions (   )->maxRenderLevel - 1;
           mDeltaBuffers = new HardwareVertexBufferSharedPtr[maxmip];
          
           // Create additional element for delta
           decl->addElement(  DELTA_BINDING,   0,   VET_SHORT2,   VES_BLEND_WEIGHTS );
           //decl->addElement(  DELTA_BINDING,   0,   VET_SHORT1,   VES_BLEND_WEIGHTS );
          
           //decl->addElement(  DELTA_BINDING,   0,   VET_FLOAT1,   VES_BLEND_WEIGHTS );
          
           //decl->addElement(  DELTA_BINDING,   0,   VET_SHORT1,   VES_TEXTURE_COORDINATES,   1 );
           //decl->addElement(  DELTA_BINDING,   0,   VET_SHORT2,   VES_TEXTURE_COORDINATES,   1 );
          
           for (  unsigned int k = 0; k < maxmip; k++ )
           {
           assert (  mDeltaBuffers[k].isNull(   ) );
           mDeltaBuffers[k] = createDeltaBuffer(   );
           }
           // NB binding is not set here,   it is set when deriving the LOD
           }
           //No need to set the indexData since it is shared from LandScapeIndexBuffer class
           mCustomGpuParameters = Vector4(  mParent->getOptions (   )->ScaledPageSizeX,  
           mParent->getOptions (   )->ScaledHeightY,  
           mParent->getOptions (   )->ScaledPageSizeZ,  
           mLODMorphFactor );
          
           mQueued = false;
           mParentTile = 0;
           }
           //-----------------------------------------------------------------------
     183   PagingLandScapeRenderable::~PagingLandScapeRenderable(   )
           {
           delete mCurrVertexes;
           delete [] mDeltaBuffers;
           }
          
           //------------------------------------------------------------------------
     190   void PagingLandScapeRenderable::uninit(   )
           {
           if (  mIsLoaded )
           unload (   );
          
           mParentTile = 0;
          
           mParent->freeRenderable(  this );
           mInfo = 0;
           mHeightfield = 0;
           mCurrIndexes = 0;
           mLastNextLevel = -1;
           mRenderLevel = -1;
           mVisible = false;
           mInUse = false;
           mMaterial.setNull(   );
           mLightListDirty = true;
           mQueued = false;
           mParentTile = 0;
           mMinLevelDistSqr = 0;
           }
           //-----------------------------------------------------------------------
     212   void PagingLandScapeRenderable::init(  PagingLandScapeTileInfo* info )
           {
           mMinLevelDistSqr = 0;
           mQueued = false;
           mParentTile = 0;
           mLightListDirty = true;
           mInfo = info;
           mInUse = true;
           mName = StringConverter::toString(  mInfo->mPageX ) + "." +
           StringConverter::toString(  mInfo->mPageZ ) + "." +
           StringConverter::toString(  mInfo->mTileX ) + "." +
           StringConverter::toString(  mInfo->mTileZ ) + "Rend";
          
           mForcedMaxLod = false;
           mUpperDistance = mParent->getOptions (   )->renderable_factor;
           mIsLoaded = false;
          
           //we can init texcoord buffer as it's data independent.
           VertexDeclaration * const decl = mCurrVertexes->vertexDeclaration;
           VertexBufferBinding * const bind = mCurrVertexes->vertexBufferBinding;
          
           // make sure buffer isn't binded to another texture coordinate buffer
           if (  decl->findElementBySemantic (  VES_TEXTURE_COORDINATES,   0 ) != 0 )
           {
           decl->removeElement(  VES_TEXTURE_COORDINATES,   0 );
           bind->unsetBinding (  TEXTURE_BINDING );
           }
          
           // Bind to an existing texture coordinate buffer if it exists
           // or create a new one for this (  x,  y ) combination tile position.
           //(  texture coordinate buffer are shared across buffers )
           const VertexElementType t = VET_FLOAT2;
           //const VertexElementType t = VET_SHORT2;
           decl->addElement(  TEXTURE_BINDING,   0,   t,   VES_TEXTURE_COORDINATES,   0 );
          
           bind->setBinding(  TEXTURE_BINDING,  
           mParent->getSceneManager(   )->getTextureCoordinatesManager(   )->getBuffer(  
           info->mTileX,  
           info->mTileZ ) );
           }
           //-----------------------------------------------------------------------
     253   bool PagingLandScapeRenderable::load(   )
           {
           assert (  mQueued || mNeedReload );
           assert (  mInfo );
          
           //if (  !mInUse )
           //{
           // if not in use,   do not load.
           //if (  mIsLoaded )
           // return true;
           //else
           // return false;
           //}
           // case renderable was queued before page was unloaded
           // when loaded,   page exists no more.
           PagingLandScapeData2D *data = mParent->getSceneManager(   )->getData2DManager(   )->getData2D(  mInfo->mPageX,   mInfo->mPageZ );
           // Page could be unloaded since renderable queued...
           if (  data == 0 || !data->isLoaded(   ) )
           return false;
           mHeightfield = data->getHeightData (   );
           if (  mHeightfield == 0 )
           return false;
          
           const bool b_lit = mParent->getOptions (   )->normals;
          
           const bool b_coverage = mParent->getOptions (   )->coverage_vertex_color;
           const bool b_colored = mParent->getOptions (   )->colored;
          
           const Real scale_x = mParent->getOptions (   )->scale.x;
           const Real scale_z = mParent->getOptions (   )->scale.z;
          
           VertexDeclaration* decl = mCurrVertexes->vertexDeclaration;
           VertexBufferBinding* bind = mCurrVertexes->vertexBufferBinding;
          
           const VertexElement* poselem = decl->findElementBySemantic(  VES_POSITION );
           const VertexElement* colorelem;
           if (  b_colored )
           colorelem= decl->findElementBySemantic(  VES_DIFFUSE );
          
           const VertexElement* normelem;
           if (  b_lit )
           normelem = decl->findElementBySemantic(  VES_NORMAL );
          
          
           // Calculate the offset in the data
           Real min,   max;
           const unsigned int tileSize = mParent->getOptions (   )->TileSize;
          
           Image::Box oldrect = mRect;
           if (  !mIsRectModified )
           {
           mRect.left = 0;
           mRect.right = tileSize;
           mRect.top = 0;
           mRect.bottom = tileSize;
          
           // Make sure we get a new min and max
           min = mParent->getSceneManager(   )->getData2DManager(   )->getMaxHeight (   );
           max = 0.0f;
           }
           else
           {
           mRect.right += 1;
           mRect.bottom += 1;
          
          
          // LogManager::getSingleton(   ).logMessage(  LML_CRITICAL,  
          // String(  "PLSM2 : Deformation on tile " ) + StringConverter::toString(  mInfo->tileX ) + ",   " + StringConverter::toString(  mInfo->tileZ )
          // + " : " + StringConverter::toString(  mRect.left ) + " - " + StringConverter::toString(  mRect.right )
          // + " | " + StringConverter::toString(  mRect.top ) + " - " + StringConverter::toString(  mRect.bottom ) );
          
           // Make sure we get a new min and max
           // only if modified heights exceed current bounds
           min = mBounds.getMinimum(   ).y;
           max = mBounds.getMaximum(   ).y;
           }
          
           const unsigned int offSetX = static_cast <unsigned int> (  mInfo->mTileX * (  tileSize - 1 ) + mRect.left );
           const unsigned int endx = static_cast <unsigned int> (  offSetX + (  mRect.right - mRect.left ) );
          
           const unsigned int offSetZ = static_cast <unsigned int> (  mInfo->mTileZ * (  tileSize - 1 ) + mRect.top );
           const unsigned int endz = static_cast <unsigned int> (  offSetZ + (  mRect.bottom - mRect.top ) );
          
          
           const double inv_scale = 65535.0 / mParent->getOptions (   )->scale.y;
          
           const unsigned int pageSize = mParent->getOptions (   )->PageSize;
           const Real * const ogre_restrict mheightField = mHeightfield;
           const bool vs = mParent->getOptions(   )->VertexCompression;
          
           HardwareVertexBufferSharedPtr vVertices = bind->getBuffer(  MAIN_BINDING );
           const size_t VertexSize = vVertices->getVertexSize (   );
           const size_t VertexTileSize = VertexSize * tileSize;
           uchar* pMain = static_cast<uchar*>(  
           vVertices->lock(  VertexTileSize * mRect.top + mRect.left * VertexSize,   // offset
           VertexTileSize *(  mRect.bottom - mRect.top ) - (  tileSize - mRect.right ) * VertexSize,  //length
           HardwareBuffer::HBL_DISCARD ) );// buffer mode
          
           // initial up-down shift and left-right shift
           const Real * const heightField = mheightField + offSetZ * pageSize;
           unsigned int K_heightFieldPos = 0;
           for (  unsigned int k = offSetZ; k < endz; k ++ )
           {
           // This allow to reuse the variables in the loop
           const Real k_pos = k * scale_z;
           uchar *pMainLocal = pMain;
           for (  unsigned int i = offSetX; i < endx; i ++ )
           {
           const Real height = heightField[ i + K_heightFieldPos ];
          
           min = std::min (  height,   min );
           max = std::max (  height,   max );
          
           // vertices are relative to the scene node
           if (  vs )
           {
           ushort *pPos;
           poselem->baseVertexPointerToElement(  pMainLocal,   &pPos );
           *pPos = static_cast<short> (  (  height * inv_scale ) - 32768 ); //Y
           }
           else
           {
           float *pPos;
          
           poselem->baseVertexPointerToElement(  pMainLocal,   &pPos );
          
           *pPos++ = static_cast <float> (  i * scale_x ); //X
           *pPos++ = static_cast <float> (  height ); //Y
           *pPos = static_cast <float> (  k_pos ); //Z
           }
          
           // normals
           if (  b_lit )
           {
           float *pNorm;
           normelem->baseVertexPointerToElement(  pMainLocal,   &pNorm );
          
           const Vector3 norm = data->getNormal (  i,   k );
           *pNorm++ = static_cast <float> (  norm.x );
           *pNorm++ = static_cast <float> (  norm.y );
           *pNorm = static_cast <float> (  norm.z );
          
           }
           if (  b_colored )
           {
           ColourValue RGBA_precalc;
          
           if (  b_coverage )
           {
           RGBA_precalc = data->getCoverage (  i,   k );
           Real a1;
           const Real a2 = 1.0f - RGBA_precalc.a;
           if (  a2 != 0.0f )
           {
           a1 = RGBA_precalc.r / a2 ;
           }
           else
           a1 = 0.0f;
          
          
           RGBA_precalc.r = a1;
           RGBA_precalc.g = a1;
           RGBA_precalc.b = a1;
           RGBA_precalc.a = a2;
           }
           RGBA *pColor;
           colorelem->baseVertexPointerToElement(  pMainLocal,   &pColor );
           Root::getSingleton(   ).convertColourValue (  RGBA_precalc,  
           pColor );
           }
           pMainLocal += VertexSize;
           }
           pMain += VertexTileSize;;
           K_heightFieldPos += pageSize;
           }
          
           // Unlock the buffers
           vVertices->unlock(   );
          
           // Calculate the bounding box for this renderable
           if (  !mIsRectModified )
           {
           mBounds.setExtents(  offSetX * scale_x,  
           min,  
           offSetZ * scale_z,  
           endx * scale_x,  
           max,  
           endz * scale_z );
           } // if (  !mIsRectModified )
           else
           {
           const Vector3 maxbound = mBounds.getMaximum(   );
           const Vector3 minbound = mBounds.getMinimum(   );
           mBounds.setExtents(  minbound.x,   min,   minbound.z,  
           maxbound.x,   max,   maxbound.z );
           }
           mBoundingRadius = Math::Sqrt(  
           Math::Sqr(  max - min ) +
           Math::Sqr(  (  endx - 1 - offSetX ) * scale_x ) +
           Math::Sqr(  (  endz - 1 - offSetZ ) * scale_z ) ) / 2;
          
          
          
          
           if (  mParent->getOptions (   )->VisMap )
           mParent->getSceneManager(   )->getHorizon(   )->registerMinMaxHeightTile (  mInfo,   min,   max );
          
           mMinLevelDistSqr = 0;
           _calculateMinLevelDist2(  mParent->getOptions (   )->CFactor );
           if (  !mIsLoaded )
           {
           mParent->getSceneManager(   )->getListenerManager(   )->fireTileLoaded (  mInfo->mPageX,   mInfo->mPageZ,  
           mInfo->mTileX,   mInfo->mTileZ,   mParentTile->getWorldBbox (   ) );
           mIsLoaded = true;
           }
           else if (  mNeedReload )
           {
           mParent->getSceneManager(   )->getListenerManager(   )->fireTileDeformed (  mInfo->mPageX,   mInfo->mPageZ,  
           mInfo->mTileX,   mInfo->mTileZ,   mParentTile->getWorldBbox (   ) );
           mNeedReload = false;
           }
           mRect.left = 0;
           mRect.right = 0;
           mRect.top = 0;
           mRect.bottom = 0;
           mIsRectModified = false;
           mVisible = false;
           mChangedRenderLevel = false;
           mIndex = 0;
           return true;
           }
          
           //-----------------------------------------------------------------------
     486   void PagingLandScapeRenderable::unload(   )
           {
           assert (  mIsLoaded && mInfo );
           assert (  !mQueued );
           if (  mNeighbors[SOUTH] )
           mNeighbors[SOUTH]->_setNeighbor (  NORTH,   0 );
           if (  mNeighbors[NORTH] )
           mNeighbors[NORTH]->_setNeighbor (  SOUTH,   0 );
           if (  mNeighbors[EAST] )
           mNeighbors[EAST]->_setNeighbor (  WEST,   0 );
           if (  mNeighbors[WEST] )
           mNeighbors[WEST]->_setNeighbor (  EAST,   0 );
           for (  unsigned int i = 0; i < 4; i++ )
           {
           mNeighbors[i] = 0;
           }
           assert (  mParentNode );
           {
           SceneNode * const s = static_cast <SceneNode*>(  mParentNode );
           s->detachObject (  mName );
           s->needUpdate (   );
           }
           mInUse = false;
           mIsLoaded = false;
           mInfo = 0;
           mLastNextLevel = -1;
           mRenderLevel = -1;
           mVisible = false;
           mNeedReload = false;
           mRect.left = 0;
           mRect.right = 0;
           mRect.top = 0;
           mRect.bottom = 0;
           mIsRectModified = false;
           mMinLevelDistSqr = 0;
           }
           //-----------------------------------------------------------------------
     523   void PagingLandScapeRenderable::_notifyCurrentCamera(  Camera* cam )
           {
           if (  mInUse && mIsLoaded && mVisible )
           {
           // if some deformation
           if (  mNeedReload )
           {
           // if between deformation and now,   tile have been unloaded
           if (  !load (   ) )
           {
           mVisible = false;
           return;
           }
           }
           // Horizon occlusion. (  needs data to be loaded or reloaded )
           if (  mParent->getOptions (   )->VisMap )
           {
           PagingLandScapeCamera* plscam = static_cast<PagingLandScapeCamera*> (  cam );
           if(  !mParent->getSceneManager(   )->getHorizon(   )->IsTileVisible(  plscam,   mInfo ) )
           {
           mVisible = false;
           return;
           }
           }
           const int oldRenderLevel = mRenderLevel;
           if (  mForcedMaxLod )
           {
           mRenderLevel = 0;
           mMaterialLODIndex = 0;
           }
           else
           {
           // get distance between renderable and tile and adjust it by the camera bias
           mDistanceToCam = (  getWorldPosition(   ) - cam -> getDerivedPosition(   ) ).squaredLength(   ) * cam->getLodBias (   );
          
           // Material LOD
           if (  !mMaterial.isNull(   )
           && mMaterial->getNumLodLevels(  MaterialManager::getSingleton(   )._getActiveSchemeIndex(   ) ) > 1
            )
           {
           const unsigned short LODIndex = mMaterial->getLodIndexSquaredDepth (  mDistanceToCam );
           if (  LODIndex != mMaterialLODIndex )
           mMaterialLODIndex = LODIndex;
           }
           mRenderLevel = -1;
           const int maxMipmap = static_cast <int> (  mParent->getOptions (   )->maxRenderLevel );
           assert (  mMinLevelDistSqr );
           for (  int i = 0; i < maxMipmap; i++ )
           {
          
           if (  (  *mMinLevelDistSqr )[ i ] > mDistanceToCam )
           {
           mRenderLevel = i - 1;
           break;
           }
           }
           if (  mRenderLevel < 0 )
           mRenderLevel = maxMipmap - 1;
          
           // Get the next LOD level down
           if (  mParent->getOptions (   )->lodMorph )
           {
           // Get the next LOD level down
           const int nextLevel = mNextLevelDown[mRenderLevel];
           if (  nextLevel == 0 )
           {
           // No next level,   so never morph
           mLODMorphFactor = 0.0f;
           mCustomGpuParameters.w = mLODMorphFactor;
           }
           else
           {
           // Set the morph such that the morph happens in the last 0.25 of
           // the distance range
           const Real range = (  *mMinLevelDistSqr )[nextLevel] - (  *mMinLevelDistSqr )[mRenderLevel];
           if (  range )
           {
           const Real percent = (  mDistanceToCam - (  *mMinLevelDistSqr )[mRenderLevel] ) / range;
           // scale result so that msLODMorphStart == 0,   1 == 1,   clamp to 0 below that
           const Real rescale = 1.0f / (  1.0f - mParent->getOptions (   )->lodMorphStart );
           mLODMorphFactor = std::max(  (  percent - mParent->getOptions (   )->lodMorphStart ) * rescale,  
           static_cast<Real>(  0.0f ) );
           mCustomGpuParameters.w = mLODMorphFactor;
           assert (  mLODMorphFactor <= 1.0f );
           }
           else
           {
           // Identical ranges
           mLODMorphFactor = 0.0f;
           mCustomGpuParameters.w = mLODMorphFactor;
           }
           }
           // Bind the correct delta buffer if it has changed
           // nextLevel - 1 since the first entry is for LOD 1 (  since LOD 0 never needs it )
           if (  mLastNextLevel != nextLevel )
           {
           assert (  mDeltaBuffers );
          
           if (  nextLevel > 1 )
           {
           mCurrVertexes->vertexBufferBinding->setBinding(  DELTA_BINDING,  
           mDeltaBuffers[nextLevel - 1] );
           }
           else
           {
           // bind dummy (  in case bindings checked )
           mCurrVertexes->vertexBufferBinding->setBinding(  DELTA_BINDING,  
           mDeltaBuffers[0] );
           }
           }
           mLastNextLevel = nextLevel;
           }
           }
           //// If we change LOD update self and neighbor
           if (  oldRenderLevel != mRenderLevel || mCurrIndexes == 0 )
           {
           update (   );
           for (  unsigned int i = 0; i < 4; i++ )
           {
           PagingLandScapeRenderable * const r = mNeighbors[i];
           if (  r && r->isLoaded (   ) && r->isVisible (   ) )
           r->update (   );
           }
           }
           mVisible = true;
           }
           else
           {
           mVisible = false;
           }
           }
           //-----------------------------------------------------------------------
     655   void PagingLandScapeRenderable::update(   )
           {
           mChangedRenderLevel = true;
           }
           //-----------------------------------------------------------------------
     660   void PagingLandScapeRenderable::_updateRenderQueue(  RenderQueue* queue )
           {
           // Notify need to calculate light list when our sending to render queue
           mLightListDirty = true;
           assert (  mInUse && mParentNode && mIsLoaded && mVisible );
          
           if (  mChangedRenderLevel )
           {
           for (  unsigned int i = 0; i < 4; i++ )
           {
           PagingLandScapeRenderable * const r = mNeighbors[i];
           if (  r && r->isLoaded (   ) && r->isVisible (   ) )
           r->update (   );
           }
           }
           queue->addRenderable(  this );
           }
           //-----------------------------------------------------------------------
     678   Technique* PagingLandScapeRenderable::getTechnique(  void ) const
           {
           return mMaterial->getBestTechnique (  mMaterialLODIndex );
           }
           //-----------------------------------------------------------------------
     683   const LightList& PagingLandScapeRenderable::getLights(  void ) const
           {
           if (  mLightListDirty )
           {
           getParentSceneNode(   )->getCreator(   )->_populateLightList(  
           mCenter,  
           this->getBoundingRadius(   ),  
           mLightList );
           mLightListDirty = false;
           }
           return mLightList;
           }
           //-----------------------------------------------------------------------
     696   Real PagingLandScapeRenderable::getSquaredViewDepth(  const Camera* cam ) const
           {
           // Use squared length to avoid square root
           return (  PagingLandScapeRenderable::getWorldPosition(   ) -
           cam->getDerivedPosition (   ) ).squaredLength(   );
           }
          
           //-----------------------------------------------------------------------
     704   void PagingLandScapeRenderable::getRenderOperation(  RenderOperation& op )
           {
           assert (  mIsLoaded );
           assert (  mInUse );
           assert (  mVisible );
           assert (  mParentNode );
          
           //setup indexes for vertices and uvs...
           op.useIndexes = true;
           op.operationType = RenderOperation::OT_TRIANGLE_LIST;
           op.vertexData = mCurrVertexes;
          
           if (  mChangedRenderLevel )
           {
           mIndex = mParent->getSceneManager(   )->getIndexBufferManager(   )->getIndexData(  mRenderLevel,  
           mNeighbors );
           mChangedRenderLevel = false;
           }
           assert (  mIndex );
           op.indexData = mIndex;
           mParent->addVisible (   );
           }
           //-----------------------------------------------------------------------
     727   void PagingLandScapeRenderable::getWorldTransforms(  Matrix4* xform ) const
           {
           *xform = mParentNode->_getFullTransform(   );
           }
           //-----------------------------------------------------------------------
     732   const Quaternion& PagingLandScapeRenderable::getWorldOrientation(  void ) const
           {
           return mParentNode->_getDerivedOrientation(   );
           }
           //-----------------------------------------------------------------------
     737   const Vector3& PagingLandScapeRenderable::getWorldPosition(  void ) const
           {
           return mCenter;
           }
           //-----------------------------------------------------------------------
     742   void PagingLandScapeRenderable::setMaterial(  const MaterialPtr &mat )
           {
           mMaterial = mat;
           }
           //-----------------------------------------------------------------------
     747   void PagingLandScapeRenderable::_calculateMinLevelDist2(  const Real C )
           {
           //level 0 has no delta.
           PagingLandScapeOptions * const opt = mParent->getOptions(   );
           const bool lodMorph = opt->lodMorph;
           const bool roughnessLod = opt->roughnessLod;
          
           bool doComputeMinLevelDistSqr = mIsRectModified;
           if (  mMinLevelDistSqr == 0 )
           {
           if (  mInfo->mMinLevelDistSqr == 0 )
           {
           mMinLevelDistSqr = new std::vector<Real>(   );
           const size_t numLod = mParent->getOptions (   )->maxRenderLevel;
           mMinLevelDistSqr->reserve(  numLod );
           mMinLevelDistSqr->resize(  numLod );
           doComputeMinLevelDistSqr = true;
          
           mInfo->mMinLevelDistSqr = mMinLevelDistSqr;
           }
           else
           {
           // already computed and in cache.
           mMinLevelDistSqr = mInfo->mMinLevelDistSqr;
           fillNextLevelDown(   );
          
           if (  !doComputeMinLevelDistSqr )
           {
           // no deformation modified
           // no need to recompute it.
           if (  !lodMorph )
           {
           // already computed and in cache.
           // and no lodMorphing...
           // so no need to recompute
           return;
           }
           }
           }
           }
           if (  doComputeMinLevelDistSqr )
           (  *mMinLevelDistSqr )[ 0 ] = 0.0f;
          
           const double inv_scale = 65535.0 / opt->scale.y;
           //const double scale = mParent->getOptions (   )->scale.y / 65535;
          
           const int maxMip = static_cast <int> (  opt->maxRenderLevel );
           const int tilesize = static_cast <int> (  opt->TileSize );
          
           const unsigned int tileSize = opt->TileSize;
          
          // should change if we're just refilling a part
           if (  mIsRectModified )
           {
           // until we find a way to adjust the modification rect
           // on step size
          
           // should also refill the vertex map with deformed point
           // (  BaseHeight )
           mRect.left = 0;
           mRect.right = tileSize;
           mRect.top = 0;
           mRect.bottom = tileSize;
          
           } // if (  mIsRectModified )
          
           const int offSetX = static_cast <int> (  mInfo->mTileX * (  tileSize - 1 ) + mRect.left );
           const int endx = static_cast <int> (  offSetX + static_cast <int> (  mRect.right - mRect.left ) );
          
           const int offSetZ = static_cast <int> (  mInfo->mTileZ * (  tileSize - 1 ) + mRect.top );
           const int IntervallModifiedZ = static_cast <int> (  mRect.bottom - mRect.top );
           const int endz = offSetZ + IntervallModifiedZ;
          
           const int pageSize = static_cast <int> (  opt->PageSize );
          
          
           const size_t blendWeights = 2;
           //const size_t blendWeights = 1;
           assert (  IntervallModifiedZ * tilesize > 0 );
          
           // until we found a way to upload part of the data.
           assert (  IntervallModifiedZ == tilesize );
          
           const size_t size = blendWeights * IntervallModifiedZ * tilesize;
           const size_t buffsize = size * sizeof(  ushort ); // sizeof(  Real );
          
           int K_heightFieldPos;
           ushort *BaseHeight = 0;
           //Real *BaseHeight = 0;
           int i,   j;
          
           const Real * const ogre_restrict heightField = mHeightfield + offSetZ * pageSize;
           if (  lodMorph )// && mIsRectModified ) )
           {
           BaseHeight = new ushort [size];
           //BaseHeight = new Real [size];
           K_heightFieldPos = 0;
           int k = 0;
           for (  j = offSetZ; j < endz; j ++ )
           {
          // should change if we're just refilling a part to whole tile (  only if using discard,   tough )
           for (  i = offSetX; i < endx; i ++ )
           {
           // Save height
           assert (  k < static_cast<int> (  size ) );
           BaseHeight[k] = static_cast<short>
           (  (  heightField[ i + K_heightFieldPos]
           * inv_scale ) - 32768 );
          
           //BaseHeight[k] = static_cast<Real>
           //(  mheightField[ i + K_heightFieldPos] );
          
          
           // should change if we're just refilling a part to whole tile,   using a
           //k += tilesize - IntervalleZ;
           k += blendWeights;
          
           }
           // should change if we're just refilling a part to whole tile,   using a
           //k += tilesize - IntervalleX;
           K_heightFieldPos += pageSize;
           }
           }
           //const ushort * const heightField = BaseHeight;
           //const Real * const heightField = BaseHeight;
          
          
           Plane t1,   t2;
           const Real Csqr = C * C;
           for (  int level = 1; level < maxMip; level++ )
           {
           ushort *pDeltaInit = 0;
           //Real *pDeltaInit = 0;
           if (  BaseHeight )
           {
           const size_t lvl_minus_one = level - 1;
          
           // Create a set of delta values (  store at index - 1 since 0 has none )
          
          // should change to an interval locking (  as in load ) ? if we're just refilling a part to whole tile
           pDeltaInit = static_cast<ushort*> (  
           mDeltaBuffers[lvl_minus_one]->lock(  HardwareBuffer::HBL_DISCARD ) );
          
           memcpy (  pDeltaInit,   BaseHeight,   buffsize );
           assert (  pDeltaInit );
           } // if (  BaseHeight )
          
           ushort * const pDeltas = pDeltaInit;
          // should keep previous change in case of partial tile refilling ?
          // But how could we lower value ? (  if terrain goes smoother )
           if (  doComputeMinLevelDistSqr )
           (  *mMinLevelDistSqr )[ level ] = 0.0f;
          
           const int step = 1 << level;
          
          // find a way to take a good step end and start
          // even with offset that would make us in "middle of a step"
           const int tilesizeMinusstepZ = endz - step;
           const int tilesizeMinusstepX = endx - step;
           const Real invStep = 1.0f / step;
          
           K_heightFieldPos = 0;
           const int ZShift = step * pageSize;
          
           for (  j = offSetZ; j < tilesizeMinusstepZ; j += step )
           {
           for (  i = offSetX; i < tilesizeMinusstepX; i += step )
           {
           //added for Ember
           bool isInValidVertex;
           {
           const Vector3 v1(  i,   heightField[ i + K_heightFieldPos ],   j );
           const Vector3 v2(  i + step,   heightField[ i + step + K_heightFieldPos ],   j );
           const Vector3 v3(  i,   heightField[ i + K_heightFieldPos + ZShift],   j + step );
           const Vector3 v4(  i + step,   heightField[ i + step + K_heightFieldPos + ZShift],   j + step );
          
           t1.redefine(  v1,   v3,   v2 );
           t2.redefine(  v2,   v3,   v4 );
           //only update the distance if none of the heights are -1.0
           //this is to allow for invalid Mercator::Segments without messing up the tricount
           //the reason is that Ember will set the height for all invalid segments to -1
           //if such a segment was to be next to a normal segment,   the delta would be way to high,  
           //resulting in a tile which was always in LOD 0
           isInValidVertex = v1.y == -1.0 || v2.y == -1.0 || v3.y == -1.0 || v4.y == -1.0;
           }
          
           if (  !isInValidVertex ) {
           // include the bottommost row of vertices if this is the last row
           const int zubound = (  j == (  tilesizeMinusstepZ )? step : step - 1 );
           for (  int z = 0; z <= zubound; z++ )
           {
           const int fulldetailz = j + z;
           const Real zpct = z * invStep;
           const bool isFullDetailZ = (  fulldetailz % step == 0 );
           const int zPageSize = z * pageSize;
           {
           // include the rightmost col of vertices if this is the last col
           const int xubound = (  i == (  tilesizeMinusstepX )? step : step - 1 );
           for (  int x = 0; x <= xubound; x++ )
           {
           const int fulldetailx = i + x;
          
           if (  isFullDetailZ &&
           fulldetailx % step == 0 )
           {
           // Skip,   this one is a vertex at this level
           continue;
           }
           const Real xpct = x * invStep;
          
           //interpolated height
           Real interp_h;
           // Determine which triangle we're on
           if (  xpct + zpct <= 1.0f )
           {
           // Solve for x/z
           interp_h =
           (  -(  t1.normal.x * fulldetailx )
           - t1.normal.z * fulldetailz
           - t1.d ) / t1.normal.y;
           }
           else
           {
           // Second triangle
           interp_h =
           (  -(  t2.normal.x * fulldetailx )
           - t2.normal.z * fulldetailz
           - t2.d ) / t2.normal.y;
           }
          
           assert (  (  fulldetailx + K_heightFieldPos + zPageSize ) < (  pageSize*pageSize ) );
          
           const Real actual_h = heightField[ fulldetailx + K_heightFieldPos + zPageSize];
           const Real delta = interp_h - actual_h;
           if (  doComputeMinLevelDistSqr )
           {
           // need to recompute it.
           const Real D2 = (  roughnessLod )? delta * delta * Csqr: Csqr;
          
           if (  (  *mMinLevelDistSqr )[ level ] < D2 )
           (  *mMinLevelDistSqr )[ level ] = D2;
           }
          
           // Should be save height difference?
           // Don't morph along edges
           if (  lodMorph )
           {
           // Save height difference
           if (  delta != 0.0f )
           {
           const int tileposx = fulldetailx - offSetX;
           const int tileposy = fulldetailz - offSetZ;
          
           if (  tileposx != 0 && tileposx != (  tilesize - 1 ) &&
           tileposy != 0 && tileposy != (  tilesize - 1 ) )
           {
          
           assert (  (  tileposx + (  tileposy * tilesize ) )*blendWeights < size );
          
           pDeltas[(  tileposx + (  tileposy * tilesize ) )*blendWeights] =
           static_cast<short>
           (  (  interp_h * inv_scale ) - 32768 );
           // pDeltas[(  tileposx + (  tileposy * tilesize ) )*blendWeights] =
           // interp_h;
           }
           }
           }
           }
          
           }
           }
           }
           }
           K_heightFieldPos += pageSize * step;
           }
          
           // Unlock morph deltas if required
           if (  lodMorph )
           mDeltaBuffers[level - 1]->unlock(   );
           }
           // delete Height Data cache and Buffer initial value.
           delete[] BaseHeight;
          
          
           if (  doComputeMinLevelDistSqr )
           {
           if (  roughnessLod )
           {
           // Post validate the whole set
           for (  i = 1; i < maxMip; i++ )
           {
          
           // Make sure no LOD transition within the tile
           // This is especially a problem when using large tiles with flat areas
          
           /* Hmm,   this can look bad on some areas,   disable for now
           Vector3 delta(  _vertex(  0,  0,  0 ),   mCenter.y,   _vertex(  0,  0,  2 ) );
           delta = delta - mCenter;
           Real minDist = delta.squaredLength(   );
           mMinLevelDistSqr[ i ] = std::max(  mMinLevelDistSqr[ i ],   minDist );
           */
          
           //make sure the levels are increasing...
           if (  (  *mMinLevelDistSqr )[ i ] < (  *mMinLevelDistSqr )[ i - 1 ] )
           (  *mMinLevelDistSqr )[ i ] = (  *mMinLevelDistSqr )[ i - 1 ];
           }
           }
           else
           {
           const int maxMip = static_cast <int> (  mParent->getOptions (   )->maxRenderLevel ) - 1;
           Real distanceLod = mParent->getOptions (   )->LOD_factor;
           for (  int level = 1; level < maxMip; level++ )
           {
           (  *mMinLevelDistSqr )[level] = distanceLod;
           distanceLod *= 2;
          
           }
           }
           fillNextLevelDown(   );
           }
           }
           //-----------------------------------------------------------------------
    1069   void PagingLandScapeRenderable::fillNextLevelDown(  void )
           {
           // reverse traverse the mMinLevelDistSqr list in order to set
           // the 'next level down'
           Real lastDist = -1;
           int lastIndex = 0;
           const int maxMip = static_cast <int> (  mParent->getOptions (   )->maxRenderLevel ) - 1;
           for (  int i = maxMip; i >= 0; --i )
           {
           assert (  i >= 0 );
           if (  i == maxMip  )
           {
           // Last one is always 0
           lastIndex = i;
           lastDist = (  *mMinLevelDistSqr )[i];
           mNextLevelDown[i] = 0;
           }
           else
           {
           mNextLevelDown[i] = lastIndex;
           if (  (  *mMinLevelDistSqr )[i] != lastDist )
           {
           lastIndex = i;
           lastDist = (  *mMinLevelDistSqr )[i];
           }
           }
           }
           }
          
           //-----------------------------------------------------------------------
    1099   HardwareVertexBufferSharedPtr PagingLandScapeRenderable::createDeltaBuffer(  void ) const
           {
           // Delta buffer is a 1D Real buffer of height offsets
           HardwareVertexBufferSharedPtr buf =
           HardwareBufferManager::getSingleton(   ).createVertexBuffer(  
           VertexElement::getTypeSize(  VET_SHORT2 ),  
           //VertexElement::getTypeSize(  VET_SHORT1 ),  
           //VertexElement::getTypeSize(  VET_FLOAT1 ),  
           mParent->getOptions (   )->TileSize * mParent->getOptions (   )->TileSize,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
           // HardwareBuffer::HBU_STATIC );
          
           return buf;
          
           }
           //-----------------------------------------------------------------------
    1115   Real PagingLandScapeRenderable::_vertex(  const int x,   const int z,   const int n ) const
           {
           const unsigned int tilesize = mParent->getOptions (   )->TileSize - 1;
           switch (  n )
           {
           case 0:
           return (  (  mInfo->mTileX * tilesize ) + x )* mParent->getOptions (   )->scale.x;
           case 1:
           return mHeightfield[(  (  mInfo->mTileX * tilesize ) + x ) +
           (  (  mInfo->mTileZ * tilesize ) + z ) * mParent->getOptions (   )->PageSize ];
           case 2:
           return (  (  mInfo->mTileZ * tilesize ) + z )* mParent->getOptions (   )->scale.z;
           default:
           return 0.0f;
           }
           }
           //-----------------------------------------------------------------------
    1132   void PagingLandScapeRenderable::_updateCustomGpuParameter(  
    1133   const GpuProgramParameters::AutoConstantEntry& constantEntry,  
    1134   GpuProgramParameters* params ) const
           {
           if (  constantEntry.data == MORPH_CUSTOM_PARAM_ID )
           {
           // Update morph LOD factor
           //params->setConstant(  constantEntry.index,   mLODMorphFactor );
           params->setNamedConstant(  "compressionSettings",   mCustomGpuParameters );
           }
           else
           {
           Renderable::_updateCustomGpuParameter(  constantEntry,   params );
           }
          
           }
           //-----------------------------------------------------------------------
    1149   void PagingLandScapeRenderable::adjustDeformationRectangle(  unsigned int x,   unsigned int z )
           {
           assert (  x < mParent->getOptions (   )->TileSize && z < mParent->getOptions (   )->TileSize );
           if (  mIsRectModified )
           {
           if (  mRect.left > x )
           mRect.left = x;
           if (  mRect.right < x )
           mRect.right = x;
          
           if (  mRect.top > z )
           mRect.top = z;
           if (  mRect.bottom < z )
           mRect.bottom = z;
           }
           else
           {
           // first modification :
           // deformation rectangle is the point
          
           mRect.left = x;
           mRect.right = x;
           mRect.top = z;
           mRect.bottom = z;
           mIsRectModified = true;
           mNeedReload = true;
           }
           }
          
           //-----------------------------------------------------------------------
    1179   uint32 PagingLandScapeRenderable::getTypeFlags(  void ) const
           {
           // return world flag
           return SceneManager::WORLD_GEOMETRY_TYPE_MASK;
           }
           //-----------------------------------------------------------------------
    1185   void PagingLandScapeRenderable::_notifyAttached(  Node* parent,   bool isTagPoint )
           {
           MovableObject::_notifyAttached(  parent,   isTagPoint );
           if (  parent )
           {
           assert (  mIsLoaded );
           mCenter = mBounds.getCenter(   ) + mParentNode->getWorldPosition(   );
           mWorldBoundingSphere.setCenter(  mCenter );
           mWorldBoundingSphere.setRadius(  (  mBounds.getMaximum(   ) - mBounds.getMinimum(   ) ).length(   ) / 2 );
           mParentNode->needUpdate(   );
           }
           }
           //-----------------------------------------------------------------------
    1198   Vector3 PagingLandScapeRenderable::_getvertex(  const int x,   const int z ) const
           {
           const unsigned int tilesize = mParent->getOptions (   )->TileSize - 1;
           const unsigned int pSize = mParent->getOptions (   )->PageSize -1;
           Vector3 vertex;
          
           vertex.x = (  mInfo->mTileX * tilesize ) + x;
          
           vertex.z = (  mInfo->mTileZ * tilesize ) + z;
          
           vertex.y = mHeightfield[static_cast<unsigned int>(  vertex.x + (  vertex.z *mParent->getOptions (   )->PageSize )  )];
          
           vertex.x += mInfo->mPageX * pSize - mParent->getOptions (   )->maxUnScaledX;
           vertex.z += mInfo->mPageZ * pSize - mParent->getOptions (   )->maxUnScaledZ;
          
           vertex.x *= mParent->getOptions (   )->scale.x;
           vertex.z *= mParent->getOptions (   )->scale.z;
           return vertex;
           }
          
           /**
           * This returns the actual Polygon assignments for this renderable at the given renderLevel
           * @param renderlevel LODLevel to get the Index data at
           * @return the queried IndexData
           */
    1223   IndexData* PagingLandScapeRenderable::getRawIndexData(  const int renderlevel )
           {
           return mParent->getSceneManager(   )->getIndexBufferManager(   )->getRawIndexes(   renderlevel );
           }
          
           /**
           * Returns the Vertices for this renderable in world space
           * @param pVerts >Pre-allocated< buffer to hold the vertices. The number of Vertices can be
           * retrieved by a call to getVertexCount
           * @note no checking is done on the array whatsoever
           */
    1234   void PagingLandScapeRenderable::getRawVertexData(  Vector3* pVerts )
           {
           // pVerts should be pre-allocated to tilesize*tilesize
           // using getVertexCount(   )
           const unsigned int tilesize = mParent->getOptions (   )->TileSize -1 ;
          
           Vector3 *vert = pVerts;
           Vector3 snPosition = mParent->getOptions (   )->position;
           Vector3 tmpVertex;
          
           for (  unsigned int i=0; i<=tilesize; ++i )
           {
           for (  unsigned int j=0; j<=tilesize; ++j )
           {
           tmpVertex = _getvertex(  j,   i );
           tmpVertex += snPosition; // translate current vertex relatively parent SN position
           *vert++= tmpVertex;
           }
           }
           }
          
           /**
           * Returns the number of this Renderable's vertices
           * @return the number of this Renderable's vertices
           */
    1259   const unsigned int PagingLandScapeRenderable::getVertexCount(   )
           {
           return mParent->getOptions (   )->TileSize * mParent->getOptions (   )->TileSize ;
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeRenderableManager.cpp

       1  /***************************************************************************
           OgrePagingLandScapeRenderableManager.cpp - description
           -------------------
           begin : Mon Jun 16 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreMovableObject.h"
          
          #include "OgreCamera.h"
          
          #include "OgreSceneNode.h"
          
          #include "OgreSimpleRenderable.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          
          #include "OgrePagingLandScapeRenderable.h"
          #include "OgrePagingLandScapeIndexBuffer.h"
          
          #include "OgrePagingLandScapeRenderableManager.h"
          
          #include "OgrePagingLandScapeTile.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      46   PagingLandScapeRenderableSet::PagingLandScapeRenderableSet(   ):
           PoolSet<PagingLandScapeRenderable>(   ),  
           mRenderableManager(  0 )
           {
           }
           //-----------------------------------------------------------------------
      52   PagingLandScapeRenderable* PagingLandScapeRenderableSet::allocate (   )
           {
           return new PagingLandScapeRenderable(  mRenderableManager );
           }
           //-----------------------------------------------------------------------
      57   void PagingLandScapeRenderableSet::deallocate (  PagingLandScapeRenderable *r )
           {
           delete r;
           }
           //-----------------------------------------------------------------------
      62   PagingLandScapeRenderableManager::PagingLandScapeRenderableManager(  PagingLandScapeSceneManager * scnMgr ):
           mSceneManager(  scnMgr ),  
           mOptions(  scnMgr->getOptions (   ) ),  
           mRenderableLoadInterval (  0 ),  
           mLoadInterval(  0 ),  
           mNumRenderableLoading(  0 )
           {
           // auto extend ourself as we rather check
           //if we can found non Freed Renderables before
           mRenderablePool.setAutoextend (  false );
           // don't Double renderables num each time... too much.
           mRenderablePool.setExtendFactor (  1.2f );
           }
           //-----------------------------------------------------------------------
      76   PagingLandScapeRenderableManager::~PagingLandScapeRenderableManager(   )
           {
           mRenderablePool.deletePool (   );
           }
           //-----------------------------------------------------------------------
      81   void PagingLandScapeRenderableManager::clear(   )
           {
           if (  !mTilesLoadRenderableQueue.empty (   ) )
           {
           PagingLandScapeTile *t = mTilesLoadRenderableQueue.pop(   );
           while (  t )
           {
           t->uninit (   );
           t = mTilesLoadRenderableQueue.pop (   );
           }
           assert (  mTilesLoadRenderableQueue.empty (   ) );
           }
           // As Renderables change too much over maps (  +- lit,   normals,   etc... )
           mRenderablePool.deletePool (   );
           }
           //-----------------------------------------------------------------------
      97   void PagingLandScapeRenderableManager::load(   )
           {
           mRenderablePool.setRenderableManager (  this );
          
           PagingLandScapeOptions *opt = mOptions;
          
           mNumRenderableLoading = opt->num_renderables_loading;
           mNumRenderablesIncrement = opt->num_renderables_increment;
           mRenderableLoadInterval = opt->RenderableLoadInterval;
           mRenderablePool.setPoolSize (  opt->num_renderables );
           mTilesLoadRenderableQueue.clear(   );
           }
           //-----------------------------------------------------------------------
     110   PagingLandScapeRenderable *PagingLandScapeRenderableManager::getRenderable(   )
           {
           PagingLandScapeRenderable *r = mRenderablePool.getPoolable (   );
           if (  r == 0 )
           {
           // unload some Tiles/renderables no more used to free some space.
           processTileUnload (   );
          
           r = mRenderablePool.getPoolable (   );
           if (  r == 0 )
           {
           mRenderablePool.autoExtend(   );
           r = mRenderablePool.getPoolable(   );
           }
           }
           return r;
           }
           //-----------------------------------------------------------------------
     128   void PagingLandScapeRenderableManager::freeRenderable(  PagingLandScapeRenderable *rend )
           {
           assert (  rend->mParentTile == 0 );
           mRenderablePool.removePoolable(  rend );
           }
           //-----------------------------------------------------------------------
     134   void PagingLandScapeRenderableManager::queueRenderableLoading(  PagingLandScapeTile *tile )
           {
           assert (  tile );
          
           assert (  !tile->isLoading(   ) );
           assert (  tile->getRenderable (   ) );
           assert (  !tile->getRenderable (   )->mQueued );
          
           assert (  tile->isLoaded (   ) );
           assert (  !tile->getRenderable (   )->isLoaded (   ) );
           assert (  tile->getRenderable (   )->isInUse (   ) );
          
           //
           tile->setLoading(  true );
           tile->getRenderable (   )->mQueued = true;
          
           //
           mTilesLoadRenderableQueue.push (  tile );
          
           }
           //-----------------------------------------------------------------------
     155   void PagingLandScapeRenderableManager::unqueueRenderable (  PagingLandScapeTile *tile )
           {
           assert (  tile->isLoading(   ) );
           assert (  tile->getRenderable (   ) );
           assert (  tile->getRenderable (   )->mQueued );
          
           assert (  tile->isLoaded (   ) );
           assert (  !tile->getRenderable (   )->isLoaded (   ) );
           //assert (  !tile->getRenderable (   )->isInUse (   ) );
          
           //
           tile->setLoading (  false );
           tile->getRenderable (   )->mQueued = false;
          
           //
           mTilesLoadRenderableQueue.remove (  tile );
           }
           //-----------------------------------------------------------------------
     173   void PagingLandScapeRenderableManager::processTileUnload(   )
           {
           if (  mTilesLoadRenderableQueue.empty(   ) )
           return;
          
           PagingLandScapeTile *tile;
           for (  PagingLandScapeQueue<PagingLandScapeTile>::MsgQueType::iterator itq = mTilesLoadRenderableQueue.begin(   );
           itq != mTilesLoadRenderableQueue.end(   ); )
           {
           tile = *itq;
           assert (  tile != 0 );
          
           assert (  tile->isLoading(   ) );
           assert (  tile->getRenderable (   ) );
           assert (  tile->getRenderable (   )->mQueued );
          
           assert (  tile->isLoaded (   ) );
           assert (  tile->getSceneNode(   ) );
           assert (  !tile->getRenderable (   )->isLoaded (   ) );
          
           if (  !tile->getRenderable (   )->isInUse (   ) )
           {
           tile->setLoading (  false );
           tile->getRenderable (   )->mQueued = false;
           tile->unload (   );
           itq = mTilesLoadRenderableQueue.erase (  itq );
           }
           else
           {
           ++itq;
           }
           }
           }
           //-----------------------------------------------------------------------
     207   bool PagingLandScapeRenderableManager::executeRenderableLoading(  const Vector3 &Cameraposition )
           {
           if (  mTilesLoadRenderableQueue.empty(   ) )
           {
           return true;
           }
           else
           {
           if (  mLoadInterval-- < 0 )
           {
           const size_t queueSize = mTilesLoadRenderableQueue.getSize (   ) ;
           mTilesLoadRenderableQueue.sortNearest(  Cameraposition );
           const size_t k = mNumRenderableLoading > queueSize ? queueSize : mNumRenderableLoading;
           for (  size_t i = 0; i < k; i++ )
           {
          
           PagingLandScapeTile * const tile = mTilesLoadRenderableQueue.pop (   );
           // no more in queues.
           assert (  tile != 0 );
           assert (  tile->isLoaded (   ) );
           assert (  tile->isLoading(   ) );
           PagingLandScapeRenderable * const rend = tile->getRenderable (   );
          
           assert (  rend != 0 );
           assert (  rend->mParentTile == tile );
           assert (  rend->mQueued );
           assert (  !rend->isLoaded (   ) );
           SceneNode * const tileSceneNode = tile->getSceneNode (   );
           assert (  tileSceneNode != 0 );
          
          
           // if renderable can be loaded
           if (  rend->load (   ) )
           {
           tileSceneNode->attachObject (  rend );
           tile->_linkRenderableNeighbor (   );
           }
           else
           {
           // (  no data yet. ) empty tile.
           tile->unload (   );
           }
          
           tile->setLoading(  false );
           rend->mQueued = false;
          
           tileSceneNode->needUpdate (   );
           }
           mLoadInterval = mRenderableLoadInterval;
           }
           }
           return false;
           }
          
           //-----------------------------------------------------------------------
     262   size_t PagingLandScapeRenderableManager::numRenderables(  void ) const
           {
           return static_cast< size_t > (  mRenderablePool.getPoolSize(   ) );
           }
          
           //-----------------------------------------------------------------------
     268   size_t PagingLandScapeRenderableManager::numFree(  void ) const
           {
           return mRenderablePool.getPoolSize(   ) - mRenderablePool.getActivePoolablesSize (   );
           }
          
           //-----------------------------------------------------------------------
     274   size_t PagingLandScapeRenderableManager::numLoading(  void ) const
           {
           return mTilesLoadRenderableQueue.getSize(   );
           }
           //-----------------------------------------------------------------------
     279   void PagingLandScapeRenderableManager::_addBatch(  const unsigned int num )
           {
           mRenderablePool.setPoolSize (  mRenderablePool.getPoolSize(   ) + num );
           #ifdef _DEBUG
           std::cout << "Renderables addBatch : " << mRenderablePool.getPoolSize(   ) << "\n";
           #endif
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeSceneManager.cpp

          /***************************************************************************
           OgrePagingLandScapeSceneManager.cpp - description
           -------------------
           begin : Mon May 12 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          
          
          #include "OgreRoot.h"
          #include "OgreSceneManager.h"
          #include "OgreVector2.h"
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          #include "OgreMovableObject.h"
          #include "OgreAxisAlignedBox.h"
          #include "OgreCamera.h"
          #include "OgreStringConverter.h"
          #include "OgreSceneNode.h"
          #include "OgreSimpleRenderable.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeRenderableManager.h"
          #include "OgrePagingLandScapeTextureCoordinatesManager.h"
          #include "OgrePagingLandScapeRenderable.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapePageManager.h"
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapeTileInfo.h"
          #include "OgrePagingLandScapeTileManager.h"
          #include "OgrePagingLandScapeRenderable.h"
          #include "OgrePagingLandScapeRenderableManager.h"
          #include "OgrePagingLandScapeAxisAlignedBoxSceneQuery.h"
          #include "OgrePagingLandScapeRaySceneQuery.h"
          #include "OgrePagingLandScapeCamera.h"
          #include "OgrePagingLandScapeMeshDecal.h"
          
          #include "OgrePagingLandScapeListenerManager.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          
          #include "OgrePagingLandScapeHorizon.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
           const String PagingLandScapeSceneManagerFactory::FACTORY_TYPE_NAME = "PagingLandScapeSceneManager";
           //-----------------------------------------------------------------------
      65   void PagingLandScapeSceneManagerFactory::initMetaData(  void ) const
           {
           mMetaData.typeName = FACTORY_TYPE_NAME;
           mMetaData.description = "Scene manager organising the scene on the basis of an octree,   and paging heightmap when needed.";
           mMetaData.sceneTypeMask = ST_EXTERIOR_REAL_FAR; // support all types
           mMetaData.worldGeometrySupported = true;
           }
           //-----------------------------------------------------------------------
      73   SceneManager* PagingLandScapeSceneManagerFactory::createInstance(  
      74   const String& instanceName )
           {
           return new PagingLandScapeSceneManager(  instanceName );
           }
           //-----------------------------------------------------------------------
      79   void PagingLandScapeSceneManagerFactory::destroyInstance(  SceneManager* instance )
           {
           delete instance;
           }
           //-----------------------------------------------------------------------
      84   PagingLandScapeSceneManager::PagingLandScapeSceneManager(  const String& name ) :
           PagingLandScapeOctreeSceneManager(  name ),  
           mData2DManager (  0 ),  
           mTextureManager (  0 ),  
           mTileManager (  0 ),  
           mRenderableManager (  0 ),  
           mIndexesManager (  0 ),  
           mTexCoordManager (  0 ),  
           mPageManager (  0 ),  
           mHorizon (  0 ),  
           mNeedOptionsUpdate (  false ),  
           //JEFF
           mWorldGeomIsSetup (  false ),  
           // TK
           mWorldGeomIsInit (  false ),  
           mBrushSize (  5 ),  
           mBrushScale (  0.2f ),  
     101   mImpactInfo (  0 ),  
           mBrushCenter (  Vector3::ZERO ),  
           mBrushArray (  0 ),   mCraterArray(  0 ),  
           mBrushArrayHeight (  0 ),  
           mBrushArrayWidth (  0 ),  
           mListenerManager(  0 ),  
           mOptions(  0 ),  
           textureFormatChanged (  false )
           {
           //showBoundingBoxes(  true );
           //setDisplaySceneNodes(  true );
          
           mMeshDecalFactory = new PagingLandScapeMeshDecalFactory;
           if(   !(  Root::getSingleton(   ).hasMovableObjectFactory(  "PagingLandScapeMeshDecal" ) )  )
           Root::getSingleton(   ).addMovableObjectFactory(   mMeshDecalFactory  );
           }
           //-------------------------------------------------------------------------
     118   const String& PagingLandScapeSceneManager::getTypeName(  void ) const
           {
           return PagingLandScapeSceneManagerFactory::FACTORY_TYPE_NAME;
           }
           //-----------------------------------------------------------------------
     123   void PagingLandScapeSceneManager::PagingLandScapeOctreeResize(   )
           {
           const Ogre::Real x = mOptions->maxScaledX;
           assert (  mData2DManager );
           const Ogre::Real y = mData2DManager->getMaxHeight (   ) * 4;
           const Ogre::Real z = mOptions->maxScaledZ;
           PagingLandScapeOctreeSceneManager::resize(  AxisAlignedBox(  -x ,   0,   -z,   x,   y,   z ) );
           }
           //-----------------------------------------------------------------------
     132   void PagingLandScapeSceneManager::WorldDimensionChange(   )
           {
           PagingLandScapeOctreeResize(   );
          
           assert (  mPageManager );
           assert (  mData2DManager );
           assert (  mTextureManager );
           mPageManager->WorldDimensionChange(   );
           mData2DManager->WorldDimensionChange(   );
           mTextureManager->WorldDimensionChange(   );
           }
           //-------------------------------------------------------------------------
     144   void PagingLandScapeSceneManager::shutdown(  void )
           {
           clearScene(   );
          
           delete mOptions;
           mOptions = 0;
          
           delete mData2DManager;
           mData2DManager = 0;
           delete mTextureManager;
           mTextureManager = 0;
          
           if (  mPageManager )
           Root::getSingleton(   ).removeFrameListener (  mPageManager );
           delete mPageManager;
           mPageManager = 0;
          
           delete mListenerManager;
           mListenerManager = 0;
           delete mTileManager;
           mTileManager = 0;
           delete mRenderableManager;
           mRenderableManager = 0;
          
           delete mIndexesManager;
           mIndexesManager = 0;
           delete mTexCoordManager;
           mTexCoordManager = 0;
          
           delete[] mCraterArray;
           mCraterArray = 0;
          
           Root::getSingleton(   ).removeMovableObjectFactory(   mMeshDecalFactory  );
           delete mMeshDecalFactory;
           }
           //-----------------------------------------------------------------------
     180   PagingLandScapeSceneManager::~PagingLandScapeSceneManager(   )
           {
           shutdown(   );
           }
           //-------------------------------------------------------------------------
     185   void PagingLandScapeSceneManager::setWorldGeometry(  DataStreamPtr& stream,   const String& typeName )
           {
           if (  !mListenerManager )
           mListenerManager = new PagingLandScapeListenerManager(  this );
           // Clear out any existing world resources (  if not default )
           if (  ResourceGroupManager::getSingleton(   ).getWorldResourceGroupName(   ) !=
           ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME )
           {
           ResourceGroupManager::getSingleton(   ).clearResourceGroup(  
           ResourceGroupManager::getSingleton(   ).getWorldResourceGroupName(   ) );
           }
          
           if (  mWorldGeomIsSetup )
           clearScene(   );
           if (  !mOptions )
           mOptions = new PagingLandScapeOptions(  this );
           InitScene (   );
           // Load the configuration file
           if (  !stream.isNull (   ) )
           {
           if (  mOptions->load(  stream ) )
           loadScene (   );
           }
           // Check if we need to set the camera
           if (  !mOptions->primaryCamera && !mCameras.empty (   ) )
           {
           PagingLandScapeCamera* c = static_cast <PagingLandScapeCamera*> (  mCameras.begin(   )->second );
           mOptions->setPrimaryCamera (  c );
           }
           }
           //-----------------------------------------------------------------------
     216   void PagingLandScapeSceneManager::setWorldGeometry(  const String& filename )
           {
           if (  filename.empty(   ) )
           {
          #ifdef PLSM2_EIHORT
           DataStreamPtr myStream;
          #else
           DataStreamPtr myStream (  0 );
          #endif
           myStream.setNull(   );
           setWorldGeometry (  myStream );
           return;
           }
          
           // try to open in the current folder first
           std::ifstream fs;
           fs.open(  filename.c_str(   ),   std::ios::in | std::ios::binary );
           if (  fs )
           {
           // Wrap as a stream
           DataStreamPtr myStream (  new FileStreamDataStream (  filename,   &fs,   false ) );
           setWorldGeometry (  myStream );
           return;
           }
          
           // otherwise try resource system
           DataStreamPtr myStream (  ResourceGroupManager::getSingleton(   ).openResource(  filename ) );
           setWorldGeometry (  myStream );
           }
           //-----------------------------------------------------------------------
     246   void PagingLandScapeSceneManager::InitScene (   )
           {
           // Only initialized once
           // not to loose use listeners
           if (  !mListenerManager )
           mListenerManager = new PagingLandScapeListenerManager(  this );
           if (  !mTileManager )
           mTileManager = new PagingLandScapeTileManager(  this );
           if (  !mData2DManager )
           mData2DManager = new PagingLandScapeData2DManager(  this,   mOptions ); //
           if (  !mTextureManager )
           mTextureManager = new PagingLandScapeTextureManager(  this );
           if (  !mIndexesManager )
           mIndexesManager = new PagingLandScapeIndexBufferManager(  this );
           if (  !mTexCoordManager )
           mTexCoordManager = new PagingLandScapeTextureCoordinatesManager(  this );
           if (  !mRenderableManager )
           mRenderableManager = new PagingLandScapeRenderableManager(  this );
           if (  !mCraterArray )
           resizeCrater(   );
           if (  !mPageManager )
           {
           mPageManager = new PagingLandScapePageManager(  this );
           Root::getSingleton(   ).addFrameListener(  mPageManager );
          
           mPageManager->setWorldGeometryRenderQueue (  static_cast<Ogre::RenderQueueGroupID>(  SceneManager::getWorldGeometryRenderQueue(   ) ) );
           mData2DManager->setPageManager(  this );
           }
           }
           //-----------------------------------------------------------------------
     276   void PagingLandScapeSceneManager::loadScene(   )
           {
           if (  !mWorldGeomIsSetup )
           {
           // listen to frames to update queues independently of cam numbers.
           // cannot do that if remove is called in same frame before it removes it
           // ...
           //Root::getSingleton(   ).addFrameListener(  mPageManager );
           mPageManager->setEnabled (  true );
          
           mTileManager->load(   );
           mData2DManager->load(   );
           mTextureManager->load(   );
           mIndexesManager->load(   );
           mTexCoordManager->load(   );
           if (  mOptions->VisMap )
           {
           assert (  !mHorizon );
           mHorizon = new PagingLandScapeHorizon(  mOptions );
           }
           mPageManager->load(   );
           mRenderableManager->load(   );
          
           // reset camera paging
           // register existing camera in node
           CameraList::iterator i = mCameras.begin(   );
           for (  ; i != mCameras.end(   ); ++i )
           {
           // Notify occlusion system
           PagingLandScapeCamera *c = static_cast <PagingLandScapeCamera *> (  i->second );
           assert (  c );
           c->resetPaging (   );
           }
           PagingLandScapeOctreeResize(   );
          
          
          
           mWorldGeomIsSetup = true;
          
          
           }
           }
           //-----------------------------------------------------------------------
     319   void PagingLandScapeSceneManager::clearScene(  void )
           {
           //SceneManager::getRenderQueue(   )->clear(   );
           PagingLandScapeSceneManager::resetScene(   );
           //Call the default
           PagingLandScapeOctreeSceneManager::clearScene(   );
           }
           //-----------------------------------------------------------------------
     327   void PagingLandScapeSceneManager::resetScene(  void )
           {
           if (  mWorldGeomIsSetup )
           {
           //Root::getSingleton(   ).removeFrameListener (  mPageManager );
           mPageManager->setEnabled (  false );
           // clear the Managers
           mPageManager->clear(   );
           mTextureManager->clear(   );
           mData2DManager->clear(   );
           if (  mHorizon )
           {
           delete mHorizon;
           mHorizon = 0;
           }
           // clear queues
           mRenderableManager->clear(   );
           mTileManager->clear(   );
          
           // unload cached map info
           mOptions->clearTileInfo(   );
          
           // clear hardware buffer caches
           //mIndexesManager->clear(   ); //don't clear to keep index buffer if tilesize
           //mTexCoordManager->clear(   ); //don't clear to keep index buffer if tilesize
          
           mWorldGeomIsSetup = false;
           mWorldGeomIsInit = false;
          
           //PagingLandScapeOctreeSceneManager::clearScene(   );
           }
           }
           //-----------------------------------------------------------------------
     360   void PagingLandScapeSceneManager::_updateSceneGraph(  Camera * cam )
           {
           // entry into here could come before setWorldGeometry
           // got called which could be disastrous
           // so check for init
           assert(  mPageManager );
           if (  isRenderQueueToBeProcessed(  mPageManager->getPageRenderQueue(   ) ) )
           {
           if (  mWorldGeomIsInit )
           {
           mPageManager->updatePaging (  static_cast<PagingLandScapeCamera *> (  cam ) );
           }
           else
           {
           if (  mWorldGeomIsSetup )
           {
           mOptions->calculateCFactor (   );
           assert (  mPageManager );
           if (  mOptions->BigImage )
           {
           assert (  mTextureManager );
          
           mTextureManager->setMapMaterial(   );
           mPageManager->setMapMaterial(   );
           }
           mWorldGeomIsInit = true;
           mPageManager->updatePaging (  static_cast<PagingLandScapeCamera *> (  cam ) );
           }
           }
           }
           // Call the default
           PagingLandScapeOctreeSceneManager::_updateSceneGraph(  cam );
           }
           //-----------------------------------------------------------------------
          // void PagingLandScapeSceneManager::_renderVisibleObjects(  void )
          // {
          // SceneManager::_renderVisibleObjects(   );
          // }
          
           //-----------------------------------------------------------------------
          // void PagingLandScapeSceneManager::_findVisibleObjects (  Camera * cam,   bool onlyShadowCasters )
          // {
          // PagingLandScapeOctreeSceneManager::_findVisibleObjects(  cam,   onlyShadowCasters );
          // }
          
          
           //----------------------------------------------------------------------------
          // IntersectionSceneQuery* PagingLandScapeSceneManager::createIntersectionQuery(  unsigned long mask )
          // {
          // PagingLandScapeIntersectionSceneQuery* q = new PagingLandScapeIntersectionSceneQuery(  this );
          // q->setQueryMask(  mask );
          // return q;
          // }
          
     414   AxisAlignedBoxSceneQuery* PagingLandScapeSceneManager::createAABBQuery(   const AxisAlignedBox& box,  
           unsigned long mask  )
           {
           PagingLandScapeAxisAlignedBoxSceneQuery* q = new PagingLandScapeAxisAlignedBoxSceneQuery(  this );
           q->setBox(  box );
           q->setQueryMask(  mask );
           return q;
           }
          
           //----------------------------------------------------------------------------
     424   RaySceneQuery* PagingLandScapeSceneManager::createRayQuery(  const Ray& ray,   unsigned long mask )
           {
           PagingLandScapeRaySceneQuery* q = new PagingLandScapeRaySceneQuery(  this );
           q->setRay(  ray );
           q->setQueryMask(  mask );
           return q;
           }
           //-------------------------------------------------------------------------
     432   bool PagingLandScapeSceneManager::intersectSegment(  const Ogre::Vector3 & raybegin,  
     433   const Ogre::Vector3 & rayend,  
     434   Ogre::Vector3 * rayresult )
           {
           return intersectSegmentTerrain (  raybegin,   rayend,   rayresult );
           }
           //-------------------------------------------------------------------------
     439   bool PagingLandScapeSceneManager::intersectSegmentTerrain (  const Ogre::Vector3 & raybegin,  
     440   const Ogre::Vector3 & raydir,  
     441   Ogre::Vector3 * rayresult )
           {
           Ogre::Vector3 raystart (  raybegin );
           assert (  mPageManager && mData2DManager );
          
           const Ogre::Real maxHeight = mData2DManager->getMaxHeight (   );
          
           if (  raystart.y > maxHeight )
           {
           // find an new ray start that is under highest terrain height
           // so that we do not test intersection between terrain and ray
           // on ray part where Y > maxHeight
          
           // First check if not parallel to terrain
           if (  Math::Abs(  raydir.y ) < std::numeric_limits<Real>::epsilon(   ) )
           {
           // Parallel ?
           *rayresult = Ogre::Vector3(  -1.0f,   -1.0f,   -1.0f );
           return false;
           }
           // now ray should begin at a pertinent place.
           const Ogre::Real t = -(  raystart.y-maxHeight )/raydir.y;
           raystart += raydir*t;
           if (  raystart.y <= mData2DManager->getInterpolatedWorldHeight(  raystart.x,   raystart.z ) )
           {
           *rayresult = raystart;
           return true;
           }
           }
          
           PagingLandScapeTile * t = mPageManager->getTile (  raystart.x,   raystart.z,   false );
           if (  t == 0 )
           {
           // we're outside LandScape
           #ifndef _STRICT_LandScape
           // if you want to be able to intersect from a point outside the canvas
           //const int pageSize = mOptions->PageSize - 1;
           const Ogre::Real W = mOptions->maxScaledX;
           const Ogre::Real H = mOptions->maxScaledZ;
           const Ogre::Real maxHeight = mData2DManager->getMaxHeight (   );
          
           if (  W != 0 && H != 0 ) {
           // while ray is outside but raydir going inside
           while (  (  raystart.y < 0.0f && raydir.y > 0.0f ) ||
           (  raystart.y > maxHeight && raydir.y < 0.0f ) ||
          
           (  raystart.x < -W && raydir.x > 0.0f ) ||
           (  raystart.x > W && raydir.x < 0.0f ) ||
          
           (  raystart.z < -H && raydir.z > 0.0f ) ||
           (  raystart.z > H && raydir.z < 0.0f ) )
           raystart += raydir;
           }
          
           if (  raystart.y < 0.0f || raystart.y >= maxHeight ||
           raystart.x < -W || raystart.x > W ||
           raystart.z < -H || raystart.z > H )
           {
           *rayresult = Ogre::Vector3(  -1.0f,   -1.0f,   -1.0f );
           return false;
           }
           t = mPageManager->getTile (  raystart.x,   raystart.z,   false );
           if (  t == 0 )
           return false;
           #else //_STRICT_LandScape
           // if you don't want to be able to intersect from a point outside the canvas
           *rayresult = Ogre::Vector3(  -1.0f,   -1.0f,   -1.0f );
           return false;
           #endif //_STRICT_LandScape
           }
          
           bool impact;
          
          
           //special case...
          // if (  raydir.x == 0.0f && raydir.z == 0.0f )
          // {
          // if (  raystart.y <= mData2DManager->getInterpolatedWorldHeight(  raystart.x,   raystart.z ) )
          // {
          // *rayresult = raystart;
          // impact = true;
          // }
          // impact = false;
          // }
          // else
           {
           // should we scale ?
          // const Ogre::Vector3 rayDirScaled (  
          // raydir.x * mOptions->scale.x,  
          // raydir.y * mOptions->scale.y,  
          // raydir.z * mOptions->scale.z );
          
           if (  raystart.y >= mData2DManager->getInterpolatedWorldHeight(  raystart.x,   raystart.z ) )
           {
           impact = t->intersectSegmentFromAbove(  raystart,   raydir,   rayresult );
           }
           else
           {
           impact = t->intersectSegmentFromBelow(  raystart,   raydir,   rayresult );
           }
          
           }
           return true;
           }
           //-------------------------------------------------------------------------
     546   void PagingLandScapeSceneManager::resizeCrater (   )
           {
           const int radius = mBrushSize;
           const unsigned int diameter = static_cast <unsigned int> (  radius ) * 2;
          
           mBrushArrayHeight = diameter;
           mBrushArrayWidth = diameter;
          
           delete [] mCraterArray;
           const unsigned int array_size = diameter * diameter;
           mCraterArray = new Real[array_size];
           memset (  mCraterArray,   0,   array_size * sizeof(  Real ) );
          
           // Calculate the minimum X value
           // make sure it is still on the height map
           const int Zmin = -radius;
           const int Zmax = radius;
          
           const int Xmin = -radius;
           const int Xmax = radius;
          
           // (  goes through each X value )
           unsigned int array_indx = 0;
           const int radiussquare = radius * radius;
           //const Ogre::Real scaler = mOptions->scale.y;// / radius;
           const Ogre::Real scaler = 1.0 / radius;
           for (  int Zcurr = Zmin; Zcurr < Zmax; Zcurr++ )
           {
           const Ogre::Real Precalc = radiussquare - (  Zcurr * Zcurr );
           if (  Precalc > 1.0f )
           {
           // Determine the minimum and maximum X value for that
           // line in the circle (  that Z value )
           //const int Xmax = static_cast<int> (  Math::Sqrt(  Precalc ) );
           //const int Xmin = - Xmax;
          
           unsigned int curr_indx = array_indx;// + Xmin + radius;
           // For each of those Z values,   calculate the new Y value
           for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           {
           assert (  curr_indx < array_size );
           // Calculate the new theoretical height for the current point on the circle
           const Ogre::Real val = static_cast <Real> (  Xcurr * Xcurr );
           const Ogre::Real diffPrecalc = Precalc - val;
           mCraterArray[curr_indx] = std::min(  static_cast <Real> (  1.0 ),  
           std::max(  static_cast <Real> (  0.0 ),  
           Math::Sqrt (  diffPrecalc )* scaler ) ) ;
           curr_indx++;
           } // for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           } // if (  Precalc > 1.0f )
           array_indx += diameter;
           //array_indx += diameter;
           } // for (  int Zcurr = Zmin; Zcurr < radius; Zcurr++ )
           mBrushArray = mCraterArray;
           }
           //-----------------------------------------------------------------------
     602   void PagingLandScapeSceneManager::paint (  const Ogre::Vector3 &impact )
           {
           if (  mOptions->textureModifiable )
           {
           const int X = static_cast<int> (  impact.x / mOptions->scale.x );
           const int Z = static_cast<int> (  impact.z / mOptions->scale.z );
          
           //const int pageSize = mOptions->PageSize - 1;
          
           const int W = static_cast<int> (  mOptions->maxUnScaledX );
           const int H = static_cast<int> (  mOptions->maxUnScaledZ );
          
           if (  X < -W || X > W || Z < -H || Z > H )
           return;
          
           const int brushW = static_cast<int> (  mBrushArrayWidth );
           // Calculate the minimum X value
           // make sure it is still on the height map
           unsigned int xshift = 0;
           int Xmin = static_cast<int> (  -brushW * 0.5f ) ;
           if (  Xmin + X < -W )
           {
           //assert (  Xmin + X + W > 0 );
           xshift = static_cast <unsigned int> (  abs (  Xmin + X + W ) );
           Xmin = - X - W;
           }
           // Calculate the maximum X value
           // make sure it is still on the height map
           int Xmax = static_cast<int> (  brushW * 0.5f ) ;
           if (  Xmax + X > W )
           Xmax = W - X;
           const int brushH = static_cast<int> (  mBrushArrayHeight );
           // Calculate the minimum Z value
           // make sure it is still on the height map
           unsigned int zshift = 0;
           int Zmin = - static_cast<int> (  brushH * 0.5 ) ;
           if (  Zmin + Z < -H )
           {
           //assert (  Zmin + Z + H > 0 );
           zshift = static_cast <unsigned int> (  abs (  Zmin + Z + H ) );
           Zmin = - Z - H;
           }
           // Calculate the maximum Z value
           // make sure it is still on the height map
           int Zmax = static_cast<int> (  brushH * 0.5 );
           if (  Zmax + Z > H )
           Zmax = H - Z;
          
           // Main loop to draw the circle on the height map
           // (  goes through each X value )
           unsigned int array_indx = zshift*brushW;
           for (  int Zcurr = Zmin; Zcurr < Zmax; Zcurr++ )
           {
           // For each of those Z values,   calculate the new Y value
           unsigned int curr_indx = array_indx + xshift;
           for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           {
           // get results by page index ?
           const Ogre::Real h = mBrushArray[curr_indx];
           // Make sure we do it for something.
           if (  h - 0.005f > 0 )
           {
           assert (  h >= 0.0f && h <= 1.0f );
           const Ogre::Real bushForce = std::min(  static_cast <Real> (  1.0 ),   h*mBrushScale );
           if (  bushForce - 0.005f > 0 )
           {
           const Ogre::Vector3 currpoint (  X + Xcurr,   static_cast <Real> (  0.0 ),   Z + Zcurr );
           assert (  mPageManager&& mData2DManager && mTextureManager );
           PagingLandScapeTile * t = mPageManager->getTileUnscaled (  currpoint.x,   currpoint.z,   false );
           if (  t && t->isLoaded (   ) )
           {
           mImpactInfo = t->getInfo (   );
           // check page boundaries to modify any page,   tile neighbour
           // tells any tile modified to update at next frame
           assert (  curr_indx < mBrushArrayWidth*mBrushArrayHeight );
           mTextureManager->paint (  currpoint,   bushForce,   mImpactInfo );
           }// if (  t && t->isLoaded (   ) )
           }
           } // if (  h != 0.0f )
           curr_indx++;
           } // for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           array_indx += brushW;
           } // for (  int Zcurr = Zmin; Zcurr < Zmax; Zcurr++ )
           }
           }//-----------------------------------------------------------------------
     687   void PagingLandScapeSceneManager::setHeight (  const Ogre::Vector3 &impact )
           {
           if (  mOptions->Deformable )
           {
           const int X = static_cast<int> (  impact.x / mOptions->scale.x );
           const int Z = static_cast<int> (  impact.z / mOptions->scale.z );
          
           //const int pageSize = mOptions->PageSize - 1;
          
           const int W = static_cast<int> (  mOptions->maxUnScaledX );
           const int H = static_cast<int> (  mOptions->maxUnScaledZ );
          
           if (  X < -W || X > W || Z < -H || Z > H )
           return;
          
           const int brushW = static_cast<int> (  mBrushArrayWidth );
           // Calculate the minimum X value
           // make sure it is still on the height map
           unsigned int xshift = 0;
           int Xmin = static_cast<int> (  -brushW * 0.5f );
           if (  Xmin + X < -W )
           {
           //assert (  Xmin + X + W > 0 );
           xshift = static_cast <unsigned int> (  abs (  Xmin + X + W ) );
           Xmin = - X - W;
           }
           // Calculate the maximum X value
           // make sure it is still on the height map
           int Xmax = static_cast<int> (  brushW * 0.5f ) ;
           if (  Xmax + X > W )
           Xmax = W - X;
           const int brushH = static_cast<int> (  mBrushArrayHeight );
           // Calculate the minimum Z value
           // make sure it is still on the height map
           unsigned int zshift = 0;
           int Zmin = static_cast<int> (  - brushH * 0.5f ) ;
           if (  Zmin + Z < -H )
           {
           //assert (  Zmin + Z + H > 0 );
           zshift = static_cast <unsigned int> (  abs (  Zmin + Z + H ) );
           Zmin = - Z - H;
           }
           // Calculate the maximum Z value
           // make sure it is still on the height map
           int Zmax = static_cast<int> (  brushH * 0.5f ) ;
           if (  Zmax + Z > H )
           Zmax = H - Z;
          
           const Ogre::Real Hscale = mOptions->scale.y * mBrushScale;
           // Main loop to draw the circle on the height map
           // (  goes through each X value )
           unsigned int array_indx = zshift*brushW;
           for (  int Zcurr = Zmin; Zcurr < Zmax; Zcurr++ )
           {
           // For each of those Z values,   calculate the new Y value
           unsigned int curr_indx = array_indx + xshift;
           for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           {
           // get results by page index ?
           const Ogre::Real h = - mBrushArray[curr_indx] * mBrushScale * Hscale;
           // Make sure we do it for something.
           if (  h != 0.0f )
           {
           const Ogre::Vector3 currpoint (  X + Xcurr,   0.0f,   Z + Zcurr );
           assert (  mPageManager&& mData2DManager && mTextureManager );
           PagingLandScapeTile * t = mPageManager->getTileUnscaled (  currpoint.x,   currpoint.z,   false );
           if (  t && t->isLoaded (   ) )
           {
           mImpactInfo = t->getInfo (   );
           // check page boundaries to modify any page,   tile neighbour
           // tells any tile modified to update at next frame
           assert (  curr_indx < mBrushArrayWidth*mBrushArrayHeight );
           if (  mData2DManager->setHeight (  currpoint,   h,   mImpactInfo ) )
           mTextureManager->deformHeight (  currpoint,   mImpactInfo );
           } // if (  t && t->isLoaded (   ) )
           } // if (  h != 0.0f )
           curr_indx++;
           } // for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           array_indx += brushW;
           } // for (  int Zcurr = Zmin; Zcurr < Zmax; Zcurr++ )
           } // if (  mOptions->Deformable )
           }
           //-----------------------------------------------------------------------
     770   void PagingLandScapeSceneManager::deformHeight (  const Ogre::Vector3 &impact )
           {
           if (  mOptions->Deformable )
           {
           const int X = static_cast<int> (  impact.x / mOptions->scale.x );
           const int Z = static_cast<int> (  impact.z / mOptions->scale.z );
          
           //const int pageSize = mOptions->PageSize - 1;
          
           const int W = static_cast<int> (  mOptions->maxUnScaledX );
           const int H = static_cast<int> (  mOptions->maxUnScaledZ );
          
           if (  X < -W || X > W || Z < -H || Z > H )
           return;
          
           const int brushW = static_cast<int> (  mBrushArrayWidth );
           // Calculate the minimum X value
           // make sure it is still on the height map
           unsigned int xshift = 0;
           int Xmin = static_cast<int> (  -brushW * 0.5f );
           if (  Xmin + X < -W )
           {
           //assert (  Xmin + X + W > 0 );
           xshift = static_cast <unsigned int> (  abs (  Xmin + X + W ) );
           Xmin = - X - W;
           }
           // Calculate the maximum X value
           // make sure it is still on the height map
           int Xmax = static_cast<int> (  brushW * 0.5f ) ;
           if (  Xmax + X > W )
           Xmax = W - X;
           const int brushH = static_cast<int> (  mBrushArrayHeight );
           // Calculate the minimum Z value
           // make sure it is still on the height map
           unsigned int zshift = 0;
           int Zmin = static_cast<int> (  - brushH * 0.5f ) ;
           if (  Zmin + Z < -H )
           {
           //assert (  Zmin + Z + H > 0 );
           zshift = static_cast <unsigned int> (  abs (  Zmin + Z + H ) );
           Zmin = - Z - H;
           }
           // Calculate the maximum Z value
           // make sure it is still on the height map
           int Zmax = static_cast<int> (  brushH * 0.5f ) ;
           if (  Zmax + Z > H )
           Zmax = H - Z;
          
           const Ogre::Real Hscale = mOptions->scale.y * mBrushScale;
          
           // Main loop to draw the circle on the height map
           // (  goes through each X value )
           unsigned int array_indx = zshift*brushW;
           for (  int Zcurr = Zmin; Zcurr < Zmax; Zcurr++ )
           {
           // For each of those Z values,   calculate the new Y value
           unsigned int curr_indx = array_indx + xshift;
           for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           {
           // get results by page index ?
           const Ogre::Real h = - mBrushArray[curr_indx] * Hscale;
           // Make sure we do it for something.
           if (  h != 0.0f )
           {
           const Ogre::Vector3 currpoint (  X + Xcurr,   0.0f,   Z + Zcurr );
           assert (  mPageManager&& mData2DManager && mTextureManager );
           PagingLandScapeTile * t = mPageManager->getTileUnscaled (  currpoint.x,   currpoint.z,   false );
           if (  t && t->isLoaded (   ) )
           {
           mImpactInfo = t->getInfo (   );
           // check page boundaries to modify any page,   tile neighbour
           // tells any tile modified to update at next frame
           assert (  curr_indx < mBrushArrayWidth*mBrushArrayHeight );
           if (  mData2DManager->deformHeight (  currpoint,   h,   mImpactInfo ) )
           mTextureManager->deformHeight (  currpoint,   mImpactInfo );
           } // if (  t && t->isLoaded (   ) )
           } // if (  h != 0.0f )
           curr_indx++;
           } // for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           array_indx += brushW;
           } // for (  int Zcurr = Zmin; Zcurr < Zmax; Zcurr++ )
           } // if (  mOptions->Deformable )
           }
           //-----------------------------------------------------------------------
     854   void PagingLandScapeSceneManager::getAreaHeight (  const Ogre::Vector3 &impact )
           {
           const int X = static_cast<int> (  impact.x / mOptions->scale.x );
           const int Z = static_cast<int> (  impact.z / mOptions->scale.z );
          
           //const int pageSize = mOptions->PageSize - 1;
          
           const int W = static_cast<int> (  mOptions->maxUnScaledX );
           const int H = static_cast<int> (  mOptions->maxUnScaledZ );
          
           if (  X < -W || X > W || Z < -H || Z > H )
           return;
          
           const int brushW = static_cast<int> (  mBrushArrayWidth );
           // Calculate the minimum X value
           // make sure it is still on the height map
           unsigned int xshift = 0;
           int Xmin = static_cast<int> (  -brushW * 0.5f );
           if (  Xmin + X < -W )
           {
           //assert (  Xmin + X + W > 0 );
           xshift = static_cast <unsigned int> (  abs (  Xmin + X + W ) );
           Xmin = - X - W;
           }
           // Calculate the maximum X value
           // make sure it is still on the height map
           int Xmax = static_cast<int> (  brushW * 0.5f ) ;
           if (  Xmax + X > W )
           Xmax = W - X;
           const int brushH = static_cast<int> (  mBrushArrayHeight );
           // Calculate the minimum Z value
           // make sure it is still on the height map
           unsigned int zshift = 0;
           int Zmin = static_cast<int> (  - brushH * 0.5f ) ;
           if (  Zmin + Z < -H )
           {
           //assert (  Zmin + Z + H > 0 );
           zshift = static_cast <unsigned int> (  abs (  Zmin + Z + H ) );
           Zmin = - Z - H;
           }
           // Calculate the maximum Z value
           // make sure it is still on the height map
           int Zmax = static_cast<int> (  brushH * 0.5f ) ;
           if (  Zmax + Z > H )
           Zmax = H - Z;
          
           const unsigned int pSize = mOptions->PageSize - 1;
           const Ogre::Real Hscale = 1 / (  mOptions->scale.y * mBrushScale );
           // Main loop to draw the circle on the height map
           // (  goes through each X value )
           unsigned int array_indx = zshift*brushW;
           for (  int Zcurr = Zmin; Zcurr < Zmax; Zcurr++ )
           {
           // For each of those Z values,   calculate the new Y value
           unsigned int curr_indx = array_indx + xshift;
           for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           {
           const Ogre::Vector3 currpoint (  X + Xcurr,   0.0f,   Z + Zcurr );
           assert (  mPageManager&& mData2DManager && mTextureManager );
           PagingLandScapeTile * t = mPageManager->getTileUnscaled (  currpoint.x,   currpoint.z,   false );
           if (  t && t->isLoaded (   ) )
           {
           mImpactInfo = t->getInfo (   );
           // check page boundaries to modify any page,   tile neighbour
           // tells any tile modified to update at next frame
           assert (  curr_indx < mBrushArrayWidth*mBrushArrayHeight );
          
           // adjust x and z to be local to page
           const unsigned int x = static_cast<unsigned int> (  currpoint.x
           - mImpactInfo->mPageX * pSize
           + W );
           const unsigned int z = static_cast<unsigned int> (  currpoint.z
           - mImpactInfo->mPageZ * pSize
           + H );
           mBrushArray[curr_indx] = mData2DManager->getHeight(  mImpactInfo->mPageX,  
           mImpactInfo->mPageZ,  
           x,  
           z )
           *
           Hscale;
          
          
           } // if (  t && t->isLoaded (   ) )
          
           curr_indx++;
           } // for (  int Xcurr = Xmin; Xcurr < Xmax; Xcurr++ )
           array_indx += brushW;
           } // for (  int Zcurr = Zmin; Zcurr < Zmax; Zcurr++ )
           }
           //-----------------------------------------------------------------------
     944   bool PagingLandScapeSceneManager::setOption(  const String& strKey,   const void* pValue )
           {
           //listeners
           if (  StringUtil::endsWith(  strKey,   "listener",   true ) )
           {
           if (  mListenerManager->setOption (  strKey,   pValue ) )
           return true;
           }
          
           if (  StringUtil::startsWith(  strKey,   "pause",   true ) )
           {
           mPageManager->setEnabled(   ! *(  const_cast < bool * > (  static_cast < const bool * >(  pValue ) ) ) );
           }
          
           // deformation and painting
           if (  strKey == "BrushArray" )
           {
           mBrushArray = const_cast <Ogre::Real * > (  static_cast < const Ogre::Real * >(  pValue ) );
           return true;
           }
           if (  strKey == "BrushArrayHeight" )
           {
           mBrushArrayHeight = * static_cast < const unsigned int * > (  pValue );
           return true;
           }
           if (  strKey == "BrushArrayWidth" )
           {
           mBrushArrayWidth = * static_cast < const unsigned int * > (  pValue );
           return true;
           }
           if (  strKey == "BrushScale" )
           {
           mBrushScale = * static_cast < const Ogre::Real * > (  pValue ) ;
           return true;
           }
           if (  strKey == "BrushSize" )
           {
           mBrushSize = * static_cast < const unsigned int * > (  pValue );
           resizeCrater(   );
           return true;
           }
           if (  strKey == "setHeightCenter" )
           {
           mBrushCenter = * static_cast < const Ogre::Vector3 * > (  pValue );
           setHeight (  mBrushCenter );
           return true;
          
           }
           if (  strKey == "DeformationCenter" )
           {
           mBrushCenter = * static_cast < const Ogre::Vector3 * > (  pValue );
           deformHeight (  mBrushCenter );
           return true;
          
           }
           if (  strKey == "fillBrushArray" )
           {
           mBrushCenter = * static_cast < const Ogre::Vector3 * > (  pValue );
           getAreaHeight (  mBrushCenter );
           return true;
           }
           if (  strKey == "PaintCenter" )
           {
           mBrushCenter = * static_cast < const Ogre::Vector3 * > (  pValue );
           paint(  mBrushCenter );
           return true;
           }
           if (  strKey == "setPaintChannelValues" )
           {
           mTextureManager->setPaintChannelValues (  
           static_cast < const std::vector<Real> *>
           (  pValue )
            );
           return true;
           }
          
           if (  strKey == "renderTextureModeToBaseTextures" )
           {
           const String alternateMaterial = *static_cast < const String * > (  pValue );
           renderBaseTextures(  alternateMaterial );
           }
          
           // Map Changes
           if (  strKey == "LoadMap" )
           {
           const String textureFormatName(  mOptions->getCurrentTextureFormat (   ) );
          
           PagingLandScapeSceneManager::resetScene(   );
           PagingLandScapeSceneManager::loadScene (   );
          
           textureFormatChanged = false;
          
           return true;
           }
          
           if (  strKey == "CurrentMap" )
           {
           const String CurrentMapName = *static_cast < const String * > (  pValue );
           mOptions->setCurrentMapName (  CurrentMapName );
           return true;
           }
           if (  strKey == "InsertNewMap" )
           {
           const String CurrentMapName = *static_cast < const String * > (  pValue );
           mOptions->insertMap(  CurrentMapName );
           return true;
           }
           // TextureFormat changes
           if (  strKey == "CurrentTextureFormat" )
           {
           // Override File TextureFormat
           mOptions->setTextureFormat (  *static_cast < const String * > (  pValue ) );
           textureFormatChanged = true;
           return true;
           }
           // TextureFormat changes
           if (  strKey == "InsertTextureFormat" )
           {
           // Override File TextureFormat
           mOptions->insertTextureFormat (  *static_cast < const String * > (  pValue ) );
           return true;
           }
           if (  strKey == "PageUpdate" )
           {
           const Vector2 page = *static_cast < const Vector2 * > (  pValue );
          
           // Reload Data. ALso must reload pages that depend on this
           mData2DManager->reload (  page.x,   page.y );
           mTextureManager->reload(  page.x,   page.y );
           if (  page.x > 0 )
           {
           mData2DManager->reload (  page.x-1,   page.y );
           mTextureManager->reload(  page.x-1,   page.y );
           }
           if (  page.y > 0 )
           {
           mTextureManager->reload(  page.x,   page.y-1 );
           mData2DManager->reload (  page.x,   page.y-1 );
           }
           if (  page.x > 0 && page.y > 0 )
           {
           mData2DManager->reload (  page.x-1,   page.y-1 );
           mTextureManager->reload(  page.x-1,   page.y-1 );
           }
          
           // Now reload pages
           //mPageManager::getSingleton(   ).getPage(  page.x,   page.y )->reload(   );
           }
          
           if (  strKey == "LoadNow" )
           {
           assert (  mPageManager );
           if (  mOptions->max_preload_pages*mOptions->max_preload_pages >= mOptions->NumPages )
           {
           // Configuration file is telling us to pre-load all pages at startup.
           for (  unsigned int pageY = 0; pageY < mOptions->world_height; pageY++ )
           {
           for (  unsigned int pageX = 0; pageX < mOptions->world_width; pageX++ )
           {
           PagingLandScapePage * const p = mPageManager->getPage(  pageX,   pageY );
           p->load(   );
           mPageManager->addLoadedPage(  p );
          
           }
           }
           if (  mOptions->primaryCamera )
           mPageManager->loadNow (  mOptions->primaryCamera );
           }
           else if (  pValue )
           {
           PagingLandScapeCamera *cam = const_cast <PagingLandScapeCamera *> (  static_cast < const PagingLandScapeCamera * > (  pValue ) );
           mPageManager->loadNow (  cam );
           }
           }
           if (  strKey == "ResetScene" )
           {
           if(   * static_cast < const bool * > (  pValue )  )
           PagingLandScapeSceneManager::resetScene(   );
          
           return true;
           }
           if (  mOptions->setOption(  strKey,   pValue ) == true )
           {
           return true;
           }
           if (  PagingLandScapeOctreeSceneManager::setOption (  strKey,   pValue ) == true )
           {
           return true;
           }
          
          
           return false;
           }
          
           //-----------------------------------------------------------------------
    1139   bool PagingLandScapeSceneManager::getOption(  const String& strKey,   void* pDestValue )
           {
           if (  strKey == "h" || strKey == "getHeightAt" )
           {
           Ogre::Vector3 *p = static_cast < Ogre::Vector3 * > (  pDestValue );
           p->y = getHeightAt (  p->x,   p->z );
           return true;
           }
           if (  strKey == "s" || strKey == "getSlopeAt" )
           {
           Ogre::Vector3 *p = static_cast < Ogre::Vector3 * > (  pDestValue );
           p->y = getSlopeAt (  p->x,   p->z );
           return true;
           }
           if (  StringUtil::startsWith(  strKey,   "pause",   true ) )
           {
           * (  static_cast < bool * > (  pDestValue ) ) = !mPageManager->isEnabled(   );
           return true;
           }
          
           // heightfield data an pos info
           if (  strKey == "MapBoundaries" )
           {
           AxisAlignedBox *box = static_cast < AxisAlignedBox * > (  pDestValue );
          
           box->setExtents(  -mOptions->maxScaledX,  
           0,  
           -mOptions->maxScaledZ,  
           mOptions->maxScaledX,  
           mOptions->scale.y,  
           mOptions->maxScaledZ );
           return true;
          
           }
           if (  strKey == "GlobalToPage" )
           {
           Ogre::Vector3 *pos = static_cast < Ogre::Vector3 * > (  pDestValue );
           mPageManager->getGlobalToPage (  pos->x,   pos->z );
           return true;
           }
           if (  strKey == "getAreaSize" )
           {
           Ogre::Vector3 *vertices_array = static_cast < Ogre::Vector3 * > (  pDestValue );
          
           mPageManager->getGlobalToPage (  vertices_array[0].x,   vertices_array[0].z );
           mPageManager->getGlobalToPage (  vertices_array[1].x,   vertices_array[1].z );
           mPageManager->getGlobalToPage (  vertices_array[2].x,   vertices_array[2].z );
           mPageManager->getGlobalToPage (  vertices_array[3].x,   vertices_array[3].z );
          
           // define an area an get number of point in it.
           const Ogre::Real maxx = std::max (  vertices_array[0].x,  
           std::max (  vertices_array[1].x,  
           std::max (  vertices_array[2].x,  
           vertices_array[3].x ) ) );
           const Ogre::Real minx = std::min (  vertices_array[0].x,  
           std::min (  vertices_array[1].x,  
           std::min (  vertices_array[2].x,  
           vertices_array[3].x ) ) );
          
           const Ogre::Real maxz = std::max (  vertices_array[0].z,  
           std::max (  vertices_array[1].z,  
           std::max (  vertices_array[2].z,  
           vertices_array[3].z ) ) );
           const Ogre::Real minz = std::min (  vertices_array[0].z,  
           std::min (  vertices_array[1].z,  
           std::min (  vertices_array[2].z,  
           vertices_array[3].z ) ) );
          
           const unsigned int xpoints = static_cast<unsigned int> (  maxx - minx );
           const unsigned int zpoints = static_cast<unsigned int> (  maxz - minz );
           vertices_array[4].x = zpoints * xpoints;
          
           return true;
           }
          
           // Visibility info
           if (  strKey == "VisibilityMaterial" )
           {
           if (  mHorizon )
           {
           * static_cast < MaterialPtr * > (  pDestValue ) = mHorizon->getVisibilityMaterial(   );
           return true;
           }
           else
           return false;
           }
           // TextureFormat info
           if (  strKey == "NextTextureFormat" )
           {
           * static_cast < String * > (  pDestValue ) = mTextureManager->getNextTextureFormat(   );
           return true;
           }
           if (  strKey == "CurrentTextureFormat" )
           {
           * static_cast < String * > (  pDestValue ) = mTextureManager->getCurrentTextureFormat(   );
           return true;
           }
          
          
           // Map Info
           if (  strKey == "NextMap" )
           {
           * static_cast < String * > (  pDestValue ) = mOptions->getNextMapName(   );
           return true;
           }
           if (  strKey == "PreviousMap" )
           {
           * static_cast < String * > (  pDestValue ) = mOptions->getPreviousMapName(   );
           return true;
           }
           if (  strKey == "CurrentMap" )
           {
           * static_cast < String * > (  pDestValue ) = mOptions->getCurrentMapName(   );
           return true;
           }
           if (  strKey == "CurrentMapFileName" )
           {
           * static_cast < String * > (  pDestValue ) = mOptions->LandScape_filename;
           return true;
           }
          
          
           // PAGEINFO
           if (  strKey == "CurrentCameraPageX" )
           {
           if (  mPageManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getCurrentCameraPageX(   );
           return true;
           }
           if (  strKey == "CurrentCameraPageZ" )
           {
           if (  mPageManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getCurrentCameraPageZ(   );
           return true;
           }
          
          
          
           if (  strKey == "PagePreloadQueue" )
           {
           if (  mPageManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getPagePreloadQueueSize(   );
           return true;
           }
           if (  strKey == "PageTextureloadQueue" )
           {
           if (  mPageManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getPageTextureloadQueueSize(   );
           return true;
           }
           if (  strKey == "PageLoadQueue" )
           {
           if (  mPageManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getPageLoadQueueSize(   );
           return true;
           }
          
           if (  strKey == "PreLoadedPages" )
           {
           if (  mPageManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getPreLoadedPageSize(   );
           return true;
           }
           if (  strKey == "TextureLoadedPages" )
           {
           if (  mPageManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getTextureLoadedPageSize(   );
           return true;
           }
           if (  strKey == "LoadedPages" )
           {
           if (  mPageManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getLoadedPageSize(   );
           return true;
           }
          
           if (  strKey == "UnloadedPages" )
           {
           if (  mPageManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getUnloadedPagesSize(   );
           return true;
           }
           //TILES INFO
           if (  strKey == "MaxNumTiles" )
           {
           if (  mTileManager )
           * static_cast < int * > (  pDestValue ) = mTileManager->numTiles(   );
           return true;
           }
           if (  strKey == "TileFree" )
           {
           if (  mTileManager )
           * static_cast < int * > (  pDestValue ) = (  int )mTileManager->numFree(   );
           return true;
           }
           if (  strKey == "CurrentCameraTileX" )
           {
           if (  mTileManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getCurrentCameraTileX(   );
           return true;
           }
           if (  strKey == "CurrentCameraTileZ" )
           {
           if (  mTileManager )
           * static_cast < int * > (  pDestValue ) = mPageManager->getCurrentCameraTileZ(   );
           return true;
           }
          
           //RENDERABLES INFO
           if (  strKey == "MaxNumRenderables" )
           {
           if (  mRenderableManager )
           * static_cast < int * > (  pDestValue ) = mRenderableManager->numRenderables(   );
           return true;
           }
           if (  strKey == "RenderableFree" )
           {
           if (  mRenderableManager )
           * static_cast < int * > (  pDestValue ) = (  int )mRenderableManager->numFree(   );
           return true;
           }
           if (  strKey == "RenderableLoading" )
           {
           if (  mRenderableManager )
           * static_cast < int * > (  pDestValue ) = (  int )mRenderableManager->numLoading(   );
           return true;
           }
           if (  strKey == "VisibleRenderables" )
           {
           if (  mRenderableManager )
           * static_cast < unsigned int * > (  pDestValue ) = mRenderableManager->numVisibles(   );
           else
           * static_cast < unsigned int * > (  pDestValue ) = 0;
           return true;
           }
          
           // IMPACT INFO
           if (  strKey == "Impact" )
           {
           * static_cast < Ogre::Vector3 * > (  pDestValue ) = mImpact;
           return true;
           }
           if (  strKey == "ImpactPageX" )
           {
           if (  mImpactInfo )
           * static_cast < int * > (  pDestValue ) = mImpactInfo->mPageX;
           return true;
           }
           if (  strKey == "ImpactPageZ" )
           {
           if (  mImpactInfo )
           * static_cast < int * > (  pDestValue ) = mImpactInfo->mPageZ;
           return true;
           }
           if (  strKey == "ImpactTileX" )
           {
           if (  mImpactInfo )
           * static_cast < int * > (  pDestValue ) = mImpactInfo->mTileZ;
           return true;
           }
           if (  strKey == "ImpactTileZ" )
           {
           if (  mImpactInfo )
           * static_cast < int * > (  pDestValue ) = mImpactInfo->mTileZ;
           return true;
           }
           if (  strKey == "numModifiedTile" )
           {
           if (  mRenderableManager )
           * static_cast < int * > (  pDestValue ) = mRenderableManager->numRenderables(   );
           return true;
           }
           if (  strKey == "BrushSize" )
           {
           * static_cast < int * > (  pDestValue ) = mBrushSize;
           return true;
           }
           if (  strKey == "BrushScale" )
           {
           * static_cast <Ogre::Real * > (  pDestValue ) = mBrushScale;
           return true;
           }
          
           // Paint
           if (  strKey == "NumChannels" )
           {
           * static_cast < unsigned int * > (  pDestValue ) = mTextureManager->getNumChannels(   );
           return true;
           }
           if (  strKey == "getNumChannelsperTexture" )
           {
           unsigned int requestChannel = *static_cast<unsigned int *>(  pDestValue );
           * static_cast < unsigned int * > (  pDestValue ) = mTextureManager->getNumChannelsperTexture(  requestChannel );
           return true;
           }
           if (  strKey == "currentColors" )
           {
           //
           return true;
           }
           //added for Vertex data retrieval
           if (  strKey == "PageGetTileVertexData_2" )
           {
           /**
           * This is the optimized,   yet a bit fuzzy implementation of the getVertexDataPatch
           * Usage: Pass in a std::vector<void*> Pointer to the getOption call containing at least 5 Elements
           * [0](  Ogre::unsigned int* ) = X Index of the Page to retrieve data from
           * [1](  Ogre::unsigned int* ) = Z Index of the Page to retrieve data from
           * [2](  Ogre::unsigned int* ) = X Index of the Tile within the Page to retrieve data from
           * [3](  Ogre::unsigned int* ) = Z Index of the Tile within the Page to retrieve data from
           * [4](  Ogre::unsigned int* ) = LodLevel to get the data at (  note that level 0 means highest detail )
           * The getData call will then append 3 entries to the end of the vector. In Detail(  in order )
           * [End-2](  Ogre::unsigned int* ) = Number of vertices returned
           * [End-1] (  Ogre::Vector3* ) = The actual vertices,   this is a array containing as many elements as returned in [End-2]
           * [End] (  Ogre::IndexData* ) = The index data for the terrain polygons at the queried LodLevel
           * @remark note that the caller is in charge of deleting the vector array,   vertices array and indice array.
           */
           unsigned int requestPageX = *static_cast<unsigned int *>(  (  *static_cast<std::vector<void*>*>(  pDestValue ) )[0] );
           unsigned int requestPageZ = *static_cast<unsigned int *>(  (  *static_cast<std::vector<void*>*>(  pDestValue ) )[1] );
           unsigned int requestTileX = *static_cast<unsigned int *>(  (  *static_cast<std::vector<void*>*>(  pDestValue ) )[2] );
           unsigned int requestTileZ = *static_cast<unsigned int *>(  (  *static_cast<std::vector<void*>*>(  pDestValue ) )[3] );
           unsigned int requestLodLevel = *static_cast<unsigned int *>(  (  *static_cast<std::vector<void*>*>(  pDestValue ) )[4] );
           PagingLandScapePage* page = mPageManager->getPage(  requestPageX,  requestPageZ );
           if(  page )
           {
           PagingLandScapeTile* tile = page->getTile(  requestTileX,  requestTileZ );
           if(  tile )
           {
           PagingLandScapeRenderable* rend = tile->getRenderable(   );
           if(  rend )
           {
           Vector3* tempPointer; //This will hold the vertexData and needs to be deleted by the caller
           unsigned int* numPtr = new unsigned int;
           *numPtr = rend->getVertexCount(   );
           (  *static_cast<std::vector<void*>*>(  pDestValue ) ).push_back(  numPtr );
           tempPointer = new Ogre::Vector3[*numPtr];
           //warning! make sure that the allocated space for the vertices is big enough!
           rend->getRawVertexData(  tempPointer );
           (  *static_cast<std::vector<void*>*>(  pDestValue ) ).push_back(  tempPointer );
           (  *static_cast<std::vector<void*>*>(  pDestValue ) ).push_back(  rend->getRawIndexData(  requestLodLevel ) );
           return true;
           }
           }
           }
           return false;
           }
           if (  strKey == "getMaterialPageName" )
           {
          
           if (  mPageManager )
           {
           // convert position
           Vector3 **pos = static_cast < Ogre::Vector3 ** > (  pDestValue );
           mPageManager->getGlobalToPage (  (  *pos )->x,   (  *pos )->z );
          
           // get the texture
           Ogre::PagingLandScapeTexture* texture_ptr =
           mTextureManager->getTexture(  (  *pos )->x,   (  *pos )->z,   false );
          
           // check for valid texture
           if(   texture_ptr  )
           {
           // get texture name
           String* name_ptr = const_cast<String*>(  &texture_ptr->getMaterialName(   ) );
          
           // convert void pointer to a string**
           String** target_ptr = static_cast<String**>(  pDestValue );
          
           // save name at target position
           *target_ptr = name_ptr;
           }
           }
           return true;
          
           }
           //end of addition
           if (  mOptions && mOptions->getOption(  strKey,   pDestValue ) == false )
           {
           return PagingLandScapeOctreeSceneManager::getOption (  strKey,   pDestValue );
           }
           return true;
           }
          
           //-----------------------------------------------------------------------
    1523   bool PagingLandScapeSceneManager::hasOption(  const String& strKey ) const
           {
           if (  strKey == "AddNewHeight" )
           {
           return true;
           }
           if (  strKey == "RemoveNewHeight" )
           {
           return true;
           }
           if (  strKey == "CurrentCameraPageX" )
           {
           return true;
           }
           if (  strKey == "CurrentCameraPageZ" )
           {
           return true;
           }
           if (  strKey == "MaxNumTiles" )
           {
           return true;
           }
           if (  strKey == "TileFree" )
           {
           return true;
           }
           if (  strKey == "MaxNumRenderables" )
           {
           return true;
           }
           if (  strKey == "RenderableFree" )
           {
           return true;
           }
           if (  strKey == "RenderableLoading" )
           {
           return true;
           }
           if (  strKey == "PagePreloadQueue" )
           {
           return true;
           }
           if (  strKey == "PageLoadQueue" )
           {
           return true;
           }
           if (  strKey == "PageUnloadQueue" )
           {
           return true;
           }
           if (  strKey == "PagePostUnloadQueue" )
           {
           return true;
           }
           //added for Vertex data retrieval
           if (  strKey == "PageGetTileVertexData" )
           {
           return true;
           }
           //end of addition
           if (  mOptions && mOptions->hasOption(  strKey ) == false )
           {
           return PagingLandScapeOctreeSceneManager::hasOption (  strKey );
           }
           return true;
           }
          
           //-----------------------------------------------------------------------
    1591   bool PagingLandScapeSceneManager::getOptionValues(  const String & key,   StringVector &refValueList )
           {
          // if (  key == "CurrentCameraPageX" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "CurrentCameraPageZ" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "MaxNumTiles" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "TileFree" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "MaxNumRenderables" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "RenderableFree" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "RenderableLoading" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "PagePreloadQueue" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "PageLoadQueue" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "PageUnloadQueue" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          // if (  key == "PagePostUnloadQueue" )
          // {
          // refValueList.push_back(  MemoryDataStreamPtr(   ) );
          // return true;
          // }
          
           if (  mOptions->getOptionValues(  key,   refValueList ) == false )
           {
           return PagingLandScapeOctreeSceneManager::getOptionValues (  key,   refValueList );
           }
           return true;
           }
          
           //-----------------------------------------------------------------------
    1657   bool PagingLandScapeSceneManager::getOptionKeys(  StringVector &refKeys )
           {
           refKeys.clear(   );
           refKeys.push_back(  "AddNewHeight" );
           refKeys.push_back(  "RemoveNewHeight" );
           refKeys.push_back(  "CurrentCameraPageX" );
           refKeys.push_back(  "CurrentCameraPageZ" );
           refKeys.push_back(  "MaxNumTiles" );
           refKeys.push_back(  "TileFree" );
           refKeys.push_back(  "MaxNumRenderables" );
           refKeys.push_back(  "RenderableFree" );
           refKeys.push_back(  "RenderableLoading" );
           refKeys.push_back(  "PagePreloadQueue" );
           refKeys.push_back(  "PageLoadQueue" );
           refKeys.push_back(  "PageUnloadQueue" );
           refKeys.push_back(  "PagePostUnloadQueue" );
           mOptions->getOptionKeys(  refKeys );
           return PagingLandScapeOctreeSceneManager::getOptionKeys (  refKeys );
           }
           //-------------------------------------------------------------------------
    1677   void PagingLandScapeSceneManager::setWorldGeometryRenderQueue (  uint8 qid )
           {
           PagingLandScapeOctreeSceneManager::setWorldGeometryRenderQueue(  qid );
           if (  mPageManager )
           mPageManager->setWorldGeometryRenderQueue (  qid );
           }
           //-----------------------------------------------------------------------
    1684   Camera * PagingLandScapeSceneManager::createCamera(  const String &name )
           {
           if (  mCameras.find(  name ) != mCameras.end(   ) )
           {
           OGRE_EXCEPT(  
           Exception::ERR_DUPLICATE_ITEM,  
           "A camera with the name " + name + " already exists",  
           "PagingLandScapeSceneManager::createCamera" );
           }
          
           Camera * c = new PagingLandScapeCamera(  name,   this );
           mCameras.insert(  CameraList::value_type(  name,   c ) );
           PagingLandScapeOctreeSceneManager::addCamera (  c );
           // Check if we need to set the primaryCamera
           if (  mOptions && !mOptions->primaryCamera )
           {
           mOptions->setPrimaryCamera (  static_cast <PagingLandScapeCamera*> (  c ) );
           }
           //default values
           c->setNearClipDistance(   1  );
           // Infinite far plane?
           if (  Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->hasCapability(  RSC_INFINITE_FAR_PLANE ) )
           {
           c->setFarClipDistance(  0 );
           }
           else if (  mOptions )
           {
           float tmp;
           getOption(   "VisibleDistance",   &tmp );
           c->setFarClipDistance(   tmp  );
           }
          #ifdef PLSM2_EIHORT
           // create visible bounds aab map entry
           mCamVisibleObjectsMap[c] = VisibleObjectsBoundsInfo(   );
          #endif
           return c;
           }
           //-----------------------------------------------------------------------
    1722   void PagingLandScapeSceneManager::destroyCamera(  Camera *cam )
           {
           if (  mOptions->primaryCamera && cam->getName(   ) == mOptions->primaryCamera->getName(   ) )
           {
           mOptions->setPrimaryCamera (  0 );
           }
           PagingLandScapeOctreeSceneManager::destroyCamera(  cam );
           }
           //-----------------------------------------------------------------------
    1731   void PagingLandScapeSceneManager::destroyCamera(  const String& name )
           {
           if (  mOptions->primaryCamera && name == mOptions->primaryCamera->getName(   ) )
           {
           mOptions->setPrimaryCamera (  0 );
           }
           PagingLandScapeOctreeSceneManager::destroyCamera(  name );
           }
           //-----------------------------------------------------------------------
    1740   void PagingLandScapeSceneManager::destroyAllCameras(  void )
           {
           mOptions->setPrimaryCamera (  0 );
           PagingLandScapeOctreeSceneManager::destroyAllCameras(   );
           }
           //-----------------------------------------------------------------------
           void _OgrePagingLandScapeExport PagingLandScapeSceneManager::getWorldSize(  Real *worldSizeX,  Ogre::Real *worldSizeZ )
           {
    1748   *worldSizeX = mOptions->maxScaledX * 2.0f;
    1749   *worldSizeZ = mOptions->maxScaledZ * 2.0f;
          // *worldSizeX = (  float )mOptions->world_width * mOptions->scale.x;
          // *worldSizeZ = (  float )mOptions->world_height * mOptions->scale.z;
           }
           //-----------------------------------------------------------------------
           float _OgrePagingLandScapeExport PagingLandScapeSceneManager::getMaxSlope(  Vector3 location1,   Ogre::Vector3 location2,   float maxSlopeIn )
           {
           return mData2DManager->getMaxSlope(  location1,   location2,   maxSlopeIn );
           }
           //-----------------------------------------------------------------------
           void PagingLandScapeSceneManager::renderBaseTextures(  const String& alternateMatName )
           {
          
           //only currently works for PLSplattingShaderLit mode
           //because I can't figure out how to elegantly handle all texture modes (  yet )
           if(  mOptions->textureFormat != "PLSplattingShaderLit" || alternateMatName != "PLSplattingShaderUnlit" )
           {
           OGRE_EXCEPT(  
           Exception::ERR_NOT_IMPLEMENTED,  
           "Only currently supports PLSplattingShaderLit texture mode and alternate material SplattingShader",  
           "PagingLandScapeSceneManager::renderBaseTextures" );
           }
          
           PagingLandScapeTexture* t = NULL;
           String matName;
           TexturePtr texture;
           RenderTexture *renderTexture;
           Camera *rttCam;
           texture = TextureManager::getSingleton (   ).createManual(  "PLRTTBaseTexture",  
           ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,  
           TEX_TYPE_2D,  
           256,  
           256,  
           0,  
           PF_A8R8G8B8,  
           TU_RENDERTARGET );
          
           renderTexture = texture->getBuffer(   )->getRenderTarget(   );
           renderTexture->setAutoUpdated(  false );
           rttCam = createCamera(  "PLRTTBaseTextureCam" );
           rttCam->setNearClipDistance(  1.0f );
           rttCam->setFarClipDistance(  0 );
           rttCam->setPosition(  Vector3(  0,  0,  2 ) );
           rttCam->lookAt(  Vector3(  0,  0,  0 ) );
           Viewport* const v = renderTexture->addViewport(  rttCam );
           v->setClearEveryFrame(  true );
           v->setBackgroundColour(  ColourValue(  0.0f,   0.0f,   0.0f,   0.0f ) );
          
           //addSpecialCaseRenderQueue(  Ogre::RENDER_QUEUE_6 );
           //setSpecialCaseRenderQueueMode(  Ogre::SceneManager::SCRQM_INCLUDE );
          
           Rectangle2D* rect = new Rectangle2D(  true );
           rect->setBoundingBox(  AxisAlignedBox(  -100000.0*Vector3::UNIT_SCALE,   100000.0*Vector3::UNIT_SCALE ) );
           rect->setCorners(  -1,   1,   1,   -1 );
           rect->setRenderQueueGroup(  Ogre::RENDER_QUEUE_OVERLAY );
           SceneNode* node = getRootSceneNode(   )->createChildSceneNode(  "PLBaseTextureRectNode" );
           rect->setVisible(  true );
           node->attachObject(  rect );
           String textureName;
           size_t strPos = 0;
           MaterialPtr material;
           MaterialPtr alternateMaterial;
           //this->setAmbientLight(  ColourValue::White );
          
           for(  uint x = 0; x < mOptions->world_width; ++x )
           {
           for(  uint z = 0; z < mOptions->world_height; ++z )
           {
           t = mTextureManager->getTexture(  x,   z );
           if(  !t->isLoaded(   ) )
           t->load(  x,   z );
          
           textureName = mOptions->LandScape_filename + ".Base." + StringConverter::toString(  z ) + "." + StringConverter::toString(  x ) + ".png";
           matName = t->getMaterialName(   );
          
           //if an alternate material name is specified,   we'll use the texture units from our original material
           //and the passes from our new material
           if(  alternateMatName != "" )
           {
           alternateMaterial = MaterialManager::getSingleton(   ).getByName(  alternateMatName + "_Clone" );
           if(  alternateMaterial.isNull(   ) )
           {
           alternateMaterial = MaterialManager::getSingleton(   ).getByName(  alternateMatName );
           if(  alternateMaterial.isNull(   ) )
           {
           OGRE_EXCEPT(  
           Exception::ERR_ITEM_NOT_FOUND,  
           "Could not find alternate material " + alternateMatName,  
           "PagingLandScapeSceneManager::renderBaseTextures" );
           }
           alternateMaterial = alternateMaterial->clone(  alternateMatName + "_Clone" );
           }
           matName = alternateMaterial->getName(   );
           material = t->getMaterial(   );
          
           //we know that pass 2 of PLSplattingShaderLitDecompress has our coverage and
           //splatting textures in specific texture units
           //I think if we want this to be completely generic we'll have to load the original
           //texture mode's material,   iterate through and find the "Coverage" and "Splatting" references from it,  
           //and do the same for alternate material,   and attempt to hook them up the same
           for(  uint i = 0; i < 5; ++i )
           {
           alternateMaterial->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  i )->setTextureName(  material->getTechnique(  0 )->getPass(  1 )->getTextureUnitState(  i )->getTextureName(   ) );
           }
           }
          
           //assign the material to the rectangle
           rect->setMaterial(  matName );
           _updateSceneGraph(  rttCam );
           renderTexture->update(   );
           renderTexture->writeContentsToFile(  "../../../Media/paginglandscape2/terrains/" + mOptions->LandScape_filename + "/" + textureName );
           TexturePtr texture = TextureManager::getSingleton(   ).getByName(  textureName );
           if(  !texture.isNull(   ) )
           texture->reload(   );
          
           if(  mOptions->VertexCompression )
           {
           MaterialManager::getSingleton(   ).remove(  material->getHandle(   ) );
           }
           }
           }
          
           TextureManager::getSingleton(   ).remove(  texture->getHandle(   ) );
           destroyCamera(  "PLRTTBaseTextureCam" );
           node->detachObject(  rect );
           destroySceneNode(  "PLBaseTextureRectNode" );
          
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeSceneManagerDll.cpp

          /***************************************************************************
           OgrePagingLandScapeSceneManagerDll.cpp - description
           -------------------
           begin : Mon May 12 2003
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreRoot.h"
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeSceneManager.h"
          
          namespace Ogre
          {
           PagingLandScapeSceneManagerFactory* PagingLandScapePlugin;
          
           extern "C" void _OgrePagingLandScapeExport dllStartPlugin(  void )
           {
           // Create new scene manager Factory
      34   PagingLandScapePlugin = new PagingLandScapeSceneManagerFactory(   );
          
           // Register Factory
      37   Root::getSingleton(   ).addSceneManagerFactory(  PagingLandScapePlugin );
           }
          
           extern "C" void _OgrePagingLandScapeExport dllShutdownPlugin(  void )
           {
           Root::getSingleton(   ).removeSceneManagerFactory(  PagingLandScapePlugin );
           }
          
           extern "C" void _OgrePagingLandScapeExport dllStopPlugin(  void )
           {
           delete PagingLandScapePlugin;
           }
          }

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture.cpp - description
          -------------------
          begin : Fri Apr 16 2004
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeTexture.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      42   PagingLandScapeTexture::PagingLandScapeTexture(  PagingLandScapeTextureManager *textureMgr,  
      43   const String materialBaseName,  
           const unsigned int numTexture,  
      45   const bool isSplatMode ) :
           mParent(  textureMgr ),  
           mMaterialBaseName(  materialBaseName ),  
           mIsLoaded (  false ),  
           mIsModified (  false ),  
           mDataX (  0 ),  
           mDataZ (  0 ),  
           mPaintRect (  0,   0,   0,   0,   0,   1 ),  
           mIsPaintRectModified(  false ),  
           mDeformRect (  0,   0,   0,   0,   0,   1 ),  
           mIsDeformRectModified(  false ),  
           mIsSplatMode(  isSplatMode ),  
           mNumTexture(  numTexture ),  
           mIsShadowed(  false ),  
           mIsShaderShadowed(  false ),  
           mIsBaseMode(  false )
           {
           mMaterial.setNull(   );
           }
           //-----------------------------------------------------------------------
      65   PagingLandScapeTexture::~PagingLandScapeTexture(   )
           {
           mNumChannelperTexture.clear(   );
           mImages.clear(   );
           mTextures.clear(   );
           mBuffers.clear(   );
           doTextureNeedUpdate.clear(   );
           isTextureModified.clear(   );
           }
           //-----------------------------------------------------------------------
      75   void PagingLandScapeTexture::setNumTexture(   )
           {
           if (  mNumTexture > 0 )
           {
           mNumChannelperTexture.reserve(  mNumTexture );
           doTextureNeedUpdate.reserve(  mNumTexture );
           isTextureModified.reserve(  mNumTexture );
           mTextures.reserve(  mNumTexture );
           mBuffers.reserve(  mNumTexture );
          
           mImages.reserve(  mNumTexture );
          
           mNumChannelperTexture.resize(  mNumTexture );
           doTextureNeedUpdate.resize(  mNumTexture );
           isTextureModified.resize(  mNumTexture );
           mTextures.resize(  mNumTexture );
           mBuffers.resize(  mNumTexture );
          
           mImages.resize(  mNumTexture );
          
           for (  size_t i = 0; i < mNumTexture; i++ )
           {
           mImages[i].loadDynamicImage (  0,   0,   0,   1,   PF_R8G8B8A8,   true,   1,   0 );
           }
          
           }
           }
           //-----------------------------------------------------------------------
     103   const String &PagingLandScapeTexture::getMaterialName(   )
           {
           return mMaterial->getName (   );
           }
           //-----------------------------------------------------------------------
     108   void PagingLandScapeTexture::bindCompressionSettings(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           Material::TechniqueIterator tIt = mMaterial->getTechniqueIterator (   );
           while (  tIt.hasMoreElements (   ) )
           {
           Technique * const t = tIt.getNext (   );
           Technique::PassIterator pIt = t->getPassIterator (   );
           while (  pIt.hasMoreElements (   ) )
           {
           Pass *p = pIt.getNext (   );
           if (  p->hasVertexProgram (   ) )
           {
           // vertex compression setting
           GpuProgramParametersSharedPtr params = p->getVertexProgramParameters(   );
           if (  opt->VertexCompression )
           {
           bindCompressionSettings (  params );
           bindCompressionSettings (  p->getShadowReceiverVertexProgramParameters (   ) );
           }
          
           // splat settings.
          #ifdef PLSM2_EIHORT
           GpuConstantDefinition const * const e = params->_findNamedConstantDefinition(  "splatSettings",   false );
           if (  e )
           {
           // use index to get RealConstantEntry
           params->_writeRawConstant(  e->physicalIndex + 0,   opt->matHeight[1] );
           params->_writeRawConstant(  e->physicalIndex + 1,   opt->matHeight[2] );
           params->_writeRawConstant(  e->physicalIndex + 2,   float(  opt->maxValue ) );
           params->_writeRawConstant(  e->physicalIndex + 3,   0.0f );
           }
          #else
           GpuProgramParameters::RealConstantEntry * const e = params->getNamedRealConstantEntry (  "splatSettings" );
           if (  e )
           {
           e->val[0] = static_cast <float> (  opt->matHeight[1] );
           e->val[1] = static_cast <float> (  opt->matHeight[2] );
           e->val[2] = static_cast <float> (  opt->maxValue );
           e->val[3] = static_cast <float> (  0.0 );
           e->isSet = true;
           }
          #endif
          
          
           }
           }
           }
           }
           //-----------------------------------------------------------------------
     159   void PagingLandScapeTexture::bindCompressionSettings(  GpuProgramParametersSharedPtr params )
           {
           GpuProgramParameters::AutoConstantIterator aci = params->getAutoConstantIterator(   );
           bool found = false;
           while (  aci.hasMoreElements(   ) )
           {
           const GpuProgramParameters::AutoConstantEntry& ace = aci.getNext(   );
           if (  ace.paramType == GpuProgramParameters::ACT_CUSTOM &&
           ace.data == MORPH_CUSTOM_PARAM_ID )
           {
           found = true;
           }
           }
           if (  !found )
           {
           params->setNamedAutoConstant(  "compressionSettings",  
           GpuProgramParameters::ACT_CUSTOM,   MORPH_CUSTOM_PARAM_ID );
           }
           }
           //-----------------------------------------------------------------------
     179   void PagingLandScapeTexture::loadTexturesToModify(   )
           {
           if (  mNumTexture > 0 || (  mIsShadowed && !mIsShaderShadowed ) )
           {
           const String nameSep(  "." );
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
           const String filename (  opt->LandScape_filename );
           const String commonName (  StringConverter::toString(  mDataZ ) +
           nameSep + StringConverter::toString(  mDataX ) );
          
           unsigned int channel = 0;
           TextureManager* texMgr = TextureManager::getSingletonPtr(   );
          
           const unsigned short numLodLevels =
           mMaterial->getNumLodLevels(  MaterialManager::getSingleton(   )._getActiveSchemeIndex(   ) );
           // some texture are shared between techniques,   ensure it's loaded once.
           bool imageLoaded = false;
           bool baseLoaded = false;
           bool coverageLoaded = false;
           bool lightLoaded = false;
           bool horizonLoaded = false;
          
           for(  unsigned short k = 0; k < numLodLevels; k++ )
           {
           Technique *t = mMaterial->getBestTechnique (  k );
           Technique::PassIterator pIt = t->getPassIterator (   );
           String texType;
           channel = 0;
           while (  pIt.hasMoreElements (   ) )
           {
           Pass *p = pIt.getNext (   );
           Pass::TextureUnitStateIterator tuIt = p->getTextureUnitStateIterator (   );
           while (  tuIt.hasMoreElements (   ) )
           {
           TextureUnitState *tu = tuIt.getNext (   );
          
           const String texName (  tu->getTextureName(   ) );
           if (  !imageLoaded && opt->ImageNameLoad &&
           StringUtil::startsWith (  texName,   opt->image_filename ) )
           {
           // if it's an Image Texture mode
           mTextures[channel] = texMgr->getByName (  texName );
           assert (  !mTextures[channel].isNull(   ) &&
           String(  texName + " is missing" ).c_str(   ) );
           mBuffers[channel] = mTextures[channel]->getBuffer(   );
           loadColorTexture (  texName,   channel );
           channel++;
           imageLoaded = true;
           }
           else if (  StringUtil::startsWith (  texName,   filename,   false ) )
           {
           // if it's a dynamic texture updated by texture mode
           // subtracts filename from texname
           String texNameInfo = texName.substr (  filename.size (   ) );
           //then split on Dot (  in case of filename with dot in it. )
           const StringVector texNameInfos =
           StringUtil::split(  texNameInfo,   nameSep );
           texType = texNameInfos[0];
          
           if (  texType == "Alpha" )
           {
           mTextures[channel] = texMgr->getByName (  texName );
           assert (  !mTextures[channel].isNull(   ) &&
           String(  texName + " is missing" ).c_str(   ) );
           mBuffers[channel] = mTextures[channel]->getBuffer(   );
           loadAlphaTexture (  texName,   channel );
           channel++;
           }
           else if (  texType == "Coverage" )
           {
           mTextures[channel] = texMgr->getByName (  texName );
           assert (  !mTextures[channel].isNull(   ) &&
           String(  texName + " is missing" ).c_str(   ) );
           mBuffers[channel] = mTextures[channel]->getBuffer(   );
           loadColorTexture (  texName,   channel );
           coverageLoaded = true;
           channel++;
           }
           else if (  !lightLoaded && !mIsShaderShadowed
           && texType == "Light"  )
           {
           mLightTexture = texMgr->getByName (  texName );
           assert (  !mLightTexture.isNull(   ) &&
           String(  texName + " is missing" ).c_str(   ) );
           mLightBuffer = mLightTexture->getBuffer(   );
           loadTexture (  texName,   mLightImage );
          
           assert (  mLightBuffer->getWidth (   ) == mLightImage.getWidth (   ) &&
           mLightBuffer->getHeight (   ) == mLightImage.getHeight (   ) );
          
           String shadowTexName (  filename + nameSep + "HS" );
           for (  size_t k = 1; k < texNameInfos.size(   ); k++ )
           shadowTexName += nameSep + texNameInfos[k];
           if (  ResourceGroupManager::getSingleton(   ).
           resourceExists (  opt->groupName,   shadowTexName ) )
           {
           loadTexture (  shadowTexName,   mShadow );
           assert (  mShadow.getWidth (   ) == mLightImage.getWidth (   ) &&
           mShadow.getHeight (   ) == mLightImage.getHeight (   ) );
           lightUpdate (   );
           }
           else
           {
           mIsShadowed = false;
           }
           lightLoaded = true;
           }
           else if (  !coverageLoaded && !baseLoaded && texType == "Base" )
           {
           mTextures[channel] = texMgr->getByName (  texName );
           assert (  !mTextures[channel].isNull(   ) &&
           String(  texName + " is missing" ).c_str(   ) );
           mBuffers[channel] = mTextures[channel]->getBuffer(   );
           loadColorTexture (  texName,   channel );
           channel++;
           baseLoaded = true;
           }
           }
           }
           }
           for (  unsigned int i = 0; i < mNumTexture; i++ )
           {
           mNumChannelperTexture[i] = mImages[i].getBPP (   ) / 8;
           doTextureNeedUpdate[i] = false;
           isTextureModified[i] = false;
           }
           }
           }
           }
           //-----------------------------------------------------------------------
     309   void PagingLandScapeTexture::setOptions(  void )
           {
           PagingLandScapeOptions * const opt = mParent->getOptions(   );
           String matClassName (  
           (  opt->VertexCompression ?
           String(  mMaterialBaseName + "Decompress" )
           :
           mMaterialBaseName ) );
          
           MaterialPtr material = MaterialManager::getSingleton(   ).getByName (  matClassName );
           if (  opt->VertexCompression && material.isNull(   ) )
           {
           matClassName = mMaterialBaseName;
           opt->VertexCompression = false;
           opt->lodMorph = false;
           material = MaterialManager::getSingleton(   ).getByName (  matClassName );
           }
           assert (  !material.isNull(   ) &&
           String(  matClassName + "Must exists in the" + opt->groupName + "group" ).c_str (   ) );
          
           bool hasVertexProgram = false;
           bool hasFragmentProgram = false;
          
           Material::TechniqueIterator tIt = material->getTechniqueIterator (   );
           while (  tIt.hasMoreElements (   ) )
           {
           Technique * const t = tIt.getNext (   );
           Technique::PassIterator pIt = t->getPassIterator (   );
           while (  pIt.hasMoreElements (   ) )
           {
           Pass * const p = pIt.getNext (   );
          
           // vertex shaders.
           if (   p->hasVertexProgram (   ) )
           {
           if (  hasVertexProgram == false )
           {
           hasVertexProgram = p->hasVertexProgram (   );
           }
           GpuProgramParametersSharedPtr params = p->getVertexProgramParameters(   );
          
          #ifdef PLSM2_EIHORT
           GpuConstantDefinition const * const e = params->_findNamedConstantDefinition(  "splatSettings" );
          #else
           GpuProgramParameters::RealConstantEntry * const e = params->getNamedRealConstantEntry (  "splatSettings" );
          #endif
           if (  e )
           {
           opt->normals = true;
           }
           }
          
           // pixel shaders.
           if (  hasFragmentProgram == false )
           {
           hasFragmentProgram = p->hasFragmentProgram (   );
           }
           }
           }
           if (  !hasVertexProgram )
           {
           opt->VertexCompression = false;
           opt->lodMorph = false;
           }
           }
           //-----------------------------------------------------------------------
     375   bool PagingLandScapeTexture::isMaterialSupported(  bool recursive )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->VertexCompression && recursive )
           {
           const String MatClassName (  mMaterialBaseName );
           mMaterialBaseName = mMaterialBaseName + "Decompress";
           const bool isOk = MaterialManager::getSingleton (   ).resourceExists (  mMaterialBaseName ) &&
           isMaterialSupported(  false );
           mMaterialBaseName = MatClassName;
           if (  isOk )
           return true;
           }
          
           MaterialPtr material = MaterialManager::getSingleton(   ).getByName (  mMaterialBaseName );
           assert (  !material.isNull(   ) &&
           String(  mMaterialBaseName + " Must exists in the" + opt->groupName + "group" ).c_str (   ) );
          
           unsigned short numPasses = 0;
          
           //these will store the maximum number of texture units,   alpha textures,  
           //coverage textures,   etc. after iterating through all passes in the material
           size_t numTextureUnits = 0;
           size_t numAlphaTexture = 0;
           size_t numCoverageTexture = 0;
           size_t numSplats = 0;
           unsigned int numDynamicTexture = 0;
          
           //per pass count
           size_t passNumTextureUnits;
           size_t passNumAlphaTextures;
           size_t passNumCoverageTextures;
           size_t passNumSplats;
           unsigned int passNumDynamicTextures;
          
           bool needVertexProgram = false;
           bool needFragmentProgram = false;
           bool isImageMode = false;
           bool isSplatMode = false;
           bool isBaseMode = false;
          
           Material::TechniqueIterator tIt = material->getTechniqueIterator (   );
           while (  tIt.hasMoreElements (   ) )
           {
           Technique * const t = tIt.getNext (   );
           numPasses = std::max (  numPasses,   t->getNumPasses(   ) );
           Technique::PassIterator pIt = t->getPassIterator (   );
           while (  pIt.hasMoreElements (   ) )
           {
          
           passNumTextureUnits = 0;
           passNumAlphaTextures = 0;
           passNumCoverageTextures = 0;
           passNumSplats = 0;
           passNumDynamicTextures = 0;
           Pass * const p = pIt.getNext (   );
           if (  needVertexProgram == false )
           needVertexProgram = p->hasVertexProgram (   );
           if (  needFragmentProgram == false )
           needFragmentProgram = p->hasFragmentProgram (   );
          #ifdef PLSM2_EIHORT
           numTextureUnits = std::max<unsigned int>(  static_cast<unsigned int>(  numTextureUnits ),   static_cast<unsigned int>(  p->getNumTextureUnitStates(   ) ) );
          #else
           numTextureUnits = std::max (  numTextureUnits,   p->getNumTextureUnitStates(   ) );
          #endif
           Pass::TextureUnitStateIterator tuIt = p->getTextureUnitStateIterator (   );
           while (  tuIt.hasMoreElements (   ) )
           {
           TextureUnitState * const tu = tuIt.getNext (   );
           const String texType (  tu->getTextureName(   ) );
           if (  std::string::npos == texType.find(  "." ) )
           {
           // This Texture Name is A keyword,  
           // check how many are dynamic in this material
           if (  !isBaseMode &&
           StringUtil::startsWith (  texType,   "base",   true ) )
           {
           isBaseMode = true;
           passNumDynamicTextures++;
           }
           else if (  !isImageMode &&
           StringUtil::startsWith (  texType,   "image",   true ) )
           {
           isImageMode = true;
           passNumDynamicTextures++;
           }
           else if (  texType == "Alpha" &&
           StringUtil::startsWith (  texType,   "alpha",   true ) )
           {
           isSplatMode = true;
           passNumAlphaTextures++;
           passNumDynamicTextures++;
           }
           else if (  texType == "Coverage" &&
           StringUtil::startsWith (  texType,   "coverage",   true ) )
           {
           isSplatMode = true;
           passNumDynamicTextures++;
           passNumCoverageTextures++;
           }
           else if (  texType == "Splatting" &&
           StringUtil::startsWith (  texType,   "splatting",   true ) )
           {
           mIsSplatMode = true;
           passNumSplats++;
           }
           else if (  texType == "Light" &&
           StringUtil::startsWith (  texType,   "light",   true ) )
           {
           //dynamic light... but in software
           mIsShadowed = true;
           }
           else if (  texType == "Horizon" &&
           StringUtil::startsWith (  texType,   "horizon",   true ) )
           {
           //dynamic light... but shader
           mIsShaderShadowed = true;
           mIsShadowed = true;
           }
           }
           }
          
           if(  passNumTextureUnits > numTextureUnits )
           numTextureUnits = passNumTextureUnits;
          
           numAlphaTexture += passNumAlphaTextures;
           numCoverageTexture += passNumCoverageTextures;
           numSplats += passNumSplats;
           numDynamicTexture += passNumDynamicTextures;
          
           }
           }
           if (  isImageMode && !opt->ImageNameLoad )
           return false;
           if (  opt->numTextureUnits < numTextureUnits )
           return false;
           if (  needVertexProgram && opt->hasVertexShader == false )
           return false;
           if (  needFragmentProgram && opt->hasFragmentShader == false )
           return false;
          
           if (  isSplatMode && numAlphaTexture && opt->NumMatHeightSplat < numAlphaTexture )
           return false;
          
           // does all coverage must be 4 alpha ?
           //if (  isSplatMode && numCoverageTexture && opt->NumMatHeightSplat < numCoverageTexture * 4 )
           // return false;
           if (  isSplatMode && numCoverageTexture && opt->NumMatHeightSplat < 4 )
           return false;
          
           if (  mIsShaderShadowed && !opt->hasFragmentShader2 )
           return false;
          
           mIsSplatMode = isSplatMode;
           mIsBaseMode = !mIsSplatMode && isBaseMode;
           mNumTexture = (  mParent->getOptions(   )->textureModifiable )? numDynamicTexture : 0;
           return true;
           }
           //-----------------------------------------------------------------------
     535   void PagingLandScapeTexture::_loadMaterial(   )
           {
           if (  mMaterial.isNull(   ) )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
           const String nameSep(  "." );
           const String commonName (  StringConverter::toString(  mDataZ ) +
           nameSep + StringConverter::toString(  mDataX ) );
           if (  opt->materialPerPage )
           {
           // JEFF - all material settings configured through material script
           mMaterial = MaterialManager::getSingleton(   ).getByName(  
           mMaterialBaseName + commonName );
           }
           else
           {
           const String filename (  opt->LandScape_filename );
           const bool compressed = opt->VertexCompression;
           const String MatClassName (  
           (  compressed ?
           String(  mMaterialBaseName + "Decompress" )
           :
           mMaterialBaseName ) );
           const String matname (  MatClassName + nameSep
           + commonName + nameSep
           + filename );
           mMaterial = MaterialManager::getSingleton(   ).getByName(  matname );
           if (  mMaterial.isNull(   ) )
           {
           mMaterial = MaterialManager::getSingleton(   ).getByName(  MatClassName );
           assert (  !mMaterial.isNull(   ) &&
           String(  MatClassName + "Must exists in the" + opt->groupName + "group" ).c_str (   ) );
           mMaterial = mMaterial->clone(  matname );
           const String extName (  opt->TextureExtension );
           const String beginName (  filename + nameSep );
           const String endName (  nameSep + commonName +
           nameSep );
           bool deformable;
           String texName,   finalTexName;
           unsigned int channel = 0;
           unsigned int splat = 0;
          
           unsigned int alphachannel = 0;
           unsigned int coveragechannel = 0;
          
           Material::TechniqueIterator tIt = mMaterial->getTechniqueIterator (   );
           while (  tIt.hasMoreElements (   ) )
           {
           splat = 0;
           channel = 0;
           coveragechannel = 0;
           alphachannel = 0;
           Technique * const t = tIt.getNext (   );
           Technique::PassIterator pIt = t->getPassIterator (   );
           while (  pIt.hasMoreElements (   ) )
           {
           Pass * const p = pIt.getNext (   );
           Pass::TextureUnitStateIterator tuIt = p->getTextureUnitStateIterator (   );
           while (  tuIt.hasMoreElements (   ) )
           {
           TextureUnitState * const tu = tuIt.getNext (   );
           const String texType (  tu->getTextureName(   ) );
           if (  std::string::npos == texType.find(  "." ) )
           {
           // This Texture Name is A keyword,  
           // meaning we have to dynamically replace it
           deformable = false;
           // check by what texture to replace keyword
           if (  StringUtil::startsWith (  texType,   "image",   true ) )
           {
           texName = opt->image_filename + endName;
           deformable = true;
           }
           else if (  StringUtil::startsWith (  texType,   "splatting",   true ) )
           {
           texName = opt->SplatDetailMapNames[splat % opt->NumMatHeightSplat];
           splat++;
           }
           else if (  StringUtil::startsWith (  texType,   "base",   true ) )
           {
           texName = beginName + texType + endName;
           channel++;
           deformable = true;
           }
           else if (  StringUtil::startsWith (  texType,   "alpha",   true ) )
           {
           texName = beginName + texType + nameSep +
           StringConverter::toString(  alphachannel ) + endName;
           deformable = true;
           alphachannel++;
           channel++;
           }
           else if (  StringUtil::startsWith (  texType,   "coverage",   true ) )
           {
           texName = beginName + texType + nameSep +
           StringConverter::toString(  (  coveragechannel * 4 ) % opt->NumMatHeightSplat ) + endName;
           deformable = true;
           channel++;
           coveragechannel++;
           }
           else if (  StringUtil::startsWith (  texType,   "light",   true ) )
           {
           texName = beginName + texType + endName + extName;
           }
           else if (  StringUtil::startsWith (  texType,   "horizon",   true ) )
           {
           texName = beginName + "HSP" + endName + extName;
           mPositiveShadow = true;
           }
           if (  deformable )
           {
           if(  opt->Deformable &&
           ResourceGroupManager::getSingleton(   ).resourceExists(  
           opt->groupName,  
           texName + "modif." + extName ) )
           {
           finalTexName = texName + "modif." + extName;
           }
           else
           {
           finalTexName = texName + extName;
           }
           }
           else
           {
           finalTexName = texName;
           }
           tu->setTextureName (  finalTexName );
           }
           }
           }
           }
           }
           }
           }
           }
           //-----------------------------------------------------------------------
     672   void PagingLandScapeTexture::_unloadMaterial(   )
           {
          
          
           }
           //-----------------------------------------------------------------------
     678   void PagingLandScapeTexture::load(  unsigned int x,   unsigned int z )
           {
           if (  !mIsLoaded && isMaterialSupported(   ) )
           {
           mDataX = x;
           mDataZ = z;
           updated(   );
           setNumTexture (   );
           _loadMaterial(   );
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
           mMaterial->setLightingEnabled (  opt->lit );
           mMaterial->setLodLevels (  opt->lodMaterialDistanceList );
           mMaterial->setReceiveShadows (  true );
           // If vertex shader,   have to bind parameters
           bindCompressionSettings (   );
           mMaterial->load (   );
           // load texture in main memory if we want to update it Real-Time
           loadTexturesToModify(   );
          
           mIsLoaded = true;
           mIsModified = false;
           }
           }
           //-----------------------------------------------------------------------
     702   void PagingLandScapeTexture::unload(   )
           {
           if (  mIsLoaded )
           {
           if (  mIsModified && mParent->getOptions(   )->saveDeformation )
           _save(   );
          
           if (  !mMaterial.isNull(   ) )
           mMaterial->unload(   );
          
           for (  unsigned int i = 0; i < mNumTexture; i++ )
           {
           doTextureNeedUpdate[i] = false;
           isTextureModified[i] = false;
           mBuffers[i].setNull (   );
           mTextures[i].setNull (   );
           mImages[i].loadDynamicImage (  0,   0,   0,   1,   PF_R8G8B8A8,   true,   1,   0 );
           }
           // Anyway,   they're surely null already,   as they're freed by delete page(   )
          
           _unloadMaterial(   );
          
           const String resourceName (  mMaterial->getName (   ) );
          
           assert (  !mMaterial.isNull(   ) && "PagingLandScapeTexture::unload" );
           mMaterial->unload(   );
           mMaterial.setNull(   );
           MaterialManager::getSingleton(   ).remove (  resourceName );
          
           mIsLoaded = false;
           }
          
           }
           //-----------------------------------------------------------------------
     736   void PagingLandScapeTexture::_save(  void )
           {
           assert (  !mMaterial.isNull(   ) && "PagingLandScapeTexture::::_save" );
          
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
           if (  mNumTexture > 0 && opt->textureModifiable )
           {
           const String extname (  opt->TextureExtension );
           for (  unsigned int i = 0; i < mNumTexture; i++ )
           {
           if (  isTextureModified[i] )
           {
           String texName = mTextures[i]->getName (   );
          
           FileInfoListPtr finfo = ResourceGroupManager::getSingleton(   ).findResourceFileInfo (  
           opt->groupName,   texName );
           FileInfoList::iterator it = finfo->begin(   );
           if (  it != finfo->end(   ) )
           {
           char *olddir = ChangeToDir (  const_cast< char * > (  (  (  it )->archive->getName(   ) ).c_str(   ) ) );
           //FileSystemArchive::pushDirectory(   )
          
           assert (  mImages[i].getData (   ) );
           // check if we have to add modif to the name.
           const String baseTexName (  texName,   0,   texName.size (   ) - extname.size(   ) );
           if (  !StringUtil::endsWith (  baseTexName,   "modif." ) )
           {
           texName = baseTexName + "modif." + extname;
           }
           mImages[i].save (  texName );
          
           RetablishDir (  olddir );
           //FileSystemArchive::popDirectory(   );
          
           } // if (  it != finfo->end(   ) )
           } // if (  doTextureNeedUpdate[i] )
           } // for (  unsigned int i = 0; i < mNumTexture; i++ )
           }
           }
           //-----------------------------------------------------------------------
     776   void PagingLandScapeTexture::upload(  const Image::Box& textureRect )
           {
           assert (  mNumTexture > 0 );
           assert (  !mMaterial.isNull(   ) && "PagingLandScapeTexture::update(   )" );
          
           for (  unsigned int i = 0; i < mNumTexture; i++ )
           {
           if (  doTextureNeedUpdate[i] )
           {
           assert (  !mTextures[i].isNull(   ) && "PagingLandScapeTexture::update(   )" );
           assert (  !mBuffers[i].isNull(   ) && "PagingLandScapeTexture::update(   )" );
           assert (  mImages[i].getData (   ) != 0 && "PagingLandScapeTexture::update(   )" );
          
           const PixelBox srcBox = mImages[i].getPixelBox(   ).getSubVolume(  textureRect );
           const PixelBox lock = mBuffers[i]->lock(  textureRect,   HardwareBuffer::HBL_DISCARD );
           PixelUtil::bulkPixelConversion(  srcBox,   lock );
           mBuffers[i]->unlock(   );
          
           doTextureNeedUpdate[i] = false;
           isTextureModified[i] = true;
          
           //#define _Missed_Spot
          
           #ifdef _Missed_Spot
           // debug can help finding missed spot.
           const PixelBox srcSpotBox = mImages[i].getPixelBox(   );
           const unsigned int textureSize = (  mParent->getOptions(   )->PageSize - 1 ) *
           mParent->getOptions(   )->TextureStretchFactor;
           const Image::Box rect (  0,   0,   0,   textureSize,   textureSize,   1 );
           const PixelBox lockSpot = mBuffers[i]->lock (  rect ,  HardwareBuffer::HBL_DISCARD );
           PixelUtil::bulkPixelConversion(  srcSpotBox,   lockSpot );
           mBuffers[i]->unlock(   );
           #endif //_Missed_Spot
           }
           }
           }
           //-----------------------------------------------------------------------
     813   bool PagingLandScapeTexture::isLoaded(   ) const
           {
           return mIsLoaded;
           }
           //-----------------------------------------------------------------------
     818   const MaterialPtr& PagingLandScapeTexture::getMaterial(   ) const
           {
           return mMaterial;
           }
           //-----------------------------------------------------------------------
     823   void PagingLandScapeTexture::loadAlphaTexture(  const String &filename,   const unsigned int channel )
           {
           assert (  mNumTexture > 0 );
           if (  mImages[channel].getData (   ) == 0 )
           {
           Image Imageloader;
           Imageloader.load(  filename,   mParent->getOptions(   )->groupName );
           const size_t size = Imageloader.getSize(   );
           uchar *data = new uchar [size];
           memcpy (  data,   Imageloader.getData(   ),   size*sizeof(  uchar ) );
           mImages[channel].loadDynamicImage(  data,  
           Imageloader.getWidth(   ),   Imageloader.getHeight(   ),  
           1,   PF_A8,   true,   1,   0 );
           }
          
           assert (  mImages[channel].getHeight(   ) == mImages[channel].getWidth(   ) );
           assert (  mImages[channel].getHeight(   ) / (  mParent->getOptions(   )->PageSize - 1 )
           == mParent->getOptions(   )->TextureStretchFactor &&
           String(  "(  texture size / (  pagesize-1 ) ) and texture stretch factor defined in terrain config file doesn't fit." ).c_str(   ) );
           }
           //-----------------------------------------------------------------------
     844   void PagingLandScapeTexture::loadColorTexture(  const String &filename,   const unsigned int channel )
           {
           assert (  mNumTexture > 0 );
          
           loadTexture (  filename,   mImages[channel] );
          
           assert (  mImages[channel].getHeight(   ) == mImages[channel].getWidth(   ) );
           assert (  mImages[channel].getHeight(   ) / (  mParent->getOptions(   )->PageSize - 1 )
           == mParent->getOptions(   )->TextureStretchFactor &&
           String(  "(  texture size / (  pagesize-1 ) ) and texture stretch factor defined in terrain config file doesn't fit." ).c_str(   ) );
           }
           //-----------------------------------------------------------------------
     856   void PagingLandScapeTexture::loadTexture(  const String &filename,   Image &img )
           {
           if (  img.getData (   ) == 0 )
           {
           img.load(  filename,   mParent->getOptions(   )->groupName );
           }
           }
           //-----------------------------------------------------------------------
     864   void PagingLandScapeTexture::updated (   )
           {
           mPaintRect.left = 0;
           mPaintRect.right = 0;
           mPaintRect.top = 0;
           mPaintRect.bottom = 0;
           mIsPaintRectModified = false;
          
           mDeformRect.left = 0;
           mDeformRect.right = 0;
           mDeformRect.top = 0;
           mDeformRect.bottom = 0;
           mIsDeformRectModified = false;
           }
           //-----------------------------------------------------------------------
     879   void PagingLandScapeTexture::compute(  
     880   PagingLandScapeData2D* data,  
     881   const Image::Box& dataRect,  
     882   const Image::Box& textureRect )
           {
           assert (  mNumTexture > 0 );
           const size_t heightfiledsize = mParent->getOptions(   )->PageSize - 1;
           const Real textureScale = mParent->getOptions(   )->TextureStretchFactor;
           const unsigned int textureSize = static_cast<unsigned int>(  heightfiledsize * textureScale );
           unsigned int curr_image_pos = static_cast <unsigned int>(  textureRect.top*textureSize + textureRect.left );
           const unsigned int image_width = static_cast <unsigned int>(  (  textureSize - (  textureRect.right - textureRect.left ) ) );
           const Real inv_scale = 1 / textureScale;
          
           const Real * const ogre_restrict heightData = data->getHeightData (   );
           assert (  heightData && "PagingLandScapeTexture::compute(   )" );
          
           for (  size_t k = textureRect.top; k < textureRect.bottom; ++k )
           {
           const unsigned int k_terrain = (  unsigned int )(  k * inv_scale );
           const size_t curr_row = k_terrain * heightfiledsize;
           for (  size_t i = textureRect.left; i < textureRect.right; ++i )
           {
           const unsigned int i_terrain = (  unsigned int )(  i * inv_scale );
          
           assert (  i < textureSize && k < textureSize &&
           "PagingLandScapeTexture::compute(   )" );
          
           assert (  i_terrain < heightfiledsize && k_terrain < heightfiledsize &&
           "PagingLandScapeTexture::compute(   )" );
          
           if (  mIsSplatMode )
           computePointAlpha(  curr_image_pos,  
           heightData[i_terrain + curr_row],  
           1.0f - data->getNormal (  i_terrain,   k_terrain ).y );
           if (  mIsBaseMode )
           computePointColor (  curr_image_pos,  
           heightData[i_terrain + curr_row],  
           1.0f - data->getNormal (  i_terrain,   k_terrain ).y );
          
           curr_image_pos += 1;
           }
           curr_image_pos += image_width;
           }
           }
           //-----------------------------------------------------------------------
     924   void PagingLandScapeTexture::paint (  const unsigned int xParam,  
           const unsigned int zParam,  
     926   const Real paintForce )
           {
           assert (  mNumTexture > 0 );
           assert (  paintForce >= 0.0f && paintForce <= 1.0f && "PagingLandScapeTexture::paint(   )" );
           const Real blend = paintForce;
          
           const size_t psize = mParent->getOptions(   )->PageSize - 1;
           const Real textureScale = mParent->getOptions (   )->TextureStretchFactor;
           const unsigned int textureScaleCount = static_cast <unsigned int> (  textureScale );
          
           assert (  (  (  xParam + zParam * psize ) < psize*psize ) && "PagingLandScapeTexture::paint(   )" );
          
           const unsigned int xScaled = xParam * textureScaleCount;
           const unsigned int zScaled = zParam * textureScaleCount;
           const size_t pSizeScaled = psize * textureScaleCount;
          
           for (  unsigned int j = 0; j < textureScaleCount; j++ )
           {
           const unsigned int z = zScaled + j;
           if (  z < pSizeScaled )
           {
           const unsigned int zShift = z * pSizeScaled;
           for (  unsigned int k = 0; k < textureScaleCount; k++ )
           {
           const unsigned int x = xScaled + k;
           if (  x < pSizeScaled )
           {
           const unsigned int curr_image_pos = x + zShift;
           assert (  curr_image_pos < pSizeScaled*pSizeScaled );
           paintPoint (  curr_image_pos,   blend );
           adjustPaintRectangle (  x,   z );
           }
           }
           }
           }
           }
           //-----------------------------------------------------------------------
     963   void PagingLandScapeTexture::update(   )
           {
           assert (  mNumTexture > 0 );
           // at least deformed once,   so need to save texture if asked by user (  option )
           mIsModified = true;
          
           Image::Box dataRect (  0,   0,   0,   0,   0,   1 );
           Image::Box texturerect (  0,   0,   0,   0,   0,   1 );
          
           // computes deformation
           PagingLandScapeData2D *data = 0;
           if (  mIsDeformRectModified )
           {
           dataRect = mDeformRect;
           data = mParent->getSceneManager(   )->getData2DManager(   )->getData2D(  mDataX,   mDataZ );
          
           if (  dataRect.getWidth(   ) && dataRect.getHeight (   ) )
           {
          
           const Real textureScale = mParent->getOptions(   )->TextureStretchFactor;
          
           texturerect.left = static_cast<size_t>(  dataRect.left * textureScale );
           texturerect.top = static_cast<size_t>(  dataRect.top * textureScale );
           texturerect.right = static_cast<size_t>(  dataRect.right * textureScale + 1 );
           texturerect.bottom = static_cast<size_t>(  dataRect.bottom * textureScale + 1 );
          
           dataRect.right += 1;
           dataRect.bottom += 1;
           compute(  data,   dataRect,   texturerect );
           }
           }
           // try to upload only the smallest rectangle containing modification
           if (  mIsPaintRectModified )
           {
           if (  mIsDeformRectModified )
           {
           texturerect.left = std::min (  mPaintRect.left,   dataRect.left );
           texturerect.right = std::max (  mPaintRect.right,   dataRect.right );
           texturerect.top = std::min (  mPaintRect.top,   dataRect.top );
           texturerect.bottom = std::max (  mPaintRect.bottom,   dataRect.bottom );
           }
           else
           {
           texturerect = mPaintRect;
          
           texturerect.right += 1;
           texturerect.bottom += 1;
           }
           } // if (  mIsRectModified )
          
          
           // Upload any changes (  deformation or )
           if (  texturerect.getWidth(   ) && texturerect.getHeight (   ) )
           {
           upload (  texturerect );
           } // if (  texturerect.getWidth(   ) && texturerect.getHeight (   ) )
          
           if (  mIsDeformRectModified )
           data->resetDeformationRectangle (   );
           PagingLandScapeTexture::updated (   );
           }
          
           //-----------------------------------------------------------------------
    1026   bool PagingLandScapeTexture::needUpdate (   ) const
           {
           return mIsDeformRectModified || mIsPaintRectModified;
           }
           //-----------------------------------------------------------------------
    1031   void PagingLandScapeTexture::adjustDeformationRectangle(  unsigned int x,   unsigned int z )
           {
           assert (  mNumTexture > 0 );
           assert (  x < (  mParent->getOptions (   )->PageSize ) );
           assert (  z < (  mParent->getOptions (   )->PageSize ) );
          
           if (  mIsDeformRectModified )
           {
           if (  mDeformRect.left > x )
           mDeformRect.left = x;
           if (  mDeformRect.right < x )
           mDeformRect.right = x;
          
           if (  mDeformRect.top > z )
           mDeformRect.top = z;
           if (  mDeformRect.bottom < z )
           mDeformRect.bottom = z;
           }
           else
           {
           // first modification :
           // deformation rectangle is the point
           mDeformRect.left = x;
           mDeformRect.right = x;
           mDeformRect.top = z;
           mDeformRect.bottom = z;
           mIsDeformRectModified = true;
           }
           }
           //-----------------------------------------------------------------------
    1061   void PagingLandScapeTexture::adjustPaintRectangle(  unsigned int x,   unsigned int z )
           {
           assert (  mNumTexture > 0 );
           assert (  x < (  (  mParent->getOptions (   )->PageSize - 1 ) * mParent->getOptions (   )->TextureStretchFactor ) );
           assert (  z < (  (  mParent->getOptions (   )->PageSize - 1 ) * mParent->getOptions (   )->TextureStretchFactor ) );
          
           if (  mIsPaintRectModified )
           {
           if (  mPaintRect.left > x )
           mPaintRect.left = x;
           else if (  mPaintRect.right < x )
           mPaintRect.right = x;
          
           if (  mPaintRect.top > z )
           mPaintRect.top = z;
           else if (  mPaintRect.bottom < z )
           mPaintRect.bottom = z;
           }
           else
           {
           // first modification :
           // deformation rectangle is the point
           mPaintRect.left = x;
           mPaintRect.right = x;
           mPaintRect.top = z;
           mPaintRect.bottom = z;
           mIsPaintRectModified = true;
           }
           }
           //-----------------------------------------------------------------------
    1091   void PagingLandScapeTexture::lightUpdate(   )
           {
           PagingLandScapeOptions * const opt = mParent->getOptions(   );
           if (  mIsShaderShadowed )
           {
           const Real SunAngle = opt->SunAngle;
           const Vector3 SunDir = opt->Sun;
          
           const bool positiveHorizon = (  SunDir.y > 0 );// Sun is west (  true ),   east (  false );
           assert (  fabs (  SunAngle ) < 1.1f );
          
           const Real LightAngle = (  positiveHorizon )? SunAngle : -SunAngle;
           if (  positiveHorizon != mPositiveShadow )
           {
           const String texname (  opt->LandScape_filename
           +
           (  (  positiveHorizon )? String(  ".HSP." ) : String(  ".HSN." ) )
           +
           StringConverter::toString(  mDataZ ) +
           String(  "." ) +
           StringConverter::toString(  mDataX ) + "." +
           opt->TextureExtension );
           mMaterial->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  2 )->setTextureName (  texname );
           mPositiveShadow = positiveHorizon;
           }
           GpuProgramParametersSharedPtr params = mMaterial->getBestTechnique(   )->getPass(  0 )->getFragmentProgramParameters(   );
          #ifdef PLSM2_EIHORT
           params->setNamedConstant(  "HorizonSettings",   Vector4(  SunDir.x,   SunDir.y,   SunDir.z,   LightAngle ) );
          #else
           GpuProgramParameters::RealConstantEntry * const e = params->getNamedRealConstantEntry (  "HorizonSettings" );
           assert (  e );
           e->val[0] = static_cast <float> (  SunDir.x );
           e->val[1] = static_cast <float> (  SunDir.y );
           e->val[2] = static_cast <float> (  SunDir.z );
           e->val[3] = static_cast <float> (  LightAngle );
           e->isSet = true;
          #endif
           }
           else if (  mIsShadowed )
           {
           assert (  mLightImage.getData (   ) );
           computeLightMap (   );
          
           // Upload changes
           const PixelBox srcBox = mLightImage.getPixelBox(   );
           const unsigned int mTextureSize = static_cast<unsigned int>(  mParent->mPageSize * opt->TextureStretchFactor );
           const Image::Box rect (  0,   0,   0,   mTextureSize,   mTextureSize,   1 );
           const PixelBox lock = mLightBuffer->lock (  rect ,   HardwareBuffer::HBL_DISCARD );
           PixelUtil::bulkPixelConversion(  srcBox,   lock );
           mLightBuffer->unlock(   );
           }
           }
           //-----------------------------------------------------------------------
    1144   void PagingLandScapeTexture::computeLightMap (   ) const
           {
           assert(  mIsShadowed );
           PagingLandScapeOptions * const opt = mParent->getOptions(   );
           const Vector3 LightDir = opt->Sun;
           const Real SunAngle = opt->SunAngle;
          
           const bool positiveHorizon = (  LightDir.y > 0 );// Sun is west (  true ),   east (  false );
           assert (  fabs (  SunAngle ) < 1.1f );
          
           const Real LightAngle = (  positiveHorizon )? SunAngle : -SunAngle;
           const size_t offsetneg = (  positiveHorizon )? 0: 1;
           //const Real LightAngle = SunAngle;
          
          
           unsigned int curr_rowY = 0;
           const uchar BScale = 255;
           const Real uchardivider = 1.0f / BScale;
           unsigned int curr_image_pos = 0;
           uchar * const ogre_restrict lightmap = (  uchar * ) (  mLightImage.getData (   ) );
           const uchar * const ogre_restrict HorizonAngle = mShadow.getData(   );
          
           const unsigned int mTextureSize = (  unsigned int ) mLightImage.getWidth (   );
           assert (  (  mShadow.getBPP (   ) ) / 8 == 3 );
           const unsigned int rowpitch = mTextureSize*3;
           for(  unsigned int nZ = 0; nZ < mTextureSize ; nZ++ )
           {
           unsigned int curr_image_posX = 0;
           for(  unsigned int nX = 0; nX < mTextureSize; nX++ )
           {
           const unsigned int nVert = static_cast <unsigned int> (  curr_rowY + curr_image_posX + offsetneg );
           const Real hAngle = HorizonAngle[nVert] * uchardivider;
           if (  hAngle < LightAngle )
           {
           const Real intensity = 1 - (  LightAngle - hAngle );
           if (  intensity > 0.0f )
           {
           //intensity *= std::max(  LightDir.dotProduct (  data->getNormal (  nX,   nZ ) ),   0.0f );
           lightmap[curr_image_pos] = static_cast <uchar> (  intensity * BScale );
          
           }
           else
           {
           // totally in shadow
           lightmap[curr_image_pos] = 0;
           }
           }
           else
           {
           // if Vertex is lighted
           const Real intensity = BScale;
           //const Real intensity = BScale * std::min(  1.0f,   LightDir.dotProduct (  data->getNormal (  nX,   nZ ) ) );
           lightmap[curr_image_pos] = static_cast <uchar> (  intensity );
           }
           // if colored light should use a rgb map..
          
           curr_image_pos ++;
           curr_image_posX += 3;
           }
           curr_rowY += rowpitch;
           }
          
           }
           //-----------------------------------------------------------------------
    1208   void PagingLandScapeTexture::computePointAlpha(  
           const unsigned int imagePos,  
    1210   const Real height,  
    1211   const Real slope )
           {
           assert (  mNumTexture > 0 );
           const unsigned int numHeights = mParent->getOptions(   )->NumMatHeightSplat;
           unsigned int indx = 1;
           while (  indx < (  numHeights - 1 ) && height >= mParent->heights[indx] )
           indx++;
          
           const unsigned int bScale = 255;
           const unsigned int up_indx = indx;
           const unsigned int down_indx = indx - 1;
           const Real interpol = (  height - mParent->heights[down_indx] )
           * mParent->dividers[up_indx];
          
           std::vector<Real> alpha;
           alpha.reserve(  numHeights );
           alpha.resize(  numHeights );
           for (  unsigned int ialpha = 0; ialpha < numHeights; ialpha++ )
           {
           alpha[ialpha] = 0.0f;
           }
          
           if (  slope < 0.05f )// speed-up as it's invisible
           {
           const Real B = (  1.0f - interpol );
           const Real C = interpol;
          
           alpha[indx - 1] = B;
           alpha[indx] = C;
           }
           else
           {
           const Real A = (  1.0f - slope );
           const Real B = A * (  1.0f - interpol );
           const Real C = A * interpol;
           const Real D = slope;
          
           alpha[indx - 1] = B;
           alpha[indx] = C;
          
           alpha[ 2 ] = alpha[ 2 ] + slope;
           alpha[ 2 ] = alpha[ 2 ] > 1.0f ? 1.0f : alpha[ 2 ];
           }
           // save changes in textures
          
           unsigned int currChannel = 0;
           for (  unsigned int k = 0; k < mNumTexture; k++ )
           {
           if (  mImages[k].getBPP (   ) == 8 )
           {
           uchar * const BaseData = mImages[k].getData (   );
           assert (  BaseData && "PagingLandScapeTexture::computePointAlpha(   )" );
           const unsigned int curr_image_pos = imagePos*(  static_cast <unsigned int>(  mNumChannelperTexture[k] ) );
           assert (  mNumChannelperTexture[k] == (  mImages[k].getBPP (   )/8 ) );
           for (  unsigned int j = 0; j < mNumChannelperTexture[k]; j++ )
           {
           BaseData[ curr_image_pos + j] = static_cast <uchar> (  alpha[currChannel]*bScale );
          
           currChannel++;
           }
           }
           }
           }
           //-----------------------------------------------------------------------
    1275   void PagingLandScapeTexture::computePointColor(  
           const unsigned int imagePos,  
    1277   const Real height,  
    1278   const Real slope )
           {
           assert (  mNumTexture > 0 );
           const unsigned int numHeights = mParent->getOptions(   )->NumMatHeightSplat;
          
           unsigned int indx = 1;
           while (  indx < (  numHeights - 1 ) && height >= mParent->heights[indx] )
           indx++;
          
           const unsigned int bScale = 255;
           const unsigned int up_indx = indx;
           const unsigned int down_indx = indx - 1;
           const Real interpol = (  height - mParent->heights[down_indx] )
           * mParent->dividers[up_indx];
          
           //ColourValue color;
           std::vector<ColourValue> color;
           for (  unsigned int itex = 0; itex < mNumTexture; itex++ )
           {
           for (  unsigned int ichan = 0; ichan < mNumChannelperTexture[itex]; ichan++ )
           {
           color.push_back (  ColourValue::Black );
           }
           }
          
          
           indx = up_indx;
           unsigned int currTexture = 0;
           while (  indx != 0 )
           {
           if (  indx < mNumChannelperTexture[currTexture] )
           break;
           indx = indx - mNumChannelperTexture[currTexture];
           currTexture++;
           }
           currTexture = currTexture < mNumTexture ? currTexture : mNumTexture - 1;
          
           if (  slope < 0.05f )// speed-up as it's invisible
           {
           const Real B = (  1.0f - interpol );
           const Real C = interpol;
           color[currTexture] = mParent->colors[down_indx] * B + mParent->colors[up_indx] * C;
           }
           else
           {
           const Real A = (  1.0f - slope );
           const Real B = A * (  1.0f - interpol );
           const Real C = A * interpol;
           const Real D = slope;
          
           color[currTexture] = mParent->colors[down_indx] * B + mParent->colors[up_indx] * C + mParent->colors[2] * D;
           }
           // save changes in textures
           unsigned int currChannel = 0;
           for (  unsigned int k = 0; k < mNumTexture; k++ )
           {
           if (  mImages[k].getBPP (   ) > 8 )
           {
           uchar * const BaseData = mImages[k].getData (   );
           assert (  BaseData && "PagingLandScapeTexture::computePointColor(   )" );
           const unsigned int curr_image_pos = imagePos*(  static_cast <unsigned int>(  mNumChannelperTexture[k] ) );
           assert (  mNumChannelperTexture[k] == (  mImages[k].getBPP (   )/8 ) );
          
           BaseData[ curr_image_pos + 0] = static_cast <uchar> (  color[k].r * bScale );
           BaseData[ curr_image_pos + 1] = static_cast <uchar> (  color[k].g * bScale );
           BaseData[ curr_image_pos + 2] = static_cast <uchar> (  color[k].b * bScale );
           currChannel += 3;
           }
           }
           }
           //-----------------------------------------------------------------------
    1349   void PagingLandScapeTexture::paintPoint (  const unsigned int imagePos,  
    1350   const Real paintForce )
           {
           assert (  mNumTexture > 0 );
           assert(  mParent->channelModifList );
           const std::vector<Real> *channelModifList = mParent->channelModifList;
           const uchar bScale = 255;
           const Real invPaintForce = 1.0f - paintForce;
           unsigned int currChannel = 0;
           for (  unsigned int k = 0; k < mNumTexture; k++ )
           {
           uchar * const BaseData = mImages[k].getData(   );
           assert (  BaseData && "PagingLandScapeTexture::paint(   )" );
           const unsigned int currImagePos = imagePos * mNumChannelperTexture[k];
           assert (  currImagePos < mImages[k].getSize (   ) );
           assert (  mNumChannelperTexture[k]*8 == mImages[k].getBPP (   ) );
          
           for (  unsigned int j = 0; j < mNumChannelperTexture[k]; j++ )
           {
           BaseData[ currImagePos + j ] =
           static_cast <uchar> (  
           (  (  *channelModifList )[currChannel] ) * paintForce * bScale
           + BaseData[ currImagePos + j ] * invPaintForce
            );
           currChannel++;
           }
           doTextureNeedUpdate[k] = true;
           }
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTextureCoordinatesManager.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTextureCoordinatesManager.cpp - description
          -------------------
          begin : Mon Jun 16 2003
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTextureCoordinatesManager.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      27   PagingLandScapeTextureCoordinatesManager::PagingLandScapeTextureCoordinatesManager(  PagingLandScapeSceneManager * scnMgr ) :
           mPageSize (  0 ),  
           mTileSize (  0 ),  
           mOptions (  scnMgr->getOptions(   ) )
           {
           }
           //-----------------------------------------------------------------------
      34   PagingLandScapeTextureCoordinatesManager::~PagingLandScapeTextureCoordinatesManager(   )
           {
           clear(   );
           }
           //-----------------------------------------------------------------------
      39   void PagingLandScapeTextureCoordinatesManager::clear(   )
           {
           // Unload the Tiles
           if (  !mTexBuffs.empty(   ) )
           {
           HardwareTextureBuffersCol::iterator iend = mTexBuffs.end(   );
           for (  HardwareTextureBuffersCol::iterator i = mTexBuffs.begin(   );
           i != iend;
           ++i )
           {
           // std::for_each(  i->begin (   ),  
           // i->end (   ),  
           // delete_object(   ) );
          
           i->clear(   );
           }
           mTexBuffs.clear(   );
           }
           }
           //-----------------------------------------------------------------------
      59   void PagingLandScapeTextureCoordinatesManager::load(   )
           {
           const unsigned int pSize = mOptions->PageSize;
           const unsigned int tSize = mOptions->TileSize;
           if (  mPageSize != pSize ||
           mTileSize != tSize )
           {
           clear(   );
          
           mPageSize = pSize;
           mTileSize = tSize;
           const unsigned int NumTiles = mOptions->NumTiles;
          
           mTexBuffs.reserve (  NumTiles );
           mTexBuffs.resize (  NumTiles );
           for (  unsigned int i = 0; i < NumTiles; ++i )
           {
           mTexBuffs[i].reserve (  NumTiles );
           mTexBuffs[i].resize (  NumTiles );
           }
           }
           }
           //-----------------------------------------------------------------------
      82   HardwareVertexBufferSharedPtr PagingLandScapeTextureCoordinatesManager::getBuffer(  
           const unsigned int tilex,  
           const unsigned int tilez )
           {
           assert (  tilex < mOptions->NumTiles &&
           tilez < mOptions->NumTiles );
          
           if (  mTexBuffs [tilex][tilez].isNull (   ) )
           {
           const unsigned int tileSize = mOptions->TileSize;
          
           const VertexElementType t = VET_FLOAT2;
           //const VertexElementType t = VET_SHORT2;
           const size_t vertexSize = VertexElement::getTypeSize (  t );
           HardwareVertexBufferSharedPtr vbuf =
           HardwareBufferManager::getSingleton (   ).createVertexBuffer(  
           vertexSize,  
           tileSize * tileSize,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
           float* pTex = static_cast<float*> (  vbuf->lock(  HardwareBuffer::HBL_DISCARD ) );
           //ushort* pSecond = static_cast<ushort*> (  vbuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          
           // Calculate the offset in the texture position
           const unsigned int offSetX = tilex * (  tileSize - 1 );
           const unsigned int offSetZ = tilez * (  tileSize - 1 );
           const unsigned int endx = offSetX + tileSize;
           const unsigned int endz = offSetZ + tileSize;
          
           const Real Aux1 = 1.0 / (  mOptions->PageSize - 1 );
           Real K_Tex2DataPos = offSetZ * Aux1;
           for (  unsigned int k = offSetZ; k < endz; k ++ )
           {
           Real K_Tex1DataPos = offSetX * Aux1;
           for (  unsigned int i = offSetX; i < endx; i ++ )
           {
           // textures
           //assert (  K_Tex1DataPos >= 0.0f && K_Tex1DataPos <= 1.0f );
           //assert (  K_Tex2DataPos >= 0.0f && K_Tex2DataPos <= 1.0f );
           if (  K_Tex1DataPos > 1.0f ) K_Tex1DataPos = 1.0f;
           if (  K_Tex2DataPos > 1.0f ) K_Tex2DataPos = 1.0f;
           *pTex++ = K_Tex1DataPos;
           *pTex++ = K_Tex2DataPos;
          
           // *pTex++ = static_cast<ushort> (  K_Tex1DataPos * 65535 );
           // *pTex++ = static_cast<ushort> (  K_Tex2DataPos * 65535 );
          
           K_Tex1DataPos += Aux1;
           }
           K_Tex2DataPos += Aux1;
           }
           vbuf->unlock(   );
           mTexBuffs [tilex][tilez] = vbuf;
           }
           return mTexBuffs [tilex][tilez];
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTextureManager.cpp

       1  /***************************************************************************
           OgrePagingLandScapeTextureManager.cpp - description
           -------------------
           begin : Fri Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
           email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          
          #include "OgreRoot.h"
          #include "OgreRenderSystem.h"
          #include "OgreMaterialManager.h"
          #include "OgreGpuProgramManager.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeData2DManager.h"
          
          // Texture loaders implementations
          #include "OgrePagingLandScapeTexture.h"
          
          // #include "OgrePagingLandScapeTexture_Image.h"
          //
          // #include "OgrePagingLandScapeTexture_BaseTexture.h"
          // #include "OgrePagingLandScapeTexture_Splatting.h"
          
          #include "OgrePagingLandScapeTileInfo.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      44   PagingLandScapeTextureManager::PagingLandScapeTextureManager(  PagingLandScapeSceneManager * scnMgr ) :
           mSceneManager(  scnMgr ),  
           mOptions (  scnMgr->getOptions(   ) ),  
           mTextureType (  0 ),  
           mTextureFormat (  "" ),  
           mWidth (  0 ),  
           mHeight (  0 ),  
           mTexturePageSize (  mOptions->PageSize -1 ),  
           mPaintChannel(  0 ),  
           mPaintColor(  ColourValue::White )
           {
           }
           //-----------------------------------------------------------------------
      57   void PagingLandScapeTextureManager::registerTextureFormats(   )
           {
           const std::vector<String> TextureFormatSupported = mOptions->TextureFormatSupported;
          
           // for all terrain configuration file texture format not in mTextureTypeMap allocate
           {
           std::vector<String>::const_iterator itTexFormatSupp = TextureFormatSupported.begin(   );
           while (  itTexFormatSupp != TextureFormatSupported.end(   ) )
           {
           const String &textureFormat = (  *itTexFormatSupp );
           if (  !textureFormat.empty (   ) )
           {
           PagingLandScapeTextureMap::iterator iTexFormatCurr = mTextureTypeMap.begin(   );
           while (  iTexFormatCurr != mTextureTypeMap.end(   ) )
           {
           if (  (  *iTexFormatCurr )->getName (   ) == textureFormat )
           break;
           ++iTexFormatCurr;
           }
           if (  iTexFormatCurr == mTextureTypeMap.end(   ) )
           registerTextureType(  new PagingLandScapeTexture(  this,   textureFormat ) );
           }
           ++itTexFormatSupp;
           }
           }
          
          
           // for all mTextureTypeMap[i] not in terrain configuration file,   delete
           {
           PagingLandScapeTextureMap::iterator iTexFormatCurr = mTextureTypeMap.begin(   );
           while (  iTexFormatCurr != mTextureTypeMap.end(   ) )
           {
           const String &textureFormat = (  *iTexFormatCurr )->getName (   );
          
           if (  TextureFormatSupported.end(   ) == std::find(  TextureFormatSupported.begin(   ),  
           TextureFormatSupported.end(   ),  
           textureFormat ) )
           {
           delete (  *iTexFormatCurr );
           iTexFormatCurr = mTextureTypeMap.erase (  iTexFormatCurr );
           }
           else
           {
           ++iTexFormatCurr;
           }
           }
           }
          
          
           // Add default texture Types.
           // dynamically create maps.
           //registerTextureType (  new PagingLandScapeTexture_BaseTexture(  this ) );
           //registerTextureType (  new PagingLandScapeTexture_Splatting(  this ) );
           }
          
           //-----------------------------------------------------------------------
     113   void PagingLandScapeTextureManager::clearTextureFormats(   )
           {
           // for all in map delete.
           PagingLandScapeTextureMap::iterator i = mTextureTypeMap.begin(   );
           while (  i != mTextureTypeMap.end(   ) )
           {
           delete (  *i );
           ++i;
           }
           }
           //-----------------------------------------------------------------------
     124   String PagingLandScapeTextureManager::getNextTextureFormat(   )
           {
           assert (  !mTextureTypeMap.empty(   ) );
           const size_t numTextureTypes = mTextureTypeMap.size(   );
           unsigned int nextTextureType = mTextureType + 1;
           if (  nextTextureType == numTextureTypes )
           nextTextureType = 0;
           unsigned int numLoop = 0;
           // find Next supported texture format.
           while (  numLoop != numTextureTypes )
           {
          #ifdef _DEBUG
           std::cout << "Trying " << mTextureTypeMap[nextTextureType]->getName (   ) << '\n';
          #endif //_DEBUG
           if (  mTextureTypeMap[nextTextureType]->isMaterialSupported(   ) )
           {
           return mTextureTypeMap[nextTextureType]->getName(   );
           }
          
           nextTextureType ++ ;
           if (  nextTextureType == numTextureTypes )
           nextTextureType = 0;
           numLoop++;
          
           }
           assert (  numLoop == numTextureTypes );
          
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           "Cannot find a TextureMode supported by current hardware! (  shaders/num texture units... )",  
           " getNextTextureFormat " );
          
           return StringUtil::BLANK;
           }
           //-----------------------------------------------------------------------
     158   void PagingLandScapeTextureManager::setPageSize (   )
           {
           PagingLandScapeOptions * const opt = mOptions;
           mPageSize = opt->PageSize - 1;
           Real Texturescale = opt->TextureStretchFactor;
           const unsigned int textureSize = (  unsigned int ) (  mPageSize * Texturescale );
           uchar *data = new uchar[textureSize * textureSize * 3];
           mImage.loadDynamicImage (  data,   textureSize,   textureSize,   PF_R8G8B8A8 );
          
           const unsigned int numColors = opt->NumMatHeightSplat;
          
           unsigned int i;
           colors.reserve (  numColors );
           colors.resize (  numColors );
           for (  i = 0; i < numColors; i++ )
           {
           colors[i] = opt->matColor[i];
           }
           heights.reserve (  numColors );
           heights.resize (  numColors );
           for (  i = 0; i < numColors; i++ )
           {
           heights[i] = opt->matHeight[i];
           }
          
           // slope[] ??
          
           if (  numColors && heights[numColors - 1] == 0.0f )
           heights[numColors - 1] = getSceneManager(   )->getData2DManager(   )->getMaxHeight (   );
          
           dividers.reserve (  numColors );
           dividers.resize (  numColors );
           if (  numColors )
           {
           dividers[0] = 1.0f;
          
           for (  i = 1; i < numColors; i++ )
           {
           if (  (  heights[i] - heights[i - 1] ) > 0 )
           dividers[i] = 1 / (  heights[i] - heights[i - 1] );
           else
           dividers[i] = 0.0f;
           }
           }
          
           }
           //-----------------------------------------------------------------------
     205   void PagingLandScapeTextureManager::clearData (   )
           {
           delete [] mImage.getData (   );
           mImage.loadDynamicImage (  0,   0,   0,   PF_R8G8B8A8 );
           }
           //-----------------------------------------------------------------------
     211   String PagingLandScapeTextureManager::getCurrentTextureFormat(   )
           {
           if (  !mTextureTypeMap.empty(   ) )
           return mTextureTypeMap[mTextureType]->getName(   );
           return StringUtil::BLANK;
           }
           //-----------------------------------------------------------------------
     218   PagingLandScapeTextureManager::~PagingLandScapeTextureManager(   )
           {
           reset (   );
           clearTextureFormats (   );
           }
           //-----------------------------------------------------------------------
     224   void PagingLandScapeTextureManager::reset(   )
           {
           if (  !mActiveTextures.empty(   ) )
           {
           std::for_each (  mActiveTextures.begin(   ),   mActiveTextures.end(   ),  
           std::mem_fun (  &PagingLandScapeTexture::unload ) );
          
           // Insert actives into free list
           mFreeTextures.insert (  mFreeTextures.end(   ),   mActiveTextures.begin(   ),   mActiveTextures.end(   ) );
           // Remove all active instances
           mActiveTextures.clear(   );
           }
          
           // could save a delete if texture type is the same... ?
           if (  !mTexturePool.empty(   ) )
           {
           std::for_each(  mTexturePool.begin(   ),   mTexturePool.end(   ),   delete_object(   ) );
           mTexturePool.clear(   );
           mFreeTextures.clear(   );
           }
           mWidth = 0;
           mHeight = 0;
           }
           //-----------------------------------------------------------------------
     248   PagingLandScapeTexture *PagingLandScapeTextureManager::getNewTexture(  const unsigned int x,   const unsigned int z )
           {
           PagingLandScapeTexture *newTexture;
           if (  mFreeTextures.empty(   ) )
           {
           const size_t pool_size = mTexturePool.size (   );
           const size_t new_pool_size = (  pool_size == 0 ) ? 9 : pool_size * 2;
           mTexturePool.reserve(  new_pool_size );
           mTexturePool.resize(  new_pool_size );
          
           // Create new pages
           for (  size_t i = pool_size; i < new_pool_size; ++i )
           {
           newTexture = allocateTexture(   );
           mTexturePool[i] = newTexture;
           mFreeTextures.push_back (  newTexture );
           }
           }
          
           newTexture = mFreeTextures.front (   );
           mFreeTextures.pop_front (   );
           mActiveTextures.push_back (  newTexture );
          
           newTexture->load(  x,   z );
          
           return newTexture;
           }
           //-----------------------------------------------------------------------
     276   void PagingLandScapeTextureManager::releaseTexture(  PagingLandScapeTexture *p )
           {
           mActiveTextures.remove (  p );
           mFreeTextures.push_back (  p );
           }
           //-----------------------------------------------------------------------
     282   PagingLandScapeTexture *PagingLandScapeTextureManager::getTexture(  const unsigned int x,   const unsigned int z,  
     283   const bool alwaysReturn )
           {
           if (  x < mWidth && z < mHeight )
           {
           PagingLandScapeTextureList::iterator l,   lend = mActiveTextures.end(   );
           for (  l = mActiveTextures.begin(   ); l != lend; ++l )
           {
           if (  (  *l )->isCoord(  x,   z ) )
           return (  *l );
           }
           if (  alwaysReturn )
           return getNewTexture(  x,   z );
           }
           assert (  !alwaysReturn );
           return 0;
           }
           //-----------------------------------------------------------------------
     300   PagingLandScapeTexture *PagingLandScapeTextureManager::allocateTexture(   ) const
           {
           return mTextureTypeMap[mTextureType]->newTexture(   );
           }
           //-----------------------------------------------------------------------
     305   void PagingLandScapeTextureManager::load (   )
           {
           registerTextureFormats (   );
           {
           reset (   );
           mTextureFormat = mOptions->textureFormat;
           unsigned int i = 0;
          
           assert (  !mTextureTypeMap.empty(   ) );
          
           const size_t numTextureTypes = mTextureTypeMap.size(   );
           for (  ; i != numTextureTypes; ++i )
           {
           const String &modeName = mTextureTypeMap[i]->getName (   );
           if (  modeName == mTextureFormat )
           {
           if (  !mTextureTypeMap[i]->isMaterialSupported(   ) )
           {
           mTextureFormat = getNextTextureFormat(   );// not supported,   find first supported.
           for (  unsigned int k = 0; k != numTextureTypes; ++k )
           {
           const String &newmodeName = mTextureTypeMap[k]->getName (   );
           if (  newmodeName == mTextureFormat )
           {
           mTextureType = k;
           i = k;
           break;
           }
           }
           }
           else
           {
           mTextureType = i;
           }
           break;
           }
           }
           if (  i == numTextureTypes )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           "TextureMode not supplied or wrong (  check case ) !",  
           " PagingLandScapeTextureManager::load " );
           }
           if (  !mTextureTypeMap[mTextureType]->isMaterialSupported(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,  
           "TextureMode not supported by current hardware! (  shaders/num texture units... )",  
           " PagingLandScapeTextureManager::load " );
           }
           mTexturePageSize = mOptions->PageSize - 1;
           }
           setPageSize(   );
           mTextureTypeMap[mTextureType]->setOptions(   );
           WorldDimensionChange(   );
           }
          
           //-----------------------------------------------------------------------
     362   unsigned int PagingLandScapeTextureManager::getNumChannels(   )
           {
           return mTextureTypeMap[mTextureType]->getNumChannels (   );
           }
           //-----------------------------------------------------------------------
     367   unsigned int PagingLandScapeTextureManager::getNumChannelsperTexture(  const size_t i )
           {
           return mTextureTypeMap[mTextureType]->getNumChannelsperTexture (  i );
           }
           //-----------------------------------------------------------------------
     372   void PagingLandScapeTextureManager::clear (   )
           {
           // member de-init.
           clearData(   );
           mMapMaterial.setNull(   );
           }
           //-----------------------------------------------------------------------
     379   void PagingLandScapeTextureManager::WorldDimensionChange(   )
           {
           const unsigned int newWidth = mOptions->world_width;
           const unsigned int newHeight = mOptions->world_height;
          
           reset(   );
          
           mWidth = newWidth;
           mHeight = newHeight;
           }
           //-----------------------------------------------------------------------
     390   void PagingLandScapeTextureManager::setMapMaterial(   )
           {
           PagingLandScapeOptions * const opt = mOptions;
           const String mapName = String(  "Small" ) + opt->image_filename;
           mMapMaterial = MaterialManager::getSingleton(   ).getByName (  mapName );
           if (  mMapMaterial.isNull(   ) )
           {
           MaterialPtr matTemplate = MaterialManager::getSingleton(   ).
           getByName (  String (  "PagingLandScape.Small.Template" ) );
           mMapMaterial = matTemplate ->clone (  mapName );
           const String texname(  opt->image_filename + ".Small." +
           opt->TextureExtension );
           mMapMaterial->getTechnique(  0 )->getPass(  0 )->
           getTextureUnitState(  0 )->setTextureName (  texname );
           mMapMaterial->load(   );
           }
           }
           //-----------------------------------------------------------------------
     408   MaterialPtr PagingLandScapeTextureManager::getMapMaterial(   )
           {
           return mMapMaterial;
           }
           //-----------------------------------------------------------------------
     413   void PagingLandScapeTextureManager::load(  const unsigned int texX,   const unsigned int texZ )
           {
           PagingLandScapeTexture* tex = getTexture (  texX ,   texZ );
           if (  !tex->isLoaded (   ) )
           {
           tex->load (  texX,   texZ );
           }
           }
           //-----------------------------------------------------------------------
     422   void PagingLandScapeTextureManager::unload(  const unsigned int texX,   const unsigned int texZ )
           {
           PagingLandScapeTexture* tex = getTexture (  texX ,   texZ,   false );
           if (  tex && tex->isLoaded (   ) )
           {
           tex->unload (   );
           releaseTexture (  tex );
           }
           }
           //-----------------------------------------------------------------------
     432   void PagingLandScapeTextureManager::reload(  const unsigned int texX,   const unsigned int texZ )
           {
           PagingLandScapeTexture* tex = getTexture (  texX ,   texZ );
           tex->unload(   );
           tex->load(  texX,   texZ );
           const unsigned int tsize = mOptions->TileSize;
           const unsigned int psize = mOptions->PageSize;
           for (  unsigned int z = 0; z <= psize ; z += tsize )
           {
           for (  unsigned int x = 0; x <= psize ; x += tsize )
           {
           tex->adjustDeformationRectangle (  x,   z );
           }
           }
           }
           //-----------------------------------------------------------------------
     448   bool PagingLandScapeTextureManager::isLoaded(  const unsigned int texX,   const unsigned int texZ )
           {
           const PagingLandScapeTexture * const tex = getTexture (  texX ,   texZ,   false );
           return tex && tex->isLoaded(   );
           }
           //-----------------------------------------------------------------------
     454   const MaterialPtr& PagingLandScapeTextureManager::getMaterial(  const unsigned int texX,   const unsigned int texZ )
           {
           PagingLandScapeTexture * const tex = getTexture (  texX ,   texZ,   false );
           assert (  tex );
           return tex->getMaterial(   );
           }
           //-----------------------------------------------------------------------
     461   void PagingLandScapeTextureManager::paint (  const Vector3 &currpoint,  
     462   const Real paintForce,  
     463   const PagingLandScapeTileInfo *info )
           {
           const unsigned int pX = info->mPageX;
           const unsigned int pZ = info->mPageZ;
           const unsigned int pSize = mOptions->PageSize - 1;
           // adjust x and z to be local to page
           const unsigned int x = static_cast<unsigned int> (  currpoint.x
           - pX * pSize
           + mOptions->maxUnScaledX );
           const unsigned int z = static_cast<unsigned int> (  currpoint.z
           - pZ * pSize
           + mOptions->maxUnScaledZ );
          
           PagingLandScapeTexture* tex = getTexture (  pX ,   pZ,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           const unsigned int tSize = pSize - 1;
           const bool rightlimit = (  x >= tSize );
           const bool uplimit = (  z >= tSize );
          
           // If we're not on a page edge
           if (  !rightlimit && !uplimit )
           {
           tex->paint (  x,   z,   paintForce );
           }
          
           // we must duplicate the change on the
           // neighbor page (  if it has one... )
           const unsigned int wL = mOptions->world_width;
           const unsigned int hL = mOptions->world_height;
           const bool right = false;//(  rightlimit && pX < wL - 1 );
           const bool up = false;//(  uplimit && pZ < hL - 1 );
           const bool left = (  x == 0 && pX != 0 );
           const bool down = (  z == 0 && pZ != 0 );
          
           assert (  z <= tSize && x <= tSize );
          
           if (  left )
           {
           if (  down )
           {
           // lower left corner
           tex = getTexture (  pX - 1 ,   pZ - 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->paint (  tSize,   tSize,   paintForce );
           }
           }
           else if (  up )
           {
           // upper left corner
           tex = getTexture (  pX - 1 ,   pZ + 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->paint (  tSize,   0,   paintForce );
           }
           }
           else
           {
           // left only
           tex = getTexture (  pX - 1 ,   pZ,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->paint (  tSize,   z,   paintForce );
           }
           }
           }
           else if (  right )
           {
           if (  up )
           {
           // upper right corner
           tex = getTexture (  pX + 1 ,   pZ + 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->paint (  0,   0,   paintForce );
           }
           }
           else if (  down )
           {
           // lower right corner
           tex = getTexture (  pX + 1 ,   pZ - 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->paint (  0,   tSize,   paintForce );
           }
           }
           else
           {
           // right only
           tex = getTexture (  pX + 1 ,   pZ,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->paint (  0,   z,   paintForce );
           } // if (  tex->isLoaded(   ) )
           }
           }
           else if (  down )
           {
           // lower (  down only )
           tex = getTexture (  pX,   pZ - 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->paint (  x,   tSize,   paintForce );
           }
           }
           else if (  up )
           {
           // upper (  up only )
           tex = getTexture (  pX,   pZ + 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->paint (  x,   0,   paintForce );
           }
           }
           }
           }
           //-----------------------------------------------------------------------
     581   void PagingLandScapeTextureManager::deformHeight (  const Vector3 &currpoint,  
     582   const PagingLandScapeTileInfo *info )
           {
           const unsigned int pX = info->mPageX;
           const unsigned int pZ = info->mPageZ;
           const unsigned int pSize = mOptions->PageSize - 1;
           // adjust x and z to be local to page
           const unsigned int x = static_cast<unsigned int> (  currpoint.x
           - pX * pSize
           + mOptions->maxUnScaledX );
           const unsigned int z = static_cast<unsigned int> (  currpoint.z
           - pZ * pSize
           + mOptions->maxUnScaledZ );
          
           PagingLandScapeTexture* tex = getTexture (  pX ,   pZ,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           const unsigned int tSize = pSize - 1;
           const bool rightlimit = (  x >= tSize );
           const bool uplimit = (  z >= tSize );
          
           // If we're on a page edge
           if (  !(  rightlimit && uplimit ) )
           {
           tex->adjustDeformationRectangle(  x,   z );
           }
          
           // we must duplicate the change on the
           // neighbour page (  if it has one... )
           const unsigned int wL = mOptions->world_width;
           const unsigned int hL = mOptions->world_height;
           const bool right = false;//(  rightlimit && pX < wL - 1 );
           const bool up = false;//(  uplimit && pZ < hL - 1 );
           const bool left = (  x == 0 && pX != 0 );
           const bool down = (  z == 0 && pZ != 0 );
          
           assert (  z <= tSize && x <= tSize );
          
           if (  left )
           {
           if (  down )
           {
           // lower left corner
           tex = getTexture (  pX - 1 ,   pZ - 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->adjustDeformationRectangle(  tSize,   tSize );
           }
           }
           else if (  up )
           {
           // upper left corner
           tex = getTexture (  pX - 1 ,   pZ + 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->adjustDeformationRectangle(  tSize,   0 );
           }
           }
           // left
           tex = getTexture (  pX - 1 ,   pZ,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->adjustDeformationRectangle(  tSize,   z );
           }
           }
           else if (  right )
           {
           if (  up )
           {
           // upper right corner
           tex = getTexture (  pX + 1 ,   pZ + 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->adjustDeformationRectangle(  0,   0 );
           }
           }
           else if (  down )
           {
           // lower right corner
           tex = getTexture (  pX + 1 ,   pZ - 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->adjustDeformationRectangle(  0,   tSize );
           }
           }
           // right only
           tex = getTexture (  pX + 1 ,   pZ,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->adjustDeformationRectangle(  0,   z );
           }
           }
           if (  down )
           {
           // lower (  down only )
           tex = getTexture (  pX,   pZ - 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->adjustDeformationRectangle(  x,   tSize );
           }
           }
           else if (  up )
           {
           // upper (  up only )
           tex = getTexture (  pX,   pZ + 1,   false );
           if (  tex && tex->isLoaded(   ) )
           {
           tex->adjustDeformationRectangle(  x,   0 );
           }
           }
           } // if (  tex->isLoaded(   ) )
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_BaseTexture.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_BaseTexture.cpp - description
          -------------------
          begin : Mon Apr 26 2004
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_BaseTexture.h"
          #include "OgrePagingLandScapeData2DManager.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      42   void PagingLandScapeTexture_BaseTexture::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           }
           //-----------------------------------------------------------------------
      48   PagingLandScapeTexture* PagingLandScapeTexture_BaseTexture::newTexture(   )
           {
           return new PagingLandScapeTexture_BaseTexture(  mParent );
           }
           //-----------------------------------------------------------------------
      53   bool PagingLandScapeTexture_BaseTexture::isMaterialSupported(   )
           {
           if (  mParent->getOptions(   )->NumMatHeightSplat > 3 )
           return true;
           else
           return false;
           }
           //-----------------------------------------------------------------------
      61   PagingLandScapeTexture_BaseTexture::PagingLandScapeTexture_BaseTexture(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "Base",   1,   false )
           {
           }
          
           //-----------------------------------------------------------------------
      68   PagingLandScapeTexture_BaseTexture::~PagingLandScapeTexture_BaseTexture(   )
           {
           }
          
           //-----------------------------------------------------------------------
      73   void PagingLandScapeTexture_BaseTexture::_loadMaterial(   )
           {
           if (  mMaterial.isNull(   ) )
           {
           PagingLandScapeOptions * const opt = mParent->getOptions(   );
           const String filename = opt->LandScape_filename;
           const String commonName = StringConverter::toString(  mDataZ ) +
           String(  "." ) +
           StringConverter::toString(  mDataX );
           const String matname = String(  "Base." ) + commonName + "." + filename;
           mMaterial = MaterialManager::getSingleton(   ).getByName(  matname );
           if (  mMaterial.isNull(   ) )
           {
           // Create a new texture using the base image
           mMaterial = MaterialManager::getSingleton(   ).getByName(  "Base" );
           assert (  !mMaterial.isNull(   ) );
           mMaterial = mMaterial->clone(  matname );
          
           const String texname = filename + commonName + "." + String(  "BaseBuildPoint." );
           TexturePtr tex = TextureManager::getSingleton(   ).getByName (  texname );
           if (  tex.isNull(   ) )
           {
          
           const unsigned int pageSize = opt->PageSize;
           // Assign the texture to the alpha map
           BaseImage.loadDynamicImage (  _BuildBaseTexture(   ),  
           pageSize,  
           pageSize,  
           1,  
           PF_R8G8B8A8,  
           true );
          
           BaseImage.resize(  pageSize - 1,  
           pageSize - 1 );
          
           TextureManager::getSingleton(   ).loadImage (  texname,  
           opt->groupName,  
           BaseImage,  
           TEX_TYPE_2D,   7,   1.0f );
           }
           // assign this texture to the material
           assert (  mMaterial->getTechnique(  0 ) && mMaterial->getTechnique(  0 )->getPass(  0 ) && mMaterial->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  0 ) );
           assert (  mMaterial->getTechnique(  1 ) && mMaterial->getTechnique(  1 )->getPass(  0 ) && mMaterial->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  0 ) );
          
           mMaterial->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  0 )->setTextureName(  texname );
           mMaterial->getTechnique(  1 )->getPass(  0 )->getTextureUnitState(  0 )->setTextureName(  texname );
          
          
          
          
           }
           }
           }
           //-----------------------------------------------------------------------
     127   uchar *PagingLandScapeTexture_BaseTexture::_BuildBaseTexture(   ) const
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
           PagingLandScapeData2DManager * const dataMgr = mParent->getSceneManager(   )->getData2DManager(   );
          
           const Real dx = opt->scale.x;
           const Real dz = opt->scale.z;
           const Real inv_dxdz = 1 / (  dx+dz );
           const Real inv_dx = 1 / dx;
           const Real inv_dz = 1 / dz;
          
           const unsigned int pageSize = opt->PageSize;
          
          # define _InterpolateColour(  O,   F,   C1,   C2 ) \
           (  (  O + (  F * matColor[C1] + \
           (  1 - F ) * matColor[C2] ) ) * 0.5f )
          
           const Real matHeight0 = opt->matHeight[1];
           const Real matHeight1 = opt->matHeight[2];
          
           const ColourValue matColor[] =
           {
           opt->matColor[0],  
           opt->matColor[1],  
           opt->matColor[2],  
           opt->matColor[3]
           };
          
           // This texture will be used as a base color for the terrain,   it will fake the splat for distant renderables.
           const unsigned int size = pageSize * pageSize;
           uchar * const ogre_restrict BaseData = new uchar [size * 3];
           const uchar maxuchar = 255;
           ColourValue out;
           unsigned int curr_image_pos = 0;
           for (  unsigned int i = 0; i < pageSize; i++ )
           {
           const int z = i;
           for (  unsigned int k = 0; k < pageSize; k++ )
           {
           // Generate the base Color
           const int x = k;
           const Real currHeight = dataMgr->getHeightAtPage(  mDataX,   mDataZ,   x,   z );
           const Real height[] =
           {
           dataMgr->getHeightAtPage(  mDataX,   mDataZ,   x - 1,   z - 1  ),   // Top-Left
           dataMgr->getHeightAtPage(  mDataX,   mDataZ,   x,   z - 1  ),   // Top-Center
           dataMgr->getHeightAtPage(  mDataX,   mDataZ,   x + 1,   z - 1  ),   // Top-Right
           dataMgr->getHeightAtPage(  mDataX,   mDataZ,   x - 1,   z  ),   // Left
           currHeight,   // Current Point
           dataMgr->getHeightAtPage(  mDataX,   mDataZ,   x + 1,   z  ),   // Right
           dataMgr->getHeightAtPage(  mDataX,   mDataZ,   x - 1,   z + 1  ),   // Bottom-Left
           dataMgr->getHeightAtPage(  mDataX,   mDataZ,   x,   z + 1  ),   // Bottom-Center
           dataMgr->getHeightAtPage(  mDataX,   mDataZ,   x + 1,   z + 1  ) // Bottom-Right
           };
          
           // Ask for the current height value and the 8 surrounding values
           // and compute each slope factor
           const Real sloppy[] =
           {
           Math::Abs (   height[0] - currHeight  ) * inv_dxdz,  
           Math::Abs (   height[1] - currHeight  ) * inv_dz,  
           Math::Abs (   height[2] - currHeight  ) * inv_dxdz,  
           Math::Abs (   height[3] - currHeight  ) * inv_dx,  
           0.0f,  
           Math::Abs (   height[5] - currHeight  ) * inv_dx,  
           Math::Abs (   height[6] - currHeight  ) * inv_dxdz,  
           Math::Abs (   height[7] - currHeight  ) * inv_dz,  
           Math::Abs (   height[8] - currHeight  ) * inv_dxdz
           };
          
           // Init the colour
           out = ColourValue(  0.0f,   0.0f,   0.0f,   0.0f );
          
           for (  unsigned int neighbor = 0; neighbor < 9; neighbor++ )
           {
           const Real h = height[neighbor];
           const Real slope = sloppy[neighbor];
          
           if (  h < matHeight0 )
           {
           if (  slope < 0.2f )
           out = matColor[GRASS];// grass-grass
           if (  slope >= 0.15f && slope < 0.4f )
           out = _InterpolateColour(  out,   0.25f,   SAND,   GRASS );// sand-grass
           if (  slope >= 0.3f && slope < 0.65f )
           out = matColor[SAND];// sand-sand
           if (  slope >= 0.55f && slope < 0.75f )
           out = _InterpolateColour(  out,   0.75f,   SAND,   ROCK );// sand-rock
           if (  slope >= 0.70f )
           out = matColor[ROCK];// rock-rock
           }
           else if (  h < matHeight1 )
           {
           if (  slope < 0.15f )
           out = _InterpolateColour(  out,   0.25f,   GRASS,   SNOW );// grass-snow
          
           if (  slope >= 0.10f && slope < 0.45f )
           out = _InterpolateColour(  out,   0.65f,   SNOW,   SAND );// snow-sand
           if (  slope >= 0.25f && slope < 0.65f )
           out = _InterpolateColour(  out,   0.5f,   SNOW,   ROCK );// snow-rock
           if (  slope >= 0.50f && slope < 0.75f )
           out = _InterpolateColour(  out,   0.75f,   SNOW,   ROCK );// snow-rock
           if (  slope >= 0.7f )
           out = matColor[ROCK];// rock-rock
           }
           else
           {
           if (  slope < 0.15f )
           out = matColor[SNOW];// snow-snow
           if (  slope >= 0.1f && slope < 0.45f )
           out = _InterpolateColour(  out,   0.35f,   SNOW,   SAND );// snow-sand
           if (  slope >= 0.25f && slope < 0.65f )
           out = _InterpolateColour(  out,   0.5f,   SNOW,   ROCK );// snow-rock
           if (  slope >= 0.5f && slope < 0.75f )
           out = _InterpolateColour(  out,   0.75f,   SNOW,   ROCK );// snow-rock
           if (  slope >= 0.7f )
           out = matColor[ROCK];// rock-rock
           }
           }
          
           // R G B is the color formats
           BaseData[curr_image_pos+0] = static_cast <uchar> (  out.r * maxuchar );
           BaseData[curr_image_pos+1] = static_cast <uchar> (  out.g * maxuchar );
           BaseData[curr_image_pos+2] = static_cast <uchar> (  out.b * maxuchar );
          
           curr_image_pos += 3;
           }
           }
           return BaseData;
          
          # undef _InterpolateColour
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_BaseTexture2.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_BaseTexture2.cpp - description
          -------------------
          begin : Mon Apr 26 2004
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_BaseTexture2.h"
          #include "OgrePagingLandScapeData2DManager.h"
          
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      37   void PagingLandScapeTexture_BaseTexture2::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           }
           //-----------------------------------------------------------------------
      43   PagingLandScapeTexture* PagingLandScapeTexture_BaseTexture2::newTexture(   )
           {
           return new PagingLandScapeTexture_BaseTexture2(  mParent );
           }
           //-----------------------------------------------------------------------
      48   bool PagingLandScapeTexture_BaseTexture2::isMaterialSupported(   )
           {
           return true;
           }
           //-----------------------------------------------------------------------
      53   PagingLandScapeTexture_BaseTexture2::PagingLandScapeTexture_BaseTexture2(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "Base",   1,   false )
           {
           }
          
           //-----------------------------------------------------------------------
      60   PagingLandScapeTexture_BaseTexture2::~PagingLandScapeTexture_BaseTexture2(   )
           {
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Image.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Image.cpp - description
          -------------------
          begin : Fri Apr 16 2004
          copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
          email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Image.h"
          
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      36   PagingLandScapeTexture* PagingLandScapeTexture_Image::newTexture(   )
           {
           return new PagingLandScapeTexture_Image(  mParent );
           }
           //-----------------------------------------------------------------------
      41   bool PagingLandScapeTexture_Image::isMaterialSupported(   )
           {
           if (  mParent->getOptions(   )->ImageNameLoad )
           return true;
           return false;
           }
           //-----------------------------------------------------------------------
      48   PagingLandScapeTexture_Image::PagingLandScapeTexture_Image(  PagingLandScapeTextureManager *textureMgr ) :
           PagingLandScapeTexture(  textureMgr,   "ImagePaging",   1,   false )
           {
           }
          
           //-----------------------------------------------------------------------
      54   PagingLandScapeTexture_Image::~PagingLandScapeTexture_Image(   )
           {
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_InstantBaseTexture.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_InstantBaseTexture.cpp - description
          -------------------
          begin : Mon Apr 26 2004
          copyright : (  C ) 2003-2006 by Jose A Milan & Tuan Kuranes
          email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_InstantBaseTexture.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      43   PagingLandScapeTexture* PagingLandScapeTexture_InstantBaseTexture::newTexture(   )
           {
           return new PagingLandScapeTexture_InstantBaseTexture(  mParent );
           }
           //-----------------------------------------------------------------------
      48   bool PagingLandScapeTexture_InstantBaseTexture::isMaterialSupported(   )
           {
           if (  mParent->getOptions(   )->NumMatHeightSplat > 3 )
           return true;
           else
           return false;
           }
           //-----------------------------------------------------------------------
      56   PagingLandScapeTexture_InstantBaseTexture::PagingLandScapeTexture_InstantBaseTexture(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "InstantBase",   1,   false )
           {
          
           }
           //-----------------------------------------------------------------------
      63   PagingLandScapeTexture_InstantBaseTexture::~PagingLandScapeTexture_InstantBaseTexture(   )
           {
          
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_InstantBaseTextureEdit.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_InstantBaseTextureEdit.cpp - description
          -------------------
          begin : Mon Apr 26 2004
          copyright : (  C ) 2002-2006 by Jose A Milan & Tuan Kuranes
          email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_InstantBaseTextureEdit.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      42   PagingLandScapeTexture* PagingLandScapeTexture_InstantBaseTextureEdit::newTexture(   )
           {
           return new PagingLandScapeTexture_InstantBaseTextureEdit(  mParent );
           }
           //-----------------------------------------------------------------------
      47   bool PagingLandScapeTexture_InstantBaseTextureEdit::isMaterialSupported(   )
           {
           if (  mParent->getOptions(   )->NumMatHeightSplat > 3 )
           return true;
           else
           return false;
           }
           //-----------------------------------------------------------------------
      55   PagingLandScapeTexture_InstantBaseTextureEdit::PagingLandScapeTexture_InstantBaseTextureEdit(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "InstantBase",   1,   false )
           {
           }
           //-----------------------------------------------------------------------
      61   PagingLandScapeTexture_InstantBaseTextureEdit::~PagingLandScapeTexture_InstantBaseTextureEdit(   )
           {
          
           }
          
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_InstantBaseTextureShadowed.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_InstantBaseTextureShadowed.cpp - description
          -------------------
          begin : Mon Apr 26 2004
          copyright : (  C ) 2003-2006 by Jose A Milan & Tuan Kuranes
          email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as published by *
          * the Free Software Foundation; either version 2 of the License,   or *
          * (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_InstantBaseTextureShadowed.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      43   PagingLandScapeTexture* PagingLandScapeTexture_InstantBaseTextureShadowed::newTexture(   )
           {
           return new PagingLandScapeTexture_InstantBaseTextureShadowed(  mParent );
           }
           //-----------------------------------------------------------------------
      48   bool PagingLandScapeTexture_InstantBaseTextureShadowed::isMaterialSupported(   )
           {
           if (  mParent->getOptions(   )->NumMatHeightSplat > 3 )
           return true;
           else
           return false;
           }
           //-----------------------------------------------------------------------
      56   PagingLandScapeTexture_InstantBaseTextureShadowed::PagingLandScapeTexture_InstantBaseTextureShadowed(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "InstantBaseShadowed",  1,   false )
           {
           mIsShadowed = true;
           }
           //-----------------------------------------------------------------------
      63   PagingLandScapeTexture_InstantBaseTextureShadowed::~PagingLandScapeTexture_InstantBaseTextureShadowed(   )
           {
          
           }
           //-----------------------------------------------------------------------
      68   void PagingLandScapeTexture_InstantBaseTextureShadowed::_loadMaterial(   )
           {
           if (  mMaterial.isNull(   ) )
           {
           PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           const String filename = opt->LandScape_filename;
           const String extname = opt->TextureExtension;
           const String groupName = opt->groupName;
          
           const String commonName = StringConverter::toString(  mDataZ ) +
           String(  "." ) +
           StringConverter::toString(  mDataX );
           const String matname = String(  "InstantBase." ) + commonName + filename;
           const String texname = filename + ".Base." + commonName + ".";
          
           String finalTexName;
           if (  opt->Deformable &&
           ResourceGroupManager::getSingleton(   ).resourceExists(  groupName,  
           texname + "modif." +extname ) )
           {
           finalTexName = texname + "modif." + extname;
           }
           else
           {
           finalTexName = texname + extname;
           }
          
           // check need of material loading
           mMaterial = MaterialManager::getSingleton(   ).getByName(  matname );
           if (  mMaterial.isNull(   ) )
           {
           MaterialPtr templateMaterial;
           if (  opt->VertexCompression && opt->hasFragmentShader )
           {
           templateMaterial = MaterialManager::getSingleton (   ).
           getByName (  String (  "InstantBaseShadowedDecompress" ) );
          
           // Create a new texture using the base image
           mMaterial = templateMaterial->clone(  matname,   true,   groupName );
          
           Pass *p = mMaterial->getTechnique(  0 )->getPass(  0 );
           bindCompressionSettings (  p->getVertexProgramParameters(   ) );
           bindCompressionSettings (  p->getShadowReceiverVertexProgramParameters (   ) );
          
          
           const String texname (  filename + ".HSP." + commonName + "." + extname );
           mMaterial->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  2 )->setTextureName (  texname );
           mPositiveShadow = true;
           }
           else
           {
           templateMaterial = MaterialManager::getSingleton(   ).getByName(  String (  "InstantBaseShadowed" ) );
          
           // Create a new texture using the base image
           mMaterial = templateMaterial->clone (  matname,   true,   groupName );
          
           mShadow.load(  filename +
           ".HS." +
           commonName + "." +
           extname,  
           groupName );
           const unsigned int mTextureSize = static_cast<unsigned int>(  mParent->mPageSize * opt->TextureStretchFactor );//mShadow.getHeight(   );
           uchar *lightdata = new uchar [mTextureSize*mTextureSize];
           mLightImage.loadDynamicImage (  lightdata,  
           mTextureSize,  
           mTextureSize,  
           1,  
           PF_L8,  
           true );
           computeLightMap(   );
           finalTexName = filename + ".L." + commonName + "." + extname;
          
           // debug only save.
           //mLightImage.save(  finalTexName );
          
           mLightTexture = TextureManager::getSingleton(   ).loadImage(  finalTexName,  
           groupName,  
           mLightImage );
           mLightBuffer = mLightTexture->getBuffer (   );
          
           mMaterial->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  2 )->setTextureName (  finalTexName );
          
          
           }
          
           // assign this texture to the material
           loadColorTexture(  finalTexName,   0 );
           mMaterial->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  0 )->setTextureName (  finalTexName );
          
           }
           else
           {
           loadColorTexture(  finalTexName,   0 );
           }
          
           }
           }
          
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Splatting.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Splatting.h"
          #include "OgrePagingLandScapeData2DManager.h"
          
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      39   void PagingLandScapeTexture_Splatting::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           }
           //-----------------------------------------------------------------------
      45   PagingLandScapeTexture* PagingLandScapeTexture_Splatting::newTexture(   )
           {
           return new PagingLandScapeTexture_Splatting(  mParent );
           }
           //-----------------------------------------------------------------------
      50   bool PagingLandScapeTexture_Splatting::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 3 )
           return false;
           if (  opt->numTextureUnits < 2 )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      62   PagingLandScapeTexture_Splatting::PagingLandScapeTexture_Splatting(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "Splatting",   4,   true )
           {
           }
           //-----------------------------------------------------------------------
      68   PagingLandScapeTexture_Splatting::~PagingLandScapeTexture_Splatting(   )
           {
           }
           //-----------------------------------------------------------------------
      72   void PagingLandScapeTexture_Splatting::_loadMaterial(   )
           {
           if (  mMaterial.isNull(   ) )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
           const String filename (  opt->LandScape_filename );
           const String commonName (  StringConverter::toString(  mDataZ ) +
           String(  "." ) +
           StringConverter::toString(  mDataX ) );
           const String matname (  String(  "Splatting." ) + commonName + filename );
           mMaterial = MaterialManager::getSingleton(   ).getByName(  matname );
          
           if (  mMaterial.isNull(   ) )
           {
           mMaterial = MaterialManager::getSingleton(   ).getByName(  "Splatting" );
           assert (  !mMaterial.isNull(   ) );
           // Create a new texture using the base image
           mMaterial = mMaterial->clone(  matname );
          
           const String Basetexname (  String(  "Splatting." ) + commonName + filename );
           TextureManager * const texMgr = TextureManager::getSingletonPtr(   );
           TexturePtr tex = texMgr->getByName (  Basetexname );
           if (  tex.isNull(   ) )
           {
           const unsigned int pageSize = opt->PageSize;
           const unsigned int size = pageSize * pageSize;
           const unsigned int pageMemorySize = size * 4;
          
           uchar * const ogre_restrict BaseData = new uchar [pageMemorySize];
          
           unsigned int alpha_pass = 0;
          
           const unsigned int numSplats = opt->NumMatHeightSplat;
          
           std::vector <uchar * ogre_restrict> alphaData;
           alphaData.reserve(  numSplats );
           alphaData.resize(  numSplats );
           alpha_pass = 0;
           while (  alpha_pass < numSplats )
           {
           alphaData[alpha_pass] = new uchar [size];
           alpha_pass++;
           }
          
           std::vector <bool> bAlphaNotUsed;
           bAlphaNotUsed.reserve(  numSplats );
           bAlphaNotUsed.resize(  numSplats );
           alpha_pass = 0;
           while (  alpha_pass < numSplats )
           {
           bAlphaNotUsed[alpha_pass] = true;
           alpha_pass++;
           }
          
           std::vector <Real> alpha;
           alpha.reserve(  numSplats );
           alpha.resize(  numSplats );
          
           ColourValue color;
           const uchar maxuchar = 255;
           unsigned int posRGB = 0;
           unsigned int posG = 0;
           for (  unsigned int i = 0; i < pageSize; ++i )
           {
           for (  unsigned int j = 0; j < pageSize; ++j )
           {
           const unsigned int c_posRGB = posRGB;
           posRGB += 4;
          
           // Generate the base texture
           _BuildPoint(  i,   j,   color,   alpha );
          
           // R G B A is the format to add the colors
           BaseData[c_posRGB+0] = static_cast <uchar> (  color.r * maxuchar );
           BaseData[c_posRGB+1] = static_cast <uchar> (  color.g * maxuchar );
           BaseData[c_posRGB+2] = static_cast <uchar> (  color.b * maxuchar );
           BaseData[c_posRGB+3] = static_cast <uchar> (  (  1 - (  alpha[0] + alpha[1] + alpha[2] + alpha[3] ) ) * maxuchar ); // Opaque
          
           alpha_pass = 0;
           const unsigned int c_posG = posG;
           posG += 1;
           while (  alpha_pass < numSplats )
           {
           // Generate the alpha map
           if (  !bAlphaNotUsed[alpha_pass] )
           {
           alphaData[alpha_pass][c_posG] = static_cast <uchar> (  alpha[alpha_pass] * maxuchar );
           }
           else if (  alpha[alpha_pass] - 0.05f > 0.0f )
           {
           bAlphaNotUsed[alpha_pass] = false;
           alphaData[alpha_pass][c_posG] = static_cast <uchar> (  alpha[alpha_pass] * maxuchar );
           }
           alpha_pass++;
           }
           }
           }
          
           // Assign the texture to the base map
           // This texture will be used as a base color for the terrain,  
           // it will fake the splat for distant renderables.
           Image tmpImage;
           tmpImage.loadDynamicImage (  BaseData,  
           pageSize,  
           pageSize,  
           1,  
           PF_R8G8B8A8,  
           true );
           tmpImage.resize(  pageSize - 1,   pageSize - 1 );
           texMgr->loadImage (  Basetexname,  
           opt->groupName,  
           tmpImage,   TEX_TYPE_2D );
          
           // assign this texture to the material
          
           // distant technique
           mMaterial->getTechnique(  1 )->getPass(  0 )->getTextureUnitState(  0 )->setTextureName(  Basetexname );
          
           // near technique
           Technique * const t = mMaterial->getTechnique(  0 );
           t->getPass(  0 )->getTextureUnitState(  0 )->setTextureName(  Basetexname );
          
           const String endName (  "." + commonName + filename );
           const String beginName(  "SplattingAlpha" );
           alpha_pass = 0;
           unsigned int splat_pass = 0; // if we remove a pass,   splat still increases
           while (  splat_pass < numSplats )
           {
           if (  !bAlphaNotUsed[splat_pass] )
           {
           Image tmpImage2;
           tmpImage2.loadDynamicImage (  alphaData[splat_pass],  
           pageSize,  
           pageSize,  
           1,  
           PF_A8,  
           true );
           tmpImage2.resize(  pageSize - 1,   pageSize - 1 );
          
           // Create a new texture using the 1st alpha map
           const String texName = beginName + StringConverter::toString(  alpha_pass + 1 ) + endName;
           texMgr->loadImage(  texName,  
           opt->groupName,  
           tmpImage2,  
           TEX_TYPE_2D );// Generate the alpha map
          
          
           // Create a new texture using the 1st alpha map
           // assign this texture to the material
           Pass * const p = t->getPass(  alpha_pass + 1 ); // base TEXture is first pass.
          
           p->getTextureUnitState(  0 )->setTextureName(  opt->SplatDetailMapNames[splat_pass] );
          
           p->getTextureUnitState(  1 )->setTextureName(  texName );
           alpha_pass++;
          
           }
           else
           {
           t->removePass (  alpha_pass + 1 );
           delete [] alphaData[splat_pass];
           }
           splat_pass++;
           }
           }
          
          
          
          
          
           }
           }
           }
           //-----------------------------------------------------------------------
     246   void PagingLandScapeTexture_Splatting::_BuildPoint(   const unsigned int x,   const int z,  
     247   ColourValue& out,   std::vector<Real> &alpha )
           {
           PagingLandScapeData2DManager * const dataPageManager = mParent->getSceneManager(   )->getData2DManager(   );
          
           // Ask for the current height value and the 8 surrounding values
          
           const Real currHeight = dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x,   z );
           const Real height[] =
           {
           dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x - 1,   z - 1 ),   // Top-Left
           dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x,   z - 1 ),   // Top-Center
           dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x + 1,   z - 1 ),   // Top-Right
           dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x - 1,   z ),   // Left
           dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x,   z ),   // Current Point
           dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x + 1,   z ),   // Right
           dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x - 1,   z + 1 ),   // Botton-Left
           dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x,   z + 1 ),   // Botton-Center
           dataPageManager->getHeightAtPage(  mDataX,   mDataZ,   x + 1,   z + 1 ) // Botton-Right
           };
           // Weight(  pt1 ,   pt2 ) = 1 - DistanceSquared(  pt1,  pt2 ) / (  1.75 )^2
          
           const PagingLandScapeOptions * const options = mParent->getOptions(   );
          
           //The slope test
           const Real dx = options->scale.x;
           const Real dz = options->scale.z;
           const Real inv_dxdz = 1 / (  dx+dz );
           const Real inv_dx = 1 / dx;
           const Real inv_dz = 1 / dz;
          
           const Real sloppy[] =
           {
           Math::Abs (   height[0] - currHeight  ) * inv_dxdz,  
           Math::Abs (   height[1] - currHeight  ) * inv_dz,  
           Math::Abs (   height[2] - currHeight  ) * inv_dxdz,  
           Math::Abs (   height[3] - currHeight  ) * inv_dx,  
           0.0f,  
           Math::Abs (   height[5] - currHeight  ) * inv_dx,  
           Math::Abs (   height[6] - currHeight  ) * inv_dxdz,  
           Math::Abs (   height[7] - currHeight  ) * inv_dz,  
           Math::Abs (   height[8] - currHeight  ) * inv_dxdz
           };
          
           // Init the colour
           out = ColourValue(  0.0f,   0.0f,   0.0f,   0.0f );
          
           alpha[0] = 0.0f;
           alpha[1] = 0.0f;
           alpha[2] = 0.0f;
           alpha[3] = 0.0f;
          
           const Real matHeight0 = options->matHeight[1];
           const Real matHeight1 = options->matHeight[2];
          
           #define _MixColour(  out,   color ) (  (  out + color ) * 0.5f )
           #define _InterpolateColour(  F,   color1,   color2 ) (  F * options->matColor[color1] + (  1.0f - F ) * options->matColor[color2] )
          
           for (  unsigned int i = 0; i < 9; i++ )
           {
           const Real h = height[i];
           const Real slope = sloppy[i];
           if (  h < matHeight0 )
           {
           if (  slope < 0.2f )
           {
           // grass-grass
           out = _MixColour (  out,   options->matColor[GRASS] );
           _InterpolateAlpha(  alpha,   1.0f,   GRASS,   GRASS );
           }
           if (  slope > 0.15f && slope < 0.4f )
           {
           // sand-grass
           out = _MixColour (  out,   _InterpolateColour (  0.25f,   SAND,   GRASS ) );
           _InterpolateAlpha(  alpha,   0.25f,   SAND,   GRASS );
           }
           if (  slope > 0.3f && slope < 0.65f )
           {
           // sand-sand
           out = _MixColour (  out,   options->matColor[SAND] );
           _InterpolateAlpha(  alpha,   1.0f,   SAND,   SAND );
           }
           if (  slope > 0.55f && slope < 0.75f )
           {
           // sand-rock
           out = _MixColour(  out,   _InterpolateColour(  0.75f,   SAND,   ROCK ) );
           _InterpolateAlpha(  alpha,   0.75f,   SAND,   ROCK );
           }
           if (  slope > 0.70f )
           {
           // rock-rock
           out = _MixColour (  out,   options->matColor[ROCK] );
           _InterpolateAlpha(  alpha,   1.0f,   ROCK,   ROCK );
           }
           }
           else if (  h < matHeight1 )
           {
           if (  slope < 0.15f )
           {
           // grass-snow
           out = _MixColour(  out,   _InterpolateColour(  0.25f,   GRASS,   SNOW ) );
           _InterpolateAlpha(  alpha,   0.25f,   GRASS,   SNOW );
           }
           if (  slope > 0.10f && slope < 0.45f )
           {
           // snow-sand
           out = _MixColour(  out,   _InterpolateColour(  0.65f,   SNOW,   SAND ) );
           _InterpolateAlpha(  alpha,   0.65f,   SNOW,   SAND );
           }
           if (  slope > 0.25f && slope < 0.65f )
           {
           // snow-rock
           out = _MixColour(  out,   _InterpolateColour(  0.5f,   SNOW,   ROCK ) );
           _InterpolateAlpha(  alpha,   0.5f,   SNOW,   ROCK );
           }
           if (  slope > 0.50f && slope < 0.75f )
           {
           // snow-rock
           out = _MixColour(  out,   _InterpolateColour(  0.75f,   SNOW,   ROCK ) );
           _InterpolateAlpha(  alpha,   0.75f,   SNOW,   ROCK );
           }
           if (  slope > 0.7f )
           {
           // rock-rock
           out = _MixColour (  out,   options->matColor[ROCK] );
           _InterpolateAlpha(  alpha,   1.0f,   ROCK,   ROCK );
           }
           }
           else
           {
           if (  slope < 0.15f )
           {
           // snow-snow
           out = _MixColour (  out,   options->matColor[SNOW] );
           _InterpolateAlpha(  alpha,   1.0f,   SNOW,   SNOW );
           }
           if (  slope > 0.1f && slope < 0.45f )
           {
           // snow-sand
           out = _MixColour(  out,   _InterpolateColour(  0.35f,   SNOW,   SAND ) );
           _InterpolateAlpha(  alpha,   0.35f,   SNOW,   SAND );
           }
           if (  slope > 0.25f && slope < 0.65f )
           {
           // snow-rock
           out = _MixColour(  out,   _InterpolateColour(  0.5f,   SNOW,   ROCK ) );
           _InterpolateAlpha(  alpha,   0.5f,   SNOW,   ROCK );
           }
           if (  slope > 0.5f && slope < 0.75f )
           {
           // snow-rock
           out = _MixColour(  out,   _InterpolateColour(  0.75f,   SNOW,   ROCK ) );
           _InterpolateAlpha(  alpha,   0.75f,   SNOW,   ROCK );
           }
           if (  slope > 0.7f )
           {
           // rock-rock
           out = _MixColour (  out,   options->matColor[ROCK] );
           _InterpolateAlpha(  alpha,   1.0f,   ROCK,   ROCK );
           }
           }
           }
           #undef _InterpolateColour
           #undef _MixColour
           }
           //-----------------------------------------------------------------------
     412   void PagingLandScapeTexture_Splatting::_InterpolateAlpha(  std::vector<Real> &alpha,  
     413   const Real percentaje,  
           const int index1,  
           const int index2 )
           {
           if (  index1 == index2 )
           {
           alpha[index1] += 1;
           }
           else
           {
           alpha[index2] += percentaje;
           alpha[index1] += 1 - percentaje;
           }
          
           const Real oneonfive = 0.2f;
          
           alpha[0] *= (  4 * oneonfive );// 4/5
           alpha[1] *= (  3 * oneonfive );// 3/5
           alpha[2] *= (  4 * oneonfive );// 4/5
           alpha[3] *= (  2 * oneonfive );// 2/5
          
           // Normalize
           const Real total = 1 / (  (  alpha[0] + alpha[1] + alpha[2] + alpha[3] ) * 2 );
          
           alpha[0] = alpha[0] * total;
           alpha[1] = alpha[1] * total;
           alpha[2] = alpha[2] * total;
           alpha[3] = alpha[3] * total;
           }
          
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Splatting2.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Splatting2.h"
          
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      37   void PagingLandScapeTexture_Splatting2::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           }
           //-----------------------------------------------------------------------
      43   PagingLandScapeTexture* PagingLandScapeTexture_Splatting2::newTexture(   )
           {
           return new PagingLandScapeTexture_Splatting2(  mParent );
           }
           //-----------------------------------------------------------------------
      48   bool PagingLandScapeTexture_Splatting2::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 3 )
           return false;
           if (  opt->numTextureUnits < 2 )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      60   PagingLandScapeTexture_Splatting2::PagingLandScapeTexture_Splatting2(  PagingLandScapeTextureManager *textureMgr )
           : PagingLandScapeTexture(  textureMgr,   "Splatting2",   4,   true )
           {
           }
           //-----------------------------------------------------------------------
      65   PagingLandScapeTexture_Splatting2::~PagingLandScapeTexture_Splatting2(   )
           {
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Splatting2Edit.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Splatting2Edit.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      42   void PagingLandScapeTexture_Splatting2Edit::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           }
           //-----------------------------------------------------------------------
      48   PagingLandScapeTexture* PagingLandScapeTexture_Splatting2Edit::newTexture(   )
           {
           return new PagingLandScapeTexture_Splatting2Edit(  mParent );
           }
           //-----------------------------------------------------------------------
      53   bool PagingLandScapeTexture_Splatting2Edit::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 3 )
           return false;
           if (  opt->numTextureUnits < 2 )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      65   PagingLandScapeTexture_Splatting2Edit::PagingLandScapeTexture_Splatting2Edit(  PagingLandScapeTextureManager *textureMgr )
           : PagingLandScapeTexture(  textureMgr,   "Splatting2",   4,   true )
           {
          
           }
           //-----------------------------------------------------------------------
      71   PagingLandScapeTexture_Splatting2Edit::~PagingLandScapeTexture_Splatting2Edit(   )
           {
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Splatting3.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Splatting3.h"
          
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      36   void PagingLandScapeTexture_Splatting3::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           mParent->getOptions(   )->coverage_vertex_color = true;
           mParent->getOptions(   )->colored = true;
           }
           //-----------------------------------------------------------------------
      44   PagingLandScapeTexture* PagingLandScapeTexture_Splatting3::newTexture(   )
           {
           return new PagingLandScapeTexture_Splatting3(  mParent );
           }
           //-----------------------------------------------------------------------
      49   bool PagingLandScapeTexture_Splatting3::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 3 )
           return false;
           if (  !opt->isRenderGL )
           return false;
           if (  opt->numTextureUnits < 4 )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      63   PagingLandScapeTexture_Splatting3::PagingLandScapeTexture_Splatting3(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "Splatting3",   1,   true )
           {
           }
           //-----------------------------------------------------------------------
      69   PagingLandScapeTexture_Splatting3::~PagingLandScapeTexture_Splatting3(   )
           {
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Splatting4.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Splatting4.h"
          
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      36   void PagingLandScapeTexture_Splatting4::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           }
           //-----------------------------------------------------------------------
      42   PagingLandScapeTexture* PagingLandScapeTexture_Splatting4::newTexture(   )
           {
           return new PagingLandScapeTexture_Splatting4(  mParent );
           }
           //-----------------------------------------------------------------------
      47   bool PagingLandScapeTexture_Splatting4::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 3 )
           return false;
           if (  opt->numTextureUnits < 2 )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      59   PagingLandScapeTexture_Splatting4::PagingLandScapeTexture_Splatting4(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "Splatting4",   5,   true )
           {
           }
          
           //-----------------------------------------------------------------------
      66   PagingLandScapeTexture_Splatting4::~PagingLandScapeTexture_Splatting4(   )
           {
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Splatting5.cpp

       1   /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Splatting5.h"
          
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      36   void PagingLandScapeTexture_Splatting5::setOptions(  void )
           {
           mParent->getOptions(   )->normals = true;
           }
           //-----------------------------------------------------------------------
      41   PagingLandScapeTexture* PagingLandScapeTexture_Splatting5::newTexture(   )
           {
           return new PagingLandScapeTexture_Splatting5(  mParent );
           }
           //-----------------------------------------------------------------------
      46   bool PagingLandScapeTexture_Splatting5::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 3 )
           return false;
           if (  opt->numTextureUnits < 4 )
           return false;
           if (  !opt->hasFragmentShader )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      60   PagingLandScapeTexture_Splatting5::PagingLandScapeTexture_Splatting5(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "Splatting5",   0,   false )
           {
          
           }
           //-----------------------------------------------------------------------
      67   PagingLandScapeTexture_Splatting5::~PagingLandScapeTexture_Splatting5(   )
           {
          
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Splatting6.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Splatting6.h"
          
          
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      37   void PagingLandScapeTexture_Splatting6::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           }
           //-----------------------------------------------------------------------
      43   PagingLandScapeTexture* PagingLandScapeTexture_Splatting6::newTexture(   )
           {
           return new PagingLandScapeTexture_Splatting6(  mParent );
           }
           //-----------------------------------------------------------------------
      48   bool PagingLandScapeTexture_Splatting6::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 3 )
           return false;
           if (  opt->numTextureUnits < 2 )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      60   PagingLandScapeTexture_Splatting6::PagingLandScapeTexture_Splatting6(  PagingLandScapeTextureManager *textureMgr ) :
           PagingLandScapeTexture(  textureMgr,   "Splatting6",   4,   true )
           {
           }
           //-----------------------------------------------------------------------
      65   PagingLandScapeTexture_Splatting6::~PagingLandScapeTexture_Splatting6(   )
           {
           }
          
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Splatting7.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting7.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Splatting7.h"
          
          
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      37   void PagingLandScapeTexture_Splatting7::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           }
           //-----------------------------------------------------------------------
      43   PagingLandScapeTexture* PagingLandScapeTexture_Splatting7::newTexture(   )
           {
           return new PagingLandScapeTexture_Splatting7(  mParent );
           }
           //-----------------------------------------------------------------------
      48   bool PagingLandScapeTexture_Splatting7::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 2 )
           return false;
           if (  opt->numTextureUnits < 8 )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      60   PagingLandScapeTexture_Splatting7::PagingLandScapeTexture_Splatting7(  PagingLandScapeTextureManager *textureMgr )
           :
           PagingLandScapeTexture(  textureMgr,   "Splatting7",   4,   true )
           {
           }
          
           //-----------------------------------------------------------------------
      67   PagingLandScapeTexture_Splatting7::~PagingLandScapeTexture_Splatting7(   )
           {
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_Splatting7Edit.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTexture_Splatting7Edit.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_Splatting7Edit.h"
          
          
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      43   void PagingLandScapeTexture_Splatting7Edit::setOptions(  void )
           {
           mParent->getOptions(   )->VertexCompression = false;
           mParent->getOptions(   )->lodMorph = false;
           }
           //-----------------------------------------------------------------------
      49   PagingLandScapeTexture* PagingLandScapeTexture_Splatting7Edit::newTexture(   )
           {
           return new PagingLandScapeTexture_Splatting7Edit(  mParent );
           }
           //-----------------------------------------------------------------------
      54   bool PagingLandScapeTexture_Splatting7Edit::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 2 )
           return false;
           if (  opt->numTextureUnits < 8 )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      66   PagingLandScapeTexture_Splatting7Edit::PagingLandScapeTexture_Splatting7Edit(  PagingLandScapeTextureManager *textureMgr )
           : PagingLandScapeTexture(  textureMgr,   "Splatting7",   4,   true )
           {
           }
          
           //-----------------------------------------------------------------------
      72   PagingLandScapeTexture_Splatting7Edit::~PagingLandScapeTexture_Splatting7Edit(   )
           {
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_SplattingShader.cpp

       1   /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture_SplattingShader.h"
          
          
          namespace Ogre
          {
           // static load
           //params->setNamedConstant
          
           // static unload
           //params->clearAutoConstants(   )
          
          
           //-----------------------------------------------------------------------
      42   PagingLandScapeTexture* PagingLandScapeTexture_SplattingShader::newTexture(   )
           {
           return new PagingLandScapeTexture_SplattingShader(  mParent );
           }
           //-----------------------------------------------------------------------
      47   bool PagingLandScapeTexture_SplattingShader::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 3 )
           return false;
           if (  opt->numTextureUnits < 4 )
           return false;
           if (  !opt->hasFragmentShader )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      61   PagingLandScapeTexture_SplattingShader::PagingLandScapeTexture_SplattingShader(  PagingLandScapeTextureManager *textureMgr ) :
           PagingLandScapeTexture(  textureMgr,   "SplattingShader",   1,   true )
           {
          
           }
           //-----------------------------------------------------------------------
      67   PagingLandScapeTexture_SplattingShader::~PagingLandScapeTexture_SplattingShader(   )
           {
          
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTexture_SplattingShaderEdit.cpp

       1   /***************************************************************************
          OgrePagingLandScapeTexture_Splatting.cpp - description
           -------------------
           begin : Mon Apr 16 2004
           copyright : (  C ) 2003-2006 by Jose A Milan && Tuan Kuranes
           email : spoke@supercable.es & tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreTextureManager.h"
          #include "OgreTechnique.h"
          #include "OgrePass.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeTexture.h"
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          
          #include "OgrePagingLandScapeTexture_SplattingShaderEdit.h"
          
          #include "fileutils.h"
          
          namespace Ogre
          {
           //-----------------------------------------------------------------------
      43   PagingLandScapeTexture* PagingLandScapeTexture_SplattingShaderEdit::newTexture(   )
           {
           return new PagingLandScapeTexture_SplattingShaderEdit(  mParent );
           }
           //-----------------------------------------------------------------------
      48   bool PagingLandScapeTexture_SplattingShaderEdit::isMaterialSupported(   )
           {
           const PagingLandScapeOptions * const opt = mParent->getOptions(   );
          
           if (  opt->NumMatHeightSplat < 3 )
           return false;
           if (  opt->numTextureUnits < 4 )
           return false;
           if (  !opt->hasFragmentShader )
           return false;
          
           return true;
           }
           //-----------------------------------------------------------------------
      62   PagingLandScapeTexture_SplattingShaderEdit::PagingLandScapeTexture_SplattingShaderEdit(  PagingLandScapeTextureManager *textureMgr ) :
           PagingLandScapeTexture(  textureMgr,   "SplattingShader",   1,   true )
           {
          
           }
           //-----------------------------------------------------------------------
      68   PagingLandScapeTexture_SplattingShaderEdit::~PagingLandScapeTexture_SplattingShaderEdit(   )
           {
          
           }
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTile.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTile.cpp - description
          -------------------
          begin : Sun Jun 08 2003
          copyright : (  C ) 2003 by Jose A. Milan
          email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreMovableObject.h"
          #include "OgreAxisAlignedBox.h"
          
          #include "OgreCamera.h"
          
          #include "OgreStringConverter.h"
          
          #include "OgreSceneNode.h"
          
          #include "OgreSimpleRenderable.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          
          #include "OgrePagingLandScapeTileManager.h"
          #include "OgrePagingLandScapeTile.h"
          #include "OgrePagingLandScapeTileInfo.h"
          
          #include "OgrePagingLandScapeData2DManager.h"
          #include "OgrePagingLandScapeData2D.h"
          
          #include "OgrePagingLandScapePageManager.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          #include "OgrePagingLandScapeRenderableManager.h"
          #include "OgrePagingLandScapeRenderable.h"
          
          #include "OgrePagingLandScapeTextureManager.h"
          #include "OgrePagingLandScapeTexture.h"
          
          #include "OgrePagingLandScapeListener.h"
          #include "OgrePagingLandScapeListenerManager.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      60   PagingLandScapeTile::PagingLandScapeTile(  PagingLandScapeTileManager *tileMgr ) :
           mParent(  tileMgr ),  
           mInfo(  0 ),  
           mTileSceneNode (  0 ),  
           mRenderable (  0 ),  
           mInit (  false ),  
           mLoaded (  false ),  
           mLoading (  false )
          {
           for (  unsigned int i = 0; i < 4; i++ )
           {
           mNeighbors[ i ] = 0;
           }
          }
          
          //-----------------------------------------------------------------------
      76  PagingLandScapeTile::~PagingLandScapeTile(   )
          {
          }
          //-----------------------------------------------------------------------
      80  void PagingLandScapeTile::uninit(  void )
          {
           if (  mInit || mLoaded || mRenderable )
           {
           mInit = false;
          
           if (  mLoaded )
           {
           if (  mLoading )
           mParent->getSceneManager(   )->getRenderableManager(   )->unqueueRenderable (  this );
           unload (   );
           }
          
           if (  mNeighbors[SOUTH] )
           mNeighbors[SOUTH]->_setNeighbor (  NORTH,   0 );
           if (  mNeighbors[NORTH] )
           mNeighbors[NORTH]->_setNeighbor (  SOUTH,   0 );
           if (  mNeighbors[EAST] )
           mNeighbors[EAST]->_setNeighbor (  WEST,   0 );
           if (  mNeighbors[WEST] )
           mNeighbors[WEST]->_setNeighbor (  EAST,   0 );
          
           for (  unsigned int i = 0; i < 4; i++ )
           {
           mNeighbors[ i ] = 0;
           }
          
           mParent->getSceneManager(   )->destroySceneNode (  mTileSceneNode->getName (   ) );
           mTileSceneNode = 0;
           mParentSceneNode = 0;
           mInfo = 0;
           mParent->freeTile(  this );
           }
          }
          //-----------------------------------------------------------------------
     115  void PagingLandScapeTile::init (  SceneNode *ParentSceneNode,  
           const int pageX,   const int pageZ,  
           const int tileX,   const int tileZ )
          {
           mInit = true;
          
           PagingLandScapeOptions * const opt = mParent->getOptions(   );
           mInfo = opt->getTileInfo (  pageX,   pageZ,   tileX,   tileZ );
          
           // Calculate the offset from the parent for this tile
           const Vector3 scale = opt->scale;
           const Real endx = opt->TileSize * scale.x;
           const Real endz = opt->TileSize * scale.z;
          
           const Real posX = mInfo->mTileX * endx;
           const Real posZ = mInfo->mTileZ * endz;
          
          
           assert (  ParentSceneNode );
           mParentSceneNode = ParentSceneNode;
           const String NodeName = "PagingLandScapeTile."
           + StringConverter::toString(  pageX ) + "." +
           StringConverter::toString(  pageZ )
           + StringConverter::toString(  tileX ) + "." +
           StringConverter::toString(  tileZ );
           mTileSceneNode = mParent->getSceneManager(   )->createSceneNode (  NodeName + ".Node" );
          
           const Vector3 ParentPos = ParentSceneNode->getWorldPosition(   );
           const Real MaxHeight = mParent->getSceneManager(   )->getData2DManager(   )->getMaxHeight(  mInfo->mPageX,   mInfo->mPageZ );
           assert (  MaxHeight >= (  Real )0.0f );
           //Change Zone of this page
          
           //tile center position
           mWorldPosition = ParentPos + Vector3 (  posX + endx * 0.5f,  
           MaxHeight * 0.5f,  
           posZ + endz * 0.5f );
          
          
           mWorldBounds.setExtents(  posX + ParentPos.x ,  
           (  Real )0.0,  
           posZ + ParentPos.z,  
           posX + ParentPos.x + endx,  
           MaxHeight,  
           posZ + ParentPos.z + endz );
          
          
          
           mWorldBoundsExt.setExtents(  mWorldPosition.x - endx * 1.5f,  
           - MaxHeight * 1.5f,  
           mWorldPosition.z - endz * 1.5f,  
          
           mWorldPosition.x + endx * 1.5f,  
           MaxHeight * 1.5f,  
           mWorldPosition.z + endz * 1.5f );
          
          
          
           for (  unsigned int i = 0; i < 4; i++ )
           {
           mNeighbors[ i ] = 0;
           }
           //force update in scene node
           mLoaded = false;
           mLoading = false;
          }
          //-----------------------------------------------------------------------
     181  void PagingLandScapeTile::_setNeighbor(  Neighbor n,   PagingLandScapeTile *t )
          {
           mNeighbors[ n ] = t;
           if (  t && mLoaded && mRenderable && t->mLoaded )
           {
           PagingLandScapeRenderable *r = t->getRenderable(   );
          
           mRenderable->_setNeighbor (  n,   r );
           if (  r )
           {
           switch (  n )
           {
           case NORTH:
           r->_setNeighbor (  SOUTH,   mRenderable );
           return;
           case SOUTH:
           r->_setNeighbor (  NORTH,   mRenderable );
           return;
           case EAST:
           r->_setNeighbor (  WEST,   mRenderable );
           return;
           case WEST:
           r->_setNeighbor (  EAST,   mRenderable );
           return;
           }
           }
           }
          };
          //-----------------------------------------------------------------------
     210  void PagingLandScapeTile::_linkRenderableNeighbor(   )
          {
           assert (  mLoaded && mRenderable );
           PagingLandScapeRenderable *n;
           PagingLandScapeTile *t = mNeighbors[SOUTH];
           if (  t && t->mLoaded )
           {
           n = t->getRenderable(   );
           assert (  n );
           mRenderable->_setNeighbor (  SOUTH,   n );
           n->_setNeighbor (  NORTH,   mRenderable );
           }
           t = mNeighbors[NORTH];
           if (  t && t->mLoaded )
           {
           n = t->getRenderable(   );
           assert (  n );
           mRenderable->_setNeighbor (  NORTH,   n );
           n->_setNeighbor (  SOUTH,   mRenderable );
           }
           t = mNeighbors[EAST];
           if (  t && t->mLoaded )
           {
           n = t->getRenderable(   );
           assert (  n );
           mRenderable->_setNeighbor (  EAST,   n );
           n->_setNeighbor (  WEST,   mRenderable );
           }
           t = mNeighbors[WEST];
           if (  t && t->mLoaded )
           {
           n = t->getRenderable(   );
           assert (  n );
           mRenderable->_setNeighbor (  WEST,   n );
           n->_setNeighbor (  EAST,   mRenderable );
           }
          }
          //-----------------------------------------------------------------------
     248  void PagingLandScapeTile::_updateLod(   )
          {
           if (  mRenderable )
           {
           _linkRenderableNeighbor(   );
           //mRenderable->update (   );
           }
          }
          //-----------------------------------------------------------------------
     257  void PagingLandScapeTile::load(   )
          {
           assert (  mInit && !mLoaded && mRenderable == 0 );
          
           PagingLandScapeRenderableManager * const rendMgr = mParent->getSceneManager(   )->getRenderableManager(   );
          
           // Request a renderable
           mRenderable = rendMgr->getRenderable(   );
          
           assert (  mRenderable );
          
           mRenderable->init (  mInfo );
           mRenderable->mParentTile = this;
          
           // Set the material
           PagingLandScapeTexture * const tex = mParent->getSceneManager(   )->getTextureManager(   )->getTexture (  mInfo->mPageX,   mInfo->mPageZ );
           assert (  tex );
           assert (  !tex->getMaterial(   ).isNull(   ) ) ;
           mRenderable->setMaterial(  tex->getMaterial(   ) );
          
           mParentSceneNode->addChild (  mTileSceneNode );
           mLoaded = true;
           mVisible = false;
          
           //Queue its renderable for loading
           rendMgr->queueRenderableLoading (  this );
           mParent->getSceneManager(   )->getPageManager(   )->setTerrainReady (  false );
          }
          //-----------------------------------------------------------------------
     286  void PagingLandScapeTile::unload(   )
          {
           assert (  mLoaded );
           mRenderable->uninit (   );
          
           mRenderable = 0;
           mVisible = true;
           mLoaded = false;
           mTimeUntouched = 0;
           mParentSceneNode->removeChild (  mTileSceneNode );
          
           assert (  mInfo );
           mParent->getSceneManager(   )->getListenerManager(   )->fireTileUnloaded (  mInfo->mPageX,   mInfo->mPageZ,  
           mInfo->mTileX,   mInfo->mTileZ,   getWorldBbox (   ) );
          }
          
          //-----------------------------------------------------------------------
     303  void PagingLandScapeTile::_Notify(  const Vector3 &pos,   const PagingLandScapeCamera * const Cam )
          {
           //const bool wasvisible = mVisible && mLoaded && (  mRenderable != 0 ) && mRenderable->isVisible (   );
           if (  
           1
           //(  pos - mWorldPosition ).squaredLength(   ) < mParent->getOptions(   )->renderable_factor
           //&& Cam->isVisible (  mWorldBoundsExt )
            )
           {
           touch(   );
           mVisible = true;
          
           }
           else
           {
           mVisible = false;
           }
           // if it changes
           //if (  wasvisible != mVisible )
           {
           if (  mVisible )
           {
           if (  !mLoaded )
           {
           load(   );
          
           // now visible
           mParent->getSceneManager(   )->getListenerManager (   )->fireTileShow
           (  mInfo->mPageX,   mInfo->mPageZ,   mInfo->mTileX,   mInfo->mTileZ,   mWorldBounds );
           }
           assert (  mRenderable );
           mRenderable->setVisible (  true );
          
           }
           else // if (  wasvisible )
           {
           // now hidden
           if (  mRenderable )
           mRenderable->setVisible (  false );
          
           }
           }
          
          }
          //-----------------------------------------------------------------------
     348  const bool PagingLandScapeTile::unloadUntouched (   )
          {
           //if (  mLoaded )
           {
           if (  mTimeUntouched == 0 )
           {
           // not visible check if we must unload it
           // must not have been visible for some time
          
           if (  mInfo )
           {
           mParent->getSceneManager(   )->getListenerManager (   )->fireTileHide
           (  mInfo->mPageX,   mInfo->mPageZ,   mInfo->mTileX,   mInfo->mTileZ,   mWorldBounds );
          
           }
           if (  mLoading )
           mParent->getSceneManager(   )->getRenderableManager(   )->unqueueRenderable (  this );
           else if (  mLoaded )
           unload(   );
          
          
           return true;
           }
          
           mTimeUntouched--;
           }
           return false;
          }
          //-----------------------------------------------------------------------
     377  bool PagingLandScapeTile::intersectSegmentFromAbove(  const Vector3 & start,  
     378   const Vector3 & dir,  
     379   Vector3 * result )
          {
           if (  mWorldBounds.isNull(   ) )
           {
           if (  result != 0 )
           * result = Vector3(  -1.0f,   -1.0f,   -1.0f );
           return false;
           }
           Vector3 ray = start;
           const Vector3 * const corners = mWorldBounds.getAllCorners(   );
          
           //start with the next one...
           ray += dir;
          
          
           const Real leftBorder = corners[ 0 ].x;
           const Real rightBorder = corners[ 4 ].x;
           const Real topBorder = corners[ 0 ].z;
           const Real bottomBorder = corners[ 4 ].z;
          
           PagingLandScapeData2DManager * const dataManager = mParent->getSceneManager(   )->getData2DManager(   );
           PagingLandScapeData2D * const data = dataManager->getData2D (  mInfo->mPageX,   mInfo->mPageZ );
           if (  data == 0 )
           {
           // just go until next tile.
           while(  (  ray.x > leftBorder ) &&
           (  ray.x < rightBorder ) &&
           (  ray.z > topBorder ) &&
           (  ray.z < bottomBorder ) )
           {
           ray += dir;
           //ember specific start
           if (  ray.y > mWorldBoundsExt.getMaximum(   ).y ) {
           //there's no terrain above this point anyway
           return false;
           }
           //ember specific end
           }
           }
           else
           {
           const Real localMax = (  mRenderable && mRenderable->isLoaded (   ) ) ?
           mRenderable->getMaxHeight (   )
           :
           data->getMaxHeight (   );
           const Vector3 &invScale = mParent->getOptions (   )->invScale;
           const unsigned int pSize = mParent->getOptions (   )->PageSize;
          
           const Real invScaledDirX = dir.x * invScale.x;
           const Real invScaledDirZ = dir.z * invScale.z;
           Real invScaledRayX = (  ray.x * invScale.x ) - data->getShiftX (   );
           Real invScaledRayZ = (  ray.z * invScale.z ) - data->getShiftZ (   );
           const int pSizeMinusOne = static_cast <int> (  pSize - 1 );
          
           int i_x,   i_z;
          
          
           while(  (  ray.x > leftBorder ) &&
           (  ray.x < rightBorder ) &&
           (  ray.z > topBorder ) &&
           (  ray.z < bottomBorder ) )
           {
           //ember specific start
           if (  ray.y > mWorldBoundsExt.getMaximum(   ).y ) {
           //there's no terrain above this point anyway
           return false;
           }
           //ember specific end
          
           if (  ray.y <= localMax ) // until under the max possible for this page/tile
           {
           // adjust x and z to be local to page
           i_x = static_cast<int> (  invScaledRayX );
           i_z = static_cast<int> (  invScaledRayZ );
          
           // due to Real imprecision on Reals,   we have to use boundaries here
           // otherwise we'll hit asserts.
           if (  i_x > pSizeMinusOne ) i_x = pSizeMinusOne;
           else if (  i_x < 0 ) i_x = 0;
           if (  i_z > pSizeMinusOne ) i_z = pSizeMinusOne;
           else if (  i_z < 0 ) i_z = 0;
          
           if (  ray.y <= data->getHeight (  static_cast<unsigned int> (  i_z * pSize + i_x ) ) )// until under the max
           {
          
           // Found intersection range
           // zone (  ray - dir < intersection < ray.y + dir )
           // now do a precise check using a interpolated height getter (  height between vertices )
           ray -= dir;
           // until under the interpolated upon current LOD max
           {
           while (  ray.y > dataManager->getInterpolatedWorldHeight(  ray.x,   ray.z )
           &&
           ray.y < localMax
           &&
           ray.y > 0
           &&
           (  ray.x > leftBorder ) &&
           (  ray.x < rightBorder ) &&
           (  ray.z > topBorder ) &&
           (  ray.z < bottomBorder ) )
           {
           ray += dir;
           }
           }
           ray.y = dataManager->getInterpolatedWorldHeight(  ray.x,   ray.z );
          
           *result = ray;
           return true;
           }
           }
           ray += dir;
           invScaledRayX += invScaledDirX;
           invScaledRayZ += invScaledDirZ;
           }
           }
          
          
           if (  ray.x < leftBorder && mNeighbors[ WEST ] != 0 && mNeighbors[ WEST ]->isLoaded(   ) )
           return mNeighbors[ WEST ] ->intersectSegmentFromAbove(  ray,   dir,   result );
           else if (  ray.z < topBorder && mNeighbors[ NORTH ] != 0 && mNeighbors[ NORTH ]->isLoaded(   ) )
           return mNeighbors[ NORTH ] ->intersectSegmentFromAbove(  ray,   dir,   result );
           else if (  ray.x > rightBorder && mNeighbors[ EAST ] != 0 && mNeighbors[ EAST ]->isLoaded(   ) )
           return mNeighbors[ EAST ] ->intersectSegmentFromAbove(  ray,   dir,   result );
           else if (  ray.z > bottomBorder && mNeighbors[ SOUTH ] != 0 && mNeighbors[ SOUTH ]->isLoaded(   ) )
           return mNeighbors[ SOUTH ] ->intersectSegmentFromAbove(  ray,   dir,   result );
           else
           {
           if (  result != 0 )
           * result = Vector3(  -1.0f,   -1.0f,   -1.0f );
          
           return false;
           }
          }
          //-----------------------------------------------------------------------
     514  bool PagingLandScapeTile::intersectSegmentFromBelow(  const Vector3 & start,  
     515   const Vector3 & dir,  
     516   Vector3 * result )
          {
           if (  mWorldBounds.isNull(   ) )
           {
           if (  result != 0 )
           * result = Vector3(  -1.0f,   -1.0f,   -1.0f );
          
           return false;
           }
           Vector3 ray = start;
           const Vector3 * const corners = mWorldBounds.getAllCorners(   );
          
           //start with the next one...
           ray += dir;
          
           PagingLandScapeData2DManager * const dataManager = mParent->getSceneManager(   )->getData2DManager(   );
          
           PagingLandScapeData2D *data = dataManager->getData2D (  mInfo->mPageX,   mInfo->mPageZ );
          
           const Real leftBorder = corners[ 0 ].x;
           const Real rightBorder = corners[ 4 ].x;
           const Real topBorder = corners[ 0 ].z;
           const Real bottomBorder = corners[ 4 ].z;
          
          
          
           if (  data == 0 )
           {
           // just go until next tile.
           while (  (  ray.x > leftBorder ) &&
           (  ray.x < rightBorder ) &&
           (  ray.z > topBorder ) &&
           (  ray.z < bottomBorder ) )
           {
           ray += dir;
           }
           }
           else
           {
           const Real localMax = (  mRenderable && mRenderable->isLoaded (   ) ) ?
           mRenderable->getMaxHeight (   )
           :
           data->getMaxHeight (   );
          
           while (  (  ray.x > leftBorder ) &&
           (  ray.x < rightBorder ) &&
           (  ray.z > topBorder ) &&
           (  ray.z < bottomBorder ) )
           {
          
           if (  ray.y >= 0 &&
           ray.y >= data->getHeightAbsolute(  ray.x,   ray.z ) )
           {
          
           // Found intersection range
           // zone (  ray - dir < intersection < ray.y + dir )
           // now do a precise check using a interpolated height getter (  height between vertices )
           ray -= dir;
           // until under the interpolated upon current LOD max
           {
           while (  ray.y < dataManager->getInterpolatedWorldHeight(  ray.x,   ray.z )
           &&
           ray.y < localMax
           &&
           ray.y >= 0
           &&
           (  ray.x > leftBorder ) &&
           (  ray.x < rightBorder ) &&
           (  ray.z > topBorder ) &&
           (  ray.z < bottomBorder ) )
           {
           ray += dir;
           }
           }
           ray.y = dataManager->getInterpolatedWorldHeight (  ray.x,   ray.z );
          
           *result = ray;
           return true;
           }
           ray += dir;
           }
           }
          
          
           if (  ray.x < leftBorder && mNeighbors[ WEST ] != 0 && mNeighbors[ WEST ]->isLoaded(   ) )
           return mNeighbors[ WEST ] ->intersectSegmentFromBelow(  ray,   dir,   result );
           else if (  ray.z < topBorder && mNeighbors[ NORTH ] != 0 && mNeighbors[ NORTH ]->isLoaded(   ) )
           return mNeighbors[ NORTH ] ->intersectSegmentFromBelow(  ray,   dir,   result );
           else if (  ray.x > rightBorder && mNeighbors[ EAST ] != 0 && mNeighbors[ EAST ]->isLoaded(   ) )
           return mNeighbors[ EAST ] ->intersectSegmentFromBelow(  ray,   dir,   result );
           else if (  ray.z > bottomBorder && mNeighbors[ SOUTH ] != 0 && mNeighbors[ SOUTH ]->isLoaded(   ) )
           return mNeighbors[ SOUTH ] ->intersectSegmentFromBelow(  ray,   dir,   result );
           else
           {
           if (  result != 0 )
           * result = Vector3(  -1.0f,   -1.0f,   -1.0f );
          
           return false;
           }
          }
          //-----------------------------------------------------------------------
     617  void PagingLandScapeTile::updateTerrain (   )
          {
           assert (  mInit && mLoaded && mRenderable );
           mRenderable->setNeedUpdate (   );
          }
          
     623  void PagingLandScapeTile::setRenderQueueGroup(  uint8 qid )
          {
           if (  mRenderable && mRenderable->isLoaded(   ) )
           mRenderable->setRenderQueueGroup(  qid );
          };
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeTileManager.cpp

       1  /***************************************************************************
          OgrePagingLandScapeTileManager.cpp - description
          -------------------
          begin : Mon Jun 16 2003
          copyright : (  C ) 2003-2006 by Jose A. Milan and Tuan Kuranes
          email : spoke2@supercable.es && tuan.kuranes@free.fr
          ***************************************************************************/
          
          /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          
          #include "OgreVector3.h"
          #include "OgreColourValue.h"
          
          #include "OgreMovableObject.h"
          #include "OgreAxisAlignedBox.h"
          
          #include "OgreCamera.h"
          
          #include "OgrePagingLandScapeSceneManager.h"
          
          #include "OgrePagingLandScapeOptions.h"
          #include "OgrePagingLandScapeCamera.h"
          #include "OgrePagingLandScapeTileManager.h"
          #include "OgrePagingLandScapeTile.h"
          
          namespace Ogre
          {
          
           //-----------------------------------------------------------------------
      40   PagingLandScapeTileManager::PagingLandScapeTileManager(  PagingLandScapeSceneManager * scnMgr ):
          mSceneManager(  scnMgr ),  
          mOptions(  scnMgr->getOptions (   ) )
          {
           mNumTiles = 0;
           // Add the requested initial number
           //_addBatch(  mParent->getOptions(   )->num_tiles );
          }
          //-----------------------------------------------------------------------
      49  PagingLandScapeTileManager::~PagingLandScapeTileManager(   )
          {
           assert (  mTiles.size(   ) == mNumTiles );
           std::for_each(  mTiles.begin(   ),  
           mTiles.end(   ),  
           delete_object(   ) );
           // destroy tiles
           mTiles.clear(   );
          
          }
          //-----------------------------------------------------------------------
      60  void PagingLandScapeTileManager::clear(   )
          {
           assert (  mTiles.size(   ) == (  unsigned int ) mQueue.getSize(   ) &&
           mTiles.size(   ) == mNumTiles );
          }
          //-----------------------------------------------------------------------
      66  void PagingLandScapeTileManager::load(   )
          {
           const unsigned int nTile = mOptions->num_tiles;
           if (  mNumTiles < nTile )
           {
           _addBatch (  nTile - mNumTiles );
           }
           assert (  mOptions->num_tiles <= mTiles.size(   ) );
           // else if (  mNumTiles > nTile )
           // {
           // for (  unsigned int i = nTile; i < mNumTiles; i++ )
           // {
           // PagingLandScapeTile *t = mTiles[i];
           // mQueue.remove(  t );
           // delete t;
           // }
           // mNumTiles = nTile;
           // mTiles.resize (  nTile );
           // }
          }
          //-----------------------------------------------------------------------
      87  PagingLandScapeTile *PagingLandScapeTileManager::getTile(   )
          {
           if (  mQueue.empty(   ) )
           {
           // We do not have more tiles,   so we need to allocate more
           _addBatch(  mOptions->num_tiles_increment );
           // Increment the next batch by a 10%
           //mParent->getOptions(   )->num_tiles_increment += static_cast<unsigned int> (  mParent->getOptions(   )->num_tiles_increment * 0.1f );
           }
           return mQueue.pop(   );
          }
          //-----------------------------------------------------------------------
      99  void PagingLandScapeTileManager::freeTile(  PagingLandScapeTile *tile )
          {
           assert (  !tile->isLoaded (   ) && tile->getRenderable (   ) == 0 );
           mQueue.push (  tile );
          }
          //-----------------------------------------------------------------------
     105  unsigned int PagingLandScapeTileManager::numTiles(  void ) const
          {
           return mNumTiles;
          }
          //-----------------------------------------------------------------------
     110  size_t PagingLandScapeTileManager::numFree(   ) const
          {
           return mQueue.getSize(   );
          }
          //-----------------------------------------------------------------------
     115  void PagingLandScapeTileManager::_addBatch(  const unsigned int num )
          {
           mNumTiles += num;
           mTiles.reserve (  mNumTiles );
           for (  unsigned int i = 0; i < num; i++ )
           {
           PagingLandScapeTile* tile = new PagingLandScapeTile(  this );
           mTiles.push_back (  tile );
           mQueue.push (  tile );
           }
          }
          //-----------------------------------------------------------------------
     127  void PagingLandScapeTileManager::unloadUntouched(   )
          {
           std::for_each(  mTiles.begin(   ),  
           mTiles.end(   ),  
           std::mem_fun(  &PagingLandScapeTile::unloadUntouched ) );
          }
          
          } //namespace

./components/ogre/SceneManagers/EmberPagingSceneManager/src/filetutils.cpp

       1  /***************************************************************************
          * *
          * This program is free software; you can redistribute it and/or modify *
          * it under the terms of the GNU General Public License as *
          * published by the Free Software Foundation; either version 2 of the *
          * License,   or (  at your option ) any later version. *
          * *
          ***************************************************************************/
          
          #include "OgrePagingLandScapePrecompiledHeaders.h"
          
          #include "OgreNoMemoryMacros.h"
          
          
          #include <sys/types.h>
          #include <sys/stat.h>
          
          #ifdef _WIN32
          # include <windows.h>
          # include <direct.h>
          # include <io.h>
          
          # define S_ISDIR(  mode ) (  mode&S_IFDIR )
          # define STRUCT_STAT struct _stat
          # define CHDIR _chdir
          # define GETCWD _getcwd
          # define MKDIR(  A ) _mkdir(  A )
          # define STAT(  A,  S ) _stat(  A,  S )
          #else //_LINUX _APPLE
          
          #ifdef _APPLE
          # include <malloc/malloc.h>
          #else
          # include <malloc.h>
          #endif
          # include <unistd.h>
          # include <sys/param.h>
          
          # define MAX_PATH MAXPATHLEN
          # define STRUCT_STAT struct stat
          # define CHDIR chdir
          # define GETCWD getcwd
          # define MKDIR(  A ) mkdir(  A,   S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH )// set mode of directory to drwxr-xr-x.
          # define STAT(  A,  S ) stat(  A,  S )
          #endif //_LINUX _APPLE
          
          //-----------------------------------------------------------------------
      48  static char* GetCurrDir(   )
          {
           // GETCWD MALLOCS A BUFFER. REMEMBER TO FREE IT.
           return GETCWD(  0,  0 );;
          }
          
          #ifdef __cplusplus
          extern "C" {
          #endif
          
          //-----------------------------------------------------------------------
      59  bool DirExists(  const char *Dirname )
          {
           STRUCT_STAT st;
          
           if (  STAT(  Dirname,   &st ) )
           {
           // doesn't exist; must create it
           return false;
           }
           if (  S_ISDIR(  st.st_mode ) == 0 )
           {
           // it's not a dir,   must create a dir
           return false;
           }
           return true;
          }
          //-----------------------------------------------------------------------
      76  char * ChangeToDir (  const char *Dirname )
          {
           STRUCT_STAT st;
          
           if (  STAT(  Dirname,   &st ) )
           {
           // doen't exist; must create it
           MKDIR (  Dirname );
           }
           if (  S_ISDIR(  st.st_mode ) == 0 )
           {
           // it's not a dir,   must create a dir
           MKDIR (  Dirname );
           }
           char *oldDirname = GetCurrDir (   );
           CHDIR(  Dirname );
           return oldDirname;
          }
          
          
      96  void RetablishDir(  char *oldDirname )
          {
           if (  oldDirname != NULL )
           {
           ChangeToDir (  oldDirname );
           // FREE MALLOC'ED GETCWD BUFFER.
           free (  oldDirname );
           }
          }
          
          #ifdef __cplusplus
          }/* end extern C definitions */
          #endif

./components/ogre/SimpleRenderContext.cpp

       1  //
          // C++ Implementation: SimpleRenderContext
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "SimpleRenderContext.h"
          
          #include "EmberOgre.h"
          #include "GUIManager.h"
          #include "model/Model.h"
          
          #include "framework/Exception.h"
          #include <OgreBitwise.h>
          
          namespace EmberOgre {
          
      34  SimpleRenderContextResourceLoader::SimpleRenderContextResourceLoader(  SimpleRenderContext& renderContext )
          : mRenderContext(  renderContext )
          {
          }
          
      39  void SimpleRenderContextResourceLoader::loadResource (  Ogre::Resource *resource )
          {
           if (  resource->getLoadingState(   ) == Ogre::Resource::LOADSTATE_UNLOADED ) {
           mRenderContext.getRenderTexture(   )->update(   );
           }
          }
          
          
      47  SimpleRenderContext::SimpleRenderContext(  const std::string& prefix,   int width,   int height )
          : mMainLight(  0 ),   mSceneManager(  0 ),   mWidth(  width ),   mHeight(  height ),   mRenderTexture(  0 ),   mCameraNode(  0 ),   mCameraPitchNode(  0 ),   mEntityNode(  0 ),   mRootNode(  0 ),   mCamera(  0 ),   mViewPort(  0 ),   mResourceLoader(  *this )
          {
          
           S_LOG_VERBOSE(  "Creating new SimpleRenderContext for prefix " << prefix << " with w:" << mWidth << " h:" << mHeight );
           mSceneManager = Ogre::Root::getSingleton(   ).createSceneManager(  Ogre::ST_GENERIC,   prefix + "_sceneManager" );
           mSceneManager->setFog(  Ogre::FOG_NONE,   Ogre::ColourValue::ZERO,   0,   0,   0 );
          
           mRootNode = mSceneManager->getRootSceneNode(   );
          
          
           mEntityNode = mRootNode->createChildSceneNode(   );
          
           ///make the cameranode a child of the main entity node
           mCameraNode = mRootNode->createChildSceneNode(   );
          
           mCameraPitchNode = mCameraNode->createChildSceneNode(   );
          
           createCamera(  prefix );
           createImage(  prefix );
           //setVisible(  false );
           mMainLight = mSceneManager->createLight(  "MainLight" );
           mMainLight->setType(  Ogre::Light::LT_DIRECTIONAL );
           mMainLight->setDirection(  Ogre::Vector3(  -1,  0,  0 ) );
           mSceneManager->setAmbientLight(  Ogre::ColourValue(  0.5,   0.5,   0.5 ) );
           mCameraPitchNode->attachObject(  mMainLight );
          
           resetCameraOrientation(   );
          }
          
          
      78  SimpleRenderContext::~SimpleRenderContext(   )
          {
           if (  mCamera ) {
           mSceneManager->destroyCamera(  mCamera );
           }
           ///we need to do this before the scene manager is destroyed since the destructor for Model relies on the scenemanager existing (  and thus can be called in the scene manager's destructor )
           if (  mRootNode ) {
           mRootNode->removeAndDestroyAllChildren(   );
           ///the root scene node cannot be removed (  evar!! )
          // mSceneManager->destroySceneNode(  mSceneManager->getRootSceneNode(   )->getName(   ) );
           }
           ///we must make sure that all models are destroyed before the entities are destroyed,   else we'll get segfaults in the Model destructor as it tries to access already deleted entities
           mSceneManager->destroyAllMovableObjectsByType(  Model::Model::sMovableType );
           Ogre::Root::getSingleton(   ).destroySceneManager(  mSceneManager );
          }
          
      94  Ogre::SceneNode* SimpleRenderContext::getSceneNode(   ) const
          {
           return mEntityNode;
          }
          
      99  Ogre::Camera* SimpleRenderContext::getCamera(   ) const
          {
           return mCamera;
          }
          
     104  void SimpleRenderContext::setActive(  bool active )
          {
           if (  mRenderTexture ) {
           mRenderTexture->setActive(  active );
           }
          }
          
     111  void SimpleRenderContext::repositionCamera(   )
          {
           mEntityNode->_update(  true,   true );
           Ogre::AxisAlignedBox bbox = mEntityNode->_getWorldAABB(   );
           if (  !bbox.isInfinite(   ) && !bbox.isNull(   ) ) {
           Ogre::Vector3 center = bbox.getCenter(   );
           Ogre::Vector3 localCenter = center - mRootNode->getPosition(   );
           mCameraNode->setPosition(  localCenter );
           }
          }
          
     122  void SimpleRenderContext::createCamera(  const std::string& prefix )
          {
           mCamera = mSceneManager->createCamera(  prefix + "_SimpleRenderContextCamera" );
          
           mCameraPitchNode->attachObject(  mCamera );
          }
          
     129  void SimpleRenderContext::pitch(  Ogre::Degree degrees )
          {
           mCameraPitchNode->pitch(  degrees );
          }
     133  void SimpleRenderContext::yaw(  Ogre::Degree degrees )
          {
           mCameraNode->yaw(  degrees );
          }
     137  void SimpleRenderContext::roll(  Ogre::Degree degrees )
          {
           mCameraNode->roll(  degrees );
          }
          
          
     143  float SimpleRenderContext::getCameraDistance(   ) const
          {
           if (  mDefaultCameraDistance ) {
           return mCamera->getPosition(   ).z / mDefaultCameraDistance;
           }
           return mCamera->getPosition(   ).z;
          }
          
     151  void SimpleRenderContext::setCameraDistance(  Ogre::Real distance )
          {
           if (  distance != 0 ) {
           Ogre::Real cameraDistance = Ogre::Math::Abs(  distance ) / 100;
           if (  cameraDistance > 0 ) {
           mCamera->setNearClipDistance(  Ogre::Math::Abs(  distance ) / 100 );
           } else {
           mCamera->setNearClipDistance(  0.01f );
           }
           mCamera->setFarClipDistance(  (  Ogre::Math::Abs(  distance ) + mDefaultCameraDistance ) );
           }
           Ogre::Vector3 pos(  0,  0,  distance );
           mCamera->setPosition(  pos );
          }
          
          // void SimpleRenderContext::setCameraAbsoluteDistance(  Ogre::Real distance )
          // {
          // Ogre::Vector3 pos(  0,  0,  distance );
          // mCamera->setPosition(  pos );
          // }
          
     172  float SimpleRenderContext::getAbsoluteCameraDistance(   ) const
          {
           return mCamera->getPosition(   ).z;
          }
          
     177  Ogre::Quaternion SimpleRenderContext::getEntityRotation(   )
          {
           return mCamera->getDerivedOrientation(   ).Inverse(   );
          }
          
     182  void SimpleRenderContext::resetCameraOrientation(   )
          {
           mCameraPitchNode->setOrientation(  Ogre::Quaternion::IDENTITY );
           mCameraNode->setOrientation(  Ogre::Quaternion::IDENTITY );
          
          }
          
     189  Ogre::SceneNode* SimpleRenderContext::getCameraRootNode(   ) const
          {
           return mCameraNode;
          }
          
     194  Ogre::TexturePtr SimpleRenderContext::getTexture(   )
          {
           return mTexture;
          }
          
          
     200  void SimpleRenderContext::createImage(  const std::string& prefix )
          {
          
           if (  mWidth == 0 || mHeight == 0 ) {
           throw Ember::Exception(  "Height and width of the image can't be 0." );
           }
          
           Ogre::Real aspectRatio = static_cast<float>(  mWidth ) / static_cast<float>(  mHeight );
          
           ///the width and height needs to be multipes of 2
           mWidth = Ogre::Bitwise::firstPO2From(  mWidth );
           mHeight = Ogre::Bitwise::firstPO2From(  mHeight );
          
          
           ///first,   create a RenderTexture to which the Ogre renderer should render the image
           S_LOG_VERBOSE(  "Creating new rendertexture " << (  prefix + "_SimpleRenderContextRenderTexture" ) << " with w:" << mWidth << " h:" << mHeight );
           mTexture = Ogre::TextureManager::getSingleton(   ).createManual(  prefix + "_SimpleRenderContextRenderTexture",   "Gui",   Ogre::TEX_TYPE_2D,   mWidth,   mHeight,   0,   Ogre::PF_A8R8G8B8,  Ogre::TU_RENDERTARGET,   &mResourceLoader );
           if (  mTexture.isNull(   ) ) {
           S_LOG_WARNING(  "Could not create a texture." );
           return;
           }
          
          
           mRenderTexture = mTexture->getBuffer(   )->getRenderTarget(   );
           mRenderTexture->setAutoUpdated(  false );
          
           S_LOG_VERBOSE(  "Removing viewports." );
           mRenderTexture->removeAllViewports(   );
           ///initially deactivate it until setActive(  true ) is called
           mRenderTexture->setActive(  false );
           S_LOG_VERBOSE(  "Setting aspect ratio of camera to " << aspectRatio );
           mCamera->setAspectRatio(  aspectRatio );
           ///make sure the camera renders into this new texture
           S_LOG_VERBOSE(  "Adding camera." );
           mViewPort = mRenderTexture->addViewport(  mCamera );
           ///this should preferrably be a transparent background,   so that CEGUI could itself decide what to show behind it,   but alas I couldn't get it to work,   thus black
           mViewPort->setBackgroundColour(  Ogre::ColourValue::Black );
          // mViewPort->setBackgroundColour(  Ogre::ColourValue::ZERO );
           ///don't show the CEGUI
           mViewPort->setOverlaysEnabled(  false );
           ///the cegui renderer wants a TexturePtr (  not a RenderTexturePtr ),   so we just ask the texturemanager for texture we just created (  rttex )
          
          
          }
          
     245  void SimpleRenderContext::setBackgroundColour(  const Ogre::ColourValue& colour )
          {
           mViewPort->setBackgroundColour(  colour );
          }
          
     250  void SimpleRenderContext::setBackgroundColour(  float red,   float green,   float blue,   float alpha )
          {
           mViewPort->setBackgroundColour(  Ogre::ColourValue(  red,   green,   blue,   alpha ) );
          }
          
          
          
     257  void SimpleRenderContext::showFull(  const Ogre::MovableObject* object )
          {
           ///only do this if there's an active object
           if (  object ) {
           mEntityNode->_update(  true,   true );
           Ogre::Real distance = object->getBoundingRadius(   ) / Ogre::Math::Tan(  mCamera->getFOVy(   ) / 2 );
           ///we can't have a distance of 0
           if (  distance == 0 ) {
           distance = 1;
           }
           Ogre::Real distanceNudge = distance / 100;
           distance += distanceNudge;
          
           mDefaultCameraDistance = distance;
          
           setCameraDistance(  distance );
           }
          
          }
          
     277  Ogre::RenderTexture* SimpleRenderContext::getRenderTexture(   )
          {
           return mRenderTexture;
          }
          
     282  Ogre::Light* SimpleRenderContext::getLight(   )
          {
           return mMainLight;
          }
          
          
          }

./components/ogre/SimpleRenderContext.h

       1  //
          // C++ Interface: SimpleRenderContext
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRESIMPLERENDERCONTEXT_H
          #define EMBEROGRESIMPLERENDERCONTEXT_H
          
          #include "EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
      30  class SimpleRenderContext;
          
          /**
          Responsible for making sure that the texture is rerendered when the texture resource needs to be reloaded.
          */
      35  class SimpleRenderContextResourceLoader : public Ogre::ManualResourceLoader
          {
          public:
           /**
           * Ctor.
           * @param renderContext The SimpleRenderContext to which this instance belongs.
           */
      42   SimpleRenderContextResourceLoader(  SimpleRenderContext& renderContext );
          
          
           /**
           * At load time the texture will be rerendered.
           * @param resource
           */
      49   virtual void loadResource (  Ogre::Resource *resource );
          protected:
      51   SimpleRenderContext& mRenderContext;
          };
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          
          Useful class for rendering a single scene node.
          
          */
      60  class SimpleRenderContext
          {
          public:
          
           /**
           * Constructor.
           * @param prefix A unique prefix for the scene manager.
           * @param width The width of the image created.
           * @param height The height of the image created.
           * @return
           */
      71   SimpleRenderContext(  const std::string& prefix,   int width,   int height );
          
      73   ~SimpleRenderContext(   );
          
           /**
           * Gets the scene node which is being rendered.
           * @return
           */
      79   Ogre::SceneNode* getSceneNode(   ) const;
          
          
           /**
           * Gets the camera used for rendering.
           * @return
           */
      86   Ogre::Camera* getCamera(   ) const;
          
           /**
           * Gets the default distance of the camera from the base,   most likely somewhere where the whole scene is shown
           * @return
           */
      92   inline Ogre::Real getDefaultCameraDistance(   ) const;
          
           /**
           * Sets whether the rendering should be active or not.
           * @param active
           */
      98   void setActive(  bool active );
          
           /**
           * Adjusts the camera distance so that the full scene is shown
           */
     103   void showFull(  const Ogre::MovableObject* object );
          
          
           /**
           * After you've changed the target of the camera,   i.e. the object attached to the base SceneNode,  
           the camera has to be repositioned. Make sure to always call this method after updating the scene.
           */
     110   void repositionCamera(   );
          
          
           /**
           * Pitches the camera.
           * @param degrees The amount of degrees to pitch.
           */
     117   void pitch(  Ogre::Degree degrees );
          
           /**
           * Yaws the camera.
           * @param degrees The amount of degree to yaw.
           */
     123   void yaw(  Ogre::Degree degrees );
          
           /**
           * Rolls the camera.
           * @param degrees The amount of degree to roll.
           */
     129   void roll(  Ogre::Degree degrees );
          
          
           /**
           * Sets the relative camera distance. Note that this is adjusted after calling repositionCamera(   ). A value of 1.0 indicates the most optimal distance for showing the complete mesh.
           * @param distance
           */
     136   void setCameraDistance(  Ogre::Real distance );
          
          
           /**
           * Gets the relative distance. 1.0 being the most optimal distance for showing the complete mesh.
           * @return
           */
     143   float getCameraDistance(   ) const;
          
           /**
           * Sets the absolute distance of the camera.
           * @param distance
           */
          // void setCameraAbsoluteDistance(  Ogre::Real distance );
          
           /**
           * Gets the absolute distance in world units.
           * @return
           */
     155   float getAbsoluteCameraDistance(   ) const;
          
           /**
           * Gets the rotation of the entity.
           * @return
           */
     161   Ogre::Quaternion getEntityRotation(   );
          
          
           /**
           * Resets the orientation of the camera.
           */
     167   void resetCameraOrientation(   );
          
          
     170   inline Ogre::SceneManager* getSceneManager(   ) const;
          
     172   Ogre::RenderTexture* getRenderTexture(   );
          
     174   Ogre::TexturePtr getTexture(   );
          
     176   Ogre::SceneNode* getCameraRootNode(   ) const;
          
           /**
           * Gets the main light.
           * @return
           */
     182   Ogre::Light* getLight(   );
          
          
           /**
           * Sets the background colour.
           * @param colour
           */
     189   void setBackgroundColour(  const Ogre::ColourValue& colour );
           /**
           * Sets the background colour.
           * @param red
           * @param green
           * @param blue
           * @param
           */
     197   void setBackgroundColour(  float red,   float green,   float blue,   float alpha );
          
          private:
          
           /**
           Main light for the scene,   places a bit to the right
           */
     204   Ogre::Light* mMainLight;
          
           /**
           Since we don't want this to be shown in the "real" world,   we'll use our own scene manager
           */
     209   Ogre::SceneManager* mSceneManager;
          
           /**
           The default distance of the camera from the base,   most likely somewhere where the whole scene is shown
           */
     214   Ogre::Real mDefaultCameraDistance;
          
           /**
           * Creates the image and sets up the rendering.
           * @param prefix
           */
     220   void createImage(  const std::string& prefix );
          
           /**
           Width and height of the image.
           */
           int mWidth,   mHeight;
          
           /**
           The rendertexture used.
           */
     230   Ogre::RenderTexture* mRenderTexture;
          
           /**
           * Creates the ogre camera.
           * @param imageSetName
           */
     236   void createCamera(  const std::string& prefix );
          
           /**
           The node to which the camera is attached.
           */
     241   Ogre::SceneNode *mCameraNode,   *mCameraPitchNode;
          
           /**
           The node to which the rendered entities are attched.
           */
     246   Ogre::SceneNode* mEntityNode;
          
           /**
           The root node.
           */
     251   Ogre::SceneNode* mRootNode;
          
           /**
           The camera used.
           */
     256   Ogre::Camera* mCamera;
          
     258   Ogre::TexturePtr mTexture;
          
     260   Ogre::Viewport* mViewPort;
          
     262   SimpleRenderContextResourceLoader mResourceLoader;
          
          };
          
     266  Ogre::Real SimpleRenderContext::getDefaultCameraDistance(   ) const
          {
           return mDefaultCameraDistance;
          }
          
     271  Ogre::SceneManager* SimpleRenderContext::getSceneManager(   ) const
          {
           return mSceneManager;
          }
          
          }
          
          #endif

./components/ogre/WorldEmberEntity.cpp

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          
          
          
          #include "EmberEntity.h"
          #include "model/Model.h"
          #include "terrain/TerrainGenerator.h"
          #include "terrain/TerrainShader.h"
          #include "terrain/TerrainLayerDefinition.h"
          #include "terrain/TerrainLayerDefinitionManager.h"
          #include "WorldEmberEntity.h"
          #include "environment/Foliage.h"
          #include "environment/Environment.h"
          #include "environment/CaelumEnvironment.h"
          #include "EmberOgre.h"
          #include "Avatar.h"
          #include "AvatarCamera.h"
          
          //#include "components/ogre/EmberSceneManager/include/EmberTerrainSceneManager.h"
          #include <Mercator/Area.h>
          #include <Mercator/FillShader.h>
          #include <Mercator/ThresholdShader.h>
          #include <Mercator/DepthShader.h>
          #include <Mercator/GrassShader.h>
          #include <Mercator/ShaderFactory.h>
          
          namespace EmberOgre {
      47  WorldEmberEntity::WorldEmberEntity(  const std::string& id,   Eris::TypeInfo* ty,   Eris::View* vw,   Ogre::SceneManager* sceneManager,   Terrain::TerrainGenerator* terrainGenerator ) :
          EmberEntity(  id,   ty,   vw,   sceneManager )
          ,   mTerrainGenerator(  terrainGenerator )
          ,   mFoliage(  0 )
          ,   mEnvironment(  0 )
          {
           sceneManager->getRootSceneNode(   )->addChild(  getSceneNode(   ) );
          }
          
      56  WorldEmberEntity::~WorldEmberEntity(   )
          {
           delete mFoliage;
           delete mEnvironment;
          }
          
      62  void WorldEmberEntity::init(  const Atlas::Objects::Entity::RootEntity &ge,   bool fromCreateOp )
          {
          
           ///create the foliage
           mFoliage = new Environment::Foliage(  EmberOgre::getSingleton(   ).getSceneManager(   ) );
          
           EmberEntity::init(  ge,   fromCreateOp );
          
           ///set the position to always 0,   0,   0
           mOgreNode->setPosition(  Ogre::Vector3(  0,   0,   0 ) );
          
           mEnvironment = new Environment::Environment(  new Environment::CaelumEnvironment(   EmberOgre::getSingleton(   ).getSceneManager(   ),   EmberOgre::getSingleton(   ).getRenderWindow(   ),   EmberOgre::getSingleton(   ).getMainCamera(   )->getCamera(   ) ) );
           mEnvironment->initialize(   );
          
          
           mTerrainParser = std::auto_ptr<TerrainParser>(  new TerrainParser(  mTerrainGenerator ) );
          
          
           bool hasValidShaders = false;
           if (  hasAttr(  "terrain" ) ) {
           const Atlas::Message::Element& terrainElement = valueOfAttr(  "terrain" );
           if (  terrainElement.isMap(   ) ) {
           const Atlas::Message::MapType& terrainMap(  terrainElement.asMap(   ) );
           if (  terrainMap.count(  "surfaces" ) ) {
           const Atlas::Message::Element& surfaceElement(  terrainMap.find(  "surfaces" )->second );
           mTerrainParser->createShaders(  surfaceElement );
           hasValidShaders = true;
           }
           }
           if (  !hasValidShaders ) {
           mTerrainParser->createDefaultShaders(   );
           hasValidShaders = true;
           }
           mTerrainParser->updateTerrain(  terrainElement );
           }
           if (  !hasValidShaders ) {
           mTerrainParser->createDefaultShaders(   );
           hasValidShaders = true;
           }
          
          
          
           ///prepare all the segments in advance
           mTerrainGenerator->prepareAllSegments(   );
           //mTerrainGenerator->prepareSegments(  0,  0,  1,  true );
          
           mFoliage->createGrass(   );
          
          
          }
          
     113  void WorldEmberEntity::onAttrChanged(  const std::string& str,   const Atlas::Message::Element& v )
          {
           ///check for terrain updates
           if (  str == "terrain" ) {
           if (  mTerrainParser.get(   ) ) {
           mTerrainParser->updateTerrain(  v );
           }
           }
           Entity::onAttrChanged(  str,   v );
          }
          
     124  TerrainParser::TerrainParser(  Terrain::TerrainGenerator* terrainGenerator )
          : mTerrainGenerator(  terrainGenerator )
          {
          }
          
          
     130  void TerrainParser::updateTerrain(  const Atlas::Message::Element& terrain )
          {
           //_fpreset(   );
           if (  !terrain.isMap(   ) ) {
           S_LOG_FAILURE(   "Terrain is not a map"  );
           }
           const Atlas::Message::MapType & tmap = terrain.asMap(   );
           Atlas::Message::MapType::const_iterator I = tmap.find(  "points" );
          // int xmin = 0,   xmax = 0,   ymin = 0,   ymax = 0;
           if (  I == tmap.end(   ) ) {
           S_LOG_FAILURE(   "No terrain points"  );
           }
          
           Terrain::TerrainGenerator::TerrainDefPointStore pointStore;
           if (  I->second.isList(   ) ) {
           // Legacy support for old list format.
           const Atlas::Message::ListType & plist = I->second.asList(   );
           Atlas::Message::ListType::const_iterator J = plist.begin(   );
           for(  ; J != plist.end(   ); ++J ) {
           if (  !J->isList(   ) ) {
           S_LOG_INFO(   "Non list in points"  );
           continue;
           }
           const Atlas::Message::ListType & point = J->asList(   );
           if (  point.size(   ) != 3 ) {
           S_LOG_INFO(   "point without 3 nums"  );
           continue;
           }
           //int x = (  int )point[0].asNum(   );
           //int y = (  int )point[1].asNum(   );
          
           Terrain::TerrainDefPoint defPoint(  (  int )point[0].asNum(   ),  (  int )point[1].asNum(   ),  (  int )point[3].asNum(   ) );
           pointStore.push_back(  defPoint );
           //mTerrain->setBasePoint(  x,  y,  point[2].asNum(   ) );
           }
           } else if (  I->second.isMap(   ) ) {
          
           const Atlas::Message::MapType & plist = I->second.asMap(   );
           Atlas::Message::MapType::const_iterator J = plist.begin(   );
           for(  ; J != plist.end(   ); ++J ) {
           if (  !J->second.isList(   ) ) {
           S_LOG_INFO(   "Non list in points"  );
           continue;
           }
           const Atlas::Message::ListType & point = J->second.asList(   );
           if (  point.size(   ) != 3 ) {
           S_LOG_INFO(   "point without 3 nums"  );
           continue;
           }
           int x = (  int )point[0].asNum(   );
           int y = (  int )point[1].asNum(   );
           float z = point[2].asNum(   );
           Terrain::TerrainDefPoint defPoint(  x,  y,  z );
           pointStore.push_back(  defPoint );
          
          
          
          /* Mercator::BasePoint bp;
           if (  mTerrain->getBasePoint(  x,   y,   bp ) && (  z == bp.height(   ) ) ) {
           S_LOG_INFO(   "Point [" << x << ",  " << y << " unchanged" );
           continue;
           }
           xmin = std::min(  xmin,   x );
           xmax = std::max(  xmax,   x );
           ymin = std::min(  ymin,   y );
           ymax = std::max(  ymax,   y );
           bp.height(   ) = z;
           // FIXME Sort out roughness and falloff,   and generally
           // verify this code is the same as that in Terrain layer
           mTerrain->setBasePoint(  x,   y,   bp );*/
          
           }
          
          
          /* const Atlas::Message::MapType & plist = I->second.asMap(   );
           Atlas::Message::MapType::const_iterator J = plist.begin(   );
           for(  ; J != plist.end(   ); ++J ) {
           if (  !J->second.isList(   ) ) {
           std::cout << "Non list in points" << std::endl << std::flush;
           continue;
           }
           const Atlas::Message::ListType & point = J->second.asList(   );
           if (  point.size(   ) != 3 ) {
           std::cout << "point without 3 nums" << std::endl << std::flush;
           continue;
           }
           int x = (  int )point[0].asNum(   );
           int y = (  int )point[1].asNum(   );
           xmin = std::min(  xmin,   x );
           xmax = std::max(  xmax,   x );
           ymin = std::min(  ymin,   y );
           ymax = std::max(  ymax,   y );
           // m_terrain.setBasePoint(  x,   y,   point[2].asNum(   ) );
           mTerrain->setBasePoint(  x,  y,  point[2].asNum(   ) );
          //System::instance(   )->getGraphics(   )->getTerrainRenderer(   )->m_terrain.setBasePoint(  x,  y,  point[2].asNum(   ) );
          //System::Instance(   )->getGraphics(  x,  y,  point[2].asNum(   ) );
           }*/
          
          
          
           } else {
           S_LOG_FAILURE(   "Terrain is the wrong type"  );
           return;
           }
           mTerrainGenerator->updateTerrain(  pointStore );
          }
          
     237  float extractFloat(  const Atlas::Message::ListType& params,   size_t position ) {
           if (  params.size(   ) > position ) {
           const Atlas::Message::Element& elem(  params[position] );
           if (  elem.isNum(   ) ) {
           return elem.asNum(   );
           }
           }
           return 0;
          }
          
     247  void TerrainParser::createShaders(  const Atlas::Message::Element& surfaces )
          {
          
          
           Terrain::TerrainLayerDefinitionManager& terrainManager = Terrain::TerrainLayerDefinitionManager::getSingleton(   );
          // Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
           bool isValid = false;
           if (  surfaces.isList(   ) ) {
           const Atlas::Message::ListType & slist(  surfaces.asList(   ) );
           for(  Atlas::Message::ListType::const_iterator I = slist.begin(   ); I != slist.end(   ); ++I ) {
           if (  I->isMap(   ) ) {
           std::string name;
           std::string pattern;
           const Atlas::Message::MapType& surfaceMap(  I->asMap(   ) );
           Mercator::Shader::Parameters params;
           if (  surfaceMap.count(  "params" ) ) {
           const Atlas::Message::Element& paramsElem(  surfaceMap.find(  "params" )->second );
           if (  paramsElem.isMap(   ) ) {
           for (  Atlas::Message::MapType::const_iterator J = paramsElem.asMap(   ).begin(   ); J != paramsElem.asMap(   ).end(   ); ++J ) {
           if (  J->second.isNum(   ) ) {
           params[J->first] = J->second.asNum(   );
           }
           }
           }
           }
          
           if (  surfaceMap.count(  "name" ) ) {
           const Atlas::Message::Element& nameElem(  surfaceMap.find(  "name" )->second );
           if (  nameElem.isString(   ) ) {
           const std::string& name = nameElem.asString(   );
           ///hack to remove the snow shader
          /* if (  name == "snow" ) {
           continue;
           }*/
           Terrain::TerrainLayerDefinition* def(  terrainManager.getDefinitionForShader(  name ) );
           if (  def ) {
           if (  surfaceMap.count(  "pattern" ) ) {
           const Atlas::Message::Element& patternElem(  surfaceMap.find(  "pattern" )->second );
           if (  patternElem.isString(   ) ) {
           const std::string& pattern = patternElem.asString(   );
           Mercator::Shader* shader = Mercator::ShaderFactories::instance(   ).newShader(  pattern,   params );
           if (  shader ) {
           isValid = true;
           Terrain::TerrainShader* terrainShader = mTerrainGenerator->createShader(  def,   shader );
           if (  name == "grass" ) {
           mTerrainGenerator->setFoliageShader(  terrainShader );
           }
           }
           }
           }
           }
           }
           }
           }
           }
           }
           if (  !isValid ) {
           createDefaultShaders(   );
           }
          }
          
     308  void TerrainParser::createDefaultShaders(   )
          {
           Terrain::TerrainLayerDefinitionManager& terrainManager = Terrain::TerrainLayerDefinitionManager::getSingleton(   );
           Terrain::TerrainLayerDefinition* def(  0 );
           if (  (  def = terrainManager.getDefinitionForShader(  "rock" ) ) ) {
           mTerrainGenerator->createShader(  def,   new Mercator::FillShader(   ) );
           }
           if (  (  def = terrainManager.getDefinitionForShader(  "sand" ) ) ) {
           mTerrainGenerator->createShader(  def,   new Mercator::BandShader(  -2.f,   1.5f ) );
           }
          
           if (  (  def = terrainManager.getDefinitionForShader(  "grass" ) ) ) {
           Terrain::TerrainShader* grassShader = mTerrainGenerator->createShader(  def,   new Mercator::GrassShader(  1.f,   80.f,   .5f,   1.f ) );
           mTerrainGenerator->setFoliageShader(  grassShader );
           }
          
          // createShader(  std::string(  configSrv->getValue(  "shadertextures",   "snow" ) ),   new Mercator::HighShader(  110.f ) ); // Snow
          // createShader(  std::string(  configSrv->getValue(  "shadertextures",   "seabottom" ) ),   new Mercator::DepthShader(  0.f,   -10.f ) ); // Underwater
          
          
          // this->addShader(  new TerrainShader(  std::string(  configSrv->getVariable(  "Shadertextures",   "grass" ) ),   new Mercator::GrassShader(  1.f,   80.f,   .5f,   1.f ) ) ); // Grass
          
          
          }
          
          
     334  void WorldEmberEntity::adjustPositionForContainedNode(  EmberEntity* const entity,   const Ogre::Vector3& position )
          {
           Ogre::SceneNode* sceneNode = entity->getSceneNode(   );
          
           if (  entity->getMovementMode(   ) == EmberEntity::MM_FLOATING ) {
           sceneNode->setPosition(  position.x,   0,  position.z );
           } else if (  entity->getMovementMode(   ) == EmberEntity::MM_SWIMMING ) {
           ///if it's swimming,   make sure that it's between the sea bottom and the surface
           const TerrainPosition pos = Ogre2Atlas_TerrainPosition(  position );
           float height = mTerrainGenerator->getHeight(  pos );
           if (  position.y < height ) {
           sceneNode->setPosition(  position.x,   height,  position.z );
           } else if (  position.y > 0 ) {
           sceneNode->setPosition(  position.x,   0,  position.z );
           }
          
           } else {
           ///get the height from Mercator through the TerrainGenerator
          /* assert(  mTerrainGenerator );
          // TerrainPosition pos(  entity->getPredictedPos(   ).x(   ),   entity->getPredictedPos(   ).y(   ) );
           TerrainPosition pos = Ogre2Atlas_TerrainPosition(  position );
           float height = mTerrainGenerator->getHeight(  pos );*/
           EmberEntity::adjustPositionForContainedNode(  entity,   position );
           //sceneNode->setPosition(  getOffsetForContainedNode(  position,   entity ) );
           }
          
          }
          
     362  const Ogre::Vector3& WorldEmberEntity::getOffsetForContainedNode(  const Ogre::Vector3& localPosition,   EmberEntity* const entity )
          {
           assert(  mTerrainGenerator );
           ///NOTE: won't work with threading!
           static Ogre::Vector3 offset = Ogre::Vector3::ZERO;
           float height = mTerrainGenerator->getHeight(  Ogre2Atlas_TerrainPosition(  localPosition ) );
           offset.y = height - localPosition.y;
           return offset;
           //return mTerrainGenerator->getHeight(  position );
          
          }
          
          
     375   void WorldEmberEntity::onMoved(   ){
           Eris::Entity::onMoved(   );
           }
          // void WorldEmberEntity::onTalk(  const Atlas::Objects::Operation::RootOperation& talk )
          // {
          // Eris::Entity::onTalk(  talk );
          // }
          // virtual void setContainer(  Entity *pr );
     383   void WorldEmberEntity::onVisibilityChanged(  bool vis )
           {
           Eris::Entity::onVisibilityChanged(  vis );
           }
     387   void WorldEmberEntity::onLocationChanged(  Eris::Entity *oldLocation )
           {
           Eris::Entity::onLocationChanged(  oldLocation );
           }
          
     392  void WorldEmberEntity::addArea(  Terrain::TerrainArea* area )
          {
           mTerrainGenerator->addArea(  area );
          }
          
     397  Environment::Environment* WorldEmberEntity::getEnvironment(   )
          {
           return mEnvironment;
          }
          
          
          
          }

./components/ogre/WorldEmberEntity.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef WORLDDIMEENTITY_H
          #define WORLDDIMEENTITY_H
          
          
          namespace EmberOgre {
          
          namespace Environment {
      26  class Environment;
      27  class Foliage;
          }
          
          namespace Terrain {
      31  class TerrainGenerator;
      32  class TerrainArea;
          }
          
      35  class TerrainParser
          {
          public:
           TerrainParser(  Terrain::TerrainGenerator* terrainGenerator );
          
           /**
           * Extracts terrain updates from the element and updates the terrain.
           * @param v
           */
           void updateTerrain(  const Atlas::Message::Element& terrain );
          
           void createShaders(  const Atlas::Message::Element& surfaces );
           void createDefaultShaders(   );
          
          private:
           Terrain::TerrainGenerator* mTerrainGenerator;
          };
          
      53  class EmberEntity;
          
          
      56  class WorldEmberEntity : public EmberEntity {
          public:
          
          
      60   WorldEmberEntity(  const std::string& id,   Eris::TypeInfo* ty,   Eris::View* vw,   Ogre::SceneManager* sceneManager,   Terrain::TerrainGenerator* terrainGenerator );
      61   virtual ~WorldEmberEntity(   );
          
      63   virtual void adjustPositionForContainedNode(  EmberEntity* const entity,   const Ogre::Vector3& position );
          
      65   Environment::Environment* getEnvironment(   );
          
          protected:
      68   virtual const Ogre::Vector3& getOffsetForContainedNode(  const Ogre::Vector3& position,   EmberEntity* const entity );
      69   Terrain::TerrainGenerator* mTerrainGenerator;
          
      71   virtual void init(  const Atlas::Objects::Entity::RootEntity &ge,   bool fromCreateOp );
          
      73   virtual void onMoved(   );
          
      75   virtual void onAttrChanged(  const std::string& str,   const Atlas::Message::Element& v );
          
          // virtual void onTalk(  const Atlas::Objects::Operation::RootOperation& talk );
          // virtual void setContainer(  Entity *pr );
      79   virtual void onVisibilityChanged(  bool vis );
      80   virtual void onLocationChanged(  Eris::Entity *oldLocation );
          
      82   void addArea(  Terrain::TerrainArea* area );
          
      84   Environment::Foliage* mFoliage;
          
      86   Environment::Environment* mEnvironment;
          
      88   std::auto_ptr<TerrainParser> mTerrainParser;
          };
          
          }
          
          #endif // WORLDDIMEENTITY_H

./components/ogre/XMLHelper.cpp

       1  //
          // C++ Implementation: XMLHelper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "XMLHelper.h"
          
          namespace EmberOgre {
          
      27  XMLHelper::XMLHelper(   )
          {
          }
          
          
      32  XMLHelper::~XMLHelper(   )
          {
          }
          
      36  bool XMLHelper::Load(  Ember::TiXmlDocument& xmlDoc,   Ogre::DataStreamPtr stream )
          {
           size_t length(  stream->size(   ) );
          
           if (   length  )
           {
           // If we have a file,   assume it is all one big XML file,   and read it in.
           // The document parser may decide the document ends sooner than the entire file,   however.
           std::string data;
           data.reserve(   length  );
          
           char *buf = new char[length];
          
           while(   stream->read(   buf,   length  )  )
           {
           //got segfaults when doing "data += buf;",   so switched to this
           data.append(  buf,   length );
           }
           delete[] buf;
          
           xmlDoc.Parse(   data.c_str(   ) );
          
           if (  xmlDoc.Error(   )  ) {
           std::string errorDesc = xmlDoc.ErrorDesc(   );
           int errorLine = xmlDoc.ErrorRow(   );
           int errorColumn = xmlDoc.ErrorCol(   );
           std::stringstream ss;
           ss << "Failed to load xml file '" << stream->getName(   ) << "'! Error at column: " << errorColumn << " line: " << errorLine << ". Error message: " << errorDesc;
           S_LOG_FAILURE(  ss.str(   ) );
           return false;
           } else {
           return true;
           }
           }
           return false;
          }
          
          }

./components/ogre/XMLHelper.h

       1  //
          // C++ Interface: XMLHelper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREXMLHELPER_H
          #define EMBEROGREXMLHELPER_H
          
          #include "EmberOgrePrerequisites.h"
          #include "framework/tinyxml/tinyxml.h"
          
          namespace EmberOgre {
          
          /**
           A simple helper class for loading tinyxml documents through the ogre resource system.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      36  class XMLHelper{
          public:
      38   XMLHelper(   );
          
      40   ~XMLHelper(   );
          
           /**
           Attempts to load the supplied stream into the document. Failures will be logged.
           @param An empty xml document.
           @param An opened and valid data stream
           @returns true if successful,   else false
           */
      48   bool Load(  Ember::TiXmlDocument& xmlDoc,   Ogre::DataStreamPtr stream );
          
          
          };
          
          }
          
          #endif

./components/ogre/carpenter/BluePrint.cpp

       1  //
          // C++ Implementation: BluePrint
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "BluePrint.h"
          
          namespace Carpenter {
          
      27  BluePrint::BluePrint(  const std::string & name,   Carpenter* carpenter )
          : mName(  name ),   mCarpenter(  carpenter )
          {
          }
          
          
          // BluePrint::~BluePrint(   )
          // {
          // }
          
      37  BuildingBlock::BuildingBlock(   )
          : mPosition(  0,  0,  0 ),   mAttached(  false ),   mChildBindings(  0 )
          
          {
          mOrientation.identity(   );
          
          }
          
      45  void BuildingBlock::removeBoundPoint(  const AttachPoint* point  )
          {
           std::vector<const AttachPoint*>::iterator pos = mBoundPoints.end(   );
           std::vector<const AttachPoint*>::iterator I = mBoundPoints.begin(   );
           std::vector<const AttachPoint*>::iterator I_end = mBoundPoints.end(   );
           for (  ; I!=I_end; ++I ) {
           if (  (  *I ) == point ) {
           pos = I;
           break;
           }
           }
           if (  pos != mBoundPoints.end(   ) ) {
           mBoundPoints.erase(  pos );
           }
          
          }
          
          
          
      64  void BluePrint::doBindingsForBlock(  BuildingBlock *block )
          {
           std::map<BuildingBlock* ,   std::vector<BuildingBlockBinding*> > relatedBindings;
          
           std::list< BuildingBlockBinding>::iterator I = mBindings.begin(   );
           std::list< BuildingBlockBinding>::iterator I_end = mBindings.end(   );
          
           for (  ;I != I_end; ++I ) {
           BuildingBlock* unboundBlock = 0;
           const AttachPair* pair = 0;
           BuildingBlock* block1 = &mBuildingBlocks.find(  (  *I ).mBlock1->getName(   ) )->second;
           BuildingBlock* block2 = &mBuildingBlocks.find(  (  *I ).mBlock2->getName(   ) )->second;
           if (  block1 == block && !block2->isAttached(   ) ) {
           unboundBlock = block2;
           pair = (  *I ).mPoint2->getAttachPair(   );
           } else if (  block2 == block && !block1->isAttached(   ) ) {
           unboundBlock = block1;
           pair = (  *I ).mPoint1->getAttachPair(   );
           }
          
           if (  unboundBlock ) {
           relatedBindings[unboundBlock].push_back(  &(  *I ) );
           if (  relatedBindings[unboundBlock].size(   ) > 1 && !unboundBlock->isAttached(   ) ) {
           placeBindings(  unboundBlock,   relatedBindings[unboundBlock] );
           doBindingsForBlock(  unboundBlock );
           }
           }
           }
          }
          
      94  bool BluePrint::isRemovable(  const BuildingBlock* bblock ) const
          {
           //cannot remove the starting block
           if (  bblock == mStartingBlock ) {
           return false;
           }
          
           //make sure the block exists in the blueprint
           if (  mBuildingBlocks.find(  bblock->getName(   ) ) == mBuildingBlocks.end(   ) ) {
           return false;
           }
          
           return bblock->mChildBindings == 0;
          /* //if the bblock has max two points attached to it it can be removed
           //HACK: here should be a better check,   some kind of graph walking
           size_t size = bblock->mBoundPoints.size(   );
           return size < 3;*/
          }
          
     113  bool BluePrint::remove(  const BuildingBlock* _bblock )
          {
           if (  !isRemovable(  _bblock ) ) {
           return false;
           }
           BuildingBlock* bblock = &mBuildingBlocks.find(  _bblock->getName(   ) )->second;
          
           std::list< BuildingBlockBinding>::iterator I = mBindings.begin(   );
           std::list< BuildingBlockBinding>::iterator I_end = mBindings.end(   );
           std::list< BuildingBlockBinding>::iterator I_remove = mBindings.end(   );
          
           for (  ; I != I_end; ++I ) {
           if (  I_remove != mBindings.end(   ) ) {
           mBindings.erase(  I_remove );
           I_remove = mBindings.end(   );
           }
          
           if (  (  *I ).getBlock1(   ) == bblock ) {
           BuildingBlock* boundBlock = &mBuildingBlocks.find(  (  *I ).mBlock2->getName(   ) )->second;
           boundBlock->removeBoundPoint(  (  *I ).getAttachPoint2(   ) );
           //decrease the number of child bindings for the parent block
           --(  boundBlock->mChildBindings );
           I_remove = I;
           } else if (  (  *I ).getBlock2(   ) == bblock ) {
           BuildingBlock* boundBlock = &mBuildingBlocks.find(  (  *I ).mBlock1->getName(   ) )->second;
           boundBlock->removeBoundPoint(  (  *I ).getAttachPoint1(   ) );
           --(  boundBlock->mChildBindings );
           I_remove = I;
           }
           }
           if (  I_remove != mBindings.end(   ) ) {
           mBindings.erase(  I_remove );
           I_remove = mBindings.end(   );
           }
          
           //check if it's in the attached blocks vector and remove it
           std::vector<BuildingBlock*>::iterator pos = mAttachedBlocks.end(   );
           std::vector<BuildingBlock*>::iterator J = mAttachedBlocks.begin(   );
           std::vector<BuildingBlock*>::iterator J_end = mAttachedBlocks.end(   );
           for (  ; J!=J_end; ++J ) {
           if (  (  *J ) == bblock ) {
           pos = J;
           break;
           }
           }
           if (  pos != mAttachedBlocks.end(   ) ) {
           mAttachedBlocks.erase(  pos );
           }
          
          
           mBuildingBlocks.erase(  bblock->getName(   ) );
           return true;
          
          }
          
          
     169  const std::string& BuildingBlockBinding::getType(   ) const
          {
           return mPoint1->getAttachPair(   )->getType(   );
          }
          
          
     175  const AttachPair* BuildingBlock::getAttachPair(  const std::string& name )
          {
           const BlockSpec* spec = mBuildingBlockSpec->getBlockSpec(   );
           return spec->getAttachPair(  name );
          
          }
          
     182  void BluePrint::compile(   )
          {
          
           mAttachedBlocks.clear(   );
          
           BuildingBlock* baseBlock = mStartingBlock;
           mStartingBlock->mAttached = true;
           mAttachedBlocks.push_back(  mStartingBlock );
           doBindingsForBlock(  mStartingBlock );
          
          // std::vector< BuildingBlockBinding>::iterator I = mBindings.begin(   );
          // std::vector< BuildingBlockBinding>::iterator I_end = mBindings.end(   );
          //
          // baseBlock = (  *I ).mBlock1;
          // baseBlock->mPosition = WFMath::Point<3>(  0,  0,  0 );
          // baseBlock->mRotation.identity(   );
          //
          // int bound = 0;
          //
          // placeBinding(  &(  *I ) );
          // ++bound;
          //
          // int boundBeforeIteration = bound;
          // bool doContinue;
          //
          // while (  doContinue ) {
          // for (  ;I != I_end; ++I ) {
          // if (  (  *I ).mBlock1->isAttached(   ) ) {
          // placeBinding(  &(  *I ) );
          // ++bound;
          // }
          //
          // }
          // if (  bound > boundBeforeIteration ) {
          // doContinue = true;
          // } else {
          // doContinue = false;
          // }
          // }
          
           //now iterate over them all and create the SceneNodes
           //TODO: move this to another class
          
          
          
          }
          
     229  const std::vector< BuildingBlock*> BluePrint::getAttachedBlocks(   ) const
          {
           return mAttachedBlocks;
          }
          
     234  const std::list< BuildingBlockBinding>* BluePrint::getBindings(   ) const
          {
           return &mBindings;
          }
          
          
          // void BluePrint::deleteBuildingBlock(  const std::string & name )
          // {
          // mBuildingBlocks.erase(  name );
          // }
          
     245  BuildingBlock* BluePrint::createBuildingBlock(  BuildingBlockDefinition definition )
          {
          
           mBuildingBlocks[definition.mName];
           BuildingBlockSpec *buildingBlockSpec = mCarpenter->getBuildingBlockSpec(  definition.mBuildingBlockSpec );
           assert(  buildingBlockSpec );
           mBuildingBlocks[definition.mName].mBlockDefinition = definition;
           mBuildingBlocks[definition.mName].mBuildingBlockSpec = buildingBlockSpec;
           return &mBuildingBlocks[definition.mName];
          
          }
          
     257  void BluePrint::setStartingBlock(  const std::string& name )
          {
           mStartingBlock = &mBuildingBlocks.find(  name )->second;
           mStartingBlock->mAttached = true;
          }
          
     263  WFMath::Point<3> BuildingBlock::getWorldPositionForPoint(  const AttachPoint* point )
          {
           WFMath::Vector<3> worldPoint = point->getPosition(   ) - WFMath::Point<3>(  0,  0,  0 );
           worldPoint.rotate(  mOrientation );
           return mPosition + worldPoint;
          }
          
          
     271  BuildingBlockBinding* BluePrint::addBinding(  BuildingBlockBindingDefinition definition )
          {
           //BuildingBlockBinding binding;
          // binding.mDefinition = definition;
          
           BuildingBlock* block1 = &mBuildingBlocks[definition.mBlock1Name];
           BuildingBlock* block2 = &mBuildingBlocks[definition.mBlock2Name];
          
           if (  !block1 || !block2 )
           return 0;
          
           const AttachPair *pair1 = block1->getAttachPair(  definition.mPair1Name );
           const AttachPair *pair2 = block2->getAttachPair(  definition.mPair2Name );
           if (  !pair1 || !pair2 ) return 0;
          
           const AttachPoint* point1 = pair1->getAttachPoint(  definition.mPoint1Name );
           const AttachPoint* point2 = pair2->getAttachPoint(  definition.mPoint2Name );
           if (  !point1 || !point2 ) return 0;
          
           return addBinding(  block1,   point1,   block2,   point2 );
          }
          
     293  BuildingBlockBinding* BluePrint::addBinding(  const BuildingBlock* block1,   const AttachPoint* point1,   const BuildingBlock* block2,   const AttachPoint* point2 )
          {
           BuildingBlockBinding binding(  block1,   point1,   block2,   point2 );
          
           mBindings.push_back(  binding );
           return &mBindings.back(   );
          
          }
          
     302  void BluePrint::placeBindings(  BuildingBlock* unboundBlock,   std::vector<BuildingBlockBinding*> bindings )
          {
          
           //we place each unvound block through
           //1 ) first rotate it so the vector of the two unbound points matches that of the vector of the two bound points
           //2 ) then we rotate the unbound block along this vector so the normals of the attach points of the unbound block matches the inverse of the normals of the attach points of the bound block
          
          
           std::vector<BuildingBlockBinding*>::iterator I = bindings.begin(   );
           BuildingBlockBinding* binding1 = *I;
           BuildingBlockBinding* binding2 = *(  ++I );
          
           BuildingBlock * boundBlock,   *boundBlock_2;
          
           const AttachPoint* boundPoint1;
           const AttachPoint* boundPoint2;
           const AttachPoint* unboundPoint1;
           const AttachPoint* unboundPoint2;
          
           //find out which block is unbound
           if (  binding1->mBlock1->isAttached(   ) ) {
           boundBlock = &mBuildingBlocks.find(  binding1->mBlock1->getName(   ) )->second;
           boundPoint1 = binding1->mPoint1;
           unboundPoint1 = binding1->mPoint2;
           } else {
           boundBlock = &mBuildingBlocks.find(  binding1->mBlock2->getName(   ) )->second;
           boundPoint1 = binding1->mPoint2;
           unboundPoint1 = binding1->mPoint1;
           }
          
           //find out which block is unbound
           if (  binding2->mBlock1->isAttached(   ) ) {
           boundBlock_2 = &mBuildingBlocks.find(  binding2->mBlock1->getName(   ) )->second;
           boundPoint2 = binding2->mPoint1;
           unboundPoint2 = binding2->mPoint2;
           } else {
           boundBlock_2 = &mBuildingBlocks.find(  binding2->mBlock2->getName(   ) )->second;
           boundPoint2 = binding2->mPoint2;
           unboundPoint2 = binding2->mPoint1;
           }
          
           WFMath::Vector<3> boundPointNormal = boundPoint1->getPosition(   ) - boundPoint2->getPosition(   );
           boundPointNormal.rotate(  boundBlock->getOrientation(   ) );
           boundPointNormal.normalize(   );
           WFMath::Vector<3> unboundPointNormal = unboundPoint1->getPosition(   ) - unboundPoint2->getPosition(   );
           unboundPointNormal.normalize(   );
          
           //we need the quaternion needed to rotate unboundPointNormal (  and thus the whole unboundBlock ) to point in the same direction as boundPointNormal
           WFMath::Quaternion neededRotation;
           neededRotation.identity(   );
           try {
           neededRotation.rotation(  unboundPointNormal,   boundPointNormal );
           } catch (  const WFMath::ColinearVectors<3> & ) {
           //colinear eh? we need to flip the block
          
           //use one of the point normals for flipping
           WFMath::Vector<3> flipVector = unboundPoint1->getNormal(   );
           neededRotation = WFMath::Quaternion(  flipVector,   WFMath::Pi  );
          
           }
          
           //do the first rotation
           unboundBlock->setOrientation(  unboundBlock->getOrientation(   ) * neededRotation );
          
           //now we must rotate around the unboundPointNormal so the normals of the point line up (  i.e. the normal of an unbound point should be the inverse of a normal of a bound point )
           WFMath::Vector<3> worldNormalOfBoundPoint1 = boundPoint1->getNormal(   );
           worldNormalOfBoundPoint1.rotate(  boundBlock->getOrientation(   ) );
          
           WFMath::Vector<3> worldNormalOfUnboundPoint1 = unboundPoint1->getNormal(   );
           worldNormalOfUnboundPoint1.rotate(  unboundBlock->getOrientation(   ) );
           try {
           //rotate through the normals of the points
           neededRotation.rotation(  -worldNormalOfBoundPoint1,   worldNormalOfUnboundPoint1 );
           //neededRotation.inverse(   );
          
          
           } catch (  const WFMath::ColinearVectors<3> & )
           {
           //colinear eh? we need to flip the block
          
           //use one of the point normals for flipping
           WFMath::Vector<3> flipVector = unboundPoint1->getPosition(   ) - unboundPoint2->getPosition(   );
           flipVector.rotate(  unboundBlock->getOrientation(   ) );
           flipVector.normalize(   );
           neededRotation = WFMath::Quaternion(  flipVector,   WFMath::Pi  );
           }
           //do the second rotation
           unboundBlock->setOrientation(  unboundBlock->getOrientation(   ) * neededRotation.inverse(   ) );
          
          
           unboundBlock->mAttached = true;
           mAttachedBlocks.push_back(  unboundBlock );
          
           //we now have to position the block
           WFMath::Vector<3> distance = boundBlock->getWorldPositionForPoint(  boundPoint1 ) - unboundBlock->getWorldPositionForPoint(  unboundPoint1 );
           unboundBlock->mPosition = unboundBlock->mPosition + distance;
          
          
           unboundBlock->mBoundPoints.push_back(  unboundPoint1 );
           unboundBlock->mBoundPoints.push_back(  unboundPoint2 );
           boundBlock->mBoundPoints.push_back(  boundPoint1 );
           boundBlock_2->mBoundPoints.push_back(  boundPoint2 );
          
           //increase the number of child bindings for the bound blocks (  which should be the same block in most cases )
           ++(  boundBlock->mChildBindings );
           ++(  boundBlock_2->mChildBindings );
          
          
          
          
          }
          
     414  const std::vector< const AttachPoint * > BuildingBlock::getAllPoints(    ) const
          {
           return getBlockSpec(   )->getAllPoints(   );
          }
          
     419  BuildingBlockBinding::BuildingBlockBinding(   const BuildingBlock * block1,   const AttachPoint * point1,   const BuildingBlock * block2,   const AttachPoint * point2 )
          : mBlock1(  block1 ),   mPoint1(  point1 ),   mBlock2(  block2 ),   mPoint2(  point2 )
          {
          }
          
          };
          
          
          

./components/ogre/carpenter/BluePrint.h

          //
          // C++ Interface: BluePrint
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef CARPENTERBLUEPRINT_H
          #define CARPENTERBLUEPRINT_H
          // ------------------------------
          // Include WFmath header files
          // ------------------------------
          #include <wfmath/point.h>
          #include <wfmath/vector.h>
          #include <wfmath/axisbox.h>
          #include <wfmath/quaternion.h>
          
          #include "Carpenter.h"
          
          namespace Carpenter {
          
      37  class AttachPair;
      38  class AttachPoint;
      39  class BlockSpec;
      40  class BuildingBlock;
      41  class BuildingBlockSpec;
      42  class BuildingBlockSpecDefinition;
      43  class BuildingBlockBinding;
      44  class BuildingBlockBindingDefinition;
      45  class BuildingBlockDefinition;
      46  class BluePrint;
      47  class Carpenter;
          
          /**
          @author Erik Hjortsberg
          */
          
          
          
      55  class BuildingBlockBindingDefinition
          {
          public:
      58   BuildingBlockBindingDefinition(   ) {}
      59   std::string mBlock1Name;
      60   std::string mBlock2Name;
      61   std::string mPair1Name;
      62   std::string mPair2Name;
      63   std::string mPoint1Name;
      64   std::string mPoint2Name;
          };
          
      67  class BuildingBlockBinding
          {
      69  friend class BluePrint;
          public:
      71   BuildingBlockBinding(  const BuildingBlock* block1,   const AttachPoint* point1,   const BuildingBlock* block2,   const AttachPoint* point2 );
      72   const std::string& getType(   ) const;
      73   const BuildingBlock* getBlock1(   ) const { return mBlock1; }
      74   const BuildingBlock* getBlock2(   ) const { return mBlock2; }
      75   const AttachPoint* getAttachPoint1(   ) const { return mPoint1; }
      76   const AttachPoint* getAttachPoint2(   ) const { return mPoint2; }
          
          
          protected:
      80   const BuildingBlock* mBlock1;
      81   const AttachPoint* mPoint1;
      82   const BuildingBlock* mBlock2;
      83   const AttachPoint* mPoint2;
          };
          
          
          
          
          
          
          
          
          
      94  class BuildingBlockDefinition
          {
          public:
      97   BuildingBlockDefinition(   ) {}
      98   std::string mName;
      99   std::string mBuildingBlockSpec;
          };
          
     102  class BuildingBlock
          {
     104  friend class BluePrint;
          public:
     106   BuildingBlock(   );
     107   const std::vector<BuildingBlockBinding*> getBindingsForBlock(   ) const;
     108   const AttachPair* getAttachPair(  const std::string& name );
     109   const std::string& getName(   ) const { return mBlockDefinition.mName; }
          
          
     112   WFMath::Point<3> getWorldPositionForPoint(  const AttachPoint* point );
     113   inline bool isAttached(   ) const { return mAttached; }
          
          
          
     117   inline void setPosition(  WFMath::Point<3> position ) { mPosition = position;}
     118   inline void setOrientation(  WFMath::Quaternion orientation ) { mOrientation = orientation;}
     119   inline const WFMath::Point<3>& getPosition(   ) const { return mPosition;}
     120   inline const WFMath::Quaternion& getOrientation(   ) const { return mOrientation;}
          
     122   inline const BuildingBlockSpec* getBuildingBlockSpec(   ) const { return mBuildingBlockSpec; }
          
     124   inline const BlockSpec* getBlockSpec(   ) const { return mBuildingBlockSpec->getBlockSpec(   ); }
          
     126   const std::vector<const AttachPoint*> getAllPoints(   ) const;
          
           /**
           * the number of bindings that are dependant on this block
           as long as it's more than zero,   the block cannot be deleted
           * @return
           */
     133   inline int getNumberOfChildBindings(   ) const { return mChildBindings; }
          
          protected:
           //ModelBlock mModelBlock;
     137   BuildingBlockSpec* mBuildingBlockSpec;
     138   BuildingBlockDefinition mBlockDefinition;
     139   WFMath::Point<3> mPosition;
     140   WFMath::Quaternion mOrientation;
     141   bool mAttached;
           /**
           A vector of all points that are already bound
           */
     145   std::vector<const AttachPoint*> mBoundPoints;
          
           /**
           * removes a point from the list of bound points
           * @param point
           */
     151   void removeBoundPoint(  const AttachPoint* point );
          
           /**
           the number of bindings that are dependant on this block
           as long as it's more than zero,   the block cannot be deleted
           */
           int mChildBindings;
          
          };
          
          
          
          
          
          
          
     167  class BluePrint
          {
          public:
     170   BluePrint(  const std::string & name,   Carpenter* carpenter );
          
     172   inline const std::string& getName(   ) const {return mName;}
          
           /**
           * compiles the blueprint into a structure
           */
     177   void compile(   );
          
     179   BuildingBlock* createBuildingBlock(  BuildingBlockDefinition );
          
           /**
           * deletes a building block from the blueprint
           * @param name
           */
          // void deleteBuildingBlock(  const std::string & name );
          
     187   BuildingBlockBinding* addBinding(  BuildingBlockBindingDefinition definition );
     188   BuildingBlockBinding* addBinding(  const BuildingBlock* block1,   const AttachPoint* point1,   const BuildingBlock* block2,   const AttachPoint* point2 );
     189   const std::vector< BuildingBlock*> getAttachedBlocks(   ) const;
     190   const std::list< BuildingBlockBinding>* getBindings(   ) const;
          
           /**
           * accessor for the name of the starting block
           * @param name
           */
     196   void setStartingBlock(  const std::string& name );
     197   inline const BuildingBlock* getStartingBlock(   ) const {return mStartingBlock;}
          
           /**
           * Places the unbound block in the supplied bindings correctly
           * @param binding
           */
     203   void placeBindings(  BuildingBlock* unboundBlock,   std::vector<BuildingBlockBinding*> bindings );
          
           inline Carpenter* const getCarpenter(   ) { return mCarpenter;}
          
          
           /**
           * true if the building block can be removed from the blueprint
           * @param
           * @return
           */
           bool isRemovable(  const BuildingBlock* bblock ) const;
          
           /**
           * removes the building block from the blueprint,   if it can be removed
           * @param bblock
           * @return
           */
     220   bool remove(  const BuildingBlock* bblock );
          
           typedef std::map<const std::string,   BuildingBlock> BuildingBlockStore;
          protected:
           BuildingBlockStore mBuildingBlocks;
           std::list< BuildingBlockBinding> mBindings;
          
           std::vector< BuildingBlock*> mAttachedBlocks;
           BuildingBlock* mStartingBlock;
           std::string mName;
          
           Carpenter* mCarpenter;
          
          
     234   void doBindingsForBlock(  BuildingBlock *block );
          
          };
          
          };
          
          #endif

./components/ogre/carpenter/Carpenter.cpp

       1  //
          // C++ Implementation: Carpenter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Carpenter.h"
          #include "BluePrint.h"
          
          #include <wfmath/error.h>
          
          namespace Carpenter {
          
          
      31  Carpenter::Carpenter(   )
          {
          }
          
          
      36  Carpenter::~Carpenter(   )
          {
          }
          
      40  BuildingBlockSpec::BuildingBlockSpec(   )
          : mBlockSpec(  0 )
          {
          }
          
      45  BuildingBlockSpecDefinition::BuildingBlockSpecDefinition(   )
          {
          }
          
      49  AttachPoint::AttachPoint(  const std::string& name,   WFMath::Point<3> position,   WFMath::Vector<3> normal )
          : mNormal(  normal ),   mPosition(  position ),   mName(  name ),   mAttachPair(  0 )
          {
          }
          
      54  AttachPair::AttachPair(  const std::string& name,   const std::string& type,   AttachPoint point1,   AttachPoint point2 )
          : mPoint1(  point1 ),   mPoint2(  point2 ),   mName(  name ),   mType(  type )
          {
           mPoint1.setAttachPair(  this );
           mPoint2.setAttachPair(  this );
          }
          
      61  const std::vector<const AttachPoint*> BlockSpec::getAllPoints(   ) const
          {
           std::vector<const AttachPoint*> points;
          
           std::map<const std::string,   AttachPair>::const_iterator I = mAttachPairs.begin(   );
           std::map<const std::string,   AttachPair>::const_iterator I_end = mAttachPairs.end(   );
          
           for (  ;I != I_end; ++I ) {
           points.push_back(  &I->second.getPoint1(   ) );
           points.push_back(  &I->second.getPoint2(   ) );
           }
           return points;
          
          }
          
      76  bool BlockSpec::addAttachPair(  AttachPair* pair )
          {
           if (  mAttachPairs.find(  pair->getName(   ) ) != mAttachPairs.end(   ) )
           return false;
           mAttachPairs.insert(  std::map<const std::string,   AttachPair>::value_type(  pair->getName(   ),   *pair ) );
           return true;
          }
          
      84  const AttachPair* BlockSpec::getAttachPair(  const std::string & name ) const
          {
           AttachPairStore::const_iterator I = mAttachPairs.find(  name );
           if (  I == mAttachPairs.end(   ) ) {
           return 0;
           }
           return &(  I->second );
          }
          
      93  void BlockSpec::setBoundingBox(  WFMath::AxisBox<3> bbox )
          {
           mBoundingBox = bbox;
          }
          
          
      99  const AttachPoint* AttachPoint::getSibling(   ) const
          {
           if (  &mAttachPair->mPoint1 == this ) {
           return &mAttachPair->mPoint2;
           }
           return &mAttachPair->mPoint1;
          }
          
          
          
     109  BlockSpec* Carpenter::createBlockSpec(  std::string name )
          {
           mBlockSpecs[name];
           mBlockSpecs[name].mName = name;
           return &mBlockSpecs[name];
          }
          
     116  BuildingBlockSpec* Carpenter::createBuildingBlockSpec(  BuildingBlockSpecDefinition definition )
          {
          /* BuildingBlockSpec* spec = new BuildingBlockSpec(   );
           spec->mDefinition = definition;
           spec->mBlockSpec = &mBlockSpecs[definition.mBlockSpecName];
           mBuildingBlockSpecs.insert(  std::map<const std::string ,   BuildingBlockSpec >::value_type(  definition.mName,   *spec ) );*/
          
           mBuildingBlockSpecs[definition.mName];
          
           mBuildingBlockSpecs[definition.mName].mDefinition = definition;
           mBuildingBlockSpecs[definition.mName].mBlockSpec = &mBlockSpecs[definition.mBlockSpecName];
          
           return &mBuildingBlockSpecs[definition.mName];
          }
          
     131  BluePrint* Carpenter::createBlueprint(  std::string name )
          {
           mBluePrints.insert(  std::map<const std::string ,   BluePrint>::value_type(  name,   BluePrint(  name,   this ) ) );
           return &(  mBluePrints.find(  name )->second );
          }
          
     137  BuildingBlockSpec* Carpenter::getBuildingBlockSpec(  const std::string& name )
          {
           return &mBuildingBlockSpecs[name];
          }
          
          
          
          };

./components/ogre/carpenter/Carpenter.h

       1  //
          // C++ Interface: Carpenter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRECARPENTER_H
          #define EMBEROGRECARPENTER_H
          
          
          // ------------------------------
          // Include WFmath header files
          // ------------------------------
          #include <wfmath/point.h>
          #include <wfmath/vector.h>
          #include <wfmath/axisbox.h>
          #include <wfmath/quaternion.h>
          
          #include "../EmberOgrePrerequisites.h"
          //#include "../model/Model.h"
          
           namespace Carpenter {
          
          /**
          @author Erik Hjortsberg
          */
          
      44  class AttachPair;
      45  class BlockSpec;
      46  class BuildingBlock;
      47  class BuildingBlockSpec;
      48  class BuildingBlockSpecDefinition;
      49  class BuildingBlockBinding;
      50  class BuildingBlockBindingDefinition;
          // class ModelBlockDefinition
          // class ModelBlock
          // class BuildingBlock
      54  class BuildingBlockDefinition;
      55  class BluePrint;
          
          
      58  class AttachPoint
          {
      60  friend class AttachPair;
      61  friend class BlockSpec;
      62  friend class Carpenter;
          public:
      64   AttachPoint(  const std::string& mName,   WFMath::Point<3> position,   WFMath::Vector<3> normal );
      65   inline const std::string& getName(   ) const { return mName; }
      66   inline const WFMath::Vector<3>& getNormal(   ) const { return mNormal; }
      67   inline const WFMath::Point<3>& getPosition(   ) const { return mPosition; }
          
      69   inline const AttachPair* getAttachPair(   ) const { return mAttachPair; }
      70   const AttachPoint* getSibling(   ) const;
          protected:
      72   WFMath::Vector<3> mNormal;
      73   WFMath::Point<3> mPosition;
      74   std::string mName;
      75   AttachPair* mAttachPair;
      76   void setAttachPair(  AttachPair* pair ) { mAttachPair = pair; }
          };
          
      79  class AttachPair
          {
      81  friend class BlockSpec;
      82  friend class AttachPoint;
      83  friend class Carpenter;
          public:
      85   const AttachPoint* getAttachPoint(  const std::string & name ) const {
           if (  mPoint1.mName == name ) {
           return &mPoint1;
           } else if (  mPoint2.mName == name ) {
           return &mPoint2;
           } else {
           //"No pair with that name."
           throw std::exception(   );
           }
          
           }
          
      97   AttachPair(  const std::string& name,   const std::string& type,   AttachPoint point1,   AttachPoint point2 );
          
      99   inline const AttachPoint& getPoint1(   ) const { return mPoint1; }
     100   inline const AttachPoint& getPoint2(   ) const { return mPoint2; }
     101   inline const std::string& getName(   ) const { return mName; }
     102   inline const std::string& getType(   ) const { return mType; }
          
          protected:
     105   AttachPoint mPoint1;
     106   AttachPoint mPoint2;
          // const AttachPoint& [] getPoints(   ) const;
     108   const std::string mName;
     109   const std::string mType;
          
          };
          
     113  class BlockSpec
          {
     115  friend class Carpenter;
          public:
           typedef std::map<const std::string,   AttachPair> AttachPairStore;
     118   inline const std::string& getName(   ) const { return mName; }
     119   inline const WFMath::AxisBox<3>& getBoundingBox(   ) const { return mBoundingBox; }
     120   const AttachPair* getAttachPair(  const std::string & name ) const;
          
     122   bool addAttachPair(  AttachPair* pair );
     123   void setBoundingBox(  WFMath::AxisBox<3> bbox );
          
     125   const std::vector<const AttachPoint*> getAllPoints(   ) const;
          
          protected:
     128   std::string mName;
     129   WFMath::AxisBox<3> mBoundingBox;
     130   AttachPairStore mAttachPairs;
          
          };
          
     134  class BuildingBlockSpecDefinition
          {
          public:
     137   BuildingBlockSpecDefinition(   );
     138   std::string mName;
     139   std::string mBlockSpecName;
           //std::string mModelName;
           //ModelBlock getModelBlock(   );
          };
          
          
     145  class BuildingBlockSpec
          {
     147  friend class Carpenter;
          public:
     149   BuildingBlockSpec(   );
     150   const BuildingBlockSpecDefinition& getDefinition(   ) const { return mDefinition; }
     151   const BlockSpec* getBlockSpec(   ) const { return mBlockSpec; }
     152   inline const std::string& getName(   ) const { return mDefinition.mName; }
          protected:
     154   BuildingBlockSpecDefinition mDefinition;
     155   BlockSpec* mBlockSpec;
           //EmberOgre::Model* mModel;
          };
          
          
          
          
          
          
          
          
          
          
     168  class Carpenter{
          public:
     170   Carpenter(   );
          
     172   ~Carpenter(   );
          /* bool loadBlockSpec(  const std::string& filename );
           bool loadModelBlockDefinition(  const std::string& filename );*/
          
     176   BluePrint* createBlueprint(  std::string name );
          
     178   BuildingBlockSpec* getBuildingBlockSpec(  const std::string& name );
          
     180   BlockSpec* createBlockSpec(  std::string name );
     181   BuildingBlockSpec* createBuildingBlockSpec(  BuildingBlockSpecDefinition definition );
          
     183   const std::map<const std::string ,   BlockSpec >* getBlockSpecs(   ) const {return &mBlockSpecs;}
     184   const std::map<const std::string ,   BuildingBlockSpec >* getBuildingBlockSpecs(   ) const {return &mBuildingBlockSpecs;}
     185   const std::map<const std::string ,   BluePrint>* getBluePrints(   ) const {return &mBluePrints;}
          
          protected:
     188   std::map<const std::string ,   BlockSpec > mBlockSpecs;
     189   std::map<const std::string ,   BuildingBlockSpec > mBuildingBlockSpecs;
     190   std::map<const std::string ,   BluePrint> mBluePrints;
          
          
          
          
          };
          
          }
          
          #endif

./components/ogre/environment/CaelumEnvironment.cpp

          //
          // C++ Implementation: CaelumEnvironment
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "CaelumEnvironment.h"
          #include "caelum/include/Caelum.h"
          #include "CaelumSky.h"
          #include "CaelumSun.h"
          #include "Water.h"
          #include "framework/Tokeniser.h"
          //#include "caelum/include/CaelumSystem.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
      35  class CloudsUpdater : public caelum::CaelumListener {
           protected:
           float mTime;
      38   Ogre::MaterialPtr mMaterial;
          
           public:
      41   CloudsUpdater (  float time,   Ogre::MaterialPtr material ) : mTime (  time ),   mMaterial(  material ) { }
      42   bool caelumStarted (  const Ogre::FrameEvent &e,   caelum::CaelumSystem *sys ) {
           Ogre::Technique* tech = mMaterial->getBestTechnique (   );
           if (  tech ) {
           Ogre::Pass* pass = tech->getPass(  0 );
           if (  pass ) {
           mTime += e.timeSinceLastFrame * 30;
           if (  pass->hasVertexProgram(   ) ) {
           pass->getVertexProgramParameters (   )->setNamedConstant (  "sunDirection",   sys->getSun (   )->getSunDirection (   ) );
           }
           if (  pass->hasFragmentProgram(   ) ) {
           pass->getFragmentProgramParameters (   )->setNamedConstant (  "sunDirection",   sys->getSun (   )->getSunDirection (   ) );
           pass->getFragmentProgramParameters (   )->setNamedConstant (  "sunColour",   sys->getSun (   )->getSunColour (   ) );
           pass->getFragmentProgramParameters (   )->setNamedConstant (  "time",   mTime );
           }
           return true;
           }
           }
           return true;
           }
          };
          
          
      64  CaelumEnvironment::CaelumEnvironment(  Ogre::SceneManager *sceneMgr,   Ogre::RenderWindow* window,   Ogre::Camera* camera )
          :
           SetCaelumTime(  "set_caelumtime",  this,   "Sets the caelum time. parameters: <hour> <minute>" )
      67  ,   mCaelumSystem(  0 )
          ,   mCaelumModel(  0 )
          ,   mSceneMgr(  sceneMgr )
          ,   mWindow(  window )
          ,   mCamera(  camera )
          ,   mSky(  0 )
          ,   mSun(  0 )
          ,   mWater(  0 )
          
          //,  mLensFlare(  camera,   sceneMgr )
          {
           sceneMgr->setAmbientLight(  Ogre::ColourValue(  0.3f,   0.3f,   0.3f ) );
          // sceneMgr->setAmbientLight(  Ogre::ColourValue(  0.6,   0.6,   0.6 ) );
          // setupCaelum(  root,   sceneMgr,   window ,   camera );
          /* mLensFlare.setNode(  mCaelumSystem->getSun(   )- } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "Could not load caelum. Message: " << ex.getFullDescription(   ) );
           }
          >getNode(   ) );
           mLensFlare.initialize(   );*/
          // mLensFlare.setVisible(  false );
           //Ogre::::Root::getSingleton(   ).addFrameListener(  this );
          }
          
      90  CaelumEnvironment::~CaelumEnvironment(   )
          {
           delete mSky;
           delete mSun;
           delete mWater;
           delete mCaelumModel;
           delete mCaelumSystem;
          }
          
      99  void CaelumEnvironment::createEnvironment(   )
          {
           try {
           setupCaelum(   Ogre::Root::getSingletonPtr(   ),   mSceneMgr,   mWindow,   mCamera );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "Could not load caelum. Message: " << ex.getFullDescription(   ) );
           }
           setupWater(   );
          
          }
          
          
     111  void CaelumEnvironment::setupWater(   )
          {
           mWater = new Water(  mCamera,   mSceneMgr );
          }
          
     116  void CaelumEnvironment::setupCaelum(  ::Ogre::Root *root,   ::Ogre::SceneManager *sceneMgr,   ::Ogre::RenderWindow* window,   ::Ogre::Camera* camera )
          {
           mCaelumSystem = new caelum::CaelumSystem (  root,   sceneMgr,   false );
           caelum::SunPositionModel *spm = new caelum::SimpleSunPositionModel (  Ogre::Degree (  13 ) );
           mCaelumSystem->getSun (   )->setSunPositionModel (  spm );
          
           // Create and configure the sky colours model to use
          
           mCaelumModel = new caelum::StoredImageElvBasedSkyColourModel (   );
           mCaelumSystem->setSkyColourModel (  mCaelumModel ); // Call this before changing the gradients image!!
           static_cast<caelum::StoredImageElvBasedSkyColourModel *>(  mCaelumModel )->setSkyGradientsImage (  "EarthClearSky2.png" );
          
           mCaelumSystem->setManageFog (  true );
          // static_cast<caelum::StoredImageSkyColourModel *>(  mCaelumModel )->setFogColoursImage (  "EarthClearSkyFog.png" );
           static_cast<caelum::StoredImageElvBasedSkyColourModel *>(  mCaelumModel )->setFogDensity (  0.005 );
          
           // Create a sky dome
          // mDome = mCaelumSystem->createSkyDome (   );
           mDome = mCaelumSystem->getSkyDome(   );
          
          
           // Create a starfield
          // window->addListener (  mCaelumSystem->createStarfield (  "Starfield.jpg" ) );
           mCaelumSystem->getStarfield (   )->setInclination (  ::Ogre::Degree (  13 ) );
          
           mCaelumSystem->getSkyDome(   )->setFarRadius(  10000 );
           mCaelumSystem->getStarfield(   )->setFarRadius(  10000 );
           mCaelumSystem->getSun(   )->setFarRadius(  100 );
          
           // Register all to the render window
           window->addListener (  mCaelumSystem );
          
          
           // Set some time parameters
           time_t t = time (  &t );
           struct tm *t2 = localtime (  &t );
           mCaelumSystem->setTimeScale (  1 );
           int hour = t2->tm_hour;
           //little hack here. We of course want to use the server time,   but currently when you log in when it's dark,   you won't see much,   so in order to show the world in it's full glory we'll try to set the time to day time
           if (  t2->tm_hour < 6 ) {
           hour = 6;
           } else if (  t2->tm_hour > 16 ) {
           hour = 15;
           }
          
           float time = 3600 * hour + 60 * t2->tm_min + t2->tm_sec;
          
           mCaelumSystem->setLocalTime (  time );
           mCaelumSystem->setUpdateRate(   1 / (  24 * 60 ) ); //update every minute
          
           mSky = new CaelumSky(  *this,   mCaelumModel,   mDome );
           mSun = new CaelumSun(  *this,   mCaelumSystem->getSun(   ) );
          
           std::string cloudMaterialName = "Cirrus";
           Ogre::MaterialPtr mat = static_cast<Ogre::MaterialPtr >(  Ogre::MaterialManager::getSingleton (   ).getByName (  cloudMaterialName ) );
          
           // Register our cloud updater
           if (  !mat.isNull(   ) ) {
           mSceneMgr->setSkyPlane (  true,   Ogre::Plane (  Ogre::Vector3::NEGATIVE_UNIT_Y,   -1000 ),   cloudMaterialName,   1000,   1,   false,   .1,   10,   10,   caelum::RESOURCE_GROUP_NAME );
           mCaelumSystem->addListener (  new CloudsUpdater (  time,   mat ) );
           }
          
           Ogre::FrameEvent ev;
           ev.timeSinceLastEvent = 0;
           ev.timeSinceLastFrame = 0;
           mCaelumSystem->frameStarted(  ev );
          
          /* sceneMgr->setSkyPlane (  true,   Ogre::Plane (  Ogre::Vector3::NEGATIVE_UNIT_Y,   -100 ),   "Altocumulus",   1000,   10,   false );
           mCaelumSystem->addListener (  new CloudsUpdater (   ) );*/
          
          }
          
     188  ISun* CaelumEnvironment::getSun(   )
          {
           return mSun;
          }
          
     193  ISky* CaelumEnvironment::getSky(   )
          {
           return mSky;
          }
          
     198  IFog* CaelumEnvironment::getFog(   )
          {
           return 0;
           //return mFog;
          }
          
     204  IWater* CaelumEnvironment::getWater(   )
          {
           return 0;
          }
          
     209  void CaelumEnvironment::setTime(  int hour,   int minute,   int second )
          {
           mCaelumSystem->setLocalTime (  3600 * hour + 60 * minute + second );
          }
          
     214  void CaelumEnvironment::setTime(  int seconds )
          {
           mCaelumSystem->setLocalTime (  seconds );
          }
          
     219  void CaelumEnvironment::runCommand(  const std::string &command,   const std::string &args )
          {
           if (  SetCaelumTime == command ) {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string hourString = tokeniser.nextToken(   );
           std::string minuteString = tokeniser.nextToken(   );
          
           int hour = ::Ogre::StringConverter::parseInt(   hourString );
           int minute = ::Ogre::StringConverter::parseInt(   minuteString );
           setTime(  hour,   minute );
          
           }
          
          }
          
          
          }
          
          }

./components/ogre/environment/CaelumEnvironment.h

       1  //
          // C++ Interface: CaelumEnvironment
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_ENVIRONMENTCAELUMENVIRONMENT_H
          #define EMBEROGRE_ENVIRONMENTCAELUMENVIRONMENT_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "Environment.h"
          #include "framework/ConsoleObject.h"
          
          namespace caelum
          {
      32   class CaelumSystem;
      33   class SkyColourModel;
      34   class SkyDome;
      35   class Sun;
          }
          
          namespace EmberOgre {
          
          namespace Environment {
          
      42  class CaelumSky;
      43  class CaelumSun;
      44  class Water;
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      49  class CaelumEnvironment : public IEnvironmentProvider,   public Ember::ConsoleObject
          {
          public:
      52   CaelumEnvironment(  Ogre::SceneManager *sceneMgr,   Ogre::RenderWindow* window,   Ogre::Camera* camera );
          
      54   ~CaelumEnvironment(   );
          
      56   virtual void createEnvironment(   );
          
      58   virtual ISun* getSun(   );
      59   virtual ISky* getSky(   );
      60   virtual IFog* getFog(   );
      61   virtual IWater* getWater(   );
          
      63   inline caelum::CaelumSystem* getCaelumSystem(   ) const;
          
      65   const Ember::ConsoleCommandWrapper SetCaelumTime;
          
      67   virtual void setTime(  int hour,   int minute,   int second = 0 );
      68   virtual void setTime(  int seconds );
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
      75   virtual void runCommand(  const std::string &command,   const std::string &args );
          
          private:
          
          
           /**
           * Creates and initializes the caelum system.
           * @param root
           * @param sceneMgr
           * @param window
           * @param camera
           */
      87   void setupCaelum(  Ogre::Root *root,   Ogre::SceneManager *sceneMgr,   Ogre::RenderWindow* window,   Ogre::Camera* camera );
          
           /**
           * Creates a water plane.
           */
      92   void setupWater(   );
          
           // Caelum system
      95   caelum::CaelumSystem *mCaelumSystem;
           // Caelum model
      97   caelum::SkyColourModel *mCaelumModel;
          
      99   caelum::SkyDome *mDome;
          
     101   Ogre::SceneManager *mSceneMgr;
     102   Ogre::RenderWindow* mWindow;
     103   Ogre::Camera* mCamera;
          
     105   CaelumSky* mSky;
     106   CaelumSun* mSun;
     107   Water* mWater;
          
          };
          
     111  caelum::CaelumSystem* CaelumEnvironment::getCaelumSystem(   ) const
          {
           return mCaelumSystem;
          }
          
     116  class CaelumEnvironmentComponent
          {
          protected:
     119   CaelumEnvironmentComponent(  CaelumEnvironment& environment ) : mEnvironment(  environment ) {}
     120   CaelumEnvironment& mEnvironment;
          };
          
          }
          
          }
          
          #endif

./components/ogre/environment/CaelumSky.cpp

       1  //
          // C++ Implementation: CaelumSky
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "CaelumSky.h"
          #include "caelum/include/Caelum.h"
          #include "framework/Tokeniser.h"
          
          
          namespace EmberOgre {
          
          namespace Environment {
          
      32  CaelumSky::CaelumSky(  CaelumEnvironment& environment,   caelum::SkyColourModel *caelumModel,   caelum::SkyDome *dome )
          : CaelumEnvironmentComponent(   environment ),   mCaelumModel(  caelumModel ),   mDome(  dome )
          {
          }
          
          
      38  CaelumSky::~CaelumSky(   )
          {
          }
          
      42  void CaelumSky::setDensity(  float density )
          {
           static_cast<caelum::StoredImageSkyColourModel *>(  mCaelumModel )->setFogDensity (  density );
          }
      46  float CaelumSky::getDensity(   ) const
          {
           //TODO: make it get the time
           return static_cast<caelum::StoredImageSkyColourModel *>(  mCaelumModel )->getFogDensity (  0,   Ogre::Vector3::ZERO );
          }
          
      52  bool CaelumSky::frameEnded(  const Ogre::FrameEvent & event )
          {
           return true;
          }
          
          
          
          }
          
          }

./components/ogre/environment/CaelumSky.h

       1  //
          // C++ Interface: CaelumSky
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRECAELUMSKY_H
          #define EMBEROGRECAELUMSKY_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "CaelumEnvironment.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      37  class CaelumSky
      38  : CaelumEnvironmentComponent
      39  ,  public IFog,  public ISky
          {
          public:
      42   CaelumSky(  CaelumEnvironment& environment,   caelum::SkyColourModel *caelumModel,   caelum::SkyDome *dome );
          
      44   virtual ~CaelumSky(   );
          
          
      47   void setDensity(  float density );
      48   float getDensity(   ) const;
          
          
      51   virtual bool frameEnded(  const Ogre::FrameEvent & event );
          
          private:
          
          
           // Caelum system
      57   caelum::CaelumSystem *mCaelumSystem;
           // Caelum model
      59   caelum::SkyColourModel *mCaelumModel;
          
      61   caelum::SkyDome *mDome;
          
          // LensFlare mLensFlare;
          
          };
          
          
          }
          
          }
          
          #endif

./components/ogre/environment/CaelumSun.cpp

       1  //
          // C++ Implementation: CaelumSun
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "CaelumSun.h"
          #include "components/ogre/EmberOgre.h"
          #include "caelum/include/Sun.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
      31  CaelumSun::CaelumSun(  CaelumEnvironment& environment,   caelum::Sun* sun )
          : CaelumEnvironmentComponent(   environment ),   mSun(  sun )
          {
          }
          
          
      37  CaelumSun::~CaelumSun(   )
          {
          }
          
      41  void CaelumSun::setAmbientLight(  const Ogre::ColourValue& colour ) {
           EmberOgre::getSingleton(   ).getSceneManager(   )->setAmbientLight(  colour );
          }
          
      45  Ogre::Vector3 CaelumSun::getSunDirection(   ) const
          {
           return mSun->getSunDirection(   );
          }
          
          }
          
          }

./components/ogre/environment/CaelumSun.h

       1  //
          // C++ Interface: CaelumSun
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRECAELUMSUN_H
          #define EMBEROGRECAELUMSUN_H
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "CaelumEnvironment.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      35  class CaelumSun : CaelumEnvironmentComponent,   public ISun
          {
          public:
      38   CaelumSun(  CaelumEnvironment& environment,   caelum::Sun* sun );
          
      40   ~CaelumSun(   );
          
      42   virtual void setAmbientLight(  const Ogre::ColourValue& colour );
          
      44   virtual Ogre::Vector3 getSunDirection(   ) const;
          
          private:
          
      48   caelum::Sun* mSun;
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/environment/Environment.cpp

          //
          // C++ Implementation: Environment
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "Environment.h"
          #include "framework/Tokeniser.h"
          #include "Forest.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
      32  Environment::Environment(  IEnvironmentProvider* provider ):
           SetTime(  "set_time",  this,   "Sets the time. parameters: <hour> <minute>" )
      34  ,   SetFogDensity(  "set_fogdensity",  this,   "Sets the fog density." )
          ,   SetAmbientLight(  "setambientlight",   this,   "Set the ambient light of the world: <red> <green> <blue>" )
          ,   mProvider(  provider )
          ,   mForest(  new Forest(   ) )
          {
          }
          
          
      42  Environment::~Environment(   )
          {
           delete mProvider;
           delete mForest;
          }
          
      48  void Environment::runCommand(  const std::string &command,   const std::string &args )
          {
          // if (  SetTime == command ) {
          // Ember::Tokeniser tokeniser;
          // tokeniser.initTokens(  args );
          // std::string hourString = tokeniser.nextToken(   );
          // std::string minuteString = tokeniser.nextToken(   );
          //
          // int hour = ::Ogre::StringConverter::parseInt(   hourString );
          // int minute = ::Ogre::StringConverter::parseInt(   minuteString );
          // setTime(  hour,   minute );
          //
          // } else
           if (  SetFogDensity == command ) {
           if (  getFog(   ) ) {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string densityString = tokeniser.nextToken(   );
          
           float density = ::Ogre::StringConverter::parseReal(  densityString );
           getFog(   )->setDensity(   density );
           }
          
           } else if (  SetAmbientLight == command )
           {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string r = tokeniser.nextToken(   );
           std::string b = tokeniser.nextToken(   );
           std::string g = tokeniser.nextToken(   );
          
           if (  r == "" || b == "" || g == "" ) {
           return;
           } else {
           Ogre::ColourValue colour(  Ogre::StringConverter::parseReal(  r ),  Ogre::StringConverter::parseReal(  b ),  Ogre::StringConverter::parseReal(  g ) );
           setAmbientLight(  colour );
           }
          
           }
          
          }
          
      90  void Environment::initialize(   )
          {
           mProvider->createEnvironment(   );
          }
          
      95  void Environment::setTime(  int hour,   int minute,   int second )
          {
           mProvider->setTime(  hour,   minute,   second );
          }
          
     100  void Environment::setTime(  int seconds )
          {
           mProvider->setTime(  seconds );
          }
          
     105  void Environment::setAmbientLight(  const Ogre::ColourValue& colour ) {
           getSun(   )->setAmbientLight(  colour );
           EventUpdatedAmbientLight.emit(  colour );
          }
          
          }
          
          }

./components/ogre/environment/Environment.h

       1  //
          // C++ Interface: Environment
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBER_OGRE_ENVIRONMENTENVIRONMENT_H
          #define EMBER_OGRE_ENVIRONMENTENVIRONMENT_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "framework/ConsoleObject.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
      33  class Forest;
          
      35  class ISun
          {
          public:
      38   virtual ~ISun(   ) {}
      39   virtual void setAmbientLight(  const Ogre::ColourValue& colour ) = 0;
      40   virtual Ogre::Vector3 getSunDirection(   ) const = 0;
          
          };
          
      44  class ISky
          {
          public:
          };
          
      49  class IFog
          {
          public:
      52   virtual ~IFog(   ) {}
      53   virtual void setDensity(  float density ) = 0;
      54   virtual float getDensity(   ) const = 0;
          };
          
      57  class IWater
          {
          public:
          };
          
      62  class IEnvironmentProvider
          {
          public:
          
      66   virtual ~IEnvironmentProvider(   ) {}
          
      68   virtual void createEnvironment(   ) = 0;
          
      70   virtual ISun* getSun(   ) = 0;
      71   virtual ISky* getSky(   ) = 0;
      72   virtual IFog* getFog(   ) = 0;
      73   virtual IWater* getWater(   ) = 0;
          
      75   virtual void setTime(  int hour,   int minute,   int second = 0 ) = 0;
      76   virtual void setTime(  int seconds ) = 0;
          
          };
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      83  class Environment : public Ember::ConsoleObject
          {
          public:
      86   Environment(  IEnvironmentProvider* provider );
          
      88   ~Environment(   );
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
      95   virtual void runCommand(  const std::string &command,   const std::string &args );
          
      97   const Ember::ConsoleCommandWrapper SetTime;
      98   const Ember::ConsoleCommandWrapper SetFogDensity;
      99   const Ember::ConsoleCommandWrapper SetAmbientLight;
          
     101   inline ISun* getSun(   );
     102   inline ISky* getSky(   );
     103   inline IFog* getFog(   );
     104   inline IWater* getWater(   );
     105   inline Forest* getForest(   );
          
          
     108   void setTime(  int hour,   int minute,   int second = 0 );
     109   void setTime(  int seconds );
          
     111   void initialize(   );
          
           /**
           * changes the ambient light
           * @param colour
           */
     117   void setAmbientLight(  const Ogre::ColourValue& colour );
          
          
           /**
           * emitted when the world ambient light is changed
           */
     123   sigc::signal<void,   const Ogre::ColourValue&> EventUpdatedAmbientLight;
          
          private:
          
     127   IEnvironmentProvider* mProvider;
     128   Forest* mForest;
          // ISun* mSun;
          // ISky* mSky;
          // IFog* mFog;
          // IWater* mWater;
          
          };
          
     136  ISun* Environment::getSun(   )
          {
           return mProvider->getSun(   );
          }
          
     141  ISky* Environment::getSky(   )
          {
           return mProvider->getSky(   );
          }
          
     146  IFog* Environment::getFog(   )
          {
           return mProvider->getFog(   );
          }
          
     151  IWater* Environment::getWater(   )
          {
           return mProvider->getWater(   );
          }
          
     156  Forest* Environment::getForest(   )
          {
           return mForest;
          }
          
          }
          
          }
          
          #endif

./components/ogre/environment/Foliage.cpp

       1  //
          // C++ Implementation: Foliage
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/config/ConfigService.h"
          
          #include "Foliage.h"
          #include "FoliageArea.h"
          // #include "FoliageImpl.h"
          
          //#include "GroundCover.h"
          #include "components/ogre/EmberOgre.h"
          #include "components/ogre/terrain/TerrainGenerator.h"
          
          template<> EmberOgre::Environment::Foliage* Ember::Singleton<EmberOgre::Environment::Foliage>::ms_Singleton = 0;
          
          namespace EmberOgre {
          
          namespace Environment {
          
          #define GRASS_HEIGHT 0.5
          #define GRASS_WIDTH 0.5
          #define GRASS_MESH_NAME "grassblades"
          #define GRASS_MATERIAL "Examples/GrassBlades"
          #define OFFSET_PARAM 999
          
          
          
      49  Foliage::Foliage(   Ogre::SceneManager* sceneMgr )
          : mSceneMgr(  sceneMgr )
          {
           S_LOG_INFO(  "Setting up foliage system." );
          
          // mImpl = new FoliageImpl(   );
          
          // createGrassMesh(   );
          //
          // Ogre::Entity* e = mSceneMgr->createEntity(  "1",   GRASS_MESH_NAME );
          // mEntities["grass"] = e;
          //
          // Ogre::Entity* entity;
          //
          // try {
          // entity = mSceneMgr->createEntity(  "environment/field/placeholder",   "placeholder.mesh" );
          // mEntities["placeholder"] = entity;
          // }
          // catch (  const Ogre::Exception& e ) {}
          // try {
          // entity = mSceneMgr->createEntity(  "environment/field/heartblood",   "environment/field/small_plant/heartblood/normal.mesh" );
          // mEntities["heartblood"] = entity;
          // }
          // catch (  const Ogre::Exception& e ) {}
          // try {
          // entity = mSceneMgr->createEntity(  "environment/field/teardrops",   "environment/field/small_plant/teardrops/normal.mesh" );
          // mEntities["teardrops"] = entity;
          // }
          // catch (  const Ogre::Exception& e ) {}
          // try {
          // entity = mSceneMgr->createEntity(  "environment/field/thingrass",   "environment/field/small_plant/thingrass/normal.mesh" );
          // mEntities["thingrass"] = entity;
          // }
          // catch (  const Ogre::Exception& e ) {}
          // try {
          // entity = mSceneMgr->createEntity(  "environment/field/bittergrass",   "3d_objects/plants/tussock/models/small_plant/simplegrass.mesh" );
          // mEntities["bittergrass"] = entity;
          // }
          // catch (  const Ogre::Exception& e ) {}
          //
          //
          // Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
          // //mSubmeshSize = (  int )configSrv->getValue(  "foliage",   "submeshsize" );
          // mGrassSpacing = (  double )configSrv->getValue(  "foliage",   "spacing_grass" );
          // // double bushSpacing = (  double )configSrv->getValue(  "foliage",   "spacing_bushes" );
          // // double cullDistance = (  double )configSrv->getValue(  "foliage",   "cullingdistance" );
          //
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          
          }
          
          
     101  Foliage::~Foliage(   )
          {
           S_LOG_INFO(  "Shutting down foliage system." );
          
          // delete mImpl;
          
          // for (  FoliageAreaStore::iterator I = mFoliageAreas.begin(   ); I != mFoliageAreas.end(   ); ++I ) {
          // delete *I;
          // }
          //
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
          // for (  EntityStore::iterator I = mEntities.begin(   ); I != mEntities.end(   ); ++I ) {
          // mSceneMgr->destroyMovableObject(  I->second );
          // }
          }
          
          
     118  void Foliage::createGrass(   )
          {
          // mImpl->createGrass(   );
          }
          
     123  Ogre::Entity* Foliage::getEntity(  const std::string& name )
          {
          // EntityStore::iterator I = mEntities.find(  name );
          // if (  I != mEntities.end(   ) ) {
          // return I->second;
          // }
           return 0;
          }
          
     132  FoliageArea* Foliage::createArea(  const WFMath::AxisBox<2>& extent )
          {
           std::stringstream ss;
           ss << mFoliageAreas.size(   );
           FoliageArea* area = new FoliageArea(  *this,   *mSceneMgr,   std::string(  "foliage_" ) + ss.str(   ) );
           mFoliageAreas.push_back(  area );
           return area;
          }
          
     141  void Foliage::destroyArea(  FoliageArea* area )
          {
           for (  FoliageAreaStore::iterator I = mFoliageAreas.begin(   ); I != mFoliageAreas.end(   ); ++I ) {
           if (  *I == area ) {
           mFoliageAreas.erase(  I );
           break;
           }
           }
           delete area;
          }
          
     152  void Foliage::createGrassMesh(   )
          {
          // // Each grass section is 3 planes at 60 degrees to each other
          // // Normals point straight up to simulate correct lighting
          // Ogre::MeshPtr msh = Ogre::MeshManager::getSingleton(   ).createManual(  GRASS_MESH_NAME,  
          // Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
          // Ogre::SubMesh* sm = msh->createSubMesh(   );
          // sm->useSharedVertices = false;
          // sm->vertexData = new Ogre::VertexData(   );
          // sm->vertexData->vertexStart = 0;
          // sm->vertexData->vertexCount = 12;
          // Ogre::VertexDeclaration* dcl = sm->vertexData->vertexDeclaration;
          // size_t offset = 0;
          // dcl->addElement(  0,   offset,   Ogre::VET_FLOAT3,   Ogre::VES_POSITION );
          // offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT3 );
          // dcl->addElement(  0,   offset,   Ogre::VET_FLOAT3,   Ogre::VES_NORMAL );
          // offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT3 );
          // dcl->addElement(  0,   offset,   Ogre::VET_FLOAT2,   Ogre::VES_TEXTURE_COORDINATES );
          // offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT2 );
          //
          // Ogre::HardwareVertexBufferSharedPtr vbuf = Ogre::HardwareBufferManager::getSingleton(   )
          // .createVertexBuffer(  
          // offset,   12,   Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          // float* pReal = static_cast<float*>(  vbuf->lock(  Ogre::HardwareBuffer::HBL_DISCARD ) );
          // Ogre::Vector3 baseVec(  GRASS_WIDTH/2,   0,   0 );
          // Ogre::Vector3 vec = baseVec;
          // Ogre::Quaternion rot;
          // rot.FromAngleAxis(  Ogre::Degree(  60 ),   Ogre::Vector3::UNIT_Y );
          // int i;
          // for (  i = 0; i < 3; ++i )
          // {
          // // position
          // *pReal++ = -vec.x;
          // *pReal++ = GRASS_HEIGHT;
          // *pReal++ = -vec.z;
          // // normal
          // *pReal++ = 0;
          // *pReal++ = 1;
          // *pReal++ = 0;
          // // uv
          // *pReal++ = 0;
          // *pReal++ = 0;
          //
          // // position
          // *pReal++ = vec.x;
          // *pReal++ = GRASS_HEIGHT;
          // *pReal++ = vec.z;
          // // normal
          // *pReal++ = 0;
          // *pReal++ = 1;
          // *pReal++ = 0;
          // // uv
          // *pReal++ = 1;
          // *pReal++ = 0;
          //
          // // position
          // *pReal++ = -vec.x;
          // *pReal++ = 0;
          // *pReal++ = -vec.z;
          // // normal
          // *pReal++ = 0;
          // *pReal++ = 1;
          // *pReal++ = 0;
          // // uv
          // *pReal++ = 0;
          // *pReal++ = 1;
          //
          // // position
          // *pReal++ = vec.x;
          // *pReal++ = 0;
          // *pReal++ = vec.z;
          // // normal
          // *pReal++ = 0;
          // *pReal++ = 1;
          // *pReal++ = 0;
          // // uv
          // *pReal++ = 1;
          // *pReal++ = 1;
          //
          // vec = rot * vec;
          // }
          // vbuf->unlock(   );
          // sm->vertexData->vertexBufferBinding->setBinding(  0,   vbuf );
          // sm->indexData->indexCount = 6*3;
          // sm->indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton(   )
          // .createIndexBuffer(  Ogre::HardwareIndexBuffer::IT_16BIT,   6*3,  
          // Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          // Ogre::uint16* pI = static_cast<Ogre::uint16*>(  
          // sm->indexData->indexBuffer->lock(  Ogre::HardwareBuffer::HBL_DISCARD ) );
          // for (  i = 0; i < 3; ++i )
          // {
          // int off = i*4;
          // *pI++ = 0 + off;
          // *pI++ = 3 + off;TerrainPageSurface
          // *pI++ = 1 + off;
          //
          // *pI++ = 0 + off;
          // *pI++ = 2 + off;
          // *pI++ = 3 + off;
          // }
          //
          // sm->indexData->indexBuffer->unlock(   );
          //
          // sm->setMaterialName(  GRASS_MATERIAL );
          // msh->load(   );
          
          }
          
          
     261  bool Foliage::frameStarted(  const Ogre::FrameEvent & evt )
          {
          // mImpl->update(   );
           for (  FoliageAreaStore::iterator I = mFoliageAreas.begin(   ); I != mFoliageAreas.end(   ); ++I ) {
           (  *I )->frameStarted(  evt.timeSinceLastFrame );
           }
           return true;
          
          }
          
          
          
          
          }
          }
          

./components/ogre/environment/Foliage.h

       1  //
          // C++ Interface: Foliage
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREFOLIAGE_H
          #define EMBEROGREFOLIAGE_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "framework/Singleton.h"
          #include <wfmath/axisbox.h>
          
          namespace EmberOgre {
          
          namespace Environment {
          
      34  class FoliageArea;
      35  class FoliageImpl;
          
          //class GroundCover;
          /**
          @author Erik Hjortsberg
          */
      41  class Foliage : public Ember::Singleton<Foliage>,   public Ogre::FrameListener
          {
          
          public:
          
           typedef std::list<FoliageArea*> FoliageAreaStore;
           typedef std::map<const std::string,   Ogre::Entity* > EntityStore;
      48   Foliage(   Ogre::SceneManager* mSceneMgr );
          
      50   ~Foliage(   );
          
           /**
           * Creates a new Foliage area,   ready to be populated
           * @return
           */
      56   FoliageArea* createArea(  const WFMath::AxisBox<2>& extent );
          
          
           /**
           * destroys a foliage area
           * @param area
           */
      63   void destroyArea(  FoliageArea* area );
          
      65   bool frameStarted(  const Ogre::FrameEvent & evt );
          
      67   Ogre::Entity* getEntity(  const std::string& name );
          
      69   inline double getGrassSpacing(   ) const {return mGrassSpacing;}
          
      71   void createGrass(   );
          
          protected:
      74   EntityStore mEntities;
          
           //GroundCover* mGround;
      77   FoliageAreaStore mFoliageAreas;
          
      79   void createGrassMesh(   );
          
          
           double mGrassSpacing;
      83   Ogre::SceneManager* mSceneMgr;
          
      85   FoliageImpl* mImpl;
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/environment/FoliageArea.cpp

       1  //
          // C++ Implementation: FoliageArea
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "FoliageArea.h"
          
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/config/ConfigService.h"
          #include "Foliage.h"
          #include "pagedgeometry/include/PagedGeometry.h"
          #include "pagedgeometry/include/BatchPage.h"
          #include "pagedgeometry/include/BatchedGeometry.h"
          
          #include "../AvatarCamera.h"
          #include "../EmberOgre.h"
          #include "../terrain/TerrainGenerator.h"
          #include "../terrain/ISceneManagerAdapter.h"
          
          using namespace PagedGeometry;
          // #define OFFSET_PARAM 999
          
          namespace EmberOgre {
          
          namespace Environment {
          
          // Ogre::Real FoliageArea::mXinc = Ogre::Math::PI * 0.004;
          // Ogre::Real FoliageArea::mZinc = Ogre::Math::PI * 0.0055;
          
      48  FoliageArea::FoliageArea(  Foliage& foliage,   Ogre::SceneManager& sceneManager,   const std::string name ) :
          mName(  name ),  
          mSceneMgr(  sceneManager ),  
          mFoliage(  foliage ),  
          mVisible(  false ),  
          mGrass(  0 ),  
          mGrass2(  0 ),  
          mGrassLoader(  0 ),  
          mGrassLoader2(  0 )
          // mStaticGeom(  0 )
          {
          /* mXpos = Ogre::Math::RangeRandom(  -Ogre::Math::PI,   Ogre::Math::PI );
           mZpos = Ogre::Math::RangeRandom(  -Ogre::Math::PI,   Ogre::Math::PI );*/
          }
          
          
      64  FoliageArea::~FoliageArea(   )
          {
           delete mGrass;
           delete mGrass2;
           delete mGrassLoader;
           delete mGrassLoader2;
          
          // if (  mStaticGeom ) {
          // mSceneMgr.destroyStaticGeometry(  mStaticGeom );
          // }
          }
          
      76  void FoliageArea::setVisible(  bool visible )
          {
          // mVisible = visible;
          // if (  mStaticGeom ) {
          // mStaticGeom->setVisible(  visible );
          // }
           //mGround->getSceneNode(   )->setVisible(  mVisible );
          }
          
          // void FoliageArea::waveGrass(  Ogre::Real timeElapsed )
          // {
          //
          // mXpos += mXinc * timeElapsed;
          // mZpos += mZinc * timeElapsed;
          //
          // // Update vertex program parameters by binding a value to each renderable
          // static Ogre::Vector4 offset(  0,  0,  0,  0 );
          //
          // Ogre::StaticGeometry::RegionIterator rit = mStaticGeom->getRegionIterator(   );
          // while (  rit.hasMoreElements(   ) )
          // {
          // Ogre::StaticGeometry::Region* reg = rit.getNext(   );
          //
          // // a little randomness
          // mXpos += reg->getCentre(   ).x * 0.000001;
          // mZpos += reg->getCentre(   ).z * 0.000001;
          // offset.x = Ogre::Math::Sin(  mXpos );
          // offset.z = Ogre::Math::Sin(  mZpos );
          //
          // Ogre::StaticGeometry::Region::LODIterator lodit = reg->getLODIterator(   );
          // while (  lodit.hasMoreElements(   ) )
          // {
          // Ogre::StaticGeometry::LODBucket* lod = lodit.getNext(   );
          // Ogre::StaticGeometry::LODBucket::MaterialIterator matit =
          // lod->getMaterialIterator(   );
          // while (  matit.hasMoreElements(   ) )
          // {
          // Ogre::StaticGeometry::MaterialBucket* mat = matit.getNext(   );
          // Ogre::StaticGeometry::MaterialBucket::GeometryIterator geomit =
          // mat->getGeometryIterator(   );
          // while (  geomit.hasMoreElements(   ) )
          // {
          // Ogre::StaticGeometry::GeometryBucket* geom = geomit.getNext(   );
          // geom->setCustomParameter(  OFFSET_PARAM,   offset );
          //
          // }
          // }
          // }
          // }
          //
          // }
          
          
          
          
     131  void FoliageArea::init(  const WFMath::AxisBox<2>& extent,   Ogre::TexturePtr densityMap,   Ogre::TexturePtr shadowMap )
          {
           mExtent = extent;
           createGrass(  densityMap,   shadowMap );
          
          /* mStaticGeom = mSceneMgr.createStaticGeometry(  name );
           mStaticGeom->setRegionDimensions(  Ogre::Vector3(  32,  32,   32 ) );
           // Set the region origin so the centre is at 0 world
           //s->setOrigin(  (  endPosition - startPosition ) / 2 );
           mStaticGeom->setRenderingDistance(  34 );
          
           mStaticGeom->setRenderQueueGroup(  Ogre::RENDER_QUEUE_7 );*/
          }
          
     145  void FoliageArea::createGrass(  Ogre::TexturePtr densityMap,   Ogre::TexturePtr shadowMap )
          {
           TBounds bounds = Atlas2Ogre(  mExtent );
          // TBounds bounds(  mExtent.lowCorner(   ).x(   ),   mExtent.lowCorner(   ).y(   ),   mExtent.highCorner(   ).x(   ),  mExtent.highCorner(   ).y(   ) );
           S_LOG_INFO(  "Creating grass for area: left: "<< bounds.left <<" right: " << bounds.right << " top: " << bounds.top << " bottom: " << bounds.bottom << "." );
           Ogre::Camera* camera = EmberOgre::getSingleton(   ).getMainCamera(   )->getCamera(   );
          // const WFMath::AxisBox<2>& worldSize = EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getTerrainInfo(   ).getWorldSizeInIndices(   );
          
           //-------------------------------------- LOAD GRASS --------------------------------------
           //Create and configure a new PagedGeometry instance for grass
          
           mGrass = new ::PagedGeometry::PagedGeometry(  camera,   32 );
           mGrass->setBounds(  bounds );
           mGrass->addDetailLevel<GrassPage>(  100 );
          
           //Create a GrassLoader object
           mGrassLoader = new GrassLoader<GrassLayer>(  mGrass );
           mGrass->setPageLoader(  mGrassLoader ); //Assign the "treeLoader" to be used to load geometry for the PagedGeometry instance
          
           mGrassLoader->setHeightFunction(  &getTerrainHeight );
          
           //Add some grass to the scene with GrassLoader::addLayer(   )
           GrassLayer *l = mGrassLoader->addLayer(  "grass" );
          
           //Configure the grass layer properties (  size,   density,   animation properties,   fade settings,   etc. )
           l->setMinimumSize(  1.0f,   1.0f );
           l->setMaximumSize(  1.5f,   1.5f );
           l->setAnimationEnabled(  true ); //Enable animations
           l->setSwayDistribution(  10.0f ); //Sway fairly unsynchronized
           l->setSwayLength(  0.5f ); //Sway back and forth 0.5 units in length
           l->setSwaySpeed(  0.5f ); //Sway 1/2 a cycle every second
           l->setDensity(  1.5f ); //Relatively dense grass
           l->setFadeTechnique(  FADETECH_GROW ); //Distant grass should slowly raise out of the ground when coming in range
           l->setRenderTechnique(  GRASSTECH_SPRITE ); //Draw grass as scattered quads
          
           l->setHeightRange(  0.001f );
          
           //This sets a color map to be used when determining thfalsee color of each grass quad. setMapBounds(   )
           //is used to set the area which is affected by the color map. Here,   "terrain_texture.jpg" is used
           //to color the grass to match the terrain under it.
           l->setColorMap(  shadowMap.get(   ) );
           l->setDensityMap(  densityMap.get(   ) );
           l->setMapBounds(  bounds ); //(  0,  0 )-(  1500,  1500 ) is the full boundaries of the terrain
          
          // //-------------------------------------- LOAD GRASS --------------------------------------
          // //Create and configure a new PagedGeometry instance for grass
          // mGrass2 = new PagedGeometry(  camera,   32 );
          // mGrass2->addDetailLevel<GrassPage>(  100 );
          //
          // //Create a GrassLoader object
          // mGrassLoader2 = new GrassLoader(  mGrass2 );
          // mGrass2->setPageLoader(  mGrassLoader2 ); //Assign the "treeLoader" to be used to load geometry for the PagedGeometry instance
          //
          // //Supply a height function to GrassLoader so it can calculate grass Y values
          // //HeightFunction::initialize(  sceneMgr );
          // mGrassLoader2->setHeightFunction(  &getTerrainHeight );
          //
          // //Add some grass to the scene with GrassLoader::addLayer(   )
          // GrassLayer *l2 = mGrassLoader2->addLayer(  "grass" );
          //
          // //Configure the grass layer properties (  size,   density,   animation properties,   fade settings,   etc. )
          // l2->setMinimumSize(  1.0f,   1.0f );
          // l2->setMaximumSize(  1.5f,   1.5f );
          // l2->setAnimationEnabled(  true ); //Enable animations
          // l2->setSwayDistribution(  10.0f ); //Sway fairly unsynchronized
          // l2->setSwayLength(  0.5f ); //Sway back and forth 0.5 units in length
          // l2->setSwaySpeed(  0.5f ); //Sway 1/2 a cycle every second
          // l2->setDensity(  1.5f ); //Relatively dense grass
          // l2->setFadeTechnique(  FADETECH_ALPHA ); //Distant grass should slowly raise out of the ground when coming in range
          // l2->setRenderTechnique(  GRASSTECH_SPRITE ); //Draw grass as scattered quads
          //
          // //This sets a color map to be used when determining the color of each grass quad. setMapBounds(   )
          // //is used to set the area which is affected by the color map. Here,   "terrain_texture.jpg" is used
          // //to color the grass to match the terrain under it.
          // //l2->setColorMap(  "terrain_texture.jpg" );
          // l2->setMapBounds(  TBounds(  mExtent.lowCorner(   ).x(   ),   mExtent.lowCorner(   ).y(   ),   mExtent.highCorner(   ).x(   ),   mExtent.highCorner(   ).y(   ) ) );
          }
          
          
          // void FoliageArea::placeGrass(  const std::string& type,   const TerrainPosition& position )
          // {
          // float scaleFactor = Ogre::Math::RangeRandom(  1.85,   2.15 );
          // const Ogre::Vector3 scale(  
          // scaleFactor,   scaleFactor,   scaleFactor );
          // placeGrass(  type,   position,   scale );
          // }
          //
          //
          // void FoliageArea::placeGrass(  const std::string& type,   const TerrainPosition& position,   const Ogre::Vector3& scale )
          // {
          // Terrain::TerrainGenerator* terrain = EmberOgre::getSingleton(   ).getTerrainGenerator(   );
          // Ogre::Vector3 ogrePosition = Atlas2Ogre(  position );
          // ogrePosition.y = terrain->getHeight(  position );
          // placeGrass(  type,   ogrePosition,   scale );
          // }
          //
          // void FoliageArea::placeGrass(  const std::string& type,   const Ogre::Vector3& position,   const Ogre::Vector3& scale )
          // {
          // Ogre::Quaternion orientation;
          // orientation.FromAngleAxis(  
          // Ogre::Degree(  Ogre::Math::RangeRandom(  0,   359 ) ),  
          // Ogre::Vector3::UNIT_Y );
          // placeGrass(  type,   position,   scale,   orientation );
          // }
          //
          // void FoliageArea::placeGrass(  const std::string& type,   const Ogre::Vector3& position,   const Ogre::Vector3& scale,   const Ogre::Quaternion& orientation )
          // {
          // Ogre::Entity* currentEnt;
          // currentEnt = mFoliage.getEntity(  type );
          // if (  currentEnt ) {
          // // std::stringstream ss;
          // // ss << "Adding foliage of type '" << type << "' at x:" << position.x << " y:" << position.y << " z:" << position.z;
          // // S_LOG_VERBOSE(  ss.str(   ) );
          //
          // mStaticGeom->addEntity(  currentEnt,   position,   orientation,   scale );
          // }
          // }
          
          // void FoliageArea::build(   )
          // {
          // assert(  mStaticGeom );
          // try {
          // mStaticGeom->build(   );
          // setVisible(  true );
          //
          // } catch (  const Ogre::Exception& e ) {
          // S_LOG_FAILURE(  "Got error when building static geometry for foliage. Expection: " << e.getFullDescription(   ) );
          // }
          // // mStaticGeom->dump(  "/home/erik/skit/staticgeom.txt" );
          // }
          
          
     277  void FoliageArea::frameStarted(  const Ogre::Real & timeElapsed )
          {
          
           mGrass->update(   );
          // mGrass2->update(   );
          
          // //don't wave if we're not visible,   not entirely sure that this won't look strange,   I don't think so
          // if (  mVisible ) {
          // waveGrass(  timeElapsed );
          // }
          
          }
          
          
          
          
          
          
          // void FoliageArea::waveGrass(  Ogre::Real timeElapsed )
          // {
          // static Ogre::Real xinc = Ogre::Math::PI * 0.4;
          // static Ogre::Real zinc = Ogre::Math::PI * 0.55;
          // static Ogre::Real xpos = Ogre::Math::RangeRandom(  -Ogre::Math::PI,   Ogre::Math::PI );
          // static Ogre::Real zpos = Ogre::Math::RangeRandom(  -Ogre::Math::PI,   Ogre::Math::PI );
          //
          // xpos += xinc * timeElapsed;
          // zpos += zinc * timeElapsed;
          //
          // // Update vertex program parameters by binding a value to each renderable
          // static Ogre::Vector4 offset(  0,  0,  0,  0 );
          //
          // Ogre::StaticGeometry::RegionIterator rit = mStaticGeom->getRegionIterator(   );
          // while (  rit.hasMoreElements(   ) )
          // {
          // Ogre::StaticGeometry::Region* reg = rit.getNext(   );
          //
          // // a little randomness
          // xpos += reg->getCentre(   ).x * 0.001;
          // zpos += reg->getCentre(   ).z * 0.001;
          // offset.x = Ogre::Math::Sin(  xpos ) * 0.05;
          // offset.z = Ogre::Math::Sin(  zpos ) * 0.05;
          //
          // Ogre::StaticGeometry::Region::LODIterator lodit = reg->getLODIterator(   );
          // while (  lodit.hasMoreElements(   ) )
          // {
          // Ogre::StaticGeometry::LODBucket* lod = lodit.getNext(   );
          // Ogre::StaticGeometry::LODBucket::MaterialIterator matit =
          // lod->getMaterialIterator(   );
          // while (  matit.hasMoreElements(   ) )
          // {
          // Ogre::StaticGeometry::MaterialBucket* mat = matit.getNext(   );
          // Ogre::StaticGeometry::MaterialBucket::GeometryIterator geomit =
          // mat->getGeometryIterator(   );
          // while (  geomit.hasMoreElements(   ) )
          // {
          // Ogre::StaticGeometry::GeometryBucket* geom = geomit.getNext(   );
          // geom->setCustomParameter(  OFFSET_PARAM,   offset );
          //
          // }
          // }
          // }
          // }
          //
          // }
          
          //Gets the height of the terrain at the specified x/z coordinate
          //The userData parameter isn't used in this implementation of a height function,   since
          //there's no need for extra data other than the x/z coordinates.
     345  float getTerrainHeight(  const float x,   const float z,   void *userData ){
          // return 1;
           return EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getAdapter(   )->getHeightAt(  x,   z );
          }
          
          }
          
          }

./components/ogre/environment/FoliageArea.h

       1  //
          // C++ Interface: FoliageArea
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREFOLIAGEAREA_H
          #define EMBEROGREFOLIAGEAREA_H
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "components/ogre/MathConverter.h"
          #include "pagedgeometry/include/GrassLoader.h"
          
          namespace PagedGeometry {
          
      31  class PagedGeometry;
          // class GrassLoader<GrassLayer>;
          // class GrassLayer;
          }
          
          namespace EmberOgre {
          
          namespace Environment {
          
      40  class Foliage;
          /**
          @author Erik Hjortsberg
          Represents an area of foliage,   normally mapped to one TerrainPage.
          Don't create this class directly,   instead use the Foliage class.
          
          Start by placing the foliage through the placeGrass methods.
          Once that's done,   call the build method,   which will create the static geometry. Once build has been called,   calls to placeGrass won't do anything unless build is called again.
          */
      49  class FoliageArea {
          public:
      51   FoliageArea(  Foliage& foliage,   Ogre::SceneManager& sceneManager,   const std::string name );
          
      53   ~FoliageArea(   );
          
      55   void init(  const WFMath::AxisBox<2>& extent,   Ogre::TexturePtr densityMap,   Ogre::TexturePtr shadowMap );
          
          
           /**
           * sets the visibility of the area
           * @param visible
           */
      62   void setVisible(  bool visible );
          
      64   void frameStarted(  const Ogre::Real & timeElapsed );
          
          /* void placeGrass(  const std::string& type,   const TerrainPosition& position );
           void placeGrass(  const std::string& type,   const TerrainPosition& position,   const Ogre::Vector3& scale );
           void placeGrass(  const std::string& type,   const Ogre::Vector3& position,   const Ogre::Vector3& scale );
           void placeGrass(  const std::string& type,   const Ogre::Vector3& position,   const Ogre::Vector3& scale,   const Ogre::Quaternion& orientation );*/
          
          
           /**
           * generates and compiles the undervegetation
           * this might take a while
           */
      76   void build(   );
          
          
          
          protected:
      81   static Ogre::Real mXinc;
      82   static Ogre::Real mZinc;
      83   Ogre::Real mXpos;
      84   Ogre::Real mZpos;
      85   const std::string& mName;
          
      87   WFMath::AxisBox<2> mExtent;
          
      89   Ogre::SceneManager& mSceneMgr;
          
      91   Foliage& mFoliage;
          
      93   bool mVisible;
          
          // void waveGrass(  Ogre::Real timeElapsed );
          
      97   TerrainPosition mExtentMin,   mExtentMax;
          
          // Ogre::StaticGeometry* mStaticGeom;
          
     101   PagedGeometry::PagedGeometry *mGrass,   *mGrass2;
     102   PagedGeometry::GrassLoader<PagedGeometry::GrassLayer> *mGrassLoader,   *mGrassLoader2;
          
     104   void createGrass(  Ogre::TexturePtr densityMap,   Ogre::TexturePtr shadowMap );
          };
          
     107  float getTerrainHeight(  const float x,   const float z,   void *userData = 0 );
          
          }
          
          }
          
          #endif

./components/ogre/environment/Forest.cpp

       1  //
          // C++ Implementation: Forest
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "Forest.h"
          
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/config/ConfigService.h"
          #include "pagedgeometry/include/PagedGeometry.h"
          #include "pagedgeometry/include/TreeLoader3D.h"
          #include "pagedgeometry/include/BatchPage.h"
          #include "pagedgeometry/include/ImpostorPage.h"
          #include "pagedgeometry/include/DummyPage.h"
          #include "pagedgeometry/include/BatchedGeometry.h"
          
          #include "../AvatarCamera.h"
          #include "../EmberOgre.h"
          #include "../terrain/TerrainGenerator.h"
          #include "../terrain/ISceneManagerAdapter.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
      48  Forest::Forest(   )
          : mTrees(  0 )
          ,   mTreeLoader(  0 )
          {
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          }
          
          
      56  Forest::~Forest(   )
          {
           delete mTreeLoader;
           delete mTrees;
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
          }
          
      63  void Forest::initialize(   )
          {
           S_LOG_INFO(  "Initializing forest." );
           const WFMath::AxisBox<2>& worldSize = EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getTerrainInfo(   ).getWorldSizeInIndices(   );
           Ogre::Camera* camera = EmberOgre::getSingleton(   ).getMainCamera(   )->getCamera(   );
          
           mTrees = new PagedGeometry::PagedGeometry(   );
           mTrees->setCamera(  camera ); //Set the camera so PagedGeometry knows how to calculate LODs
           mTrees->setPageSize(  64 ); //Set the size of each page of geometry
           mTrees->setInfinite(   ); //Use infinite paging mode
          // mTrees->addDetailLevel<PagedGeometry::BatchPage>(  150,   50 ); //Use batches up to 150 units away,   and fade for 30 more units
           mTrees->addDetailLevel<PagedGeometry::DummyPage>(  100,   0 ); //Use batches up to 150 units away,   and fade for 30 more units
           mTrees->addDetailLevel<PagedGeometry::ImpostorPage>(  500,   50 ); //Use impostors up to 400 units,   and for for 50 more units
          
           //Create a new TreeLoader2D object
           mTreeLoader = new PagedGeometry::TreeLoader3D(  mTrees,   Atlas2Ogre(  worldSize ) );
           mTrees->setPageLoader(  mTreeLoader ); //Assign the "treeLoader" to be used to load geometry for the PagedGeometry instance
          }
          
      82  void Forest::addTree(  Ogre::Entity *entity,   const Ogre::Vector3 &position,   Ogre::Degree yaw,   Ogre::Real scale )
          {
           if (  mTreeLoader )
           {
           S_LOG_VERBOSE(  "Adding tree of entity type " << entity->getMesh(   )->getName(   ) << " to position x: " << position.x << " y: " << position.y << " z: " << position.z << " and scale " << scale );
           mTreeLoader->addTree(  entity,   position,   yaw,   scale );
           } else {
           S_LOG_WARNING(  "Could not add tree before the forest has been initialized." );
           }
          }
          
      93  bool Forest::frameStarted(  const Ogre::FrameEvent & evt )
          {
           if (  mTrees ) {
           try {
           mTrees->update(   );
           } catch (  const Ogre::Exception& ex )
           {
           S_LOG_FAILURE(  "Error when updating forest. Will disable forest.\n"<< ex.what(   ) );
           delete mTreeLoader;
           delete mTrees;
           }
           }
           return true;
          }
          
          }
          
          }

./components/ogre/environment/Forest.h

       1  //
          // C++ Interface: Forest
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_ENVIRONMENTFOREST_H
          #define EMBEROGRE_ENVIRONMENTFOREST_H
          
          #include <OgreMath.h>
          #include <OgreFrameListener.h>
          
          namespace PagedGeometry {
      30  class PagedGeometry;
      31  class TreeLoader3D;
          }
          
          namespace Ogre
          {
      36   class Entity;
      37   class Vector3;
          }
      39  namespace EmberOgre {
          
          namespace Environment {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
          class Forest : public Ogre::FrameListener
          {
          public:
           Forest(   );
          
           ~Forest(   );
          
           void initialize(   );
          
           void addTree(  Ogre::Entity *entity,   const Ogre::Vector3 &position,   Ogre::Degree yaw = Ogre::Degree(  0 ),   Ogre::Real scale = 1.0f );
          
           bool frameStarted(  const Ogre::FrameEvent & evt );
          
          protected:
          
          
           PagedGeometry::PagedGeometry *mTrees;
           PagedGeometry::TreeLoader3D *mTreeLoader;
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/environment/LensFlare.cpp

       1  //
          // C++ Implementation: LensFlare
          //
          // Description:
          //
          //
          // Author : David de Lorenzo
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "LensFlare.h"
          #include "../EmberEntity.h"
          
          using namespace Ogre;
          
          namespace EmberOgre {
          
          namespace Environment {
          
          
          /* ------------------------------------------------------------------------- */
          /// Constructor
          /// @param LightPosition The 3D position of the Light,   relative to the camera.
          /// @param camera The camera on which the lensflare effect will appear.
          /// @param SceneMgr Pointer on the SceneManager.
          /* ------------------------------------------------------------------------- */
      39  LensFlare::LensFlare(  Camera* camera,   SceneManager* SceneMgr ) : mLightNode(  0 )
          {
           mSceneMgr = SceneMgr;
           mCamera = camera;
           mHidden = true;
          }
          
          /* ------------------------------------------------------------------------- */
          /// Destructor
          /* ------------------------------------------------------------------------- */
      49  LensFlare::~LensFlare(   )
          {
           if (  mLightNode ) {
           mLightNode->detachObject(  mHaloSet );
           mLightNode->detachObject(  mBurstSet );
           mSceneMgr->destroyBillboardSet(  mHaloSet );
           mSceneMgr->destroyBillboardSet(  mBurstSet );
          
          /* Ogre::SceneNode* parent = static_cast<Ogre::SceneNode*>(  mNode->getParent(   ) );
           if (  parent ) {
           parent->removeAndDestroyChild(  mNode->getName(   ) );
           } else {
           mNode->getCreator(   )->destroySceneNode(  mNode->getName(   ) );
           }*/
           }
          }
          
      66  void LensFlare::setNode(  Ogre::SceneNode* node )
          {
           mLightNode = node;
          }
          
      71  void LensFlare::initialize(   )
          {
           createLensFlare(   );
          }
          
          
          /* ------------------------------------------------------------------------- */
          /// this function creates and shows all the LensFlare graphical elements.
          /* ------------------------------------------------------------------------- */
      80  bool LensFlare::createLensFlare(   )
          {
           Real LF_scale = 150;
           try {
           // -----------------------------------------------------
           // We create 2 sets of billboards for the lensflare
           // -----------------------------------------------------
           mHaloSet = mSceneMgr->createBillboardSet(  "halo" );
           mHaloSet->setMaterialName(  "/global/environment/lensflare/halo" );
           mHaloSet->setCullIndividually(  true );
           mHaloSet->setRenderQueueGroup(  RENDER_QUEUE_SKIES_LATE );
          
           mBurstSet= mSceneMgr->createBillboardSet(  "burst" );
           mBurstSet->setMaterialName(  "/global/environment/lensflare/burst" );
           mBurstSet->setCullIndividually(  true );
           mBurstSet->setRenderQueueGroup(  RENDER_QUEUE_SKIES_LATE );
           } catch (  const Ogre::Exception& ) {
           S_LOG_FAILURE(  "Couldn't load lens flare,   you are probably missing the needed materials." );
           return false;
           }
           // The node is located at the light source.
           //mLightNode = mSceneMgr->getRootSceneNode(   )->createChildSceneNode(   );
          
           mLightNode->attachObject(  mBurstSet );
           mLightNode->attachObject(  mHaloSet );
          
           // -------------------------------
           // Creation of the Halo billboards
           // -------------------------------
           Billboard* LF_Halo1 = mHaloSet->createBillboard(  0,  0,  0 );
           LF_Halo1->setDimensions(  LF_scale*0.5,  LF_scale*0.5 );
           Billboard* LF_Halo2 = mHaloSet->createBillboard(  0,  0,  0 );
           LF_Halo2->setDimensions(  LF_scale,  LF_scale );
           Billboard* LF_Halo3 = mHaloSet->createBillboard(  0,  0,  0 );
           LF_Halo3->setDimensions(  LF_scale*0.25,  LF_scale*0.25 );
          
          
           // -------------------------------
           // Creation of the "Burst" billboards
           // -------------------------------
           Billboard* LF_Burst1 = mBurstSet->createBillboard(  0,  0,  0 );
           LF_Burst1->setDimensions(  LF_scale*0.25,  LF_scale*0.25 );
           Billboard* LF_Burst2 = mBurstSet->createBillboard(  0,  0,  0 );
           LF_Burst2->setDimensions(  LF_scale*0.5,  LF_scale*0.5 );
           Billboard* LF_Burst3 = mBurstSet->createBillboard(  0,  0,  0 );
           LF_Burst3->setDimensions(  LF_scale*0.25,  LF_scale*0.25 );
          
           return true;
          }
          
     130  const Ogre::Vector3& LensFlare::getLightPosition(   ) const
          {
           return mLightNode->getWorldPosition(   );
          }
          
          
          /* -------------------------------------------------------------------------- */
          /// This function updates the lensflare effect.
          /** This function should be called by your frameListener.
          */
          /* -------------------------------------------------------------------------- */
     141  void LensFlare::update(   )
          {
           if (  mHidden || !mLightNode ) return;
          
           /// If the Light is out of the Camera field Of View,   the lensflare is hidden.
           if (  !mCamera->isVisible(  getLightPosition(   ) ) )
           {
           mHaloSet->setVisible(  false );
           mBurstSet->setVisible(  false );
           return;
           }
          
           Vector3 lightToCamera = mCamera->getDerivedPosition(   ) - getLightPosition(   );
          
           Vector3 CameraVect = lightToCamera.length(   ) * mCamera->getDerivedDirection(   );
           CameraVect += mCamera->getDerivedPosition(   );
          
           // The LensFlare effect takes place along this vector.
           Vector3 LFvect = (  CameraVect - getLightPosition(   ) );
          
          // LFvect += Vector3(  -64,  -64,  0 ); // sprite dimension (  to be adjusted,   but not necessary )
          
           // The different sprites are placed along this line.
           mHaloSet->getBillboard(  0 )->setPosition(   LFvect );
           mHaloSet->getBillboard(  1 )->setPosition(   LFvect*0.725 );
           mHaloSet->getBillboard(  2 )->setPosition(   LFvect*0.250 );
          
           mBurstSet->getBillboard(  0 )->setPosition(   LFvect*0.833 );
           mBurstSet->getBillboard(  1 )->setPosition(   LFvect*0.500 );
           mBurstSet->getBillboard(  2 )->setPosition(   LFvect*0.320 );
          
           // We redraw the lensflare (  in case it was previouly out of the camera field,   and hidden )
           this->setVisible(  true );
          }
          
          /* ------------------------------------------------------------------------- */
          /// This function shows (  or hide ) the lensflare effect.
          /* ------------------------------------------------------------------------- */
     179  void LensFlare::setVisible(  bool visible )
          {
           if (  mLightNode ) {
           mHaloSet->setVisible(  visible );
           mBurstSet->setVisible(  visible );
           mHidden = !visible;
           }
          }
          
          
          /* ------------------------------------------------------------------------- */
          /// This function updates the light source position.
          /** This function can be used if the light source is moving.*/
          /* ------------------------------------------------------------------------- */
          // void LensFlare::setLightPosition(  Vector3 pos )
          // {
          // mLightPosition = pos;
          // if (  mNode ) {
          // mNode->setPosition(  mLightPosition );
          // }
          // }
          
          
          /* ------------------------------------------------------------------------- */
          /// This function changes the colour of the burst.
          /* ------------------------------------------------------------------------- */
     205  void LensFlare::setBurstColour(  ColourValue color )
          {
           if (  mLightNode ) {
           mBurstSet->getBillboard(  0 )->setColour(  color );
           mBurstSet->getBillboard(  1 )->setColour(  color*0.8 );
           mBurstSet->getBillboard(  2 )->setColour(  color*0.6 );
           }
          }
          
          /* ------------------------------------------------------------------------- */
          /// This function changes the colour of the halos.
          /* ------------------------------------------------------------------------- */
     217  void LensFlare::setHaloColour(  ColourValue color )
          {
           if (  mLightNode ) {
           mHaloSet->getBillboard(  0 )->setColour(  color*0.8 );
           mHaloSet->getBillboard(  1 )->setColour(  color*0.6 );
           mHaloSet->getBillboard(  2 )->setColour(  color );
           }
          }
          
          
          }
          
          }

./components/ogre/environment/LensFlare.h

       1  //
          // C++ Interface: LensFlare
          //
          // Description:
          //
          //
          // Author : David de Lorenzo
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRELENSFLARE_H
          #define EMBEROGRELENSFLARE_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
          
          /* ------------------------------------------------------------------------- */
          /// A lens Flare effect.
          /**
          This class will create a lensflare effect,   between The light position and the
          camera position.
          Some functions will allow to change the lensflare color effect,   in case of coloured
          light,   for instance.
          */
          /* ------------------------------------------------------------------------- */
      42  class LensFlare
          {
          public:
      45   LensFlare(  Ogre::Camera* camera,   Ogre::SceneManager* SceneMgr );
      46   virtual ~LensFlare(   );
      47   bool createLensFlare(   );
      48   void update(   );
      49   void setVisible(  bool visible );
          // void setLightPosition(  Ogre::Vector3 pos );
      51   void setNode(  Ogre::SceneNode* node );
      52   void setHaloColour(  Ogre::ColourValue color );
      53   void setBurstColour(  Ogre::ColourValue color );
      54   void initialize(   );
          
          
          protected:
      58   Ogre::SceneManager* mSceneMgr;
      59   Ogre::Camera* mCamera;
      60   Ogre::ColourValue mColour;
           //Ogre::SceneNode* mNode;
      62   Ogre::BillboardSet* mHaloSet;
      63   Ogre::BillboardSet* mBurstSet;
           //Ogre::Vector3 mLightPosition;
      65   Ogre::SceneNode* mLightNode;
      66   bool mHidden;
          
      68   const Ogre::Vector3& getLightPosition(   ) const;
          };
          
          }
          
          }
          
          #endif

./components/ogre/environment/Sky.cpp

       1  //
          // C++ Implementation: Sky
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Sky.h"
          #include "../EmberOgrePrerequisites.h"
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include "../EmberOgre.h"
          #include "../terrain/TerrainGenerator.h"
          #include "framework/Tokeniser.h"
          #include "../AvatarCamera.h"
          
          
          
          #include <sigc++/object_slot.h>
          
          #include "CaelumSky.h"
          
          
          
          namespace EmberOgre {
          
          namespace Environment {
          
      44  Sky::Sky(  Ogre::Camera* camera,   Ogre::SceneManager* sceneMgr )
          {
          
           createSimpleSky(  camera,   sceneMgr );
          
           updateFogValuesFromConfig(   );
           Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->EventChangedConfigItem.connect(  sigc::mem_fun(  *this,   &Sky::ConfigService_EventChangedConfigItem ) );
          }
          
          
      54  void Sky::createSimpleSky(  Ogre::Camera* camera,   Ogre::SceneManager* sceneMgr ) {
           sceneMgr->setSkyBox(  true,   "/global/environment/sky/day",   253 );
          
           updateFogValuesFromConfig(   );
           Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->EventChangedConfigItem.connect(  sigc::mem_fun(  *this,   &Sky::ConfigService_EventChangedConfigItem ) );
          }
          
          
      62  Sky::~Sky(   )
          {
          }
          
      66  void Sky::updateFogValuesFromConfig(   )
          {
           Ogre::ColourValue fadeColour(  0.9,  0.9,  0.9 );
           float fogstartDistance = 96; //default for fog
           float fogmaxDistance = 256; //default for fog gradient endind (  i.e. where the fog is at 100% )
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "graphics",   "fogstart" ) ) {
           fogstartDistance = static_cast<double>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "graphics",   "fogstart" ) );
           }
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "graphics",   "fogmax" ) ) {
           fogmaxDistance = static_cast<double>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "graphics",   "fogmax" ) );
           }
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "graphics",   "fogcolour" ) ) {
           varconf::Variable var = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "graphics",   "fogcolour" );
           std::string stringValue(  var );
          
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  stringValue );
           std::string r = tokeniser.nextToken(   );
           std::string b = tokeniser.nextToken(   );
           std::string g = tokeniser.nextToken(   );
          
           if (  r != "" && b != "" && g != "" ) {
           fadeColour = Ogre::ColourValue(  Ogre::StringConverter::parseReal(  r ),   Ogre::StringConverter::parseReal(  g ),   Ogre::StringConverter::parseReal(  b ) );
           }
           }
          
           setFogValues(  fogstartDistance,   fogmaxDistance,   fadeColour );
          }
          
      95  void Sky::ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key )
          {
           if (  section == "graphics" ) {
           if (  key == "fogstart" || key == "fogcolour" || key == "fogmax" ) {
           updateFogValuesFromConfig(   );
           }
           }
          }
          
     104  void Sky::setFogValues(  float start,   float end,   Ogre::ColourValue colour )
          {
           Ogre::SceneManager* sceneMgr = EmberOgre::getSingleton(   ).getSceneManager(   );
           sceneMgr->setFog(   Ogre::FOG_LINEAR,   colour,   .001,   start,   end );
          
          // EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getTerrainOptions(   ).fogEnd = fogendDistance * fogendDistance;
          
          
           try {
           //set up values for the splatting shader and the linear fog shader
           Ogre::HighLevelGpuProgramPtr splatProgram = Ogre::HighLevelGpuProgramManager::getSingleton(   ).getByName(  "splat_cg" );
           if (  !splatProgram.isNull(   ) && splatProgram->isSupported(   ) ) {
           splatProgram->load(   );
           // splatProgram->createParameters(   );
           Ogre::GpuProgramParametersSharedPtr fpParams = splatProgram->getDefaultParameters(   );
           fpParams->setAutoAddParamName(  true );
           Ogre::ColourValue fogColour = sceneMgr->getFogColour(   );
           fpParams->setNamedConstant(  "iFogColour",   fogColour );
           }
           } catch (  ... ) {}
          
           try {
           Ogre::HighLevelGpuProgramPtr fogProgram = Ogre::HighLevelGpuProgramManager::getSingleton(   ).getByName(  "fog_linear_vp" );
           if (  !fogProgram.isNull(   ) && fogProgram->isSupported(   ) ) {
           fogProgram->load(   );
           // fogProgram->createParameters(   );
           Ogre::GpuProgramParametersSharedPtr vpParams = fogProgram->getDefaultParameters(   );
           vpParams->setAutoAddParamName(  true );
           Ogre::ColourValue fogColour = sceneMgr->getFogColour(   );
           vpParams->setNamedAutoConstant(  "worldViewProj",   Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX );
           //get the values for the linear fog from the SceneManager
           vpParams->setNamedConstant(  "iFogStart",   sceneMgr->getFogStart(   ) );
           vpParams->setNamedConstant(  "iFogMax",   sceneMgr->getFogEnd(   ) );
           }
           } catch (  ... ) {}
          
          }
          
          
          }
          
          }

./components/ogre/environment/Sky.h

       1  //
          // C++ Interface: Sky
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef DIMEOGRESKY_H
          #define DIMEOGRESKY_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          // ------------------------------
          // Include sigc header files
          // ------------------------------
          // #include <sigc++/object.h>
          // #include <sigc++/connection.h>
          #include <sigc++/trackable.h>
          
          #include <OgreColourValue.h>
          
          
          namespace EmberOgre {
          
          namespace Environment {
          
          
          /**
          @author Erik Hjortsberg
          */
      46  class Sky: public sigc::trackable
          {
          public:
      49   Sky(  ::Ogre::Camera* camera,   Ogre::SceneManager* sceneMgr );
          
      51   ~Sky(   );
      52   void updateFogValuesFromConfig(   );
          private:
          
      55   void createSimpleSky(  Ogre::Camera* camera,   Ogre::SceneManager* sceneMgr );
          
      57   void setFogValues(  float start,   float end,   Ogre::ColourValue colour );
      58   void ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key );
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/environment/Sun.cpp

          //
          // C++ Implementation: Sun
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Sun.h"
          
          #include "framework/Tokeniser.h"
          
          #include "framework/ConsoleBackend.h"
          #include "../EmberOgre.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
          
      35  Sun::Sun(  Ogre::Camera* camera,   Ogre::SceneManager* sceneMgr ):
          SetSunPosition(  "setsunposition",   this,   "Set the position of the sun." )
      37  ,  SetSunColour(  "setsuncolour",   this,   "Set the colour of the sun." )
          ,  SetAmbientLight(  "setambientlight",   this,   "Set the ambient light of the world." )
          ,  mLensFlare(  camera,   sceneMgr )
          {
           mSun = sceneMgr->createLight(  "SunLight" );
           mSun->setType(  Ogre::Light::LT_DIRECTIONAL );
          
           if (  sceneMgr->hasSceneNode(  "SunNode" ) ) {
           mSunNode = sceneMgr->getSceneNode(   "SunNode" );
           } else {
           mSunNode = sceneMgr->getRootSceneNode (   )->createChildSceneNode(  "SunNode" );
           }
          
           mSunNode->attachObject(  mSun );
          
           mLensFlare.setNode(  mSunNode  );
           mLensFlare.initialize(   );
          
          ///disable for now
          // try {
          // Ogre::ParticleSystem* sunParticle = sceneMgr->createParticleSystem(  "Sun",   "Space/Sun" );
          // mSunNode->attachObject(  sunParticle );
          // } catch (  const Ogre::Exception& ex ) {
          // S_LOG_FAILURE(  "Error when creating sun. Message: " << ex.getFullDescription(   ) );
          // }
          
           setSunPosition(  Ogre::Vector3(  -500,  300,  -350 ) );
           setSunColour(  Ogre::ColourValue(  1,   1,   0.7 ) ); //yellow
           //mSun->setSpecularColour(  1,   1,   0.7 ); //yellow
           mSun->setCastShadows(  true );
           mSun->setAttenuation(  1000000,   1,   0,   0 );
          
           // sceneMgr->setAmbientLight(  Ogre::ColourValue(  0.5,   0.5,   0.35 ) );
          // setAmbientLight(  Ogre::ColourValue(  0.6,   0.6,   0.6 ) );
          
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
           mLensFlare.setVisible(  true );
          
          }
          
          
      78  Sun::~Sun(   )
          {
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
          
          }
          
      84  void Sun::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  SetSunPosition == command )
           {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string x = tokeniser.nextToken(   );
           std::string y = tokeniser.nextToken(   );
           std::string z = tokeniser.nextToken(   );
          
           if (  x == "" || y == "" || z == "" ) {
           return;
           } else {
           Ogre::Vector3 position(  Ogre::StringConverter::parseReal(  x ),  Ogre::StringConverter::parseReal(  y ),  Ogre::StringConverter::parseReal(  z ) );
           setSunPosition(  position );
           }
           } else if (  SetSunColour == command )
           {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string r = tokeniser.nextToken(   );
           std::string b = tokeniser.nextToken(   );
           std::string g = tokeniser.nextToken(   );
          
           if (  r == "" || b == "" || g == "" ) {
           return;
           } else {
           Ogre::ColourValue colour(  Ogre::StringConverter::parseReal(  r ),  Ogre::StringConverter::parseReal(  b ),  Ogre::StringConverter::parseReal(  g ) );
           setSunColour(  colour );
           }
          
           } else if (  SetAmbientLight == command )
           {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string r = tokeniser.nextToken(   );
           std::string b = tokeniser.nextToken(   );
           std::string g = tokeniser.nextToken(   );
          
           if (  r == "" || b == "" || g == "" ) {
           return;
           } else {
           Ogre::ColourValue colour(  Ogre::StringConverter::parseReal(  r ),  Ogre::StringConverter::parseReal(  b ),  Ogre::StringConverter::parseReal(  g ) );
           setAmbientLight(  colour );
           }
          
           }
          }
          
     133  bool Sun::frameEnded(  const Ogre::FrameEvent & event )
          {
           mLensFlare.update(   );
           return true;
          }
          
          
          
     141  void Sun::setSunPosition(  const Ogre::Vector3& position ) {
           //mSun->setPosition(  position );
           mSunNode->setPosition(  position );
           Ogre::Vector3 dir = -mSunNode->getPosition(   );
           dir.normalise(   );
           mSun->setDirection(  dir );
           EventUpdatedSunPosition.emit(  this,   position );
          }
          
     150  void Sun::setSunColour(  const Ogre::ColourValue& colour ) {
           mSun->setDiffuseColour(  colour );
           mLensFlare.setBurstColour(  colour );
           mLensFlare.setHaloColour(  colour );
           EventUpdatedSunColour.emit(  this,   colour );
          }
          
     157  void Sun::setAmbientLight(  const Ogre::ColourValue& colour ) {
           EmberOgre::getSingleton(   ).getSceneManager(   )->setAmbientLight(  colour );
           EventUpdatedAmbientLight.emit(  this,   colour );
          }
          
          }
          
          }

./components/ogre/environment/Sun.h

       1  //
          // C++ Interface: Sun
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef DIMEOGRESUN_H
          #define DIMEOGRESUN_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          
          #include <sigc++/signal.h>
          
          #include "framework/ConsoleObject.h"
          
          #include "LensFlare.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
          /**
          @author Erik Hjortsberg
          */
      42  class Sun :
      43  public Ember::ConsoleObject
      44  ,   public Ogre::FrameListener
          {
          public:
      47   Sun(  Ogre::Camera* camera,   Ogre::SceneManager* sceneMgr );
          
      49   ~Sun(   );
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
      56   virtual void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           * emitted when the sun changes position
           */
      61   sigc::signal<void,   Sun*,   Ogre::Vector3> EventUpdatedSunPosition;
          
           /**
           * emitted when the sun changes colour
           */
      66   sigc::signal<void,   Sun*,   Ogre::ColourValue> EventUpdatedSunColour;
          
           /**
           * emitted when the world ambient light is changed
           */
      71   sigc::signal<void,   Sun*,   Ogre::ColourValue> EventUpdatedAmbientLight;
          
      73   const Ember::ConsoleCommandWrapper SetSunPosition;
      74   const Ember::ConsoleCommandWrapper SetSunColour;
      75   const Ember::ConsoleCommandWrapper SetAmbientLight;
          
          
           /**
           * changes the sun's position
           * @param position a new world position
           */
      82   void setSunPosition(  const Ogre::Vector3& position );
          
          
           /**
           * changes the colour of the sun light
           * @param colour
           */
      89   void setSunColour(  const Ogre::ColourValue& colour );
          
          
           /**
           * changes the ambient light
           * @param colour
           */
      96   void setAmbientLight(  const Ogre::ColourValue& colour );
          
          
      99   virtual bool frameEnded(  const Ogre::FrameEvent & event );
          
          protected:
     102   Ogre::Light* mSun;
          
     104   Ogre::SceneNode* mSunNode;
     105   LensFlare mLensFlare;
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/environment/Tree.cpp

       1  //
          // C++ Implementation: Tree
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "meshtree/TParameters.h"
          #include "meshtree/MeshTree.h"
          #include "../OgreIncludes.h"
          #include "Tree.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
          using namespace Ogre;
          
      35  Tree::Tree(   )
          {
          /* Material *pBarkMat = (  Material* )MaterialManager::getSingleton(   ).create(   "BarkTextMat"  );
           pBarkMat->getTechnique(  0 )->getPass(  0 )->createTextureUnitState(   "tree_bark.jpg"  );
           Material *pLeafMat = (  Material* )MaterialManager::getSingleton(   ).create(   "LeafTextMat"  );
          
           pLeafMat->getTechnique(  0 )->getPass(  0 )->createTextureUnitState(   "tree_leaves_pack1.tga"  );
           pLeafMat->getTechnique(  0 )->getPass(  0 )->setSceneBlending(  SBT_TRANSPARENT_ALPHA );
           pLeafMat->getTechnique(  0 )->getPass(  0 )->setCullingMode(  Ogre::CULL_NONE );
           pLeafMat->getTechnique(  0 )->getPass(  0 )->setManualCullingMode(  Ogre::MANUAL_CULL_NONE );
           pLeafMat->getTechnique(  0 )->getPass(  0 )->setLightingEnabled(  true );
           pLeafMat->getTechnique(  0 )->getPass(  0 )->setDiffuse(  0.9f,   1.0f,   0.9f,   1.0f ); // alpha not working with DX9 !!!!!!!
           pLeafMat->getTechnique(  0 )->getPass(  0 )->setAmbient(  0.5f,   0.6f,   0.5f );
          
           Material *pCoordFrameMat = (  Material* )MaterialManager::getSingleton(   ).create(   "CoordFrameMat"  );
           pCoordFrameMat->getTechnique(  0 )->getPass(  0 )->setSceneBlending(  SBT_TRANSPARENT_ALPHA );
           pCoordFrameMat->getTechnique(  0 )->getPass(  0 )->setLightingEnabled(  false );*/
          }
          
          
      55  Tree::~Tree(   )
          {
          }
          
          
      60  void Tree::makeMesh(  Ogre::String meshName,   Ogre::TParameters::TreeType type )
          {
           //pCoordFrameMat->getTechnique(  0 )->getPass(  0 )->setShadingMode(   );
          
          
           // Attach the entity to the root of the scene
          
          
           uchar u8Levels = 2;
           TParameters* pParams = new TParameters(  u8Levels );
           pParams->Set(   type  );
          
           uchar u8Season = 0;
           int iSeed = 0;
          
           Ogre::Tree* pTree = new Ogre::Tree(  "TreeTest",   pParams,   u8Season,   iSeed );
           pTree->Grow(   );
           MeshPtr pTreeMesh = pTree->CreateMesh(  meshName );
           pTreeMesh->getSubMesh(  0 )->setMaterialName(  "BarkTextMat" );
           if (  pTree->GetParameters(   )->GetLeaves(   ) > 0 )
           {
           pTreeMesh->getSubMesh(  1 )->setMaterialName(  "LeafTextMat" );
           if (  pTree->GetParameters(   )->GetTreeType(   ) == TParameters::Simple )
           pTreeMesh->getSubMesh(  2 )->setMaterialName(  "CoordFrameMat" );
           }
           else if (  pTree->GetParameters(   )->GetTreeType(   ) == TParameters::Simple )
           pTreeMesh->getSubMesh(  1 )->setMaterialName(  "CoordFrameMat" );
          
          
          }
          
          }
          
          }

./components/ogre/environment/Tree.h

       1  //
          // C++ Interface: Tree
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef TREE_H
          #define TREE_H
          
          /**
          @author Erik Hjortsberg
          */
          namespace EmberOgre {
          
          namespace Environment {
          
      33  class TreeType;
      34  class Tree{
          public:
      36   Tree(   );
          
      38   ~Tree(   );
          
      40   void makeMesh(  Ogre::String meshName,   Ogre::TParameters::TreeType type );
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/environment/Water.cpp

       1  //
          // C++ Implementation: Water
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Water.h"
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include "components/ogre/EmberOgre.h"
          
          
          
          
          using namespace Ogre;
          
          namespace EmberOgre {
          
          namespace Environment {
          
      37  class RefractionTextureListener : public RenderTargetListener
          {
      39  Entity* pPlaneEnt;
      40  std::vector<Entity*> aboveWaterEnts;
          
          public:
          
      44   void setPlaneEntity(  Entity* plane )
           {
           pPlaneEnt = plane;
           }
          
          
          
      51   void preRenderTargetUpdate(  const RenderTargetEvent& evt )
           {
           // Hide plane and objects above the water
           pPlaneEnt->setVisible(  false );
           std::vector<Entity*>::iterator i,   iend;
           iend = aboveWaterEnts.end(   );
           for (  i = aboveWaterEnts.begin(   ); i != iend; ++i )
           {
           (  *i )->setVisible(  false );
           }
          
           }
      63   void postRenderTargetUpdate(  const RenderTargetEvent& evt )
           {
           // Show plane and objects above the water
           pPlaneEnt->setVisible(  true );
           std::vector<Entity*>::iterator i,   iend;
           iend = aboveWaterEnts.end(   );
           for (  i = aboveWaterEnts.begin(   ); i != iend; ++i )
           {
           (  *i )->setVisible(  true );
           }
           }
          
          };
      76  class ReflectionTextureListener : public RenderTargetListener
          {
      78  Plane reflectionPlane;
      79  Entity* pPlaneEnt;
      80  std::vector<Entity*> belowWaterEnts;
      81  Ogre::Camera* theCam;
          
          public:
          
      85   void setPlaneEntity(  Entity* plane )
           {
           pPlaneEnt = plane;
           }
          
      90   void setReflectionPlane(  Plane &aPlane )
           {
           reflectionPlane = aPlane;
           }
          
      95   void setCamera(  Ogre::Camera* aCamera ) {
           theCam = aCamera;
           }
          
          
     100   void preRenderTargetUpdate(  const RenderTargetEvent& evt )
           {
           // Hide plane and objects below the water
           pPlaneEnt->setVisible(  false );
           std::vector<Entity*>::iterator i,   iend;
           iend = belowWaterEnts.end(   );
           for (  i = belowWaterEnts.begin(   ); i != iend; ++i )
           {
           (  *i )->setVisible(  false );
           }
           theCam->enableReflection(  reflectionPlane );
          
           }
     113   void postRenderTargetUpdate(  const RenderTargetEvent& evt )
           {
           // Show plane and objects below the water
           pPlaneEnt->setVisible(  true );
           std::vector<Entity*>::iterator i,   iend;
           iend = belowWaterEnts.end(   );
           for (  i = belowWaterEnts.begin(   ); i != iend; ++i )
           {
           (  *i )->setVisible(  true );
           }
           theCam->disableReflection(   );
           }
          
          };
          
          
          
     130   Water::Water(  Ogre::Camera *camera,   Ogre::SceneManager* mSceneMgr ) : mCamera(  camera )
           {
          
           Ogre::Plane waterPlane(  Ogre::Vector3::UNIT_Y,   0 );
          
          
           // create a water plane/scene node
          /* waterPlane.normal = ;
           waterPlane.d = 0; */
           Ogre::MeshManager::getSingleton(   ).createPlane(  
           "WaterPlane",  
           "environment",  
           waterPlane,  
           10000,   10000,  
           5,   5,  
           true,   1,  
           1000,   1000,  
           Ogre::Vector3::UNIT_Z
            );
          
           mWaterNode = EmberOgre::getSingleton(   ).getWorldSceneNode(   )->createChildSceneNode(  "water" );
           //mWaterNode->translate(  500,   0,   500 );
          
          
           mRefractionListener = new RefractionTextureListener(   );
           mReflectionListener = new ReflectionTextureListener(   );
          
           bool canDoFresnel = true;
           // Check prerequisites first
           const RenderSystemCapabilities* caps = Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   );
           if (  !caps->hasCapability(  RSC_VERTEX_PROGRAM ) || !(  caps->hasCapability(  RSC_FRAGMENT_PROGRAM ) ) )
           {
           canDoFresnel = false;
           /* Except(  1,   "Your card does not support vertex and fragment programs,   so cannot "
           "run this demo. Sorry!",  
           "Fresnel::createScene" );*/
           }
           else
           {
           if (  !GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "arbfp1" ) &&
           !GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "ps_2_0" ) &&
           !GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "ps_1_4" )
            )
           {
           canDoFresnel = false;
           /* Except(  1,   "Your card does not support advanced fragment programs,   "
           "so cannot run this demo. Sorry!",  
           "Fresnel::createScene" );*/
           }
           }
          
           //default to normal water if "fresnelwater" not found in config
           if (  canDoFresnel && Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "graphics",   "fresnelwater" ) ) {
           canDoFresnel = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "graphics",   "fresnelwater" );
           } else {
           canDoFresnel = false;
           }
          
           if (  canDoFresnel )
           {
           createFresnelWater(  camera,   mSceneMgr );
           } else {
           createSimpleWater(  camera,   mSceneMgr );
           }
          
           }
          
     197   void Water::createFresnelWater(  Ogre::Camera *camera,   Ogre::SceneManager* mSceneMgr )
           {
           RenderTexture* rttTex = EmberOgre::getSingleton(   ).getOgreRoot(   )->getRenderSystem(   )->createRenderTexture(   "Refraction",   512,   512  );
          
           {
           Viewport *v = rttTex->addViewport(   mCamera  );
           Ogre::MaterialPtr mat = MaterialManager::getSingleton(   ).getByName(  "Examples/FresnelReflectionRefraction" );
           if (  !mat.isNull(   ) ) {
           mat->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  2 )->setTextureName(  "Refraction" );
           v->setOverlaysEnabled(  false );
           rttTex->addListener(  mRefractionListener );
           }
           }
          
          
           rttTex = EmberOgre::getSingleton(   ).getOgreRoot(   )->getRenderSystem(   )->createRenderTexture(   "Reflection",   512,   512  );
           {
           Viewport *v = rttTex->addViewport(   mCamera  );
           Ogre::MaterialPtr mat = MaterialManager::getSingleton(   ).getByName(  "Examples/FresnelReflectionRefraction" );
           if (  !mat.isNull(   ) ) {
           mat->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  1 )->setTextureName(  "Reflection" );
           v->setOverlaysEnabled(  false );
           rttTex->addListener(  mReflectionListener );
           }
           }
          
           // Define a floor plane mesh
          /* reflectionPlane.normal = Vector3::UNIT_Y;
           reflectionPlane.d = 0;*/
          /* MeshManager::getSingleton(   ).createPlane(  "ReflectPlane",  reflectionPlane,  
           1500,  1500,  10,  10,  true,  1,  5,  5,  Vector3::UNIT_Z );*/
          
          
           Entity* pPlaneEnt = mSceneMgr->createEntity(   "plane",   "WaterPlane"  );
           pPlaneEnt->setMaterialName(  "Examples/FresnelReflectionRefraction" );
           mRefractionListener->setPlaneEntity(  pPlaneEnt );
           mReflectionListener->setPlaneEntity(  pPlaneEnt );
           mReflectionListener->setReflectionPlane(  reflectionPlane );
           mReflectionListener->setCamera(  camera );
           mWaterNode->attachObject(  pPlaneEnt );
          
           }
          
     240   void Water::createSimpleWater(  Ogre::Camera *camera,   Ogre::SceneManager* mSceneMgr )
           {
           Ogre::Entity *waterEntity;
          /* Ogre::Plane waterPlane;
          
          
           // create a water plane/scene node
           waterPlane.normal = Ogre::Vector3::UNIT_Y;
           waterPlane.d = 0;
           Ogre::MeshManager::getSingleton(   ).createPlane(  
           "WaterPlane",  
           waterPlane,  
           1400,   1400,  
           20,   20,  
           true,   1,  
           100,   100,  
           Ogre::Vector3::UNIT_Z
            );*/
          
           waterEntity = mSceneMgr->createEntity(  "water",   "WaterPlane" );
           waterEntity->setMaterialName(  "/global/environment/water/simple" );
           waterEntity->setRenderQueueGroup(  Ogre::RENDER_QUEUE_6 );
           waterEntity->setCastShadows(  false );
          
           mWaterNode->attachObject(  waterEntity );
          
           }
          
          
     269   Water::~Water(   )
           {
           }
          
          
          }
          
          }

./components/ogre/environment/Water.h

       1  //
          // C++ Interface: Water
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef DIMEOGREWATER_H
          #define DIMEOGREWATER_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "Environment.h"
          
          namespace EmberOgre {
          
          namespace Environment {
          
      33  class RefractionTextureListener;
      34  class ReflectionTextureListener;
          
          
          /**
          @author Erik Hjortsberg
          */
      40  class Water : public IWater
          {
          
          
          public:
      45   Water(  Ogre::Camera* camera,   Ogre::SceneManager* mSceneMgr );
          
      47   ~Water(   );
          
          protected:
          
      51   Ogre::Plane reflectionPlane;
          
      53   Ogre::Camera* mCamera;
          
      55   RefractionTextureListener* mRefractionListener;
      56   ReflectionTextureListener* mReflectionListener;
      57   void createFresnelWater(  Ogre::Camera *camera,   Ogre::SceneManager* mSceneMgr );
      58   void createSimpleWater(  Ogre::Camera *camera,   Ogre::SceneManager* mSceneMgr );
      59   Ogre::SceneNode *mWaterNode;
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/environment/caelum/include/Caelum.h

       1  #ifndef CAELUM_H
          #define CAELUM_H
          
          #include "CaelumPrerequisites.h"
          
          #include "CaelumSystem.h"
          #include "CaelumListener.h"
          #include "CameraBoundElement.h"
          #include "SkyColourModel.h"
          #include "SunPositionModel.h"
          #include "SimpleSunPositionModel.h"
          #include "StoredImageSkyColourModel.h"
          #include "StoredImageElvBasedSkyColourModel.h"
          #include "GeometryFactory.h"
          #include "SkyDome.h"
          #include "Sun.h"
          
          #endif //CAELUM_H

./components/ogre/environment/caelum/include/CaelumListener.h

          #ifndef CAELUMLISTENER_H
          #define CAELUMLISTENER_H
          
          #include "CaelumPrerequisites.h"
          
          namespace caelum {
          
          // Predefinition of the system for the crossed reference.
       9  class CaelumSystem;
          
          /** The Caelum listener interface.
           Allows to register its subclasses to Caelum so that it receives notifications each frame
           before it's started or finished. Useful,   for instance,   to prototype certain functionality
           like passing the sun direction to a shader/material that isn't defined inside Caelum
           itself.
           @author Jesús Alonso Abad
           @version 1.0
           */
          class DllExport CaelumListener {
          // Methods --------------------------------------------------------------------
           public:
          
      23   virtual ~CaelumListener(   ) {}
          
           /** Trigger fired just before Caelum is about to do its work.
           @param e The Ogre FrameEvent object,   in case it's desired to use this as a
           FrameListener as well.
           @param caelumSystem A reference to the invoker (  the Caelum system ) itself in case some
           operations on it are wanted to be done.
           @return True if it's desired to continue running Caelum.
           */
           virtual bool caelumStarted (  const Ogre::FrameEvent &e,   CaelumSystem *caelumSystem ) {
           return true;
           }
          
           /** Trigger fired just after Caelum is about to do its work.
           @param e The Ogre FrameEvent object,   in case it's desired to use this as a
           FrameListener as well.
           @param caelumSystem A reference to the invoker (  the Caelum system ) itself in case some
           operations on it are wanted to be done.
           @return True if it's desired to continue running after Caelum finished.
           */
           virtual bool caelumFinished (  const Ogre::FrameEvent &e,   CaelumSystem *caelumSystem ) {
           return true;
           }
          };
          
          } // namespace caelum
          
          #endif //CAELUMLISTENER_H

./components/ogre/environment/caelum/include/CaelumPrerequisites.h

       1  #ifndef CAELUMPREREQUISITES_H
          #define CAELUMPREREQUISITES_H
          
          // Include external headers
          #include <Ogre.h>
          
          // Define the dll export qualifier if compiling for Windows
          #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
           #define DllExport __declspec (  dllexport )
          #else
           #define DllExport
          #endif
          
          // Define the version code
          #define CAELUM_VERSION_MAIN 0
          #define CAELUM_VERSION_SEC 2
          #define CAELUM_VERSION_TER 1
          #define CAELUM_VERSION = (  CAELUM_VERSION_MAIN << 16 ) | (  CAELUM_VERSION_SEC << 8 ) | CAELUM_VERSION_TER
          
          /* Set a global camera distances modifier for the clipping distance.
           This threshold will be substracted from the far clipping distance if applicable,   else it will be
           added to the near clipping distance (  ie,   if infinite far clipping distance is used ).
           */
          #define CAMERA_DISTANCE_MODIFIER 0.1
          
          // Log macro
          #define LOG(  msg ) Ogre::LogManager::getSingleton(   ).logMessage(  msg );
          
          
          namespace caelum {
          
          /** The Caelum resources group name
           */
          static Ogre::String RESOURCE_GROUP_NAME = "Caelum";
          
          } // namespace caelum
          
          #endif //CAELUMPREREQUISITES_H

./components/ogre/environment/caelum/include/StoredImageElvBasedSkyColourModel.h

          #ifndef STOREDIMAGEELVBASEDSKYCOLOURMODEL_H
          #define STOREDIMAGEELVBASEDSKYCOLOURMODEL_H
          
          #include "StoredImageSkyColourModel.h"
          #include "CaelumPrerequisites.h"
          
          namespace caelum {
          
          /** A stored image (  sun elevation ) based sky colour model.
           This particular model takes a stored bitmap as the sky gradients map,   and the sun elevation as the
           localisation parameter.
           @author Jesús Alonso Abad
           @version 0.1
           */
          class DllExport StoredImageElvBasedSkyColourModel : public StoredImageSkyColourModel {
          // Attributes -----------------------------------------------------------------
          
          // Methods --------------------------------------------------------------------
           public:
           /** Constructor method.
           */
      22   StoredImageElvBasedSkyColourModel (   ) : StoredImageSkyColourModel (   ) {}
          
           /** Destructor.
           */
      26   ~StoredImageElvBasedSkyColourModel (   ) {}
          
           /** @copydoc StoredImageSkyColourModel::getFogColour(   ).
           */
      30   Ogre::ColourValue getFogColour (  float time,   const Ogre::Vector3 &sunDir );
          
           /** @copydoc StoredImageSkyColourModel::getFogDensity(   ).
           */
      34   float getFogDensity (  float time,   const Ogre::Vector3 &sunDir );
          
           /** @copydoc StoredImageSkyColourModel::setSkyGradientsImage(   ).
           */
      38   void setSkyGradientsImage (  const Ogre::String &gradients );
          
           /** @copydoc StoredImageSkyColourModel::getSunColour(   ).
           */
      42   Ogre::ColourValue getSunColour (  float time,   const Ogre::Vector3 &sunDir );
          
           /** @copydoc StoredImageSkyColourModel::updateMaterial(   ).
           */
      46   bool updateMaterial (  Ogre::GpuProgramParametersSharedPtr fpp,   Ogre::GpuProgramParametersSharedPtr vpp,   float time,   const Ogre::Vector3 &sunDir );
          };
          
          } // namespace caelum
          
          #endif //STOREDIMAGEELVBASEDSKYCOLOURMODEL_H

./components/ogre/environment/caelum/src/CaelumSystem.cpp

       1  #include "CaelumSystem.h"
          
          namespace caelum {
          
       5  CaelumSystem::CaelumSystem (  Ogre::Root *root,  
       6   Ogre::SceneManager *sceneMgr,  
       7   bool manageResGroup,  
       8   const Ogre::String &resGroupName,  
       9   bool createSkyDome,   bool createSun,   bool createStarfield ) {
           LOG (  "Initialising Caelum system..." );
           mOgreRoot = root;
           mSceneMgr = sceneMgr;
          
           RESOURCE_GROUP_NAME = resGroupName;
          
           // Create resource group
           if (  manageResGroup ) {
           mManageResourceGroup = true;
           Ogre::ResourceGroupManager::getSingleton (   ).createResourceGroup (  RESOURCE_GROUP_NAME );
           LOG (  Ogre::String (  "Created Caelum resource group (  " ) + RESOURCE_GROUP_NAME + " )" );
           }
           else
           mManageResourceGroup = false;
          
           // Set-up attributes
           mUpdateRate = 0;
           mTimeSinceLastUpdate = 0;
          
           mTotalDayTime = 86396.0; // 23h59m56s
           mTimeScale = 1.0f;
           mLocalTime = 0.0f;
           mRelativeTime = 0.0f;
          
           mManageFog = false;
          
           mSkyDome = 0;
           mSun = 0;
           mStarfield = 0;
           LOG (  "System attributes set up." );
          
           // Create basic elements
           if (  createSkyDome )
           this->createSkyDome (   );
           if (  createSun )
           this->createSun (   );
           if (  createStarfield )
           this->createStarfield (   );
          
           // Auto-register itself as a frame listener
           mOgreRoot->addFrameListener (  this );
          
           LOG (  "DONE" );
          }
          
      55  CaelumSystem::~CaelumSystem (   ) {
           LOG (  "Shutting down Caelum system..." );
           // Remove itself as a frame listener
           mOgreRoot->removeFrameListener (  this );
          
           // Unregister all the caelum listeners
           mListeners.clear (   );
          
           // Destroy the elements
           destroySkyDome (   );
           destroySun (   );
           destroyStarfield (   );
          
           // Remove resource group
           if (  mManageResourceGroup ) {
           Ogre::ResourceGroupManager::getSingleton (   ).destroyResourceGroup (  RESOURCE_GROUP_NAME );
           LOG (  "Destroyed Caelum resource group" );
           }
          
           LOG (  "DONE" );
          }
          
      77  void CaelumSystem::addListener (  CaelumListener *listener ) {
           mListeners.insert (  listener );
          }
          
      81  void CaelumSystem::removeListener (  CaelumListener *listener ) {
           mListeners.erase (  listener );
          }
          
      85  void CaelumSystem::preViewportUpdate (  const Ogre::RenderTargetViewportEvent &e ) {
           Ogre::Camera *cam = e.source->getCamera (   );
          
           if (  mSkyDome ) {
           mSkyDome->notifyCameraChanged (  cam );
           }
          
           if (  mSun ) {
           mSun->notifyCameraChanged (  cam );
           }
          
           if (  mStarfield ) {
           mStarfield->notifyCameraChanged (  cam );
           }
          }
          
     101  void CaelumSystem::setUpdateRate (  float rate ) {
           if (  rate < 0 )
           rate = 0;
          
           mUpdateRate = rate;
          
           // Force an update when changing this
           forceUpdate (   );
          }
          
     111  float CaelumSystem::getUpdateRate (   ) {
           return mUpdateRate;
          }
          
     115  void CaelumSystem::setTimeScale (  const float scale ) {
           mTimeScale = scale;
          }
          
     119  float CaelumSystem::getTimeScale (   ) const {
           return mTimeScale;
          }
          
     123  void CaelumSystem::setLocalTime (  const float time ) {
           mLocalTime = time;
          
           // Force an update when changing this
           forceUpdate (   );
          }
          
     130  float CaelumSystem::getLocalTime (   ) const {
           return mLocalTime;
          }
          
     134  void CaelumSystem::setTotalDayTime (  const float time ) {
           mTotalDayTime = time;
          
           if (  mTotalDayTime <= 0 )
           mTotalDayTime = 86396; // 23h59m56s
          
           // Force an update when changing this
           forceUpdate (   );
          }
          
     144  float CaelumSystem::getTotalDayTime (   ) const {
           return mTotalDayTime;
          }
          
     148  bool CaelumSystem::frameStarted (  const Ogre::FrameEvent &e ) {
           // Update local time
           mLocalTime += e.timeSinceLastFrame * mTimeScale;
           if (  mLocalTime > mTotalDayTime ) {
           clampLocalTime (   );
           }
          
           // Update only if required
           mTimeSinceLastUpdate += (  e.timeSinceLastFrame * Ogre::Math::Abs (  mTimeScale ) ) / mTotalDayTime;
           if (  mTimeSinceLastUpdate > mUpdateRate ) {
           // Do it this way so we don't lose any seconds and the updates doesn't queue
           if (  mUpdateRate != 0 )
           mTimeSinceLastUpdate -= mUpdateRate * Ogre::Math::Floor (  mTimeSinceLastUpdate / mUpdateRate );
           else
           mTimeSinceLastUpdate = 0;
          
           mRelativeTime = mLocalTime / mTotalDayTime;
          
           // Call every listener before doing anything
           if (  !fireStartedEvent (  e ) )
           return false;
          
           if (  mSun ) {
           mSun->update (  mRelativeTime );
           }
          
           if (  mStarfield ) {
           mStarfield->update (  mRelativeTime );
           }
          
           if (  mSkyDome ) {
           mSkyDome->updateSkyDomeMaterialTime (  mSkyColourModel,   mRelativeTime,   mSun );
          
           mSkyDome->setSunDirection (  mSun->getSunDirection (   ) );
           }
          
           if (  mManageFog ) {
           // TODO: Fog stuff here!!!
           if (  mSkyColourModel ) {
           mSceneMgr->setFog(   Ogre::FOG_LINEAR,   mSkyColourModel->getFogColour (  mRelativeTime,   mSun ? mSun->getSunDirection(   ) : Ogre::Vector3::UNIT_Y ) * 0.7,   .001,   10,   600 );
          /* mSceneMgr->setFog (  Ogre::FOG_EXP2,  
           mSkyColourModel->getFogColour (  mRelativeTime,   mSun ? mSun->getSunDirection(   ) : Ogre::Vector3::UNIT_Y ) * 0.7,  
           mSkyColourModel->getFogDensity (  mRelativeTime,   mSun ? mSun->getSunDirection(   ) : Ogre::Vector3::UNIT_Y ) );*/
           }
           }
          
           if (  mSun ) {
           if (  mSkyColourModel )
           mSun->setSunColour (  mSkyColourModel->getSunColour (  mRelativeTime,   mSun->getSunDirection (   ) ) );
           else
           mSun->setSunColour (  mSceneMgr->getFogColour (   ) );
           }
          
           // Call every listener before quiting
           if (  !fireFinishedEvent (  e ) )
           return false;
           }
          
           return true;
          }
          
     209  SkyDome *CaelumSystem::createSkyDome (   ) {
           if (  !mSkyDome ) {
           mSkyDome = new SkyDome (  mSceneMgr );
           LOG (  "Sky Dome created." );
           }
          
           return mSkyDome;
          }
          
     218  SkyDome *CaelumSystem::getSkyDome (   ) const {
           return mSkyDome;
          }
          
     222  void CaelumSystem::destroySkyDome (   ) {
           if (  mSkyDome ) {
           delete mSkyDome;
           mSkyDome = 0;
           LOG (  "Sky Dome destroyed." );
           }
          }
          
     230  Sun *CaelumSystem::createSun (   ) {
           if (  !mSun ) {
           mSun = new Sun (  mSceneMgr );
           LOG (  "Sun created." );
           }
          
           return mSun;
          }
          
     239  Sun *CaelumSystem::getSun (   ) const {
           return mSun;
          }
          
     243  void CaelumSystem::destroySun (   ) {
           if (  mSun ) {
           delete mSun;
           mSun = 0;
           LOG (  "Sun destroyed." );
           }
          }
          
     251  Starfield *CaelumSystem::createStarfield (  const Ogre::String &mapName ) {
           if (  !mStarfield ) {
           mStarfield = new Starfield (  mSceneMgr );
           LOG (  "Starfield created." );
           }
          
           mStarfield->updateMaterial (  mapName );
          
           return mStarfield;
          }
          
     262  Starfield *CaelumSystem::getStarfield (   ) const {
           return mStarfield;
          }
          
     266  void CaelumSystem::destroyStarfield (   ) {
           if (  mStarfield ) {
           delete mStarfield;
           mStarfield = 0;
           LOG (  "Starfield destroyed." );
           }
          }
          
     274  void CaelumSystem::setSkyColourModel (  SkyColourModel *model ) {
           mSkyColourModel = model;
           if (  mSkyDome ) {
           Ogre::TextureUnitState *temp = mSkyDome->getTextureUnitState (   );
           if (  temp )
           mSkyColourModel->setSkyGradientsTextureUnitState (  temp );
           }
          }
          
     283  void CaelumSystem::setManageFog (  bool manage ) {
           mManageFog = manage;
          }
          
     287  bool CaelumSystem::isFogManaged (   ) const {
           return mManageFog;
          }
          
     291  bool CaelumSystem::fireStartedEvent (  const Ogre::FrameEvent &e ) {
           std::set<CaelumListener *>::iterator it,   iend = mListeners.end (   );
           bool flag = true;
          
           it = mListeners.begin (   );
          
           while (  it != iend && flag ) {
           flag &= (  *it )->caelumStarted (  e,   this );
          
           ++it;
           }
          
           return flag;
          }
          
     306  bool CaelumSystem::fireFinishedEvent (  const Ogre::FrameEvent &e ) {
           std::set<CaelumListener *>::iterator it,   iend = mListeners.end (   );
           bool flag = true;
          
           it = mListeners.begin (   );
          
           while (  it != iend && flag ) {
           flag &= (  *it )->caelumFinished (  e,   this );
          
           ++it;
           }
          
           return flag;
          }
          
     321  void CaelumSystem::clampLocalTime (   ) {
           if (  mLocalTime < 0 ) {
           int ratio = (  int  )(  mTotalDayTime / -mLocalTime );
           mLocalTime += mTotalDayTime * ratio;
           }
           if (  mLocalTime > mTotalDayTime ) {
           int ratio = (  int  )(  mTotalDayTime / mLocalTime );
           mLocalTime -= mTotalDayTime * ratio;
           }
          }
          
     332  void CaelumSystem::forceUpdate (   ) {
           mTimeSinceLastUpdate = mUpdateRate + 1;
          }
          
          } // namespace caelum

./components/ogre/environment/caelum/src/GeometryFactory.cpp

       1  #include "GeometryFactory.h"
          #include "CaelumSystem.h"
          
          namespace caelum {
          
       6  void GeometryFactory::generateSphericDome (  const Ogre::String &name,   const unsigned int segments,   DomeType type ) {
           // Return now if already exists
           if (  Ogre::MeshManager::getSingleton (   ).resourceExists (  name ) )
           return;
          
           LOG (  "Creating " + name + " sphere mesh resource..." );
          
           // Use the mesh manager to create the mesh
           Ogre::MeshPtr msh = Ogre::MeshManager::getSingleton (   ).createManual (  name,   RESOURCE_GROUP_NAME );
           // Create a submesh
           Ogre::SubMesh *sub = msh->createSubMesh (   );
          
           // Create the shared vertex data
           Ogre::VertexData *vertexData = new Ogre::VertexData (   );
           msh->sharedVertexData = vertexData;
          
           // Define the vertices' format
           Ogre::VertexDeclaration *vertexDecl = vertexData->vertexDeclaration;
           size_t currOffset = 0;
           // Position
           vertexDecl->addElement (  0,   currOffset,   Ogre::VET_FLOAT3,   Ogre::VES_POSITION );
           currOffset += Ogre::VertexElement::getTypeSize (  Ogre::VET_FLOAT3 );
           // Normal
           vertexDecl->addElement (  0,   currOffset,   Ogre::VET_FLOAT3,   Ogre::VES_NORMAL );
           currOffset += Ogre::VertexElement::getTypeSize (  Ogre::VET_FLOAT3 );
           // Texture coordinates
           vertexDecl->addElement (  0,   currOffset,   Ogre::VET_FLOAT2,   Ogre::VES_TEXTURE_COORDINATES,   0 );
           currOffset += Ogre::VertexElement::getTypeSize (  Ogre::VET_FLOAT2 );
          
           // Allocate the vertex buffer
           switch (  type ) {
           case DT_GRADIENTS:
           vertexData->vertexCount = segments * (  segments - 1 ) + 2;
           break;
           case DT_STARFIELD:
           vertexData->vertexCount = (  segments + 1 ) * (  segments + 1 );
           break;
           };
           Ogre::HardwareVertexBufferSharedPtr vBuf = Ogre::HardwareBufferManager::getSingleton (   ).createVertexBuffer (  vertexDecl->getVertexSize (  0 ),   vertexData->vertexCount,   Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
           Ogre::VertexBufferBinding *binding = vertexData->vertexBufferBinding;
           binding->setBinding (  0,   vBuf );
          
           float *pVertex = static_cast<float *>(  vBuf->lock (  Ogre::HardwareBuffer::HBL_DISCARD ) );
          
           // Allocate the index buffer
           switch (  type ) {
           case DT_GRADIENTS:
           sub->indexData->indexCount = 2 * segments * (  segments - 1 ) * 3;
           break;
           case DT_STARFIELD:
           // TODO
           sub->indexData->indexCount = 2 * (  segments + 1 ) * segments * 3;
           break;
           };
           sub->indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton (   ).createIndexBuffer (  Ogre::HardwareIndexBuffer::IT_16BIT,   sub->indexData->indexCount,   Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
           Ogre::HardwareIndexBufferSharedPtr iBuf = sub->indexData->indexBuffer;
           unsigned short *pIndices = static_cast<unsigned short *>(  iBuf->lock (  Ogre::HardwareBuffer::HBL_DISCARD ) );
          
           // Fill the buffers
           switch (  type ) {
           case DT_GRADIENTS:
           fillGradientsDomeBuffers (  pVertex,   pIndices,   segments );
           break;
           case DT_STARFIELD:
           fillStarfieldDomeBuffers (  pVertex,   pIndices,   segments );
           break;
           };
          
           // Close the vertex buffer
           vBuf->unlock (   );
          
           // Close the index buffer
           iBuf->unlock (   );
          
           // Finishing it...
           sub->useSharedVertices = true;
           msh->_setBounds (  Ogre::AxisAlignedBox (  -1,   -1,   -1,   1,   1,   1 ),   false );
           msh->_setBoundingSphereRadius (  1 );
           msh->load (   );
          
           LOG (  "DONE" );
          }
          
      89  void GeometryFactory::fillGradientsDomeBuffers (  float *pVertex,   unsigned short *pIndices,   unsigned int segments ) {
           const float deltaLatitude = Ogre::Math::PI / (  float  )segments;
           const float deltaLongitude = Ogre::Math::PI * 2.0 / (  float  )segments;
          
           // Generate the rings
           for (  unsigned int i = 1; i < segments; i++ ) {
           float r0 = Ogre::Math::Sin (  Ogre::Radian (  i * deltaLatitude ) );
           float y0 = Ogre::Math::Cos (  Ogre::Radian (  i * deltaLatitude ) );
          
           for (  unsigned int j = 0; j < segments; j++ ) {
           float x0 = r0 * Ogre::Math::Sin (  Ogre::Radian (  j * deltaLongitude ) );
           float z0 = r0 * Ogre::Math::Cos (  Ogre::Radian (  j * deltaLongitude ) );
          
           *pVertex++ = x0;
           *pVertex++ = y0;
           *pVertex++ = z0;
          
           *pVertex++ = -x0;
           *pVertex++ = -y0;
           *pVertex++ = -z0;
          
           *pVertex++ = 0;
           *pVertex++ = 1 - y0;
           }
           }
          
           // Generate the "north pole"
           *pVertex++ = 0; // Position
           *pVertex++ = 1;
           *pVertex++ = 0;
           *pVertex++ = 0; // Normal
           *pVertex++ = -1;
           *pVertex++ = 0;
           *pVertex++ = 0; // UV
           *pVertex++ = 0;
          
           // Generate the "south pole"
           *pVertex++ = 0; // Position
           *pVertex++ = -1;
           *pVertex++ = 0;
           *pVertex++ = 0; // Normal
           *pVertex++ = 1;
           *pVertex++ = 0;
           *pVertex++ = 0; // UV
           *pVertex++ = 2;
          
           // Generate the mid segments
           for (  unsigned int i = 0; i < segments - 2; i++ ) {
           for (  unsigned int j = 0; j < segments; j++ ) {
           *pIndices++ = segments * i + j;
           *pIndices++ = segments * i + (  j + 1 ) % segments;
           *pIndices++ = segments * (  i + 1 ) + (  j + 1 ) % segments;
           *pIndices++ = segments * i + j;
           *pIndices++ = segments * (  i + 1 ) + (  j + 1 ) % segments;
           *pIndices++ = segments * (  i + 1 ) + j;
           }
           }
          
           // Generate the upper cap
           for (  unsigned int i = 0; i < segments; i++ ) {
           *pIndices++ = segments * (  segments - 1 );
           *pIndices++ = (  i + 1 ) % segments;
           *pIndices++ = i;
           }
          
           // Generate the lower cap
           for (  unsigned int i = 0; i < segments; i++ ) {
           *pIndices++ = segments * (  segments - 1 ) + 1;
           *pIndices++ = segments * (  segments - 2 ) + i;
           *pIndices++ = segments * (  segments - 2 ) + (  i + 1 ) % segments;
           }
          }
          
     162  void GeometryFactory::fillStarfieldDomeBuffers (  float *pVertex,   unsigned short *pIndices,   unsigned int segments ) {
           const float deltaLatitude = Ogre::Math::PI / (  float  )segments;
           const float deltaLongitude = Ogre::Math::PI * 2.0 / (  float  )segments;
          
           // Generate the rings
           for (  unsigned int i = 0; i <= segments; i++ ) {
           float r0 = Ogre::Math::Sin (  Ogre::Radian (  i * deltaLatitude ) );
           float y0 = Ogre::Math::Cos (  Ogre::Radian (  i * deltaLatitude ) );
          
           for (  unsigned int j = 0; j <= segments; j++ ) {
           float x0 = r0 * Ogre::Math::Sin (  Ogre::Radian (  j * deltaLongitude ) );
           float z0 = r0 * Ogre::Math::Cos (  Ogre::Radian (  j * deltaLongitude ) );
          
           *pVertex++ = x0;
           *pVertex++ = y0;
           *pVertex++ = z0;
          
           *pVertex++ = -x0;
           *pVertex++ = -y0;
           *pVertex++ = -z0;
          
           *pVertex++ = (  float  )j / (  float  )segments;
           *pVertex++ = 1 - (  y0 * 0.5 + 0.5 );
           }
           }
          
           // Generate the mid segments
           for (  unsigned int i = 0; i <= segments; i++ ) {
           for (  unsigned int j = 0; j < segments; j++ ) {
           *pIndices++ = segments * i + j;
           *pIndices++ = segments * i + (  j + 1 ) % segments;
           *pIndices++ = segments * (  i + 1 ) + (  j + 1 ) % segments;
           *pIndices++ = segments * i + j;
           *pIndices++ = segments * (  i + 1 ) + (  j + 1 ) % segments;
           *pIndices++ = segments * (  i + 1 ) + j;
           }
           }
          }
          
          } // namespace caelum

./components/ogre/environment/caelum/src/SimpleSunPositionModel.cpp

       1  #include "SimpleSunPositionModel.h"
          
          namespace caelum {
          
       5  SimpleSunPositionModel::SimpleSunPositionModel (  Ogre::Degree inc ) {
           setInclination (  inc );
          }
          
       9  void SimpleSunPositionModel::setInclination (  Ogre::Degree inc ) {
           mInclination = inc;
          }
          
      13  Ogre::Degree SimpleSunPositionModel::getInclination (   ) const {
           return mInclination;
          }
          
      17  Ogre::Vector3 SimpleSunPositionModel::update (  const float time ) {
           // Get the inclinated axis
           Ogre::Vector3 axis = Ogre::Vector3::UNIT_Z;
           axis = Ogre::Quaternion (  mInclination,   Ogre::Vector3::UNIT_X ) * axis;
          
           // Get the inclinated light direction,   according to the day time
           Ogre::Vector3 dir = Ogre::Vector3::UNIT_Y;
           dir = Ogre::Quaternion (  Ogre::Radian (  time * 2 * Ogre::Math::PI ),   axis ) * dir;
          
           mSunPosition = dir.normalisedCopy (   ) * -1;
          
           return mSunPosition * -1;
          }
          
          } // namespace caelum

./components/ogre/environment/caelum/src/SkyDome.cpp

       1  #include "SkyDome.h"
          #include "CaelumSystem.h"
          #include "GeometryFactory.h"
          
          namespace caelum {
          
          
          
          const Ogre::String SkyDome::mSphericDomeResourceName = "CaelumSphericDome";
          
          const Ogre::String SkyDome::SKY_DOME_MATERIAL_NAME = "CaelumSkyDomeMaterial";
          
          
          
      15  SkyDome::SkyDome (  Ogre::SceneManager *sceneMgr ) {
          
           mAutoRadius = true;
          
          
          
           createSkyDomeMaterial (   );
          
          
          
           GeometryFactory::generateSphericDome (  mSphericDomeResourceName,   32 );
          
           Ogre::Entity *ent = sceneMgr->createEntity (  "Dome",   mSphericDomeResourceName );
          
           ent->setMaterialName (  SKY_DOME_MATERIAL_NAME );
          
           ent->setRenderQueueGroup (  Ogre::RENDER_QUEUE_SKIES_EARLY + 2 );
          
           ent->setCastShadows (  false );
          
          
          
           mNode = sceneMgr->getRootSceneNode (   )->createChildSceneNode (   );
           mNode->attachObject (  ent );
          }
          
      41  SkyDome::~SkyDome (   ) {
           if (  mNode ) {
           // Detach and destroy attached entity.
           Ogre::Entity *ent = static_cast<Ogre::Entity *>(  mNode->detachObject (  "Dome" ) );
           ent->_getManager (   )->destroyEntity (  ent );
          
           // Destroy the node
           static_cast<Ogre::SceneNode *>(  mNode->getParent (   ) )->removeAndDestroyChild (  mNode->getName (   ) );
          
           mNode = 0;
          
           }
          
          
          
           destroySkyDomeMaterial (   );
          
          }
          
          
          
      62  void SkyDome::notifyCameraChanged (  Ogre::Camera *cam ) {
          
           mNode->setPosition (  cam->getRealPosition (   ) );
          
           if (  mAutoRadius ) {
          
           if (  cam->getFarClipDistance (   ) > 0 )
          
           mNode->setScale (  Ogre::Vector3::UNIT_SCALE * (  cam->getFarClipDistance (   ) - CAMERA_DISTANCE_MODIFIER ) );
           else
           mNode->setScale (  Ogre::Vector3::UNIT_SCALE * (  cam->getNearClipDistance (   ) + CAMERA_DISTANCE_MODIFIER ) );
           }
          
          }
          
          
          
      79  void SkyDome::setFarRadius (  float radius ) {
          
           if (  radius > 0 ) {
          
           mNode->setScale (  Ogre::Vector3::UNIT_SCALE * radius );
          
           mAutoRadius = false;
          
           }
           else {
           mAutoRadius = true;
           }
          
          }
          
          
          
      96  void SkyDome::setSunDirection (  Ogre::Vector3 dir ) {
          
           if (  !mSkyDomeMaterial.isNull (   ) ) {
          
           Ogre::Technique* tech = mSkyDomeMaterial->getBestTechnique (   );
           if (  tech ) {
           Ogre::Pass* pass = tech->getPass(  0 );
           if (  pass ) {
           if (  pass->hasVertexProgram(   ) ) {
           pass->getVertexProgramParameters (   )->setNamedConstant (  "sunDirection",   dir );
           }
           }
           }
          
           }
          
          }
          
          
          
     116  void SkyDome::setLightAbsorption (  float absorption ) const {
          
           if (  absorption > 1 )
          
           absorption = 1;
          
           else if (  absorption < 0 )
          
           absorption = 0;
          
          
          
           if (  !mSkyDomeMaterial.isNull (   ) ) {
          
           if (  Ogre::Root::getSingleton (   ).getRenderSystem (   )->getCapabilities (   )->hasCapability (  Ogre::RSC_VERTEX_PROGRAM ) ) {
          
           Ogre::Technique* tech = mSkyDomeMaterial->getBestTechnique (   );
           if (  tech ) {
           Ogre::Pass* pass = tech->getPass(  0 );
           if (  pass ) {
           if (  pass->hasVertexProgram(   ) ) {
           pass->getVertexProgramParameters (   )->setNamedConstant (  "lightAbsorption",   absorption );
           }
           }
           }
          
           }
          
           }
          
          }
          
          
          
     150  void SkyDome::setLightScattering (  float scattering ) const {
          
           if (  scattering <= 0 )
          
           scattering = 0.00001;
          
          
          
           if (  !mSkyDomeMaterial.isNull (   ) ) {
          
           if (  Ogre::Root::getSingleton (   ).getRenderSystem (   )->getCapabilities (   )->hasCapability (  Ogre::RSC_VERTEX_PROGRAM ) ) {
          
           mSkyDomeMaterial->getTechnique (  0 )->getPass (  0 )->getFragmentProgramParameters (   )->setNamedConstant (  "lightInvScattering",   1.0f / scattering );
          
           }
          
           }
          
          }
          
          
          
     172  void SkyDome::setAtmosphereHeight (  float height ) const {
          
           if (  height <= 0 )
          
           height = 0.00001;
          
           else if (  height > 1 )
          
           height = 1;
          
          
          
           if (  !mSkyDomeMaterial.isNull (   ) ) {
          
           if (  Ogre::Root::getSingleton (   ).getRenderSystem (   )->getCapabilities (   )->hasCapability (  Ogre::RSC_VERTEX_PROGRAM ) ) {
          
           mSkyDomeMaterial->getTechnique (  0 )->getPass (  0 )->getFragmentProgramParameters (   )->setNamedConstant (  "atmosphereInvHeight",   1.0f / height );
          
           }
          
           }
          
          }
          
          
          
     198  void SkyDome::updateSkyDomeMaterialTime (  SkyColourModel *skyColourModel,   float time,   Sun *sun ) {
          
           Ogre::Technique* tech = mSkyDomeMaterial->getBestTechnique (   );
           if (  tech ) {
           Ogre::Pass* pass = tech->getPass(  0 );
           if (  pass ) {
           Ogre::GpuProgramParametersSharedPtr vertexProgramParams,   fragmentProgramParams;
           if (  pass->hasVertexProgram(   ) ) {
           vertexProgramParams = pass->getVertexProgramParameters (   );
           }
           if (  pass->hasFragmentProgram(   ) ) {
           fragmentProgramParams = pass->getFragmentProgramParameters (   );
           }
           skyColourModel->updateMaterial (  fragmentProgramParams,  
           vertexProgramParams,  
           time,   sun ? sun->getSunDirection (   ) : Ogre::Vector3::UNIT_Y );
           }
           }
          }
          
          
     219  Ogre::TextureUnitState *SkyDome::getTextureUnitState (   ) {
          
           if (  mSkyDomeMaterial.isNull (   ) )
          
           return 0;
          
          
          
           return mSkyDomeMaterial->getTechnique (  0 )->getPass (  0 )->getTextureUnitState (  0 );
          
          }
          
          
          
     233  void SkyDome::createSkyDomeMaterial (   ) {
          
           Ogre::MaterialPtr mat;
          
          
          
           LOG (  "Generating sky dome material..." );
          
           if (  !Ogre::MaterialManager::getSingleton (   ).resourceExists (  SKY_DOME_MATERIAL_NAME ) ) {
          
           LOG (  "\tMaterial not found; creating..." );
          
           mat = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton (   ).create (  SKY_DOME_MATERIAL_NAME,   RESOURCE_GROUP_NAME ) );
          
           mat->setReceiveShadows (  false );
          
           LOG (  "\t\tMaterial [OK]" );
          
           Ogre::Pass *pass = mat->getTechnique (  0 )->getPass (  0 );
          
           pass->setSceneBlending (  Ogre::SBT_TRANSPARENT_ALPHA );
          
           pass->setDepthCheckEnabled (  false );
          
           pass->setDepthWriteEnabled (  false );
          
           pass->setLightingEnabled (  false );
          
           pass->setFog (  true );
          
           // Bind the sky light absorption shader if capable to
          
           // TODO
          
           LOG (  "\t\tPass [OK]" );
          
           Ogre::TextureUnitState *tus = pass->createTextureUnitState (   );
          
           tus->setTextureAddressingMode (  Ogre::TextureUnitState::TAM_WRAP,   Ogre::TextureUnitState::TAM_CLAMP,   Ogre::TextureUnitState::TAM_CLAMP );
          
           LOG (  "\t\tTextureUnit [OK]" );
          
           mat->load (   );
          
           LOG (  "\tDONE" );
          
           }
          
           else {
          
           mat = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton (   ).getByName (  SKY_DOME_MATERIAL_NAME ) );
          
           }
          
           LOG (  "DONE" );
          
          
          
           mSkyDomeMaterial = mat;
          
          }
          
          
          
     297  void SkyDome::destroySkyDomeMaterial (   ) {
          
           LOG (  "Removing sky dome material..." );
          
           if (  !Ogre::MaterialManager::getSingleton (   ).resourceExists (  SKY_DOME_MATERIAL_NAME ) ) {
          
           Ogre::MaterialManager::getSingleton (   ).remove (  SKY_DOME_MATERIAL_NAME );
          
           }
          
           mSkyDomeMaterial.setNull (   );
          
           LOG (  "DONE" );
          
          }
          
          
          
          } // namespace caelum
          

./components/ogre/environment/caelum/src/Starfield.cpp

       1  #include "Starfield.h"
          #include "CaelumSystem.h"
          #include "GeometryFactory.h"
          
          namespace caelum {
          
          const Ogre::String Starfield::mStarfieldDomeResourceName = "CaelumStarfieldDome";
          const Ogre::String Starfield::STARFIELD_MATERIAL_NAME = "CaelumStarfieldMaterial";
          
      10  Starfield::Starfield (  Ogre::SceneManager *sceneMgr ) {
           mAutoRadius = true;
           mInclination = Ogre::Degree (  0 );
          
           createStarfieldMaterial (   );
          
           GeometryFactory::generateSphericDome (  mStarfieldDomeResourceName,   32,   GeometryFactory::DT_STARFIELD );
           Ogre::Entity *ent = sceneMgr->createEntity (  "StarfieldDome",   mStarfieldDomeResourceName );
           ent->setMaterialName (  STARFIELD_MATERIAL_NAME );
           ent->setRenderQueueGroup (  Ogre::RENDER_QUEUE_SKIES_EARLY + 1 );
           ent->setCastShadows (  false );
          
           mNode = sceneMgr->getRootSceneNode (   )->createChildSceneNode (   );
           mNode->attachObject (  ent );
          }
          
      26  Starfield::~Starfield (   ) {
           if (  mNode ) {
           // Detach and destroy attached entity.
           Ogre::Entity *ent = static_cast<Ogre::Entity *>(  mNode->detachObject (  "StarfieldDome" ) );
           ent->_getManager (   )->destroyEntity (  ent );
          
           // Destroy the node
           static_cast<Ogre::SceneNode *>(  mNode->getParent (   ) )->removeAndDestroyChild (  mNode->getName (   ) );
           mNode = 0;
           }
          
           destroyStarfieldMaterial (   );
          }
          
      40  void Starfield::notifyCameraChanged (  Ogre::Camera *cam ) {
           mNode->setPosition (  cam->getRealPosition (   ) );
           if (  mAutoRadius ) {
           if (  cam->getFarClipDistance (   ) > 0 )
           mNode->setScale (  Ogre::Vector3::UNIT_SCALE * (  cam->getFarClipDistance (   ) - CAMERA_DISTANCE_MODIFIER ) );
           else
           mNode->setScale (  Ogre::Vector3::UNIT_SCALE * (  cam->getNearClipDistance (   ) + CAMERA_DISTANCE_MODIFIER ) );
           }
          }
          
      50  void Starfield::setFarRadius (  float radius ) {
           if (  radius > 0 ) {
           mNode->setScale (  Ogre::Vector3::UNIT_SCALE * radius );
           mAutoRadius = false;
           }
           else {
           mAutoRadius = true;
           }
          }
          
      60  void Starfield::setInclination (  Ogre::Degree inc ) {
           mInclination = inc;
          }
          
      64  void Starfield::update (  const float time ) {
           Ogre::Quaternion orientation = Ogre::Quaternion::IDENTITY;
           orientation = orientation * Ogre::Quaternion (  Ogre::Radian (  mInclination + Ogre::Degree (  90 ) ),   Ogre::Vector3::UNIT_X );
           orientation = orientation * Ogre::Quaternion (  Ogre::Radian (  time * 2 * Ogre::Math::PI ),   Ogre::Vector3::UNIT_Y );
          
           mNode->setOrientation (  orientation );
          }
          
      72  void Starfield::updateMaterial (  const Ogre::String &mapName ) {
           // Update the starfield material
           mStarfieldMaterial->getBestTechnique (   )->getPass (  0 )->getTextureUnitState (  0 )->setTextureName (  mapName );
          }
          
      77  void Starfield::createStarfieldMaterial (   ) {
           Ogre::MaterialPtr mat;
          
           LOG (  "Generating starfield material..." );
           if (  !Ogre::MaterialManager::getSingleton (   ).resourceExists (  STARFIELD_MATERIAL_NAME ) ) {
           LOG (  "\tMaterial not found; creating..." );
           mat = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton (   ).create (  STARFIELD_MATERIAL_NAME,   RESOURCE_GROUP_NAME ) );
           mat->setReceiveShadows (  false );
           LOG (  "\t\tMaterial [OK]" );
           Ogre::Pass *pass = mat->getTechnique (  0 )->getPass (  0 );
           pass->setDepthCheckEnabled (  false );
           pass->setDepthWriteEnabled (  false );
           pass->setLightingEnabled (  false );
           pass->setFog (  true );
           LOG (  "\t\tPass [OK]" );
           Ogre::TextureUnitState *tus = pass->createTextureUnitState (   );
           tus->setTextureAddressingMode (  Ogre::TextureUnitState::TAM_WRAP,   Ogre::TextureUnitState::TAM_WRAP,   Ogre::TextureUnitState::TAM_WRAP );
           LOG (  "\t\tTextureUnit [OK]" );
           mat->load (   );
           LOG (  "\tDONE" );
           }
           else {
           mat = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton (   ).getByName (  STARFIELD_MATERIAL_NAME ) );
           }
           LOG (  "DONE" );
          
           mStarfieldMaterial = mat;
          }
          
     106  void Starfield::destroyStarfieldMaterial (   ) {
           LOG (  "Removing starfield material..." );
           if (  !Ogre::MaterialManager::getSingleton (   ).resourceExists (  STARFIELD_MATERIAL_NAME ) ) {
           Ogre::MaterialManager::getSingleton (   ).remove (  STARFIELD_MATERIAL_NAME );
           }
           mStarfieldMaterial.setNull (   );
           LOG (  "DONE" );
          }
          
          } // namespace caelum

./components/ogre/environment/caelum/src/StoredImageElvBasedSkyColourModel.cpp

       1  #include "StoredImageElvBasedSkyColourModel.h"
          
          namespace caelum {
          
       5  Ogre::ColourValue StoredImageElvBasedSkyColourModel::getFogColour (  float time,   const Ogre::Vector3 &sunDir ) {
           float elevation = sunDir.dotProduct (  Ogre::Vector3::UNIT_Y );
           elevation = elevation * 0.5 + 0.5;
          
           if (  mFogColourMap == 0 ) {
           return Ogre::ColourValue::White;
           }
           else {
           return getInterpolatedColour (  elevation,   1,   mFogColourMap,   false );
           }
          }
          
      17  float StoredImageElvBasedSkyColourModel::getFogDensity (  float time,   const Ogre::Vector3 &sunDir ) {
           float elevation = sunDir.dotProduct (  Ogre::Vector3::UNIT_Y );
           elevation = elevation * 0.5 + 0.5;
          
           if (  mFogColourMap == 0 ) {
           return mFogDensity;
           }
           else {
           return mFogDensity * (  getInterpolatedColour (  elevation,   1,   mFogColourMap,   false ) ).a;
           }
          }
          
      29  void StoredImageElvBasedSkyColourModel::setSkyGradientsImage (  const Ogre::String &gradients ) {
           StoredImageSkyColourModel::setSkyGradientsImage (  gradients );
          
           mSkyGradientsTextureUnitState->setTextureAddressingMode (  Ogre::TextureUnitState::TAM_CLAMP );
          }
          
      35  Ogre::ColourValue StoredImageElvBasedSkyColourModel::getSunColour (  float time,   const Ogre::Vector3 &sunDir ) {
           float elevation = sunDir.dotProduct (  Ogre::Vector3::UNIT_Y );
           elevation = elevation * 0.5 + 0.5;
          
           if (  mSkyGradientsImage == 0 ) {
           return Ogre::ColourValue::White;
           }
           else {
           return getInterpolatedColour (  elevation,   elevation,   mSkyGradientsImage,   false );
           }
          }
          
      47  bool StoredImageElvBasedSkyColourModel::updateMaterial (  Ogre::GpuProgramParametersSharedPtr fpp,   Ogre::GpuProgramParametersSharedPtr vpp,   float time,   const Ogre::Vector3 &sunDir ) {
           float elevation = sunDir.dotProduct (  Ogre::Vector3::UNIT_Y );
           elevation = elevation * 0.5 + 0.5;
          
           mSkyGradientsTextureUnitState->setTextureUScroll (  elevation );
           if (  !fpp.isNull (   ) ) {
           fpp->setNamedConstant (  "offset",   elevation );
           }
          
           return true;
          }
          
          } // namespace caelum

./components/ogre/environment/caelum/src/StoredImageSkyColourModel.cpp

       1  #include "StoredImageSkyColourModel.h"
          
          namespace caelum {
          
       5  StoredImageSkyColourModel::StoredImageSkyColourModel (   ) {
           mFogColourMap = 0;
           mFogDensity = 0.0005;
          }
          
      10  void StoredImageSkyColourModel::setSkyGradientsImage (  const Ogre::String &gradients ) {
           if (  mSkyGradientsImage == 0 )
           mSkyGradientsImage = new Ogre::Image (   );
          
           mSkyGradientsImage->load (  gradients,   RESOURCE_GROUP_NAME );
          
           if (  mSkyGradientsTextureUnitState ) {
           // Dagon and Eihort compatibility
           #if OGRE_VERSION < (  (  1 << 16 ) | (  3 << 8 ) )
           mSkyGradientsTextureUnitState->setTextureName (  gradients,   Ogre::TEX_TYPE_2D,   -1,   true );
           #else
           mSkyGradientsTextureUnitState->setTextureName (  gradients,   Ogre::TEX_TYPE_2D );
           mSkyGradientsTextureUnitState->setIsAlpha (  true );
           #endif
           }
          
           setFogColoursImage (  gradients );
          }
          
      29  Ogre::ColourValue StoredImageSkyColourModel::getFogColour (  float time,   const Ogre::Vector3 &sunDir ) {
           if (  mFogColourMap == 0 ) {
           return Ogre::ColourValue::White;
           }
           else {
           return getInterpolatedColour (  time,   1,   mFogColourMap );
           }
          }
          
      38  float StoredImageSkyColourModel::getFogDensity (  float time,   const Ogre::Vector3 &sunDir ) {
           if (  mFogColourMap == 0 ) {
           return mFogDensity;
           }
           else {
           return mFogDensity * (  getInterpolatedColour (  time,   1,   mFogColourMap ) ).a;
           }
          }
          
      47  void StoredImageSkyColourModel::setFogDensity (  float density ) {
           mFogDensity = density;
          }
          
      51  void StoredImageSkyColourModel::setFogColoursImage (  const Ogre::String &name ) {
           if (  mFogColourMap == 0 )
           mFogColourMap = new Ogre::Image (   );
          
           mFogColourMap->load (  name,   RESOURCE_GROUP_NAME );
          }
          
      58  Ogre::ColourValue StoredImageSkyColourModel::getSunColour (  float time,   const Ogre::Vector3 &sunDir ) {
           if (  mSkyGradientsTextureUnitState == 0 ) {
           return Ogre::ColourValue::White;
           }
           else {
           return getInterpolatedColour (  time,   sunDir.y,   mSkyGradientsImage );
           }
          }
          
      67  bool StoredImageSkyColourModel::updateMaterial (  Ogre::GpuProgramParametersSharedPtr fpp,   Ogre::GpuProgramParametersSharedPtr vpp,   float time,   const Ogre::Vector3 &sunDir ) {
           mSkyGradientsTextureUnitState->setTextureUScroll (  time );
           if (  !fpp.isNull (   ) ) {
           fpp->setNamedConstant (  "offset",   time );
           }
          
           return true;
          }
          
      76  Ogre::ColourValue StoredImageSkyColourModel::getInterpolatedColour (  float x,   float height,   Ogre::Image *img,   bool wrap ) {
           // Get the image width
           int width = img->getWidth (   );
          
           // calculate the height
           int y = (  int  )(  img->getHeight (   ) * height );
           if (  y >= img->getHeight (   ) )
           y--;
          
           // Get the two closest pixels
           int curPix,   auxPix;
           float diff;
           curPix = (  int  )(  width * x );
           diff = width * x - curPix;
           if (  diff < 0 ) {
           auxPix = curPix - 1;
           }
           else {
           auxPix = curPix + 1;
           }
          
           // Calculate the interpolated pixel
           Ogre::ColourValue c1,   c2,   cf;
           c1 = img->getColourAt (  wrap ? curPix % width : curPix > width ? width : curPix,   y,   0 );
           c2 = img->getColourAt (  wrap ? auxPix % width : auxPix > width ? width : auxPix,   y,   0 );
           cf = c1 * (  1 - diff ) + c2 * diff;
          
           return cf;
          }
          
          } // namespace caelum

./components/ogre/environment/caelum/src/Sun.cpp

       1  #include "Sun.h"
          #include "CaelumSystem.h"
          
          namespace caelum {
          
          const Ogre::String Sun::SUN_MATERIAL_NAME = "CaelumSunMaterial";
          
       8  Sun::Sun (  Ogre::SceneManager *sceneMgr ) {
           mSunColour = Ogre::ColourValue::White;
           mAutoRadius = true;
           mSunPositionModel = 0;
           mSunDirection = -Ogre::Vector3::UNIT_Z;
          
           mMainLight = sceneMgr->createLight (  "CaelumSun" );
           mMainLight->setType (  Ogre::Light::LT_DIRECTIONAL );
           mMainLight->setPowerScale (  10 ); // REALLY bright.
          
           createSunMaterial (   );
          
           if (  sceneMgr->hasSceneNode(  "SunNode" ) ) {
           mSunNode = sceneMgr->getSceneNode(   "SunNode" );
           } else {
           mSunNode = sceneMgr->getRootSceneNode (   )->createChildSceneNode(  "SunNode" );
           }
           mSunEntity = sceneMgr->createEntity (  "CaelumSun",   "3d_objects/environment/sky/models/sphere/sphere.mesh" );
           mSunEntity->setMaterialName (  SUN_MATERIAL_NAME );
           mSunEntity->setCastShadows (  false );
           mSunEntity->setRenderQueueGroup (  Ogre::RENDER_QUEUE_SKIES_EARLY + 3 );
           mSunNode->attachObject (  mSunEntity );
           mSunNode->_update(  true,   false );
           if (  mSunEntity->getBoundingRadius (   ) ) {
           ///make it one unit in size
           Ogre::Real scale = 1 / mSunEntity->getBoundingRadius (   );
           mSunNode->setScale(  scale,   scale,   scale );
          // mSunNode->showBoundingBox(  true );
           }
          }
          
      39  Sun::~Sun (   ) {
           if (  mSunNode ) {
           mSunNode->detachObject (  mSunEntity );
           static_cast<Ogre::SceneNode *>(  mSunNode->getParent (   ) )->removeAndDestroyChild (  mSunNode->getName (   ) );
           mSunNode = 0;
           }
           if (  mSunEntity ) {
           mSunEntity->_getManager (   )->destroyEntity (  mSunEntity );
           mSunEntity = 0;
           }
          
           destroySunMaterial (   );
          
           if (  mMainLight ) {
           mMainLight->_getManager (   )->destroyLight (  mMainLight );
           mMainLight = 0;
           }
          
           if (  mSunPositionModel ) {
           delete mSunPositionModel;
           }
          }
          
      62  void Sun::notifyCameraChanged (  Ogre::Camera *cam ) {
           float sunRadius0;
           if (  mAutoRadius ) {
           if (  cam->getFarClipDistance (   ) > 0 ) {
           mRadius = (  cam->getFarClipDistance (   ) - CAMERA_DISTANCE_MODIFIER ) * 0.5;
           sunRadius0 = -1;
           }
           else {
           mRadius = (  cam->getNearClipDistance (   ) + CAMERA_DISTANCE_MODIFIER ) * 2;
           sunRadius0 = 1;
           }
           }
           sunRadius0 *= mRadius * Ogre::Math::Tan (  Ogre::Degree (  0.01 ) );
           mSunNode->setPosition (  cam->getRealPosition (   ) - mSunDirection * (  mRadius + sunRadius0 ) );
           //ember: we don't need to scale it
           //mSunNode->setScale (  Ogre::Vector3::UNIT_SCALE * (  mRadius + sunRadius0 ) * Ogre::Math::Tan (  Ogre::Degree (  0.01 ) ) );
          }
          
      80  void Sun::setFarRadius (  float radius ) {
           if (  radius > 0 ) {
           mRadius = radius;
           mAutoRadius = false;
           }
           else {
           mAutoRadius = true;
           }
          }
          
      90  void Sun::update (  const float time ) {
           Ogre::Vector3 dir = Ogre::Vector3::NEGATIVE_UNIT_Y;
          
           if (  mSunPositionModel ) {
           dir = mSunPositionModel->update (  time );
           }
          
           // Update the main light direction
           if (  mMainLight != 0 ) {
           mMainLight->setDirection (  dir );
           ///hide the sun if it's below the horizon
           if (  dir.y > 0 ) {
           mMainLight->setVisible(  false );
           } else {
           mMainLight->setVisible(  true );
           }
           }
          
           // Store the latest sun direction.
           mSunDirection = dir;
          }
          
     112  SunPositionModel *Sun::setSunPositionModel (  SunPositionModel *model ) {
           SunPositionModel *temp = mSunPositionModel;
          
           mSunPositionModel = model;
          
           return temp;
          }
          
     120  SunPositionModel *Sun::getSunPositionModel (   ) const {
           return mSunPositionModel;
          }
          
     124  Ogre::Vector3 Sun::getSunDirection (   ) const {
           return mSunDirection;
          }
          
          /**
          "Normalizes" a colour value,   i.e. makes sure that it stays within [0..1] range.
          */
     131  Ogre::ColourValue& normalizeColour(  Ogre::ColourValue& colour )
          {
           Ogre::Real max = 0.0f;
           max = std::max<Ogre::Real>(  colour[0],   max );
           max = std::max<Ogre::Real>(  colour[1],   max );
           max = std::max<Ogre::Real>(  colour[2],   max );
           if (  max > 1 ) {
           Ogre::Real adjust = 1.0f / max;
           colour[0] = adjust * colour[0];
           colour[1] = adjust * colour[1];
           colour[2] = adjust * colour[2];
           }
           return colour;
          }
          
     146  void Sun::setSunColour (  Ogre::ColourValue colour ) {
           colour = Ogre::ColourValue (  1,   1,   0.9 );
          /* colour = colour * Ogre::ColourValue (  1,   1,   0.9 );
           colour = colour * 3;*/
           ///we need to normalize it because some shaders might not be able to cope with colours that go beyond 1
          // normalizeColour(  colour );
           mMainLight->setDiffuseColour (  colour );
           mMainLight->setSpecularColour (  colour );
          
           colour += Ogre::ColourValue (  .5,   .4,   .2 );
          // normalizeColour(  colour );
           mSunMaterial->setSelfIllumination (  colour );
          
           // Store this last colour
           mSunColour = colour;
          }
          
     163  Ogre::ColourValue Sun::getSunColour (   ) {
           return mSunColour;
          }
          
     167  void Sun::createSunMaterial (   ) {
           Ogre::MaterialPtr mat;
          
           LOG (  "Generating sun material..." );
           if (  !Ogre::MaterialManager::getSingleton (   ).resourceExists (  SUN_MATERIAL_NAME ) ) {
           LOG (  "\tMaterial not found; creating..." );
           mat = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton (   ).create (  SUN_MATERIAL_NAME,   RESOURCE_GROUP_NAME ) );
           mat->setReceiveShadows (  false );
           LOG (  "\t\tMaterial [OK]" );
           Ogre::Pass *pass = mat->getTechnique (  0 )->getPass (  0 );
           pass->setDepthCheckEnabled (  false );
           pass->setDepthWriteEnabled (  false );
          // pass->setLightingEnabled (  false );
           pass->setFog (  true );
           pass->setAmbient (  Ogre::ColourValue::Black );
           pass->setDiffuse (  Ogre::ColourValue::Black );
           pass->setSpecular (  Ogre::ColourValue::Black );
           LOG (  "\t\tPass [OK]" );
           mat->load (   );
           LOG (  "\tDONE" );
           }
           else {
           mat = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton (   ).getByName (  SUN_MATERIAL_NAME ) );
           }
           LOG (  "DONE" );
          
           mSunMaterial = mat;
          }
          
     196  void Sun::destroySunMaterial (   ) {
           LOG (  "Removing sun material..." );
           if (  Ogre::MaterialManager::getSingleton (   ).resourceExists (  SUN_MATERIAL_NAME ) ) {
           Ogre::MaterialManager::getSingleton (   ).remove (  SUN_MATERIAL_NAME );
           }
           mSunMaterial.setNull (   );
           LOG (  "DONE" );
          }
          
          } // namespace caelum

./components/ogre/environment/meshtree/MeshTree.cpp

       1  #include "MeshTree.h"
          
          //---------------------------------------------------------------------------
          
          /*
           Based "The Creation and Rendering of Realistic Trees" article by Jason Weber and Joseph Penn
           Based on a port of Delphi code from TReal project by Ton van den Heuvel
           For further information go see:
           http://members.chello.nl/~l.vandenheuvel2/TReal/
           Copyright (  c ) 2002-2003,   Ton van den Heuvel
           Copyright (  c ) 2004,   Nicolas Chauvin
          
           ==================================
           Tree generation classes for Ogre3D
           ==================================
          
          */
          
          namespace Ogre {
          
          //===========================================================================
          // Class Tree
          //===========================================================================
          
      25  Tree::Tree(  const String& name,   TParameters *pParameters,   uchar u8Season,   int iSeed )
          {
           if (  iSeed == -1 )
           {
           srand(  time(  0 ) );
           }
           else
           {
           srand(  iSeed );
           }
          
           mpParameters = pParameters->Clone(   );
           mpTrunk = new TStem(  this );
           mfMaxX = 0.0;
           mfMaxY = 0.0;
           mfMaxZ = 0.0;
           miTotalStems = 0;
           miTotalVertices = 0;
           miTotalFaces = 0;
           miTotalLeaves = 0;
           miTotalLeavesFaces = 0;
           miTotalCoordFrames = 0;
           mu8Season = u8Season;
           mfScale = mpParameters->mfScale + GetRandomValue(  mpParameters->mfScaleV );
           mfTrunkLength = (  mpParameters->mafNLength[0] + GetRandomValue(  mpParameters->mafNLengthV[0] ) ) * mfScale;
           mfTrunkRadius = mfTrunkLength * mpParameters->mfRatio * mpParameters->mfScale0;
          
           mpTrunk->CreateStructure(  NULL,   mfTrunkLength,   0,   0 );
          
          }
          
          //---------------------------------------------------------------------------
          
      58  Tree::~Tree(   )
          {
           delete mpParameters;
           delete mpTrunk;
          }
          
          //---------------------------------------------------------------------------
          
      66  void Tree::Grow(  void )
          {
           // Create trunk
           TSectionFrame treeFrame(  Quaternion::IDENTITY,   Vector3(  0,  0,  0 ),   Vector3(  0,  0,  0 ) );
           mpTrunk->Grow(  treeFrame,   mfTrunkRadius,   0 );
          }
          
          //---------------------------------------------------------------------------
          
      75  Real Tree::GetRandomValue(  const Real fUpperBound )
          {
           int iSign = 1;
           int iPrecision = 1000;
          
           if (  fUpperBound == 0 )
           {
           return 0.0;
           }
           else
           {
           if (  rand(   )%2 == 1 )
           iSign = -1;
          
           return iSign*(  rand(   )%iPrecision ) * fUpperBound / iPrecision;
           }
          }
          
          //---------------------------------------------------------------------------
          
      95  Ogre::MeshPtr Tree::CreateMesh(  const String &name )
          {
           //HACK: implement ManualResourceLoader
           Ogre::MeshPtr pMesh = MeshManager::getSingleton(   ).createManual(  name,  "trees" );
           SubMesh *pStemsSub,   *pLeavesSub,   *pCoordFrameSub;
          
           // Set up vertex data
           // Use a single shared buffer
           pMesh->sharedVertexData = new VertexData(   );
           VertexData* vertexData = pMesh->sharedVertexData;
           // Set up Vertex Declaration
           VertexDeclaration* vertexDecl = vertexData->vertexDeclaration;
           size_t currOffset = 0;
           // We always need positions
           vertexDecl->addElement(  POSITION_BINDING,   currOffset,   VET_FLOAT3,   VES_POSITION );
           currOffset += VertexElement::getTypeSize(  VET_FLOAT3 );
          
           // normals
           vertexDecl->addElement(  POSITION_BINDING,   currOffset,   VET_FLOAT3,   VES_NORMAL );
           currOffset += VertexElement::getTypeSize(  VET_FLOAT3 );
          
           // 2D texture coords
           vertexDecl->addElement(  POSITION_BINDING,   currOffset,   VET_FLOAT2,   VES_TEXTURE_COORDINATES,   0 );
           currOffset += VertexElement::getTypeSize(  VET_FLOAT2 );
          
           // vertex color
           vertexDecl->addElement(  COLOUR_BINDING,   currOffset,   VET_COLOUR,   VES_DIFFUSE );
           currOffset += VertexElement::getTypeSize(  VET_COLOUR );
          
           vertexData->vertexCount = miTotalVertices;
          
           // Allocate vertex buffer
           HardwareVertexBufferSharedPtr vbuf =
           HardwareBufferManager::getSingleton(   ).
           createVertexBuffer(  vertexDecl->getVertexSize(  POSITION_BINDING ),   vertexData->vertexCount,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
          
           // Set up the binding (  one source only )
           VertexBufferBinding* binding = vertexData->vertexBufferBinding;
           binding->setBinding(  POSITION_BINDING,   vbuf );
          
           // Generate vertex data recurcively
           // Lock the whole buffer
           Real* pVertexArray = static_cast<Real*>(   vbuf->lock(  HardwareBuffer::HBL_DISCARD )  );
          
           HardwareVertexBufferSharedPtr vcolbuf =
           HardwareBufferManager::getSingleton(   ).
           createVertexBuffer(  vertexDecl->getVertexSize(  COLOUR_BINDING ),   vertexData->vertexCount,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
           // bind position and diffuses
           binding->setBinding(  COLOUR_BINDING,   vcolbuf );
          
           RGBA* pVertexColorArray = static_cast<RGBA*>(   vcolbuf->lock(  HardwareBuffer::HBL_DISCARD )  );
          
           mpTrunk->AddMeshVertices(  &pVertexArray,   &pVertexColorArray );
           if (  miTotalLeaves > 0 )
           mpTrunk->AddLeavesVertices(  &pVertexArray,   &pVertexColorArray,   0 );
           if (  this->mpParameters->mTreeType == TParameters::Simple )
           mpTrunk->AddCoordFrameVertices(  &pVertexArray,   &pVertexColorArray );
          
           // Unlock
           vbuf->unlock(   );
           vcolbuf->unlock(   );
          
           // Generate face list for the trunk and the stems
           pStemsSub = pMesh->createSubMesh(   );
           pStemsSub->useSharedVertices = true;
          
           pStemsSub->indexData->indexCount = 3 * miTotalFaces;
           pStemsSub->indexData->indexBuffer = HardwareBufferManager::getSingleton(   ).
           createIndexBuffer(   HardwareIndexBuffer::IT_32BIT /*HardwareIndexBuffer::IT_16BIT */ ,  
           pStemsSub->indexData->indexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
          
           // int v1,   v2,   v3;
           HardwareIndexBufferSharedPtr ibuf = pStemsSub->indexData->indexBuffer;
           // Lock the whole buffer
           // unsigned short* pFaceIndexes = static_cast<unsigned short*> (   ibuf->lock(  HardwareBuffer::HBL_DISCARD )  );
           unsigned long* pFaceIndexes = static_cast<unsigned long*> (   ibuf->lock(  HardwareBuffer::HBL_DISCARD )  );
          
           unsigned long u32VertexIndexOffset = 0;
           mpTrunk->AddMeshFaces(  &pFaceIndexes,   &u32VertexIndexOffset );
          
           // Unlock
           ibuf->unlock(   );
          
           // Generate face list for the leaves
           if (  miTotalLeaves > 0 )
           {
           pLeavesSub = pMesh->createSubMesh(   );
           pLeavesSub->useSharedVertices = true;
          
           pLeavesSub->indexData->indexCount = 3 * miTotalLeavesFaces;
           pLeavesSub->indexData->indexBuffer = HardwareBufferManager::getSingleton(   ).
           createIndexBuffer(  HardwareIndexBuffer::IT_32BIT /*HardwareIndexBuffer::IT_16BIT*/,  
           pLeavesSub->indexData->indexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
          
           // int v1,   v2,   v3;
           ibuf = pLeavesSub->indexData->indexBuffer;
           // Lock the whole buffer
           // pFaceIndexes = static_cast<unsigned short*>(   ibuf->lock(  HardwareBuffer::HBL_DISCARD )  );
           pFaceIndexes = static_cast<unsigned long*>(   ibuf->lock(  HardwareBuffer::HBL_DISCARD )  );
          
           mpTrunk->AddLeavesMeshFaces(  &pFaceIndexes,   &u32VertexIndexOffset );
          
           // Unlock
           ibuf->unlock(   );
           }
          
          
           // Generate face list for the coordinate frame display
           if (  this->mpParameters->mTreeType == TParameters::Simple )
           {
           pCoordFrameSub = pMesh->createSubMesh(   );
           pCoordFrameSub->useSharedVertices = true;
          
           pCoordFrameSub->indexData->indexCount = 3 * 9 * miTotalCoordFrames; // 9 faces per coord frames
           pCoordFrameSub->indexData->indexBuffer = HardwareBufferManager::getSingleton(   ).
           createIndexBuffer(  HardwareIndexBuffer::IT_32BIT /*HardwareIndexBuffer::IT_16BIT*/,  
           pCoordFrameSub->indexData->indexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
          
           ibuf = pCoordFrameSub->indexData->indexBuffer;
           // Lock the whole buffer
           pFaceIndexes = static_cast<unsigned long*>(   ibuf->lock(  HardwareBuffer::HBL_DISCARD )  );
          
           mpTrunk->AddCoordFrameMeshFaces(  &pFaceIndexes,   &u32VertexIndexOffset );
          
           // Unlock
           ibuf->unlock(   );
           }
          
           // TODO: Improve AAB + SphereRadius !!!!!!!!!!!
           Vector3 vb1,   vb2;
           vb1 = Vector3(  -mfMaxX,   0,   -mfMaxZ ) ;
           vb2 = Vector3(  mfMaxX,   mfMaxY,   mfMaxZ ) ;
           pMesh->_setBounds(  AxisAlignedBox(  vb1,   vb2 ) );
           pMesh->_setBoundingSphereRadius(  Math::Sqrt(  (  vb2-vb1 ).Vector3::dotProduct(  vb2-vb1 ) )/2.0 );
          
           return pMesh;
          }
          //---------------------------------------------------------------------------
          
          } // namespace

./components/ogre/environment/meshtree/MeshTree.h

       1  #ifndef __MeshTree_H__
          #define __MeshTree_H__
          
          #include "../../OgreIncludes.h"
          #include "TTypes.h"
          #include "TStem.h"
          #include "TParameters.h"
          
          #define FLARE_RESOLUTION 10
          
          /*
           Based "The Creation and Rendering of Realistic Trees" article by Jason Weber and Joseph Penn
           Based on a port of Delphi code from TReal project by Ton van den Heuvel
           For further information go see:
           http://members.chello.nl/~l.vandenheuvel2/TReal/
           Copyright (  c ) 2002-2003,   Ton van den Heuvel
           Copyright (  c ) 2004,   Nicolas Chauvin
          
           ==================================
           Tree generation classes for Ogre3D
           ==================================
          
          */
          
          namespace Ogre {
          
          
          #define POSITION_BINDING 0
          #define COLOUR_BINDING 1
          
          //---------------------------------------------------------------------------
          
      33  class Tree
          {
      35   friend class TStem;
          
           private:
          
      39   TStem *mpTrunk;
      40   Real mfTrunkLength;
      41   Real mfTrunkRadius;
      42   Real mfScale;
           int miTotalStems;
      44   Real mfMaxX; // Variables holding the maximum x,   y and z values
      45   Real mfMaxY; // occurring in the tree
      46   Real mfMaxZ;
      47   uchar mu8Season;
          
           protected:
          
      51   TParameters *mpParameters;
           int miTotalLeaves;
           int miTotalVertices;
           int miTotalFaces;
           int miTotalLeavesFaces;
           int miTotalCoordFrames;
          
           public:
          
      60   Tree(  const String& name,   TParameters *pParameters,   uchar u8Season,   int iSeed = -1 );
      61   ~Tree(   );
          
      63   void Grow(  void );
      64   Real GetRandomValue(  const Real fUpperBound );
      65   Ogre::MeshPtr CreateMesh(  const String &name );
      66   inline TParameters* GetParameters(  void ){return mpParameters;};
      67   inline Real GetScale(  void ){return mfScale;};
          };
          
          //---------------------------------------------------------------------------
          
          } // namespace
          
          #endif

./components/ogre/environment/meshtree/TParameters.cpp

       1  #include "TParameters.h"
          
          //---------------------------------------------------------------------------
          
          /*
           Based "The Creation and Rendering of Realistic Trees" article by Jason Weber and Joseph Penn
           Based on a port of Delphi code from TReal project by Ton van den Heuvel
           For further information go see:
           http://members.chello.nl/~l.vandenheuvel2/TReal/
           Copyright (  c ) 2002-2003,   Ton van den Heuvel
           Copyright (  c ) 2004,   Nicolas Chauvin
          
           ==================================
           Tree generation classes for Ogre3D
           ==================================
          
          */
          
          namespace Ogre {
          
          
          //===========================================================================
          // Class TParameters
          //===========================================================================
          
      26  TParameters::TParameters(  uchar u8Levels )
          {
          
           mu8Levels = u8Levels;
          
           // The array length of the Stem parameters is equal to u8Levels. So,   the total
           // length of the stem parameter arrays is u8Levels - 1,   because the last level
           // of recursion is reserved for the leaves.
          
           mafNDownAngle = new Real[u8Levels];
           mafNDownAngleV = new Real[u8Levels];
           mafNRotate = new Real[u8Levels];
           mafNRotateV = new Real[u8Levels];
           mafNLength = new Real[u8Levels];
           mafNLengthV = new Real[u8Levels];
           mafNTaper = new Real[u8Levels];
           maiNBranches = new int[u8Levels];
           mafNSegSplits = new Real[u8Levels];
           mafNSplitAngle = new Real[u8Levels];
           mafNSplitAngleV = new Real[u8Levels];
           maiNCurveRes = new int[u8Levels];
           mafNCurve = new Real[u8Levels];
           mafNCurveBack = new Real[u8Levels];
           mafNCurveV = new Real[u8Levels];
           maiNVertices = new int[u8Levels];
          
           mu8LeafAlpha = 0xFF;
          }
          
          //---------------------------------------------------------------------------
          
      57  TParameters::~TParameters(   )
          {
           delete []mafNDownAngle;
           delete []mafNDownAngleV;
           delete []mafNRotate;
           delete []mafNRotateV;
           delete []mafNLength;
           delete []mafNLengthV;
           delete []mafNTaper;
           delete []maiNBranches;
           delete []mafNSegSplits;
           delete []mafNSplitAngle;
           delete []mafNSplitAngleV;
           delete []maiNCurveRes;
           delete []mafNCurve;
           delete []mafNCurveBack;
           delete []mafNCurveV;
           delete []maiNVertices;
          }
          
          //---------------------------------------------------------------------------
          
      79  void TParameters::Set(  TreeType eType )
          {
           mTreeType = eType;
          
           switch(  eType )
           {
           case Simple:
           SetLevels(  3 );
           SetShape(  4 );
           SetBaseSize(  0.3 );
           SetScale(  10.0 );
           SetScaleV(  0.0 );
           SetZScale(  1.0 );
           SetZScaleV(  0.0 );
           SetRatio(  0.015 );
           SetRatioPower(  1.2 );
           SetLobes(  0 );
           SetLobeDepth(  0.0 );
           SetFlare(  0.0 );
           SetLeaves(  0 );
           SetLeafShape(  0 );
           SetLeafScale(  1.0 );
           SetLeafScaleX(  1.0 );
           SetLeafQuality(  0.0 );
           SetAttractionUp(  0.0 );
           SetScale0(  1.0 );
           SetScaleV0(  0.0 );
          
           SetnLength(  0,   1.0 );
           SetnLengthV(  0,   0.0 );
           SetnTaper(  0,   1.8 );
           SetnSegSplits(  0,   0.0 );
           SetnSplitAngle(  0,   0.0 );
           SetnSplitAngleV(  0,   0.0 );
           SetnVertices(  0,   6 );
           SetnCurveRes(  0,   4 );
           SetnCurve(  0,   0.0 );
           SetnCurveV(  0,   0.0 );
           SetnCurveBack(  0,   0.0 );
          
           SetnBranches(  1,   4 );
           SetnVertices(  1,   4 );
           SetnLength(  1,   0.4 );
           SetnLengthV(  1,   0.0 );
           SetnTaper(  1,   1.8 );
           SetnDownAngle(  1,   45.0 );
           SetnDownAngleV(  1,   0.0 );
           SetnRotate(  1,   90.0 );
           SetnRotateV(  1,   0.0 );
           SetnSegSplits(  1,   0.0 );
           SetnSplitAngle(  1,   0.0 );
           SetnSplitAngleV(  1,   0.0 );
           SetnCurveRes(  1,   4 );
           SetnCurve(  1,   60.0 );
           SetnCurveV(  1,   0.0 );
           SetnCurveBack(  1,   0.0 );
          
           SetnBranches(  2,   6 );
           SetnVertices(  2,   4 );
           SetnLength(  2,   1.0 );
           SetnLengthV(  2,   0.0 );
           SetnTaper(  2,   1.3 );
           SetnDownAngle(  2,   20.0 );
           SetnDownAngleV(  2,   0.0 );
           SetnRotate(  2,   120.0 );
           SetnRotateV(  2,   0.0 );
           SetnSegSplits(  2,   0.0 );
           SetnSplitAngle(  2,   0.0 );
           SetnSplitAngleV(  2,   0.0 );
           SetnCurveRes(  2,   3 );
           SetnCurve(  2,   90.0 );
           SetnCurveV(  2,   0.0 );
           SetnCurveBack(  2,   0.0 );
           break;
          
           case Black_Tupelo:
           SetLevels(  4 );
           SetShape(  4 );
           SetBaseSize(  0.2 );
           SetScale(  23.0 );
           SetScaleV(  5.0 );
           SetZScale(  1.0 );
           SetZScaleV(  0.0 );
           SetRatio(  0.015 );
           SetRatioPower(  1.3 );
           SetLobes(  3 );
           SetLobeDepth(  0.1 );
           SetFlare(  1.0 );
           SetLeaves(  6 );
           SetLeafShape(  0 );
           SetLeafScale(  0.3 );
           SetLeafScaleX(  0.5 );
           SetLeafQuality(  1.25 );
           SetAttractionUp(  0.5 );
           SetScale0(  1.0 );
           SetScaleV0(  0.0 );
          
           SetnLength(  0,   1.0 );
           SetnLengthV(  0,   0.0 );
           SetnTaper(  0,   1.1 );
           SetnSegSplits(  0,   0.0 );
           SetnSplitAngle(  0,   0.0 );
           SetnSplitAngleV(  0,   0.0 );
           SetnVertices(  0,   24 );
           SetnCurveRes(  0,   10 );
           SetnCurve(  0,   0.0 );
           SetnCurveV(  0,   40.0 );
           SetnCurveBack(  0,   0.0 );
          
           SetnBranches(  1,   50 );
           SetnVertices(  1,   6 );
           SetnLength(  1,   0.3 );
           SetnLengthV(  1,   0.05 );
           SetnTaper(  1,   1.0 );
           SetnDownAngle(  1,   60.0 );
           SetnDownAngleV(  1,   -40.0 );
           SetnRotate(  1,   140.0 );
           SetnRotateV(  1,   0.0 );
           SetnSegSplits(  1,   0.0 );
           SetnSplitAngle(  1,   0.0 );
           SetnSplitAngleV(  1,   0.0 );
           SetnCurveRes(  1,   10 );
           SetnCurve(  1,   0.0 );
           SetnCurveV(  1,   90.0 );
           SetnCurveBack(  1,   0.0 );
          
           SetnBranches(  2,   25 );
           SetnVertices(  2,   6 );
           SetnLength(  2,   0.6 );
           SetnLengthV(  2,   0.1 );
           SetnTaper(  2,   1.0 );
           SetnDownAngle(  2,   30.0 );
           SetnDownAngleV(  2,   10.0 );
           SetnRotate(  2,   140.0 );
           SetnRotateV(  2,   0.0 );
           SetnSegSplits(  2,   0.0 );
           SetnSplitAngle(  2,   0.0 );
           SetnSplitAngleV(  2,   0.0 );
           SetnCurveRes(  2,   10 );
           SetnCurve(  2,   10.0 );
           SetnCurveV(  2,   150.0 );
           SetnCurveBack(  2,   0.0 );
          
           SetnBranches(  3,   12 );
           SetnVertices(  3,   3 );
           SetnLength(  3,   0.4 );
           SetnLengthV(  3,   0.0 );
           SetnTaper(  3,   1.0 );
           SetnDownAngle(  3,   45.0 );
           SetnDownAngleV(  3,   10.0 );
           SetnRotate(  3,   140.0 );
           SetnRotateV(  3,   0.0 );
           SetnSegSplits(  3,   0.0 );
           SetnSplitAngle(  3,   0.0 );
           SetnSplitAngleV(  3,   0.0 );
           SetnCurveRes(  3,   1 );
           SetnCurve(  3,   0.0 );
           SetnCurveV(  3,   0.0 );
           SetnCurveBack(  3,   0.0 );
           break;
          
           case Weeping_Willow:
           SetLevels(  4 );
           SetShape(  3 );
           SetBaseSize(  0.05 );
           SetScale(  15.0 );
           SetScaleV(  5.0 );
           SetZScale(  1.0 );
           SetZScaleV(  0.0 );
           SetRatio(  0.03 );
           SetRatioPower(  2.0 );
           SetLobes(  9 );
           SetLobeDepth(  0.03 );
           SetFlare(  0.75 );
           SetLeaves(  10 );
           SetLeafShape(  0 );
           SetLeafScale(  0.2 );
           SetLeafScaleX(  0.2 );
           SetLeafQuality(  1.0 );
           SetAttractionUp(  -2.0 );
           SetScale0(  1.0 );
           SetScaleV0(  0.0 );
          
           SetnLength(  0,   0.8 );
           SetnLengthV(  0,   0.0 );
           SetnTaper(  0,   1.0 );
           SetnSegSplits(  0,   0.1 );
           SetnSplitAngle(  0,   3.0 );
           SetnSplitAngleV(  0,   0.0 );
           SetnVertices(  0,   24 );
           SetnCurveRes(  0,   8 );
           SetnCurve(  0,   0.0 );
           SetnCurveV(  0,   120.0 );
           SetnCurveBack(  0,   20.0 );
          
           SetnBranches(  1,   25 );
           SetnVertices(  1,   6 );
           SetnLength(  1,   0.5 );
           SetnLengthV(  1,   0.1 );
           SetnTaper(  1,   1.0 );
           SetnDownAngle(  1,   20.0 );
           SetnDownAngleV(  1,   10.0 );
           SetnRotate(  1,   -120.0 );
           SetnRotateV(  1,   30.0 );
           SetnSegSplits(  1,   0.2 );
           SetnSplitAngle(  1,   30.0 );
           SetnSplitAngleV(  1,   10.0 );
           SetnCurveRes(  1,   16 );
           SetnCurve(  1,   40.0 );
           SetnCurveV(  1,   90.0 );
           SetnCurveBack(  1,   80.0 );
          
           SetnBranches(  2,   10 );
           SetnVertices(  2,   6 );
           SetnLength(  2,   1.5 );
           SetnLengthV(  2,   0.0 );
           SetnTaper(  2,   1.0 );
           SetnDownAngle(  2,   30.0 );
           SetnDownAngleV(  2,   10.0 );
           SetnRotate(  2,   -120.0 );
           SetnRotateV(  2,   30.0 );
           SetnSegSplits(  2,   0.2 );
           SetnSplitAngle(  2,   45.0 );
           SetnSplitAngleV(  2,   20.0 );
           SetnCurveRes(  2,   12 );
           SetnCurve(  2,   0.0 );
           SetnCurveV(  2,   0.0 );
           SetnCurveBack(  2,   0.0 );
          
           SetnBranches(  3,   100 );
           SetnVertices(  3,   3 );
           SetnLength(  3,   0.1 );
           SetnLengthV(  3,   0.0 );
           SetnTaper(  3,   1.0 );
           SetnDownAngle(  3,   20.0 );
           SetnDownAngleV(  3,   10.0 );
           SetnRotate(  3,   140.0 );
           SetnRotateV(  3,   0.0 );
           SetnSegSplits(  3,   0.0 );
           SetnSplitAngle(  3,   0.0 );
           SetnSplitAngleV(  3,   0.0 );
           SetnCurveRes(  3,   1 );
           SetnCurve(  3,   0.0 );
           SetnCurveV(  3,   0.0 );
           SetnCurveBack(  3,   0.0 );
           break;
          
           case Lombardy_Poplar:
           SetLevels(  3 );
           SetShape(  2 );
           SetBaseSize(  0.0 );
           SetScale(  25.0 );
           SetScaleV(  5.0 );
           SetZScale(  1.0 );
           SetZScaleV(  0.0 );
           SetRatio(  0.015 );
           SetRatioPower(  1.3 );
           SetLobes(  7 );
           SetLobeDepth(  0.05 );
           SetFlare(  0.8 );
           SetLeaves(  25 );
           SetLeafShape(  0 );
           SetLeafScale(  0.25 );
           SetLeafScaleX(  1.0 );
           SetLeafQuality(  1.0 );
           SetAttractionUp(  0.5 );
           SetScale0(  0.8 );
           SetScaleV0(  0.0 );
          
           SetnLength(  0,   1.0 );
           SetnLengthV(  0,   0.0 );
           SetnTaper(  0,   1.0 );
           SetnSegSplits(  0,   0.0 );
           SetnSplitAngle(  0,   0.0 );
           SetnSplitAngleV(  0,   0.0 );
           SetnVertices(  0,   24 );
           SetnCurveRes(  0,   1 );
           SetnCurve(  0,   0.0 );
           SetnCurveV(  0,   15.0 );
           SetnCurveBack(  0,   0.0 );
          
           SetnBranches(  1,   40 );
           SetnVertices(  1,   6 );
           SetnLength(  1,   0.3 );
           SetnLengthV(  1,   0.0 );
           SetnTaper(  1,   1.0 );
           SetnDownAngle(  1,   30.0 );
           SetnDownAngleV(  1,   0.0 );
           SetnRotate(  1,   77.0 );
           SetnRotateV(  1,   0.0 );
           SetnSegSplits(  1,   0.0 );
           SetnSplitAngle(  1,   0.0 );
           SetnSplitAngleV(  1,   0.0 );
           SetnCurveRes(  1,   3 );
           SetnCurve(  1,   -20.0 );
           SetnCurveV(  1,   0.0 );
           SetnCurveBack(  1,   0.0 );
          
           SetnBranches(  2,   30 );
           SetnVertices(  2,   4 );
           SetnLength(  2,   0.4 );
           SetnLengthV(  2,   0.0 );
           SetnTaper(  2,   1.0 );
           SetnDownAngle(  2,   30.0 );
           SetnDownAngleV(  2,   10.0 );
           SetnRotate(  2,   77.0 );
           SetnRotateV(  2,   0.0 );
           SetnSegSplits(  2,   0.0 );
           SetnSplitAngle(  2,   0.0 );
           SetnSplitAngleV(  2,   0.0 );
           SetnCurveRes(  2,   3 );
           SetnCurve(  2,   -20.0 );
           SetnCurveV(  2,   40.0 );
           SetnCurveBack(  2,   0.0 );
           break;
          
           case Palm:
           SetLevels(  2 );
           SetShape(  4 );
           SetBaseSize(  0.95 );
           SetScale(  12.0 );
           SetScaleV(  10.0 );
           SetZScale(  1.0 );
           SetZScaleV(  0.0 );
           SetRatio(  0.015 );
           SetRatioPower(  2.0 );
           SetLobes(  0 );
           SetLobeDepth(  0.0 );
           SetFlare(  0.0 );
           SetLeaves(  250 );
           SetLeafShape(  0 );
           SetLeafScale(  0.6 );
           SetLeafScaleX(  0.06 );
           SetLeafQuality(  1.0 );
           SetAttractionUp(  0.0 );
           SetScale0(  1.0 );
           SetScaleV0(  0.0 );
          
           SetnLength(  0,   1.0 );
           SetnLengthV(  0,   0.0 );
           SetnTaper(  0,   2.1 );
           SetnSegSplits(  0,   0.0 );
           SetnSplitAngle(  0,   0.0 );
           SetnSplitAngleV(  0,   0.0 );
           SetnVertices(  0,   16 );
           SetnCurveRes(  0,   60 );
           SetnCurve(  0,   20.0 );
           SetnCurveV(  0,   10.0 );
           SetnCurveBack(  0,   -5.0 );
          
           SetnBranches(  1,   33 );
           SetnVertices(  1,   8 );
           SetnLength(  1,   0.4 );
           SetnLengthV(  1,   0.05 );
           SetnTaper(  1,   1.0 );
           SetnDownAngle(  1,   70.0 );
           SetnDownAngleV(  1,   -80.0 );
           SetnRotate(  1,   120.0 );
           SetnRotateV(  1,   60.0 );
           SetnSegSplits(  1,   0.0 );
           SetnSplitAngle(  1,   0.0 );
           SetnSplitAngleV(  1,   0.0 );
           SetnCurveRes(  1,   9 );
           SetnCurve(  1,   50.0 );
           SetnCurveV(  1,   20.0 );
           SetnCurveBack(  1,   0.0 );
           break;
          
           case European_Larch:
           SetLevels(  3 );
           SetShape(  0 );
           SetBaseSize(  0.25 );
           SetScale(  15.0 );
           SetScaleV(  7.0 );
           SetZScale(  1.0 );
           SetZScaleV(  0.0 );
           SetRatio(  0.015 );
           SetRatioPower(  1.3 );
           SetLobes(  0 );
           SetLobeDepth(  0.0 );
           SetFlare(  0.3 );
           SetLeaves(  100 );
           SetLeafShape(  0 );
           SetLeafScale(  0.15 /*0.03*/ );
           SetLeafScaleX(  0.2 );
           SetLeafQuality(  0.5 );
           SetAttractionUp(  -2.0 );
           SetScale0(  1.0 );
           SetScaleV0(  0.0 );
          
           SetnLength(  0,   1.0 );
           SetnLengthV(  0,   0.0 );
           SetnTaper(  0,   1.0 );
           SetnSegSplits(  0,   0.0 );
           SetnSplitAngle(  0,   0.0 );
           SetnSplitAngleV(  0,   0.0 );
           SetnVertices(  0,   24 );
           SetnCurveRes(  0,   20 );
           SetnCurve(  0,   0.0 );
           SetnCurveV(  0,   20.0 );
           SetnCurveBack(  0,   0.0 );
          
           SetnBranches(  1,   60 );
           SetnVertices(  1,   6 );
           SetnLength(  1,   0.25 );
           SetnLengthV(  1,   0.15 );
           SetnTaper(  1,   1.0 );
           SetnDownAngle(  1,   60.0 );
           SetnDownAngleV(  1,   -50.0 );
           SetnRotate(  1,   70.0 );
           SetnRotateV(  1,   30.0 );
           SetnSegSplits(  1,   0.0 );
           SetnSplitAngle(  1,   0.0 );
           SetnSplitAngleV(  1,   0.0 );
           SetnCurveRes(  1,   17 );
           SetnCurve(  1,   20.0 );
           SetnCurveV(  1,   120.0 );
           SetnCurveBack(  1,   /*-100.0*/ -20.0 );
          
           SetnBranches(  2,   50 );
           SetnVertices(  2,   4 );
           SetnLength(  2,   0.3 );
           SetnLengthV(  2,   0.1 );
           SetnTaper(  2,   1.0 );
           SetnDownAngle(  2,   70.0 );
           SetnDownAngleV(  2,   30.0 );
           SetnRotate(  2,   70.0 );
           SetnRotateV(  2,   30.0 );
           SetnSegSplits(  2,   0.15 );
           SetnSplitAngle(  2,   40.0 );
           SetnSplitAngleV(  2,   10.0 );
           SetnCurveRes(  2,   7 );
           SetnCurve(  2,   0.0 );
           SetnCurveV(  2,   0.0 );
           break;
          
           case Quaking_Aspen:
           default:
           SetLevels(  3 );
           SetShape(  7 );
           SetBaseSize(  0.3 );
           SetScale(  13 );
           SetScaleV(  3 );
           SetZScale(  1 );
           SetZScaleV(  0 );
           SetRatio(  0.015 );
           SetRatioPower(  1.2 );
           SetLobes(  5 );
           SetLobeDepth(  0.07 );
           SetFlare(  0.6 );
          
           SetScale0(  1 );
           SetScaleV0(  0 );
           SetnBranches(  0,   1 );
           SetnVertices(  0,   6 );
           SetnLength(  0,   1 );
           SetnLengthV(  0,   0 );
           SetnTaper(  0,   1 );
           SetnSegSplits(  0,   0 );
           SetnSplitAngle(  0,   0 );
           SetnSplitAngleV(  0,   0 );
           SetnCurveRes(  0,   3 );
           SetnCurve(  0,   0 );
           SetnCurveBack(  0,   0 );
           SetnCurveV(  0,   20 );
          
           SetnBranches(  1,   50 );
           SetnVertices(  1,   6 );
           SetnDownAngle(  1,   60 );
           SetnDownAngleV(  1,   -50 );
           SetnRotate(  1,   140 );
           SetnRotateV(  1,   0 );
           SetnLength(  1,   0.3 );
           SetnLengthV(  1,   0 );
           SetnTaper(  1,   1 );
           SetnSegSplits(  1,   0 );
           SetnSplitAngle(  1,   0 );
           SetnSplitAngleV(  1,   0 );
           SetnCurveRes(  1,   5 );
           SetnCurve(  1,   -40 );
           SetnCurveBack(  1,   0 );
           SetnCurveV(  1,   50 );
          
           SetnBranches(  2,   35 );
           SetnVertices(  2,   4 );
           SetnDownAngle(  2,   45 );
           SetnDownAngleV(  2,   10 );
           SetnRotate(  2,   140 );
           SetnRotateV(  2,   0 );
           SetnLength(  2,   0.6 );
           SetnLengthV(  2,   0 );
           SetnTaper(  2,   1 );
           SetnSegSplits(  2,   0 );
           SetnSplitAngle(  2,   0 );
           SetnSplitAngleV(  2,   0 );
           SetnCurveRes(  2,   3 );
           SetnCurve(  2,   -40 );
           SetnCurveBack(  2,   0 );
           SetnCurveV(  2,   75 );
          
           SetLeaves(  25 );
           SetLeafQuality(  1.0 );
           // SetLeafShape(  0 ); // not implemented yet
           SetLeafScale(  0.25 );
           SetLeafScaleX(  1 );
           SetAttractionUp(  0.5 );
           SetPruneRatio(  0 );
           // SetPruneWidth(  0.5 ); // not implemented yet
           // SetPruneWidthPeak(  0.5 ); // not implemented yet
           // SetPrunePowerLow(  0.5 ); // not implemented yet
           // SetPrunePowerHigh(  0.5 ); // not implemented yet
           break;
          
           case Fir:
           SetZScale(  1 );
           SetZScaleV(  0 );
          
           SetShape(  0 );
           SetLevels(  3 );
           SetScale(  2 );
           SetScaleV(  1 );
           SetBaseSize(  0.1 );
           SetRatio(  0.012 );
           SetRatioPower(  1.0 );
           SetFlare(  0.2 );
           SetLobes(  0 );
           SetLobeDepth(  0.0 );
           SetLeaves(  70 );
           SetLeafShape(  0 );
           SetLeafScale(  0.03 /*0.03*/ );
           SetLeafScaleX(  0.03 );
           SetLeafQuality(  1.0 );
           SetAttractionUp(  0.5 );
           SetPruneRatio(  0 );
           SetPrunePowerLow(  0.5 ); // not implemented yet
           SetPrunePowerHigh(  0.5 ); // not implemented yet
           SetPruneWidth(  0.5 ); // not used yet !!!!
           SetPruneWidthPeak(  0.5 ); // not used yet !!!!
           SetScale0(  1.0 );
           SetScaleV0(  0.0 );
           SetBaseSplits(  0 );
          
           SetnDownAngle(  0,   0 );
           SetnDownAngleV(  0,   0 );
           SetnRotate(  0,   0 );
           SetnRotateV(  0,   0 );
           SetnBranches(  0,   1 );
           SetnVertices(  0,   4 );
           SetnLength(  0,   1 );
           SetnLengthV(  0,   0 );
           SetnTaper(  0,   1 );
           SetnSegSplits(  0,   0 );
           SetnSplitAngle(  0,   0 );
           SetnSplitAngleV(  0,   0 );
           SetnCurveRes(  0,   7 );
           SetnCurve(  0,   0 );
           SetnCurveBack(  0,   0 );
           SetnCurveV(  0,   20 );
          
           SetnDownAngle(  1,   70 );
           SetnDownAngleV(  1,   -20 );
           SetnRotate(  1,   60 );
           SetnRotateV(  1,   20 );
           SetnBranches(  1,   80 );
           SetnVertices(  1,   4 );
           SetnLength(  1,   0.25 );
           SetnLengthV(  1,   0.2 );
           SetnTaper(  1,   0.8 );
           SetnSegSplits(  1,   0 );
           SetnSplitAngle(  1,   0 );
           SetnSplitAngleV(  1,   0 );
           SetnCurveRes(  1,   5 );
           SetnCurve(  1,   -20 );
           SetnCurveBack(  1,   0 );
           SetnCurveV(  1,   40 );
          
           SetnDownAngle(  2,   70 );
           SetnDownAngleV(  2,   20 );
           SetnRotate(  2,   -90 );
           SetnRotateV(  2,   40 );
           SetnBranches(  2,   20 );
           SetnVertices(  2,   4 );
           SetnLength(  2,   0.4 );
           SetnLengthV(  2,   0.2 );
           SetnTaper(  2,   0.7 );
           SetnSegSplits(  2,   0.1 );
           SetnSplitAngle(  2,   70 );
           SetnSplitAngleV(  2,   20 );
           SetnCurveRes(  2,   3 );
           SetnCurve(  2,   0 );
           SetnCurveBack(  2,   0 );
           SetnCurveV(  2,   30 );
          
           SetnDownAngle(  3,   45 );
           SetnDownAngleV(  3,   40 );
           SetnRotate(  3,   77 );
           SetnRotateV(  3,   0 );
           break;
          
           }
          }
          //---------------------------------------------------------------------------
          
     682  TParameters::TreeType TParameters::GetTreeType(  void )
          {
           return mTreeType;
          }
          //---------------------------------------------------------------------------
          
     688  String TParameters::GetTreeTypeString(  void )
          {
           String sTreeName;
           switch (  mTreeType )
           {
           case Simple:
           sTreeName = "Simple";
           break;
           case Quaking_Aspen:
           sTreeName = "Quaking Aspen";
           break;
           case Black_Tupelo:
           sTreeName = "Black Tupelo";
           break;
           case Weeping_Willow:
           sTreeName = "Weeping Willow";
           break;
           case Lombardy_Poplar:
           sTreeName = "Lombardy Poplar";
           break;
           case Palm:
           sTreeName = "Palm";
           break;
           case European_Larch:
           sTreeName = "European Larch";
           break;
           case Fir:
           sTreeName = "Fir";
           break;
           }
          
           return sTreeName;
          }
          //---------------------------------------------------------------------------
          
     723  uchar TParameters::GetShape(  void )
          {
           return mu8Shape;
          }
          
          //---------------------------------------------------------------------------
          
     730  Real TParameters::GetBaseSize(  void )
          {
           return mfBaseSize;
          }
          
          //---------------------------------------------------------------------------
          
     737  uchar TParameters::GetBaseSplits(  void )
          {
           return mu8BaseSplits;
          }
          
          //---------------------------------------------------------------------------
          
     744  Real TParameters::GetScale(  void )
          {
           return mfScale;
          }
          
          //---------------------------------------------------------------------------
          
     751  Real TParameters::GetScaleV(  void )
          {
           return mfScaleV;
          }
          
          //---------------------------------------------------------------------------
          
     758  Real TParameters::GetZScale(  void )
          {
           return mfZScale;
          }
          
          //---------------------------------------------------------------------------
          
     765  Real TParameters::GetZScaleV(  void )
          {
           return mfZScaleV;
          }
          
          //---------------------------------------------------------------------------
          
     772  Real TParameters::GetRatio(  void )
          {
           return mfRatio;
          }
          
          //---------------------------------------------------------------------------
          
     779  Real TParameters::GetRatioPower(  void )
          {
           return mfRatioPower;
          }
          
          //---------------------------------------------------------------------------
          
     786  uchar TParameters::GetLobes(  void )
          {
           return mu8Lobes;
          }
          
          //---------------------------------------------------------------------------
          
     793  Real TParameters::GetLobeDepth(  void )
          {
           return mfLobeDepth;
          }
          
          //---------------------------------------------------------------------------
          
     800  Real TParameters::GetFlare(  void )
          {
           return mfFlare;
          }
          
          //---------------------------------------------------------------------------
          
     807  int TParameters::GetLeaves(  void )
          {
           return miLeaves;
          }
          
          //---------------------------------------------------------------------------
          
     814  TLeafShape TParameters::GetLeafShape(  void )
          {
           return mu8LeafShape;
          }
          
          //---------------------------------------------------------------------------
          
     821  Real TParameters::GetLeafScale(  void )
          {
           return mfLeafScale;
          }
          
          //---------------------------------------------------------------------------
          
     828  Real TParameters::GetLeafScaleX(  void )
          {
           return mfLeafScaleX;
          }
          
          //---------------------------------------------------------------------------
          
     835  Real TParameters::GetLeafQuality(  void )
          {
           return mfLeafQuality;
          }
          
          //---------------------------------------------------------------------------
          
     842  uint TParameters::GetLeafColor(  void )
          {
           return mu16LeafColor;
          }
          
          //---------------------------------------------------------------------------
          
     849  bool TParameters::GetLeafColorVariation(  void )
          {
           return mbLeafColorVariation;
          }
          
          //---------------------------------------------------------------------------
          
     856  uchar TParameters::GetLeafAlpha(  void )
          {
           return mu8LeafAlpha;
          }
          //---------------------------------------------------------------------------
          
     862  Real TParameters::GetAttractionUp(  void )
          {
           return mfAttractionUp;
          }
          
          //---------------------------------------------------------------------------
          
     869  Real TParameters::GetPruneRatio(  void )
          {
           return mfPruneRatio;
          }
          
          //---------------------------------------------------------------------------
          
     876  Real TParameters::GetPruneWidth(  void )
          {
           return mfPruneWidth;
          }
          
          //---------------------------------------------------------------------------
          
     883  Real TParameters::GetPruneWidthPeak(  void )
          {
           return mfPruneWidthPeak;
          }
          
          //---------------------------------------------------------------------------
          
     890  Real TParameters::GetPrunePowerLow(  void )
          {
           return mfPrunePowerLow;
          }
          
          //---------------------------------------------------------------------------
          
     897  Real TParameters::GetPrunePowerHigh(  void )
          {
           return mfPrunePowerHigh;
          }
          
          //---------------------------------------------------------------------------
          
     904  Real TParameters::GetScale0(  void )
          {
           return mfScale0;
          }
          
          //---------------------------------------------------------------------------
          
     911  Real TParameters::GetScaleV0(  void )
          {
           return mfScaleV0;
          }
          
          //---------------------------------------------------------------------------
          
          
     919  Real TParameters::GetnDownAngle(  uchar u8Index )
          {
           return mafNDownAngle[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     926  Real TParameters::GetnDownAngleV(  uchar u8Index )
          {
           return mafNDownAngleV[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     933  Real TParameters::GetnRotate(  uchar u8Index )
          {
           return mafNRotate[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     940  Real TParameters::GetnRotateV(  uchar u8Index )
          {
           return mafNRotateV[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     947  Real TParameters::GetnLength(  uchar u8Index )
          {
           return mafNLength[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     954  Real TParameters::GetnLengthV(  uchar u8Index )
          {
           return mafNLengthV[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     961  Real TParameters::GetnTaper(  uchar u8Index )
          {
           return mafNTaper[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     968  int TParameters::GetnBranches(  uchar u8Index )
          {
           return maiNBranches[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     975  Real TParameters::GetnSegSplits(  uchar u8Index )
          {
           return mafNSegSplits[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     982  Real TParameters::GetnSplitAngle(  uchar u8Index )
          {
           return mafNSplitAngle[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     989  Real TParameters::GetnSplitAngleV(  uchar u8Index )
          {
           return mafNSplitAngleV[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
     996  int TParameters::GetnCurveRes(  uchar u8Index )
          {
           return maiNCurveRes[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
    1003  Real TParameters::GetnCurve(  uchar u8Index )
          {
           return mafNCurve[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
    1010  Real TParameters::GetnCurveV(  uchar u8Index )
          {
           return mafNCurveV[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
    1017  Real TParameters::GetnCurveBack(  uchar u8Index )
          {
           return mafNCurveBack[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
    1024  int TParameters::GetnVertices(  uchar u8Index )
          {
           return maiNVertices[u8Index];
          }
          
          //---------------------------------------------------------------------------
          
    1031  void TParameters::SetLevels(  uchar u8Value )
          {
           if (  u8Value == mu8Levels )
           return;
          
           uchar i;
          
           Real* afTempNDownAngle = mafNDownAngle;
           Real* afTempNDownAngleV = mafNDownAngleV;
           Real* afTempNRotate = mafNRotate;
           Real* afTempNRotateV = mafNRotateV;
           Real* afTempNLength = mafNLength;
           Real* afTempNLengthV = mafNLengthV;
           Real* afTempNTaper = mafNTaper;
           int* aiTempNBranches = maiNBranches;
           Real* afTempNSegSplits = mafNSegSplits;
           Real* afTempNSplitAngle = mafNSplitAngle;
           Real* afTempNSplitAngleV = mafNSplitAngleV;
           int* aiTempNCurveRes = maiNCurveRes;
           Real* afTempNCurve = mafNCurve;
           Real* afTempNCurveBack = mafNCurveBack;
           Real* afTempNCurveV = mafNCurveV;
           int* aiTempNVertices = maiNVertices;
          
           mafNDownAngle = new Real[u8Value];
           mafNDownAngleV = new Real[u8Value];
           mafNRotate = new Real[u8Value];
           mafNRotateV = new Real[u8Value];
           mafNLength = new Real[u8Value];
           mafNLengthV = new Real[u8Value];
           mafNTaper = new Real[u8Value];
           maiNBranches = new int[u8Value];
           mafNSegSplits = new Real[u8Value];
           mafNSplitAngle = new Real[u8Value];
           mafNSplitAngleV = new Real[u8Value];
           maiNCurveRes = new int[u8Value];
           mafNCurve = new Real[u8Value];
           mafNCurveBack = new Real[u8Value];
           mafNCurveV = new Real[u8Value];
           maiNVertices = new int[u8Value];
          
           if (  u8Value > mu8Levels )
           {
           for (  i=0; i<mu8Levels; i++ )
           {
           mafNDownAngle[i] = afTempNDownAngle[i];
           mafNDownAngleV[i] = afTempNDownAngleV[i];
           mafNRotate[i] = afTempNRotate[i];
           mafNRotateV[i] = afTempNRotateV[i];
           mafNLength[i] = afTempNLength[i];
           mafNLengthV[i] = afTempNLengthV[i];
           mafNTaper[i] = afTempNTaper[i];
           maiNBranches[i] = aiTempNBranches[i];
           mafNSegSplits[i] = afTempNSegSplits[i];
           mafNSplitAngle[i] = afTempNSplitAngle[i];
           mafNSplitAngleV[i] = afTempNSplitAngleV[i];
           maiNCurveRes[i] = aiTempNCurveRes[i];
           mafNCurve[i] = afTempNCurve[i];
           mafNCurveBack[i] = afTempNCurveBack[i];
           mafNCurveV[i] = afTempNCurveV[i];
           maiNVertices[i] = aiTempNVertices[i];
           }
           for (  i=mu8Levels; i<u8Value; i++ )
           {
           mafNDownAngle[i] = 0.0;
           mafNDownAngleV[i] = 0.0;
           mafNRotate[i] = 0.0;
           mafNRotateV[i] = 0.0;
           mafNLength[i] = 0.0;
           mafNLengthV[i] = 0.0;
           mafNTaper[i] = 0.0;
           maiNBranches[i] = 0;
           mafNSegSplits[i] = 0.0;
           mafNSplitAngle[i] = 0.0;
           mafNSplitAngleV[i] = 0.0;
           maiNCurveRes[i] = 0;
           mafNCurve[i] = 0.0;
           mafNCurveBack[i] = 0.0;
           mafNCurveV[i] = 0.0;
           maiNVertices[i] = 0;
           }
           }
           else
           {
           for (  i=0; i<u8Value; i++ )
           {
           mafNDownAngle[i] = afTempNDownAngle[i];
           mafNDownAngleV[i] = afTempNDownAngleV[i];
           mafNRotate[i] = afTempNRotate[i];
           mafNRotateV[i] = afTempNRotateV[i];
           mafNLength[i] = afTempNLength[i];
           mafNLengthV[i] = afTempNLengthV[i];
           mafNTaper[i] = afTempNTaper[i];
           maiNBranches[i] = aiTempNBranches[i];
           mafNSegSplits[i] = afTempNSegSplits[i];
           mafNSplitAngle[i] = afTempNSplitAngle[i];
           mafNSplitAngleV[i] = afTempNSplitAngleV[i];
           maiNCurveRes[i] = aiTempNCurveRes[i];
           mafNCurve[i] = afTempNCurve[i];
           mafNCurveBack[i] = afTempNCurveBack[i];
           mafNCurveV[i] = afTempNCurveV[i];
           maiNVertices[i] = aiTempNVertices[i];
           }
           }
          
           mu8Levels = u8Value;
          
           delete[] afTempNDownAngle;
           delete[] afTempNDownAngleV;
           delete[] afTempNRotate;
           delete[] afTempNRotateV;
           delete[] afTempNLength;
           delete[] afTempNLengthV;
           delete[] afTempNTaper;
           delete[] aiTempNBranches;
           delete[] afTempNSegSplits;
           delete[] afTempNSplitAngle;
           delete[] afTempNSplitAngleV;
           delete[] aiTempNCurveRes;
           delete[] afTempNCurve;
           delete[] afTempNCurveBack;
           delete[] afTempNCurveV;
           delete[] aiTempNVertices;
          }
          
          //---------------------------------------------------------------------------
          
    1158  void TParameters::SetShape(  uchar u8Value )
          {
           mu8Shape = u8Value;
          }
          
          //---------------------------------------------------------------------------
          
    1165  void TParameters::SetBaseSize(  Real fValue )
          {
           mfBaseSize = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1172  void TParameters::SetBaseSplits(  uchar u8Value )
          {
           mu8BaseSplits = u8Value;
          }
          
          //---------------------------------------------------------------------------
          
    1179  void TParameters::SetScale(  Real fValue )
          {
           mfScale = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1186  void TParameters::SetScaleV(  Real fValue )
          {
           mfScaleV = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1193  void TParameters::SetZScale(  Real fValue )
          {
           mfZScale = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1200  void TParameters::SetZScaleV(  Real fValue )
          {
           mfZScaleV = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1207  void TParameters::SetRatio(  Real fValue )
          {
           mfRatio = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1214  void TParameters::SetRatioPower(  Real fValue )
          {
           mfRatioPower = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1221  void TParameters::SetLobes(  uchar u8Value )
          {
           mu8Lobes = u8Value;
          }
          
          //---------------------------------------------------------------------------
          
    1228  void TParameters::SetLobeDepth(  Real fValue )
          {
           mfLobeDepth = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1235  void TParameters::SetFlare(  Real fValue )
          {
           mfFlare = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1242  void TParameters::SetLeaves(  int iValue )
          {
           miLeaves = iValue;
          }
          
          //---------------------------------------------------------------------------
          
    1249  void TParameters::SetLeafShape(  TLeafShape u8Value )
          {
           mu8LeafShape = u8Value;
          }
          
          //---------------------------------------------------------------------------
          
    1256  void TParameters::SetLeafScale(  Real fValue )
          {
           mfLeafScale = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1263  void TParameters::SetLeafScaleX(  Real fValue )
          {
           mfLeafScaleX = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1270  void TParameters::SetLeafQuality(  Real fValue )
          {
           mfLeafQuality = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1277  void TParameters::SetLeafColor(  uint u16Value )
          {
           mu16LeafColor = u16Value;
          }
          
          //---------------------------------------------------------------------------
          
    1284  void TParameters::SetLeafColorVariation(  bool bValue )
          {
           mbLeafColorVariation = bValue;
          }
          
          //---------------------------------------------------------------------------
          
    1291  void TParameters::SetLeafAlpha(  uchar u8Value )
          {
           mu8LeafAlpha = u8Value;
          }
          
          //---------------------------------------------------------------------------
          
    1298  void TParameters::SetAttractionUp(  Real fValue )
          {
           mfAttractionUp = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1305  void TParameters::SetPruneRatio(  Real fValue )
          {
           mfPruneRatio = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1312  void TParameters::SetPruneWidth(  Real fValue )
          {
           mfPruneWidth = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1319  void TParameters::SetPruneWidthPeak(  Real fValue )
          {
           mfPruneWidthPeak = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1326  void TParameters::SetPrunePowerLow(  Real fValue )
          {
           mfPrunePowerLow = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1333  void TParameters::SetPrunePowerHigh(  Real fValue )
          {
           mfPrunePowerHigh = fValue;
          }
          
          //---------------------------------------------------------------------------
          
          
    1341  void TParameters::SetScale0(  Real fValue )
          {
           mfScale0 = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1348  void TParameters::SetScaleV0(  Real fValue )
          {
           mfScaleV0 = fValue;
          }
          
          //---------------------------------------------------------------------------
          
          
    1356  void TParameters::SetnDownAngle(  uchar u8Index,   Real fValue )
          {
           mafNDownAngle[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1363  void TParameters::SetnDownAngleV(  uchar u8Index,   Real fValue )
          {
           mafNDownAngleV[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1370  void TParameters::SetnRotate(  uchar u8Index,   Real fValue )
          {
           mafNRotate[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1377  void TParameters::SetnRotateV(  uchar u8Index,   Real fValue )
          {
           mafNRotateV[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1384  void TParameters::SetnLength(  uchar u8Index,   Real fValue )
          {
           mafNLength[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1391  void TParameters::SetnLengthV(  uchar u8Index,   Real fValue )
          {
           mafNLengthV[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1398  void TParameters::SetnTaper(  uchar u8Index,   Real fValue )
          {
           mafNTaper[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1405  void TParameters::SetnBranches(  uchar u8Index,   int iValue )
          {
           maiNBranches[u8Index] = iValue;
          }
          
          //---------------------------------------------------------------------------
          
    1412  void TParameters::SetnSegSplits(  uchar u8Index,   Real fValue )
          {
           mafNSegSplits[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1419  void TParameters::SetnSplitAngle(  uchar u8Index,   Real fValue )
          {
           mafNSplitAngle[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1426  void TParameters::SetnSplitAngleV(  uchar u8Index,   Real fValue )
          {
           mafNSplitAngleV[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1433  void TParameters::SetnCurveRes(  uchar u8Index,   int iValue )
          {
           maiNCurveRes[u8Index] = iValue;
          }
          
          //---------------------------------------------------------------------------
          
    1440  void TParameters::SetnCurve(  uchar u8Index,   Real fValue )
          {
           mafNCurve[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1447  void TParameters::SetnCurveV(  uchar u8Index,   Real fValue )
          {
           mafNCurveV[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1454  void TParameters::SetnCurveBack(  uchar u8Index,   Real fValue )
          {
           mafNCurveBack[u8Index] = fValue;
          }
          
          //---------------------------------------------------------------------------
          
    1461  void TParameters::SetnVertices(  uchar u8Index,   int iValue )
          {
           maiNVertices[u8Index] = iValue;
          }
          
          //---------------------------------------------------------------------------
          
    1468  TParameters* TParameters::Clone(  void )
          {
           int i;
           TParameters *pClonedParameters = new TParameters(  mu8Levels );
          
           pClonedParameters->mTreeType = mTreeType;
           pClonedParameters->mu8Shape = mu8Shape;
           pClonedParameters->mfBaseSize = mfBaseSize;
           pClonedParameters->mu8BaseSplits = mu8BaseSplits;
           pClonedParameters->mfScale = mfScale;
           pClonedParameters->mfScaleV = mfScaleV;
           pClonedParameters->mfZScale = mfZScale;
           pClonedParameters->mfZScaleV = mfZScaleV;
           pClonedParameters->mfRatio = mfRatio;
           pClonedParameters->mfRatioPower = mfRatioPower;
           pClonedParameters->mu8Lobes = mu8Lobes;
           pClonedParameters->mfLobeDepth = mfLobeDepth;
           pClonedParameters->mfFlare = mfFlare;
           pClonedParameters->miLeaves = miLeaves;
           pClonedParameters->mu8LeafShape = mu8LeafShape;
           pClonedParameters->mfLeafScale = mfLeafScale;
           pClonedParameters->mfLeafScaleX = mfLeafScaleX;
           pClonedParameters->mfLeafQuality = mfLeafQuality;
           pClonedParameters->mu16LeafColor = mu16LeafColor;
           pClonedParameters->mbLeafColorVariation = mbLeafColorVariation;
           pClonedParameters->mu8LeafAlpha = mu8LeafAlpha;
           pClonedParameters->mfAttractionUp = mfAttractionUp;
           pClonedParameters->mfPruneRatio = mfPruneRatio;
           pClonedParameters->mfPruneWidth = mfPruneWidth;
           pClonedParameters->mfPruneWidthPeak = mfPruneWidthPeak;
           pClonedParameters->mfPrunePowerLow = mfPrunePowerLow;
           pClonedParameters->mfPrunePowerHigh = mfPrunePowerHigh;
           pClonedParameters->mfScale0 = mfScale0;
           pClonedParameters->mfScaleV0 = mfScaleV0;
          
           for (  i=0; i<mu8Levels; i++ )
           {
           pClonedParameters->mafNDownAngle[i] = mafNDownAngle[i];
           pClonedParameters->mafNDownAngleV[i] = mafNDownAngleV[i];
           pClonedParameters->mafNRotate[i] = mafNRotate[i];
           pClonedParameters->mafNRotateV[i] = mafNRotateV[i];
           pClonedParameters->mafNLength[i] = mafNLength[i];
           pClonedParameters->mafNLengthV[i] = mafNLengthV[i];
           pClonedParameters->mafNTaper[i] = mafNTaper[i];
           pClonedParameters->maiNBranches[i] = maiNBranches[i];
           pClonedParameters->mafNSegSplits[i] = mafNSegSplits[i];
           pClonedParameters->mafNSplitAngle[i] = mafNSplitAngle[i];
           pClonedParameters->mafNSplitAngleV[i] = mafNSplitAngleV[i];
           pClonedParameters->maiNCurveRes[i] = maiNCurveRes[i];
           pClonedParameters->mafNCurve[i] = mafNCurve[i];
           pClonedParameters->mafNCurveBack[i] = mafNCurveBack[i];
           pClonedParameters->mafNCurveV[i] = mafNCurveV[i];
           pClonedParameters->maiNVertices[i] = maiNVertices[i];
           }
          
           return pClonedParameters;
          }
          
          //---------------------------------------------------------------------------
          
          } // namespace

./components/ogre/environment/meshtree/TParameters.h

       1  #ifndef __TParameters_H__
          #define __TParameters_H__
          
          #include "../../OgreIncludes.h"
          #include "TTypes.h"
          
          /*
           Based "The Creation and Rendering of Realistic Trees" article by Jason Weber and Joseph Penn
           Based on a port of Delphi code from TReal project by Ton van den Heuvel
           For further information go see:
           http://members.chello.nl/~l.vandenheuvel2/TReal/
           Copyright (  c ) 2002-2003,   Ton van den Heuvel
           Copyright (  c ) 2004,   Nicolas Chauvin
          
           ==================================
           Tree generation classes for Ogre3D
           ==================================
          
          */
          
          namespace Ogre {
          
          //---------------------------------------------------------------------------
          
      25  class TParameters
          {
           public:
          
      29   enum TreeType
           {
           Simple,   // 2
           Quaking_Aspen,   // 3
           Black_Tupelo,   // 4
           Weeping_Willow,   // 4
           Lombardy_Poplar,   // 3
           Palm,   // 2
           European_Larch,   // 3
           Fir
           };
          
          
      42   friend class Tree;
      43   friend class TStem;
          
           private:
          
           protected:
          
      49   TreeType mTreeType;
      50   uchar mu8Shape;
      51   Real mfBaseSize;
      52   uchar mu8BaseSplits; // not used yet !!!!
      53   Real mfScale;
      54   Real mfScaleV;
      55   Real mfZScale;
      56   Real mfZScaleV;
      57   uchar mu8Levels;
      58   Real mfRatio;
      59   Real mfRatioPower;
      60   uchar mu8Lobes;
      61   Real mfLobeDepth;
      62   Real mfFlare;
           int miLeaves;
      64   TLeafShape mu8LeafShape;
      65   Real mfLeafScale;
      66   Real mfLeafScaleX;
      67   Real mfLeafQuality;
      68   uint mu16LeafColor; // unsigned short mu16LeafColor
      69   bool mbLeafColorVariation;
      70   uchar mu8LeafAlpha;
      71   Real mfAttractionUp;
      72   Real mfPruneRatio; // not used yet !!!!
      73   Real mfPruneWidth; // not used yet !!!!
      74   Real mfPruneWidthPeak; // not used yet !!!!
      75   Real mfPrunePowerLow; // not used yet !!!!
      76   Real mfPrunePowerHigh; // not used yet !!!!
      77   Real mfScale0;
      78   Real mfScaleV0;
      79   Real *mafNDownAngle;
      80   Real *mafNDownAngleV;
      81   Real *mafNRotate;
      82   Real *mafNRotateV;
      83   Real *mafNLength;
      84   Real *mafNLengthV;
      85   Real *mafNTaper;
           int *maiNBranches;
      87   Real *mafNSegSplits;
      88   Real *mafNSplitAngle;
      89   Real *mafNSplitAngleV;
           int *maiNCurveRes;
      91   Real *mafNCurve;
      92   Real *mafNCurveBack;
      93   Real *mafNCurveV;
           int *maiNVertices;
          
           public:
          
      98   TParameters(   );
      99   TParameters(  uchar u8Levels );
     100   ~TParameters(   );
          
     102   TParameters* Clone(  void );
          
     104   void Set(  TreeType eType );
          
     106   TreeType GetTreeType(  void );
     107   String GetTreeTypeString(  void );
     108   uchar GetShape(  void );
     109   Real GetBaseSize(  void );
     110   uchar GetBaseSplits(  void ); // not used yet !!!!
     111   Real GetScale(  void );
     112   Real GetScaleV(  void );
     113   Real GetZScale(  void );
     114   Real GetZScaleV(  void );
     115   Real GetRatio(  void );
     116   Real GetRatioPower(  void );
     117   uchar GetLobes(  void );
     118   Real GetLobeDepth(  void );
     119   Real GetFlare(  void );
     120   int GetLeaves(  void );
     121   TLeafShape GetLeafShape(  void );
     122   Real GetLeafScale(  void );
     123   Real GetLeafScaleX(  void );
     124   Real GetLeafQuality(  void );
     125   uint GetLeafColor(  void );
     126   bool GetLeafColorVariation(  void );
     127   uchar GetLeafAlpha(  void );
     128   Real GetAttractionUp(  void );
     129   Real GetPruneRatio(  void ); // not used yet !!!!
     130   Real GetPruneWidth(  void ); // not used yet !!!!
     131   Real GetPruneWidthPeak(  void ); // not used yet !!!!
     132   Real GetPrunePowerLow(  void ); // not used yet !!!!
     133   Real GetPrunePowerHigh(  void ); // not used yet !!!!
     134   Real GetScale0(  void );
     135   Real GetScaleV0(  void );
          
     137   Real GetnDownAngle(  uchar u8Index );
     138   Real GetnDownAngleV(  uchar u8Index );
     139   Real GetnRotate(  uchar u8Index );
     140   Real GetnRotateV(  uchar u8Index );
     141   Real GetnLength(  uchar u8Index );
     142   Real GetnLengthV(  uchar u8Index );
     143   Real GetnTaper(  uchar u8Index );
     144   int GetnBranches(  uchar u8Index );
     145   Real GetnSegSplits(  uchar u8Index );
     146   Real GetnSplitAngle(  uchar u8Index );
     147   Real GetnSplitAngleV(  uchar u8Index );
     148   int GetnCurveRes(  uchar u8Index );
     149   Real GetnCurve(  uchar u8Index );
     150   Real GetnCurveV(  uchar u8Index );
     151   Real GetnCurveBack(  uchar u8Index );
     152   int GetnVertices(  uchar u8Index );
          
     154   void SetLevels(  uchar u8Levels );
     155   void SetShape(  uchar u8Shape );
     156   void SetBaseSize(  Real fBaseSize );
     157   void SetBaseSplits(  uchar u8BaseSplits ); // not used yet !!!!
     158   void SetScale(  Real fScale );
     159   void SetScaleV(  Real fScaleV );
     160   void SetZScale(  Real fZScale );
     161   void SetZScaleV(  Real fZScaleV );
     162   void SetRatio(  Real fRatio );
     163   void SetRatioPower(  Real fRatioPower );
     164   void SetLobes(  uchar u8Lobes );
     165   void SetLobeDepth(  Real fLobeDepth );
     166   void SetFlare(  Real fFlare );
     167   void SetLeaves(  int iLeaves );
     168   void SetLeafShape(  TLeafShape u8Value );
     169   void SetLeafScale(  Real fValue );
     170   void SetLeafScaleX(  Real fValue );
     171   void SetLeafQuality(  Real fValue );
     172   void SetLeafColor(  uint u16Value );
     173   void SetLeafColorVariation(  bool bValue );
     174   void SetLeafAlpha(  uchar u8Value );
     175   void SetAttractionUp(  Real fValue );
     176   void SetPruneRatio(  Real fValue ); // not used yet !!!!
     177   void SetPruneWidth(  Real fValue ); // not used yet !!!!
     178   void SetPruneWidthPeak(  Real fValue ); // not used yet !!!!
     179   void SetPrunePowerLow(  Real fValue ); // not used yet !!!!
     180   void SetPrunePowerHigh(  Real fValue ); // not used yet !!!!
     181   void SetScale0(  Real fValue );
     182   void SetScaleV0(  Real fValue );
          
     184   void SetnDownAngle(  uchar u8Index,   Real fValue );
     185   void SetnDownAngleV(  uchar u8Index,   Real fValue );
     186   void SetnRotate(  uchar u8Index,   Real fValue );
     187   void SetnRotateV(  uchar u8Index,   Real fValue );
     188   void SetnLength(  uchar u8Index,   Real fValue );
     189   void SetnLengthV(  uchar u8Index,   Real fValue );
     190   void SetnTaper(  uchar u8Index,   Real fValue );
     191   void SetnBranches(  uchar u8Index,   int iValue );
     192   void SetnSegSplits(  uchar u8Index,   Real fValue );
     193   void SetnSplitAngle(  uchar u8Index,   Real fValue );
     194   void SetnSplitAngleV(  uchar u8Index,   Real fValue );
     195   void SetnCurveRes(  uchar u8Index,   int iValue );
     196   void SetnCurve(  uchar u8Index,   Real fValue );
     197   void SetnCurveV(  uchar u8Index,   Real fValue );
     198   void SetnCurveBack(  uchar u8Index,   Real fValue );
     199   void SetnVertices(  uchar u8Index,   int iValue );
          };
          
          //---------------------------------------------------------------------------
          
          } // namespace
          
          #endif

./components/ogre/environment/meshtree/TStem.cpp

       1  #include "TStem.h"
          #include "MeshTree.h"
          #include "framework/float_cast.h"
          
          //---------------------------------------------------------------------------
          
          /*
           Based "The Creation and Rendering of Realistic Trees" article by Jason Weber and Joseph Penn
           Based on a port of Delphi code from TReal project by Ton van den Heuvel
           For further information go see:
           http://members.chello.nl/~l.vandenheuvel2/TReal/
           Copyright (  c ) 2002-2003,   Ton van den Heuvel
           Copyright (  c ) 2004,   Nicolas Chauvin
          
           ==================================
           Tree generation classes for Ogre3D
           ==================================
          
          */
          
          namespace Ogre {
          
      23  inline int Round(  const Real fValue )
          { return fValue<0 ? lrintf(  fValue-0.5 ) : lrintf(  fValue+0.5 ); }
          
      26  inline int Trunc(  const Real fValue )
          {
          // return fValue<0 ? fValue+1.0 : fValue;
           return lrintf(  fValue );
          }
          
          //===========================================================================
          // Class TStem
          //===========================================================================
          
      36  TStem::TStem(  Tree *pTree )
          {
           mpTree = pTree;
          }
          
          //---------------------------------------------------------------------------
          
      43  TStem::~TStem(   )
          {
           int i,   j;
          
           // Destroy all elements in the vectors;
           for (  i=0; i<mVectorOfSections.size(   ); i++ )
           {
           for (  j=0; j< mVectorOfSections[i]->size(   ); j++ )
           delete (  *mVectorOfSections[i] )[j];
          
           delete mVectorOfSections[i];
           }
          
           for (  i=0; i<mVectorOfLeaves.size(   ); i++ )
           {
           for (  j=0; j< mVectorOfLeaves[i]->size(   ); j++ )
           delete (  *mVectorOfLeaves[i] )[j];
          
           delete mVectorOfLeaves[i];
           }
          
           for (  i=0; i<mVectorOfSubStems.size(   ); i++ )
           delete mVectorOfSubStems[i];
          
           for (  i=0; i<mVectorOfSectionFrames.size(   ); i++ )
           delete mVectorOfSectionFrames[i];
          
          }
          
          //---------------------------------------------------------------------------
          
      74  void TStem::CreateStructure(  TStem *pParent,   const Real fLength,   const Real fOffsetChild,   const uchar u8Level )
          {
           int i;
           Real fSubStemLength;
           int iTotalSubStems; // The amount of sub stems the current stem will spawn
           TStem *pSubStem; // The stem object used to hold spawned sub stems
           Real fFracPos; // Holds the current fractional y position along the stem (  used when spawning sub stems )
           Real fOffsetSubStem; // Holds the current y position along the stemin global coordinates of the sub stem
           TParameters *pParam = mpTree->mpParameters;
          
           mfOffsetChild = fOffsetChild;
           mpParent = pParent;
           mfLength = fLength;
           mpTree->miTotalStems++;
          
           // Calculate the base length of the current stem (  is always 0 except for level0 )
          
           if (  u8Level == 0 )
           mfBaseLength = pParam->mfBaseSize * mpTree->mfScale;
           else
           mfBaseLength = 0.0;
          
           // Spawn sub stems or leaves
           if (  pParam->mu8Levels > u8Level )
           {
           if (  pParam->mu8Levels == u8Level + 1 ) // TODO TODO : check +1 in "u8Level + 1" !!!!!!!!!!!!
           {
           // Count the total number of leaves (  last level in the recursion )
           if (  u8Level != 0 )
           mpTree->miTotalLeaves += Round(  pParam->miLeaves * ShapeRatio(  4,   mfOffsetChild / mpParent->mfLength ) * pParam->mfLeafQuality );
           else
           mpTree->miTotalLeaves = 0;
          
           }
           else
           {
           // Calculate the amount of sub stems the current stem will spawn
           if (  u8Level == 0 )
           // iTotalSubStems = Round(  (  1.0 - pParam->mfBaseSize ) * pParam->maiNBranches[1] );
           iTotalSubStems = pParam->maiNBranches[1];
           else if (  u8Level == 1 )
           iTotalSubStems = Round(  pParam->maiNBranches[2] * (  0.2 + 0.8 * (  mfLength / mpParent->mfLength ) / mpParent->mfLengthChildMax ) );
           else
           iTotalSubStems = Round(  pParam->maiNBranches[u8Level + 1] * (  1.0 - 0.5 * mfOffsetChild / mpParent->mfLength ) );
          
           // Add child stems coming out of the current stem
           for (  i=0; i<iTotalSubStems; i++ )
           {
          
           // Calculate fractional position along the stem
           if (  u8Level == 0 )
           fFracPos = pParam->mfBaseSize + (  (  i + 1 ) * (  1.0 - pParam->mfBaseSize ) / (  iTotalSubStems + 1 ) );
           else
           fFracPos = (  i + 1 ) * (  1.0 / (  iTotalSubStems + 1 ) );
          
           // Calculate the y position of the sub stem measured from the base of the stem (  in the global coordinate system )
           fOffsetSubStem = fFracPos * mfLength;
          
           // Calculate the length of the sub stem
           mfLengthChildMax = pParam->mafNLength[u8Level + 1] + mpTree->GetRandomValue(  pParam->mafNLengthV[u8Level+ 1] );
          
           if (  u8Level == 0 )
           fSubStemLength = mpTree->mfTrunkLength * mfLengthChildMax *
           ShapeRatio(  pParam->mu8Shape,   (  mpTree->mfTrunkLength - fOffsetSubStem ) / (  mpTree->mfTrunkLength - mfBaseLength ) );
           else
           fSubStemLength = mfLengthChildMax * (  mfLength - 0.6 * fOffsetSubStem );
          
           // Spawn the sub stem,   but only if the sub stem radius is greater than zero
           pSubStem = new TStem(  mpTree );
           mVectorOfSubStems.push_back(  pSubStem );
           pSubStem->CreateStructure(  this,   fSubStemLength,   fOffsetSubStem,   u8Level + 1 );
          
           } // for
           } // else
           } // if
          
          }
          
          //---------------------------------------------------------------------------
          
     154  void TStem::Grow(  const TSectionFrame &rStartSectionFrame,   const Real fRadius,   const uchar u8Level )
          {
          
           int i;
           Vector3 localSectionOrigin;
           Vector3 currentSectionOrigin;
           TSectionFrame *pSectionFrame;
           TSectionFrame *pNextSectionFrame;
           Quaternion nextQuat;
           Real fSectionRadius;
           Real fStemY; // Y position along the stem where the current section is located (  measured in the local coordinate system
           Degree fAngle;
           Radian fAngleRadian;
           TParameters *pParam = mpTree->mpParameters;
          
           mfRadius = fRadius;
           mStemOrigin = rStartSectionFrame.mGlobalOrigin + rStartSectionFrame.mQuat * rStartSectionFrame.mOrigin ; // TODO TESTS TESTS !!!!!!!!!
           currentSectionOrigin = mStemOrigin;
          
           // Now for the amount of sections specified,   create a quaterion and create and initialize the sections
           pSectionFrame = new TSectionFrame(   rStartSectionFrame.mQuat,   Vector3(  0,  0,  0 ),   currentSectionOrigin  );
           mVectorOfSectionFrames.push_back(  pSectionFrame );
          
           // Create a stem
           fStemY = 0.0;
          
           // Calculate the radius of the section
           fSectionRadius = CalculateSectionRadius(  u8Level,   fStemY,   mfLength,   mfRadius );
          
           // Create the points that make up the section
           CreateSection(  pSectionFrame,   fSectionRadius,   pParam->maiNVertices[u8Level] );
           mpTree->miTotalVertices += pParam->maiNVertices[u8Level];
           if (  mpTree->mpParameters->mTreeType == TParameters::Simple )
           {
           mpTree->miTotalVertices += gu8CoordFrameVerticesNumber;
           mpTree->miTotalCoordFrames++;
           }
          
           // In case we are creating the trunk,   the first segment of the stem is (  again ) divided into maiNCurveRes[u8Level] sections
           // This is done because otherwise the exponentional curve at the base of the trunk wouldn't be exponentional but linear
          
           Real fFlareOffset = 0.0;
          
           if (  u8Level == 0 )
           {
           // We are creating the trunk,   so divide the first segment in maiNCurveRes[0] sections
           for (  i=1; i< FLARE_RESOLUTION - 1; i++ )
           {
           // Calculate the coordinate system of the current section
           // Calculate the new origin of the next section using the current origin and the v vector of the previous section frame
           localSectionOrigin = Vector3(  0.0,   mfLength / (  pParam->maiNCurveRes[0] * FLARE_RESOLUTION ),   0.0 );
          
           // Calculate the radius of the section
           fStemY = fStemY + (  mfLength / (  pParam->maiNCurveRes[0] * FLARE_RESOLUTION ) );
          
           if (  mfLength == 0.0 )
           fSectionRadius = 0.0;
           else
           fSectionRadius = CalculateSectionRadius(  0,   fStemY / mfLength,   mfLength,   mfRadius );
          
           pNextSectionFrame = new TSectionFrame(  pSectionFrame->mQuat,   localSectionOrigin,   currentSectionOrigin );
           mVectorOfSectionFrames.push_back(  pNextSectionFrame );
          
           // Create the points that make up the section
           CreateSection(  pNextSectionFrame,   fSectionRadius,   pParam->maiNVertices[0] );
           mpTree->miTotalVertices += pParam->maiNVertices[u8Level];
           mpTree->miTotalFaces += 2 * pParam->maiNVertices[u8Level];
           if (  mpTree->mpParameters->mTreeType == TParameters::Simple )
           {
           mpTree->miTotalVertices += gu8CoordFrameVerticesNumber;
           mpTree->miTotalCoordFrames++;
           }
          
          
           pSectionFrame = pNextSectionFrame;
           currentSectionOrigin += pNextSectionFrame->mQuat * localSectionOrigin;
          
           }
          
           fFlareOffset = currentSectionOrigin.y; // TODO test with : fStemY !!!!!!!!!!
           }
          
           // Now,   for the rest of the sections of the stem,   create them and add them to the sections list of the stem
          
           fStemY = 0.0;
          
           for (  i=0; i<pParam->maiNCurveRes[u8Level]; i++ )
           {
           // Calculate the coordinate system of the current section
           // Calculate the new origin of the next section using the current origin and the v vector of the previous section frame ONB
          
           localSectionOrigin = Vector3(  0.0,   (  mfLength - fFlareOffset ) / pParam->maiNCurveRes[u8Level],   0.0 );
          
           // Calculate the angle over which the y axis of current segment is rotated away from the y axis of the previous segment
           if (  pParam->mafNCurveBack[u8Level] != 0 )
           {
           // If mafNCurveBack[u8Level] is not equal to zero each of the segments in the
           // first half of the stem is rotated (  mafNCurve / (  maiNCurveRes / 2 ) ) degrees and
           // each in the second half is rotated (  mafNCurveBack / (  maiNCurveRes / 2 ) ) degrees.
          
           if (  pParam->maiNCurveRes[u8Level] / (  i + 1 ) < 2 )
           fAngle = 2.0 * pParam->mafNCurve[u8Level] / pParam->maiNCurveRes[u8Level];
           else
           fAngle = 2.0 * pParam->mafNCurveBack[u8Level] / pParam->maiNCurveRes[u8Level];
           }
           else
           fAngle = pParam->mafNCurve[u8Level] / pParam->maiNCurveRes[u8Level];
          
           fAngle += Degree(  mpTree->GetRandomValue(  pParam->mafNCurveV[u8Level] / pParam->maiNCurveRes[u8Level] ) );
           fAngleRadian = Radian(  fAngle );
          
           // Now calculated the additional angle (  in radians ) added because of vertical attraction
           // There is no vertical attraction for the trunk and the main branches
          
           if (  u8Level > 1 )
           fAngleRadian += Radian(  CalculateVerticalAttraction(  u8Level,   pSectionFrame->mQuat ) );
          
           // Calculate the new rotated y vector for the next section
          
           nextQuat.FromAngleAxis(  fAngleRadian,   Vector3::UNIT_X  );
           nextQuat = pSectionFrame->mQuat * nextQuat;
          
          
          //currentSectionOrigin += nextQuat * localSectionOrigin;
          
           pNextSectionFrame = new TSectionFrame(  nextQuat,   localSectionOrigin,   currentSectionOrigin  );
           mVectorOfSectionFrames.push_back(  pNextSectionFrame );
          
           // Calculate the radius of the section
           fStemY = fStemY + (  mfLength / pParam->maiNCurveRes[u8Level] );
          
           if (  fStemY == 0.0 )
           fSectionRadius = 0.0;
           else
           fSectionRadius = CalculateSectionRadius(  u8Level,   fStemY / mfLength,   mfLength,   mfRadius );
          
           // Create the points that make up the section.
           CreateSection(  pNextSectionFrame,   fSectionRadius,   pParam->maiNVertices[u8Level] );
           mpTree->miTotalVertices += pParam->maiNVertices[u8Level];
           mpTree->miTotalFaces += 2 * pParam->maiNVertices[u8Level];
           if (  mpTree->mpParameters->mTreeType == TParameters::Simple )
           {
           mpTree->miTotalVertices += gu8CoordFrameVerticesNumber;
           mpTree->miTotalCoordFrames++;
           }
          
           pSectionFrame = pNextSectionFrame;
           currentSectionOrigin += pNextSectionFrame->mQuat * localSectionOrigin;
           }
          
           // Spawn sub stems or leaves
           if (  pParam->mu8Levels > u8Level )
           {
           // We'll need to spawn sub stems or leaves
          
           if (  pParam->mu8Levels == u8Level + 1 )
           {
           // Create leaves (  last level in the recursion )
           if (  mpTree->miTotalLeaves != 0 )
           GrowLeaves(  u8Level );
           }
           else
           {
           // Create sub stems
           GrowSubStems(  u8Level );
           }
           }
          }
          
          //---------------------------------------------------------------------------
          
     325  void TStem::CreateSection(  TSectionFrame *pSectionFrame,   const Real fSectionRadius,   const int iVertices )
          {
           // The amount of vertices in the section depends on the quality set by the user
           int i;
           Real fAngle;
           Real fModSectionRadius;
           Vector3 localPoint;
           Vector3 *pGlobalPoint;
           TSection *pSection;
           Real fLobedSectionRadius;
           TParameters *pParam = mpTree->mpParameters;
          
           pSection = new TSection(   );
          
           // Lame but effective hack to prevent empty triangles
           if (  fSectionRadius == 0 )
           fModSectionRadius = 0.0001;
           else
           fModSectionRadius = fSectionRadius;
          
           fAngle = (  2 * Math::PI ) / iVertices;
           for (  i=0; i<iVertices; i++ )
           {
           // Apply lobing to the section
           fLobedSectionRadius = fModSectionRadius * (  1.0 + pParam->mfLobeDepth * sin(  pParam->mu8Lobes*i*fAngle ) );
           localPoint.x = cos(  i*fAngle ) * fLobedSectionRadius;
           localPoint.y = 0.0;
           localPoint.z = sin(  i*fAngle ) * fLobedSectionRadius;
          
           pGlobalPoint = new Vector3(  0,  0,  0 );
           *pGlobalPoint = pSectionFrame->mQuat * (   pSectionFrame->mOrigin + localPoint  ) + pSectionFrame->mGlobalOrigin;
          
           pSection->push_back(  pGlobalPoint );
          
           // Update the maximum x,   y and z values of the tree
           if (  pGlobalPoint->x > mpTree->mfMaxX )
           mpTree->mfMaxX = pGlobalPoint->x;
           if (  pGlobalPoint->y > mpTree->mfMaxY )
           mpTree->mfMaxY = pGlobalPoint->y;
           if (  pGlobalPoint->z > mpTree->mfMaxZ )
           mpTree->mfMaxZ = pGlobalPoint->z;
           }
          
           mVectorOfSections.push_back(  pSection );
          }
          
          //---------------------------------------------------------------------------
          
     373  void TStem::GrowSubStems(  const uchar u8Level )
          {
           // Creates the sub stems for the current stem
           int i,   j;
           Vector3 localSubStemOrigin;
           Vector3 subStemOrigin;
           TSectionFrame *pSectionFrame;
           // TSectionFrame *pNextSubStemFrame;
           Quaternion quatX;
           Quaternion quatY;
           Quaternion subStemQuat;
          
           Real fFracPos; // Holds the current fractional y position along the stem (  used when spawning sub stems )
           Real fLocalPos; // Holds the current y position along a segment
           int iCurrentSegment; // Holds the segment where we reside along the stem (  used when spawning sub stems )
           Real fSubStemLength;
           Real fSubStemRadius;
           int iTotalSubStems;
           Degree fStemDownAngle; // The angle between the current stem and the sub stem
           Radian fStemDownAngle_Radian; // The angle between the current stem and the sub stem
           Radian fStemRotateAngle; // The angle between the previous sub stem and the currently being spawned sub stem
           Real fLocalRadius;
           Real fOffsetSubStem; // Holds the current y position along the stem in global coordinates of the sub stem that is about to be spawned
           TParameters *pParam = mpTree->mpParameters;
          
           // Initialize the angle about the y axis of the parent relative to the previous sub stem
           //fStemRotateAngle = mpTree->GetRandomValue(  2*Math::PI );
           fStemRotateAngle = mpTree->GetRandomValue(  Math::PI );
          
           // Calculate the amount of sub stems the current stem will spawn
           iTotalSubStems = (  int )(  mVectorOfSubStems.size(   ) );
          
           // Add child stems coming out of the current stem
           for (  i=0; i<iTotalSubStems; i++ )
           {
           // Calculate fractional position along the stem
           if (  u8Level == 0 )
           {
           fFracPos = pParam->mfBaseSize + (  (  i + 1 ) * (  1.0 - pParam->mfBaseSize ) / (  iTotalSubStems + 1 ) );
           if (  fFracPos < 1.0 / pParam->maiNCurveRes[u8Level] )
           iCurrentSegment = Trunc(  fFracPos * pParam->maiNCurveRes[u8Level]*FLARE_RESOLUTION );
           else
           iCurrentSegment = Trunc(  fFracPos * pParam->maiNCurveRes[u8Level] ) + FLARE_RESOLUTION - 1;
          
           // TODO : to improve this !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO TODO TODO !!!!!!
           fOffsetSubStem = fFracPos * mfLength;
           Real fCurrentLength = 0.0;
           for (  j=0; j<iCurrentSegment; j++ )
           fCurrentLength += mVectorOfSectionFrames[j]->mOrigin.y;
          
           fLocalPos = fOffsetSubStem - fCurrentLength;
          
           }
           else
           {
           fFracPos = (  i + 1 ) * (  1.0 / (  iTotalSubStems + 1 ) );
           iCurrentSegment = Trunc(  fFracPos * pParam->maiNCurveRes[u8Level] );
           fOffsetSubStem = fFracPos * mfLength;
           fLocalPos = fOffsetSubStem - iCurrentSegment * (  mfLength / pParam->maiNCurveRes[u8Level] );
           }
          
           // Calculate the y position of the sub stem measured from the base of the stem (  in the global coordinate system )
          
          
           // Calculate in which segment we reside
           // TODO: Check check !!!!!!!!!!!!!!!!!!!!!!
           // iCurrentSegment = trunc(  fFracPos / (  1.0 / pParam->maiNCurveRes[u8Level] ) ) + 1;
          
          
           /* Calculate the position within the segment (  "in meters" ).
           iCurrentSegment * (  1 / maiNCurveRes[u8Level] ) delivers us the fractional y
           position of the origin of the current segment along the stem.
           Multiplying this value with mfLength results in the global y position
           "in meters" of the segment. Subtracting this value from the current
           global y position results in the position within the segment. */
          
          
          
           /* Create the origin point of the sub stem frame. The origin is calculated
           from the origin of the local frame of the current segment and the
           local y position within the current segment. */
          
           pSectionFrame = mVectorOfSectionFrames[iCurrentSegment];
           localSubStemOrigin = Vector3(  0.0,   fLocalPos,   0.0 );
          
           subStemOrigin = pSectionFrame->mQuat * localSubStemOrigin + pSectionFrame->mGlobalOrigin;
          
           // Calculate the angle between the current stem and the sub stem and use this angle to create a rotation quaternion
           if (  pParam->mafNDownAngleV[u8Level + 1] >= 0.0 )
           fStemDownAngle = pParam->mafNDownAngle[u8Level + 1] + mpTree->GetRandomValue(  pParam->mafNDownAngleV[u8Level + 1] );
           else
           {
           Real fCurrentLength = (  u8Level==0 ) ? mfLength - mfBaseLength : mfLength;
           fStemDownAngle = pParam->mafNDownAngle[u8Level + 1] + pParam->mafNDownAngleV[u8Level + 1] *
           (  1.0 - 2 * ShapeRatio(  0,   (  mfLength - fOffsetSubStem ) / fCurrentLength ) );
           }
          
           fStemDownAngle_Radian = Radian(  fStemDownAngle );
          
           quatX.FromAngleAxis(  fStemDownAngle_Radian,   Vector3::UNIT_X  );
          
           if (  pParam->mafNRotate[u8Level + 1] >= 0 )
           fStemRotateAngle += Degree(  pParam->mafNRotate[u8Level+ 1] + mpTree->GetRandomValue(  pParam->mafNRotateV[u8Level+ 1] ) );
           else
           fStemRotateAngle += Degree(  180 + pParam->mafNRotate[u8Level+ 1] + mpTree->GetRandomValue(  pParam->mafNRotateV[u8Level+ 1] ) );
          
           if (  fStemRotateAngle > Radian(  Math::TWO_PI ) )
           fStemRotateAngle -= Radian(  Math::TWO_PI );
          
           quatY.FromAngleAxis(  fStemRotateAngle,   Vector3::UNIT_Y  );
          
           subStemQuat = pSectionFrame->mQuat * quatY * quatX;
          
          
           // Calculate the length of the sub stem
           mfLengthChildMax = pParam->mafNLength[u8Level + 1] + mpTree->GetRandomValue(  pParam->mafNLengthV[u8Level + 1] );
          
           if (  u8Level == 0 )
           fSubStemLength = mpTree->mfTrunkLength * mfLengthChildMax *
           ShapeRatio(  pParam->mu8Shape,   (  mpTree->mfTrunkLength - fOffsetSubStem ) / (  mpTree->mfTrunkLength - mfBaseLength ) );
           else
           fSubStemLength = mfLengthChildMax * (  mfLength - 0.6 * fOffsetSubStem );
          
           // Calculate the radius of the sub stem
           if (  mfLength == 0.0 )
           fSubStemRadius = 0.0;
           else
           fSubStemRadius = mfRadius * Math::Pow(  (  fSubStemLength / mfLength ),   pParam->mfRatioPower );
          
           // Check if the calculated radius is greater than the radius of the current stem at the spawning position
           fLocalRadius = CalculateSectionRadius(  u8Level,   fFracPos,   mfLength,   mfRadius );
          
           if (  (  fSubStemRadius > fLocalRadius ) || (  fSubStemRadius == 0.0 ) )
           fSubStemRadius = fLocalRadius;
          
           // Spawn the sub stem,   but only if the sub stem radius is greater than zero
           TSectionFrame subStemFrame(  subStemQuat,   Vector3(  0,  0,  0 ),   subStemOrigin );
           mVectorOfSubStems[i]->Grow(  subStemFrame,   fSubStemRadius,   u8Level + 1 );
          
           }
          }
          
          //---------------------------------------------------------------------------
          
     517  void TStem::GrowLeaves(  const uchar u8Level )
          {
           // Creates leaves for the current stem
          
           int i;
           Vector3 localLeafOrigin;
           Vector3 leafOrigin;
           Quaternion leafQuat;
           int iTotalLeaves;
           Real fFracPos; // Holds the current fractional y position along the stem (  used when spawning sub stems )
           int iCurrentSegment; // Holds the segment where we reside along the stem (  used when spawning sub stems )
           Real fLocalPos; // Holds the current y position along a segment
           TSectionFrame *pSectionFrame;
          // TSectionFrame *pLeafFrame;
           Quaternion quatX;
           Quaternion quatY;
           Radian fLeafRotateAngle; // The angle between the previous leaf and the currently being spawned leaf
           Degree fLeafDownAngle; // The angle between the current stem and the leaf
           Radian fLeafDownAngle_Radian; // The angle between the current stem and the leaf
           Real fOffsetLeaf;
           TParameters *pParam = mpTree->mpParameters;
           TSectionFrame leafFrame(  Quaternion::IDENTITY,   Vector3(  0,  0,  0 ),   Vector3(  0,  0,  0 ) );
          
           iTotalLeaves = Round(  pParam->miLeaves * ShapeRatio(  4,   mfOffsetChild / mpParent->mfLength ) * pParam->mfLeafQuality );
           //fLeafRotateAngle = mpTree->GetRandomValue(  2*Math::PI );
           fLeafRotateAngle = mpTree->GetRandomValue(  Math::PI );
          
           for (  i=0; i<iTotalLeaves; i++ )
           {
          
           // Calculate fractional position along the stem
          
           if (  u8Level == 0 )
           fFracPos = pParam->mfBaseSize + (  (  i + 1 ) * (  1.0 - pParam->mfBaseSize ) / (  iTotalLeaves + 1 ) );
           else
           fFracPos = (  i + 1 ) * (  1.0 / (  iTotalLeaves + 1 ) );
          
           // Calculate the y position of the leaf measured from the base of the stem (  in the global coordinate system )
           fOffsetLeaf = fFracPos * mfLength;
          
           // Calculate in which segment we reside
           iCurrentSegment = Trunc(  fFracPos * pParam->maiNCurveRes[u8Level] );
          
           /* Calculate the position within the segment (  "in meters" ).
           iCurrentSegment * (  1 / maiNCurveRes[u8Level] ) delivers us the fractional y
           position of the origin of the current segment along the stem.
           Multiplying this value with mfLength results in the global y position
           "in meters" of the segment. Subtracting this value from the current
           global y position results in the position within the segment. */
          
           fLocalPos = fOffsetLeaf - iCurrentSegment * (  mfLength / pParam->maiNCurveRes[u8Level] );
          
           /* Create the origin point of the sub stem frame. The origin is calculated
           from the origin of the local frame of the current segment and the
           local y position within the current segment. */
          
           pSectionFrame = mVectorOfSectionFrames[iCurrentSegment];
           localLeafOrigin = Vector3(  0.0,   fLocalPos,   0.0 );
          
           leafOrigin = pSectionFrame->mQuat * localLeafOrigin + pSectionFrame->mGlobalOrigin;
          
           // *** Not in Jason Weber and Joseph Penn's model: when the season is autumn,   some leaves will be lying on the ground
          
           // calculate the rotation angle around the y axis of the parent relative to the previous sub stem
           if (  pParam->mafNRotate[u8Level] >= 0 )
           fLeafRotateAngle += Degree(  pParam->mafNRotate[u8Level] + mpTree->GetRandomValue(  pParam->mafNRotateV[u8Level] ) );
           else
           fLeafRotateAngle += Degree(  180 + pParam->mafNRotate[u8Level] + mpTree->GetRandomValue(  pParam->mafNRotateV[u8Level] ) );
          
           quatY.FromAngleAxis(  fLeafRotateAngle,   Vector3::UNIT_Y  );
          
           if (  (  mpTree->mu8Season == 3 ) && (  mpTree->GetRandomValue(  3 ) == 0 ) )
           {
          
           // Adjust the y coordinates of the axes of the local coordinate system and of the origin of the local coordinate system
          
           // Scatter the leaves around over the ground
          
           leafOrigin.y = 0.0;
           leafOrigin.x *= 1.0 + mpTree->GetRandomValue(  3.0 );
           leafOrigin.z *= 1.0 + mpTree->GetRandomValue(  3.0 );
          
           leafQuat = quatY * pSectionFrame->mQuat;
           }
           else
           {
           // Calculate the angle between the current stem and the sub stem and use this angle to create a rotation quaternion
           if (  pParam->mafNDownAngleV[u8Level] >= 0.0 )
           fLeafDownAngle = pParam->mafNDownAngle[u8Level] + mpTree->GetRandomValue(  pParam->mafNDownAngleV[u8Level] );
           else
           fLeafDownAngle = pParam->mafNDownAngle[u8Level] + pParam->mafNDownAngleV[u8Level] *
           (  1.0 - 2 * ShapeRatio(  0,   (  mfLength - fOffsetLeaf ) / (  mfLength - mfBaseLength ) ) );
          
           fLeafDownAngle_Radian = Radian(  fLeafDownAngle );
           quatX.FromAngleAxis(  fLeafDownAngle_Radian,   Vector3::UNIT_X  );
          
           leafQuat = quatY * quatX * pSectionFrame->mQuat;
           }
          
           // We will now adjust the leaf orientation,   so that it is facing upwards and outwards,   to optimize the available direct sunlight and scattered sky light
           // And finally,   create the leaf itself
           // pLeafFrame = new TSectionFrame(  leafQuat,   localLeafOrigin,   leafOrigin );
           leafFrame.mQuat = leafQuat;
           leafFrame.mOrigin = localLeafOrigin;
           leafFrame.mGlobalOrigin = leafOrigin;
          
           // mVectorOfSectionFrames.push_back(  pLeafFrame );
           CreateLeaf(   &leafFrame /*pLeafFrame*/,   pParam->mu8LeafShape );
          
           // delete pLeafFrame;
           }
          
           // mpTree->miTotalLeavesFaces += 6 * iTotalLeaves; // 6 faces per leaf
           mpTree->miTotalLeavesFaces += 2 * iTotalLeaves; // 2 faces per leaf
          }
          
          //---------------------------------------------------------------------------
          
     635  void TStem::CreateLeaf(  TSectionFrame *pLeafFrame,   const TLeafShape u8LeafShape )
          {
           int i;
           Vector3 localPoint;
           Vector3 *pGlobalPoint;
           TLeaf *pLeaf;
           TParameters *pParam = mpTree->mpParameters;
          
           pLeaf = new TLeaf(   );
          
           // Leaf shapes are hard coded right now. Later on they should be made available through a leaf definition file or something like that
          
           // TODO: implement Leaf Shapes : u8LeafShape
           // TODO: gaLeafPolygonVertices[u8LeafShape][i] !!!!!!!!!
          
           for (  i=0; i<gu8LeafPolygonVerticesNumber; i++ )
           {
           localPoint = gaLeafPolygonVertices[i];
           // Scale the length of the leaf
           localPoint.y *= pParam->mfLeafScale / Math::Sqrt(  pParam->mfLeafQuality );
           // Scale the width of the leaf
           localPoint.x *= pParam->mfLeafScale * pParam->mfLeafScaleX / Math::Sqrt(  pParam->mfLeafQuality );
          
           pGlobalPoint = new Vector3(  0,  0,  0 );
           *pGlobalPoint = pLeafFrame->mQuat * (  localPoint + pLeafFrame->mOrigin ) + pLeafFrame->mGlobalOrigin;
          
           pLeaf->push_back(  pGlobalPoint );
           }
          
           mpTree->miTotalVertices += gu8LeafPolygonVerticesNumber;
          
           mVectorOfLeaves.push_back(  pLeaf );
          }
          
          //---------------------------------------------------------------------------
          
     671  Real TStem::CalculateSectionRadius(  const uchar u8Level,   const Real fY,   const Real fStemLength,   const Real fStemRadius )
          {
           // expecting: 0 <= fY <= 1
           // return the radius of the stem at the (  normalized ) y position along the stem.
           // for precise details to check "The Creation and Rendering of Realistic Trees" article by Jason Weber and Joseph Penn
          
           Real fY2,   fY3;
           Real fDepth; // Scaling factor used for periodic tapering
           Real fTaperY; // Tapered radius along at the (  normalized ) y position along the stem
           Real fUnitTaper; // UnitTaper is used to determine the radius of the stem along a specified (  normalized ) position along the stem
           Real fSectionRadius;
          
           TParameters *pParam = mpTree->mpParameters;
           Real fLevelTaper = pParam->mafNTaper[u8Level];
          
           // Calculate UnitTaper,   a variable used to determine the radius of the stem along a specified (  normalized ) position Z along the stem
           fUnitTaper = 0.0;
          
           if (  (  fLevelTaper >= 0.0 ) && (  fLevelTaper < 1.0 ) )
           fUnitTaper = fLevelTaper;
           else if (  (  fLevelTaper >= 1.0 ) && (  fLevelTaper < 2.0 ) )
           fUnitTaper = 2.0 - fLevelTaper;
           else if (  (  fLevelTaper >= 2.0 ) && (  fLevelTaper < 3.0 ) )
           fUnitTaper = 0.0;
          
           fTaperY = fStemRadius * (  1.0 - (  fUnitTaper * fY ) );
          
           if (  (  fLevelTaper >= 0 ) && (  fLevelTaper < 1 ) )
           fSectionRadius = fTaperY;
           else
           {
           fY2 = (  1.0 - fY ) * fStemLength;
          
           // Initialize Depth
           if (  (  fLevelTaper < 2 ) || (  fY2 < fTaperY ) )
           fDepth = 1.0;
           else
           fDepth = fLevelTaper - 2.0;
          
           if (  fLevelTaper < 2 )
           fY3 = fY2;
           else
           fY3 = fabs(  fY2 - 2 * fTaperY * floor(  fY2 / (  2 * fTaperY ) + 0.5 ) );
          
           // Return the radius
           if (  (  fLevelTaper < 2 ) && (  fY3 >= fTaperY ) )
           fSectionRadius = fTaperY;
           else
           fSectionRadius = (  1.0 - fDepth ) * fTaperY + fDepth * sqrt(  fabs(  fTaperY * fTaperY - (  fY3 - fTaperY ) * (  fY3 - fTaperY ) ) );
          
           }
          
           // Calculate flaring
           if (  u8Level == 0 )
           {
           fY2 = 1.0 - 8 * fY;
           if (  fY2 < 0.0 )
           fY2 = 0.0;
          
           fSectionRadius *= 1.0 + pParam->mfFlare * (  Math::Pow(  100,   fY2 ) - 1.0 ) / 100.0;
           }
          
           return fSectionRadius;
          }
          
          //---------------------------------------------------------------------------
          
     738  Real TStem::CalculateVerticalAttraction(  const uchar u8Level,   const Quaternion &rQuat )
          {
           // there is no vertical attraction for the trunk and main branches,   so u8Level should be > 1
           // return an angle in radians that is added to the segments curve angle to simulate vertical attraction
          
           Vector3 transformY;
           Vector3 transformZ;
           Real fDeclination;
           Real fOrientation;
          
           // TODO : need to review the math anyway !!!!!!!!!!!
           transformY = rQuat * Vector3::UNIT_Y;
           transformZ = rQuat * Vector3::UNIT_Z;
           fDeclination = acos(  transformY.y );
           fOrientation = acos(  transformZ.y );
          
           // why doing an acos to use the cos of the value at the end ?????????????? !!!!!!!!!!!
           // return mpTree->mpParameters->mfAttractionUp * fDeclination * cos(  fOrientation ) / mpTree->mpParameters->maiNCurveRes[u8Level];
           return mpTree->mpParameters->mfAttractionUp * fDeclination * transformZ.y / mpTree->mpParameters->maiNCurveRes[u8Level];
          }
          
          //---------------------------------------------------------------------------
          
     761  Real TStem::ShapeRatio(  const int iShape,   const Real fRatio )
          {
           // return a certain predefined ratio depending on the Shape and Ratio parameter
           // for precise details to check "The Creation and Rendering of Realistic Trees" article by Jason Weber and Joseph Penn
          
           Real fShapeRatio = 0.0;
          
           switch (  iShape )
           {
           case 0:
           fShapeRatio = 0.2 + 0.8 * fRatio;
           break;
           case 1:
           fShapeRatio = 0.2 + 0.8 * sin(  Math::PI * fRatio );
           break;
           case 2:
           fShapeRatio = 0.2 + 0.8 * sin(  Math::HALF_PI * fRatio );
           break;
           case 3:
           fShapeRatio = 1.0;
           break;
           case 4:
           fShapeRatio = 0.5 + 0.5 * fRatio;
           break;
           case 5:
           if (  fRatio <= 0.7 )
           fShapeRatio = fRatio / 0.7;
           else
           fShapeRatio = (  1.0 - fRatio ) / 0.3;
           break;
           case 6:
           fShapeRatio = 1.0 - 0.8 * fRatio;
           break;
           case 7:
           if (  fRatio <= 0.7 )
           fShapeRatio = 0.5 + 0.5 * fRatio / 0.7;
           else
           fShapeRatio = 0.5 + 0.5 * (  1.0 - fRatio ) / 0.3;
           break;
           case 8:
           // TODO TODO: Use pruning envelope for ShapeRatio(  8,   fRatio ) !!!!!!!!!!!!!!!!!!!!!!!
           fShapeRatio = 1.0;
           break;
           default:
           fShapeRatio = 0.2 + 0.8 * fRatio;
           }
          
           return fShapeRatio;
          }
          
          //---------------------------------------------------------------------------
          
     813  void TStem::AddMeshVertices(  Real **pVertexArray,   RGBA **pVertexColorArray )
          {
           uint i,   j,   u16NbSections,   u16NbVertices,   u16NbSubStems;
           TStem *pStem;
           TSection *pSection;
           Vector3 *pCurrentVertex,   *pPrevVertex,   *pNextVertex;
           Vector3 currentNormal;
          
           u16NbSections = (  uint )mVectorOfSections.size(   );
          
           // AARRGGBB
           RGBA color = 0xFFEEDDCC;
          
           for(  i=0; i<u16NbSections; i++ )
           {
           pSection = mVectorOfSections[i];
           u16NbVertices = (  uint )pSection->size(   );
          
           for (  j=0; j<u16NbVertices; j++ )
           {
           pCurrentVertex = (  *pSection )[j];
           pPrevVertex = (  *pSection )[(  j-1 )%u16NbVertices];
           pNextVertex = (  *pSection )[(  j+1 )%u16NbVertices];
           currentNormal = 2 * *pCurrentVertex - *pPrevVertex - *pNextVertex;
           currentNormal.normalise(   );
          
           FillVertex(  *pVertexArray,   pCurrentVertex->x,   pCurrentVertex->y,   pCurrentVertex->z,  
           currentNormal.x,   currentNormal.y,   currentNormal.z,  
           2*(  Real )j/u16NbVertices,   2*(  Real )i/u16NbSections );
          
           *(  *pVertexColorArray )++ = color;
           }
           }
          
           u16NbSubStems = (  uint )mVectorOfSubStems.size(   );
           for (  i=0; i<u16NbSubStems ; i++ )
           {
           pStem = mVectorOfSubStems[i];
           pStem->AddMeshVertices(  pVertexArray,   pVertexColorArray );
           }
          
          }
          //---------------------------------------------------------------------------
          
     857  void TStem::AddLeavesVertices(  Real **pVertexArray,   RGBA **pVertexColorArray,   const Real fDist )
          {
           uint i,   j,   u16NbLeaves,   u16NbVertices,   u16NbSubStems;
           TStem *pStem,   *pTrunk,   *p1Stem;
           TLeaf *pLeaf;
           Vector3 *pCurrentVertex,   *pPrevVertex,   *pNextVertex;
           Vector3 currentNormal;
           int iLeafType;
           Real fTexCoordOffsetU,   fTexCoordOffsetV;
           Real fDistRatio;
           Real fDistToTrunk = fDist;
           TParameters *pParams = mpTree->mpParameters;
          
           u16NbLeaves = (  uint )mVectorOfLeaves.size(   );
          
           // AARRGGBB
           //RGBA color = 0xCC77CCAA;
          
           pTrunk = mpTree->mpTrunk;
          
           if (  pParams->mu8Levels > 2 )
           {
           p1Stem = this;
           if (  p1Stem == pTrunk )
           fDistRatio = 1.0;
           else if (  p1Stem->mpParent != pTrunk )
           {
           while (  p1Stem->mpParent != pTrunk )
           p1Stem = p1Stem->mpParent;
           }
          
           fDistRatio = fDist / p1Stem->mfLength;
           if (  fDistRatio > 1.0 )
           fDistRatio = 1.0;
           }
           else
           fDistRatio = 1.0;
          
          
           uchar u8ColR = (  uchar )(  20 + 215*fDistRatio + mpTree->GetRandomValue(  20.0 ) );
           uchar u8ColG = (  uchar )(  60 + 175*fDistRatio + mpTree->GetRandomValue(  20.0 ) );
           uchar u8ColB = (  uchar )(  40 + 195*fDistRatio + mpTree->GetRandomValue(  20.0 ) );
           uchar u8ColA = pParams->GetLeafAlpha(   );
          
          /*
           uchar u8ColR = (  uchar )(  255*fDistRatio );
           uchar u8ColG = (  uchar )(  255*fDistRatio );
           uchar u8ColB = (  uchar )(  255*fDistRatio );
          */
           RGBA color = (  u8ColA << 24 ) | (  u8ColR << 16 ) | (  u8ColG << 8 ) | (  uint )u8ColB;
          
           for(  i=0; i<u16NbLeaves; i++ )
           {
           pLeaf = mVectorOfLeaves[i];
           u16NbVertices = (  uint )pLeaf->size(   );
           iLeafType = Round(   mpTree->GetRandomValue(  3.99 )  );
           fTexCoordOffsetU = 0.5 * (  iLeafType / 2 );
           fTexCoordOffsetV = 0.5 * (  iLeafType % 2 );
          
           for (  j=0; j<u16NbVertices; j++ )
           {
           pCurrentVertex = (  *pLeaf )[j];
           pPrevVertex = (  *pLeaf )[(  j-1 )%u16NbVertices];
           pNextVertex = (  *pLeaf )[(  j+1 )%u16NbVertices];
          
           currentNormal = (  *pCurrentVertex - *pPrevVertex ).crossProduct(  *pNextVertex - *pCurrentVertex );
           currentNormal.normalise(   );
          
           FillVertex(  *pVertexArray,   pCurrentVertex->x,   pCurrentVertex->y,   pCurrentVertex->z,  
           currentNormal.x,   currentNormal.y,   currentNormal.z,  
           0.5*(  gaLeafPolygonVertices[j].x + 0.5 ) + fTexCoordOffsetU,  
           1.0 - 0.5*(  gaLeafPolygonVertices[j].y ) - fTexCoordOffsetV );
          
           *(  *pVertexColorArray )++ = color;
           }
           }
          
           u16NbSubStems = (  uint )mVectorOfSubStems.size(   );
           for (  i=0; i<u16NbSubStems ; i++ )
           {
           pStem = mVectorOfSubStems[i];
          
           if (  this == pTrunk )
           fDistToTrunk = 0.0;
           else if (  (  mVectorOfSectionFrames[0] != NULL ) && (  pStem->mVectorOfSectionFrames[0] != NULL ) )
           fDistToTrunk = fDist + (  pStem->mVectorOfSectionFrames[0]->mGlobalOrigin - mVectorOfSectionFrames[0]->mGlobalOrigin ).length(   );
          
           pStem->AddLeavesVertices(  pVertexArray,   pVertexColorArray,   fDistToTrunk );
           }
          }
          //---------------------------------------------------------------------------
          
     949  void TStem::AddCoordFrameVertices(  Real **pVertexArray,   RGBA **pVertexColorArray )
          {
           unsigned long i,   j,   u32NbSections,   u32NbVertices,   u32NbSubStems;
           TStem *pStem;
           TSection *pSection;
           TSectionFrame *pSectionFrame;
           Vector3 currentVertex,   currentNormal;
          
           u32NbSections = (  unsigned long )mVectorOfSections.size(   );
           u32NbVertices = gu8CoordFrameVerticesNumber;
          
           for(  i=0; i<u32NbSections; i++ )
           {
           pSection = mVectorOfSections[i];
           pSectionFrame = mVectorOfSectionFrames[i];
          
           for (  j=0; j<u32NbVertices; j++ )
           {
           currentVertex = pSectionFrame->mGlobalOrigin
           + pSectionFrame->mQuat * (  0.5*gaCoordFrameVertices[j] + pSectionFrame->mOrigin );
           currentNormal = pSectionFrame->mQuat * gaCoordFrameNormals[j];
           currentNormal.normalise(   );
          
           FillVertex(  *pVertexArray,   currentVertex.x,   currentVertex.y,   currentVertex.z,  
           currentNormal.x,   currentNormal.y,   currentNormal.z,  
           0.0,   0.0 );
          
           **pVertexColorArray = gaCoordFrameColors[j];
           (  *pVertexColorArray )++;
           }
           }
          
           u32NbSubStems = (  unsigned long )mVectorOfSubStems.size(   );
           for (  i=0; i<u32NbSubStems ; i++ )
           {
           pStem = mVectorOfSubStems[i];
           pStem->AddCoordFrameVertices(  pVertexArray,   pVertexColorArray );
           }
          
          }
          //---------------------------------------------------------------------------
          
     991  void TStem::AddMeshFaces(  unsigned long** pFaceIndexes,   unsigned long* pIndexOffset )
          {
           unsigned long i,   j,   u32NbSections,   u32NbVertices,   u32NbSubStems,   u32Offest;
           TStem *pStem;
           TSection *pSection;
          
           u32NbSections = (  unsigned long )mVectorOfSections.size(   );
          
           for(  i=0; i<u32NbSections - 1; i++ )
           {
           pSection = mVectorOfSections[i];
           u32NbVertices = (  unsigned long )pSection->size(   );
           u32Offest = *pIndexOffset + i*u32NbVertices;
          
           for (  j=0; j<u32NbVertices; j++ )
           {
           FillIndex(  *pFaceIndexes,   u32Offest + (  j+1 )%u32NbVertices,   u32Offest + j,   u32Offest + j + u32NbVertices );
           FillIndex(  *pFaceIndexes,   u32Offest + (  j+1 )%u32NbVertices,   u32Offest + j + u32NbVertices,   u32Offest + (  j+1 )%u32NbVertices + u32NbVertices );
           }
           }
          
           *pIndexOffset += u32NbVertices * u32NbSections;
          
           u32NbSubStems = (  unsigned long )mVectorOfSubStems.size(   );
           for (  i=0; i<u32NbSubStems ; i++ )
           {
           pStem = mVectorOfSubStems[i];
           pStem->AddMeshFaces(  pFaceIndexes,   pIndexOffset );
           }
          }
          //---------------------------------------------------------------------------
          
    1023  void TStem::AddLeavesMeshFaces(  unsigned long** pFaceIndexes,   unsigned long* pIndexOffset )
          {
           unsigned long i,   u32NbLeaves,   u32NbVertices,   u32NbSubStems,   u32Offest;
           TStem *pStem;
           TLeaf *pLeaf;
          
           u32NbLeaves = (  unsigned long )mVectorOfLeaves.size(   );
          
           for(  i=0; i<u32NbLeaves; i++ )
           {
           pLeaf = mVectorOfLeaves[i];
           u32NbVertices = (  unsigned long )pLeaf->size(   );
           // TODO : improve code !!!!!!!!! no need of u32Offest !!
           u32Offest = *pIndexOffset;
          
           // TODO : improve code !!! currently hard coded
          
           FillIndex(  *pFaceIndexes,   u32Offest + 0,   u32Offest + 1,   u32Offest + 2 );
           FillIndex(  *pFaceIndexes,   u32Offest + 0,   u32Offest + 2,   u32Offest + 3 );
          
           *pIndexOffset += u32NbVertices;
           }
          
           u32NbSubStems = (  unsigned long )mVectorOfSubStems.size(   );
           for (  i=0; i<u32NbSubStems ; i++ )
           {
           pStem = mVectorOfSubStems[i];
           pStem->AddLeavesMeshFaces(  pFaceIndexes,   pIndexOffset );
           }
          }
          //---------------------------------------------------------------------------
          
    1055  void TStem::AddCoordFrameMeshFaces(  unsigned long** pFaceIndexes,   unsigned long* pIndexOffset )
          {
           unsigned long i,   u32NbSections,   u32NbVertices,   u32NbSubStems,   u32Offest;
           TStem *pStem;
          
           u32NbSections = (  unsigned long )mVectorOfSections.size(   );
           u32NbVertices = TREE_COORDFRAMEVERTICESNUMBER;
          
           for(  i=0; i<u32NbSections; i++ )
           {
           u32Offest = *pIndexOffset;
          
           FillIndex(  *pFaceIndexes,   u32Offest + 0,   u32Offest + 1,   u32Offest + 2 );
           FillIndex(  *pFaceIndexes,   u32Offest + 0,   u32Offest + 2,   u32Offest + 3 );
           FillIndex(  *pFaceIndexes,   u32Offest + 0,   u32Offest + 3,   u32Offest + 1 );
          
           FillIndex(  *pFaceIndexes,   u32Offest + 4,   u32Offest + 5,   u32Offest + 6 );
           FillIndex(  *pFaceIndexes,   u32Offest + 4,   u32Offest + 6,   u32Offest + 7 );
           FillIndex(  *pFaceIndexes,   u32Offest + 4,   u32Offest + 7,   u32Offest + 5 );
          
           FillIndex(  *pFaceIndexes,   u32Offest + 8,   u32Offest + 9,   u32Offest + 10 );
           FillIndex(  *pFaceIndexes,   u32Offest + 8,   u32Offest + 10,   u32Offest + 11 );
           FillIndex(  *pFaceIndexes,   u32Offest + 8,   u32Offest + 11,   u32Offest + 9 );
          
           *pIndexOffset += u32NbVertices;
           }
          
           u32NbSubStems = (  unsigned long )mVectorOfSubStems.size(   );
           for (  i=0; i<u32NbSubStems ; i++ )
           {
           pStem = mVectorOfSubStems[i];
           pStem->AddCoordFrameMeshFaces(  pFaceIndexes,   pIndexOffset );
           }
          }
          //---------------------------------------------------------------------------
          
    1091  void TStem::FillVertex(  Real *&p,  Real x,  Real y,  Real z,  Real nx,  Real ny,  Real nz,   Real u,  Real v )
          {
           *p++ = x;
           *p++ = y;
           *p++ = z;
           *p++ = nx;
           *p++ = ny;
           *p++ = nz;
           *p++ = u;
           *p++ = v;
          
          }
          //---------------------------------------------------------------------------
          
    1105  void TStem::FillIndex(  unsigned long *&p,  unsigned long i1,  unsigned long i2,  unsigned long i3 )
          {
           *p++ = i1;
           *p++ = i2;
           *p++ = i3;
          }
          //---------------------------------------------------------------------------
          
          } // namespace

./components/ogre/environment/meshtree/TStem.h

       1  #ifndef __TStem_H__
          #define __TStem_H__
          
          #include "../../OgreIncludes.h"
          #include "TTypes.h"
          
          #define FLARE_RESOLUTION 10
          
          /*
           Based "The Creation and Rendering of Realistic Trees" article by Jason Weber and Joseph Penn
           Based on a port of Delphi code from TReal project by Ton van den Heuvel
           For further information go see:
           http://members.chello.nl/~l.vandenheuvel2/TReal/
           Copyright (  c ) 2002-2003,   Ton van den Heuvel
           Copyright (  c ) 2004,   Nicolas Chauvin
          
           ==================================
           Tree generation classes for Ogre3D
           ==================================
          
          */
          
          namespace Ogre {
          
      25  class Tree;
          
          // Leaf definitions,   hard coded for the moment...later on these leaf
          // definitions should be loaded from leaf definition files.
          
          #define TREE_LEAFPOLYGONVERTICESNUMBER 4
          const uchar gu8LeafPolygonVerticesNumber = TREE_LEAFPOLYGONVERTICESNUMBER;
          
          const Vector3 gaLeafPolygonVertices[TREE_LEAFPOLYGONVERTICESNUMBER] =
           {
           Vector3(   -0.5,   0.0,   0.0 ),  
           Vector3(  -0.5,   1.0,   0.0 ),  
           Vector3(  0.5,   1.0,   0.0 ),  
           Vector3(  0.5,   0.0,   0.0 )
           };
          
          // Coordinate Frame Meshes for debugging purpose
          #define TREE_COORDFRAMEVERTICESNUMBER 12
          const uchar gu8CoordFrameVerticesNumber = TREE_COORDFRAMEVERTICESNUMBER;
          const Vector3 gaCoordFrameVertices[TREE_COORDFRAMEVERTICESNUMBER] =
           {
           Vector3(   1.00,   0.00,   0.00 ),  
           Vector3(   0.00,  -0.03,  -0.04 ),  
           Vector3(   0.00,  -0.03,   0.04 ),  
           Vector3(   0.00,   0.05,   0.00 ),  
           Vector3(   0.00,   1.00,   0.00 ),  
           Vector3(  -0.04,   0.00,  -0.03 ),  
           Vector3(   0.04,   0.00,  -0.03 ),  
           Vector3(   0.00,   0.00,   0.05 ),  
           Vector3(   0.00,   0.00,   1.00 ),  
           Vector3(  -0.03,  -0.04,   0.00 ),  
           Vector3(  -0.03,   0.04,   0.00 ),  
           Vector3(   0.05,   0.00,   0.00 )
           };
          
          const Vector3 gaCoordFrameNormals[TREE_COORDFRAMEVERTICESNUMBER] =
           {
           Vector3(   1.0,   0.0,   0.0 ),  
           Vector3(   0.0,  -0.6,  -0.8 ),  
           Vector3(   0.0,  -0.6,   0.8 ),  
           Vector3(   0.0,   1.0,   0.0 ),  
           Vector3(   0.0,   1.0,   0.0 ),  
           Vector3(  -0.8,   0.0,  -0.6 ),  
           Vector3(   0.8,   0.0,  -0.6 ),  
           Vector3(   0.0,   0.0,   1.0 ),  
           Vector3(   0.0,   0.0,   1.0 ),  
           Vector3(  -0.6,  -0.8,   0.0 ),  
           Vector3(  -0.6,   0.8,   0.0 ),  
           Vector3(   1.0,   0.0,   0.0 )
           };
          
          const RGBA gaCoordFrameColors[TREE_COORDFRAMEVERTICESNUMBER] =
           {
           0xA0FF0000,  
           0xA0FF0000,  
           0xA0FF0000,  
           0xA0FF0000,  
           0xA000FF00,  
           0xA000FF00,  
           0xA000FF00,  
           0xA000FF00,  
           0xA00000FF,  
           0xA00000FF,  
           0xA00000FF,  
           0xA00000FF
           };
          
          //---------------------------------------------------------------------------
          
      94  class TStem
          {
           private:
          
      98   std::vector<TSection*> mVectorOfSections;
      99   Real mfBaseLength;
     100   Real mfLength;
     101   Real mfRadius;
     102   Tree *mpTree;
     103   Vector3 mStemOrigin;
     104   std::vector<class TStem*> mVectorOfSubStems;
     105   std::vector<TLeaf*> mVectorOfLeaves;
           TStem *mpParent;
     107   Real mfLengthChildMax; // The maximum relative length of the substem
     108   Real mfOffsetChild; // Holds the current y position along the stem in global coordinates
           // Vector of local orientation frame of the sections that make up the current stem
     110   std::vector<class TSectionFrame*> mVectorOfSectionFrames;
          
     112   void FillVertex(  Real *&p,  Real x,  Real y,  Real z,  Real nx,  Real ny,  Real nz,   Real u,  Real v );
     113   void FillIndex(  unsigned long *&p,  unsigned long i1,  unsigned long i2,  unsigned long i3 );
          
           protected:
          
          
           public:
          
     120   TStem(  Tree *pTree );
     121   ~TStem(   );
          
     123   void CreateStructure(  TStem *pParent,   const Real fLength,   const Real fOffsetChild,   const uchar u8Level );
     124   void Grow(  const TSectionFrame &rSectionFrame,   const Real fRadius,   const uchar u8Level );
     125   void CreateSection(  TSectionFrame *pSectionFrame,   const Real fSectionRadius,   const int iVertices );
     126   void GrowSubStems(  const uchar u8Level );
     127   void GrowLeaves(  const uchar u8Level );
     128   void CreateLeaf(  TSectionFrame *pLeafFrame,   const TLeafShape u8LeafShape );
     129   Real CalculateSectionRadius(  const uchar u8Level,   const Real fY,   const Real fStemLength,   const Real fStemRadius );
     130   Real CalculateVerticalAttraction(  const uchar u8Level,   const Quaternion &rQuat );
     131   Real ShapeRatio(  const int iShape,   const Real fRatio );
          
     133   void AddMeshVertices(  Real** pVertexArray,   RGBA **pVertexColorArray );
     134   void AddLeavesVertices(  Real **pVertexArray,   RGBA **pVertexColorArray,   const Real fDist );
     135   void AddCoordFrameVertices(  Real **pVertexArray,   RGBA **pVertexColorArray );
     136   void AddMeshFaces(  unsigned long** pFaceIndexes,   unsigned long* pIndexOffset );
     137   void AddLeavesMeshFaces(  unsigned long** pFaceIndexes,   unsigned long* pIndexOffset );
     138   void AddCoordFrameMeshFaces(  unsigned long** pFaceIndexes,   unsigned long* pIndexOffset );
          
          };
          
          //---------------------------------------------------------------------------
          
          } // namespace
          
          #endif

./components/ogre/environment/meshtree/TTypes.h

       1  #ifndef __TTypes_H__
          #define __TTypes_H__
          
          #include <vector>
          #include "Ogre.h"
          
          /*
           Based "The Creation and Rendering of Realistic Trees" article by Jason Weber and Joseph Penn
           Based on a port of Delphi code from TReal project by Ton van den Heuvel
           For further information go see:
           http://members.chello.nl/~l.vandenheuvel2/TReal/
           Copyright (  c ) 2002-2003,   Ton van den Heuvel
           Copyright (  c ) 2004,   Nicolas Chauvin
          
           ==================================
           Tree generation classes for Ogre3D
           ==================================
          
          */
          
          namespace Ogre {
          
          typedef std::vector<class Vector3*> TSection;
          typedef std::vector<class Vector3*> TLeaf;
          typedef uchar TLeafShape;
          
          //---------------------------------------------------------------------------
          
      29  class TSectionFrame
          {
           public:
      32   Quaternion mQuat;
      33   Vector3 mOrigin;
      34   Vector3 mGlobalOrigin;
          
      36   TSectionFrame(  const Quaternion &rQuat,   const Vector3 &rOrign,   const Vector3 &rGlobalOrign ): mQuat(  rQuat ),  
           mOrigin(  rOrign ),  
           mGlobalOrigin(  rGlobalOrign ){};
          
          };
          
          //---------------------------------------------------------------------------
          
          }// namespace
          
          #endif

./components/ogre/environment/pagedgeometry/include/BatchPage.h

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //BatchPage.h
          //BatchPage is an extension to PagedGeometry which displays entities as static geometry.
          //-------------------------------------------------------------------------------------
          
          #ifndef __BatchPage_H__
          #define __BatchPage_H__
          
          #include "PagedGeometry.h"
          #include "BatchedGeometry.h"
          
          #include "OgrePrerequisites.h"
          #include "OgreStringConverter.h"
          
          namespace PagedGeometry {
          
          /**
          \brief The BatchPage class renders entities as StaticGeometry.
          
          This is one of the geometry page types included in the StaticGeometry engine. These
          page types should be added to a PagedGeometry object with PagedGeometry::addDetailLevel(   )
          so the PagedGeometry will know how you want your geometry displayed.
          
          To use this page type,   use:
          \code
          PagedGeometry::addDetailLevel<BatchPage>(  farRange );
          \endcode
          
          This page type uses batched geometry (  Ogre::StaticGeometry ) to represent the entities.
          Batched geometry is generally much faster than plain entities,   since video card state
          changes and transform calculations can be minimized. Batched geometry can be anywhere
          from 2 to 20 times faster than plain entities.
          */
      43  class BatchPage: public GeometryPage
          {
          public:
      46   void init(  PagedGeometry *geom );
      47   ~BatchPage(   );
          
      49   void addEntity(  Ogre::Entity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale,   const Ogre::ColourValue &color );
      50   void build(   );
      51   void removeEntities(   );
          
      53   void setVisible(  bool visible );
      54   void setFade(  bool enabled,   Ogre::Real visibleDist,   Ogre::Real invisibleDist );
          
      56   void addEntityToBoundingBox(   ) {}
      57   void clearBoundingBox(   ) {}
      58   const Ogre::AxisAlignedBox &getBoundingBox(   ) { return batch->getBoundingBox(   ); }
          
          private:
      61   void _updateShaders(   );
          
      63   bool fadeEnabled,   shadersSupported;
      64   Ogre::Real visibleDist,   invisibleDist;
      65   std::vector<Ogre::MaterialPtr> unfadedMaterials;
          
      67   Ogre::SceneManager *sceneMgr;
      68   BatchedGeometry *batch;
          
           static unsigned long refCount;
           static unsigned long GUID;
      72   static inline Ogre::String getUniqueID(  const Ogre::String &prefix )
           {
           return prefix + Ogre::StringConverter::toString(  ++GUID );
           }
          };
          
          }
          
          #endif

./components/ogre/environment/pagedgeometry/include/BatchedGeometry.h

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
          1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
          2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
          3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //BatchedGeometry.h
          //A "lightweight" version of Ogre::StaticGeometry,   which gives you a little more control
          //over the batch materials,   etc.
          //-------------------------------------------------------------------------------------
          
          #ifndef __BatchedGeometry_H__
          #define __BatchedGeometry_H__
          
          #include "OgrePrerequisites.h"
          #include "OgreMovableObject.h"
          #include "OgreSceneNode.h"
          #include "OgreMaterialManager.h"
          
          namespace PagedGeometry {
          
      26  class BatchedGeometry: public Ogre::MovableObject
          {
          public:
      29   BatchedGeometry(  Ogre::SceneManager *mgr,   Ogre::SceneNode *rootSceneNode );
      30   ~BatchedGeometry(   );
          
      32   void addEntity(  Ogre::Entity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &orientation = Ogre::Quaternion::IDENTITY,   const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE,   const Ogre::ColourValue &color = Ogre::ColourValue::White );
      33   void build(   );
      34   void clear(   );
          
      36   Ogre::Vector3 _convertToLocal(  const Ogre::Vector3 &globalVec ) const;
          
      38   void _notifyCurrentCamera(  Ogre::Camera *cam );
      39   void _updateRenderQueue(  Ogre::RenderQueue *queue );
      40   bool isVisible(   );
      41   const Ogre::AxisAlignedBox &getBoundingBox(  void ) const { return bounds; }
      42   Ogre::Real getBoundingRadius(  void ) const { return radius; }
      43   const Ogre::String &getMovableType(  void ) const { static Ogre::String t = "BatchedGeometry"; return t; }
          
           #if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR > 4
           //Shaggoth compatibility
      47   void visitRenderables(  Ogre::Renderable::Visitor* visitor,   bool debugRenderables ) {}
           #endif
          
      50   class SubBatch: public Ogre::Renderable
           {
           public:
      53   SubBatch(  BatchedGeometry *parent,   Ogre::SubEntity *ent );
      54   ~SubBatch(   );
          
      56   void addSubEntity(  Ogre::SubEntity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &orientation,   const Ogre::Vector3 &scale,   const Ogre::ColourValue &color = Ogre::ColourValue::White );
      57   void build(   );
      58   void clear(   );
          
      60   void setMaterial(  Ogre::MaterialPtr &mat ) { material = mat; }
      61   void setMaterialName(  const Ogre::String &mat ) { material = Ogre::MaterialManager::getSingleton(   ).getByName(  mat ); }
      62   inline Ogre::String getMaterialName(   ) const { return material->getName(   ); }
          
      64   void addSelfToRenderQueue(  Ogre::RenderQueue *queue,   Ogre::uint8 group );
      65   void getRenderOperation(  Ogre::RenderOperation& op );
      66   Ogre::Real getSquaredViewDepth(  const Ogre::Camera* cam ) const;
      67   const Ogre::LightList& getLights(  void ) const;
          
      69   Ogre::Technique *getTechnique(   ) const { return bestTechnqiue; }
      70   const Ogre::MaterialPtr &getMaterial(  void ) const { return material; }
      71   void getWorldTransforms(  Ogre::Matrix4* xform ) const { *xform = parent->_getParentNodeFullTransform(   ); }
      72   const Ogre::Quaternion& getWorldOrientation(  void ) const { return parent->sceneNode->_getDerivedOrientation(   ); }
      73   const Ogre::Vector3& getWorldPosition(  void ) const { return parent->sceneNode->_getDerivedPosition(   ); }
      74   bool castsShadows(  void ) const { return parent->getCastShadows(   ); }
          
           private:
           //This function is used to make a single clone of materials used,   since the materials
           //will be modified by the batch system (  and it wouldn't be good to modify the original materials
           //that the user may be using somewhere else ).
      80   Ogre::Material *getMaterialClone(  Ogre::Material *mat );
          
           //A structure defining the desired position/orientation/scale of a batched mesh. The
           //SubMesh is not specified since that can be determined by which MeshQueue this belongs to.
           struct QueuedMesh
           {
           Ogre::SubMesh *mesh;
           Ogre::Vector3 position;
           Ogre::Quaternion orientation;
           Ogre::Vector3 scale;
           Ogre::ColourValue color;
           };
          
      93   bool built;
          
      95   Ogre::VertexData *vertexData;
      96   Ogre::IndexData *indexData;
          
      98   Ogre::SubMesh *meshType;
      99   BatchedGeometry *parent;
     100   Ogre::MaterialPtr material;
     101   Ogre::Technique *bestTechnqiue; //This is recalculated every frame
          
           typedef std::vector<QueuedMesh>::iterator MeshQueueIterator;
           typedef std::vector<QueuedMesh> MeshQueue;
     105   MeshQueue meshQueue; //The list of meshes to be added to this batch
           };
          
          private:
     109   Ogre::String getFormatString(  Ogre::SubEntity *ent );
          
           typedef std::map<Ogre::String,   SubBatch*> SubBatchMap; //Stores a list of GeomBatch'es,   using a format string (  generated with getGeometryFormatString(   ) ) as the key value
     112   SubBatchMap subBatchMap;
          
     114   Ogre::Vector3 center;
     115   Ogre::AxisAlignedBox bounds;
     116   bool boundsUndefined;
     117   Ogre::Real radius;
          
     119   Ogre::SceneManager *sceneMgr;
     120   Ogre::SceneNode *sceneNode,   *parentSceneNode;
          
     122   Ogre::Real minDistanceSquared;
     123   bool withinFarDistance;
          
     125   bool built;
          
          public:
           typedef Ogre::MapIterator<SubBatchMap> SubBatchIterator;
     129   SubBatchIterator getSubBatchIterator(   ) const;
          };
          
          
          }
          
          #endif

./components/ogre/environment/pagedgeometry/include/DummyPage.h

       1  //
          // C++ Interface: DummyPage
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          //ImpostorPage.h
          //ImposterPage is an extension to PagedGeometry which displays entities as imposters.
          //-------------------------------------------------------------------------------------
          
          #ifndef __DummyPage_H__
          #define __DummyPage_H__
          
          #include "PagedGeometry.h"
          
          #include <OgrePrerequisites.h>
          #include <OgreTextureManager.h>
          #include <OgreRenderTexture.h>
          
          
          namespace PagedGeometry {
          
          //-------------------------------------------------------------------------------------
          /**
          \brief The DummyPage class won't render anything. This might be useful if you want to render entities using normal entity rendering up to a certain distance.
          
          To use this page type,   use:
          \code
          PagedGeometry::addDetailLevel<DummyPage>(  farRange );
          \endcode
          
          */
      49  class DummyPage: public GeometryPage
          {
          
          public:
      53   void init(  PagedGeometry *geom );
      54   ~DummyPage(   );
          
      56   void setRegion(  Ogre::Real left,   Ogre::Real top,   Ogre::Real right,   Ogre::Real bottom ) {}
      57   void addEntity(  Ogre::Entity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale,   const Ogre::ColourValue &color ) {}
      58   void build(   ) {}
      59   void removeEntities(   ) {}
          
      61   void setVisible(  bool visible ) {}
      62   void setFade(  bool enabled,   Ogre::Real visibleDist,   Ogre::Real invisibleDist ) {}
          
      64   void update(   ) {}
          
          protected:
      67   Ogre::SceneManager *sceneMgr;
      68   PagedGeometry *geom;
          };
          
          }
          
          #endif

./components/ogre/environment/pagedgeometry/include/GrassLoader.h

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          #ifndef __GrassLoader_H__
          #define __GrassLoader_H__
          
          #include "PagedGeometry.h"
          #include "PropertyMaps.h"
          
          #include "OgrePrerequisites.h"
          #include "OgreMaterial.h"
          #include "OgrePixelFormat.h"
          #include "OgreStringConverter.h"
          #include "OgreMeshManager.h"
          
          
          #include "OgreRoot.h"
          #include "OgreTimer.h"
          #include "OgreCamera.h"
          #include "OgreVector3.h"
          #include "OgreQuaternion.h"
          #include "OgreEntity.h"
          #include "OgreString.h"
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreMaterial.h"
          #include "OgreHardwareBufferManager.h"
          #include "OgreHardwareBuffer.h"
          #include "OgreMeshManager.h"
          #include "OgreMesh.h"
          #include "OgreSubMesh.h"
          #include "OgreLogManager.h"
          #include "OgreTextureManager.h"
          #include "OgreHardwarePixelBuffer.h"
          #include "OgreRenderSystem.h"
          #include "OgreRenderSystemCapabilities.h"
          #include "OgreHighLevelGpuProgram.h"
          #include "OgreHighLevelGpuProgramManager.h"
          
          namespace PagedGeometry {
          
      49  class GrassLayer;
      50  class GrassLayerBase;
          
          /** \brief A PageLoader-derived object you can use with PagedGeometry to produce realistic grass.
          
          Using a GrassLoader is simple - simply create an instance,   attach it to your PagedGeometry object
          with PagedGeometry::setPageLoader(   ),   and add your grass. Important: For best performance,   it is
          recommended that you use GrassPage (  included in GrassLoader.h ) to display geometry loaded by GrassLoader.
          This page type is designed for best performance with this grass system. BatchPage
          will work,   although performance will be reduced slightly,   and ImpostorPage will run extremely slow.
          
          To add grass,   just call addLayer(   ). addLayer(   ) returns a GrassLayer object pointer,   which you should
          use to further configure your newly added grass. Properties like size,   density,   color,   animation,   etc.
          can be controlled through the GrassLayer class.
          
          \note By default,   the GrassLoader doesn't know what shape your terrain so all grass will be placed at
          0 height. To inform GrassLoader of the shape of your terrain,   you must specify a height function
          that returns the height (  y coordinate ) of your terrain at the given x and z coordinates. See
          the TreeLoader2D::setHeightFunction(   ) documentation for more information.
          
          \warning If you attempt to use Ogre's scene queries to get the terrain height,  
          keep in mind that calculating the height of Ogre's built-in terrain this way can
          be VERY slow if not done properly,   and may cause stuttering due to long paging delays.
          */
          template <typename TGrassLayer>
      74  class GrassLoader: public PageLoader
          {
          public:
           /** \brief Creates a new GrassLoader object.
           \param geom The PagedGeometry object that this GrassLoader will be assigned to.*/
      79   inline GrassLoader(  PagedGeometry *geom );
      80   ~GrassLoader(   );
          
           /** \brief Adds a grass layer to the scene.
           \param material The initial grass texture to use (  this can be changed later ).
          
           Since all grass is potentially infinite,   it is not added like normal entities which
           have a specific position. Instead you add a grass "layer" to the scene. A grass layer
           is a "carpet" of a single type of grass that gets applied everywhere in your world.
           If you want multiple types of grass with different appearances,   you'll have to add
           a multiple grass layers for each style.
          
           Of course,   a grass layer is not completely uniform. The GrassLayer class contains
           functions to vary grass size and density levels as desired.
          
           \see GrassLayer class for more information. */
      95   TGrassLayer *addLayer(  const Ogre::String &material );
          
           /** \brief Removes and deletes a grass layer from the scene
          
           This function simply deletes a GrassLayer previously created with addLayer(   ). */
     100   void deleteLayer(  TGrassLayer *layer );
          
           /** \brief Returns a list of added grass layers.
          
           This function returns a std::list<GrassLayer*> reference,   which contains all grass
           layers which have been added to this GrassLoader. */
     106   inline std::list<TGrassLayer*> &getLayerList(   ) { return layerList; }
          
           /** \brief Sets the global wind direction for this GrassLoader.
          
           GrassLayer animation properties are used to configure the most of the animation
           behavour (  sway length,   speed,   etc. ),   but wind direction is not included in GrassLayer
           since this is really a global property. Using this function,   you can set the "global"
           wind direction which affects all animated grass associated with this PageLoader.
          
           Default value is Vector3::UNIT_X.
          
           \note This only affects grass layers which have breeze animations enabled.
           */
     119   inline void setWindDirection(  Ogre::Vector3 &dir ) { windDir = dir; }
          
           /** \brief Returns the global wind direction for this GrassLoader.
          
           \see setWindDirection(   ) for more information about the wind direction. */
     124   inline Ogre::Vector3 &getWindDirection(   ) { return windDir; }
          
           /** \brief Sets the global density factor for this GrassLoader.
          
           This function can be used to up-scale or down-scale the density of all grass
           associated with this GrassLoader. This is typically used to provide the user
           the option to reduce grass density for better performance on slower machines.
          
           Final density values are calculated by multiplying the layer density by this
           density factor. For example,   a layer with .4 density and a density factor of .5
           will result in a final density of .2 (  .5 * .4 )
          
           By default,   the density factor is set to 1.0 so the layer density is not modified.
           */
     138   inline void setDensityFactor(  float density ) { densityFactor = density; }
          
           /** \brief Returns the global density factor for this GrassLoader.
          
           \see setDensityFactor(   ) for more information about the density factor. */
     143   inline float getDensityFactor(   ) { return densityFactor; }
          
           /** \brief Sets the render queue group the grass will be rendered through
           \param queueID Enumerated value of the queue group to use
          
           Like Ogre's MovableObject::setRenderQueueGroup(   ),   this allows you to customize
           the rendering order of your scene. Since grass is transparent,   it's likely that
           you may encounter alpha-sorting issues between grass and your particle effects,  
           for example. In this case you can use this function to adjust the rendering order
           of the grass to fix the problem.
          
           If you don't call this function,   the RENDER_QUEUE_6 queue will be used.
          
           \note Once grass is loaded and being rendered,   this won't have any effect on it.
           Be sure to call this function before the scene begins rendering,   otherwise you will
           have to call PagedGeometry::reloadGeometry(   ) to force a reload in order for the changes
           to take effect. */
     160   inline void setRenderQueueGroup(  Ogre::uint8 queueID ) { renderQueue = queueID; }
          
           /** \brief Sets the height function used to calculate grass Y coordinates
           \param heightFunction A pointer to a height function
          
           Unless you want all your grass placed at 0 height,   you need to specify a height function
           so GrassLoader will be able to calculate the Y coordinate. The height function given
           to setHeightFunction(   ) should use the following prototype (  although you can name the
           function anything you want ):
          
           \code
           Real getHeightAt(  Real x,   Real z,   void *userData );
           \endcode
          
           \note If you're not using the default coordinate system (  where x = right,   z = back ),   the
           x/z parameters will actually be representing the appropriate equivalents.
          
           The userData parameter allows you to include any additional data you want when your height
           function is called,   and is completely optional (  although you can't actually omit it from the
           declaration,   you can ignore it ). Any userData value you choose to supply to setHeightFunction(   )
           will be passed on to your height function every time it is called.
          
           After you've defined a height function,   using setHeightFunction is easy:
          
           \code
           pageLoader2D->setHeightFunction(  &getHeightAt );
           //Or (  if you want to pass additional data on to your height function )...
           pageLoader2D->setHeightFunction(  &getHeightAt,   myUserData );
           \endcode
          
           In most cases,   you may not even need to use the extra "userData" parameter,   but it's there in
           the event that your height function needs extra contextual data.
           */
     193   void setHeightFunction(  Ogre::Real (  *heightFunction )(  Ogre::Real x,   Ogre::Real z,   void *userData ),   void *userData = NULL ) {
           this->heightFunction = heightFunction;
           heightFunctionUserData = userData;
           }
          
          
           /** INTERNAL FUNCTION - DO NOT USE */
     200   void loadPage(  PageInfo &page );
           /** INTERNAL FUNCTION - DO NOT USE */
     202   void unloadPage(  const PageInfo &page );
           /** INTERNAL FUNCTION - DO NOT USE */
     204   void frameUpdate(   );
          
          private:
     207   friend class GrassLayer;
          
           //Helper functions
     210   Ogre::Mesh *generateGrass_QUAD(  PageInfo &page,   TGrassLayer *layer,   float *grassPositions,   unsigned int grassCount );
     211   Ogre::Mesh *generateGrass_CROSSQUADS(  PageInfo &page,   TGrassLayer *layer,   float *grassPositions,   unsigned int grassCount );
     212   Ogre::Mesh *generateGrass_SPRITE(  PageInfo &page,   TGrassLayer *layer,   float *grassPositions,   unsigned int grassCount );
          
           //List of grass types
     215   std::list<TGrassLayer*> layerList;
          
           //Height data
           Ogre::Real (  *heightFunction )(  Ogre::Real x,   Ogre::Real z,   void *userData ); //Pointer to height function
           void *heightFunctionUserData;
          
           //Misc.
           PagedGeometry *geom;
           Ogre::uint8 renderQueue;
           float densityFactor;
          
           //Animation
           Ogre::Timer windTimer;
           Ogre::Vector3 windDir;
           unsigned long lastTime;
          
           static unsigned long GUID;
           static inline Ogre::String getUniqueID(   )
           {
           return "GrassLDR" + Ogre::StringConverter::toString(  ++GUID );
           }
          };
          
          
          
          
          
          /** \brief A technique used to render grass. Passed to GrassLayer::setRenderTechnique(   ). */
          enum GrassTechnique
          {
           /// Grass constructed of randomly placed and rotated quads
           GRASSTECH_QUAD,  
           /// Grass constructed of two quads forming a "X" cross shape
           GRASSTECH_CROSSQUADS,  
           /// Grass constructed of camera-facing billboard quads
           GRASSTECH_SPRITE
          };
          
          /** \brief A technique used to fade grass into the distance. Passed to GrassLayer::setFadeTechnique(   ). */
          enum FadeTechnique
          {
           /// Grass that fades into the distance with transparency. Fairly effective in most cases.
           FADETECH_ALPHA,  
           /// Grass that fades in by "growing" up out of the ground. Very effective when grass fades in against the sky,   or with alpha-rejected grass.
           FADETECH_GROW,  
           /// Grass that fades in by slowly becoming opaque while it "grows" up out of the ground. Effective with alpha grass fading in against the sky.
           FADETECH_ALPHAGROW
          };
          
     264  class GrassLayerBase
          {
          public:
           /** \brief Sets the material that is applied to all grass billboards/quads */
     268   void setMaterialName(  const Ogre::String &matName );
          
           /** \brief Sets the minimum size that grass quads/billboards will be */
     271   void setMinimumSize(  float width,   float height );
          
           /** \brief Sets the maximum size that grass quads/billboards will be */
     274   void setMaximumSize(  float width,   float height );
          
           /** \brief Sets the technique used to render this grass layer
           \param style The GrassTechnique style used to display grass.
           \param blendBase Whether or not grass base blending is enabled.
          
           The "style" setting allows you to choose from various construction methods,   such as
           sprite-style grass quads,   plain 3D quads,   etc. See the GrassTechnique documentation
           for more information about this option. GRASSTECH_QUAD is used by default.
          
           Setting "blendBase" to true will enable grass base blending,   a technique which helps
           reduce the unnatural flat appearance of grass quads near the camera. Since the flatness
           is most obvious where the grass intersects the terrain,   this technique attempts to
           smoothly blend the base of near-by grass into the terrain.
          
           \note Base blending does not work well with alpha-rejected textures.
           */
     291   void setRenderTechnique(  GrassTechnique style,   bool blendBase = false );
          
           /** \brief Sets the technique used when fading out distant grass
           \param style The FadeTechnique style used to fade grass.
          
           This "style" setting allows you to choose from various fade techniques. Depending on
           your scene,   certain techniques may look better than others. The most compatible method
           is FADETECH_ALPHA (  used by default ),   although better results can usually be achieved
           with other methods. See the FadeTechnique documentation for more information.
           */
     301   void setFadeTechnique(  FadeTechnique style );
          
           /** \brief Enables/disables animation on this layer
          
           Always use this function to disable animation,   rather than setting SwayLength or SwaySpeed
           to 0. This function will use a different vertex shader which means improved performance
           when animation is disabled.
           */
     309   void setAnimationEnabled(  bool enabled );
          
           /** \brief Sets how far grass should sway back and forth
          
           \note Since this is measured in world units,   you may have to adjust this depending on
           the size of your grass as set by setMinimumSize(   ) and setMaximumSize(   ).*/
     315   void setSwayLength(  float mag ) { animMag = mag; }
          
           /** \brief Sets the sway speed of the grass (  measured in "sways-per-second" ) */
     318   void setSwaySpeed(  float speed ) { animSpeed = speed; }
          
           /** \brief Sets the smooth distribution (  positional phase shift ) of the grass swaying animation
          
           If you set this to 0,   grass animation will look very unnatural,   since all the grass sway motions
           will be in perfect synchronization (  everything sways to the right,   then everything sways to the
           left,   etc. ) This sets the "positional phase shift",   which gives the grass a "wave" like phase
           distribution. The higher this value is,   the more "chaotic" the wind will appear. Lower values give
           a smoother breeze appearance,   but values too high can look unrealistic.
           */
     328   void setSwayDistribution(  float freq ) { animFreq = freq; }
          
           /** \brief Sets the boundaries of the density/color maps
           \param bounds The map boundary
          
           By default,   the GrassLayer has no knowledge of your terrain/world boundaries,   so you must
           use this function to specify a rectangular/square area of your world,   otherwise density/color maps
           won't work properly. The boundary given to this function defines the area where density/color
           maps take effect. Normally this is set to your terrain's bounds so the density/color map is aligned
           to your heightmap,   but you could apply it anywhere you want.
          
           \note The grass system is infinite,   so there's no need to worry about using too expansive
           boundaries. This setting simply configures the behavior of density and color maps. */
     341   virtual void setMapBounds(  const Ogre::TRect<Ogre::Real> &bounds )
           {
           mapBounds = bounds;
           }
          
          
           /**
           * Calculates the max number of grass instances for this layer.
           * @param densityFactor The density factor set on the grass loader
           * @param volume The volume,   in world units,   to fill
           * @return The max number of grass instances to create.
           */
     353   virtual unsigned int calculateMaxGrassCount(  float densityFactor,   float volume ) = 0;
          
          protected:
          
           //Used by GrassLoader::loadPage(   ) - populates an array with grass.
           //Returns the final number of grasses,   which will always be <= grassCount
     359   virtual unsigned int _populateGrassList(  PageInfo page,   float *posBuff,   unsigned int grassCount ) = 0;
          
           //Updates the vertex shader used by this layer based on the animate enable status
     362   void _updateShaders(   );
          
           //Grass material/shape properties
     365   Ogre::MaterialPtr material;
           float minWidth,   maxWidth;
           float minHeight,   maxHeight;
          
           FadeTechnique fadeTechnique;
           GrassTechnique renderTechnique;
          
           //Property maps
     373   Ogre::TRect<Ogre::Real> mapBounds;
          
           //Grass shader properties
     376   bool animate,   blend,   shaderNeedsUpdate;
           float animMag,   animSpeed,   animFreq;
          
           //Current frame of animation for this layer
           float waveCount;
          
     382   PagedGeometry *geom;
          
          };
          
          
          /** \brief A data structure giving you full control over grass properties.
          
          Grass is added to the scene through GrassLoader::addLayer(   ). Through this class you
          can configure your grass layer any way you like - size,   density,   render technique,  
          animation,   etc. Simply call the appropriate "set" member function to set the desired property.
          
          Remember that you cannot create or delete layers directly. Layers can only be created
          with GrassLoader::addLayer(   ),   and may not be deleted manually (  they will be deleted when
          the associated GrassLoader is deleted ).
          */
     397  class GrassLayer : public GrassLayerBase
          {
          public:
          
           /** \brief Sets the maximum density (  measured in grass quads/billboards per square unit ) of grass */
     402   void setDensity(  float density ) { this->density = density; }
          
           /** \brief Sets a minimum / maximum height where grass may appear
           \param minHeight Sets the minimum height grass may have. 0 = no minimum
           \param maxHeight Sets the maximum height grass may have. 0 = no maximum
          
           By default grass appears at all altitudes. You can use this function to restrict grass to a
           certain height range. For example,   if sea level is at 100 units Y,   you might restrict this
           layer to display only above 100 units (  so your grass doesn't grow under water ).
          
           It's possible to use density maps (  see setDensityMap(   ) ) to achieve similar results,   but if
           your density map is extremely low resolution,   this function may be the only practical option
           to prevent grass from growing under water (  when used in combination with your density map ).
          
           Setting minHeight to 0 means grass has no minimum height - it can grow as low as necessary.
           Similarly,   setting maxHeight to 0 means grass has no maximum height - it can grow as high
           as necessary. */
     419   void setHeightRange(  float minHeight,   float maxHeight = 0 ) { minY = minHeight; maxY = maxHeight; }
          
           /** \brief Sets the density map used for this grass layer
           \param mapFile The density map image
           \param channel The color channel(  s ) to from the image to interpret as density
          
           A density map is simply a greyscale image,   similar to a heightmap,   that specifies the grass
           density on your map. Full pixel intensity indicates that grass should be fully dense at that
           point (  the maximum density is specified by GrassLayer::setDensity(   ) ),   while no pixel intensity
           indicates that no grass should appear at that location.
          
           The channel parameter allows you to extract the density information from the image's
           red,   green,   blue,   alpha,   or color values. For example,   you may store density values in the
           alpha channel,   in which case you would use CHANNEL_ALPHA. By default,   CHANNEL_COLOR is used,  
           which means the image color is converted to greyscale internally and used as a density map.
          
           Note that GrassLayer by default has no idea of your terrain/world boundaries,   so you
           must specify a rectangular/square area of your world that is affected by density/color maps.
           To do this,   use the setMapBounds(   ) function. Normally this is set to your terrain's bounds
           so the density/color map is aligned to your heightmap,   but you could apply it anywhere you
           want. */
     440   void setDensityMap(  const Ogre::String &mapFile,   MapChannel channel = CHANNEL_COLOR );
          
           /** \brief Sets the density map used for this grass layer
          
           Overloaded to accept a Texture object. See the original setDensityMap(   ) documentation above
           for more detailed information on density maps.
          
           \note The texture data you provide is copied into the GrassLayer's own memory space,   so you
           can delete the texture after calling this function without risk of crashing. */
     449   void setDensityMap(  Ogre::Texture *map,   MapChannel channel = CHANNEL_COLOR );
          
           /** \brief Sets the filtering mode used for density maps
          
           This function can be used to set the filtering mode used for your density map when generating
           grass. By default,   bilinear filtering is used (  MAPFILTER_BILINEAR ). If you disable filtering
           by using MAPFILTER_NONE,   the resulting layout of your grass may look square and blocky,  
           depending on the resolution of your density map.
          
           MAPFILTER_NONE is slightly faster than MAPFILTER_BILINEAR,   so use it if you don't notice any
           considerable blockyness.
           */
     461   void setDensityMapFilter(  MapFilter filter );
          
           /** \brief Sets the color map used for this grass layer
           \param mapFile The color map image
           \param channel The color channel(  s ) to from the image to use
          
           A color map is simply a texture that allows you to vary the color and shading of grass
           across your world for a more realistic look. For example,   adding a dark spot to the center
           of your color map will make grass near the center of your terrain look darker,   as long as
           you have the color map aligned to your terrain (  see setMapBounds(   ) ).
          
           The channel parameter allows you to extract the color information from the image's
           red,   green,   blue,   alpha,   or color values. For example,   you may store the desired shade of your
           grass in the red channel of an image,   in which case you would use CHANNEL_RED (  when you choose
           a single channel,   it is converted to a greyscale color ). By default,   CHANNEL_COLOR is used,  
           which uses the full color information available in the image.
          
           Remember that GrassLayer by default has no idea of your terrain/world boundaries,   so you
           must specify a rectangular/square area of your world that is affected by density/color maps.
           To do this,   use the setMapBounds(   ) function. Normally this is set to your terrain's bounds
           so the density/color map is aligned to your heightmap,   but you could apply it anywhere you
           want. */
     483   void setColorMap(  const Ogre::String &mapFile,   MapChannel channel = CHANNEL_COLOR );
          
           /** \brief Sets the color map used for this grass layer
          
           Overloaded to accept a Texture object. See the original setColorMap(   ) documentation above
           for more detailed information on color maps.
          
           \note The texture data you provide is copied into RAM,   so you can delete the texture after
           calling this function without risk of crashing. */
     492   void setColorMap(  Ogre::Texture *map,   MapChannel channel = CHANNEL_COLOR );
          
           /** \brief Sets the filtering mode used for color maps
          
           This function can be used to set the filtering mode used for your color map when generating
           grass. By default,   bilinear filtering is used (  MAPFILTER_BILINEAR ). If you disable filtering
           by using MAPFILTER_NONE,   the resulting grass coloration may appear slightly pixelated,  
           depending on the resolution of your color map.
          
           MAPFILTER_NONE is slightly faster than MAPFILTER_BILINEAR,   so use it if you don't notice any
           considerable pixelation.
           */
     504   void setColorMapFilter(  MapFilter filter );
          
           /** \brief Gets a pointer to the density map being used
          
           You can use this function to access the internal density map object used by the GrassLoader.
           Through this object you can directly manipulate the pixels of the density map,   among other
           things.
          
           Note that although you can edit the density map in real-time through this class,   the changes
           won't be uploaded to your video card until you call PagedGeometry::reloadGeometry(   ). If you
           don't,   the grass you see will remain unchanged. */
     515   DensityMap *getDensityMap(   ) { return densityMap; }
          
           /** \brief Gets a pointer to the color map being used
          
           You can use this function to access the internal color map object used by the GrassLoader.
           Through this object you can directly manipulate the pixels of the color map,   among other
           things.
          
           Note that although you can edit the color map in real-time through this class,   the changes
           won't be uploaded to your video card until you call PagedGeometry::reloadGeometry(   ). If you
           don't,   the grass you see will remain unchanged. */
     526   ColorMap *getColorMap(   ) { return colorMap; }
          
          
           /** \brief Sets the boundaries of the density/color maps
           \param bounds The map boundary
          
           By default,   the GrassLayer has no knowledge of your terrain/world boundaries,   so you must
           use this function to specify a rectangular/square area of your world,   otherwise density/color maps
           won't work properly. The boundary given to this function defines the area where density/color
           maps take effect. Normally this is set to your terrain's bounds so the density/color map is aligned
           to your heightmap,   but you could apply it anywhere you want.
          
           \note The grass system is infinite,   so there's no need to worry about using too expansive
           boundaries. This setting simply configures the behavior of density and color maps. */
     540   virtual void setMapBounds(  const Ogre::TRect<Ogre::Real> &bounds )
           {
           GrassLayerBase::setMapBounds(  bounds );
           if (  densityMap )
           densityMap->setMapBounds(  mapBounds );
           if (  colorMap )
           colorMap->setMapBounds(  mapBounds );
           }
          
           /**
           * Calculates the max number of grass instances for this layer.
           * @param densityFactor The density factor set on the grass loader
           * @param volume The volume,   in world units,   to fill
           * @return The max number of grass instances to create.
           */
     555   virtual unsigned int calculateMaxGrassCount(  float densityFactor,   float volume );
          
          private:
     558   friend class GrassLoader<GrassLayer>;
          
           /** \brief Do not create a GrassLayer directly - use GrassLoader->addLayer(   ) */
     561   GrassLayer(  PagedGeometry *geom,   GrassLoader<GrassLayer> *ldr );
          
           /** \brief Do not delete a GrassLayer yourself - the GrassLoader will do this automatically when it's deleted */
     564   ~GrassLayer(   );
          
           //Used by GrassLoader::loadPage(   ) - populates an array with grass.
           //Returns the final number of grasses,   which will always be <= grassCount
     568   virtual unsigned int _populateGrassList(  PageInfo page,   float *posBuff,   unsigned int grassCount );
          
           //Used by GrassLoader::loadPage(   ) - populates an array with a uniform distribution of grass
           //Returns the final number of grasses,   which will always be <= grassCount
     572   unsigned int _populateGrassList_Uniform(  PageInfo page,   float *posBuff,   unsigned int grassCount );
          
           //Used by GrassLoader::loadPage(   ) - populates an array of grass positions based on the density map
           //Returns the final number of grasses,   which will always be <= grassCount
     576   unsigned int _populateGrassList_UnfilteredDM(  PageInfo page,   float *posBuff,   unsigned int grassCount );
          
           //Variation of _populateGrassList(   ),   using bilinear filtering on the density map lookups
           //Returns the final number of grasses,   which will always be <= grassCount
     580   unsigned int _populateGrassList_BilinearDM(  PageInfo page,   float *posBuff,   unsigned int grassCount );
          
          
     583   GrassLoader<GrassLayer> *parent;
          
           //Grass material/shape properties
           float density;
          
           float minY,   maxY;
          
          
     591   DensityMap *densityMap;
           MapFilter densityMapFilter;
          
     594   ColorMap *colorMap;
           MapFilter colorMapFilter;
          
          };
          
          
          /** \brief A custom page type designed specifically for use with GrassLoader.
          
          You can use this in your own project if you want,   but remember that no optimizations
          are performed. The given entity is simply cloned and attached to a new scene node as
          quickly and simply as possible (  this means there's no batching overhead as in BatchPage,  
          but it also means potentially poor performance if you don't know what you're doing ).
          */
     607  class GrassPage: public GeometryPage
          {
          public:
     610   void init(  PagedGeometry *geom );
     611   ~GrassPage(   );
          
     613   void addEntity(  Ogre::Entity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale,   const Ogre::ColourValue &color );
     614   void removeEntities(   );
     615   void setFade(  bool enabled,   Ogre::Real visibleDist,   Ogre::Real invisibleDist ) {}
     616   void setVisible(  bool visible );
          
          private:
     619   Ogre::SceneManager *sceneMgr;
     620   Ogre::SceneNode *rootNode;
          
     622   std::list<Ogre::SceneNode*> nodeList;
          
           static unsigned long GUID;
     625   static inline Ogre::String getUniqueID(   )
           {
           return "GrassPage" + Ogre::StringConverter::toString(  ++GUID );
           }
          };
          
          
          // class IGrassPopulator
          // {
          // public:
          // //Used by GrassLoader::loadPage(   ) - populates an array with a uniform distribution of grass
          // //Returns the final number of grasses,   which will always be <= grassCount
          // virtual unsigned int populateGrassList(  PageInfo page,   float *posBuff,   unsigned int grassCount ) = 0;
          // };
          //
          // class GrassPopulatorUniform : public IGrassPopulator
          // {
          // public:
          // //Used by GrassLoader::loadPage(   ) - populates an array with a uniform distribution of grass
          // //Returns the final number of grasses,   which will always be <= grassCount
          // virtual unsigned int populateGrassList(  PageInfo page,   float *posBuff,   unsigned int grassCount );
          // };
          //
          // class GrassPopulatorUnfilteredDM : public IGrassPopulator
          // {
          // public:
          // //Used by GrassLoader::loadPage(   ) - populates an array with a uniform distribution of grass
          // //Returns the final number of grasses,   which will always be <= grassCount
          // virtual unsigned int populateGrassList(  PageInfo page,   float *posBuff,   unsigned int grassCount );
          // };
          //
          // class GrassPopulatorBilinearDM : public IGrassPopulator
          // {
          // public:
          // //Used by GrassLoader::loadPage(   ) - populates an array with a uniform distribution of grass
          // //Returns the final number of grasses,   which will always be <= grassCount
          // virtual unsigned int populateGrassList(  PageInfo page,   float *posBuff,   unsigned int grassCount );
          // };
          
          template <class TGrassLayer>
     665  GrassLoader<TGrassLayer>::GrassLoader(  PagedGeometry *geom )
          {
           GrassLoader<TGrassLayer>::geom = geom;
          
           heightFunction = NULL;
           heightFunctionUserData = NULL;
          
           windDir = Ogre::Vector3::UNIT_X;
           densityFactor = 1.0f;
           renderQueue = Ogre::RENDER_QUEUE_6;
          
           windTimer.reset(   );
           lastTime = 0;
          }
          
          template <class TGrassLayer>
     681  GrassLoader<TGrassLayer>::~GrassLoader(   )
          {
           typename std::list<TGrassLayer*>::iterator it;
           for (  it = layerList.begin(   ); it != layerList.end(   ); ++it ){
           delete *it;
           }
           layerList.clear(   );
          }
          
          template <class TGrassLayer>
     691  TGrassLayer *GrassLoader<TGrassLayer>::addLayer(  const Ogre::String &material )
          {
           TGrassLayer *layer = new TGrassLayer(  geom,   this );
           layer->setMaterialName(  material );
           layerList.push_back(  layer );
          
           return layer;
          }
          
          template <class TGrassLayer>
     701  void GrassLoader<TGrassLayer>::deleteLayer(  TGrassLayer *layer )
          {
           layerList.remove(  layer );
           delete layer;
          }
          
          template <class TGrassLayer>
     708  void GrassLoader<TGrassLayer>::frameUpdate(   )
          {
           unsigned long currentTime = windTimer.getMilliseconds(   );
           unsigned long ellapsedTime = currentTime - lastTime;
           lastTime = currentTime;
          
           float ellapsed = ellapsedTime / 1000.0f;
          
           //Update the vertex shader parameters
           typename std::list<TGrassLayer*>::iterator it;
           for (  it = layerList.begin(   ); it != layerList.end(   ); ++it ){
           TGrassLayer *layer = *it;
          
           layer->_updateShaders(   );
          
           Ogre::GpuProgramParametersSharedPtr params = layer->material->getTechnique(  0 )->getPass(  0 )->getVertexProgramParameters(   );
           if (  layer->animate ){
           //Increment animation frame
           layer->waveCount += ellapsed * (  layer->animSpeed * Ogre::Math::PI );
           if (  layer->waveCount > Ogre::Math::PI*2 ) layer->waveCount -= Ogre::Math::PI*2;
          
           //Set vertex shader parameters
           params->setNamedConstant(  "time",   layer->waveCount );
           params->setNamedConstant(  "frequency",   layer->animFreq );
          
           Ogre::Vector3 direction = windDir * layer->animMag;
           params->setNamedConstant(  "direction",   Ogre::Vector4(  direction.x,   direction.y,   direction.z,   0 ) );
          
           }
           }
          }
          
          template <class TGrassLayer>
     741  void GrassLoader<TGrassLayer>::loadPage(  PageInfo &page )
          {
           //Seed random number generator based on page indexes
           Ogre::uint16 xSeed = static_cast<Ogre::uint16>(  page.xIndex % 0xFFFF );
           Ogre::uint16 zSeed = static_cast<Ogre::uint16>(  page.zIndex % 0xFFFF );
           Ogre::uint32 seed = (  xSeed << 16 ) | zSeed;
           srand(  seed );
          
           typename std::list<TGrassLayer*>::iterator it;
           for (  it = layerList.begin(   ); it != layerList.end(   ); ++it ){
           TGrassLayer *layer = *it;
          
           //Calculate how much grass needs to be added
           float volume = page.bounds.width(   ) * page.bounds.height(   );
           unsigned int grassCount = layer->calculateMaxGrassCount(  densityFactor,   volume );
          
           //The vertex buffer can't be allocated until the exact number of polygons is known,  
           //so the locations of all grasses in this page must be precalculated.
          
           //Precompute grass locations into an array of floats. A plain array is used for speed;
           //there's no need to use a dynamic sized array since a maximum size is known.
           float *position = new float[grassCount*2];
           grassCount = layer->_populateGrassList(  page,   position,   grassCount );
          
           //Don't build a mesh unless it contains something
           if (  grassCount != 0 ){
           Ogre::Mesh *mesh = NULL;
           switch (  layer->renderTechnique ){
           case GRASSTECH_QUAD:
           mesh = generateGrass_QUAD(  page,   layer,   position,   grassCount );
           break;
           case GRASSTECH_CROSSQUADS:
           mesh = generateGrass_CROSSQUADS(  page,   layer,   position,   grassCount );
           break;
           case GRASSTECH_SPRITE:
           mesh = generateGrass_SPRITE(  page,   layer,   position,   grassCount );
           break;
           }
           assert(  mesh );
          
           //Add the mesh to PagedGeometry
           Ogre::Entity *entity = geom->getCamera(   )->getSceneManager(   )->createEntity(  getUniqueID(   ),   mesh->getName(   ) );
           entity->setRenderQueueGroup(  renderQueue );
           entity->setCastShadows(  false );
           addEntity(  entity,   page.centerPoint,   Ogre::Quaternion::IDENTITY,   Ogre::Vector3::UNIT_SCALE );
           geom->getSceneManager(   )->destroyEntity(  entity );
          
           //Store the mesh pointer
           page.userData = mesh;
           } else {
           //No mesh
           page.userData = NULL;
           }
          
           //Delete the position list
           delete[] position;
           }
          }
          
          template <class TGrassLayer>
     801  void GrassLoader<TGrassLayer>::unloadPage(  const PageInfo &page )
          {
           //Unload mesh
           Ogre::Mesh *mesh = (  Ogre::Mesh* )page.userData;
           if (  mesh )
           Ogre::MeshManager::getSingleton(   ).remove(  mesh->getName(   ) );
          }
          template <class TGrassLayer>
     809  Ogre::Mesh *GrassLoader<TGrassLayer>::generateGrass_QUAD(  PageInfo &page,   TGrassLayer *layer,   float *grassPositions,   unsigned int grassCount )
          {
           //Calculate the number of quads to be added
           unsigned int quadCount;
           quadCount = grassCount;
          
           //Create manual mesh to store grass quads
           Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton(   ).createManual(  getUniqueID(   ),   Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
           Ogre::SubMesh *subMesh = mesh->createSubMesh(   );
           subMesh->useSharedVertices = false;
          
           //Setup vertex format information
           subMesh->vertexData = new Ogre::VertexData;
           subMesh->vertexData->vertexStart = 0;
           subMesh->vertexData->vertexCount = 4 * quadCount;
          
           Ogre::VertexDeclaration* dcl = subMesh->vertexData->vertexDeclaration;
           size_t offset = 0;
           dcl->addElement(  0,   offset,   Ogre::VET_FLOAT3,   Ogre::VES_POSITION );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT3 );
           dcl->addElement(  0,   offset,   Ogre::VET_COLOUR,   Ogre::VES_DIFFUSE );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_COLOUR );
           dcl->addElement(  0,   offset,   Ogre::VET_FLOAT2,   Ogre::VES_TEXTURE_COORDINATES );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT2 );
          
           //Populate a new vertex buffer with grass
           Ogre::HardwareVertexBufferSharedPtr vbuf = Ogre::HardwareBufferManager::getSingleton(   )
           .createVertexBuffer(  offset,   subMesh->vertexData->vertexCount,   Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
           float* pReal = static_cast<float*>(  vbuf->lock(  Ogre::HardwareBuffer::HBL_DISCARD ) );
          
           //Calculate size variance
           float rndWidth = layer->maxWidth - layer->minWidth;
           float rndHeight = layer->maxHeight - layer->minHeight;
          
           float minY = Ogre::Math::POS_INFINITY,   maxY = Ogre::Math::NEG_INFINITY;
           float *posPtr = grassPositions; //Position array "iterator"
           for (  Ogre::uint16 i = 0; i < grassCount; ++i )
           {
           //Get the x and z positions from the position array
           float x = *posPtr++;
           float z = *posPtr++;
          
           //Get the color at the grass position
           Ogre::uint32 color;
           if (  layer->colorMap )
           color = layer->colorMap->getColorAt(  x,   z );
           else
           color = 0xFFFFFFFF;
          
           //Calculate size
           float rnd = Ogre::Math::UnitRandom(   ); //The same rnd value is used for width and height to maintain aspect ratio
           float halfScaleX = (  layer->minWidth + rndWidth * rnd ) * 0.5f;
           float scaleY = (  layer->minHeight + rndHeight * rnd );
          
           //Calculate rotation
           float angle = Ogre::Math::RangeRandom(  0,   Ogre::Math::TWO_PI );
           float xTrans = Ogre::Math::Cos(  angle ) * halfScaleX;
           float zTrans = Ogre::Math::Sin(  angle ) * halfScaleX;
          
           //Calculate heights and edge positions
           float x1 = x - xTrans,   z1 = z - zTrans;
           float x2 = x + xTrans,   z2 = z + zTrans;
          
           float y1,   y2;
           if (  heightFunction ){
           y1 = heightFunction(  x1,   z1,   heightFunctionUserData );
           y2 = heightFunction(  x2,   z2,   heightFunctionUserData );
           } else {
           y1 = 0;
           y2 = 0;
           }
          
           //Add vertices
           *pReal++ = (  x1 - page.centerPoint.x ); *pReal++ = (  y1 + scaleY ); *pReal++ = (  z1 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 0; *pReal++ = 0; //uv
          
           *pReal++ = (  x2 - page.centerPoint.x ); *pReal++ = (  y2 + scaleY ); *pReal++ = (  z2 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 1; *pReal++ = 0; //uv
          
           *pReal++ = (  x1 - page.centerPoint.x ); *pReal++ = (  y1 ); *pReal++ = (  z1 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 0; *pReal++ = 1; //uv
          
           *pReal++ = (  x2 - page.centerPoint.x ); *pReal++ = (  y2 ); *pReal++ = (  z2 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 1; *pReal++ = 1; //uv
          
           //Update bounds
           if (  y1 < minY ) minY = y1;
           if (  y2 < minY ) minY = y2;
           if (  y1 + scaleY > maxY ) maxY = y1 + scaleY;
           if (  y2 + scaleY > maxY ) maxY = y2 + scaleY;
           }
          
           vbuf->unlock(   );
           subMesh->vertexData->vertexBufferBinding->setBinding(  0,   vbuf );
          
           //Populate index buffer
           subMesh->indexData->indexStart = 0;
           subMesh->indexData->indexCount = 6 * quadCount;
           subMesh->indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton(   )
           .createIndexBuffer(  Ogre::HardwareIndexBuffer::IT_16BIT,   subMesh->indexData->indexCount,   Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
           Ogre::uint16* pI = static_cast<Ogre::uint16*>(  subMesh->indexData->indexBuffer->lock(  Ogre::HardwareBuffer::HBL_DISCARD ) );
           for (  Ogre::uint16 i = 0; i < quadCount; ++i )
           {
           Ogre::uint16 offset = i * 4;
          
           *pI++ = 0 + offset;
           *pI++ = 2 + offset;
           *pI++ = 1 + offset;
          
           *pI++ = 1 + offset;
           *pI++ = 2 + offset;
           *pI++ = 3 + offset;
           }
          
           subMesh->indexData->indexBuffer->unlock(   );
          
           //Finish up mesh
           Ogre::AxisAlignedBox bounds(  page.bounds.left - page.centerPoint.x,   minY,   page.bounds.top - page.centerPoint.z,  
           page.bounds.right - page.centerPoint.x,   maxY,   page.bounds.bottom - page.centerPoint.z );
           mesh->_setBounds(  bounds );
           Ogre::Vector3 temp = bounds.getMaximum(   ) - bounds.getMinimum(   );
           mesh->_setBoundingSphereRadius(  temp.length(   ) * 0.5f );
          
           Ogre::LogManager::getSingleton(   ).setLogDetail(  static_cast<Ogre::LoggingLevel>(  0 ) );
           mesh->load(   );
           Ogre::LogManager::getSingleton(   ).setLogDetail(  Ogre::LL_NORMAL );
          
           //Apply grass material to mesh
           subMesh->setMaterialName(  layer->material->getName(   ) );
          
           //Return the mesh
           return mesh.getPointer(   );
          }
          
          template <class TGrassLayer>
     948  Ogre::Mesh *GrassLoader<TGrassLayer>::generateGrass_CROSSQUADS(  PageInfo &page,   TGrassLayer *layer,   float *grassPositions,   unsigned int grassCount )
          {
           //Calculate the number of quads to be added
           unsigned int quadCount;
           quadCount = grassCount * 2;
          
           //Create manual mesh to store grass quads
           Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton(   ).createManual(  getUniqueID(   ),   Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
           Ogre::SubMesh *subMesh = mesh->createSubMesh(   );
           subMesh->useSharedVertices = false;
          
           //Setup vertex format information
           subMesh->vertexData = new Ogre::VertexData;
           subMesh->vertexData->vertexStart = 0;
           subMesh->vertexData->vertexCount = 4 * quadCount;
          
           Ogre::VertexDeclaration* dcl = subMesh->vertexData->vertexDeclaration;
           size_t offset = 0;
           dcl->addElement(  0,   offset,   Ogre::VET_FLOAT3,   Ogre::VES_POSITION );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT3 );
           dcl->addElement(  0,   offset,   Ogre::VET_COLOUR,   Ogre::VES_DIFFUSE );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_COLOUR );
           dcl->addElement(  0,   offset,   Ogre::VET_FLOAT2,   Ogre::VES_TEXTURE_COORDINATES );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT2 );
          
           //Populate a new vertex buffer with grass
           Ogre::HardwareVertexBufferSharedPtr vbuf = Ogre::HardwareBufferManager::getSingleton(   )
           .createVertexBuffer(  offset,   subMesh->vertexData->vertexCount,   Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
           float* pReal = static_cast<float*>(  vbuf->lock(  Ogre::HardwareBuffer::HBL_DISCARD ) );
          
           //Calculate size variance
           float rndWidth = layer->maxWidth - layer->minWidth;
           float rndHeight = layer->maxHeight - layer->minHeight;
          
           float minY = Ogre::Math::POS_INFINITY,   maxY = Ogre::Math::NEG_INFINITY;
           float *posPtr = grassPositions; //Position array "iterator"
           for (  Ogre::uint16 i = 0; i < grassCount; ++i )
           {
           //Get the x and z positions from the position array
           float x = *posPtr++;
           float z = *posPtr++;
          
           //Get the color at the grass position
           Ogre::uint32 color;
           if (  layer->colorMap )
           color = layer->colorMap->getColorAt(  x,   z );
           else
           color = 0xFFFFFFFF;
          
           //Calculate size
           float rnd = Ogre::Math::UnitRandom(   ); //The same rnd value is used for width and height to maintain aspect ratio
           float halfScaleX = (  layer->minWidth + rndWidth * rnd ) * 0.5f;
           float scaleY = (  layer->minHeight + rndHeight * rnd );
          
           //Calculate rotation
           float angle = Ogre::Math::RangeRandom(  0,   Ogre::Math::TWO_PI );
           float xTrans = Ogre::Math::Cos(  angle ) * halfScaleX;
           float zTrans = Ogre::Math::Sin(  angle ) * halfScaleX;
          
           //Calculate heights and edge positions
           float x1 = x - xTrans,   z1 = z - zTrans;
           float x2 = x + xTrans,   z2 = z + zTrans;
          
           float y1,   y2;
           if (  heightFunction ){
           y1 = heightFunction(  x1,   z1,   heightFunctionUserData );
           y2 = heightFunction(  x2,   z2,   heightFunctionUserData );
           } else {
           y1 = 0;
           y2 = 0;
           }
          
           //Add vertices
           *pReal++ = (  x1 - page.centerPoint.x ); *pReal++ = (  y1 + scaleY ); *pReal++ = (  z1 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 0; *pReal++ = 0; //uv
          
           *pReal++ = (  x2 - page.centerPoint.x ); *pReal++ = (  y2 + scaleY ); *pReal++ = (  z2 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 1; *pReal++ = 0; //uv
          
           *pReal++ = (  x1 - page.centerPoint.x ); *pReal++ = (  y1 ); *pReal++ = (  z1 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 0; *pReal++ = 1; //uv
          
           *pReal++ = (  x2 - page.centerPoint.x ); *pReal++ = (  y2 ); *pReal++ = (  z2 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 1; *pReal++ = 1; //uv
          
           //Update bounds
           if (  y1 < minY ) minY = y1;
           if (  y2 < minY ) minY = y2;
           if (  y1 + scaleY > maxY ) maxY = y1 + scaleY;
           if (  y2 + scaleY > maxY ) maxY = y2 + scaleY;
          
           //Calculate heights and edge positions
           float x3 = x + zTrans,   z3 = z - xTrans;
           float x4 = x - zTrans,   z4 = z + xTrans;
          
           float y3,   y4;
           if (  heightFunction ){
           y3 = heightFunction(  x3,   z3,   heightFunctionUserData );
           y4 = heightFunction(  x4,   z4,   heightFunctionUserData );
           } else {
           y3 = 0;
           y4 = 0;
           }
          
           //Add vertices
           *pReal++ = (  x3 - page.centerPoint.x ); *pReal++ = (  y3 + scaleY ); *pReal++ = (  z3 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 0; *pReal++ = 0; //uv
          
           *pReal++ = (  x4 - page.centerPoint.x ); *pReal++ = (  y4 + scaleY ); *pReal++ = (  z4 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 1; *pReal++ = 0; //uv
          
           *pReal++ = (  x3 - page.centerPoint.x ); *pReal++ = (  y3 ); *pReal++ = (  z3 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 0; *pReal++ = 1; //uv
          
           *pReal++ = (  x4 - page.centerPoint.x ); *pReal++ = (  y4 ); *pReal++ = (  z4 - page.centerPoint.z ); //pos
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = 1; *pReal++ = 1; //uv
          
           //Update bounds
           if (  y3 < minY ) minY = y1;
           if (  y4 < minY ) minY = y2;
           if (  y3 + scaleY > maxY ) maxY = y3 + scaleY;
           if (  y4 + scaleY > maxY ) maxY = y4 + scaleY;
           }
          
           vbuf->unlock(   );
           subMesh->vertexData->vertexBufferBinding->setBinding(  0,   vbuf );
          
           //Populate index buffer
           subMesh->indexData->indexStart = 0;
           subMesh->indexData->indexCount = 6 * quadCount;
           subMesh->indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton(   )
           .createIndexBuffer(  Ogre::HardwareIndexBuffer::IT_16BIT,   subMesh->indexData->indexCount,   Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
           Ogre::uint16* pI = static_cast<Ogre::uint16*>(  subMesh->indexData->indexBuffer->lock(  Ogre::HardwareBuffer::HBL_DISCARD ) );
           for (  Ogre::uint16 i = 0; i < quadCount; ++i )
           {
           Ogre::uint16 offset = i * 4;
          
           *pI++ = 0 + offset;
           *pI++ = 2 + offset;
           *pI++ = 1 + offset;
          
           *pI++ = 1 + offset;
           *pI++ = 2 + offset;
           *pI++ = 3 + offset;
           }
          
           subMesh->indexData->indexBuffer->unlock(   );
          
           //Finish up mesh
           Ogre::AxisAlignedBox bounds(  page.bounds.left - page.centerPoint.x,   minY,   page.bounds.top - page.centerPoint.z,  
           page.bounds.right - page.centerPoint.x,   maxY,   page.bounds.bottom - page.centerPoint.z );
           mesh->_setBounds(  bounds );
           Ogre::Vector3 temp = bounds.getMaximum(   ) - bounds.getMinimum(   );
           mesh->_setBoundingSphereRadius(  temp.length(   ) * 0.5f );
          
           Ogre::LogManager::getSingleton(   ).setLogDetail(  static_cast<Ogre::LoggingLevel>(  0 ) );
           mesh->load(   );
           Ogre::LogManager::getSingleton(   ).setLogDetail(  Ogre::LL_NORMAL );
          
           //Apply grass material to mesh
           subMesh->setMaterialName(  layer->material->getName(   ) );
          
           //Return the mesh
           return mesh.getPointer(   );
          }
          
          template <class TGrassLayer>
    1123  Ogre::Mesh *GrassLoader<TGrassLayer>::generateGrass_SPRITE(  PageInfo &page,   TGrassLayer *layer,   float *grassPositions,   unsigned int grassCount )
          {
           //Calculate the number of quads to be added
           unsigned int quadCount;
           quadCount = grassCount;
          
           //Create manual mesh to store grass quads
           Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton(   ).createManual(  getUniqueID(   ),   Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
           Ogre::SubMesh *subMesh = mesh->createSubMesh(   );
           subMesh->useSharedVertices = false;
          
           //Setup vertex format information
           subMesh->vertexData = new Ogre::VertexData;
           subMesh->vertexData->vertexStart = 0;
           subMesh->vertexData->vertexCount = 4 * quadCount;
          
           Ogre::VertexDeclaration* dcl = subMesh->vertexData->vertexDeclaration;
           size_t offset = 0;
           dcl->addElement(  0,   offset,   Ogre::VET_FLOAT3,   Ogre::VES_POSITION );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT3 );
           dcl->addElement(  0,   offset,   Ogre::VET_FLOAT4,   Ogre::VES_NORMAL );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT4 );
           dcl->addElement(  0,   offset,   Ogre::VET_COLOUR,   Ogre::VES_DIFFUSE );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_COLOUR );
           dcl->addElement(  0,   offset,   Ogre::VET_FLOAT2,   Ogre::VES_TEXTURE_COORDINATES );
           offset += Ogre::VertexElement::getTypeSize(  Ogre::VET_FLOAT2 );
          
           //Populate a new vertex buffer with grass
           Ogre::HardwareVertexBufferSharedPtr vbuf = Ogre::HardwareBufferManager::getSingleton(   )
           .createVertexBuffer(  offset,   subMesh->vertexData->vertexCount,   Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
           float* pReal = static_cast<float*>(  vbuf->lock(  Ogre::HardwareBuffer::HBL_DISCARD ) );
          
           //Calculate size variance
           float rndWidth = layer->maxWidth - layer->minWidth;
           float rndHeight = layer->maxHeight - layer->minHeight;
          
           float minY = Ogre::Math::POS_INFINITY,   maxY = Ogre::Math::NEG_INFINITY;
           float *posPtr = grassPositions; //Position array "iterator"
           for (  Ogre::uint16 i = 0; i < grassCount; ++i )
           {
           //Get the x and z positions from the position array
           float x = *posPtr++;
           float z = *posPtr++;
          
           //Calculate height
           float y;
           if (  heightFunction ){
           y = heightFunction(  x,   z,   heightFunctionUserData );
           } else {
           y = 0;
           }
          
           float x1 = (  x - page.centerPoint.x );
           float z1 = (  z - page.centerPoint.z );
          
           //Get the color at the grass position
           Ogre::uint32 color;
           if (  layer->colorMap )
           color = layer->colorMap->getColorAt(  x,   z );
           else
           color = 0xFFFFFFFF;
          
           //Calculate size
           float rnd = Ogre::Math::UnitRandom(   ); //The same rnd value is used for width and height to maintain aspect ratio
           float halfXScale = (  layer->minWidth + rndWidth * rnd ) * 0.5f;
           float scaleY = (  layer->minHeight + rndHeight * rnd );
          
           //Randomly mirror grass textures
           float uvLeft,   uvRight;
           if (  Ogre::Math::UnitRandom(   ) > 0.5f ){
           uvLeft = 0;
           uvRight = 1;
           } else {
           uvLeft = 1;
           uvRight = 0;
           }
          
           //Add vertices
           *pReal++ = x1; *pReal++ = y; *pReal++ = z1; //center position
           *pReal++ = -halfXScale; *pReal++ = scaleY; *pReal++ = 0; *pReal++ = 0; //normal (  used to store relative corner positions )
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = uvLeft; *pReal++ = 0; //uv
          
           *pReal++ = x1; *pReal++ = y; *pReal++ = z1; //center position
           *pReal++ = +halfXScale; *pReal++ = scaleY; *pReal++ = 0; *pReal++ = 0; //normal (  used to store relative corner positions )
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = uvRight; *pReal++ = 0; //uv
          
           *pReal++ = x1; *pReal++ = y; *pReal++ = z1; //center position
           *pReal++ = -halfXScale; *pReal++ = 0.0f; *pReal++ = 0; *pReal++ = 0; //normal (  used to store relative corner positions )
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = uvLeft; *pReal++ = 1; //uv
          
           *pReal++ = x1; *pReal++ = y; *pReal++ = z1; //center position
           *pReal++ = +halfXScale; *pReal++ = 0.0f; *pReal++ = 0; *pReal++ = 0; //normal (  used to store relative corner positions )
           *(  (  Ogre::uint32* )pReal++ ) = color; //color
           *pReal++ = uvRight; *pReal++ = 1; //uv
          
           //Update bounds
           if (  y < minY ) minY = y;
           if (  y + scaleY > maxY ) maxY = y + scaleY;
           }
          
           vbuf->unlock(   );
           subMesh->vertexData->vertexBufferBinding->setBinding(  0,   vbuf );
          
           //Populate index buffer
           subMesh->indexData->indexStart = 0;
           subMesh->indexData->indexCount = 6 * quadCount;
           subMesh->indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton(   )
           .createIndexBuffer(  Ogre::HardwareIndexBuffer::IT_16BIT,   subMesh->indexData->indexCount,   Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
           Ogre::uint16* pI = static_cast<Ogre::uint16*>(  subMesh->indexData->indexBuffer->lock(  Ogre::HardwareBuffer::HBL_DISCARD ) );
           for (  Ogre::uint16 i = 0; i < quadCount; ++i )
           {
           Ogre::uint16 offset = i * 4;
          
           *pI++ = 0 + offset;
           *pI++ = 2 + offset;
           *pI++ = 1 + offset;
          
           *pI++ = 1 + offset;
           *pI++ = 2 + offset;
           *pI++ = 3 + offset;
           }
          
           subMesh->indexData->indexBuffer->unlock(   );
          
           //Finish up mesh
           Ogre::AxisAlignedBox bounds(  page.bounds.left - page.centerPoint.x,   minY,   page.bounds.top - page.centerPoint.z,  
           page.bounds.right - page.centerPoint.x,   maxY,   page.bounds.bottom - page.centerPoint.z );
           mesh->_setBounds(  bounds );
           Ogre::Vector3 temp = bounds.getMaximum(   ) - bounds.getMinimum(   );
           mesh->_setBoundingSphereRadius(  temp.length(   ) * 0.5f );
          
           Ogre::LogManager::getSingleton(   ).setLogDetail(  static_cast<Ogre::LoggingLevel>(  0 ) );
           mesh->load(   );
           Ogre::LogManager::getSingleton(   ).setLogDetail(  Ogre::LL_NORMAL );
          
           //Apply grass material to mesh
           subMesh->setMaterialName(  layer->material->getName(   ) );
          
           //Return the mesh
           return mesh.getPointer(   );
          }
          
          template <class TGrassLayer>
          unsigned long GrassLoader<TGrassLayer>::GUID = 0;
          
          }
          #endif

./components/ogre/environment/pagedgeometry/include/ImpostorPage.h

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //ImpostorPage.h
          //ImposterPage is an extension to PagedGeometry which displays entities as imposters.
          //-------------------------------------------------------------------------------------
          
          #ifndef __ImpostorPage_H__
          #define __ImpostorPage_H__
          
          #include "PagedGeometry.h"
          #include "StaticBillboardSet.h"
          
          #include "OgrePrerequisites.h"
          #include "OgreTextureManager.h"
          #include "OgreRenderTexture.h"
          
          
          #define IMPOSTOR_YAW_ANGLES 8
          #define IMPOSTOR_PITCH_ANGLES 4
          
          namespace PagedGeometry {
          
      31  class ImpostorBatch;
      32  class ImpostorTexture;
          
          //Blend modes used by ImpostorPage::setBlendMode(   )
          typedef enum ImpostorBlendMode {
           ALPHA_REJECT_IMPOSTOR,  
           ALPHA_BLEND_IMPOSTOR
          };
          
          //-------------------------------------------------------------------------------------
          /**
          \brief The ImpostorPage class renders entities as impostors (  billboard images that look just like the real entity ).
          
          This is one of the geometry page types included in the StaticGeometry engine. These
          page types should be added to a PagedGeometry object with PagedGeometry::addDetailLevel(   )
          so the PagedGeometry will know how you want your geometry displayed.
          
          To use this page type,   use:
          \code
          PagedGeometry::addDetailLevel<ImpostorPage>(  farRange );
          \endcode
          
          Of all the page types included in the PagedGeometry engine,   this one is the fastest. It
          uses impostors (  billboards that look just like the real entity ) to represent entities.
          This way,   your video card only has to render a bunch of 2D images,   instead of a full 3D
          mesh. Imposters are generally used off in the distance slightly,   since they don't always
          look exactly like the real thing,   especially up close (  since they are flat,   and sometimes
          slightly pixelated ).
          
          \note Impostors are generated only once for each entity. If you make any changes to your
          entities,   you'll have to force impostor regeneration by deleting the prerender files
          located in your executable's working directory (  named "Impostor.[ResourceGroup].[Entity].png" )
          */
      64  class ImpostorPage: public GeometryPage
          {
      66   friend class ImpostorBatch;
      67   friend class ImpostorTexture;
          
          public:
      70   void init(  PagedGeometry *geom );
      71   ~ImpostorPage(   );
          
      73   void setRegion(  Ogre::Real left,   Ogre::Real top,   Ogre::Real right,   Ogre::Real bottom );
      74   void addEntity(  Ogre::Entity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale,   const Ogre::ColourValue &color );
      75   void build(   );
      76   void removeEntities(   );
          
      78   void setVisible(  bool visible );
      79   void setFade(  bool enabled,   Ogre::Real visibleDist,   Ogre::Real invisibleDist );
          
      81   void update(   );
          
           /**
           \brief Sets the resolution for single impostor images.
           \param pixels The width/height of one square impostor render
          
           The default impostor resolution is 128x128. Note that 32 impostor images
           will be stored in a single texture (  8 x 4 ),   so a impostor resolution of 128,  
           for example,   results in final texture size of 1024 x 512.
          
           \warning Calling this function will have no effect unless it is done before
           any entities are added to any page.
           */
      94   static void setImpostorResolution(  int pixels ) { impostorResolution = pixels; }
          
           /**
           \brief Sets the background color used when rendering impostor images.
           \param color The background color
          
           Choosing an impostor color that closely matches the main color of your objects
           is important to reduce mipmap artifacts. When distant objects are displayed as
           impostors,   hardware mipmapping can cause the color surrounding your object (  the
           background color ) to "bleed" into the main image,   which can result in incorrectly
           tinted distant objects.
          
           The default background color is ColourValue(  0.0f,   0.3f,   0.0f,   0.0f ),   or dark green
           (  this color was chosen because the main use of ImpostorPage is for trees,   bushes,   etc. )
          
           \warning Calling this function will have no effect unless it is done before
           any entities are added to any page. Also remember that you may have to
           delete the old impostor renders (  located in your exe's directory ) in
           order for the new ones to be generated.
           */
     114   static void setImpostorColor(  const Ogre::ColourValue &color )
           {
           impostorBackgroundColor = color;
           impostorBackgroundColor.a = 0.0f;
           }
          
           /**
           \brief Sets the billboard pivot point used when rendering camera-facing impostors
          
           This function can be used to set how impostors should rotate to face the camera. By default,  
           impostors are pointed towards the camera by rotating around the impostor billboard's center.
           By choosing an alternate pivot point with this function,   you can acheive better results under
           certain conditions. For example,   when looking up or down very steep hills,   you'll probably want
           to set BBO_BOTTOM_CENTER as the pivot point. For most other cases,   however,   the default pivot
           point of BBO_CENTER works best.
          
           \note Only BBO_CENTER and BBO_BOTTOM_CENTER is supported by this function currently.
          
           \warning Calling this function will have no effect unless it is done before
           any entities are added to any page.
           */
     135   static void setImpostorPivot(  Ogre::BillboardOrigin origin );
          
           /**
           \brief Regenerates the impostor texture for the specified entity
           \param ent The entity which will have it's impostor texture regenerated
          
           This function can be called to force the regeneration of a specific impostor.
           Normally,   impostors are generated once (  saved to a file ),   and simply preloaded
           from the file afterwards (  unless you delete the file ). Calling this will
           instantly regenerate the impostor and update it's saved image file.
          
           \note This function cannot regenerate an impostor unless it's already being used
           in the scene.
          
           \warning This is NOT a real-time operation - it may take a few seconds to complete.
           */
     151   static void regenerate(  Ogre::Entity *ent );
          
           /**
           \brief Regenerates all impostor textures currently being used in the scene
          
           This function can be called to force the regeneration of all impostors currently being
           used in your scene. Normally,   impostors are generated once (  saved to a file ),   and simply
           preloaded from the files afterwards (  unless you delete the files ). Calling this will
           instantly regenerate the impostors and update their saved image files.
          
           \warning This is NOT a real-time operation - it may take a few seconds to complete.
           */
     163   static void regenerateAll(   );
          
          
     166   inline void setBlendMode(  ImpostorBlendMode blendMode ) { this->blendMode = blendMode; }
     167   inline ImpostorBlendMode getBlendMode(   ) { return blendMode; }
          
          protected:
     170   Ogre::SceneManager *sceneMgr;
     171   PagedGeometry *geom;
          
           ImpostorBlendMode blendMode;
           static int impostorResolution;
     175   static Ogre::ColourValue impostorBackgroundColor;
     176   static Ogre::BillboardOrigin impostorPivot;
          
           static unsigned int selfInstances;
           static unsigned int updateInstanceID;
           unsigned int instanceID;
          
     182   Ogre::Timer updateTimer;
          
     184   Ogre::Vector3 center;
           int aveCount;
          
     187   std::map<Ogre::String,   ImpostorBatch *> impostorBatches;
          };
          
          
          //-------------------------------------------------------------------------------------
          //This is used internally by ImpostorPage to store a "batch" of impostors. Similar
          //impostors are all batched into ImpostorBatch'es,   which contain a BillboardSet (  where
          //the actual billboards are ),   and a pointer to an existing ImpostorTexture.
     195  class ImpostorBatch
          {
          public:
     198   static ImpostorBatch *getBatch(  ImpostorPage *group,   Ogre::Entity *entity );
     199   ~ImpostorBatch(   );
          
     201   inline void build(   )
           {
           bbset->build(   );
           }
          
     206   inline void clear(   )
           {
           bbset->clear(   );
           }
          
     211   inline void setVisible(  bool visible )
           {
           bbset->setVisible(  visible );
           }
          
     216   inline void setFade(  bool enabled,   Ogre::Real visibleDist,   Ogre::Real invisibleDist )
           {
           bbset->setFade(  enabled,   visibleDist,   invisibleDist );
           }
          
     221   void setBillboardOrigin(  Ogre::BillboardOrigin origin );
     222   inline void addBillboard(  const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale,   const Ogre::ColourValue &color = Ogre::ColourValue::White );
     223   void setAngle(  float pitchDeg,   float yawDeg );
          
     225   static Ogre::String generateEntityKey(  Ogre::Entity *entity );
          
          protected:
     228   ImpostorBatch(  ImpostorPage *group,   Ogre::Entity *entity );
          
     230   ImpostorTexture *tex;
     231   StaticBillboardSet *bbset;
          
     233   Ogre::Vector3 entityBBCenter;
          
     235   ImpostorPage *igroup;
          
     237   Ogre::uint16 pitchIndex,   yawIndex;
          
           static unsigned long GUID;
     240   static inline Ogre::String getUniqueID(  const Ogre::String &prefix )
           {
           return prefix + Ogre::StringConverter::toString(  ++GUID );
           }
          };
          
          
          //-------------------------------------------------------------------------------------
          //This is used internally by ImpostorPage. An ImpostorTexture is actually multiple
          //images of an entity from various rotations. ImpostorTextures are applied
          //to billboards to create the effect of 3D shapes,   when in reality they are simply
          //flat billboards.
     252  class ImpostorTexture
          {
     254   friend class ImpostorBatch;
          
          public:
           /** Returns a pointer to an ImpostorTexture for the specified entity. If one does not
           already exist,   one will automatically be created.
           */
     260   static ImpostorTexture *getTexture(  ImpostorPage *group,   Ogre::Entity *entity );
          
           /** remove created texture,   note that all of the ImposterTextures
           must be deleted at once,   because there is no track if a texture is still
           being used by something else
           */
     266   static void removeTexture(  ImpostorTexture* Texture );
          
     268   void regenerate(   );
     269   static void regenerateAll(   );
          
     271   ~ImpostorTexture(   );
          
          protected:
     274   ImpostorTexture(  ImpostorPage *group,   Ogre::Entity *entity );
          
     276   void renderTextures(  bool force ); // Renders the impostor texture grid
     277   void updateMaterials(   ); // Updates the materials to use the latest rendered impostor texture grid
          
     279   Ogre::String removeInvalidCharacters(  Ogre::String s );
          
     281   static std::map<Ogre::String,   ImpostorTexture *> selfList;
     282   Ogre::SceneManager *sceneMgr;
     283   Ogre::Entity *entity;
     284   Ogre::String entityKey;
          
     286   Ogre::MaterialPtr material[IMPOSTOR_PITCH_ANGLES][IMPOSTOR_YAW_ANGLES];
     287   Ogre::TexturePtr texture;
          
     289   Ogre::ResourceHandle sourceMesh;
     290   Ogre::AxisAlignedBox boundingBox;
           float entityDiameter,   entityRadius;
     292   Ogre::Vector3 entityCenter;
          
           static unsigned long GUID;
     295   static inline Ogre::String getUniqueID(  const Ogre::String &prefix )
           {
           return prefix + Ogre::StringConverter::toString(  ++GUID );
           }
          };
          
          
          
          //-------------------------------------------------------------------------------------
          //This is an inline function from ImposterBatch that had to be defined down below the
          //ImpostorTexture class,   because it uses it.
     306  void ImpostorBatch::addBillboard(  const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale,   const Ogre::ColourValue &color )
          {
           //float degrees = (  Math::ACos(  rotation.w )*2.0f ).valueDegrees(   );
           const Ogre::Vector3 zVector = rotation * Ogre::Vector3::UNIT_Z;
           float degrees = Ogre::Math::ATan2(  zVector.x,   zVector.z ).valueDegrees(   );
           if (  degrees < 0 ) degrees += 360;
          
           int n = IMPOSTOR_YAW_ANGLES * (  degrees / 360.0f ) + 0.5f;
           Ogre::uint16 texCoordIndx = (  IMPOSTOR_YAW_ANGLES - n ) % IMPOSTOR_YAW_ANGLES;
          
           bbset->createBillboard(  position + (  rotation * entityBBCenter ) * scale,  
           tex->entityDiameter * 0.5f * (  scale.x + scale.z ),  
           tex->entityDiameter * scale.y,   color,  
           texCoordIndx );
          }
          }
          
          #endif

./components/ogre/environment/pagedgeometry/include/PagedGeometry.h

          /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //PagedGeometry.h
          //Main header file for the PagedGeometry engine.
          //-------------------------------------------------------------------------------------
          
          //-------- The following is the main API documentation page (  parsed by doxygen ) --------
          /**
          \page Main PagedGeometry API Documentation
          
          \section A Introduction
          Although the PagedGeometry engine is fairly simple and easy to use,   there are some
          advanced features that may be difficult to learn on you own. This API reference is here
          for your convenience,   to aid you in learning how to get the most out of the PagedGeometry
          engine.
          
          Every feature of the engine is covered here in detail,   so you won't be left in the dark
          about any aspect of PagedGeometry's use (  however,   some of the internal workings of the
          engine are not documented in here - you'll have to refer to the source code comments
          for that ).
          
          
          \section B What is PagedGeometry?
          The PagedGeometry engine is an add-on to the <a href="http://www.ogre3d.org">OGRE
          Graphics Engine</a>,   which provides highly optimized methods for rendering massive amounts
          of small meshes covering a possibly infinite area. This is especially well suited for dense
          forests and outdoor scenes,   with millions of trees,   bushes,   grass,   rocks,   etc.,   etc.
          
          Paged geometry gives you many advantages over plain entities,   the main one being speed:
          With proper usage of detail levels,   outdoor scenes managed by PagedGeometry can
          be >100x faster than plain entities. Another advantage is that the geometry is paged; in
          other words,   only entities which are immediately needed (  to be displayed ) are loaded.
          This allows you to expand the boundaries of your virtual world almost infinitely
          (  only limited by floating point precision ),   providing the player with a more realistically
          scaled game area.
          
          
          \section C Getting Started
          
          The first thing you should do is follow the instructions in "Getting Started.txt" to
          get PagedGeometry compiled and the examples running. Note: Keep in mind that the art
          in the examples is not the best,   and is there simply to demonstrate the performance of
          the engine.
          
          When you're ready to start learning how to use PagedGeometry,   the best place to start is
          with Tutorial 1 (  in the docs folder ). The tutorials will teach you how to use many
          important PagedGeometry features,   step by step. This API reference isn't recommended
          for learning,   but is a valuable resource when you need specific in-depth information
          about a certain function or class.
          
          
          \section E Credits
          
          <ul>
          <li><b>John Judnich</b> - <i>Programming / design / documentation</i></li>
          <li><b><a href="http://sjcomp.com">Alexander Shyrokov</a></b> (  aka. sj ) - <i>Testing / co-design</i></li>
          <li><b><a href="http://www.pop-3d.com">Tuan Kuranes</a></b> - <i>Imposter image render technique</i></li>
          <li><b></b> (  Falagard ) - <i>Camera-facing billboard vertex shader</i></li>
          </ul>
          
          
          \section D License
          <b>Copyright (  c ) 2007 John Judnich</b>
          
          <i>
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
          
          <b>1.</b> The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
          
          <b>2.</b> Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
          
          <b>3.</b> This notice may not be removed or altered from any source distribution.
          </i>
          
          
          */
          
          //--------------------------------------------------------------------------------------
          
          
          
          #ifndef __PagedGeometry_H__
          #define __PagedGeometry_H__
          
          #include <limits> // numeric_limits<>
          
          #include "OgreRoot.h"
          #include "OgrePrerequisites.h"
          #include "OgreRenderSystem.h"
          #include "OgreEntity.h"
          #include "OgreCommon.h"
          #include "OgreCamera.h"
          #include "OgreVector3.h"
          #include "OgreTimer.h"
          
          namespace PagedGeometry {
          
     107  class GeometryPageManager;
     108  class PageLoader;
          
          /// Define TBounds as a TRect using Real numeric units.
          typedef Ogre::TRect<Ogre::Real> TBounds;
          
          //Enable PagedGeometry::setCoordinateSystem(   )
          //#define PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
          
          
          //-------------------------------------------------------------------------------------
          /**
          \brief A class providing highly optimized methods for rendering massive amounts of geometry.
          
          The PagedGeometry class provides highly optimized methods for rendering massive amounts
          of small meshes,   covering a large area. This is especially well suited for dense
          forests,   with thousands of trees,   bushes,   grass,   rocks,   etc.,   etc.
          
          The paged geometry works by loading only the geometry that is visible (  or will soon
          be visible ),   to save memory. The PagedGeometry engine can display entities using many
          different methods (  static geometry,   impostors,   etc. ) What method is used depends on the
          entities' distance from the camera,   and how you configured these methods (  see
          PagedGeometry::addDetailLevel(   ) for more info about this ).
          
          The loading of pages is done through a PageLoader,   which you define. This way,   you
          can program the PagedGeometry to load pages any way you want,   whether it's from a
          file on your hard drive,   from a procedural generation algorithm,   or anything else.
          See the documentation for the PageLoader class for more information about this.
          
          \note Always remember to call each PagedGeometry object's update(   ) function every
          frame; otherwise the geometry you're trying to display will not appear correctly.
          See PagedGeometry::update(   ) for more information.
          */
     140  class PagedGeometry
          {
          public:
           /**
           \brief Initializes a PagedGeometry object.
           \param cam A camera which the PagedGeometry object will use for LOD calculations.
           \param pageSize The page size (  pages are square )
          
           pageSize sets the size of a single "page" of geometry. If your pages are too big,  
           you may experience "hiccuping" during the game as these regions are loaded. However,  
           regions that are too small may result in lower frame rates (  depending on what detail
           levels you are using ).
          
           Also,   using larger pages uses slightly less memory,   although you should generally
           give performance precedence over memory usage.
          
           \note You do not need to specify the page size or camera in the constructor if you
           don't want to. PagedGeometry::setCamera(   ) and PagedGeometry::setPageSize(   ) allows
           you to configure these values later.
          
           \see setCamera(   ),   setPageSize(   ),   setBounds(   ),   setInfinite(   ),   setPageLoader(   )
           */
     162   PagedGeometry(  Ogre::Camera *cam = NULL,   Ogre::Real pageSize = 100 );
          
     164   ~PagedGeometry(   );
          
           /**
           \brief Sets the camera to use when calculating levels of detail.
           \param cam The camera to assign to this PagedGeometry object.
          
           \note The specified camera must belong to the same scene manager as
           previous ones; once a camera is set,   the scene manager that camera
           belongs to will be used permanently for this PagedGeometry instance.
          
           \warning Changing cameras will often result in low cache efficiency in
           infinite mode. If you are constantly switching between multiple cameras
           that are relatively far apart,   consider using bounded mode.
           */
     178   void setCamera(  Ogre::Camera *cam );
          
           /**
           \brief Gets the camera which is used to calculate levels of detail.
           \returns The camera assigned to this PagedGeometry object.
          
           \warning Be careful when storing a local copy of this - the camera returned
           may change at any time,   so it's usually best to call getCamera(   ) repeatedly,  
           instead of storing a local copy. This is an inline function,   so don't worry
           too much about performance.
           */
     189   inline Ogre::Camera *getCamera(   )
           {
           return sceneCam;
           }
          
           /**
           \brief Gets the scene manager which is being used to display the geometry
           \returns A SceneManager
          
           This function simply returns the SceneManager that this PagedGeometry object
           is using. If no camera has been set yet,   this will return NULL,   since PagedGeometry
           has no way of knowing which SceneManager to use. However,   once a camera is set,  
           the SceneManager this function returns will always remain the same - even if the
           camera is later set to NULL.
           */
     204   inline Ogre::SceneManager *getSceneManager(   )
           {
           return sceneMgr;
           }
          
           /**
           \brief Gets the scene node to which all PagedGeometry geometry is attached
           \returns A SceneNode
          
           \note Feel free to ignore this function - you can fully make use of PagedGeometry's features
           without it.
          
           This function returns the SceneNode which PagedGeometry uses to render all it's
           geometry. Everything that PagedGeometry renders to the screen can be found under
           this scene node.
          
           You don't need to use this function at all to fully make use of PagedGeometry's
           features - it's primary use is for PagedGeometry's internal subsystems to be able
           to create geometry using the proper scene node.
          
           \warning If no camera has been set yet,   this will return NULL,   since PagedGeometry
           can't create the SceneNode until it know which SceneManager to use (  which is determined
           from the assigned camera ). However,   once a camera is set,   the SceneNode this function
           returns will always remain the same - even if the camera is later set to NULL.
           */
     229   inline Ogre::SceneNode *getSceneNode(   )
           {
           return rootNode;
           }
          
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           /**
           \brief Sets the coordinate system to be used by PagedGeometry
           \param up A vector pointing to whatever direction you consider to be "up"
           \param right A vector pointing to whatever direction you consider to be "right"
          
           By default,   PagedGeometry uses the standard coordinate system where X is right,   Y is up,  
           and Z is back. If you use an alternate coordinate system,   for example where Z is up,   you'll
           have to use this function to configure PagedGeometry to use that coordinate system; otherwise,  
           LOD calculations,   impostors,   etc. will be all messed up.
          
           To do so,   simply supply which directions you consider "right" and "up". For example,   if your
           coordinate system uses X as right,   Y as forward,   and Z as up,   you would set the "right" parameter
           to Vector3::UNIT_X and the "up" parameter to Vector3::UNIT_Z. The forward direction
           (  Vector3::UNIT_Y in this case ) doesn't need to be supplied since it will be automatically calculated
           from the right and up vectors.
          
           \warning Be sure to configure PagedGeometry with your coordinate system before using any PageLoader's,  
           since they may depend on the current coordinate system to function properly.
          
           \note By default this function is disabled and won't appear in the PagedGeometry library. To
           enable it,   reenable the line near the top of PagedGeometry.h where PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           is defined by un-commenting it (  then recompile ).
           */
     258   void setCoordinateSystem(  Ogre::Vector3 up,   Ogre::Vector3 right = Ogre::Vector3::UNIT_X );
           #endif
          
           /**
           \brief Switches to bounded mode and uses the given boundaries
          
           By default,   PagedGeometry does not place boundaries on the geometry that can
           be added to it though the PageLoader. However,   there are cases where specifying
           a strict boundary can improve performance.
          
           When bounded mode is used,   PagedGeometry allocates certain lightweight data
           structures to fill the boundaries. This may result in a slight frame rate boost
           compared to an infinite world,   although it will take a little more memory
           (  especially with large areas ).
          
           Since bounded mode requires more memory for larger boundaries,   it is best suited
           for small to medium sized worlds,   while infinite mode is best for huge or even
           near-infinite worlds.
          
           \note Bounds must be square.
          
           \see setInfinite(   )
           */
     281   void setBounds(  TBounds bounds );
          
           /**
           \brief Switches to infinite mode
          
           By default,   PagedGeometry will just allocate enough memory to display and cache
           what is on the screen. This behavior is called "infinite mode",   and can be activated
           by calling this function if not already activated (  it will be by default ).
          
           Most game worlds have boundaries of some sort,   but infinite mode allows you to
           expand the size of your game world almost to infinity. Since only what's on the
           screen is actually loaded,   it makes little difference if your world is 100 square
           miles,   or 1,  000,  000 square miles.
          
           The only disadvantage to using infinite mode is that cache efficiency will be
           slightly reduced in some cases. For example,   bounded mode will achieve better
           performance if you are often switching between multiple cameras,   since the cache
           is more globally based (  unlike the locally based cache of infinite mode ).
          
           \see setBounds(   )
           */
     302   void setInfinite(   );
          
           /**
           \brief Gets the current geometry boundary.
           \returns The geometry boundary which was set in the constructor.
          
           \see The PagedGeometry constructor for information about the geometry boundary.
          
           This returns a TBounds value,   which contains information about the boundaries
           of the geometry. Since TBounds is simply a typedef for TRect<Real>,   accessing
           the boundary information is easy,   for example:
          
           \code
           (  ... ) = PagedGeometry::getBounds(   ).top;
           (  ... ) = PagedGeometry::getBounds(   ).bottom;
           (  etc. )
           \endcode
          
           Ogre's documentation should contain more information about TRect members.
           */
     322   inline const TBounds& getBounds(   )
           {
           return m_bounds;
           }
          
           /**
           \brief Sets the page size
          
           This sets the size of a single "page" of geometry. If your pages are too big,  
           you may experience "hiccuping" during the game as these regions are loaded. However,  
           regions that are too small may result in lower frame rates (  depending on what detail
           levels you are using ).
          
           Also,   using larger pages uses slightly less memory,   although you should generally
           give performance precedence over memory usage.
           */
     338   void setPageSize(  Ogre::Real size );
          
           /**
           \brief Gets the current page size.
           \returns The current page size.
          
           \see setPageSize(   ) for more information about page size.
           */
     346   inline Ogre::Real getPageSize(   )
           {
           return pageSize;
           }
          
          
           /**
           \brief Adds a detail level to the PagedGeometry object.
           \param PageType The page type class you want to use for this detail level.
           \param maxRange The maximum distance this detail level will be used at.
           \param transitionLength The desired length of fade transitions - optional
          
           \note PageType is not really a function parameter,   but a template parameter.
           See the code below for an example on how this "parameter" is used.
          
           On it's own,   a plain PagedGeometry object can't display anything. It needs you
           to add detail levels to it with this function. This way,   you can easily customize
           the behavior of the PagedGeometry.
          
           To use this function,   simply use the form:
          
           \code
           pagedGeometry::addDetailLevel<PageType>(  farRange );
           \endcode
          
           In the above example,   "farRange" specifies the maximum view distance this detail
           level will be used at. However,   the most important part is "<PageType>". Here you
           substitute "PageType" with the name of a installed page type you want to use for
           this detail level. A page type is simply a method of displaying or otherwise
           representing entities.
          
           The PagedGeometry engine currently comes pre-installed with a few page types:
           BatchPage and ImpostorPage. Refer to their class documentation for detailed
           information about them (  although you never actually access these classes yourself ).
          
           You can use these page types in any configuration you want. For example:
          
           \code
           pagedTrees->addDetailLevel<BatchPage>(  100 ); //Use batched geometry from 0-100
           pagedTrees->addDetailLevel<ImpostorPage>(  500 ); //Use impostors from 100-500
           \endcode
          
           That example would set up the PagedGeometry object called pagedTrees to use
           batched geometry (  StaticGeometry ) from 0 to 100 units from the camera,   and impostors
           from 100 to 500 units from the camera.
          
           If the included page types aren't adequate,   you can fairly easily add your own
           by simply extending the virtual GeometryPage class properly.
          
           By default,   no fade transitions are used. This means that there will be a noticeable
           "popping" effect when your tree changes from an impostor to a batch,   for example.
           Enabling fade transitions will smooth out the change by slowly "morphing" between
           the two detail levels. To enable fade transitions,   simply add a second parameter to
           you addDetailLevel(   ) call:
          
           \code
           //Use batched geometry from 0-100,   and transition to the next LOD for 50 units
           pagedTrees->addDetailLevel<BatchPage>(  100,   50 );
           //Use impostors from 100-500
           pagedTrees->addDetailLevel<ImpostorPage>(  500 );
           \endcode
          
           The second parameter seen above will enable transitions between BatchPage and the next
           LOD (  which is ImpostorPage,   in this case ). The number you supply will specify how long
           the transition is. Longer transitions result in smoother "morphs",   although shorter
           transitions will give slightly better frame rates.
          
           The transition parameter can also be applied to the last detail level to cause it to fade out:
          
           \code
           //Use batched geometry from 0-100,   and transition to the next LOD for 50 units
           pagedTrees->addDetailLevel<BatchPage>(  100,   50 );
           //Use impostors from 100-400,   and fade out for 100 units beyond that
           pagedTrees->addDetailLevel<ImpostorPage>(  400,   100 );
           \endcode
          
           In the example above,   batching is used up to 100 units,   where the batched geometry
           starts transitioning for 50 units into the next level of detail (  impostors ). The
           impostors continue up to 400 units,   where they begin to fade out for 100 more units.
          
           \warning Depending on your page size and transition length,   enabling fade transitions
           will often reduce PagedGeometry's rendering performance anywhere from 10 - 30%.
          
           Transitions can be disabled by omitting the transitionLength parameter,   or setting
           it to 0.
          
           \note Make sure you make any calls to setPageSize(   ) and setBounds(   ) / setInfinite(   )
           before adding detail levels with this function. After a detail level is added you
           cannot call these functions without first removing them with removeDetailLevels(   ).
          
           \see The GeometryPage class documention for more information on adding custom
           page types.
           */
           template <class PageType> inline GeometryPageManager* addDetailLevel(  Ogre::Real maxRange,   Ogre::Real transitionLength = 0 );
          
           /**
           \brief Removes all detail levels from the PagedGeometry object.
          
           This removes all detail levels (  added with addDetailLevel ) from the PagedGeometry
           object. This also removes all geometry associated with PagedGeometry from the scene.
           Remember that you will need to re-add all the detail levels again with
           addDetailLevel(   ) before any of the geometry will be displayed.
           */
           void removeDetailLevels(   );
          
           /**
           \brief Returns a reference to a list of all added detail levels.
          
           This returns a std::list of all detail levels (  GeometryPageManager's ). These objects
           can be used to set/get advanced properties,   such as view ranges and cache speeds.
          
           Normally you won't ever have to access this data,   but it's there in case you need it.
           */
           inline const std::list<GeometryPageManager*> &getDetailLevels(   ) { return managerList; }
          
          
           /**
           \brief Assigns a PageLoader object for the PagedGeometry.
           \param loader A PageLoader object.
          
           When the page manager decides it should cache a certain region of geometry,   it calls
           on your PageLoader to do the job. This way you can load entities from RAM,   a hard-drive,  
           the internet,   or even procedurally. Simply create a PageLoader class and use this function
           to link it to a PagedGeometry object.
          
           \warning Since you must instantiate your PageLoader yourself,   you must also be sure to
           deallocate it properly (  as with any other class instance ). PagedGeometry will not do this
           for you.
          
           \see PageLoader documentation for more information on setting up a page loader.
           */
           void setPageLoader(  PageLoader *loader );
          
           /**
           \brief Gets the PageLoader currently being used to load geometry.
           \returns A PageLoader object which is currently being used to load geometry.
          
           This can be useful if you want to retreive the current page loader to delete it,  
           or any other task that needs to be done to the currently used page loader.
           */
     486   inline PageLoader *getPageLoader(   )
           {
           return pageLoader;
           }
          
          
           /**
           \brief Updates this PagedGeometry object
          
           This function must be called each frame in order for the PagedGeometry object
           to calculate LODs and perform paging. If this function is not called every frame,  
           none of the geometry managed by this PagedGeometry instance will appear (  or if it
           does,   it will appear incorrectly )
           */
     500   void update(   );
          
          
           /**
           \brief Reloads all visible geometry.
          
           If your PageLoader changes it's output during runtime,   you normally won't see
           the changes immediately (  and in many cases,   you will never see the changes ).
           This function provides a way to reload the geometry to force the changes to take
           effect immediately.
          
           This function will cause ALL visible geometry to be reloaded during the next
           update. This can take up to several seconds,   depending on the complexity of
           the current scene,   so use this function only when absolutely necessary.
           */
     515   void reloadGeometry(   );
          
           /**
           \brief Reloads geometry at the given location.
           \param point The point in 3D space where geometry needs to be reloaded.
          
           If your PageLoader changes it's output during runtime,   you normally won't see
           the changes immediately (  and in many cases,   you will never see the changes ).
           This function provides a way to reload the geometry to force the changes to take
           effect immediately.
          
           This function will cause a certain page of visible geometry to be reloaded
           during the next update. Unlike reloadGeometry(   ),   this function allows pinpoint
           reloading to take place,   resulting in better performance if a small portion
           of the geometry changes.
          
           Since this doesn't actually reload anything immediately,   you can call this
           function as many times as you need without worrying too much about performance.
           For example,   if you update 150 trees in your game,   simply supply this function
           with the locations of each tree. When the scene is about to be rendered,   the
           appropriate geometry pages will automatically be reloaded.
           */
     537   void reloadGeometryPage(  const Ogre::Vector3 &point );
          
          
           /*
           \brief Immediately loads visible geometry.
           \param maxTime The maximum amount of time (  in milliseconds ) which cacheGeometry(   )
           is allowed to use before returning (  roughly ).
           \returns Whether or not everything was cached.
          
           PagedGeometry automatically loads and caches geometry near the camera in real-time.
           This function allows you to easily pre-load this geometry outside of your render loop.
          
           For example,   in your loading code,   you might call PagedGeometry::cacheGeometry(   ) to
           load all your trees/etc. managed by PagedGeometry instantly,   rather than later on.
          
           If it takes several seconds to cache geometry,   you may want to update a progress bar
           more often. The maxTime parameter allows you to split up this task into smaller
           segments for this purpose. Simply call cacheGeometry(  maxTime ) repeatedly until
           everything is cached (  cacheGeometry(   ) will return true when finished  ).
           */
           //todo
           //bool cacheGeometry(  unsigned long maxTime = 0 );
          
          
           /** INTERNAL FUNCTION - DO NOT USE */
     562   Ogre::Vector3 _convertToLocal(  const Ogre::Vector3 &globalVec );
          
          protected:
           //Internal function - do not use
     566   void _addDetailLevel(  GeometryPageManager *mgr,   Ogre::Real maxRange,   Ogre::Real transitionLength );
          
           Ogre::SceneManager* sceneMgr;
           Ogre::SceneNode* rootNode; //PagedGeometry's own "root" node
          
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           Ogre::Quaternion coordinateSystemQuat; //The orientation of rootNode
           #endif
          
           //Camera data
           Ogre::Camera* sceneCam;
           Ogre::Vector3 oldCamPos;
          
           Ogre::Camera* lastSceneCam;
           Ogre::Vector3 lastOldCamPos;
          
           //This list keeps track of all the GeometryPageManager's added with addPageManager(   )
           std::list<GeometryPageManager *> managerList;
          
           //The assigned PageLoader used to load entities
           PageLoader* pageLoader;
          
           //The bounds and page size
           TBounds m_bounds;
           //The page size
           Ogre::Real pageSize;
          
           //Time-related data
           Ogre::Timer timer;
           unsigned long lastTime;
          };
          
          
          
          //-------------------------------------------------------------------------------------
          /**
          \brief This base-class can be extended to provide different ways of representing entities.
          
          The PagedGeometry engine comes pre-installed with a few GeometryPage sub-classes
          (  BatchPage,   and ImpostorPage ). These "page types" can all be supplied to
          a PagedGeometry object through addDetailLevel(   ).
          \see PagedGeometry::addDetailLevel(   ) for more information about setting up detail levels.
          
          If you need more than the pre-installed page types,   you can easily create your own!
          Simply make a new class inheriting GeometryPage. Then implement the necessary member
          functions,   and it should work immediately. No additional setup is required.
          
          There are several virtual member functions you will need to implement in your class:
          \code
          virtual void init(  SceneManager *mgr,   Camera *cam ) = 0;
          virtual void setRegion(  Real left,   Real top,   Real right,   Real bottom ) = 0;
          virtual void addEntity(  Entity *ent,   const Vector3 &position,   const Quaternion &rotation,   const Vector3 &scale,   const Ogre::ColourValue &color ) = 0;
          virtual void build(   ) {}
          virtual void removeEntities(   ) = 0;
          virtual void setVisible(  bool visible ) = 0;
          virtual void setFade(  bool enabled,   Real visibleDist,   Real invisibleDist ) = 0;
          virtual void update(   ) {}
          \endcode
          
          \note For detailed information on implementing each of these functions,   please refer to
          their documentation.
          
          Here is how the page manager uses these functions:
          
          \b 1. When a PagedGeometry first creates a GeometryPage,   it immediately calls
          GeometryPage::init(   ). This function is called just like a constructor,   and you should
          use it the same way.
          
          \b 2. GeometryPage::setRegion(   ) is called to provide you with the area where upcoming
          entities will be added. You can use this information any way you like,   or you can omit
          this step completely by omitting the setRegion(   ) function from your class definition.
          
          \b 3. To load a page,   the addEntity(   ) function is used to insert all the entities into the scene.
          Then,   build(   ) is called. Entities don't actually have to be displayed until after build(   )
          is called.
          
          \b 4. setVisible(   ) and setFade(   ) will be called occasionally to update the visibility/fade status
          of the page.
          
          \b 5. When the page has become obsolete,   the contents of it is deleted with removeEntities(   ).
          This should return the page to the state it was before addEntity(   ) and build(   ).
          
          \b 6. Steps 2-5 are repeated as pages are loaded/unloaded
          
          Implementing your own geometry page is really very simple. As long as the functions
          do their jobs right,   everything will work fine. If you learn best be example,   you may
          want to take a look at how the included page types are implemented also.
          
          \see The BatchPage or GrassPage code for examples of how page types are implemented (  the
          ImpostorPage can also be used as an example,   although it is a somewhat complex technique,  
          and is not recommended for learning how GeometryPage's work ).
          */
          class GeometryPage
          {
           friend class GeometryPageManager;
          
          public:
           /**
           \brief Prepare a geometry page for use.
           \param geom The PagedGeometry object that's creating this GeometryPage.
          
           This is called immediately after creating a new GeometryPage. It is never called more
           than once for a single instance of your geometry page.
          
           \note If you need to get the current camera,   scene manager,   etc.,   use the geom
           parameter. The PagedGeometry class contains inline methods you can use to access
           the camera and scene manager.
          
           \warning Do NOT store a local copy of geom->getCamera(   )! The camera returned by this
           function may change at any time!
           */
           virtual void init(  PagedGeometry *geom ) = 0;
          
           /**
           \brief Prepare a geometry page for entities
           \param left The minimum x-coordinate any entities will have.
           \param top The minimum z-coordinate any entities will have.
           \param right The maximum x-coordinate any entities will have.
           \param bottom The maximum z-coordinate any entities will have.
          
           This basically provides you with a region where upcoming entities will be located,  
           since many geometry rendering methods require this data. It's up to you how this
           data is used,   if at all.
          
           setRegion(   ) is never called when the page contains entities; only once just before
           a load process (  when entities are added with addEntity ).
          
           \note Implementing this funtion in your GeometryPage is completely optional,   since
           most of the time you don't need region information.
           */
           virtual void setRegion(  Ogre::Real left,   Ogre::Real top,   Ogre::Real right,   Ogre::Real bottom ) {};
          
           /**
           \brief Add an entity to the page,   at the specified position,   rotation,   and scale.
           \param ent The entity that is being added. Keep in mind that the same entity may
           be added multiple times.
           \param position The position where the entity must be placed. Under normal
           circumstances,   this will never be outside of the bounds supplied to init(   ).
           The only exception is when a PageLoader tries to add an entity outside of the
           bounds it was given.
           \param rotation The rotation which should be applied to the entity.
           \param scale The scale which should be applied to the entity.
           \param color The desired color to apply to the whole entity
          
           \note The entity does not have to actually appear in the scene until build(   )
           is called.
           */
           virtual void addEntity(  Ogre::Entity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale,   const Ogre::ColourValue &color ) = 0;
          
           /**
           \brief Perform any final steps to make added entities appear in the scene.
          
           build(   ) is automatically called right after all the entities have been added with
           addEntity(   ). Use this if there are any final steps that need to be performed after
           addEntity(   ) has been called in order to display the entities.
          
           \note This function is not pure virtual,   so you don't have to override it if you
           don't need to.
           */
           virtual void build(   ) {}
          
           /**
           \brief Remove all geometry/entities from the page completely.
          
           Make sure this completely reverses the effects of both build(   ) and addEntity(   ). This
           is necessary,   because after this is called,   the entities will most likely be added
           again with addEntity(   ) and build(   ).
          
           Do not leave any remains of the entities in memory after this function is called.
           One of the advantages of using paged geometry is that you can have near-infinite
           game worlds,   which would normally exceed a computer's RAM capacity. This advantage
           would completely dissappear if you did not clean up properly when the page manager
           calls this function.
           */
           virtual void removeEntities(   ) = 0;
          
           /**
           \brief Sets fade behavior for this page.
           \param enabled Whether or not to enable fading
           \param visibleDist The distance where geometry will be fully opaque (  alpha 1 )
           \param invisibleDist The distance where geometry will be invisible (  alpha 0 )
          
           This is called whenever a page needs fading enabled/disabled. The distance ranges
           given specify how the final alpha values should be calculated - geometry at
           visibleDist should have alpha values of 1,   while geometry at invisibleDist should
           have alpha values of 0. Important: Distances must be calculated in the xz plane
           only - the y coordinate should be disregarded when calculating distance.
          
           setFade(   ) won't be called unless the user's computer supports vertex shaders.
          
           \note invisibleDist may be greater than or less than visibleDist,   depending on
           whether the geometry is fading out or in to the distance.
           */
           virtual void setFade(  bool enabled,   Ogre::Real visibleDist = 0,   Ogre::Real invisibleDist = 0 ) = 0;
          
           /**
           \brief Toggle the entire page's visibility.
           \param visible Whether or not this page should be visible.
           */
           virtual void setVisible(  bool visible ) = 0;
          
           /**
           \brief Do whatever needs to be done to keep the page geometry up-to-date.
          
           update(   ) is called each frame for each GeometryPage instance. This function should
           perform any operations that are needed to keep the geometry page up-to-date.
          
           \note Overriding this function is optional,   however,   since not all implementations
           of geometry may need to be updated.
           */
           virtual void update(   ) {}
          
           /**
           \brief Gets the center point of the page.
           \returns The center points of the page.
           \note This is a non-virtual utility function common to all GeometryPage classes,   don't
           try to override it.
           */
           inline Ogre::Vector3 &getCenterPoint(   ) { return _centerPoint; }
          
           /**
           \brief Return the current visibility status of the page.
           \returns The current visibility status of the page.
           \note This is a non-virtual utility function common to all GeometryPage classes,   don't
           try to override it.
           */
           inline bool isVisible(   ) { return (  _visible && _loaded ); }
          
           /**
           \brief Advanced: Return the bounding box computed with addEntityToBoundingBox(   )
          
           Advanced: Override this function only if your page implementation already computes a
           bounding box (  local to the page center ) for added entities. This way you can prevent
           the bounding box from being computed twice.
          
           When performing fade transitions,   the page manager needs to know the actual boundaries
           of an entire page of entities in order to avoid entities "popping" into view without a
           smooth transition due to loose grid boundaries. Anyway,   as long as this function returns
           the combined bounding box of all entities added to this page properly,   fade transitions
           should work fairly smoothly.
          
           Important: If you implement this function,   you must also override addEntityToBoundingBox(   )
           and clearBoundingBox(   ) (  although you don't need to implement them as long as getBoundingBox(   )
           functions as expected ). Otherwise the default implementations of these function will be
           used and therefore result in the bounding box being calculated twice.
           */
           virtual const Ogre::AxisAlignedBox &getBoundingBox(   );
          
           /**
           \brief Advanced: Expand the current bounding box to include the given entity
          
           Advanced: Override this function only if your page implementation already computes a
           bounding box (  local to the page center ) for added entities. This way you can prevent
           the bounding box from being computed twice.
          
           \see getBoundingBox(   ) for important details.
           */
           virtual void addEntityToBoundingBox(  Ogre::Entity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale );
          
           /**
           \brief Advanced: Reset the bounding box used by addEntityToBoundingBox(   )
          
           Advanced: Override this function only if your page implementation already computes a
           bounding box (  local to the page center ) for added entities. This way you can prevent
           the bounding box from being computed twice.
          
           \see getBoundingBox(   ) for important details.
           */
           virtual void clearBoundingBox(   );
          
           /**
           \brief Destructor
           This is defined here so the destructors of derived classes are called properly. Whether
           or not you actually implement a destructor is up to you.
           */
           virtual ~GeometryPage(   ) {}
          
          private:
           //These values and functions are used by the GeometryPageManager internally.
           Ogre::Vector3 _centerPoint; //The central point of this page (  used to visibility calculation )
           int _xIndex,   _zIndex; //The absolute grid position of this page
           unsigned long _inactiveTime; //How long this page has been inactive (  used to calculate expired pages )
           bool _visible; //Flag indicating if page is visible
           bool _fadeEnable; //Flag indicating if page fading is enabled
          
           bool _pending; //Flag indicating if page needs loading
           bool _loaded; //Flag indicating if page is loaded
           bool _needsUnload; //Flag indicating if page needs unloading before next load
           std::list<GeometryPage*>::iterator _iter; //Iterator in loadedList
          
           Ogre::AxisAlignedBox _trueBounds; //Actual bounding box of the 3D geometry added to this page
           bool _trueBoundsUndefined; //Flag indicating if _trueBounds has not been defined yet
          
           void *_userData; //Misc. data associated with this page by the PageLoader
          };
          
          
          
          //-------------------------------------------------------------------------------------
          /**
          \brief Useful page information supplied to a pageloader.
          
          When your page loader's loadPage(   ) or unloadPage(   ) is called,   you are supplied with a
          PageInfo variable. This basically tells you what region in space is to be loaded into
          the page,   in addition to some other useful information about that region.
          
          \see the PageLoader::loadPage(   ) and PageLoader::unloadPage(   ) documentation for more information.
          */
          struct PageInfo
          {
           /**
           \brief The page boundaries in which all entities should be placed.
          
           This specifies the rectangular boundary of the page. Every entity
           contained in the page should reside within these boundaries.
          
           <ul>
           <li>bounds.left is the minimum X coordinate allowed for any entity in the page.</li>
           <li>bounds.right is the maximum X coordinate allowed for any entity in the page.</li>
           <li>bounds.top is the minimum Z coordinate allowed for any entity in the page.</li>
           <li>bounds.bottom is the maximum Z coordinate allowed for any entity in the page.</li>
           </ul>
           */
           TBounds bounds;
          
           /**
           \brief The center of the page (  simply the middle of the bounds ).
           \note Since there is no way of knowing the elevation of your entities,  
           centerPoint.y will always be defaulted at 0.
           */
           Ogre::Vector3 centerPoint;
          
           /**
           \brief The X index of the page tile.
          
           If all the geometry pages were arranged in a big 2D grid,   this would be the
           X index of this page in that grid.
          
           This is mathematically equivelant to Math::Floor(   bounds.left / bounds.width(   )  ),  
           although this should be used instead due to floating point precision
           issues which may occur otherwise.
           */
           int xIndex;
          
           /**
           \brief The Z index of the page tile.
          
           If all the geometry pages were arranged in a big 2D grid,   this would be the
           Z index of this page in that grid.
          
           This is mathematically equivelant to Math::Floor(   bounds.top / bounds.height(   )  ),  
           although this should be used instead due to floating point precision
           issues which may occur otherwise.
           */
           int zIndex;
          
           /**
           \brief Misc. custom data to associate with this page tile.
          
           This field can be set in PageLoader::loadPage(   ) to point to custom data
           allocated during the loading of a page. You can later retreive this data in
           PageLoader::unloadPage(   ) in order to deallocate the data if desired.
          
           \warning After a page is unloaded,   userData becomes NULL. Don't attempt to
           use userData to reference an object longer than the page's life span;
           anything userData points to should be fully deallocated when
           PageLoader::unloadPage(   ) is called.
           */
           void *userData;
          };
          
          /**
          \brief A class which you extend to provide a callback function for loading entities.
          
          \note PagedGeometry comes pre-installed with several PageLoader classes,   so you probably
          won't need to create you're own from scratch. See TreeLoader2D,   TreeLoader3D,   and GrassLoader
          for more info.
          
          Unlike most entity managers,   PagedGeometry does not allow you to simply add all your
          entities to the object,   and let the engine run from that point on. Since the
          PagedGeometry engine is designed to work with extremely large game areas,   preloading
          everything would take far too much memory. Instead,   it pages the geometry. In other
          words,   it loads the geometry only as needed.
          
          Whenever the engine needs a specific region of geometry to be loaded,   it calls on your
          page loader class's loadPage(   ) function. It's completely up to you how this function
          loads the entities,   just as long as it gets the job done. When loadPage(   ) is called,  
          you are provided with a PageInfo variable,   which specifies the boundary which must
          be loaded (  in addition to other useful info ). Make sure you don't add anything outside
          of this boundary,   otherwise the results may be unpredictable.
          
          Within loadPage(   ),   you add entities by calling addEntity(   ). Simply supply the entity
          you want to add (  you can add the same entity as many times as you want - in fact,   you
          should do this as much as possible for better performance ),   and it's position,   rotation,  
          and scale (  optional ).
          
          Note that your page loader may be asked to load an area which is out of your world's
          bounds (  if you have any ). In this case simply return without adding any entities.
          
          To set up a page loader,   just make a new sub-class (  call it anything you want ) of
          PageLoader. Your class must have one function:
          
          \code
          void loadPage(  const PageInfo &page );
          \endcode
          
          Make sure you get the declaration right,   otherwise it won't compile. The rest is up to
          you. You can define your own member functions if that helps,   just as long as your
          loadPage(   ) function does it's job right.
          
          Once you've created your PageLoader-derived class,   you need to attach it to a
          PagedGeometry object. To do this,   simply create an instance of your class,   and call
          
          \code
          pagedGeometry->setPageLoader(  yourPageLoader );
          \endcode
          
          Remember: If you ever delete a PagedGeometry object,   you will have to delete your page
          loader yourself (  if you want to ). The PagedGeometry destructor won't do this for you.
          */
          class PageLoader
          {
          public:
           /**
           \brief This should be overridden to load a specified region of entities.
           \param page A PageInfo variable which includes boundary information and other useful values.
          
           Override this function to load entities within the specified boundary. The boundary
           information is contained in the "page" parameter,   along with other useful information
           as well (  see the PageInfo documentation for more info about this ).
          
           Simply use the member function addEntity(   ) to add all the entities you want. If you
           create your own objects inside this function,   you are responsible for deleting it
           appropriately in unloadPage(   ) or somewhere else. The PageInfo::userData member is
           useful here since you can point it to your data structures for later reference in
           unloadPage(   ).
          
           \warning Do not ever add an entity outside of the given region,   otherwise this may
           crash the program (  depending on how the current page types handle this situation ).
          
           \see PagedGeometry::addDetailLevel(   ) for information about page types.
           */
           virtual void loadPage(  PageInfo &page ) = 0;
          
           /**
           \brief This may be overridden (  optional ) to unload custom data associated with a page.
           \param page A PageInfo variable which includes boundary information and other useful values.
          
           During a PageLoader::loadPage(   ) call,   you are supposed to add entities by calling
           the addEntity(   ) member function. In case you created anything else (  particle systems,  
           sound effects,   etc. ),   this function gives you a chance to delete them along with
           the rest of the entities added with addEntity(   ).
          
           \note Entities added with addEntity(   ) will automatically be deleted after this
           function returns,   so you don't need to worry about them.
          
           In most cases you won't need to implement this function in your page loader at all,  
           since addEntity(   ) is usually all that is used.
           */
           virtual void unloadPage(  const PageInfo &page ) {}
          
           /**
           \brief Provides a method for you to perform per-frame tasks for your PageLoader if overridden (  optional )
          
           frameUpdate(   ) is completely optional,   and unnecessary in most cases. However,   if you ever
           need to update anything in your PageLoader per-frame,   this function is here for that purpose.
          
           \warning This function is actually called every time PagedGeometry::update(   ) is called,   so if the
           application doesn't call PagedGeometry::update(   ) as it should,   this function will not be called
           either.
          
           \note frameUpdate(   ) will be called after PagedGeometry::update(   ) is called but before any
           GeometryPage's are actually loaded/unloaded for the frame.
           */
           virtual void frameUpdate(   ) {}
          
           /**
           \brief Destructor
           This is defined here so the destructors of derived classes are called properly. Whether
           or not you actually implement a destructor is up to you.
           */
           virtual ~PageLoader(   ) {}
          
          protected:
           /**
           \brief Call this from loadPage(   ) to add an entity to the page being loaded.
           \param ent The entity to add. You may add the same entity multiple times.
           \param position The position where the entity will be placed.
           \param rotation The rotation to apply to the entity.
           \param scale The scale to apply to the entity.
           \param color The color to apply to the whole entity
          
           \note This copies the entity into the page,   so don't make copies of the entity
           yourself; you may simply add the same entity over and over again. You are also
           free to destroy any entities you used when you are finished adding them.
          
           \warning This does not double-check whether or not your entity is within the proper
           boundaries (  for better performance ),   so be careful not to add entities out of bounds.
           Depending on what current page types are being used,   an out-of-bounds entity could
           cause your program to crash.
          
           \see PagedGeometry::addDetailLevel(   ) for information about page types.
           */
           void addEntity(  Ogre::Entity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE,   const Ogre::ColourValue &color = Ogre::ColourValue::White )
           {
           geomPage->addEntity(  ent,   position,   rotation,   scale,   color );
           geomPage->addEntityToBoundingBox(  ent,   position,   rotation,   scale );
           }
          
          private:
           friend class GeometryPageManager;
          
           //Do NOT modify or use this variable - it is used internally by addEntity(   )
           GeometryPage *geomPage;
          };
          
          
          
          //-------------------------------------------------------------------------------------
          /**
          \brief Manages the rendering of geometry for a detail level type.
          
          \warning This class is used internally by PagedGeometry,   and in most cases you should
          ignore it completely. However,   this does provide some advanced capabilities such as
          modifying the near and far view ranges,   which may come in handy.
          
          This class manages pages of geometry,   cacheing,   deleting,   etc. them as necessary.
          It analyzes the motion of the camera to determine how fast pages need to be cached,  
          and deletes obsolete pages which have been invisible for a certain amount of time.
          
          When you call PagedGeometry::addDetailLevel(   ),   a GeometryPageManager is created to
          manage the new detail level. addDetailLevel(   ) returns a pointer to this page manager,  
          allowing you access to some useful functions,   documented below.
          
          \note Some functions (  marked by "DO NOT USE" in the documentation ) should never be
          called by you. Only the internal processes of PagedGeometry can safely use these
          functions,   so be careful. Using these functions will cause unpredictable results.
          */
          class GeometryPageManager
          {
          public:
           /** \brief A std::list of pointers to geometry pages */
           typedef std::list<GeometryPage*> TPGeometryPages;
          
           /** \brief Internal function - DO NOT USE */
           GeometryPageManager(  PagedGeometry *mainGeom );
          
           /** \brief Internal function - DO NOT USE */
           ~GeometryPageManager(   );
          
           /**
           \brief Sets the near viewing range of this page manager.
           \param nearRange The distance where this page manager starts displaying geometry.
          
           All geometry displayed by this page manager is confined within a certain radius
           gap from the camera. This function sets the closest distance geometry is allowed
           near the camera.
           */
           inline void setNearRange(  Ogre::Real nearRange )
           {
           nearDist = nearRange;
           nearDistSq = nearDist * nearDist;
           }
          
           /**
           \brief Sets the far viewing range of this page manager.
           \param farRange The distance where this page manager stops displaying geometry.
          
           All geometry displayed by this page manager is confined within a certain radius
           gap from the camera. This function sets the farthest distance geometry is allowed
           from the camera.
           */
           inline void setFarRange(  Ogre::Real farRange )
           {
           farDist = farRange;
           farDistSq = farDist * farDist;
          
           farTransDist = farDist + fadeLength;
           farTransDistSq = farTransDist * farTransDist;
           }
          
           /**
           \brief Gets the near viewing range of this page manager.
           \returns The near viewing range of this page manager.
          
           \see setNearRange(   ) for more info about the near viewing range.
           */
           inline Ogre::Real getNearRange(   ) const
           {
           return nearDist;
           }
          
           /**
           \brief Gets the far viewing range of this page manager.
           \returns The far viewing range of this page manager.
          
           \see setFarRange(   ) for more info about the near viewing range.
           */
           inline Ogre::Real getFarRange(   ) const
           {
           return farDist;
           }
          
           /**
           \brief Customizes the cache behaviour (  advanced ).
           \param maxCacheInterval The maximum period of time (  milliseconds ) before another page is loaded.
           \param inactivePageLife The maximum period of time (  milliseconds ) a inactive (  invisible ) page
           is allowed to stay loaded.
          
           The GeometryPageManager automatically determines how fast pages should be cached to keep
           everything running as smooth as possible,   but there are a few options that are adjustable.
           This function allows you to adjust these variables to fine-tune cache performance.
          
           The maxCacheInterval is basically a minimum rate at which pages are cached. Normally,   a stopped
           camera would cause the cache rate prediction algorithm to say 0 pages-per-second must be cached.
           However,   this is not optimal,   since idle time should be taken advantage of to finish loading.
           By adjusting this value,   you can set how much caching you want going on when the camera is
           stopped or moving very slowly.
          
           The inactivePageLife allows you to set how long inactive pages remain in memory. An inactive page
           is one that is out of the cache range and may not be immediately needed. By allowing these pages
           to remain in memory for a short period of time,   the camera can return to it's previous position
           with no need to reload anything.
          
           \note Even with large inactivePageLife values,   pages may be unloaded if the camera moves far enough
           from them,   so setting extremely high inactivePageLife values won't result in massive memory usage.
           */
           inline void setCacheSpeed(  unsigned long maxCacheInterval = 200,   unsigned long inactivePageLife = 2000 )
           {
           GeometryPageManager::maxCacheInterval = maxCacheInterval;
           GeometryPageManager::inactivePageLife = inactivePageLife;
           }
          
           inline void setTransition(  Ogre::Real transitionLength )
           {
           if (  transitionLength > 0 ) {
           //Setup valid transition
           fadeLength = transitionLength;
           fadeLengthSq = fadeLength * fadeLength;
           fadeEnabled = true;
           } else {
           //<= 0 indicates disabled transition
           fadeLength = 0;
           fadeLengthSq = 0;
           fadeEnabled = false;
           }
          
           farTransDist = farDist + fadeLength;
           farTransDistSq = farTransDist * farTransDist;
           }
          
           inline Ogre::Real getTransition(   ) const
           {
           return fadeLength;
           }
          
          
           /** \brief Internal function - DO NOT USE */
           inline TPGeometryPages getLoadedPages(   ) const { return loadedList; }
          
           /** \brief Internal function - DO NOT USE */
           template <class PageType> void initPages(  const TBounds& bounds );
          
           /** \brief Internal function - DO NOT USE */
           void update(  unsigned long deltaTime,   Ogre::Vector3 &camPos,   Ogre::Vector3 &camSpeed,   bool &enableCache,   GeometryPageManager *prevManager );
          
           /** \brief Internal function - DO NOT USE */
           void reloadGeometry(   );
          
           /** \brief Internal function - DO NOT USE */
           void reloadGeometryPage(  const Ogre::Vector3 &point );
          
          private:
           PagedGeometry *mainGeom;
          
           //geomGrid is a 2D array storing all the GeometryPage instances managed by this object.
           GeometryPage **geomGrid; //A dynamic 2D array of pointers (  2D grid of GeometryPage's )
           GeometryPage **scrollBuffer; //A dynamic 1D array of pointers (  temporary GeometryPage's used in scrolling geomGrid )
           int geomGridX,   geomGridZ; //The dimensions of the dynamic array
           TBounds gridBounds; //Current grid bounds
          
           //Fade transitions
           Ogre::Real fadeLength,   fadeLengthSq;
           bool fadeEnabled;
          
           //Inline function used to get geometry page tiles
           inline GeometryPage *_getGridPage(  const int x,   const int z )
           {
           #ifdef _DEBUG
           if(  x >= geomGridX || z >= geomGridZ  )
           OGRE_EXCEPT(  Ogre::Exception::ERR_INVALIDPARAMS,  
           "Grid dimension is out of bounds",  
           "GeometryPageManager::_getGridPage(   )" );
           #endif
          
           return geomGrid[z * geomGridX + x];
           }
           inline void _setGridPage(  const int x,   const int z,   GeometryPage *page )
           {
           #ifdef _DEBUG
           if(  x >= geomGridX || z >= geomGridZ  )
           OGRE_EXCEPT(  Ogre::Exception::ERR_INVALIDPARAMS,  
           "Grid dimension is out of bounds",  
           "GeometryPageManager::_setGridPage(   )" );
           #endif
          
           geomGrid[z * geomGridX + x] = page;
           }
          
           //Utility functions for loading/unloading geometry pages (  see source for detailed descriptions )
           void _loadPage(  GeometryPage *page );
           void _unloadPage(  GeometryPage *page );
           void _unloadPageDelayed(  GeometryPage *page );
          
           //Utility function for scrolling pages in the grid by the given amount
           void _scrollGridPages(  int shiftX,   int shiftZ );
          
          
           //Timer counting how long it has been since the last page has been cached
           unsigned long cacheTimer;
          
           TPGeometryPages pendingList; //Pages of geometry to be loaded
           TPGeometryPages loadedList; //Pages of geometry already loaded
          
           //Cache settings
           unsigned long maxCacheInterval;
           unsigned long inactivePageLife;
          
           //Near and far visibility ranges for this type of geometry
           Ogre::Real nearDist,   nearDistSq;
           Ogre::Real farDist,   farDistSq;
           Ogre::Real farTransDist,   farTransDistSq; //farTransDist = farDist + fadeLength
          };
          
          
          
          //-------------------------------------------------------------------------------------
          
          template <class PageType> inline GeometryPageManager* PagedGeometry::addDetailLevel(  Ogre::Real maxRange,   Ogre::Real transitionLength )
          {
           //Create a new page manager
           GeometryPageManager *mgr = new GeometryPageManager(  this );
          
           //If vertex shaders aren't supported,   don't use transitions
           Ogre::Root *root = root->getSingletonPtr(   ); //Work-around for Linux compiler bug
           if (  !root->getRenderSystem(   )->getCapabilities(   )->hasCapability(  Ogre::RSC_VERTEX_PROGRAM ) )
           transitionLength = 0;
          
           //Add it to the list (  also initializing maximum viewing distance )
           _addDetailLevel(  mgr,   maxRange,   transitionLength );
          
           //And initialize the paged (  dependent on maximum viewing distance )
           mgr->initPages<PageType>(  getBounds(   ) );
          
           return mgr;
          }
          
          template <class PageType> inline void GeometryPageManager::initPages(  const TBounds& bounds )
          {
           // Calculate grid size,   if left is Real minimum,   it means that bounds are infinite
           // scrollBuffer is used as a flag. If it is allocated than infinite bounds are used
           // !!! Two cases are required because of the way scrolling is implemented
           // if it is redesigned it would allow to use the same functionality.
           if(  bounds.width(   ) < 0.00001 )
           {
           // In case of infinite bounds bounding rect needs to be calculated in a different manner,   since
           // it represents local bounds,   which are shifted along with the player's movements around the world.
           geomGridX = (  2 * farTransDist / mainGeom->getPageSize(   ) ) + 4;
           gridBounds.top = 0;
           gridBounds.left = 0;
           gridBounds.right = geomGridX * mainGeom->getPageSize(   );
           gridBounds.bottom = geomGridX * mainGeom->getPageSize(   );
           // Allocate scroll buffer (  used in scrolling the grid )
           scrollBuffer = new GeometryPage *[geomGridX];
          
           //Note: All this padding and transition preparation is performed because even in infinite
           //mode,   a local grid size must be chosen. Unfortunately,   this also means that view ranges
           //and transition lengths cannot be exceeded dynamically with set functions.
           }
           else
           {
           //Bounded mode
           gridBounds = bounds;
           geomGridX = (  gridBounds.width(   ) / mainGeom->getPageSize(   ) );
           }
           geomGridZ = geomGridX; //Note: geomGridX == geomGridZ; Need to merge.
          
          
           //Allocate grid array
           geomGrid = new GeometryPage *[geomGridX * geomGridZ];
          
          
           //Create GeometryPage's
           int offsetx = Ogre::Math::Floor(  gridBounds.left / mainGeom->getPageSize(   ) );
           int offsetz = Ogre::Math::Floor(  gridBounds.top / mainGeom->getPageSize(   ) );
           for (  int x = 0; x < geomGridX; ++x )
           {
           for (  int z = 0; z < geomGridZ; ++z )
           {
           GeometryPage* page = new PageType(   );
           page->init(  mainGeom );
           // 0,  0 page is located at (  gridBounds.left,  gridBounds.top ) corner of the bounds
           page->_centerPoint.x = (  (  x + 0.5f ) * mainGeom->getPageSize(   ) ) + gridBounds.left;
           page->_centerPoint.z = (  (  z + 0.5f ) * mainGeom->getPageSize(   ) ) + gridBounds.top;
           page->_centerPoint.y = 0.0f;
           page->_xIndex = x + offsetx;
           page->_zIndex = z + offsetz;
           page->_inactiveTime = 0;
           page->_loaded = false;
           page->_needsUnload = false;
           page->_pending = false;
           page->_visible = false;
           page->_userData = 0;
           page->_fadeEnable = false;
          
           page->clearBoundingBox(   );
          
           _setGridPage(  x,   z,   page );
           }
           }
          }
          }
          #endif

./components/ogre/environment/pagedgeometry/include/PropertyMaps.h

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
          1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
          2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
          3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          #ifndef __PropertyMaps_H__
          #define __PropertyMaps_H__
          
          #include "OgrePrerequisites.h"
          #include "OgrePixelFormat.h"
          #include "OgreColourValue.h"
          #include "OgreRoot.h"
          #include "OgreRenderSystem.h"
          
          namespace PagedGeometry {
          
          /** \brief Specifies which color channel(  s ) to extract from an image */
          enum MapChannel {
           /// Use only the image's red color channel
           CHANNEL_RED,  
           /// Use only the image's green color channel
           CHANNEL_GREEN,  
           /// Use only the image's blue color channel
           CHANNEL_BLUE,  
           /// Use only the image's alpha channel
           CHANNEL_ALPHA,  
           /// Use the image's full RGB color information
           CHANNEL_COLOR
          };
          
          /** \brief Specifies the filtering method used to interpret property maps */
          enum MapFilter {
           /// Use no filtering - fast,   but may appear blocky
           MAPFILTER_NONE,  
           /// Use bilinear filtering - slower,   but will appear less blocky
           MAPFILTER_BILINEAR
          };
          
          /** \brief A 2D greyscale image that is assigned to a certain region of your world to represent density levels.
          
          This class is used by various PagedLoader's internally,   so it's not necessary to learn anything about this class.
          However,   you can achieve more advanced effects through the DensityMap class interface than you can with the standard
          GrassLayer density map functions,   for example.
          
          Probably the most useful function in this class is getPixelBox(   ),   which you can use to directly manipulate the
          density map pixels in real-time. */
      52  class DensityMap
          {
          public:
      55   static DensityMap *load(  const Ogre::String &fileName,   MapChannel channel = CHANNEL_COLOR );
      56   static DensityMap *load(  Ogre::Texture *texture,   MapChannel channel = CHANNEL_COLOR );
      57   void unload(   );
          
           /** \brief Sets the filtering mode used for this density map
          
           This function can be used to set the filtering mode used for your density map. By default,  
           bilinear filtering is used (  MAPFILTER_BILINEAR ). If you disable filtering by using MAPFILTER_NONE,  
           the resulting effect of the density map may look square and blocky,   depending on the resolution of
           the map.
          
           MAPFILTER_NONE is slightly faster than MAPFILTER_BILINEAR,   so use it if you don't notice any
           considerable blockyness. */
      68   void setFilter(  MapFilter filter ) { this->filter = filter; }
          
           /** \brief Returns the filtering mode being used for this density map */
      71   MapFilter getFilter(   ) { return filter; }
          
           /** \brief Sets the boundaries that this density map affects
          
           The boundary given to this function defines the area where this density map takes effect.
           Normally this is set to your terrain's bounds so the density map is aligned
           to your heightmap,   but you could apply it anywhere you want. */
      78   void setMapBounds(  const Ogre::TRect<Ogre::Real> &bounds ) { mapBounds = bounds; }
          
           /** \brief Returns the map bounds for this density map,   as set by setMapBounds(   ) */
      81   Ogre::TRect<Ogre::Real> getMapBounds(   ) { return mapBounds; }
          
           /** \brief Gets a pointer to the pixel data of the density map
          
           You can use this function to access the pixel data of the density map. The PixelBox
           returned is an image in PF_BYTE_L (  aka. PF_L8 ) byte format. You can modify this image
           any way you like in real-time,   so long as you do not change the byte format.
          
           This function is useful in editors where the density map needs to be changed dynamically.
           Note that although you can change this map in real-time,   the changes won't be uploaded to your
           video card until you call PagedGeometry::reloadGeometry(   ). If you don't,   the grass you see
           will remain unchanged. */
      93   Ogre::PixelBox getPixelBox(   )
           {
           assert(  pixels );
           return *pixels;
           }
          
           /** \brief Gets the density level at the specified position */
     100   inline float getDensityAt(  float x,   float z )
           {
           if (  filter == MAPFILTER_NONE )
           return _getDensityAt_Unfiltered(  x,   z );
           else
           return _getDensityAt_Bilinear(  x,   z );
           }
          
     108   float _getDensityAt_Unfiltered(  float x,   float z );
     109   float _getDensityAt_Bilinear(  float x,   float z );
          
          private:
     112   DensityMap(  Ogre::Texture *texture,   MapChannel channel );
     113   ~DensityMap(   );
          
     115   static std::map<Ogre::String,   DensityMap*> selfList;
     116   Ogre::String selfKey;
           unsigned int refCount;
          
           MapFilter filter;
     120   Ogre::PixelBox *pixels;
     121   Ogre::TRect<Ogre::Real> mapBounds;
          };
          
          /** \brief A 2D greyscale image that is assigned to a certain region of your world to represent color levels.
          
          This class is used by various PagedLoader's internally,   so it's not necessary to learn anything about this class.
          However,   you can achieve more advanced effects through the ColorMap class interface than you can with the standard
          GrassLayer color map functions,   for example.
          
          Probably the most useful function in this class is getPixelBox(   ),   which you can use to directly manipulate the
          color map pixels in real-time. */
     132  class ColorMap
          {
          public:
     135   static ColorMap *load(  const Ogre::String &fileName,   MapChannel channel = CHANNEL_COLOR );
     136   static ColorMap *load(  Ogre::Texture *texture,   MapChannel channel = CHANNEL_COLOR );
     137   void unload(   );
          
           /** \brief Sets the filtering mode used for this color map
          
           This function can be used to set the filtering mode used for your color map. By default,  
           bilinear filtering is used (  MAPFILTER_BILINEAR ). If you disable filtering by using
           MAPFILTER_NONE,   the resulting coloration may appear slightly pixelated,   depending on the
           resolution of the map.
          
           MAPFILTER_NONE is slightly faster than MAPFILTER_BILINEAR,   so use it if you don't notice any
           considerable pixelation. */
     148   void setFilter(  MapFilter filter ) { this->filter = filter; }
          
           /** \brief Returns the filtering mode being used for this color map */
     151   MapFilter getFilter(   ) { return filter; }
          
           /** \brief Sets the boundaries that this color map affects
          
           The boundary given to this function defines the area where this color map takes effect.
           Normally this is set to your terrain's bounds so the color map is aligned
           to your heightmap,   but you could apply it anywhere you want. */
     158   void setMapBounds(  const Ogre::TRect<Ogre::Real> &bounds ) { mapBounds = bounds; }
          
           /** \brief Returns the map bounds for this color map,   as set by setMapBounds(   ) */
     161   Ogre::TRect<Ogre::Real> getMapBounds(   ) { return mapBounds; }
          
           /** \brief Gets a pointer to the pixel data of the color map
          
           You can use this function to access the pixel data of the color map. The PixelBox
           returned is an image in PF_A8R8G8B8 format when running with DirectX,   and PF_A8B8G8R8
           when running with OpenGL. You can modify this image any way you like in
           real-time,   so long as you do not change the byte format.
          
           This function is useful in editors where the color map needs to be changed dynamically.
           Note that although you can change this map in real-time,   the changes won't be uploaded to your
           video card until you call PagedGeometry::reloadGeometry(   ). If you don't,   the grass you see
           will remain unchanged. */
     174   Ogre::PixelBox getPixelBox(   )
           {
           assert(  pixels );
           return *pixels;
           }
          
           /** \brief Gets the color value at the specified position
          
           A RenderSystem-specific 32-bit packed color value is used,   so it can be fed directly to
           the video card. */
     184   inline Ogre::uint32 getColorAt(  float x,   float z )
           {
           if (  filter == MAPFILTER_NONE )
           return _getColorAt(  x,   z );
           else
           return _getColorAt_Bilinear(  x,   z );
           }
          
           /** \brief Gets the color value at the specified position
          
           The unpacks the 32-bit color value into an Ogre::ColourValue and returns it. */
     195   inline Ogre::ColourValue getColorAt_Unpacked(  float x,   float z )
           {
           Ogre::uint32 c;
          
           if (  filter == MAPFILTER_NONE )
           c = _getColorAt(  x,   z );
           else
           c = _getColorAt_Bilinear(  x,   z );
          
           Ogre::Real r,   g,   b,   a;
           static Ogre::VertexElementType format = Ogre::Root::getSingleton(   ).getRenderSystem(   )->getColourVertexElementType(   );
           if (  format == Ogre::VET_COLOUR_ARGB ){
           b = (  (  c ) & 0xFF ) / 255.0f;
           g = (  (  c >> 8 ) & 0xFF ) / 255.0f;
           r = (  (  c >> 16 ) & 0xFF ) / 255.0f;
           a = (  (  c >> 24 ) & 0xFF ) / 255.0f;
           } else {
           r = (  (  c ) & 0xFF ) / 255.0f;
           g = (  (  c >> 8 ) & 0xFF ) / 255.0f;
           b = (  (  c >> 16 ) & 0xFF ) / 255.0f;
           a = (  (  c >> 24 ) & 0xFF ) / 255.0f;
           }
          
           return Ogre::ColourValue(  r,   g,   b,   a );
           }
          
          private:
     222   ColorMap(  Ogre::Texture *map,   MapChannel channel );
     223   ~ColorMap(   );
          
     225   static std::map<Ogre::String,   ColorMap*> selfList;
     226   Ogre::String selfKey;
           unsigned int refCount;
          
           //Directly interpolates two uint32 colors
     230   Ogre::uint32 _interpolateColor(  Ogre::uint32 color1,   Ogre::uint32 color2,   float ratio,   float ratioInv );
          
           //Returns the color map value at the given location
     233   Ogre::uint32 _getColorAt(  float x,   float z );
          
           //Returns the color map value at the given location with bilinear filtering
     236   Ogre::uint32 _getColorAt_Bilinear(  float x,   float z );
          
           MapFilter filter;
     239   Ogre::PixelBox *pixels;
     240   Ogre::TRect<Ogre::Real> mapBounds;
          };
          
          }
          
          #endif

./components/ogre/environment/pagedgeometry/include/StaticBillboardSet.h

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //StaticBillboardSet.h
          //Provides a method of displaying billboards faster than Ogre's built-in BillboardSet
          //functions by taking advantage of the static nature of tree billboards (  note:
          //StaticBillboardSet does not allow billboards to be moved or deleted individually in
          //real-time )
          //-------------------------------------------------------------------------------------
          
          #ifndef __StaticBillboardSet_H__
          #define __StaticBillboardSet_H__
          
          #include "OgrePrerequisites.h"
          #include "OgreRoot.h"
          #include "OgreRenderSystem.h"
          #include "OgreVector3.h"
          #include "OgreMesh.h"
          #include "OgreMaterial.h"
          #include "OgreBillboard.h"
          #include "OgreBillboardSet.h"
          #include "OgreMaterialManager.h"
          #include "OgreSceneNode.h"
          #include "OgreStringConverter.h"
          
          namespace PagedGeometry {
          
      35  class SBMaterialRef;
          typedef std::map<Ogre::Material*,   SBMaterialRef*> SBMaterialRefList;
          
          
          //Internal class - do not use
      40  class StaticBillboard
          {
          public:
      43   Ogre::Vector3 position;
      44   Ogre::uint32 color;
           float xScale,   yScale;
      46   Ogre::uint16 texcoordIndexU,   texcoordIndexV;
          };
          
          /** Different methods used to render billboards. This can be supplied as a parameter
          to the StaticBillboardSet constructor to manually select how you want billboards
          rendered (  although in almost all cases BB_METHOD_ACCELERATED is the best choice ).*/
          typedef enum BillboardMethod {
           /** This mode accelerates the performance of billboards by using vertex shaders
           to keep billboards facing the camera. Note: If the computer's hardware is not
           capable of vertex shaders,   it will automatically fall back to BB_METHOD_COMPATIBLE
           mode.*/
           BB_METHOD_ACCELERATED = 1,  
          
           /** Unlike BB_METHOD_ACCELERATED,   this does not use vertex shaders to align
           billboards to the camera. This is more compatible with old video cards,  
           although it can result in poor performance with high amounts of billboards.*/
           BB_METHOD_COMPATIBLE = 0,  
          };
          
          /**
          \brief A faster alternative to Ogre's built-in BillboardSet class.
          
          This class provides a method of displaying billboards faster than Ogre's built-in
          BillboardSet functions by taking advantage of the static nature of tree billboards.
          
          However,   if your video card does not support vertex shaders,   using this class over
          Ogre's built-in Billboard class will have no performance benefit.
          
          \note StaticBillboardSet does not allow billboards to be moved or deleted
          individually in real-time
          */
      77  class StaticBillboardSet
          {
          public:
           /**
           \brief Initializes a StaticBillboardSet object.
           \param mgr The SceneManager to be used to display the billboards.
           \param method The method used when rendering billboards. See the BillboardMethod
           documentation for more information. In almost all cases,   this should be set to
           BB_METHOD_ACCELERATED for optimal speed and efficiency.
           */
      87   StaticBillboardSet(  Ogre::SceneManager *mgr,   Ogre::SceneNode *rootSceneNode,   BillboardMethod method = BB_METHOD_ACCELERATED );
      88   ~StaticBillboardSet(   );
          
           /**
           \brief Adds a billboard to the StaticBillboardSet at the specified position.
           \param position The desired position of the billboard.
           \param xScale The width scale of the billboard.
           \param yScale The height scale of the billboard.
           \param texcoordIndex The texture tile this billboard will use. This value shoud be
           0..n,   where n is the number of slices set with setTextureSlices(   )
          
           The texcoordIndex option is only applicable if you have used setTextureSlices(   )
           to divide the applied material into a number of horizontal segments. texcoordIndex selects
           which segment is applied to the billboard as a texture.
          
           \note Any billboards created will not appear in the scene until you call build(   )
           */
     104   inline void createBillboard(  const Ogre::Vector3 &position,   float xScale = 1.0f,   float yScale = 1.0f,   const Ogre::ColourValue &color = Ogre::ColourValue::White,   Ogre::uint16 texcoordIndexU = 0,   Ogre::uint16 texcoordIndexV = 0 )
           {
           if (  renderMethod == BB_METHOD_ACCELERATED ){
           StaticBillboard *bb = new StaticBillboard;
           billboardBuffer.push_back(  bb );
          
           bb->position = position;
           bb->xScale = xScale;
           bb->yScale = yScale;
           bb->texcoordIndexU = texcoordIndexU;
           bb->texcoordIndexV = texcoordIndexV;
          
           Ogre::uint32 packedColor;
           Ogre::Root::getSingleton(   ).getRenderSystem(   )->convertColourValue(  color,   &packedColor );
           bb->color = packedColor;
           } else {
           Ogre::Billboard *bb = fallbackSet->createBillboard(  position );
           bb->setDimensions(  xScale,   yScale );
           bb->setTexcoordRect(  texcoordIndexU * uFactor,   texcoordIndexV * vFactor,  
           (  texcoordIndexU + 1 ) * uFactor,   (  texcoordIndexV + 1 ) * vFactor );
          
           bb->setColour(  color );
           }
           }
          
           /**
           \brief Sets the billboard's origin (  pivotal point )
          
           This function can be used to set what part of the billboard image is considered the
           origin,   or "center". By default,   the center of the image is used,   so billboards will
           pivot around the center and positioning a billboard will place it's center at the desired
           location. Other origins,   like BBO_BOTTOM_CENTER are good for trees,   etc. BBO_CENTER is
           used by default.
           */
     138   void setBillboardOrigin(  Ogre::BillboardOrigin origin );
          
           /** Returns the current billboard origin
          
           This returns the current billboard origin as set by setBillboardOrigin(   ).
           */
     144   inline Ogre::BillboardOrigin getBillboardOrigin(   )
           {
           return bbOrigin;
           }
          
           /**
           \brief Returns the method used to render billboards
          
           The billboard render method is set in the constructor. See the BillboardMethod enum
           documentation for more information on billboard render methods.
           */
     155   inline BillboardMethod getRenderMethod(   )
           {
           return renderMethod;
           }
          
           /**
           \brief Sets whether or not this StaticBillboardSet will be rendered.
           \param visible The desired visibility state of the StaticBillboardSet (  true/false )
           */
     164   inline void setVisible(  bool visible )
           {
           if (  StaticBillboardSet::visible != visible ){
           StaticBillboardSet::visible = visible;
           node->setVisible(  visible );
           }
           }
          
           /**
           \brief Enables/disables distance fade-out for this billboard set
           \param enabled Whether or not to enable fading
           \param visibleDist The distance where billboards will be fully opaque (  alpha 1 )
           \param invisibleDist The distance where billboards will be invisible (  alpha 0 )
          
           You can use this function to enable distance based alpha fading,   so billboards will
           smoothly fade out into the distance. Note that the fading is performed 2-dimensionally,  
           which means height is not taken into account when fading - only xz distances. This works
           well with flat terrain maps,   but may not be well suited for spherical worlds.
          
           The distance ranges given specify how the final alpha values should be calculated -
           billboards at visibleDist will have alpha values of 1,   and geometry at invisibleDist
           will have alpha values of 0.
          
           \note invisibleDist may be greater than or less than visibleDist,   depending on
           whether the geometry is fading out or in to the distance.
          
           \note setFade(   ) only works in BB_MODE_ACCELERATED mode.
           */
     192   void setFade(  bool enabled,   Ogre::Real visibleDist,   Ogre::Real invisibleDist );
          
           /**
           \brief Performs final steps required for the created billboards to appear in the scene.
          
           Until this is called,   any billboards created with createBillboard(   ) will not appear.
           */
     199   void build(   );
          
           /**
           \brief Deletes all billboards from the scene.
          
           The only way to delete a billboard in a StaticBillboardSet is to delete them all,  
           which this function does.
           */
     207   void clear(   );
          
           /**
           \brief Applies a material to the billboards in this set.
           \param materialName The name of the material to apply to this StaticBillboardSet.
          
           This may actually modify the material to include a vertex shader (  which
           is used to keep the billboards facing the camera ).
           */
     216   void setMaterial(  const Ogre::String &materialName );
          
           /**
           \brief Sets how many horizontal slices and vertical stacks the currently applied material is using.
           \param stacks The number of vertical stacks.
           \param slices The number of horizontal slices.
          
           If the applied material contains multiple images all merged together into a grid
           you can use this function to gain access to the individual images. Simply set how
           many tiles are contained within the material horizontally and vertically,   and use
           the texcoordIndexU and texcoordIndexV parameters of createBillboard(   ) to specify
           which image is to be used for the billboard.
           */
     229   void setTextureStacksAndSlices(  Ogre::uint16 stacks,   Ogre::uint16 slices );
          
           /**
           \brief Manually updates all StaticBillboardSet objects for a frame.
          
           \note If you are using root->startRendering(   ) or root->renderOneFrame(   ) to update
           your scene,   there is no need to use this function at all. Doing so would be redundant
           and ineffient,   as it will be called automatically in this case.
          
           However,   if you update all your render targets yourself,   you will have to call this
           manually per frame from your program loop. If updateAll(   ) doesn't get called one way
           or another,   your billboards will not be updated to face the camera.
           */
     242   static void updateAll(  const Ogre::Vector3 &cameraDirection );
          
          private:
     245   Ogre::SceneManager *sceneMgr;
          
     247   bool visible;
     248   Ogre::SceneNode *node;
     249   Ogre::Entity *entity;
     250   Ogre::MeshPtr mesh;
     251   Ogre::SubMesh *subMesh;
     252   Ogre::String entityName;
          
     254   Ogre::MaterialPtr materialPtr,   fadeMaterialPtr;
           float uFactor,   vFactor;
          
     257   std::vector<StaticBillboard*> billboardBuffer;
          
           BillboardMethod renderMethod;
     260   Ogre::BillboardSet *fallbackSet;
          
     262   Ogre::BillboardOrigin bbOrigin;
          
     264   Ogre::MaterialPtr getFadeMaterial(  Ogre::Real visibleDist,   Ogre::Real invisibleDist );
           typedef std::map<Ogre::String,   Ogre::MaterialPtr> FadedMaterialMap;
     266   static FadedMaterialMap fadedMaterialMap;
     267   bool fadeEnabled;
     268   Ogre::Real fadeVisibleDist,   fadeInvisibleDist;
          
           static unsigned int selfInstances;
          
           static unsigned long GUID;
     273   static inline Ogre::String getUniqueID(  const Ogre::String &prefix )
           {
           return prefix + Ogre::StringConverter::toString(  ++GUID );
           }
          };
          
          
          
          //-------------------------------------------------------------------------------------
          
          //SBMaterialRef::addMaterialRef(   ) and ::removeMaterialRef(   ) are used to keep track
          //of all the materials in use by the billboard system. This is necessary when keeping
          //the materials' vertex shaders up-to-date. To get the list of all materials in use,  
          //use getList(   ).
     287  class SBMaterialRef
          {
          public:
     290   static void addMaterialRef(  const Ogre::MaterialPtr &matP,   Ogre::BillboardOrigin o );
     291   static void removeMaterialRef(  const Ogre::MaterialPtr &matP );
          
     293   inline static SBMaterialRefList &getList(   ) { return selfList; }
          
     295   inline Ogre::Material *getMaterial(   ) { return material; }
     296   inline Ogre::BillboardOrigin getOrigin(   ) { return origin; }
          
          private:
     299   SBMaterialRef(  Ogre::Material *mat,   Ogre::BillboardOrigin o );
          
     301   static SBMaterialRefList selfList;
          
           unsigned int refCount;
     304   Ogre::Material *material;
     305   Ogre::BillboardOrigin origin;
          };
          }
          
          #endif

./components/ogre/environment/pagedgeometry/include/TreeLoader2D.h

          /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          #ifndef __TreeLoader2D_H__
          #define __TreeLoader2D_H__
          
          #include "PagedGeometry.h"
          #include "PropertyMaps.h"
          
          #include "OgrePrerequisites.h"
          
          namespace PagedGeometry {
          
      21  class TreeIterator3D;
      22  class TreeIterator2D;
          
          /** \brief A PageLoader-derived object you can use with PagedGeometry to easily place trees on your terrain.
          
          \note TreeLoader2D is derived from PageLoader - this implementation provides you with an easy way
          to add trees to your scene. Remember that if the included PageLoader's aren't enough,   you can easily
          create your own to load geometry any way you want. You could even modify existing an PageLoader
          to suit your needs.
          
          Using a TreeLoader is simple - simply create an instance,   attach it to your PagedGeometry object
          with PagedGeometry::setPageLoader(   ),   and add your trees.
          
          To add trees,   just call TreeLoader2D::addTree(   ),   supplying the appropriate parameters. You may notice that
          TreeLoader2D restricts trees to uniform scale,   yaw rotation,   and a position value with no vertical component.
          This is done to conserve memory; TreeLoader2D packs trees into memory as effeciently as possible,   taking only
          6 bytes per tree. This means 1 million trees only takes 5.72 MB of RAM (  additionally,   adding 1 million trees
          takes less than a second in a release build ).
          
          \note By default,   TreeLoader2D doesn't know what shape your terrain is,   so all trees will be placed
          at 0 height. To inform TreeLoader2D of the shape of your terrain,   you must specify a height function
          that returns the height (  vertical coordinate ) of your terrain at the given coordinates. See the
          TreeLoader2D::setHeightFunction(   ) documentation for more information.
          
          \warning If you attempt to use Ogre's scene queries to get the terrain height,  
          keep in mind that calculating the height of Ogre's built-in terrain this way can
          be VERY slow if not done properly,   and may cause stuttering due to long paging delays.
          
          If the inability to supply a vertical coordinate to addTree(   ) is too limiting,   or you are unable to implement
          a fast enough height function,   please refer to TreeLoader3D. TreeLoader3D allows you to provide full 3D x/y/z
          coordinates,   although 40% more memory is required per tree.
          */
      53  class TreeLoader2D: public PageLoader
          {
          public:
           /** \brief Creates a new TreeLoader2D object.
           \param geom The PagedGeometry object that this TreeLoader2D will be assigned to.
           \param bounds The rectangular boundary in which all trees will be placed. */
      59   TreeLoader2D(  PagedGeometry *geom,   const Ogre::TRect<Ogre::Real> &bounds );
      60   ~TreeLoader2D(   );
          
           /** \brief Adds an entity to the scene with the specified location,   rotation,   and scale.
           \param entity The entity to be added to the scene.
           \param position The desired position of the tree
           \param yaw The desired rotation around the vertical axis in degrees
           \param scale The desired scale of the entity
          
           Trees added with TreeLoader2D are restricted to yaw rotation only,   and uniform scale
           values. This conserves memory by avoiding storage of useless data (  for example,   storing
           the height of each tree when this can be easily calculated from the terrain's shape ).
          
           Unlike TreeLoader3D,   the vertical position of each tree is NOT stored (  therefore
           TreeLoader2D takes less memory than TreeLoader3D ),   but this means you must provide
           a height function with setHeightFunction(   ) in order for TreeLoader2D to be able to
           calculate the desired height values when the time comes. If you do not specify a
           height function,   all trees will appear at 0 height.
          
           \warning By default,   scale values may not exceed 2.0. If you need to use higher scale
           values than 2.0,   use setMaximumScale(   ) to reconfigure the maximum. */
      80   void addTree(  Ogre::Entity *entity,   const Ogre::Vector3 &position,   Ogre::Degree yaw = Ogre::Degree(  0 ),   Ogre::Real scale = 1.0f );
          
           /** \brief Deletes trees within a certain radius of the given coordinates.
           \param position The coordinate of the tree(  s ) to delete
           \param radius The radius from the given coordinate where trees will be deleted
           \param type The type of tree to delete (  optional )
          
           \note If the "type" parameter is set to an entity,   only trees created with that entity
           will be deleted. */
      89   void deleteTrees(  const Ogre::Vector3 &position,   float radius,   Ogre::Entity *type = NULL );
          
           /** \brief Sets the height function used to calculate tree height coordinates
           \param heightFunction A pointer to a height function
           \param userData Optional user data to be supplied to the height function
          
           Unless you want all your trees placed at 0 height,   you need to specify a height function
           so TreeLoader2D will be able to calculate the height coordinate. The height function given
           to setHeightFunction(   ) should use the following prototype (  although you can name the
           function anything you want ):
          
           \code
           Real getHeightAt(  Real x,   Real z,   void *userData );
           \endcode
          
           \note If you're not using the default coordinate system (  where x = right,   z = back ),   the
           x/z parameters will actually be representing the appropriate equivalents.
          
           The userData parameter allows you to include any additional data you want when your height
           function is called,   and is completely optional (  although you can't actually omit it from the
           declaration,   you can ignore it ). Any userData value you choose to supply to setHeightFunction(   )
           will be passed on to your height function every time it is called.
          
           After you've defined a height function,   using setHeightFunction is easy:
          
           \code
           pageLoader2D->setHeightFunction(  &getHeightAt );
           //Or (  if you want to pass additional data on to your height function )...
           pageLoader2D->setHeightFunction(  &getHeightAt,   myUserData );
           \endcode
          
           In most cases,   you may not even need to use the extra "userData" parameter,   but it's there in
           the event that your height function needs extra contextual data.
           */
     123   void setHeightFunction(  Ogre::Real (  *heightFunction )(  Ogre::Real x,   Ogre::Real z,   void *userData ),   void *userData = NULL )
           {
           this->heightFunction = heightFunction;
           heightFunctionUserData = userData;
           }
          
           /** \brief Gets an iterator which can be used to access all added trees.
          
           The returned TreeIterator can be used to iterate through every tree that was added
           to this TreeLoader fairly efficiently.
          
           \see The TreeIterator class documentation for more info.
           */
     136   TreeIterator2D getTrees(   );
          
           /** \brief Sets the color map used to color trees
           \param mapFile The color map image
           \param channel The color channel(  s ) to from the image to use
          
           A color map is simply a texture that allows you to vary the color and shading of trees
           across your world for a more realistic look. For example,   adding a dark spot to the center
           of your color map will make trees near the center of your world look darker.
          
           The channel parameter allows you to extract the color information from the image's
           red,   green,   blue,   alpha,   or color values. For example,   you may store the desired shade of your
           trees in the red channel of an image,   in which case you would use CHANNEL_RED (  when you choose
           a single channel,   it is converted to a greyscale color ). By default,   CHANNEL_COLOR is used,  
           which uses the full color information available in the image. */
     151   void setColorMap(  const Ogre::String &mapFile,   MapChannel channel = CHANNEL_COLOR );
          
           /** \brief Sets the color map used to color trees
          
           Overloaded to accept a Texture object. See the original setColorMap(   ) documentation above
           for more detailed information on color maps.
          
           \note The texture data you provide is copied into RAM,   so you can delete the texture after
           calling this function without risk of crashing. */
     160   void setColorMap(  Ogre::Texture *map,   MapChannel channel = CHANNEL_COLOR );
          
           /** \brief Gets a pointer to the color map being used
          
           You can use this function to access the internal color map object used by the TreeLoader2D.
           Through this object you can directly manipulate the pixels of the color map,   among other
           things.
          
           Note that although you can edit the color map in real-time through this class,   the changes
           won't be uploaded to your video card until you call PagedGeometry::reloadGeometry(   ). If you
           don't,   the colors of the trees you see will remain unchanged. */
     171   ColorMap *getColorMap(   ) { return colorMap; }
          
           /** \brief Sets the filtering mode used for the color map
          
           This function can be used to set the filtering mode used for your tree color map.
           By default,   no filtering is used (  MAPFILTER_NONE ). If you enable bilinear filtering
           by using MAPFILTER_BILINEAR,   the resulting tree coloration may appear more smooth
           (  less pixelated ),   depending on the resolution of your color map.
          
           MAPFILTER_BILINEAR is slightly slowe than MAPFILTER_NONE,   so don't use it unless you notice
           considerable pixelation. */
     182   void setColorMapFilter(  MapFilter filter )
           {
           colorMapFilter = filter;
           if (  colorMap )
           colorMap->setFilter(  colorMapFilter );
           }
          
           /** \brief Sets the maximum tree scale value
          
           When calling addTree(   ) to add trees,   the scale values you are allowed to use are restricted
           to 2.0 maximum by default. With this function,   you can adjust the maximum scale you are allowed
           to use for trees. However,   keep in mind that the higher the maximum scale is,   the less precision
           there will be in storing the tree scales (  since scale values are actually packed into a single byte ).
          
           \warning Be sure to call this before adding any trees - otherwise adjusting this value will cause
           the size of the currently added trees to change. */
     198   void setMaximumScale(  Ogre::Real maxScale )
           {
           maximumScale = maxScale;
           }
          
           /** \brief Gets the maximum tree scale value
           \returns The maximum tree scale value
          
           This function will return the maximum tree scale value as set by setMaximumScale(   ). By
           default this value will be 2.0. */
     208   float getMaximumScale(   )
           {
           return maximumScale;
           }
          
           /** \brief Sets the minimum tree scale value
          
           When calling addTree(   ) to add trees,   the scale values you are allowed to use are restricted
           in the range of 0.0 - 2.0 by default. With this function,   you can adjust the minimum scale you are
           allowed to use for trees. The closer this minimum value is to the maximum tree scale,   the more
           precision there will be when storing trees with addTree(   ).
          
           \warning Be sure to call this before adding any trees - otherwise adjusting this value will cause
           the size of the currently added trees to change. */
     222   void setMinimumScale(  Ogre::Real minScale )
           {
           minimumScale = minScale;
           }
          
           /** \brief Gets the minimum tree scale value
           \returns The minimum tree scale value
          
           This function will return the minimum tree scale value as set by setMinimumScale(   ). By
           default this value will be 0. */
     232   float getMinimumScale(   )
           {
           return minimumScale;
           }
          
     237   void loadPage(  PageInfo &page );
          
          private:
     240   friend class TreeIterator2D;
          
           struct TreeDef
           {
           Ogre::uint16 xPos,   zPos;
           Ogre::uint8 scale,   rotation;
           };
          
           //Information about the 2D grid of pages
           int pageGridX,   pageGridZ;
     250   Ogre::Real pageSize;
     251   Ogre::TRect<Ogre::Real> gridBounds,   actualBounds;
          
     253   Ogre::Real maximumScale,   minimumScale;
          
           //Colormap
     256   ColorMap *colorMap;
           MapFilter colorMapFilter;
          
           //Height data
           Ogre::Real (  *heightFunction )(  Ogre::Real x,   Ogre::Real z,   void *userData ); //Pointer to height function
           void *heightFunctionUserData;
          
           //Misc.
           PagedGeometry *geom;
          
           //A std::map of 2D grid arrays. Each array is the same size (  pageGridX x pageGridZ ),   and
           //contains a std::vector list of trees. Each std::map entry corresponds to a single tree
           //type,   and every tree defined in the std::map entry's grid should be of that tree type.
           std::map<Ogre::Entity*,   std::vector<TreeDef>*> pageGridList;
           typedef std::map<Ogre::Entity*,   std::vector<TreeDef>*>::iterator PageGridListIterator;
           typedef std::pair<Ogre::Entity*,   std::vector<TreeDef>*> PageGridListValue;
          
           inline std::vector<TreeDef> &_getGridPage(  std::vector<TreeDef> *grid,   int x,   int z )
           {
           #ifdef _DEBUG
           if(  x >= pageGridX || z >= pageGridZ  )
           OGRE_EXCEPT(  Ogre::Exception::ERR_INVALIDPARAMS,  
           "Grid dimension is out of bounds",  
           "TreeLoader2D::_getGridPage(   )" );
           #endif
          
           return grid[z * pageGridX + x];
           }
          
           inline void _setGridPage(  std::vector<TreeDef> *grid,   int x,   int z,   const std::vector<TreeDef> &page )
           {
           #ifdef _DEBUG
           if(  x >= pageGridX || z >= pageGridZ  )
           OGRE_EXCEPT(  Ogre::Exception::ERR_INVALIDPARAMS,  
           "Grid dimension is out of bounds",  
           "TreeLoader2D::_getGridPage(   )" );
           #endif
          
     294   grid[z * pageGridX + x] = page;
           }
          };
          
          
          
          //The TreeRef class is used by both TreeLoader2D and TreeLoader3D.
          //This #ifndef makes sure TreeRef isn't declared twice in case both treeloaders are used.
          #ifndef TreeRef_Declared
          #define TreeRef_Declared
          
     305  class TreeRef
          {
          public:
           /** Returns the tree's position */
     309   inline Ogre::Vector3 &getPosition(   ) { return position; }
          
           /** Returns the tree's yaw as a degree value */
     312   inline Ogre::Degree &getYaw(   ) { return yaw; }
          
           /** Returns the tree's uniform scale value */
     315   inline Ogre::Real &getScale(   ) { return scale; }
          
           /** Returns the tree's orientation as a Quaternion */
     318   inline Ogre::Quaternion getOrientation(   ) { return Ogre::Quaternion(  yaw,   Ogre::Vector3::UNIT_Y ); }
          
           /** Returns the entity used to create the tree */
     321   inline Ogre::Entity *getEntity(   ) { return entity; }
          
          private:
     324   friend class TreeIterator3D;
     325   friend class TreeIterator2D;
     326   Ogre::Vector3 position;
     327   Ogre::Degree yaw;
     328   Ogre::Real scale;
     329   Ogre::Entity *entity;
          };
          
          #endif
          
          
     335  class TreeIterator2D
          {
          public:
     338   TreeIterator2D(  TreeLoader2D *trees );
          
           /** Returns true if there are more trees available to be read */
     341   inline bool hasMoreElements(   ) const { return hasMore; }
          
           /** Returns the next tree,   and advances to the next */
     344   TreeRef getNext(   );
          
           /** Returns the next tree,   without advancing to the next */
     347   inline TreeRef &peekNext(   ) { return prevTreeDat; }
          
           /** Returns a pointer to the next tree,   without advancing to the next */
     350   inline TreeRef *peekNextPtr(   ) { return &prevTreeDat; }
          
           /** Moves the iterator on to the next tree */
     353   void moveNext(   );
          
          private:
     356   void _readTree(   );
          
     358   TreeLoader2D *trees;
     359   TreeLoader2D::PageGridListIterator currentGrid;
           int currentX,   currentZ;
     361   std::vector<TreeLoader2D::TreeDef> *currentTreeList;
     362   std::vector<TreeLoader2D::TreeDef>::iterator currentTree;
          
     364   TreeRef currentTreeDat,   prevTreeDat;
     365   bool hasMore;
          };
          
          }
          
          #endif

./components/ogre/environment/pagedgeometry/include/TreeLoader3D.h

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
          1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
          2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
          3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          #ifndef __TreeLoader3D_H__
          #define __TreeLoader3D_H__
          
          #include "PagedGeometry.h"
          #include "PropertyMaps.h"
          
          #include "OgrePrerequisites.h"
          
          namespace PagedGeometry {
          
      21  class TreeIterator3D;
      22  class TreeIterator2D;
          
          /** \brief A PageLoader-derived object you can use with PagedGeometry to easily place trees on your terrain.
          
          \note TreeLoader3D is derived from PageLoader - this implementation provides you with an easy way
          to add trees to your scene. Remember that if the included PageLoader's aren't enough,   you can easily
          create your own to load geometry any way you want. You could even modify existing an PageLoader
          to suit your needs.
          
          Using a TreeLoader is simple - simply create an instance,   attach it to your PagedGeometry object
          with PagedGeometry::setPageLoader(   ),   and add your trees.
          
          To add trees,   just call TreeLoader3D::addTree(   ),   supplying the appropriate parameters. You may notice that
          TreeLoader3D restricts trees to uniform scale and yaw rotation. This is done to conserve memory; TreeLoader3D
          packs trees into memory as effeciently as possible,   taking only 10 bytes per tree. This means 1 million trees
          takes 9.53 MB of RAM (  additionally,   adding 1 million trees takes less than a second in a release build ).
          
          \note Using TreeLoader2D uses 40% less memory than TreeLoader3D.
          */
      41  class TreeLoader3D: public PageLoader
          {
          public:
           /** \brief Creates a new TreeLoader3D object.
           \param geom The PagedGeometry object that this TreeLoader3D will be assigned to.
           \param bounds The rectangular boundary in which all trees will be placed. */
      47   TreeLoader3D(  PagedGeometry *geom,   const Ogre::TRect<Ogre::Real> &bounds );
      48   ~TreeLoader3D(   );
          
           /** \brief Adds an entity to the scene with the specified location,   rotation,   and scale.
           \param entity The entity to be added to the scene.
           \param position The desired position of the tree
           \param yaw The desired rotation around the vertical axis in degrees
           \param scale The desired scale of the entity
          
           While TreeLoader3D allows you to provide full 3-dimensional x/y/z coordinates,  
           you are restricted to only yaw rotation,   and only uniform scale.
          
           \warning By default,   scale values may not exceed 2.0. If you need to use higher scale
           values than 2.0,   use setMaximumScale(   ) to reconfigure the maximum. */
      61   void addTree(  Ogre::Entity *entity,   const Ogre::Vector3 &position,   Ogre::Degree yaw = Ogre::Degree(  0 ),   Ogre::Real scale = 1.0f );
          
           /** \brief Deletes trees within a certain radius of the given coordinates.
           \param position The coordinate of the tree(  s ) to delete
           \param radius The radius from the given coordinate where trees will be deleted
           \param type The type of tree to delete (  optional )
          
           \note If the "type" parameter is set to an entity,   only trees created with that entity
           will be deleted. */
      70   void deleteTrees(  const Ogre::Vector3 &position,   float radius,   Ogre::Entity *type = NULL );
          
           /** \brief Gets an iterator which can be used to access all added trees.
          
           The returned TreeIterator3D can be used to iterate through every tree that was added
           to this TreeLoader3D fairly efficiently.
          
           \see The TreeIterator class documentation for more info.
           */
      79   TreeIterator3D getTrees(   );
          
           /** \brief Sets the color map used to color trees
           \param mapFile The color map image
           \param channel The color channel(  s ) to from the image to use
          
           A color map is simply a texture that allows you to vary the color and shading of trees
           across your world for a more realistic look. For example,   adding a dark spot to the center
           of your color map will make trees near the center of your world look darker.
          
           The channel parameter allows you to extract the color information from the image's
           red,   green,   blue,   alpha,   or color values. For example,   you may store the desired shade of your
           trees in the red channel of an image,   in which case you would use CHANNEL_RED (  when you choose
           a single channel,   it is converted to a greyscale color ). By default,   CHANNEL_COLOR is used,  
           which uses the full color information available in the image. */
      94   void setColorMap(  const Ogre::String &mapFile,   MapChannel channel = CHANNEL_COLOR );
          
           /** \brief Sets the color map used to color trees
          
           Overloaded to accept a Texture object. See the original setColorMap(   ) documentation above
           for more detailed information on color maps.
          
           \note The texture data you provide is copied into RAM,   so you can delete the texture after
           calling this function without risk of crashing. */
     103   void setColorMap(  Ogre::Texture *map,   MapChannel channel = CHANNEL_COLOR );
          
           /** \brief Gets a pointer to the color map being used
          
           You can use this function to access the internal color map object used by the TreeLoader3D.
           Through this object you can directly manipulate the pixels of the color map,   among other
           things.
          
           Note that although you can edit the color map in real-time through this class,   the changes
           won't be uploaded to your video card until you call PagedGeometry::reloadGeometry(   ). If you
           don't,   the colors of the trees you see will remain unchanged. */
     114   ColorMap *getColorMap(   ) { return colorMap; }
          
           /** \brief Sets the filtering mode used for the color map
          
           This function can be used to set the filtering mode used for your tree color map.
           By default,   no filtering is used (  MAPFILTER_NONE ). If you enable bilinear filtering
           by using MAPFILTER_BILINEAR,   the resulting tree coloration may appear more smooth
           (  less pixelated ),   depending on the resolution of your color map.
          
           MAPFILTER_BILINEAR is slightly slowe than MAPFILTER_NONE,   so don't use it unless you notice
           considerable pixelation. */
     125   void setColorMapFilter(  MapFilter filter )
           {
           colorMapFilter = filter;
           if (  colorMap )
           colorMap->setFilter(  colorMapFilter );
           }
          
           /** \brief Sets the maximum tree scale value
          
           When calling addTree(   ) to add trees,   the scale values you are allowed to use are restricted
           to 2.0 maximum by default. With this function,   you can adjust the maximum scale you are allowed
           to use for trees. However,   keep in mind that the higher the maximum scale is,   the less precision
           there will be in storing the tree scales (  since scale values are actually packed into a single byte ).
          
           \warning Be sure to call this before adding any trees - otherwise adjusting this value will cause
           the size of the currently added trees to change. */
     141   void setMaximumScale(  Ogre::Real maxScale )
           {
           maximumScale = maxScale;
           }
          
           /** \brief Gets the maximum tree scale value
           \returns The maximum tree scale value
          
           This function will return the maximum tree scale value as set by setMaximumScale(   ). By
           default this value will be 2.0. */
     151   float getMaximumScale(   )
           {
           return maximumScale;
           }
          
           /** \brief Sets the minimum tree scale value
          
           When calling addTree(   ) to add trees,   the scale values you are allowed to use are restricted
           in the range of 0.0 - 2.0 by default. With this function,   you can adjust the minimum scale you are
           allowed to use for trees. The closer this minimum value is to the maximum tree scale,   the more
           precision there will be when storing trees with addTree(   ).
          
           \warning Be sure to call this before adding any trees - otherwise adjusting this value will cause
           the size of the currently added trees to change. */
     165   void setMinimumScale(  Ogre::Real minScale )
           {
           minimumScale = minScale;
           }
          
           /** \brief Gets the minimum tree scale value
           \returns The minimum tree scale value
          
           This function will return the minimum tree scale value as set by setMinimumScale(   ). By
           default this value will be 0. */
     175   float getMinimumScale(   )
           {
           return minimumScale;
           }
          
     180   void loadPage(  PageInfo &page );
          
          private:
     183   friend class TreeIterator3D;
          
           struct TreeDef
           {
           float yPos;
           Ogre::uint16 xPos,   zPos;
           Ogre::uint8 scale,   rotation;
           };
          
           //Information about the 2D grid of pages
           int pageGridX,   pageGridZ;
     194   Ogre::Real pageSize;
     195   Ogre::TRect<Ogre::Real> gridBounds,   actualBounds;
          
     197   Ogre::Real maximumScale,   minimumScale;
          
           //Colormap
     200   ColorMap *colorMap;
           MapFilter colorMapFilter;
          
           //Misc.
     204   PagedGeometry *geom;
          
           //A std::map of 2D grid arrays. Each array is the same size (  pageGridX x pageGridZ ),   and
           //contains a std::vector list of trees. Each std::map entry corresponds to a single tree
           //type,   and every tree defined in the std::map entry's grid should be of that tree type.
     209   std::map<Ogre::Entity*,   std::vector<TreeDef>*> pageGridList;
           typedef std::map<Ogre::Entity*,   std::vector<TreeDef>*>::iterator PageGridListIterator;
           typedef std::pair<Ogre::Entity*,   std::vector<TreeDef>*> PageGridListValue;
          
     213   inline std::vector<TreeDef> &_getGridPage(  std::vector<TreeDef> *grid,   int x,   int z )
           {
           #ifdef _DEBUG
           if(  x >= pageGridX || z >= pageGridZ  )
           OGRE_EXCEPT(  Ogre::Exception::ERR_INVALIDPARAMS,  
           "Grid dimension is out of bounds",  
           "TreeLoader2D::_getGridPage(   )" );
           #endif
          
           return grid[z * pageGridX + x];
           }
          
     225   inline void _setGridPage(  std::vector<TreeDef> *grid,   int x,   int z,   const std::vector<TreeDef> &page )
           {
           #ifdef _DEBUG
           if(  x >= pageGridX || z >= pageGridZ  )
           OGRE_EXCEPT(  Ogre::Exception::ERR_INVALIDPARAMS,  
           "Grid dimension is out of bounds",  
           "TreeLoader2D::_getGridPage(   )" );
           #endif
          
           grid[z * pageGridX + x] = page;
           }
          };
          
          
          
          //The TreeRef class is used by both TreeLoader2D and TreeLoader3D.
          //This #ifndef makes sure TreeRef isn't declared twice in case both treeloaders are used.
          #ifndef TreeRef_Declared
          #define TreeRef_Declared
          
     245  class TreeRef
          {
          public:
           /** Returns the tree's position */
     249   inline Ogre::Vector3 &getPosition(   ) { return position; }
          
           /** Returns the tree's yaw as a degree value */
     252   inline Ogre::Degree &getYaw(   ) { return yaw; }
          
           /** Returns the tree's uniform scale value */
     255   inline Ogre::Real &getScale(   ) { return scale; }
          
           /** Returns the tree's orientation as a Quaternion */
     258   inline Ogre::Quaternion getOrientation(   ) { return Ogre::Quaternion(  yaw,   Ogre::Vector3::UNIT_Y ); }
          
           /** Returns the entity used to create the tree */
     261   inline Ogre::Entity *getEntity(   ) { return entity; }
          
          private:
     264   friend class TreeIterator2D;
     265   friend class TreeIterator3D;
     266   Ogre::Vector3 position;
     267   Ogre::Degree yaw;
     268   Ogre::Real scale;
     269   Ogre::Entity *entity;
          };
          
          #endif
          
          
     275  class TreeIterator3D
          {
          public:
     278   TreeIterator3D(  TreeLoader3D *trees );
          
           /** Returns true if there are more trees available to be read */
     281   inline bool hasMoreElements(   ) const { return hasMore; }
          
           /** Returns the next tree,   and advances to the next */
     284   TreeRef getNext(   );
          
           /** Returns the next tree,   without advancing to the next */
     287   inline TreeRef &peekNext(   ) { return prevTreeDat; }
          
           /** Returns a pointer to the next tree,   without advancing to the next */
     290   inline TreeRef *peekNextPtr(   ) { return &prevTreeDat; }
          
           /** Moves the iterator on to the next tree */
     293   void moveNext(   );
          
          private:
     296   void _readTree(   );
          
     298   TreeLoader3D *trees;
     299   TreeLoader3D::PageGridListIterator currentGrid;
           int currentX,   currentZ;
     301   std::vector<TreeLoader3D::TreeDef> *currentTreeList;
     302   std::vector<TreeLoader3D::TreeDef>::iterator currentTree;
          
     304   TreeRef currentTreeDat,   prevTreeDat;
     305   bool hasMore;
          };
          
          }
          
          #endif

./components/ogre/environment/pagedgeometry/source/BatchPage.cpp

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //BatchPage.cpp
          //BatchPage is an extension to PagedGeometry which displays entities as static geometry.
          //-------------------------------------------------------------------------------------
          
          #include "BatchPage.h"
          #include "BatchedGeometry.h"
          
          #include "OgreRoot.h"
          #include "OgreCamera.h"
          #include "OgreVector3.h"
          #include "OgreQuaternion.h"
          #include "OgreEntity.h"
          #include "OgreRenderSystem.h"
          #include "OgreRenderSystemCapabilities.h"
          #include "OgreHighLevelGpuProgram.h"
          #include "OgreHighLevelGpuProgramManager.h"
          using namespace Ogre;
          
          namespace PagedGeometry {
          
          //-------------------------------------------------------------------------------------
          
          
          unsigned long BatchPage::refCount = 0;
          unsigned long BatchPage::GUID = 0;
          
      37  void BatchPage::init(  PagedGeometry *geom )
          {
           sceneMgr = geom->getSceneManager(   );
           batch = new BatchedGeometry(  sceneMgr,   geom->getSceneNode(   ) );
          
           fadeEnabled = false;
          
           const RenderSystemCapabilities *caps = Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   );
           if (  caps->hasCapability(  RSC_VERTEX_PROGRAM ) )
           shadersSupported = true;
           else
           shadersSupported = false;
          
           ++refCount;
          }
          
      53  BatchPage::~BatchPage(   )
          {
           delete batch;
          
           //Delete unfaded material references
           unfadedMaterials.clear(   );
          }
          
          
      62  void BatchPage::addEntity(  Entity *ent,   const Vector3 &position,   const Quaternion &rotation,   const Vector3 &scale,   const Ogre::ColourValue &color )
          {
           batch->addEntity(  ent,   position,   rotation,   scale,   color );
          }
          
      67  void BatchPage::build(   )
          {
           batch->build(   );
          
           BatchedGeometry::SubBatchIterator it = batch->getSubBatchIterator(   );
           while (  it.hasMoreElements(   ) ){
           BatchedGeometry::SubBatch *subBatch = it.getNext(   );
           MaterialPtr mat = subBatch->getMaterial(   );
          
           //Disable specular unless a custom shader is being used.
           //This is done because the default shader applied by BatchPage
           //doesn't support specular,   and fixed-function needs to look
           //the same as the shader (  for computers with no shader support )
           for (  int t = 0; t < mat->getNumTechniques(   ); ++t ){
           Technique *tech = mat->getTechnique(  t );
           for (  int p = 0; p < tech->getNumPasses(   ); ++p ){
           Pass *pass = tech->getPass(  p );
           if (  pass->getVertexProgramName(   ) == "" )
           pass->setSpecular(  0,   0,   0,   1 );
           }
           }
          
           //Store the original materials
           unfadedMaterials.push_back(  subBatch->getMaterial(   ) );
           }
          
           _updateShaders(   );
          }
          
      96  void BatchPage::removeEntities(   )
          {
           batch->clear(   );
          
           unfadedMaterials.clear(   );
           fadeEnabled = false;
          }
          
          
     105  void BatchPage::setVisible(  bool visible )
          {
           batch->setVisible(  visible );
          }
          
     110  void BatchPage::setFade(  bool enabled,   Real visibleDist,   Real invisibleDist )
          {
           if (  !shadersSupported )
           return;
          
           //If fade status has changed...
           if (  fadeEnabled != enabled ){
           fadeEnabled = enabled;
          
           if (  enabled ) {
           //Transparent batches should render after impostors
           batch->setRenderQueueGroup(  RENDER_QUEUE_6 );
           } else {
           //Opaque batches should render in the normal render queue
           batch->setRenderQueueGroup(  RENDER_QUEUE_MAIN );
           }
          
           this->visibleDist = visibleDist;
           this->invisibleDist = invisibleDist;
           _updateShaders(   );
           }
          }
          
     133  void BatchPage::_updateShaders(   )
          {
           if (  !shadersSupported )
           return;
          
           unsigned int i = 0;
           BatchedGeometry::SubBatchIterator it = batch->getSubBatchIterator(   );
           while (  it.hasMoreElements(   ) ){
           BatchedGeometry::SubBatch *subBatch = it.getNext(   );
           MaterialPtr mat = unfadedMaterials[i++];
          
           //Compile the CG shader script based on various material / fade options
           StringUtil::StrStreamType tmpName;
           tmpName << "BatchPage_";
           if (  fadeEnabled )
           tmpName << "fade_";
           tmpName << "vp";
          
           const String vertexProgName = tmpName.str(   );
          
           //If the shader hasn't been created yet,   create it
           if (  HighLevelGpuProgramManager::getSingleton(   ).getByName(  vertexProgName ).isNull(   ) ){
           String vertexProgSource =
           "void main(   \n"
           " float3 normal : NORMAL,   \n"
           " float4 iPosition : POSITION,   \n"
           " float4 iColor : COLOR,   \n"
           " float2 iUV : TEXCOORD0,   \n"
          
           " out float4 oPosition : POSITION,   \n"
           " out float4 oColor : COLOR,   \n"
           " out float2 oUV : TEXCOORD0,   \n"
           " out float4 oFog : FOG,   \n"
          
           " uniform float4 objSpaceLight,   \n"
           " uniform float4 lightDiffuse,   \n"
           " uniform float4 lightAmbient,   \n"
           " uniform float4 matAmbient,   \n";
          
           if (  fadeEnabled ) vertexProgSource +=
           " uniform float3 camPos,   \n";
          
           vertexProgSource +=
           " uniform float4x4 worldViewProj,   \n"
           " uniform float fadeGap,   \n"
           " uniform float invisibleDist  )\n"
           "{ \n";
          
           vertexProgSource +=
           //Perform lighting calculations (  no specular )
           " float3 light = normalize(  objSpaceLight.xyz - (  iPosition.xyz * objSpaceLight.w ) ); \n"
           " float diffuseFactor = max(  dot(  normal,   light ),   0 ); \n"
           " oColor = lightAmbient + diffuseFactor * lightDiffuse; \n";
          
           vertexProgSource +=
           " oColor *= (  iColor / matAmbient ); \n";
          
           if (  fadeEnabled ) vertexProgSource +=
           //Fade out in the distance
           " float dist = distance(  camPos.xz,   iPosition.xz ); \n"
           " oColor.a *= (  invisibleDist - dist ) / fadeGap; \n";
          
           vertexProgSource +=
           " oUV = iUV; \n"
           " oPosition = mul(  worldViewProj,   iPosition ); \n"
           " oFog.x = oPosition.z; \n"
           "}";
          
           HighLevelGpuProgramPtr vertexShader = HighLevelGpuProgramManager::getSingleton(   ).createProgram(  
           vertexProgName,  
           ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,  
           "cg",   GPT_VERTEX_PROGRAM );
          
           vertexShader->setSource(  vertexProgSource );
           vertexShader->setParameter(  "profiles",   "vs_1_1 arbvp1" );
           vertexShader->setParameter(  "entry_point",   "main" );
           vertexShader->load(   );
           }
          
           //Now that the shader is ready to be applied,   apply it
           StringUtil::StrStreamType materialSignature;
           materialSignature << "BatchMat|";
           materialSignature << mat->getName(   ) << "|";
           if (  fadeEnabled ){
           materialSignature << visibleDist << "|";
           materialSignature << invisibleDist << "|";
           }
          
           //Search for the desired material
           MaterialPtr generatedMaterial = MaterialManager::getSingleton(   ).getByName(  materialSignature.str(   ) );
           if (  generatedMaterial.isNull(   ) ){
           //Clone the material
           generatedMaterial = mat->clone(  materialSignature.str(   ) );
          
           //And apply the fade shader
           for (  unsigned short t = 0; t < generatedMaterial->getNumTechniques(   ); ++t ){
           Technique *tech = generatedMaterial->getTechnique(  t );
           for (  unsigned short p = 0; p < tech->getNumPasses(   ); ++p ){
           Pass *pass = tech->getPass(  p );
          
           //Setup vertex program
           if (  pass->getVertexProgramName(   ) == "" )
           pass->setVertexProgram(  vertexProgName );
          
           try{
           GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters(   );
          
           params->setNamedAutoConstant(  "objSpaceLight",   GpuProgramParameters::ACT_LIGHT_POSITION_OBJECT_SPACE );
           params->setNamedAutoConstant(  "lightDiffuse",   GpuProgramParameters::ACT_DERIVED_LIGHT_DIFFUSE_COLOUR );
           params->setNamedAutoConstant(  "lightAmbient",   GpuProgramParameters::ACT_DERIVED_AMBIENT_LIGHT_COLOUR );
          
           params->setNamedAutoConstant(  "matAmbient",   GpuProgramParameters::ACT_SURFACE_AMBIENT_COLOUR );
           params->setNamedAutoConstant(  "worldViewProj",   GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX );
          
           if (  fadeEnabled ){
           params->setNamedAutoConstant(  "camPos",   GpuProgramParameters::ACT_CAMERA_POSITION_OBJECT_SPACE );
          
           //Set fade ranges
           params->setNamedAutoConstant(  "invisibleDist",   GpuProgramParameters::ACT_CUSTOM );
           params->setNamedConstant(  "invisibleDist",   invisibleDist );
          
           params->setNamedAutoConstant(  "fadeGap",   GpuProgramParameters::ACT_CUSTOM );
           params->setNamedConstant(  "fadeGap",   invisibleDist - visibleDist );
          
           if (  pass->getAlphaRejectFunction(   ) == CMPF_ALWAYS_PASS )
           pass->setSceneBlending(  SBT_TRANSPARENT_ALPHA );
           }
           }
           catch (  ... ) {
           OGRE_EXCEPT(  Exception::ERR_INTERNAL_ERROR,   "Error configuring batched geometry transitions. If you're using materials with custom vertex shaders,   they will need to implement fade transitions to be compatible with BatchPage.",   "BatchPage::_updateShaders(   )" );
           }
           }
           }
          
           }
          
           //Apply the material
           subBatch->setMaterial(  generatedMaterial );
           }
          
          }
          }

./components/ogre/environment/pagedgeometry/source/BatchedGeometry.cpp

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
          1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
          2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
          3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //BatchedGeometry.h
          //A "lightweight" version of Ogre::StaticGeometry,   which gives you a little more control
          //over the batch materials,   etc.
          //-------------------------------------------------------------------------------------
          
          #include "BatchedGeometry.h"
          
          #include "OgreRoot.h"
          #include "OgreRenderSystem.h"
          #include "OgreCamera.h"
          #include "OgreVector3.h"
          #include "OgreQuaternion.h"
          #include "OgreSceneNode.h"
          #include "OgreString.h"
          #include "OgreStringConverter.h"
          #include "OgreEntity.h"
          #include "OgreSubMesh.h"
          #include "OgreSubEntity.h"
          #include "OgreMesh.h"
          #include "OgreMeshManager.h"
          #include "OgreHardwareBufferManager.h"
          #include "OgreHardwareBuffer.h"
          #include "OgreMaterialManager.h"
          #include "OgreMaterial.h"
          using namespace Ogre;
          
          namespace PagedGeometry {
          
          //-------------------------------------------------------------------------------------
          
      41  BatchedGeometry::BatchedGeometry(  SceneManager *mgr,   SceneNode *rootSceneNode )
           : withinFarDistance(  0 ),  
           minDistanceSquared(  0 ),  
           sceneNode(  NULL ),  
           sceneMgr(  mgr ),  
           built(  false ),  
           boundsUndefined(  true ),  
           parentSceneNode(  rootSceneNode )
          {
           clear(   );
          }
          
      53  BatchedGeometry::~BatchedGeometry(   )
          {
           clear(   );
          }
          
      58  void BatchedGeometry::addEntity(  Entity *ent,   const Vector3 &position,   const Quaternion &orientation,   const Vector3 &scale,   const Ogre::ColourValue &color )
          {
           //For each subentity
           for (  Ogre::uint i = 0; i < ent->getNumSubEntities(   ); ++i ){
           //Get the subentity
           SubEntity *subEntity = ent->getSubEntity(  i );
           SubMesh *subMesh = subEntity->getSubMesh(   );
          
           //Generate a format string that uniquely identifies this material & vertex/index format
           if (  subMesh->vertexData == NULL )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "BatchedGeometry cannot use meshes with shared vertex data",   "BatchedGeometry::addEntity(   )" );
           String formatStr = getFormatString(  subEntity );
          
           //If a batch using an identical format exists...
           SubBatch *batch;
           SubBatchMap::iterator batchIter = subBatchMap.find(  formatStr );
           if (  batchIter != subBatchMap.end(   ) ){
           //Use the batch
           batch = batchIter->second;
           } else {
           //Otherwise create a new batch
           batch = new SubBatch(  this,   subEntity );
           subBatchMap.insert(  std::pair<String,   SubBatch*>(  formatStr,   batch ) );
           }
          
           //Now add the submesh to the compatible batch
           batch->addSubEntity(  subEntity,   position,   orientation,   scale,   color );
           }
          
           //Update bounding box
           Matrix4 mat(  orientation );
           mat.setScale(  scale );
           AxisAlignedBox entBounds = ent->getBoundingBox(   );
           entBounds.transform(  mat );
          
           if (  boundsUndefined ){
           bounds.setMinimum(  entBounds.getMinimum(   ) + position );
           bounds.setMaximum(  entBounds.getMaximum(   ) + position );
           boundsUndefined = false;
           } else {
           Vector3 min = bounds.getMinimum(   );
           Vector3 max = bounds.getMaximum(   );
           min.makeFloor(  entBounds.getMinimum(   ) + position );
           max.makeCeil(  entBounds.getMaximum(   ) + position );
           bounds.setMinimum(  min );
           bounds.setMaximum(  max );
           }
          }
          
     107  BatchedGeometry::SubBatchIterator BatchedGeometry::getSubBatchIterator(   ) const
          {
           return BatchedGeometry::SubBatchIterator(  (  SubBatchMap& )subBatchMap );
          }
          
     112  String BatchedGeometry::getFormatString(  SubEntity *ent )
          {
           StringUtil::StrStreamType str;
          
           str << ent->getMaterialName(   ) << "|";
           str << ent->getSubMesh(   )->indexData->indexBuffer->getType(   ) << "|";
          
           const VertexDeclaration::VertexElementList &elemList = ent->getSubMesh(   )->vertexData->vertexDeclaration->getElements(   );
           VertexDeclaration::VertexElementList::const_iterator i;
           for (  i = elemList.begin(   ); i != elemList.end(   ); ++i )
           {
           const VertexElement &element = *i;
           str << element.getSource(   ) << "|";
           str << element.getSemantic(   ) << "|";
           str << element.getType(   ) << "|";
           }
          
           return str.str(   );
          }
          
     132  void BatchedGeometry::build(   )
          {
           ///Make sure the batch hasn't already been built
           if (  built )
           OGRE_EXCEPT(  Exception::ERR_DUPLICATE_ITEM,   "Invalid call to build(   ) - geometry is already batched (  call clear(   ) first )",   "BatchedGeometry::GeomBatch::build(   )" );
          
           if (  subBatchMap.size(   ) != 0 ) {
           //Finish bounds information
           center = bounds.getCenter(   ); //Calculate bounds center
           bounds.setMinimum(  bounds.getMinimum(   ) - center ); //Center the bounding box
           bounds.setMaximum(  bounds.getMaximum(   ) - center ); //Center the bounding box
           radius = bounds.getMaximum(   ).length(   ); //Calculate BB radius
          
           //Create scene node
           sceneNode = parentSceneNode->createChildSceneNode(  center );
          
           //Build each batch
           for (  SubBatchMap::iterator i = subBatchMap.begin(   ); i != subBatchMap.end(   ); ++i ){
           i->second->build(   );
           }
          
           //Attach the batch to the scene node
           sceneNode->attachObject(  this );
          
           //Debug
           //sceneNode->showBoundingBox(  true );
          
           built = true;
           }
          
          }
          
     164  void BatchedGeometry::clear(   )
          {
           //Remove the batch from the scene
           if (  sceneNode ){
           sceneNode->removeAllChildren(   );
           sceneMgr->destroySceneNode(  sceneNode->getName(   ) );
           sceneNode = NULL;
           }
          
           //Reset bounds information
           boundsUndefined = true;
           center = Vector3::ZERO;
           radius = 0;
          
           //Delete each batch
           for (  SubBatchMap::iterator i = subBatchMap.begin(   ); i != subBatchMap.end(   ); ++i ){
           delete i->second;
           }
           subBatchMap.clear(   );
          
           built = false;
          }
          
     187  void BatchedGeometry::_updateRenderQueue(  RenderQueue *queue )
          {
           //If visible...
           if (  isVisible(   ) ){
           //Ask each batch to add itself to the render queue if appropriate
           for (  SubBatchMap::iterator i = subBatchMap.begin(   ); i != subBatchMap.end(   ); ++i ){
           i->second->addSelfToRenderQueue(  queue,   getRenderQueueGroup(   ) );
           }
           }
          }
          
     198  bool BatchedGeometry::isVisible(   )
          {
           return mVisible && withinFarDistance;
          }
          
     203  void BatchedGeometry::_notifyCurrentCamera(  Camera *cam )
          {
           if (  getRenderingDistance(   ) == 0 ) {
           withinFarDistance = true;
           } else {
           //Calculate camera distance
           Vector3 camVec = _convertToLocal(  cam->getDerivedPosition(   ) ) - center;
           Real centerDistanceSquared = camVec.squaredLength(   );
           minDistanceSquared = std::max(  0.0f,   centerDistanceSquared - (  radius * radius ) );
           //Note: centerDistanceSquared measures the distance between the camera and the center of the GeomBatch,  
           //while minDistanceSquared measures the closest distance between the camera and the closest edge of the
           //geometry's bounding sphere.
          
           //Determine whether the BatchedGeometry is within the far rendering distance
           withinFarDistance = minDistanceSquared <= Math::Sqr(  getRenderingDistance(   ) );
           }
          }
          
     221  Ogre::Vector3 BatchedGeometry::_convertToLocal(  const Vector3 &globalVec ) const
          {
           assert(  parentSceneNode );
           //Convert from the given global position to the local coordinate system of the parent scene node.
           return (  parentSceneNode->getOrientation(   ).Inverse(   ) * globalVec );
          }
          
          
          
          
     231  BatchedGeometry::SubBatch::SubBatch(  BatchedGeometry *parent,   SubEntity *ent )
          {
           meshType = ent->getSubMesh(   );
           this->parent = parent;
           built = false;
          
           Material *origMat = (  (  MaterialPtr )MaterialManager::getSingleton(   ).getByName(  ent->getMaterialName(   ) ) ).getPointer(   );
           material = MaterialManager::getSingleton(   ).getByName(  getMaterialClone(  origMat )->getName(   ) );
          
           //Setup vertex/index data structure
           vertexData = meshType->vertexData->clone(  false );
           indexData = meshType->indexData->clone(  false );
          
           //Remove blend weights from vertex format
           const VertexElement* blendIndices = vertexData->vertexDeclaration->findElementBySemantic(  VES_BLEND_INDICES );
           const VertexElement* blendWeights = vertexData->vertexDeclaration->findElementBySemantic(  VES_BLEND_WEIGHTS );
           if (  blendIndices && blendWeights )
           {
           //Check for format errors
           assert(  blendIndices->getSource(   ) == blendWeights->getSource(   )
           && "Blend indices and weights should be in the same buffer" );
           assert(  blendIndices->getSize(   ) + blendWeights->getSize(   ) == vertexData->vertexBufferBinding->getBuffer(  blendIndices->getSource(   ) )->getVertexSize(   )
           && "Blend indices and blend buffers should have buffer to themselves!" );
          
           //Remove the blend weights
           vertexData->vertexBufferBinding->unsetBinding(  blendIndices->getSource(   ) );
           vertexData->vertexDeclaration->removeElement(  VES_BLEND_INDICES );
           vertexData->vertexDeclaration->removeElement(  VES_BLEND_WEIGHTS );
           #if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR > 2
           vertexData->closeGapsInBindings(   );
           #endif
           }
          
           //Reset vertex/index count
           vertexData->vertexStart = 0;
           vertexData->vertexCount = 0;
           indexData->indexStart = 0;
           indexData->indexCount = 0;
          }
          
     271  BatchedGeometry::SubBatch::~SubBatch(   )
          {
           clear(   );
          
           delete vertexData;
           delete indexData;
          }
          
     279  Material *BatchedGeometry::SubBatch::getMaterialClone(  Material *mat )
          {
           String clonedName = mat->getName(   ) + "_Batched";
           MaterialPtr clonedMat = MaterialManager::getSingleton(   ).getByName(  clonedName );
           if (  clonedMat.isNull(   ) )
           clonedMat = mat->clone(  clonedName );
          
           return clonedMat.getPointer(   );
          }
          
     289  void BatchedGeometry::SubBatch::addSubEntity(  SubEntity *ent,   const Vector3 &position,   const Quaternion &orientation,   const Vector3 &scale,   const Ogre::ColourValue &color )
          {
           assert(  !built );
          
           //Add this submesh to the queue
           QueuedMesh newMesh;
           newMesh.mesh = ent->getSubMesh(   );
           newMesh.position = position;
           newMesh.orientation = orientation;
           newMesh.scale = scale;
          
           newMesh.color = color;
           VertexElementType format = Root::getSingleton(   ).getRenderSystem(   )->getColourVertexElementType(   );
           switch (  format ){
           case VET_COLOUR_ARGB:
           std::swap(  newMesh.color.r,   newMesh.color.b );
           break;
           case VET_COLOUR_ABGR:
           break;
           default:
           OGRE_EXCEPT(  0,   "Unknown RenderSystem color format",   "BatchedGeometry::SubBatch::addSubMesh(   )" );
           break;
           }
          
           meshQueue.push_back(  newMesh );
          
           //Increment the vertex/index count so the buffers will have room for this mesh
           vertexData->vertexCount += ent->getSubMesh(   )->vertexData->vertexCount;
           indexData->indexCount += ent->getSubMesh(   )->indexData->indexCount;
          }
          
     320  void BatchedGeometry::SubBatch::build(   )
          {
           assert(  !built );
          
           //Misc. setup
           Vector3 batchCenter = parent->center;
          
           HardwareIndexBuffer::IndexType srcIndexType = meshType->indexData->indexBuffer->getType(   );
           HardwareIndexBuffer::IndexType destIndexType;
           if (  vertexData->vertexCount > 0xFFFF || srcIndexType == HardwareIndexBuffer::IT_32BIT )
           destIndexType = HardwareIndexBuffer::IT_32BIT;
           else
           destIndexType = HardwareIndexBuffer::IT_16BIT;
          
           //Allocate the index buffer
           indexData->indexBuffer = HardwareBufferManager::getSingleton(   )
           .createIndexBuffer(  destIndexType,   indexData->indexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
           //Lock the index buffer
           uint32 *indexBuffer32;
           uint16 *indexBuffer16;
           if (  destIndexType == HardwareIndexBuffer::IT_32BIT )
           indexBuffer32 = static_cast<uint32*>(  indexData->indexBuffer->lock(  HardwareBuffer::HBL_DISCARD ) );
           else
           indexBuffer16 = static_cast<uint16*>(  indexData->indexBuffer->lock(  HardwareBuffer::HBL_DISCARD ) );
          
           //Allocate & lock the vertex buffers
           std::vector<uchar*> vertexBuffers;
           std::vector<VertexDeclaration::VertexElementList> vertexBufferElements;
          
           VertexBufferBinding *vertBinding = vertexData->vertexBufferBinding;
           VertexDeclaration *vertDecl = vertexData->vertexDeclaration;
          
           for (  Ogre::ushort i = 0; i < vertBinding->getBufferCount(   ); ++i )
           {
           HardwareVertexBufferSharedPtr buffer = HardwareBufferManager::getSingleton(   )
           .createVertexBuffer(  vertDecl->getVertexSize(  i ),   vertexData->vertexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY );
           vertBinding->setBinding(  i,   buffer );
          
           vertexBuffers.push_back(  static_cast<uchar*>(  buffer->lock(  HardwareBuffer::HBL_DISCARD ) ) );
           vertexBufferElements.push_back(  vertDecl->findElementsBySource(  i ) );
           }
          
           //If no vertex colors are used,   make sure the final batch includes them (  so the shade values work )
           if (  !vertexData->vertexDeclaration->findElementBySemantic(  VES_DIFFUSE ) ) {
           Ogre::ushort i = (  Ogre::ushort )vertBinding->getBufferCount(   );
          
           vertDecl->addElement(  i,   0,   VET_COLOUR,   VES_DIFFUSE );
          
           HardwareVertexBufferSharedPtr buffer = HardwareBufferManager::getSingleton(   )
           .createVertexBuffer(  vertDecl->getVertexSize(  i ),   vertexData->vertexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY );
           vertBinding->setBinding(  i,   buffer );
          
           vertexBuffers.push_back(  static_cast<uchar*>(  buffer->lock(  HardwareBuffer::HBL_DISCARD ) ) );
           vertexBufferElements.push_back(  vertDecl->findElementsBySource(  i ) );
          
           }
          
           //Prepare vertex colors
           Pass *p = material->getTechnique(  0 )->getPass(  0 );
           p->setVertexColourTracking(  TVC_AMBIENT );
          
           ColourValue ambient = p->getAmbient(   );
           VertexElementType format = Root::getSingleton(   ).getRenderSystem(   )->getColourVertexElementType(   );
           switch (  format ){
           case VET_COLOUR_ARGB:
           std::swap(  ambient.r,   ambient.b );
           break;
           case VET_COLOUR_ABGR:
           break;
           default:
           OGRE_EXCEPT(  0,   "Unknown RenderSystem color format",   "BatchedGeometry::SubBatch::build(   )" );
           break;
           }
          
          
           //For each queued mesh...
           MeshQueueIterator it;
           size_t indexOffset = 0;
           for (  it = meshQueue.begin(   ); it != meshQueue.end(   ); ++it ) {
           const QueuedMesh queuedMesh = (  *it );
           const IndexData *sourceIndexData = queuedMesh.mesh->indexData;
           const VertexData *sourceVertexData = queuedMesh.mesh->vertexData;
          
           //Copy mesh vertex data into the vertex buffer
           VertexBufferBinding *sourceBinds = sourceVertexData->vertexBufferBinding;
           VertexBufferBinding *destBinds = vertexData->vertexBufferBinding;
           for (  Ogre::ushort i = 0; i < destBinds->getBufferCount(   ); ++i )
           {
           if (  i < sourceBinds->getBufferCount(   ) ){
           //Lock the input buffer
           HardwareVertexBufferSharedPtr sourceBuffer = sourceBinds->getBuffer(  i );
           uchar *sourceBase = static_cast<uchar*>(  sourceBuffer->lock(  HardwareBuffer::HBL_READ_ONLY ) );
          
           //Get the locked output buffer
           uchar *destBase = vertexBuffers[i];
          
           //Copy vertices
           float *sourcePtr,   *destPtr;
           for (  size_t v = 0; v < sourceVertexData->vertexCount; ++v )
           {
           // Iterate over vertex elements
           VertexDeclaration::VertexElementList &elems = vertexBufferElements[i];
           VertexDeclaration::VertexElementList::iterator ei;
           for (  ei = elems.begin(   ); ei != elems.end(   ); ++ei )
           {
           VertexElement &elem = *ei;
           elem.baseVertexPointerToElement(  sourceBase,   &sourcePtr );
           elem.baseVertexPointerToElement(  destBase,   &destPtr );
          
           Vector3 tmp;
           uint32 tmpColor;
           uint8 tmpR,   tmpG,   tmpB,   tmpA;
          
           switch (  elem.getSemantic(   ) )
           {
           case VES_POSITION:
           tmp.x = *sourcePtr++;
           tmp.y = *sourcePtr++;
           tmp.z = *sourcePtr++;
          
           //Transform
           tmp = (  queuedMesh.orientation * (  tmp * queuedMesh.scale ) ) + queuedMesh.position;
           tmp -= batchCenter; //Adjust for batch center
          
           *destPtr++ = tmp.x;
           *destPtr++ = tmp.y;
           *destPtr++ = tmp.z;
           break;
          
           case VES_NORMAL:
           tmp.x = *sourcePtr++;
           tmp.y = *sourcePtr++;
           tmp.z = *sourcePtr++;
          
           //Rotate
           tmp = queuedMesh.orientation * tmp;
          
           *destPtr++ = tmp.x;
           *destPtr++ = tmp.y;
           *destPtr++ = tmp.z;
           break;
          
           case VES_DIFFUSE:
           tmpColor = *(  (  uint32* )sourcePtr++ );
           tmpR = (  (  tmpColor ) & 0xFF ) * queuedMesh.color.r * ambient.r;
           tmpG = (  (  tmpColor >> 8 ) & 0xFF ) * queuedMesh.color.g * ambient.g;
           tmpB = (  (  tmpColor >> 16 ) & 0xFF ) * queuedMesh.color.b * ambient.b;
           tmpA = (  tmpColor >> 24 ) & 0xFF;
          
           tmpColor = tmpR | (  tmpG << 8 ) | (  tmpB << 16 ) | (  tmpA << 24 );
           *(  (  uint32* )destPtr++ ) = tmpColor;
           break;
          
           case VES_TANGENT:
           case VES_BINORMAL:
           tmp.x = *sourcePtr++;
           tmp.y = *sourcePtr++;
           tmp.z = *sourcePtr++;
          
           //Rotate
           tmp = queuedMesh.orientation * tmp;
          
           *destPtr++ = tmp.x;
           *destPtr++ = tmp.y;
           *destPtr++ = tmp.z;
           break;
          
           default:
           //Raw copy
           memcpy(  destPtr,   sourcePtr,   VertexElement::getTypeSize(  elem.getType(   ) ) );
           break;
           };
           }
          
           // Increment both pointers
           destBase += sourceBuffer->getVertexSize(   );
           sourceBase += sourceBuffer->getVertexSize(   );
           }
          
           //Unlock the input buffer
           vertexBuffers[i] = destBase;
           sourceBuffer->unlock(   );
           } else {
           //Get the locked output buffer
           uint32 *startPtr = (  uint32* )vertexBuffers[vertBinding->getBufferCount(   )-1];
           uint32 *endPtr = startPtr + sourceVertexData->vertexCount;
          
           //Generate color
           uint8 tmpR = ambient.r * queuedMesh.color.r * 255;
           uint8 tmpG = ambient.g * queuedMesh.color.g * 255;
           uint8 tmpB = ambient.b * queuedMesh.color.b * 255;
           uint32 tmpColor = tmpR | (  tmpG << 8 ) | (  tmpB << 16 ) | (  0xFF << 24 );
          
           //Copy colors
           while (  startPtr < endPtr ) {
           *startPtr++ = tmpColor;
           }
          
           vertexBuffers[vertBinding->getBufferCount(   )-1] += (  sizeof(  uint32 ) * sourceVertexData->vertexCount );
           }
           }
          
          
           //Copy mesh index data into the index buffer
           if (  srcIndexType == HardwareIndexBuffer::IT_32BIT ) {
           //Lock the input buffer
           uint32 *source = static_cast<uint32*>(  sourceIndexData->indexBuffer->lock(  
           sourceIndexData->indexStart,   sourceIndexData->indexCount,   HardwareBuffer::HBL_READ_ONLY
            ) );
           uint32 *sourceEnd = source + sourceIndexData->indexCount;
          
           //And copy it to the output buffer
           while (  source != sourceEnd ) {
           *indexBuffer32++ = static_cast<uint32>(  *source++ + indexOffset );
           }
          
           //Unlock the input buffer
           sourceIndexData->indexBuffer->unlock(   );
          
           //Increment the index offset
           indexOffset += sourceVertexData->vertexCount;
           } else {
           if (  destIndexType == HardwareIndexBuffer::IT_32BIT ){
           //-- Convert 16 bit to 32 bit indices --
           //Lock the input buffer
           uint16 *source = static_cast<uint16*>(  sourceIndexData->indexBuffer->lock(  
           sourceIndexData->indexStart,   sourceIndexData->indexCount,   HardwareBuffer::HBL_READ_ONLY
            ) );
           uint16 *sourceEnd = source + sourceIndexData->indexCount;
          
           //And copy it to the output buffer
           while (  source != sourceEnd ) {
           uint32 indx = *source++;
           *indexBuffer32++ = (  indx + indexOffset );
           }
          
           //Unlock the input buffer
           sourceIndexData->indexBuffer->unlock(   );
          
           //Increment the index offset
           indexOffset += sourceVertexData->vertexCount;
           } else {
           //Lock the input buffer
           uint16 *source = static_cast<uint16*>(  sourceIndexData->indexBuffer->lock(  
           sourceIndexData->indexStart,   sourceIndexData->indexCount,   HardwareBuffer::HBL_READ_ONLY
            ) );
           uint16 *sourceEnd = source + sourceIndexData->indexCount;
          
           //And copy it to the output buffer
           while (  source != sourceEnd ) {
           *indexBuffer16++ = static_cast<uint16>(  *source++ + indexOffset );
           }
          
           //Unlock the input buffer
           sourceIndexData->indexBuffer->unlock(   );
          
           //Increment the index offset
           indexOffset += sourceVertexData->vertexCount;
           }
           }
           }
          
           //Unlock buffers
           indexData->indexBuffer->unlock(   );
           for (  Ogre::ushort i = 0; i < vertBinding->getBufferCount(   ); ++i )
           vertBinding->getBuffer(  i )->unlock(   );
          
           //Clear mesh queue
           meshQueue.clear(   );
          
           built = true;
          }
          
     594  void BatchedGeometry::SubBatch::clear(   )
          {
           //If built,   delete the batch
           if (  built ){
           //Delete buffers
           indexData->indexBuffer.setNull(   );
           vertexData->vertexBufferBinding->unsetAllBindings(   );
          
           //Reset vertex/index count
           vertexData->vertexStart = 0;
           vertexData->vertexCount = 0;
           indexData->indexStart = 0;
           indexData->indexCount = 0;
           }
          
           //Clear mesh queue
           meshQueue.clear(   );
          
           built = false;
          }
          
     615  void BatchedGeometry::SubBatch::addSelfToRenderQueue(  RenderQueue *queue,   uint8 group )
          {
           if (  built ){
           //Update material technique based on camera distance
           assert(  !material.isNull(   ) );
           bestTechnqiue = material->getBestTechnique(  material->getLodIndexSquaredDepth(  parent->minDistanceSquared ) );
          
           //Add to render queue
           queue->addRenderable(  this,   group );
           }
          }
          
     627  void BatchedGeometry::SubBatch::getRenderOperation(  RenderOperation& op )
          {
           op.operationType = RenderOperation::OT_TRIANGLE_LIST;
           op.srcRenderable = this;
           op.useIndexes = true;
           op.vertexData = vertexData;
           op.indexData = indexData;
          }
          
     636  Real BatchedGeometry::SubBatch::getSquaredViewDepth(  const Camera* cam ) const
          {
           Vector3 camVec = parent->_convertToLocal(  cam->getDerivedPosition(   ) ) - parent->center;
           return camVec.squaredLength(   );
          }
          
          #if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR <= 2
          //Dagon-compatible getLights(   )
     644  const Ogre::LightList& BatchedGeometry::SubBatch::getLights(  void ) const
          {
           return parent->sceneNode->findLights(  parent->radius );
          }
          #else
          //Eihort-compatible getLights(   )
     650  const Ogre::LightList& BatchedGeometry::SubBatch::getLights(  void ) const
          {
           return parent->queryLights(   );
          }
          
          }
          
          #endif

./components/ogre/environment/pagedgeometry/source/DummyPage.cpp

       1  //
          // C++ Implementation: DummyPage
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          //ImpostorPage.cpp
          //ImposterPage is an extension to PagedGeometry which displays entities as imposters.
          //-------------------------------------------------------------------------------------
          
          #include "DummyPage.h"
          
          #include <OgreRoot.h>
          #include <OgreTimer.h>
          #include <OgreCamera.h>
          #include <OgreVector3.h>
          #include <OgreQuaternion.h>
          #include <OgreEntity.h>
          #include <OgreSubEntity.h>
          #include <OgreHardwarePixelBuffer.h>
          using namespace Ogre;
          
          namespace PagedGeometry {
          
          //-------------------------------------------------------------------------------------
          
          
      44  void DummyPage::init(  PagedGeometry *geom )
          {
           //Save pointers to PagedGeometry object
           sceneMgr = geom->getSceneManager(   );
           this->geom = geom;
          }
          
      51  DummyPage::~DummyPage(   )
          {
          }
          
          }

./components/ogre/environment/pagedgeometry/source/GrassLoader.cpp

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          #include "GrassLoader.h"
          #include "PagedGeometry.h"
          #include "PropertyMaps.h"
          
          #include "OgreRoot.h"
          #include "OgreTimer.h"
          #include "OgreCamera.h"
          #include "OgreVector3.h"
          #include "OgreQuaternion.h"
          #include "OgreEntity.h"
          #include "OgreString.h"
          #include "OgreStringConverter.h"
          #include "OgreMaterialManager.h"
          #include "OgreMaterial.h"
          #include "OgreHardwareBufferManager.h"
          #include "OgreHardwareBuffer.h"
          #include "OgreMeshManager.h"
          #include "OgreMesh.h"
          #include "OgreSubMesh.h"
          #include "OgreLogManager.h"
          #include "OgreTextureManager.h"
          #include "OgreHardwarePixelBuffer.h"
          #include "OgreRenderSystem.h"
          #include "OgreRenderSystemCapabilities.h"
          #include "OgreHighLevelGpuProgram.h"
          #include "OgreHighLevelGpuProgramManager.h"
          using namespace Ogre;
          
          namespace PagedGeometry {
          
          // template <class TGrassLayer>
          // unsigned long GrassLoader<TGrassLayer>::GUID = 0;
          
          // template <class TGrassLayer>
          // GrassLoader<TGrassLayer>::GrassLoader(  PagedGeometry *geom )
          // {
          // GrassLoader<TGrassLayer>::geom = geom;
          //
          // heightFunction = NULL;
          // heightFunctionUserData = NULL;
          //
          // windDir = Vector3::UNIT_X;
          // densityFactor = 1.0f;
          // renderQueue = RENDER_QUEUE_6;
          //
          // windTimer.reset(   );
          // lastTime = 0;
          // }
          
          // template <class TGrassLayer>
          // GrassLoader<TGrassLayer>::~GrassLoader(   )
          // {
          // typename std::list<TGrassLayer*>::iterator it;
          // for (  it = layerList.begin(   ); it != layerList.end(   ); ++it ){
          // delete *it;
          // }
          // layerList.clear(   );
          // }
          
          // template <class TGrassLayer>
          // TGrassLayer *GrassLoader<TGrassLayer>::addLayer(  const String &material )
          // {
          // TGrassLayer *layer = new TGrassLayer(  geom,   this );
          // layer->setMaterialName(  material );
          // layerList.push_back(  layer );
          //
          // return layer;
          // }
          
          // template <class TGrassLayer>
          // void GrassLoader<TGrassLayer>::deleteLayer(  TGrassLayer *layer )
          // {
          // layerList.remove(  layer );
          // delete layer;
          // }
          
          // template <class TGrassLayer>
          // void GrassLoader<TGrassLayer>::frameUpdate(   )
          // {
          // unsigned long currentTime = windTimer.getMilliseconds(   );
          // unsigned long ellapsedTime = currentTime - lastTime;
          // lastTime = currentTime;
          //
          // float ellapsed = ellapsedTime / 1000.0f;
          //
          // //Update the vertex shader parameters
          // typename std::list<TGrassLayer*>::iterator it;
          // for (  it = layerList.begin(   ); it != layerList.end(   ); ++it ){
          // TGrassLayer *layer = *it;
          //
          // layer->_updateShaders(   );
          //
          // GpuProgramParametersSharedPtr params = layer->material->getTechnique(  0 )->getPass(  0 )->getVertexProgramParameters(   );
          // if (  layer->animate ){
          // //Increment animation frame
          // layer->waveCount += ellapsed * (  layer->animSpeed * Math::PI );
          // if (  layer->waveCount > Math::PI*2 ) layer->waveCount -= Math::PI*2;
          //
          // //Set vertex shader parameters
          // params->setNamedConstant(  "time",   layer->waveCount );
          // params->setNamedConstant(  "frequency",   layer->animFreq );
          //
          // Vector3 direction = windDir * layer->animMag;
          // params->setNamedConstant(  "direction",   Vector4(  direction.x,   direction.y,   direction.z,   0 ) );
          //
          // }
          // }
          // }
          //
          // template <class TGrassLayer>
          // void GrassLoader<TGrassLayer>::loadPage(  PageInfo &page )
          // {
          // //Seed random number generator based on page indexes
          // uint16 xSeed = static_cast<uint16>(  page.xIndex % 0xFFFF );
          // uint16 zSeed = static_cast<uint16>(  page.zIndex % 0xFFFF );
          // uint32 seed = (  xSeed << 16 ) | zSeed;
          // srand(  seed );
          //
          // typename std::list<TGrassLayer*>::iterator it;
          // for (  it = layerList.begin(   ); it != layerList.end(   ); ++it ){
          // TGrassLayer *layer = *it;
          //
          // //Calculate how much grass needs to be added
          // float volume = page.bounds.width(   ) * page.bounds.height(   );
          // unsigned int grassCount = layer->density * densityFactor * volume;
          //
          // //The vertex buffer can't be allocated until the exact number of polygons is known,  
          // //so the locations of all grasses in this page must be precalculated.
          //
          // //Precompute grass locations into an array of floats. A plain array is used for speed;
          // //there's no need to use a dynamic sized array since a maximum size is known.
          // float *position = new float[grassCount*2];
          // if (  layer->densityMap ){
          // if (  layer->densityMap->getFilter(   ) == MAPFILTER_NONE )
          // grassCount = layer->_populateGrassList_UnfilteredDM(  page,   position,   grassCount );
          // else if (  layer->densityMap->getFilter(   ) == MAPFILTER_BILINEAR )
          // grassCount = layer->_populateGrassList_BilinearDM(  page,   position,   grassCount );
          // } else {
          // grassCount = layer->_populateGrassList_Uniform(  page,   position,   grassCount );
          // }
          //
          // //Don't build a mesh unless it contains something
          // if (  grassCount != 0 ){
          // Mesh *mesh = NULL;
          // switch (  layer->renderTechnique ){
          // case GRASSTECH_QUAD:
          // mesh = generateGrass_QUAD(  page,   layer,   position,   grassCount );
          // break;
          // case GRASSTECH_CROSSQUADS:
          // mesh = generateGrass_CROSSQUADS(  page,   layer,   position,   grassCount );
          // break;
          // case GRASSTECH_SPRITE:
          // mesh = generateGrass_SPRITE(  page,   layer,   position,   grassCount );
          // break;
          // }
          // assert(  mesh );
          //
          // //Add the mesh to PagedGeometry
          // Entity *entity = geom->getCamera(   )->getSceneManager(   )->createEntity(  getUniqueID(   ),   mesh->getName(   ) );
          // entity->setRenderQueueGroup(  renderQueue );
          // entity->setCastShadows(  false );
          // addEntity(  entity,   page.centerPoint,   Quaternion::IDENTITY,   Vector3::UNIT_SCALE );
          // geom->getSceneManager(   )->destroyEntity(  entity );
          //
          // //Store the mesh pointer
          // page.userData = mesh;
          // } else {
          // //No mesh
          // page.userData = NULL;
          // }
          //
          // //Delete the position list
          // delete[] position;
          // }
          // }
          //
          // template <class TGrassLayer>
          // void GrassLoader<TGrassLayer>::unloadPage(  const PageInfo &page )
          // {
          // //Unload mesh
          // Mesh *mesh = (  Mesh* )page.userData;
          // if (  mesh )
          // MeshManager::getSingleton(   ).remove(  mesh->getName(   ) );
          // }
          
          // template <class TGrassLayer>
          // Mesh *GrassLoader<TGrassLayer>::generateGrass_QUAD(  PageInfo &page,   TGrassLayer *layer,   float *grassPositions,   unsigned int grassCount )
          // {
          // //Calculate the number of quads to be added
          // unsigned int quadCount;
          // quadCount = grassCount;
          //
          // //Create manual mesh to store grass quads
          // MeshPtr mesh = MeshManager::getSingleton(   ).createManual(  getUniqueID(   ),   ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
          // SubMesh *subMesh = mesh->createSubMesh(   );
          // subMesh->useSharedVertices = false;
          //
          // //Setup vertex format information
          // subMesh->vertexData = new VertexData;
          // subMesh->vertexData->vertexStart = 0;
          // subMesh->vertexData->vertexCount = 4 * quadCount;
          //
          // VertexDeclaration* dcl = subMesh->vertexData->vertexDeclaration;
          // size_t offset = 0;
          // dcl->addElement(  0,   offset,   VET_FLOAT3,   VES_POSITION );
          // offset += VertexElement::getTypeSize(  VET_FLOAT3 );
          // dcl->addElement(  0,   offset,   VET_COLOUR,   VES_DIFFUSE );
          // offset += VertexElement::getTypeSize(  VET_COLOUR );
          // dcl->addElement(  0,   offset,   VET_FLOAT2,   VES_TEXTURE_COORDINATES );
          // offset += VertexElement::getTypeSize(  VET_FLOAT2 );
          //
          // //Populate a new vertex buffer with grass
          // HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton(   )
          // .createVertexBuffer(  offset,   subMesh->vertexData->vertexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
          // float* pReal = static_cast<float*>(  vbuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          //
          // //Calculate size variance
          // float rndWidth = layer->maxWidth - layer->minWidth;
          // float rndHeight = layer->maxHeight - layer->minHeight;
          //
          // float minY = Math::POS_INFINITY,   maxY = Math::NEG_INFINITY;
          // float *posPtr = grassPositions; //Position array "iterator"
          // for (  uint16 i = 0; i < grassCount; ++i )
          // {
          // //Get the x and z positions from the position array
          // float x = *posPtr++;
          // float z = *posPtr++;
          //
          // //Get the color at the grass position
          // uint32 color;
          // if (  layer->colorMap )
          // color = layer->colorMap->getColorAt(  x,   z );
          // else
          // color = 0xFFFFFFFF;
          //
          // //Calculate size
          // float rnd = Math::UnitRandom(   ); //The same rnd value is used for width and height to maintain aspect ratio
          // float halfScaleX = (  layer->minWidth + rndWidth * rnd ) * 0.5f;
          // float scaleY = (  layer->minHeight + rndHeight * rnd );
          //
          // //Calculate rotation
          // float angle = Math::RangeRandom(  0,   Math::TWO_PI );
          // float xTrans = Math::Cos(  angle ) * halfScaleX;
          // float zTrans = Math::Sin(  angle ) * halfScaleX;
          //
          // //Calculate heights and edge positions
          // float x1 = x - xTrans,   z1 = z - zTrans;
          // float x2 = x + xTrans,   z2 = z + zTrans;
          //
          // float y1,   y2;
          // if (  heightFunction ){
          // y1 = heightFunction(  x1,   z1,   heightFunctionUserData );
          // y2 = heightFunction(  x2,   z2,   heightFunctionUserData );
          // } else {
          // y1 = 0;
          // y2 = 0;
          // }
          //
          // //Add vertices
          // *pReal++ = (  x1 - page.centerPoint.x ); *pReal++ = (  y1 + scaleY ); *pReal++ = (  z1 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 0; *pReal++ = 0; //uv
          //
          // *pReal++ = (  x2 - page.centerPoint.x ); *pReal++ = (  y2 + scaleY ); *pReal++ = (  z2 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 1; *pReal++ = 0; //uv
          //
          // *pReal++ = (  x1 - page.centerPoint.x ); *pReal++ = (  y1 ); *pReal++ = (  z1 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 0; *pReal++ = 1; //uv
          //
          // *pReal++ = (  x2 - page.centerPoint.x ); *pReal++ = (  y2 ); *pReal++ = (  z2 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 1; *pReal++ = 1; //uv
          //
          // //Update bounds
          // if (  y1 < minY ) minY = y1;
          // if (  y2 < minY ) minY = y2;
          // if (  y1 + scaleY > maxY ) maxY = y1 + scaleY;
          // if (  y2 + scaleY > maxY ) maxY = y2 + scaleY;
          // }
          //
          // vbuf->unlock(   );
          // subMesh->vertexData->vertexBufferBinding->setBinding(  0,   vbuf );
          //
          // //Populate index buffer
          // subMesh->indexData->indexStart = 0;
          // subMesh->indexData->indexCount = 6 * quadCount;
          // subMesh->indexData->indexBuffer = HardwareBufferManager::getSingleton(   )
          // .createIndexBuffer(  HardwareIndexBuffer::IT_16BIT,   subMesh->indexData->indexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          // uint16* pI = static_cast<uint16*>(  subMesh->indexData->indexBuffer->lock(  HardwareBuffer::HBL_DISCARD ) );
          // for (  uint16 i = 0; i < quadCount; ++i )
          // {
          // uint16 offset = i * 4;
          //
          // *pI++ = 0 + offset;
          // *pI++ = 2 + offset;
          // *pI++ = 1 + offset;
          //
          // *pI++ = 1 + offset;
          // *pI++ = 2 + offset;
          // *pI++ = 3 + offset;
          // }
          //
          // subMesh->indexData->indexBuffer->unlock(   );
          //
          // //Finish up mesh
          // AxisAlignedBox bounds(  page.bounds.left - page.centerPoint.x,   minY,   page.bounds.top - page.centerPoint.z,  
          // page.bounds.right - page.centerPoint.x,   maxY,   page.bounds.bottom - page.centerPoint.z );
          // mesh->_setBounds(  bounds );
          // Vector3 temp = bounds.getMaximum(   ) - bounds.getMinimum(   );
          // mesh->_setBoundingSphereRadius(  temp.length(   ) * 0.5f );
          //
          // LogManager::getSingleton(   ).setLogDetail(  static_cast<LoggingLevel>(  0 ) );
          // mesh->load(   );
          // LogManager::getSingleton(   ).setLogDetail(  LL_NORMAL );
          //
          // //Apply grass material to mesh
          // subMesh->setMaterialName(  layer->material->getName(   ) );
          //
          // //Return the mesh
          // return mesh.getPointer(   );
          // }
          //
          // template <class TGrassLayer>
          // Mesh *GrassLoader<TGrassLayer>::generateGrass_CROSSQUADS(  PageInfo &page,   TGrassLayer *layer,   float *grassPositions,   unsigned int grassCount )
          // {
          // //Calculate the number of quads to be added
          // unsigned int quadCount;
          // quadCount = grassCount * 2;
          //
          // //Create manual mesh to store grass quads
          // MeshPtr mesh = MeshManager::getSingleton(   ).createManual(  getUniqueID(   ),   ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
          // SubMesh *subMesh = mesh->createSubMesh(   );
          // subMesh->useSharedVertices = false;
          //
          // //Setup vertex format information
          // subMesh->vertexData = new VertexData;
          // subMesh->vertexData->vertexStart = 0;
          // subMesh->vertexData->vertexCount = 4 * quadCount;
          //
          // VertexDeclaration* dcl = subMesh->vertexData->vertexDeclaration;
          // size_t offset = 0;
          // dcl->addElement(  0,   offset,   VET_FLOAT3,   VES_POSITION );
          // offset += VertexElement::getTypeSize(  VET_FLOAT3 );
          // dcl->addElement(  0,   offset,   VET_COLOUR,   VES_DIFFUSE );
          // offset += VertexElement::getTypeSize(  VET_COLOUR );
          // dcl->addElement(  0,   offset,   VET_FLOAT2,   VES_TEXTURE_COORDINATES );
          // offset += VertexElement::getTypeSize(  VET_FLOAT2 );
          //
          // //Populate a new vertex buffer with grass
          // HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton(   )
          // .createVertexBuffer(  offset,   subMesh->vertexData->vertexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
          // float* pReal = static_cast<float*>(  vbuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          //
          // //Calculate size variance
          // float rndWidth = layer->maxWidth - layer->minWidth;
          // float rndHeight = layer->maxHeight - layer->minHeight;
          //
          // float minY = Math::POS_INFINITY,   maxY = Math::NEG_INFINITY;
          // float *posPtr = grassPositions; //Position array "iterator"
          // for (  uint16 i = 0; i < grassCount; ++i )
          // {
          // //Get the x and z positions from the position array
          // float x = *posPtr++;
          // float z = *posPtr++;
          //
          // //Get the color at the grass position
          // uint32 color;
          // if (  layer->colorMap )
          // color = layer->colorMap->getColorAt(  x,   z );
          // else
          // color = 0xFFFFFFFF;
          //
          // //Calculate size
          // float rnd = Math::UnitRandom(   ); //The same rnd value is used for width and height to maintain aspect ratio
          // float halfScaleX = (  layer->minWidth + rndWidth * rnd ) * 0.5f;
          // float scaleY = (  layer->minHeight + rndHeight * rnd );
          //
          // //Calculate rotation
          // float angle = Math::RangeRandom(  0,   Math::TWO_PI );
          // float xTrans = Math::Cos(  angle ) * halfScaleX;
          // float zTrans = Math::Sin(  angle ) * halfScaleX;
          //
          // //Calculate heights and edge positions
          // float x1 = x - xTrans,   z1 = z - zTrans;
          // float x2 = x + xTrans,   z2 = z + zTrans;
          //
          // float y1,   y2;
          // if (  heightFunction ){
          // y1 = heightFunction(  x1,   z1,   heightFunctionUserData );
          // y2 = heightFunction(  x2,   z2,   heightFunctionUserData );
          // } else {
          // y1 = 0;
          // y2 = 0;
          // }
          //
          // //Add vertices
          // *pReal++ = (  x1 - page.centerPoint.x ); *pReal++ = (  y1 + scaleY ); *pReal++ = (  z1 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 0; *pReal++ = 0; //uv
          //
          // *pReal++ = (  x2 - page.centerPoint.x ); *pReal++ = (  y2 + scaleY ); *pReal++ = (  z2 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 1; *pReal++ = 0; //uv
          //
          // *pReal++ = (  x1 - page.centerPoint.x ); *pReal++ = (  y1 ); *pReal++ = (  z1 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 0; *pReal++ = 1; //uv
          //
          // *pReal++ = (  x2 - page.centerPoint.x ); *pReal++ = (  y2 ); *pReal++ = (  z2 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 1; *pReal++ = 1; //uv
          //
          // //Update bounds
          // if (  y1 < minY ) minY = y1;
          // if (  y2 < minY ) minY = y2;
          // if (  y1 + scaleY > maxY ) maxY = y1 + scaleY;
          // if (  y2 + scaleY > maxY ) maxY = y2 + scaleY;
          //
          // //Calculate heights and edge positions
          // float x3 = x + zTrans,   z3 = z - xTrans;
          // float x4 = x - zTrans,   z4 = z + xTrans;
          //
          // float y3,   y4;
          // if (  heightFunction ){
          // y3 = heightFunction(  x3,   z3,   heightFunctionUserData );
          // y4 = heightFunction(  x4,   z4,   heightFunctionUserData );
          // } else {
          // y3 = 0;
          // y4 = 0;
          // }
          //
          // //Add vertices
          // *pReal++ = (  x3 - page.centerPoint.x ); *pReal++ = (  y3 + scaleY ); *pReal++ = (  z3 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 0; *pReal++ = 0; //uv
          //
          // *pReal++ = (  x4 - page.centerPoint.x ); *pReal++ = (  y4 + scaleY ); *pReal++ = (  z4 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 1; *pReal++ = 0; //uv
          //
          // *pReal++ = (  x3 - page.centerPoint.x ); *pReal++ = (  y3 ); *pReal++ = (  z3 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 0; *pReal++ = 1; //uv
          //
          // *pReal++ = (  x4 - page.centerPoint.x ); *pReal++ = (  y4 ); *pReal++ = (  z4 - page.centerPoint.z ); //pos
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = 1; *pReal++ = 1; //uv
          //
          // //Update bounds
          // if (  y3 < minY ) minY = y1;
          // if (  y4 < minY ) minY = y2;
          // if (  y3 + scaleY > maxY ) maxY = y3 + scaleY;
          // if (  y4 + scaleY > maxY ) maxY = y4 + scaleY;
          // }
          //
          // vbuf->unlock(   );
          // subMesh->vertexData->vertexBufferBinding->setBinding(  0,   vbuf );
          //
          // //Populate index buffer
          // subMesh->indexData->indexStart = 0;
          // subMesh->indexData->indexCount = 6 * quadCount;
          // subMesh->indexData->indexBuffer = HardwareBufferManager::getSingleton(   )
          // .createIndexBuffer(  HardwareIndexBuffer::IT_16BIT,   subMesh->indexData->indexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          // uint16* pI = static_cast<uint16*>(  subMesh->indexData->indexBuffer->lock(  HardwareBuffer::HBL_DISCARD ) );
          // for (  uint16 i = 0; i < quadCount; ++i )
          // {
          // uint16 offset = i * 4;
          //
          // *pI++ = 0 + offset;
          // *pI++ = 2 + offset;
          // *pI++ = 1 + offset;
          //
          // *pI++ = 1 + offset;
          // *pI++ = 2 + offset;
          // *pI++ = 3 + offset;
          // }
          //
          // subMesh->indexData->indexBuffer->unlock(   );
          //
          // //Finish up mesh
          // AxisAlignedBox bounds(  page.bounds.left - page.centerPoint.x,   minY,   page.bounds.top - page.centerPoint.z,  
          // page.bounds.right - page.centerPoint.x,   maxY,   page.bounds.bottom - page.centerPoint.z );
          // mesh->_setBounds(  bounds );
          // Vector3 temp = bounds.getMaximum(   ) - bounds.getMinimum(   );
          // mesh->_setBoundingSphereRadius(  temp.length(   ) * 0.5f );
          //
          // LogManager::getSingleton(   ).setLogDetail(  static_cast<LoggingLevel>(  0 ) );
          // mesh->load(   );
          // LogManager::getSingleton(   ).setLogDetail(  LL_NORMAL );
          //
          // //Apply grass material to mesh
          // subMesh->setMaterialName(  layer->material->getName(   ) );
          //
          // //Return the mesh
          // return mesh.getPointer(   );
          // }
          //
          // template <class TGrassLayer>
          // Mesh *GrassLoader<TGrassLayer>::generateGrass_SPRITE(  PageInfo &page,   TGrassLayer *layer,   float *grassPositions,   unsigned int grassCount )
          // {
          // //Calculate the number of quads to be added
          // unsigned int quadCount;
          // quadCount = grassCount;
          //
          // //Create manual mesh to store grass quads
          // MeshPtr mesh = MeshManager::getSingleton(   ).createManual(  getUniqueID(   ),   ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
          // SubMesh *subMesh = mesh->createSubMesh(   );
          // subMesh->useSharedVertices = false;
          //
          // //Setup vertex format information
          // subMesh->vertexData = new VertexData;
          // subMesh->vertexData->vertexStart = 0;
          // subMesh->vertexData->vertexCount = 4 * quadCount;
          //
          // VertexDeclaration* dcl = subMesh->vertexData->vertexDeclaration;
          // size_t offset = 0;
          // dcl->addElement(  0,   offset,   VET_FLOAT3,   VES_POSITION );
          // offset += VertexElement::getTypeSize(  VET_FLOAT3 );
          // dcl->addElement(  0,   offset,   VET_FLOAT4,   VES_NORMAL );
          // offset += VertexElement::getTypeSize(  VET_FLOAT4 );
          // dcl->addElement(  0,   offset,   VET_COLOUR,   VES_DIFFUSE );
          // offset += VertexElement::getTypeSize(  VET_COLOUR );
          // dcl->addElement(  0,   offset,   VET_FLOAT2,   VES_TEXTURE_COORDINATES );
          // offset += VertexElement::getTypeSize(  VET_FLOAT2 );
          //
          // //Populate a new vertex buffer with grass
          // HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton(   )
          // .createVertexBuffer(  offset,   subMesh->vertexData->vertexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
          // float* pReal = static_cast<float*>(  vbuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          //
          // //Calculate size variance
          // float rndWidth = layer->maxWidth - layer->minWidth;
          // float rndHeight = layer->maxHeight - layer->minHeight;
          //
          // float minY = Math::POS_INFINITY,   maxY = Math::NEG_INFINITY;
          // float *posPtr = grassPositions; //Position array "iterator"
          // for (  uint16 i = 0; i < grassCount; ++i )
          // {
          // //Get the x and z positions from the position array
          // float x = *posPtr++;
          // float z = *posPtr++;
          //
          // //Calculate height
          // float y;
          // if (  heightFunction ){
          // y = heightFunction(  x,   z,   heightFunctionUserData );
          // } else {
          // y = 0;
          // }
          //
          // float x1 = (  x - page.centerPoint.x );
          // float z1 = (  z - page.centerPoint.z );
          //
          // //Get the color at the grass position
          // uint32 color;
          // if (  layer->colorMap )
          // color = layer->colorMap->getColorAt(  x,   z );
          // else
          // color = 0xFFFFFFFF;
          //
          // //Calculate size
          // float rnd = Math::UnitRandom(   ); //The same rnd value is used for width and height to maintain aspect ratio
          // float halfXScale = (  layer->minWidth + rndWidth * rnd ) * 0.5f;
          // float scaleY = (  layer->minHeight + rndHeight * rnd );
          //
          // //Randomly mirror grass textures
          // float uvLeft,   uvRight;
          // if (  Math::UnitRandom(   ) > 0.5f ){
          // uvLeft = 0;
          // uvRight = 1;
          // } else {
          // uvLeft = 1;
          // uvRight = 0;
          // }
          //
          // //Add vertices
          // *pReal++ = x1; *pReal++ = y; *pReal++ = z1; //center position
          // *pReal++ = -halfXScale; *pReal++ = scaleY; *pReal++ = 0; *pReal++ = 0; //normal (  used to store relative corner positions )
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = uvLeft; *pReal++ = 0; //uv
          //
          // *pReal++ = x1; *pReal++ = y; *pReal++ = z1; //center position
          // *pReal++ = +halfXScale; *pReal++ = scaleY; *pReal++ = 0; *pReal++ = 0; //normal (  used to store relative corner positions )
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = uvRight; *pReal++ = 0; //uv
          //
          // *pReal++ = x1; *pReal++ = y; *pReal++ = z1; //center position
          // *pReal++ = -halfXScale; *pReal++ = 0.0f; *pReal++ = 0; *pReal++ = 0; //normal (  used to store relative corner positions )
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = uvLeft; *pReal++ = 1; //uv
          //
          // *pReal++ = x1; *pReal++ = y; *pReal++ = z1; //center position
          // *pReal++ = +halfXScale; *pReal++ = 0.0f; *pReal++ = 0; *pReal++ = 0; //normal (  used to store relative corner positions )
          // *(  (  uint32* )pReal++ ) = color; //color
          // *pReal++ = uvRight; *pReal++ = 1; //uv
          //
          // //Update bounds
          // if (  y < minY ) minY = y;
          // if (  y + scaleY > maxY ) maxY = y + scaleY;
          // }
          //
          // vbuf->unlock(   );
          // subMesh->vertexData->vertexBufferBinding->setBinding(  0,   vbuf );
          //
          // //Populate index buffer
          // subMesh->indexData->indexStart = 0;
          // subMesh->indexData->indexCount = 6 * quadCount;
          // subMesh->indexData->indexBuffer = HardwareBufferManager::getSingleton(   )
          // .createIndexBuffer(  HardwareIndexBuffer::IT_16BIT,   subMesh->indexData->indexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          // uint16* pI = static_cast<uint16*>(  subMesh->indexData->indexBuffer->lock(  HardwareBuffer::HBL_DISCARD ) );
          // for (  uint16 i = 0; i < quadCount; ++i )
          // {
          // uint16 offset = i * 4;
          //
          // *pI++ = 0 + offset;
          // *pI++ = 2 + offset;
          // *pI++ = 1 + offset;
          //
          // *pI++ = 1 + offset;
          // *pI++ = 2 + offset;
          // *pI++ = 3 + offset;
          // }
          //
          // subMesh->indexData->indexBuffer->unlock(   );
          //
          // //Finish up mesh
          // AxisAlignedBox bounds(  page.bounds.left - page.centerPoint.x,   minY,   page.bounds.top - page.centerPoint.z,  
          // page.bounds.right - page.centerPoint.x,   maxY,   page.bounds.bottom - page.centerPoint.z );
          // mesh->_setBounds(  bounds );
          // Vector3 temp = bounds.getMaximum(   ) - bounds.getMinimum(   );
          // mesh->_setBoundingSphereRadius(  temp.length(   ) * 0.5f );
          //
          // LogManager::getSingleton(   ).setLogDetail(  static_cast<LoggingLevel>(  0 ) );
          // mesh->load(   );
          // LogManager::getSingleton(   ).setLogDetail(  LL_NORMAL );
          //
          // //Apply grass material to mesh
          // subMesh->setMaterialName(  layer->material->getName(   ) );
          //
          // //Return the mesh
          // return mesh.getPointer(   );
          // }
          
     656  GrassLayer::GrassLayer(  PagedGeometry *geom,   GrassLoader<GrassLayer> *ldr )
          {
           GrassLayer::geom = geom;
           GrassLayer::parent = ldr;
          
           density = 1.0f;
           minWidth = 1.0f; maxWidth = 1.0f;
           minHeight = 1.0f; maxHeight = 1.0f;
           minY = 0; maxY = 0;
           renderTechnique = GRASSTECH_QUAD;
           fadeTechnique = FADETECH_ALPHA;
           animMag = 1.0f;
           animSpeed = 1.0f;
           animFreq = 1.0f;
           waveCount = 0.0f;
           animate = false;
           blend = false;
           shaderNeedsUpdate = true;
          
           densityMap = NULL;
           densityMapFilter = MAPFILTER_BILINEAR;
           colorMap = NULL;
           colorMapFilter = MAPFILTER_BILINEAR;
          }
          
     681  GrassLayer::~GrassLayer(   )
          {
           if (  densityMap )
           densityMap->unload(   );
           if (  colorMap )
           colorMap->unload(   );
          }
          
     689  unsigned int GrassLayer::calculateMaxGrassCount(  float densityFactor,   float volume )
          {
           return density * densityFactor * volume;
          }
          
     694  unsigned int GrassLayer::_populateGrassList(  PageInfo page,   float *posBuff,   unsigned int grassCount )
          {
           if (  densityMap ){
           if (  densityMap->getFilter(   ) == MAPFILTER_NONE )
           return _populateGrassList_UnfilteredDM(  page,   posBuff,   grassCount );
           else if (  densityMap->getFilter(   ) == MAPFILTER_BILINEAR )
           return _populateGrassList_BilinearDM(  page,   posBuff,   grassCount );
           } else {
           return _populateGrassList_Uniform(  page,   posBuff,   grassCount );
           }
          }
          
     706  void GrassLayerBase::setMaterialName(  const String &matName )
          {
           if (  material.isNull(   ) || matName != material->getName(   ) ){
           material = MaterialManager::getSingleton(   ).getByName(  matName );
           if (  material.isNull(   ) )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "The specified grass material does not exist",   "GrassLayer::setMaterialName(   )" );
           shaderNeedsUpdate = true;
           }
          }
          
     716  void GrassLayerBase::setMinimumSize(  float width,   float height )
          {
           minWidth = width;
           minHeight = height;
          }
          
     722  void GrassLayerBase::setMaximumSize(  float width,   float height )
          {
           maxWidth = width;
           if (  maxHeight != height ){
           maxHeight = height;
           shaderNeedsUpdate = true;
           }
          }
          
     731  void GrassLayerBase::setRenderTechnique(  GrassTechnique style,   bool blendBase )
          {
           if (  blend != blendBase || renderTechnique != style ){
           blend = blendBase;
           renderTechnique = style;
           shaderNeedsUpdate = true;
           }
          }
          
     740  void GrassLayerBase::setFadeTechnique(  FadeTechnique style )
          {
           if (  fadeTechnique != style ){
           fadeTechnique = style;
           shaderNeedsUpdate = true;
           }
          }
          
     748  void GrassLayerBase::setAnimationEnabled(  bool enabled )
          {
           if (  animate != enabled ){
           animate = enabled;
           shaderNeedsUpdate = true;
           }
          }
          
     756  void GrassLayer::setDensityMap(  const String &mapFile,   MapChannel channel )
          {
           if (  densityMap ){
           densityMap->unload(   );
           densityMap = NULL;
           }
           if (  mapFile != "" ){
           densityMap = DensityMap::load(  mapFile,   channel );
           densityMap->setMapBounds(  mapBounds );
           densityMap->setFilter(  densityMapFilter );
           }
          }
     768  void GrassLayer::setDensityMap(  Texture *map,   MapChannel channel )
          {
           if (  densityMap ){
           densityMap->unload(   );
           densityMap = NULL;
           }
           if (  map ){
           densityMap = DensityMap::load(  map,   channel );
           densityMap->setMapBounds(  mapBounds );
           densityMap->setFilter(  densityMapFilter );
           }
          }
          
     781  void GrassLayer::setDensityMapFilter(  MapFilter filter )
          {
           densityMapFilter = filter;
           if (  densityMap )
           densityMap->setFilter(  densityMapFilter );
          }
          
     788  unsigned int GrassLayer::_populateGrassList_Uniform(  PageInfo page,   float *posBuff,   unsigned int grassCount )
          {
           float *posPtr = posBuff;
          
           //No density map
           if (  !minY && !maxY ){
           //No height range
           for (  unsigned int i = 0; i < grassCount; ++i ){
           //Pick a random position
           float x = Math::RangeRandom(  page.bounds.left,   page.bounds.right );
           float z = Math::RangeRandom(  page.bounds.top,   page.bounds.bottom );
          
           //Add to list in within bounds
           if (  !colorMap ){
           *posPtr++ = x;
           *posPtr++ = z;
           } else if (  x >= mapBounds.left && x <= mapBounds.right && z >= mapBounds.top && z <= mapBounds.bottom ){
           *posPtr++ = x;
           *posPtr++ = z;
           }
           }
           } else {
           //Height range
           Real min,   max;
           if (  minY ) min = minY; else min = Math::NEG_INFINITY;
           if (  maxY ) max = maxY; else max = Math::POS_INFINITY;
          
           for (  unsigned int i = 0; i < grassCount; ++i ){
           //Pick a random position
           float x = Math::RangeRandom(  page.bounds.left,   page.bounds.right );
           float z = Math::RangeRandom(  page.bounds.top,   page.bounds.bottom );
          
           //Calculate height
           float y = parent->heightFunction(  x,   z,   parent->heightFunctionUserData );
          
           //Add to list if in range
           if (  y >= min && y <= max ){
           //Add to list in within bounds
           if (  !colorMap ){
           *posPtr++ = x;
           *posPtr++ = z;
           } else if (  x >= mapBounds.left && x <= mapBounds.right && z >= mapBounds.top && z <= mapBounds.bottom ){
           *posPtr++ = x;
           *posPtr++ = z;
           }
           }
           }
           }
          
           grassCount = (  posPtr - posBuff ) / 2;
           return grassCount;
          }
          
     841  unsigned int GrassLayer::_populateGrassList_UnfilteredDM(  PageInfo page,   float *posBuff,   unsigned int grassCount )
          {
           float *posPtr = posBuff;
          
           //Use density map
           if (  !minY && !maxY ){
           //No height range
           for (  unsigned int i = 0; i < grassCount; ++i ){
           //Pick a random position
           float x = Math::RangeRandom(  page.bounds.left,   page.bounds.right );
           float z = Math::RangeRandom(  page.bounds.top,   page.bounds.bottom );
          
           //Determine whether this grass will be added based on the local density.
           //For example,   if localDensity is .32,   grasses will be added 32% of the time.
           if (  Math::UnitRandom(   ) < densityMap->_getDensityAt_Unfiltered(  x,   z ) ){
           //Add to list
           *posPtr++ = x;
           *posPtr++ = z;
           }
           }
           } else {
           //Height range
           Real min,   max;
           if (  minY ) min = minY; else min = Math::NEG_INFINITY;
           if (  maxY ) max = maxY; else max = Math::POS_INFINITY;
          
           for (  unsigned int i = 0; i < grassCount; ++i ){
           //Pick a random position
           float x = Math::RangeRandom(  page.bounds.left,   page.bounds.right );
           float z = Math::RangeRandom(  page.bounds.top,   page.bounds.bottom );
          
           //Determine whether this grass will be added based on the local density.
           //For example,   if localDensity is .32,   grasses will be added 32% of the time.
           if (  Math::UnitRandom(   ) < densityMap->_getDensityAt_Unfiltered(  x,   z ) ){
           //Calculate height
           float y = parent->heightFunction(  x,   z,   parent->heightFunctionUserData );
          
           //Add to list if in range
           if (  y >= min && y <= max ){
           //Add to list
           *posPtr++ = x;
           *posPtr++ = z;
           }
           }
           }
           }
          
           grassCount = (  posPtr - posBuff ) / 2;
           return grassCount;
          }
          
     892  unsigned int GrassLayer::_populateGrassList_BilinearDM(  PageInfo page,   float *posBuff,   unsigned int grassCount )
          {
           float *posPtr = posBuff;
          
           if (  !minY && !maxY ){
           //No height range
           for (  unsigned int i = 0; i < grassCount; ++i ){
           //Pick a random position
           float x = Math::RangeRandom(  page.bounds.left,   page.bounds.right );
           float z = Math::RangeRandom(  page.bounds.top,   page.bounds.bottom );
          
           //Determine whether this grass will be added based on the local density.
           //For example,   if localDensity is .32,   grasses will be added 32% of the time.
           if (  Math::UnitRandom(   ) < densityMap->_getDensityAt_Bilinear(  x,   z ) ){
           //Add to list
           *posPtr++ = x;
           *posPtr++ = z;
           }
           }
           } else {
           //Height range
           Real min,   max;
           if (  minY ) min = minY; else min = Math::NEG_INFINITY;
           if (  maxY ) max = maxY; else max = Math::POS_INFINITY;
          
           for (  unsigned int i = 0; i < grassCount; ++i ){
           //Pick a random position
           float x = Math::RangeRandom(  page.bounds.left,   page.bounds.right );
           float z = Math::RangeRandom(  page.bounds.top,   page.bounds.bottom );
          
           //Determine whether this grass will be added based on the local density.
           //For example,   if localDensity is .32,   grasses will be added 32% of the time.
           if (  Math::UnitRandom(   ) < densityMap->_getDensityAt_Bilinear(  x,   z ) ){
           //Calculate height
           float y = parent->heightFunction(  x,   z,   parent->heightFunctionUserData );
          
           //Add to list if in range
           if (  y >= min && y <= max ){
           //Add to list
           *posPtr++ = x;
           *posPtr++ = z;
           }
           }
           }
           }
          
           grassCount = (  posPtr - posBuff ) / 2;
           return grassCount;
          }
          
     942  void GrassLayer::setColorMap(  const String &mapFile,   MapChannel channel )
          {
           if (  colorMap ){
           colorMap->unload(   );
           colorMap = NULL;
           }
           if (  mapFile != "" ){
           colorMap = ColorMap::load(  mapFile,   channel );
           colorMap->setMapBounds(  mapBounds );
           colorMap->setFilter(  colorMapFilter );
           }
          }
          
     955  void GrassLayer::setColorMap(  Texture *map,   MapChannel channel )
          {
           if (  colorMap ){
           colorMap->unload(   );
           colorMap = NULL;
           }
           if (  map ){
           colorMap = ColorMap::load(  map,   channel );
           colorMap->setMapBounds(  mapBounds );
           colorMap->setFilter(  colorMapFilter );
           }
          }
          
     968  void GrassLayer::setColorMapFilter(  MapFilter filter )
          {
           colorMapFilter = filter;
           if (  colorMap )
           colorMap->setFilter(  colorMapFilter );
          }
          
     975  void GrassLayerBase::_updateShaders(   )
          {
           if (  shaderNeedsUpdate ){
           shaderNeedsUpdate = false;
          
           //Proceed only if there is no custom vertex shader and the user's computer supports vertex shaders
           const RenderSystemCapabilities *caps = Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   );
           if (  caps->hasCapability(  RSC_VERTEX_PROGRAM ) ){
           //Generate a string ID that identifies the current set of vertex shader options
           StringUtil::StrStreamType tmpName;
           tmpName << "GrassVS_";
           if (  animate )
           tmpName << "anim_";
           if (  blend )
           tmpName << "blend_";
           tmpName << renderTechnique << "_";
           tmpName << fadeTechnique << "_";
           if (  fadeTechnique == FADETECH_GROW || fadeTechnique == FADETECH_ALPHAGROW )
           tmpName << maxHeight << "_";
           tmpName << "vp";
           const String vsName = tmpName.str(   );
          
           //Generate a string ID that identifies the material combined with the vertex shader
           const String matName = material->getName(   ) + "_" + vsName;
          
           //Check if the desired material already exists (  if not,   create it )
           MaterialPtr tmpMat = MaterialManager::getSingleton(   ).getByName(  matName );
           if (  tmpMat.isNull(   ) ){
           //Clone the original material
           tmpMat = material->clone(  matName );
          
           //Disable lighting
           tmpMat->setLightingEnabled(  false );
           //tmpMat->setReceiveShadows(  false );
          
           //Check if the desired shader already exists (  if not,   compile it )
           HighLevelGpuProgramPtr vertexShader = HighLevelGpuProgramManager::getSingleton(   ).getByName(  vsName );
           if (  vertexShader.isNull(   ) ){
           //Generate the grass shader
           String vertexProgSource;
           vertexProgSource =
           "void main(   \n"
           " float4 iPosition : POSITION,   \n"
           " float4 iColor : COLOR,   \n"
           " float2 iUV : TEXCOORD0,   \n"
           " out float4 oPosition : POSITION,   \n"
           " out float4 oColor : COLOR,   \n"
           " out float2 oUV : TEXCOORD0,   \n";
          
           if (  animate ) vertexProgSource +=
           " uniform float time,   \n"
           " uniform float frequency,   \n"
           " uniform float4 direction,   \n";
          
           if (  fadeTechnique == FADETECH_GROW || fadeTechnique == FADETECH_ALPHAGROW ) vertexProgSource +=
           " uniform float grassHeight,   \n";
          
           if (  renderTechnique == GRASSTECH_SPRITE ) vertexProgSource +=
           " float4 iNormal : NORMAL,   \n";
          
           vertexProgSource +=
           " uniform float4x4 worldViewProj,   \n"
           " uniform float3 camPos,   \n"
           " uniform float fadeRange  ) \n"
           "{ \n"
           " oColor.rgb = iColor.rgb; \n"
           " float4 position = iPosition; \n"
           " float dist = distance(  camPos.xz,   position.xz ); \n";
          
           if (  fadeTechnique == FADETECH_ALPHA || fadeTechnique == FADETECH_ALPHAGROW ) vertexProgSource +=
           //Fade out in the distance
           " oColor.a = 2.0f - (  2.0f * dist / fadeRange ); \n";
           else vertexProgSource +=
           " oColor.a = 1.0f; \n";
          
           vertexProgSource +=
           " float oldposx = position.x; \n";
          
           if (  renderTechnique == GRASSTECH_SPRITE ) vertexProgSource +=
           //Face the camera
           " float3 dirVec = (  float3 )position - (  float3 )camPos; \n"
           " float3 p = normalize(  cross(  float4(  0,  1,  0,  0 ),   dirVec ) ); \n"
           " position += float4(  p.x * iNormal.x,   iNormal.y,   p.z * iNormal.x,   0 ); \n";
          
           if (  animate ) vertexProgSource +=
           " if (  iUV.y == 0.0f ){ \n"
           //Wave grass in breeze
           " float offset = sin(  time + oldposx * frequency ); \n"
           " position += direction * offset; \n"
           " } \n";
          
           if (  blend && animate ) vertexProgSource +=
           " else { \n";
           else if (  blend ) vertexProgSource +=
           " if (  iUV.y != 0.0f ){ \n";
          
           if (  blend ) vertexProgSource +=
           //Blend the base of nearby grass into the terrain
           " if (  oColor.a >= 1.0f ) \n"
           " oColor.a = 4.0f * (  (  dist / fadeRange ) - 0.1f ); \n"
           " } \n";
          
           if (  fadeTechnique == FADETECH_GROW || fadeTechnique == FADETECH_ALPHAGROW ) vertexProgSource +=
           " float offset = (  2.0f * dist / fadeRange ) - 1.0f; \n"
           " position.y -= grassHeight * clamp(  offset,   0,   1 ); ";
          
           vertexProgSource +=
           " oPosition = mul(  worldViewProj,   position ); \n";
          
           vertexProgSource +=
           " oUV = iUV;\n"
           "}";
          
           vertexShader = HighLevelGpuProgramManager::getSingleton(   ).createProgram(  
           vsName,  
           ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,  
           "cg",   GPT_VERTEX_PROGRAM );
          
           vertexShader->setSource(  vertexProgSource );
           vertexShader->setParameter(  "profiles",   "vs_1_1 arbvp1" );
           vertexShader->setParameter(  "entry_point",   "main" );
           vertexShader->load(   );
           }
           //Now the vertex shader (  vertexShader ) has either been found or just generated
           //(  depending on whether or not it was already generated ).
          
           //Apply the shader to the material
           Pass *pass = tmpMat->getTechnique(  0 )->getPass(  0 );
           pass->setVertexProgram(  vsName );
           GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters(   );
          
           params->setNamedAutoConstant(  "worldViewProj",   GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX );
           params->setNamedAutoConstant(  "camPos",   GpuProgramParameters::ACT_CAMERA_POSITION_OBJECT_SPACE );
           params->setNamedAutoConstant(  "fadeRange",   GpuProgramParameters::ACT_CUSTOM,   1 );
          
           if (  animate ){
           params->setNamedAutoConstant(  "time",   GpuProgramParameters::ACT_CUSTOM,   1 );
           params->setNamedAutoConstant(  "frequency",   GpuProgramParameters::ACT_CUSTOM,   1 );
           params->setNamedAutoConstant(  "direction",   GpuProgramParameters::ACT_CUSTOM,   4 );
           }
          
           if (  fadeTechnique == FADETECH_GROW || fadeTechnique == FADETECH_ALPHAGROW ){
           params->setNamedAutoConstant(  "grassHeight",   GpuProgramParameters::ACT_CUSTOM,   1 );
           params->setNamedConstant(  "grassHeight",   maxHeight * 1.05f );
           }
          
           float farViewDist = geom->getDetailLevels(   ).front(   )->getFarRange(   );
           pass->getVertexProgramParameters(   )->setNamedConstant(  "fadeRange",   farViewDist / 1.225f );
           //Note: 1.225 ~= sqrt(  1.5 ),   which is necessary since the far view distance is measured from the centers
           //of pages,   while the vertex shader needs to fade grass completely out (  including the closest corner )
           //before the page center is out of range.
           }
           //Now the material (  tmpMat ) has either been found or just created (  depending on whether or not it was already
           //created ). The appropriate vertex shader should be applied and the material is ready for use.
          
           //Apply the new material
           material = tmpMat;
           }
           }
          }
          
          
          unsigned long GrassPage::GUID = 0;
          
    1139  void GrassPage::init(  PagedGeometry *geom )
          {
           sceneMgr = geom->getSceneManager(   );
           rootNode = geom->getSceneNode(   );
          }
          
    1145  GrassPage::~GrassPage(   )
          {
           removeEntities(   );
          }
          
    1150  void GrassPage::addEntity(  Entity *entity,   const Vector3 &position,   const Quaternion &rotation,   const Vector3 &scale,   const Ogre::ColourValue &color )
          {
           SceneNode *node = rootNode->createChildSceneNode(   );
           node->setPosition(  position );
           nodeList.push_back(  node );
          
           Entity *ent = entity->clone(  getUniqueID(   ) );
           ent->setCastShadows(  false );
           ent->setRenderQueueGroup(  entity->getRenderQueueGroup(   ) );
           node->attachObject(  ent );
          }
          
    1162  void GrassPage::removeEntities(   )
          {
           std::list<SceneNode*>::iterator i;
           for (  i = nodeList.begin(   ); i != nodeList.end(   ); ++i ){
           SceneNode *node = *i;
           sceneMgr->destroyEntity(  static_cast<Entity*>(  node->getAttachedObject(  0 ) ) );
           sceneMgr->destroySceneNode(  node->getName(   ) );
           }
           nodeList.clear(   );
          }
          
    1173  void GrassPage::setVisible(  bool visible )
          {
           std::list<SceneNode*>::iterator i;
           for (  i = nodeList.begin(   ); i != nodeList.end(   ); ++i ){
           SceneNode *node = *i;
           node->setVisible(  visible );
           }
          }
          }

./components/ogre/environment/pagedgeometry/source/ImpostorPage.cpp

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //ImpostorPage.cpp
          //ImposterPage is an extension to PagedGeometry which displays entities as imposters.
          //-------------------------------------------------------------------------------------
          
          #include "ImpostorPage.h"
          #include "StaticBillboardSet.h"
          
          #include "OgreRoot.h"
          #include "OgreTimer.h"
          #include "OgreCamera.h"
          #include "OgreVector3.h"
          #include "OgreQuaternion.h"
          #include "OgreEntity.h"
          #include "OgreSubEntity.h"
          #include "OgreHardwarePixelBuffer.h"
          using namespace Ogre;
          
          namespace PagedGeometry {
          
          //-------------------------------------------------------------------------------------
          
          unsigned int ImpostorPage::selfInstances = 0;
          
          int ImpostorPage::impostorResolution = 128;
          ColourValue ImpostorPage::impostorBackgroundColor = ColourValue(  0.0f,   0.3f,   0.0f,   0.0f );
          BillboardOrigin ImpostorPage::impostorPivot = BBO_CENTER;
          
          
      39  void ImpostorPage::init(  PagedGeometry *geom )
          {
           //Save pointers to PagedGeometry object
           sceneMgr = geom->getSceneManager(   );
           this->geom = geom;
          
           //Init. variables
           setBlendMode(  ALPHA_REJECT_IMPOSTOR );
          
           if (  ++selfInstances == 1 ){
           //Set up a single instance of a scene node which will be used when rendering impostor textures
           geom->getSceneNode(   )->createChildSceneNode(  "ImpostorPage::renderNode" );
           }
          }
          
      54  ImpostorPage::~ImpostorPage(   )
          {
           //Delete all impostor batches
           std::map<String,   ImpostorBatch *>::iterator iter;
           for (  iter = impostorBatches.begin(   ); iter != impostorBatches.end(   ); ++iter ){
           ImpostorBatch *ibatch = iter->second;
           delete ibatch;
           }
          
           if (  --selfInstances == 0 ){
           sceneMgr->destroySceneNode(  "ImpostorPage::renderNode" );
           }
          }
          
          
      69  void ImpostorPage::setRegion(  Ogre::Real left,   Ogre::Real top,   Ogre::Real right,   Ogre::Real bottom )
          {
           //Calculate center of region
           center.x = (  left + right ) * 0.5f;
           center.z = (  top + bottom ) * 0.5f;
          
           center.y = 0.0f; //The center.y value is calculated when the entities are added
           aveCount = 0;
          }
          
      79  void ImpostorPage::addEntity(  Entity *ent,   const Vector3 &position,   const Quaternion &rotation,   const Vector3 &scale,   const Ogre::ColourValue &color )
          {
           //Get the impostor batch that this impostor will be added to
           ImpostorBatch *ibatch = ImpostorBatch::getBatch(  this,   ent );
          
           //Then add the impostor to the batch
           ibatch->addBillboard(  position,   rotation,   scale,   color );
          
           //Add the Y position to the center.y value (  to be averaged later )
           center.y += position.y + ent->getBoundingBox(   ).getCenter(   ).y * scale.y;
           ++aveCount;
          }
          
      92  void ImpostorPage::build(   )
          {
           //Calculate the average Y value of all the added entities
           if (  aveCount != 0 )
           center.y /= aveCount;
           else
           center.y = 0.0f;
          
           //Build all batches
           std::map<String,   ImpostorBatch *>::iterator iter;
           for (  iter = impostorBatches.begin(   ); iter != impostorBatches.end(   ); ++iter ){
           ImpostorBatch *ibatch = iter->second;
           ibatch->build(   );
           }
          }
          
     108  void ImpostorPage::setVisible(  bool visible )
          {
           //Update visibility status of all batches
           std::map<String,   ImpostorBatch *>::iterator iter;
           for (  iter = impostorBatches.begin(   ); iter != impostorBatches.end(   ); ++iter ){
           ImpostorBatch *ibatch = iter->second;
           ibatch->setVisible(  visible );
           }
          }
          
     118  void ImpostorPage::setFade(  bool enabled,   Real visibleDist,   Real invisibleDist )
          {
           //Update fade status of all batches
           std::map<String,   ImpostorBatch *>::iterator iter;
           for (  iter = impostorBatches.begin(   ); iter != impostorBatches.end(   ); ++iter ){
           ImpostorBatch *ibatch = iter->second;
           ibatch->setFade(  enabled,   visibleDist,   invisibleDist );
           }
          }
          
     128  void ImpostorPage::removeEntities(   )
          {
           //Clear all impostor batches
           std::map<String,   ImpostorBatch *>::iterator iter;
           for (  iter = impostorBatches.begin(   ); iter != impostorBatches.end(   ); ++iter ){
           ImpostorBatch *ibatch = iter->second;
           ibatch->clear(   );
           }
          
           //Reset y center
           center.y = 0.0f;
           aveCount = 0;
          }
          
     142  void ImpostorPage::update(   )
          {
           //Calculate the direction the impostor batches should be facing
           Vector3 camPos = geom->_convertToLocal(  geom->getCamera(   )->getDerivedPosition(   ) );
          
           //Update all batches
           float distX = camPos.x - center.x;
           float distZ = camPos.z - center.z;
           float distY = camPos.y - center.y;
           float distRelZ = Math::Sqrt(  distX * distX + distZ * distZ );
           Radian pitch = Math::ATan2(  distY,   distRelZ );
          
           Radian yaw;
           if (  distRelZ > geom->getPageSize(   ) * 3 ) {
           yaw = Math::ATan2(  distX,   distZ );
           } else {
           Vector3 dir = geom->_convertToLocal(  geom->getCamera(   )->getDerivedDirection(   ) );
           yaw = Math::ATan2(  -dir.x,   -dir.z );
           }
          
           std::map<String,   ImpostorBatch *>::iterator iter;
           for (  iter = impostorBatches.begin(   ); iter != impostorBatches.end(   ); ++iter ){
           ImpostorBatch *ibatch = iter->second;
           ibatch->setAngle(  pitch.valueDegrees(   ),   yaw.valueDegrees(   ) );
           }
          }
          
     169  void ImpostorPage::regenerate(  Entity *ent )
          {
           ImpostorTexture *tex = ImpostorTexture::getTexture(  NULL,   ent );
           if (  tex != NULL )
           tex->regenerate(   );
          }
          
     176  void ImpostorPage::regenerateAll(   )
          {
           ImpostorTexture::regenerateAll(   );
          }
          
     181  void ImpostorPage::setImpostorPivot(  BillboardOrigin origin )
          {
           if (  origin != BBO_CENTER && origin != BBO_BOTTOM_CENTER )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Invalid origin - only BBO_CENTER and BBO_BOTTOM_CENTER is supported",   "ImpostorPage::setImpostorPivot(   )" );
           impostorPivot = origin;
          }
          
          //-------------------------------------------------------------------------------------
          
          unsigned long ImpostorBatch::GUID = 0;
          
     192  ImpostorBatch::ImpostorBatch(  ImpostorPage *group,   Entity *entity )
          {
           //Render impostor texture for this entity
           tex = ImpostorTexture::getTexture(  group,   entity );
          
           //Create billboard set
           bbset = new StaticBillboardSet(  group->sceneMgr,   group->geom->getSceneNode(   ) );
           bbset->setTextureStacksAndSlices(  IMPOSTOR_PITCH_ANGLES,   IMPOSTOR_YAW_ANGLES );
          
           setBillboardOrigin(  ImpostorPage::impostorPivot );
          
           //Default the angle to 0 degrees
           pitchIndex = -1;
           yawIndex = -1;
           setAngle(  0.0f,   0.0f );
          
           //Init. variables
           igroup = group;
          }
          
     212  ImpostorBatch::~ImpostorBatch(   )
          {
           //Delete billboard set
           delete bbset;
           //Delete texture
           ImpostorTexture::removeTexture(  tex );
          }
          
          //Returns a pointer to an ImpostorBatch for the specified entity in the specified
          //ImpostorPage. If one does not already exist,   one will automatically be created.
     222  ImpostorBatch *ImpostorBatch::getBatch(  ImpostorPage *group,   Entity *entity )
          {
           //Search for an existing impostor batch for this entity
           String entityKey = ImpostorBatch::generateEntityKey(  entity );
           std::map<String,   ImpostorBatch *>::iterator iter;
           iter = group->impostorBatches.find(  entityKey );
          
           //If found..
           if (  iter != group->impostorBatches.end(   ) ){
           //Return it
           return iter->second;
           } else {
           //Otherwise,   create a new batch
           ImpostorBatch *batch = new ImpostorBatch(  group,   entity );
          
           //Add it to the impostorBatches list
           typedef std::pair<String,   ImpostorBatch *> ListItem;
           group->impostorBatches.insert(  ListItem(  entityKey,   batch ) );
          
           //Return it
           return batch;
           }
          }
          
          //Rotates all the impostors to the specified angle (  virtually - it actually changes
          //their materials to produce this same effect )
     248  void ImpostorBatch::setAngle(  float pitchDeg,   float yawDeg )
          {
           //Calculate pitch material index
           Ogre::uint16 newPitchIndex;
           if (  pitchDeg > 0 ){
           newPitchIndex = static_cast<Ogre::uint16>(  IMPOSTOR_PITCH_ANGLES * (  pitchDeg / 67.5f ) );
           if (  newPitchIndex > IMPOSTOR_PITCH_ANGLES-1 ) newPitchIndex = IMPOSTOR_PITCH_ANGLES-1;
           } else {
           newPitchIndex = 0;
           }
          
           //Calculate yaw material index
           Ogre::uint16 newYawIndex;
           if (  yawDeg > 0 ){
           newYawIndex = static_cast<Ogre::uint16>(  IMPOSTOR_YAW_ANGLES * (  yawDeg / 360.0f ) + 0.5f ) % IMPOSTOR_YAW_ANGLES;
           } else {
           newYawIndex = static_cast<Ogre::uint16>(  IMPOSTOR_YAW_ANGLES + IMPOSTOR_YAW_ANGLES * (  yawDeg / 360.0f ) + 0.5f ) % IMPOSTOR_YAW_ANGLES;
           }
          
           //Change materials if necessary
           if (  newPitchIndex != pitchIndex || newYawIndex != yawIndex ){
           pitchIndex = newPitchIndex;
           yawIndex = newYawIndex;
           bbset->setMaterial(  tex->material[pitchIndex][yawIndex]->getName(   ) );
           }
          }
          
     275  void ImpostorBatch::setBillboardOrigin(  BillboardOrigin origin )
          {
           bbset->setBillboardOrigin(  origin );
          
           if (  bbset->getBillboardOrigin(   ) == BBO_CENTER )
           entityBBCenter = tex->entityCenter;
           else if (  bbset->getBillboardOrigin(   ) == BBO_BOTTOM_CENTER )
           entityBBCenter = Vector3(  tex->entityCenter.x,   tex->entityCenter.y - tex->entityRadius,   tex->entityCenter.z );
          }
          
     285  String ImpostorBatch::generateEntityKey(  Entity *entity )
          {
           StringUtil::StrStreamType entityKey;
           entityKey << entity->getMesh(   )->getName(   );
           for (  Ogre::uint i = 0; i < entity->getNumSubEntities(   ); ++i ){
           entityKey << "-" << entity->getSubEntity(  i )->getMaterialName(   );
           }
           return entityKey.str(   );
          }
          
          //-------------------------------------------------------------------------------------
          
          std::map<String,   ImpostorTexture *> ImpostorTexture::selfList;
          unsigned long ImpostorTexture::GUID = 0;
          
          //Do not use this constructor yourself - instead,   call getTexture(   )
          //to get/create an ImpostorTexture for an Entity.
     302  ImpostorTexture::ImpostorTexture(  ImpostorPage *group,   Entity *entity )
          {
           //Store scene manager and entity
           ImpostorTexture::sceneMgr = group->sceneMgr;
           ImpostorTexture::entity = entity;
          
           //Add self to list of ImpostorTexture's
           entityKey = ImpostorBatch::generateEntityKey(  entity );
           typedef std::pair<String,   ImpostorTexture *> ListItem;
           selfList.insert(  ListItem(  entityKey,   this ) );
          
           //Calculate the entity's bounding box and it's diameter
           boundingBox = entity->getBoundingBox(   );
          
           //Note - this radius calculation assumes the object is somewhat rounded (  like trees/rocks/etc. )
           Real tmp;
           entityRadius = boundingBox.getMaximum(   ).x - boundingBox.getCenter(   ).x;
           tmp = boundingBox.getMaximum(   ).y - boundingBox.getCenter(   ).y;
           if (  tmp > entityRadius ) entityRadius = tmp;
           tmp = boundingBox.getMaximum(   ).z - boundingBox.getCenter(   ).z;
           if (  tmp > entityRadius ) entityRadius = tmp;
          
           entityDiameter = 2.0f * entityRadius;
           entityCenter = boundingBox.getCenter(   );
          
           //Render impostor textures
           renderTextures(  false );
          
           //Set up materials
           for (  int o = 0; o < IMPOSTOR_YAW_ANGLES; ++o ){
           for (  int i = 0; i < IMPOSTOR_PITCH_ANGLES; ++i ){
           material[i][o] = MaterialManager::getSingleton(   ).create(  getUniqueID(  "ImpostorMaterial" ),   "Impostors" );
          
           Material *m = material[i][o].getPointer(   );
           Pass *p = m->getTechnique(  0 )->getPass(  0 );
          
           TextureUnitState *t = p->createTextureUnitState(  texture->getName(   ) );
          
           t->setTextureUScroll(  (  float )o / IMPOSTOR_YAW_ANGLES );
           t->setTextureVScroll(  (  float )i / IMPOSTOR_PITCH_ANGLES );
          
           p->setLightingEnabled(  false );
           m->setReceiveShadows(  false );
          
           if (  group->getBlendMode(   ) == ALPHA_REJECT_IMPOSTOR ){
           p->setAlphaRejectSettings(  CMPF_GREATER_EQUAL,   128 );
           //p->setAlphaRejectSettings(  CMPF_GREATER_EQUAL,   64 );
           } else if (  group->getBlendMode(   ) == ALPHA_BLEND_IMPOSTOR ){
           p->setSceneBlending(  SBF_SOURCE_ALPHA,   SBF_ONE_MINUS_SOURCE_ALPHA );
           p->setDepthWriteEnabled(  false );
           }
           }
           }
          }
          
     357  void ImpostorTexture::updateMaterials(   )
          {
           for (  int o = 0; o < IMPOSTOR_YAW_ANGLES; ++o ){
           for (  int i = 0; i < IMPOSTOR_PITCH_ANGLES; ++i ){
           Material *m = material[i][o].getPointer(   );
           Pass *p = m->getTechnique(  0 )->getPass(  0 );
          
          // int x = p->getNumTextureUnitStates(   );
           TextureUnitState *t = p->getTextureUnitState(  0 );
          
           t->setTextureName(  texture->getName(   ) );
           }
           }
          }
          
     372  ImpostorTexture::~ImpostorTexture(   )
          {
           //Delete textures
           assert(  !texture.isNull(   ) );
           String texName(  texture->getName(   ) );
          
           texture.setNull(   );
           if (  TextureManager::getSingletonPtr(   ) )
           TextureManager::getSingleton(   ).remove(  texName );
          
           //Delete materials
           for (  int o = 0; o < IMPOSTOR_YAW_ANGLES; ++o ){
           for (  int i = 0; i < IMPOSTOR_PITCH_ANGLES; ++i ){
           assert (  !material[i][o].isNull(   ) );
           String matName(  material[i][o]->getName(   ) );
          
           material[i][o].setNull(   );
           if (  MaterialManager::getSingletonPtr(   ) )
           MaterialManager::getSingleton(   ).remove(  matName );
           }
           }
          
           //Remove self from list of ImpostorTexture's
           selfList.erase(  entityKey );
          }
          
     398  void ImpostorTexture::regenerate(   )
          {
           assert(  !texture.isNull(   ) );
           String texName(  texture->getName(   ) );
           texture.setNull(   );
           if (  TextureManager::getSingletonPtr(   ) )
           TextureManager::getSingleton(   ).remove(  texName );
          
           renderTextures(  true );
           updateMaterials(   );
          }
          
     410  void ImpostorTexture::regenerateAll(   )
          {
           std::map<String,   ImpostorTexture *>::iterator iter;
           for (  iter = selfList.begin(   ); iter != selfList.end(   ); ++iter ){
           iter->second->regenerate(   );
           }
          }
          
     418  void ImpostorTexture::renderTextures(  bool force )
          {
           TexturePtr renderTexture;
           RenderTexture *renderTarget;
           Camera *renderCamera;
           Viewport *renderViewport;
          
           //Set up RTT texture
           unsigned int textureSize = ImpostorPage::impostorResolution;
           renderTexture = TextureManager::getSingleton(   ).createManual(  getUniqueID(  "ImpostorTexture" ),   "Impostors",  
           TEX_TYPE_2D,   textureSize * IMPOSTOR_YAW_ANGLES,   textureSize * IMPOSTOR_PITCH_ANGLES,   0,   PF_A8R8G8B8,   TU_RENDERTARGET );
           renderTexture->setNumMipmaps(  MIP_UNLIMITED );
          
           //Set up render target
           renderTarget = renderTexture->getBuffer(   )->getRenderTarget(   );
           renderTarget->setAutoUpdated(  false );
          
           //Set up camera
           renderCamera = sceneMgr->createCamera(  getUniqueID(  "ImpostorCam" ) );
           renderCamera->setLodBias(  1000.0f );
           renderViewport = renderTarget->addViewport(  renderCamera );
           renderViewport->setOverlaysEnabled(  false );
           renderViewport->setClearEveryFrame(  true );
           renderViewport->setShadowsEnabled(  false );
           renderViewport->setBackgroundColour(  ImpostorPage::impostorBackgroundColor );
          
           //Set up scene node
           SceneNode* node = sceneMgr->getSceneNode(  "ImpostorPage::renderNode" );
          
           Ogre::SceneNode* oldSceneNode = entity->getParentSceneNode(   );
           if (  oldSceneNode ) {
           oldSceneNode->detachObject(  entity );
           }
           node->attachObject(  entity );
           node->setPosition(  -entityCenter );
          
           //Set up camera FOV
           const Real objDist = entityRadius * 100;
           const Real nearDist = objDist - (  entityRadius + 1 );
           const Real farDist = objDist + (  entityRadius + 1 );
          
           renderCamera->setAspectRatio(  1.0f );
           renderCamera->setFOVy(  Math::ATan(  entityDiameter / objDist ) );
           renderCamera->setNearClipDistance(  nearDist );
           renderCamera->setFarClipDistance(  farDist );
          
           //Disable mipmapping (  without this,   masked textures look bad )
           MaterialManager *mm = MaterialManager::getSingletonPtr(   );
           FilterOptions oldMinFilter = mm->getDefaultTextureFiltering(  FT_MIN );
           FilterOptions oldMagFilter = mm->getDefaultTextureFiltering(  FT_MAG );
           FilterOptions oldMipFilter = mm->getDefaultTextureFiltering(  FT_MIP );
           mm->setDefaultTextureFiltering(  FO_POINT,   FO_LINEAR,   FO_NONE );
          
           //Disable fog
           FogMode oldFogMode = sceneMgr->getFogMode(   );
           ColourValue oldFogColor = sceneMgr->getFogColour(   );
           Real oldFogDensity = sceneMgr->getFogDensity(   );
           Real oldFogStart = sceneMgr->getFogStart(   );
           Real oldFogEnd = sceneMgr->getFogEnd(   );
           sceneMgr->setFog(  FOG_NONE );
          
           //Only render the entity
           sceneMgr->setSpecialCaseRenderQueueMode(  Ogre::SceneManager::SCRQM_INCLUDE );
           sceneMgr->addSpecialCaseRenderQueue(  RENDER_QUEUE_6 );
          
           //uint8 oldRenderQueueGroup = entity->getRenderQueueGroup(   );
           entity->setRenderQueueGroup(  RENDER_QUEUE_6 );
          
           //Calculate the filename used to identity this render
           ResourceGroupManager::getSingleton(   ).addResourceLocation(  ".",   "FileSystem",   "BinFolder" );
           String fileName = "Impostor." + removeInvalidCharacters(  entity->getMesh(   )->getGroup(   ) )
           + '.' + removeInvalidCharacters(  entityKey )
           + '.' + StringConverter::toString(  textureSize ) + ".png";
          
           //Attempt to load the pre-render file if allowed
           bool needsRegen = force;
           if (  !needsRegen ){
           try{
           texture = TextureManager::getSingleton(   ).load(  fileName,   "BinFolder",   TEX_TYPE_2D,   MIP_UNLIMITED );
           }
           catch (  ... ){
           needsRegen = true;
           }
           }
          
           if (  needsRegen ){
           //If this has not been pre-rendered,   do so now
           const float xDivFactor = 1.0f / IMPOSTOR_YAW_ANGLES;
           const float yDivFactor = 1.0f / IMPOSTOR_PITCH_ANGLES;
           for (  int o = 0; o < IMPOSTOR_PITCH_ANGLES; ++o ){ //4 pitch angle renders
           Radian pitch = Degree(  (  90.0f * o ) * yDivFactor ); //0,   22.5,   45,   67.5
          
           for (  int i = 0; i < IMPOSTOR_YAW_ANGLES; ++i ){ //8 yaw angle renders
           Radian yaw = Degree(  (  360.0f * i ) * xDivFactor ); //0,   45,   90,   135,   180,   225,   270,   315
          
           //Position camera
           renderCamera->setPosition(  0,   0,   0 );
           renderCamera->setOrientation(  Quaternion::IDENTITY );
           renderCamera->pitch(  -pitch );
           renderCamera->yaw(  yaw );
           renderCamera->moveRelative(  Vector3(  0,   0,   objDist ) );
          
           //Render the impostor
           renderViewport->setDimensions(  (  float )(  i ) * xDivFactor,   (  float )(  o ) * yDivFactor,   xDivFactor,   yDivFactor );
           renderTarget->update(   );
           }
           }
          
           //Save RTT to file
           renderTarget->writeContentsToFile(  fileName );
          
           //Load the render into the appropriate texture view
           texture = TextureManager::getSingleton(   ).load(  fileName,   "BinFolder",   TEX_TYPE_2D,   MIP_UNLIMITED );
           }
          
          
           //entity->setRenderQueueGroup(  oldRenderQueueGroup );
           sceneMgr->removeSpecialCaseRenderQueue(  RENDER_QUEUE_6 );
           sceneMgr->setSpecialCaseRenderQueueMode(  Ogre::SceneManager::SCRQM_EXCLUDE );
          
           //Re-enable mipmapping
           mm->setDefaultTextureFiltering(  oldMinFilter,   oldMagFilter,   oldMipFilter );
          
           //Re-enable fog
           sceneMgr->setFog(  oldFogMode,   oldFogColor,   oldFogDensity,   oldFogStart,   oldFogEnd );
          
           //Delete camera
           renderTarget->removeViewport(  0 );
           renderCamera->getSceneManager(   )->destroyCamera(  renderCamera );
          
           //Delete scene node
           node->detachAllObjects(   );
           if (  oldSceneNode ) {
           oldSceneNode->attachObject(  entity );
           }
           //Delete RTT texture
           assert(  !renderTexture.isNull(   ) );
           String texName2(  renderTexture->getName(   ) );
          
           renderTexture.setNull(   );
           if (  TextureManager::getSingletonPtr(   ) )
           TextureManager::getSingleton(   ).remove(  texName2 );
          }
          
     562  String ImpostorTexture::removeInvalidCharacters(  String s )
          {
           StringUtil::StrStreamType s2;
          
           for (  unsigned int i = 0; i < s.length(   ); ++i ){
           char c = s[i];
           if (  c == '/' || c == '\\' || c == ':' || c == '*' || c == '?' || c == '\"' || c == '<' || c == '>' || c == '|' ){
           s2 << '-';
           } else {
           s2 << c;
           }
           }
          
           return s2.str(   );
          }
          
     578  void ImpostorTexture::removeTexture(  ImpostorTexture* Texture )
          {
           //Search for an existing impostor texture,   in case it was already deleted
           for(  std::map<String,   ImpostorTexture *>::iterator iter=selfList.begin(   );
           iter!=selfList.end(   ); ++iter )
           {
           if(  iter->second==Texture )
           {
           delete Texture;
           return;
           }
           }
           // no need to anything if it was not found,   chances are that it was already deleted
          }
          
     593  ImpostorTexture *ImpostorTexture::getTexture(  ImpostorPage *group,   Entity *entity )
          {
           //Search for an existing impostor texture for the given entity
           String entityKey = ImpostorBatch::generateEntityKey(  entity );
           std::map<String,   ImpostorTexture *>::iterator iter;
           iter = selfList.find(  entityKey );
          
           //If found..
           if (  iter != selfList.end(   ) ){
           //Return it
           return iter->second;
           } else {
           if (  group ){
           //Otherwise,   return a new texture
           return (  new ImpostorTexture(  group,   entity ) );
           } else {
           //But if group is null,   return null
           return NULL;
           }
           }
          }
          }

./components/ogre/environment/pagedgeometry/source/PagedGeometry.cpp

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //PagedGeometry.h
          //Main source file for the PagedGeometry engine.
          //-------------------------------------------------------------------------------------
          
          #include "PagedGeometry.h"
          #include "StaticBillboardSet.h"
          
          #include "OgreRoot.h"
          #include "OgreTimer.h"
          #include "OgreCamera.h"
          #include "OgreVector3.h"
          using namespace Ogre;
          
          namespace PagedGeometry {
          
          //-------------------------------------------------------------------------------------
      27  PagedGeometry::PagedGeometry(  Camera* cam,   const Real pageSize )
          {
           //Setup camera,   scene manager,   and scene node
           if (  cam ){
           sceneCam = cam;
           sceneMgr = sceneCam->getSceneManager(   );
           oldCamPos = sceneCam->getDerivedPosition(   );
          
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           rootNode = sceneMgr->getRootSceneNode(   )->createChildSceneNode(   ); //Create PagedGeometry's root node
           #else
           rootNode = sceneMgr->getRootSceneNode(   );
           #endif
           } else {
           sceneCam = NULL;
           sceneMgr = NULL;
           rootNode = NULL;
           oldCamPos = Vector3::ZERO;
           }
          
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           //Setup default coordinate system
           coordinateSystemQuat = Quaternion::IDENTITY;
           #endif
          
           //Init. timer
           timer.reset(   );
           lastTime = 0;
          
           //Setup page size / bounds
           PagedGeometry::pageSize = pageSize;
           m_bounds = TBounds(  0,   0,   0,   0 );
          
           //Misc.
           pageLoader = NULL;
          }
          
      64  PagedGeometry::~PagedGeometry(   )
          {
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           //Remove PagedGeometry's coordinate system node
           if (  rootNode )
           sceneMgr->destroySceneNode(  rootNode->getName(   ) );
           #endif
          
           //Remove all page managers and the geometry associated with them
           removeDetailLevels(   );
          }
          
      76  void PagedGeometry::setPageLoader(  PageLoader *loader )
          {
           pageLoader = loader;
          }
          
      81  void PagedGeometry::setCamera(  Camera *cam )
          {
           if (  cam == NULL ){
           //Simply set camera to null
           sceneCam = NULL;
           } else {
           if (  sceneMgr && cam->getSceneManager(   ) != sceneMgr )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "The specified camera is from the wrong SceneManager",   "PagedGeometry::setCamera(   )" );
          
           if (  cam == lastSceneCam ){
           //If the cache values for this camera are preserved,   use them
           std::swap(  oldCamPos,   lastOldCamPos );
           std::swap(  sceneCam,   lastSceneCam );
           } else {
           lastSceneCam = sceneCam;
           lastOldCamPos = oldCamPos;
           sceneCam = cam;
           }
          
           //If sceneMgre is NULL (  this only occurs the first time a camera is set ),  
           //then set the scene manager (  it won't change after this point ).
           if (  sceneMgr == NULL )
           sceneMgr = sceneCam->getSceneManager(   );
          
           //If rootNode is NULL (  this also only occurs the first time a camera is set ),  
           //the create a scene node (  it won't change after this point ) for the coordinate
           //system translations.
           if (  rootNode == NULL ){
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           rootNode = sceneMgr->getRootSceneNode(   )->createChildSceneNode(   );
           rootNode->setOrientation(  coordinateSystemQuat );
           #else
           rootNode = sceneMgr->getRootSceneNode(   );
           #endif
           }
           }
          }
          
          #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
     120  void PagedGeometry::setCoordinateSystem(  Vector3 up,   Vector3 right )
          {
           up.z = -up.z;
           Vector3 forward = right.crossProduct(  up );
           coordinateSystemQuat = Quaternion(  right,   up,   forward );
          
           if (  rootNode )
           rootNode->setOrientation(  coordinateSystemQuat );
          }
          #endif
          
          #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
     132  Vector3 PagedGeometry::_convertToLocal(  const Vector3 &globalVec )
          {
           assert(  getSceneNode(   ) );
           //Convert from the given global position to the local coordinate system of PagedGeometry's root scene node.
           return (  getSceneNode(   )->getOrientation(   ).Inverse(   ) * globalVec );
          }
          #else
          //Default coordinate system - no conversion
     140  Vector3 PagedGeometry::_convertToLocal(  const Vector3 &globalVec )
          {
           return globalVec;
          }
          #endif
          
     146  void PagedGeometry::setPageSize(  Real size )
          {
           if (  !managerList.empty(   ) )
           OGRE_EXCEPT(  0,   "PagedGeometry::setPageSize(   ) cannot be called after detail levels have been added. Call removeDetailLevels(   ) first.",   "PagedGeometry::setPageSize(   )" );
          
           pageSize = size;
          }
          
     154  void PagedGeometry::setInfinite(   )
          {
           if (  !managerList.empty(   ) )
           OGRE_EXCEPT(  0,   "PagedGeometry::setInfinite(   ) cannot be called after detail levels have been added. Call removeDetailLevels(   ) first.",   "PagedGeometry::setInfinite(   )" );
          
           m_bounds = TBounds(  0,   0,   0,   0 );
          }
          
     162  void PagedGeometry::setBounds(  TBounds bounds )
          {
           if (  !managerList.empty(   ) )
           OGRE_EXCEPT(  0,   "PagedGeometry::setBounds(   ) cannot be called after detail levels have been added. Call removeDetailLevels(   ) first.",   "PagedGeometry::setBounds(   )" );
           if (  bounds.width(   ) != bounds.height(   ) )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Bounds must be square",   "PagedGeometry::setBounds(   )" );
           if (  bounds.width(   ) <= 0 || bounds.height(   ) <=0 )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Bounds must have positive width and height",   "PagedGeometry::setBounds(   )" );
          
           m_bounds = bounds;
          }
          
     174  void PagedGeometry::removeDetailLevels(   )
          {
           std::list<GeometryPageManager *>::iterator it;
          
           //Delete all the page managers
           for (  it = managerList.begin(   ); it != managerList.end(   ); ++it ){
           GeometryPageManager *mgr = *it;
           delete mgr;
           }
          
           //Clear the page manager list
           managerList.clear(   );
          }
          
     188  void PagedGeometry::update(   )
          {
           //If no camera has been set,   then return without doing anything
           if (  sceneCam == NULL )
           return;
          
           //Calculate time since last update
           unsigned long deltaTime,   tmp;
           tmp = timer.getMilliseconds(   );
           deltaTime = tmp - lastTime;
           lastTime = tmp;
          
           //Get camera position and speed
           Vector3 camPos = _convertToLocal(  sceneCam->getDerivedPosition(   ) );
           Vector3 camSpeed; //Speed in units-per-millisecond
           if (  deltaTime == 0 ){
           camSpeed.x = 0;
           camSpeed.y = 0;
           camSpeed.z = 0;
           } else {
           camSpeed = (  camPos - oldCamPos ) / deltaTime;
           }
           oldCamPos = camPos;
          
           if (  pageLoader != 0 ){
           //Update the PageLoader
           pageLoader->frameUpdate(   );
          
           //Update all the page managers
           bool enableCache = true;
           std::list<GeometryPageManager *>::iterator it;
           GeometryPageManager *prevMgr = NULL;
           for (  it = managerList.begin(   ); it != managerList.end(   ); ++it ){
           GeometryPageManager *mgr = *it;
           mgr->update(  deltaTime,   camPos,   camSpeed,   enableCache,   prevMgr );
           prevMgr = mgr;
           }
           }
          
           //Update misc. subsystems
           StaticBillboardSet::updateAll(  _convertToLocal(  getCamera(   )->getDerivedDirection(   ) ) );
          }
          
     231  void PagedGeometry::reloadGeometry(   )
          {
           assert(  pageLoader );
          
           std::list<GeometryPageManager *>::iterator it;
           for (  it = managerList.begin(   ); it != managerList.end(   ); ++it ){
           GeometryPageManager *mgr = *it;
           mgr->reloadGeometry(   );
           }
          }
          
     242  void PagedGeometry::reloadGeometryPage(  const Vector3 &point )
          {
           if (  !pageLoader )
           return;
          
           std::list<GeometryPageManager *>::iterator it;
           for (  it = managerList.begin(   ); it != managerList.end(   ); ++it ){
           GeometryPageManager *mgr = *it;
           mgr->reloadGeometryPage(  point );
           }
          }
          
          
     255  void PagedGeometry::_addDetailLevel(  GeometryPageManager *mgr,   Real maxRange,   Real transitionLength )
          {
           //Calculate the near range
           Real minRange = 0;
           if (  !managerList.empty(   ) ){
           GeometryPageManager *lastMgr = managerList.back(   );
           minRange = lastMgr->getFarRange(   );
           }
          
           //Error check
           if (  maxRange <= minRange ){
           OGRE_EXCEPT(  1,   "Closer detail levels must be added before farther ones",   "PagedGeometry::addDetailLevel(   )" );
           }
          
           //Setup the new manager
           mgr->setNearRange(  minRange );
           mgr->setFarRange(  maxRange );
           mgr->setTransition(  transitionLength );
          
           managerList.push_back(  mgr );
          }
          
          //-------------------------------------------------------------------------------------
          
     279  GeometryPageManager::GeometryPageManager(  PagedGeometry *mainGeom )
          : mainGeom(  mainGeom )
           ,   cacheTimer(  0 ) // Reset the cache timer
           ,   scrollBuffer(  NULL )
           ,   geomGrid(  NULL )
          {
           //Use default cache speeds
           setCacheSpeed(   );
          
           //No transition default
           setTransition(  0 );
          }
          
     292  GeometryPageManager::~GeometryPageManager(   )
          {
           //Delete GeometryPage's
           for (  int x = 0; x < geomGridX; ++x )
           for (  int z = 0; z < geomGridZ; ++z )
           delete _getGridPage(  x,   z );
          
           //Deallocate arrays
           if(  geomGrid )
           delete[] geomGrid;
           if(  scrollBuffer )
           delete[] scrollBuffer;
          }
          
     306  void GeometryPageManager::update(  unsigned long deltaTime,   Vector3 &camPos,   Vector3 &camSpeed,   bool &enableCache,   GeometryPageManager *prevManager )
          {
           //-- Cache new geometry pages --
          
           //Cache 1 page ahead of the view ranges
           const Real cacheDist = farTransDist + mainGeom->getPageSize(   );
           const Real cacheDistSq = cacheDist * cacheDist;
          
           //First calculate the general area where the pages will be processed
           // 0,  0 is the left top corner of the bounding box
           int x1 = Math::Floor(  (  (  camPos.x - cacheDist ) - gridBounds.left ) / mainGeom->getPageSize(   ) );
           int x2 = Math::Floor(  (  (  camPos.x + cacheDist ) - gridBounds.left ) / mainGeom->getPageSize(   ) );
           int z1 = Math::Floor(  (  (  camPos.z - cacheDist ) - gridBounds.top ) / mainGeom->getPageSize(   ) );
           int z2 = Math::Floor(  (  (  camPos.z + cacheDist ) - gridBounds.top ) / mainGeom->getPageSize(   ) );
           if(  scrollBuffer )
           {
           //Check if the page grid needs to be scrolled
           int shiftX = 0,   shiftZ = 0;
           if (  x1 < 0 ) shiftX = x1; else if (  x2 >= geomGridX-1 ) shiftX = x2 - (  geomGridX-1 );
           if (  z1 < 0 ) shiftZ = z1; else if (  z2 >= geomGridZ-1 ) shiftZ = z2 - (  geomGridZ-1 );
           if (  shiftX != 0 || shiftZ != 0 )
           {
           //Scroll grid
           _scrollGridPages(  shiftX,   shiftZ );
          
           //Update grid bounds and processing area
           gridBounds.left += shiftX * mainGeom->getPageSize(   );
           gridBounds.right += shiftX * mainGeom->getPageSize(   );
           gridBounds.top += shiftZ * mainGeom->getPageSize(   );
           gridBounds.bottom += shiftZ * mainGeom->getPageSize(   );
           x1 -= shiftX; x2 -= shiftX;
           z1 -= shiftZ; z2 -= shiftZ;
           }
           }
           else
           {
           // make sure that values are inbounds
           if(  x2 >= geomGridX )
           x2 = geomGridX - 1;
           if(  z2 >= geomGridZ )
           z2 = geomGridZ - 1;
          
           if (  x1 < 0 )
           x1 = 0;
           if (  z1 < 0 )
           z1 = 0;
           }
           //Now,   in that general area,   find what pages are within the cacheDist radius
           //Pages within the cacheDist radius will be added to the pending block list
           //to be loaded later,   and pages within farDist will be loaded immediately.
           for (  int x = x1; x <= x2; ++x ){
           for (  int z = z1; z <= z2; ++z ){
           GeometryPage *blk = _getGridPage(  x,   z );
          
           Real dx = camPos.x - blk->_centerPoint.x;
           Real dz = camPos.z - blk->_centerPoint.z;
           Real distSq = dx * dx + dz * dz;
          
           //If the page is in the cache radius...
           if (  distSq <= cacheDistSq ){
           //If the block hasn't been loaded yet,   it should be
           if (  blk->_loaded == false ){
           //Test if the block's distance is between nearDist and farDist
           if (  distSq >= nearDistSq && distSq < farTransDistSq ){
           //If so,   load the geometry immediately
           _loadPage(  blk );
           loadedList.push_back(  blk );
           blk->_iter = (  --loadedList.end(   ) );
          
           //And remove it from the pending list if necessary
           if (  blk->_pending ){
           pendingList.remove(  blk );
           blk->_pending = false;
           }
           } else {
           //Otherwise,   add it to the pending geometry list (  if not already )
           //Pages in then pending list will be loaded later (  see below )
           if (  !blk->_pending ){
           pendingList.push_back(  blk );
           blk->_pending = true;
           }
           }
           } else {
           //Set the inactive time to 0 (  since the page is active ). This
           //must be done in order to keep it from expiring (  and deleted ).
           //This way,   blocks not in the cache radius won't have their
           //inactivity clock reset,   and they will expire in a few seconds.
           blk->_inactiveTime = 0;
           }
           }
           }
           }
          
          
           //Calculate cache speeds based on camera speed. This is important to keep the cache
           //process running smooth,   because if the cache can't keep up with the camera,   the
           //immediately visible pages will be forced to load instantly,   which can cause
           //noticeable and sudden stuttering. The cache system results in smoother performance
           //because it smooths the loading tasks out across multiple frames. For example,  
           //instead of loading 10+ blocks every 2 seconds,   the cache would load 1 block every
           //200 milliseconds.
           Real speed = Math::Sqrt(  camSpeed.x * camSpeed.x + camSpeed.z * camSpeed.z );
          
           unsigned long cacheInterval;
           if (  speed == 0 )
           cacheInterval = maxCacheInterval;
           else {
           cacheInterval = (  mainGeom->getPageSize(   ) * 0.8f ) / (  speed * pendingList.size(   ) );
           if (  cacheInterval > maxCacheInterval )
           cacheInterval = maxCacheInterval;
           }
          
          
           TPGeometryPages::iterator i1,   i2;
          
           //Now load a single geometry page periodically,   based on the cacheInterval
           cacheTimer += deltaTime;
           if (  cacheTimer >= cacheInterval && enableCache ){
           //Find a block to be loaded from the pending list
           i1 = pendingList.begin(   );
           i2 = pendingList.end(   );
           while (  i1 != i2 )
           {
           GeometryPage *blk = *i1;
          
           //Remove it from the pending list
           i1 = pendingList.erase(  i1 );
           blk->_pending = false;
          
           //If it's within the geometry cache radius,   load it and break out of the loop
           Real dx = camPos.x - blk->_centerPoint.x;
           Real dz = camPos.z - blk->_centerPoint.z;
           Real distSq = dx * dx + dz * dz;
           if (  distSq <= cacheDistSq ){
           _loadPage(  blk );
           loadedList.push_back(  blk );
           blk->_iter = (  --loadedList.end(   ) );
          
           enableCache = false;
           break;
           }
          
           //Otherwise this will keep looping until an unloaded page is found
           }
          
           //Reset the cache timer
           cacheTimer = 0;
           }
          
          
           //-- Update existing geometry and impostors --
          
           //Loop through each loaded geometry block
           i1 = loadedList.begin(   );
           i2 = loadedList.end(   );
          
           //Real fadeBeginDistSq = farDistSq - Math::Sqr(  mainGeom->getPageSize(   ) * 1.4142f );
           Real halfPageSize = mainGeom->getPageSize(   ) * 0.5f;
           while (  i1 != i2 )
           {
           GeometryPage *blk = *i1;
          
           //If the geometry has expired...
           if (  blk->_inactiveTime >= inactivePageLife ){
           //Unload it
           _unloadPage(  blk );
           i1 = loadedList.erase(  i1 );
           } else {
           //Update it's visibility/fade status based on it's distance from the camera
           bool visible = false;
           Real dx = camPos.x - blk->_centerPoint.x;
           Real dz = camPos.z - blk->_centerPoint.z;
           Real distSq = dx * dx + dz * dz;
          
           Real overlap = 0,   tmp;
          
           tmp = blk->_trueBounds.getMaximum(   ).x - halfPageSize;
           if (  tmp > overlap ) overlap = tmp;
           tmp = blk->_trueBounds.getMaximum(   ).z - halfPageSize;
           if (  tmp > overlap ) overlap = tmp;
           tmp = blk->_trueBounds.getMinimum(   ).x + halfPageSize;
           if (  tmp > overlap ) overlap = tmp;
           tmp = blk->_trueBounds.getMinimum(   ).z + halfPageSize;
           if (  tmp > overlap ) overlap = tmp;
          
           Real pageLengthSq = Math::Sqr(  (  mainGeom->getPageSize(   ) + overlap ) * 1.41421356f );
          
           if (  distSq + pageLengthSq >= nearDistSq && distSq - pageLengthSq < farTransDistSq ){
           //Fade the page when transitioning
           bool enable = false;
           Real fadeNear = 0;
           Real fadeFar = 0;
          
           if (  fadeEnabled && distSq + pageLengthSq >= farDistSq ){
           //Fade in
           visible = true;
           enable = true;
           fadeNear = farDist;
           fadeFar = farTransDist;
           }
           else if (  prevManager && prevManager->fadeEnabled && (  distSq - pageLengthSq < prevManager->farTransDistSq ) ){
           //Fade out
           visible = true;
           enable = true;
           fadeNear = prevManager->farDist + (  prevManager->farTransDist - prevManager->farDist ) * 0.5f; //This causes geometry to fade out faster than it fades in,   avoiding a state where a transition appears semitransparent
           fadeFar = prevManager->farDist;
           }
          
           //Apply fade settings
           if (  enable != blk->_fadeEnable ){
           blk->setFade(  enable,   fadeNear,   fadeFar );
           blk->_fadeEnable = enable;
           }
           }
           //Non-fade visibility
           if (  distSq >= nearDistSq && distSq < farDistSq )
           visible = true;
          
           //Update visibility
           if (  visible ){
           //Show the page if it isn't visible
           if (  blk->_visible != true ){
           blk->setVisible(  true );
           blk->_visible = true;
           }
           } else {
           //Hide the page if it's not already
           if (  blk->_visible != false ){
           blk->setVisible(  false );
           blk->_visible = false;
           }
           }
          
           //And update it
           blk->update(   );
          
           i1++;
           }
          
           //Increment the inactivity timer for the geometry
           blk->_inactiveTime += deltaTime;
           }
          }
          
          //Clears all GeometryPage's
     551  void GeometryPageManager::reloadGeometry(   )
          {
           TPGeometryPages::iterator it;
           for (  it = loadedList.begin(   ); it != loadedList.end(   ); ++it )
           {
           GeometryPage *page = *it;
           _unloadPage(  page );
           }
           loadedList.clear(   );
          }
          
          //Clears a single page (  which contains the given point )
     563  void GeometryPageManager::reloadGeometryPage(  const Vector3 &point )
          {
           //Determine which grid block contains the given points
           const int x = Math::Floor(  geomGridX * (  point.x - gridBounds.left ) / gridBounds.width(   ) );
           const int z = Math::Floor(  geomGridZ * (  point.z - gridBounds.top ) / gridBounds.height(   ) );
          
           //Unload the grid block if it's in the grid area,   and is loaded
           if (  x >= 0 && z >= 0 && x < geomGridX && z < geomGridZ ){
           GeometryPage *page = _getGridPage(  x,   z );
           if (  page->_loaded ){
           _unloadPage(  page );
           loadedList.erase(  page->_iter );
           }
           }
          }
          
          //Loads the given page of geometry immediately
          //Note: _loadPage(   ) does add the page to loadedList,   so that will have to be done manually
     581  void GeometryPageManager::_loadPage(  GeometryPage *page )
          {
           //Calculate page info
           PageInfo info;
           Real halfPageSize = mainGeom->getPageSize(   ) * 0.5f;
          
           info.bounds.left = page->_centerPoint.x - halfPageSize;
           info.bounds.right = page->_centerPoint.x + halfPageSize;
           info.bounds.top = page->_centerPoint.z - halfPageSize;
           info.bounds.bottom = page->_centerPoint.z + halfPageSize;
           info.centerPoint = page->_centerPoint;
           info.xIndex = page->_xIndex;
           info.zIndex = page->_zIndex;
           info.userData = page->_userData;
          
           //Check if page needs unloading (  if a delayed unload has been issued )
           if (  page->_needsUnload ){
           page->removeEntities(   );
           mainGeom->getPageLoader(   )->unloadPage(  info );
           page->_userData = 0;
          
           page->clearBoundingBox(   );
           }
          
           //Load the page
           page->setRegion(  info.bounds.left,   info.bounds.top,   info.bounds.right,   info.bounds.bottom );
          
           mainGeom->getPageLoader(   )->geomPage = page;
           mainGeom->getPageLoader(   )->loadPage(  info );
          
           page->_userData = info.userData;
          
           page->build(   );
           page->setVisible(  page->_visible );
          
           page->_inactiveTime = 0;
           page->_loaded = true;
           page->_fadeEnable = false;
          }
          
          //Unloads the given page of geometry immediately
          //Note: _unloadPage(   ) does not remove the page from loadedList,   so that will have to be done manually
     623  void GeometryPageManager::_unloadPage(  GeometryPage *page )
          {
           //Calculate boundaries to unload
           PageInfo info;
           Real halfPageSize = mainGeom->getPageSize(   ) * 0.5f;
          
           info.bounds.left = page->_centerPoint.x - halfPageSize;
           info.bounds.right = page->_centerPoint.x + halfPageSize;
           info.bounds.top = page->_centerPoint.z - halfPageSize;
           info.bounds.bottom = page->_centerPoint.z + halfPageSize;
           info.centerPoint = page->_centerPoint;
           info.xIndex = page->_xIndex;
           info.zIndex = page->_zIndex;
           info.userData = page->_userData;
          
           //Unload the page
           page->removeEntities(   );
           mainGeom->getPageLoader(   )->unloadPage(  info );
           page->_userData = 0;
          
           page->clearBoundingBox(   );
          
           page->_inactiveTime = 0;
           page->_loaded = false;
           page->_fadeEnable = false;
          }
          
          //"Virtually" unloads the given page of geometry. In reality it is unloaded during the next load.
          //Note: _unloadPageDelayed(   ) does not remove the page from loadedList,   so that will have to be done manually
     652  void GeometryPageManager::_unloadPageDelayed(  GeometryPage *page )
          {
           page->_needsUnload = true;
           page->_loaded = false;
          }
          
          
          //Scrolls pages in the grid by the given amount
     660  void GeometryPageManager::_scrollGridPages(  int shiftX,   int shiftZ )
          {
           //Check if the camera moved completely out of the grid
           if (  shiftX > geomGridX || shiftX < -geomGridX || shiftZ > geomGridZ || shiftZ < -geomGridZ ){
           //If so,   just reload all the tiles (  reloading is accomplished by unloading - loading is automatic )
           for (  int x = 0; x < geomGridX; ++x ){
           for (  int z = 0; z < geomGridZ; ++z ){
           GeometryPage *page = _getGridPage(  x,   z );
           if (  page->_loaded ){
           _unloadPage(  page );
           loadedList.erase(  page->_iter );
           }
           page->_centerPoint.x += shiftX * mainGeom->getPageSize(   );
           page->_centerPoint.z += shiftZ * mainGeom->getPageSize(   );
           page->_xIndex += shiftX;
           page->_zIndex += shiftZ;
           }
           }
           } else { //If not,   scroll the grid by the X and Y values
           //Scroll horizontally (  X )
           if (  shiftX > 0 ){
           for (  int z = 0; z < geomGridZ; ++z ){
           //Temporarily store off-shifted pages first
           for (  int x = 0; x < shiftX; ++x ){
           GeometryPage *page = _getGridPage(  x,   z );
           if (  page->_loaded ){
           _unloadPageDelayed(  page );
           loadedList.erase(  page->_iter );
           }
           scrollBuffer[x] = page;
           }
           //Shift left
           int shiftedMidpoint = geomGridX - shiftX;
           for (  int x = 0; x < shiftedMidpoint; ++x )
           _setGridPage(  x,   z,   _getGridPage(  x + shiftX,   z ) );
           //Rotate temporary pages around to other side of grid
           for (  int x = 0; x < shiftX; ++x ){
           scrollBuffer[x]->_centerPoint.x += geomGridX * mainGeom->getPageSize(   );
           scrollBuffer[x]->_xIndex += geomGridX;
           _setGridPage(  x + shiftedMidpoint,   z,   scrollBuffer[x] );
           }
           }
           }
           else if (  shiftX < 0 ) {
           for (  int z = 0; z < geomGridZ; ++z ){
           //Temporarily store off-shifted pages first
           int initialMidpoint = geomGridX + shiftX;
           for (  int x = initialMidpoint; x < geomGridX; ++x ){
           GeometryPage *page = _getGridPage(  x,   z );
           if (  page->_loaded ){
           _unloadPageDelayed(  page );
           loadedList.erase(  page->_iter );
           }
           scrollBuffer[x - initialMidpoint] = page;
           }
           //Shift right
           for (  int x = geomGridX-1; x >= -shiftX; x-- )
           _setGridPage(  x,   z,   _getGridPage(  x + shiftX,   z ) );
           //Rotate temporary pages around to other side of grid
           for (  int x = 0; x < -shiftX; ++x ){
           scrollBuffer[x]->_centerPoint.x -= geomGridX * mainGeom->getPageSize(   );
           scrollBuffer[x]->_xIndex -= geomGridX;
           _setGridPage(  x,   z,   scrollBuffer[x] );
           }
           }
           }
           //Scroll vertically (  Z )
           if (  shiftZ > 0 ){
           for (  int x = 0; x < geomGridX; ++x ){
           //Temporarily store off-shifted pages first
           for (  int z = 0; z < shiftZ; ++z ){
           GeometryPage *page = _getGridPage(  x,   z );
           if (  page->_loaded ){
           _unloadPageDelayed(  page );
           loadedList.erase(  page->_iter );
           }
           scrollBuffer[z] = page;
           }
           //Shift left
           int shiftedMidpoint = geomGridZ - shiftZ;
           for (  int z = 0; z < shiftedMidpoint; ++z )
           _setGridPage(  x,   z,   _getGridPage(  x,   z + shiftZ ) );
           //Rotate temporary pages around to other side of grid
           for (  int z = 0; z < shiftZ; ++z ){
           scrollBuffer[z]->_centerPoint.z += geomGridZ * mainGeom->getPageSize(   );
           scrollBuffer[z]->_zIndex += geomGridZ;
           _setGridPage(  x,   z + shiftedMidpoint,   scrollBuffer[z] );
           }
           }
           }
           else if (  shiftZ < 0 ) {
           for (  int x = 0; x < geomGridX; ++x ){
           //Temporarily store off-shifted pages first
           int initialMidpoint = geomGridZ + shiftZ;
           for (  int z = initialMidpoint; z < geomGridZ; ++z ){
           GeometryPage *page = _getGridPage(  x,   z );
           if (  page->_loaded ){
           _unloadPageDelayed(  page );
           loadedList.erase(  page->_iter );
           }
           scrollBuffer[z - initialMidpoint] = page;
           }
           //Shift right
           for (  int z = geomGridZ-1; z >= -shiftZ; z-- )
           _setGridPage(  x,   z,   _getGridPage(  x,   z + shiftZ ) );
           //Rotate temporary pages around to other side of grid
           for (  int z = 0; z < -shiftZ; ++z ){
           scrollBuffer[z]->_centerPoint.z -= geomGridZ * mainGeom->getPageSize(   );
           scrollBuffer[z]->_zIndex -= geomGridZ;
           _setGridPage(  x,   z,   scrollBuffer[z] );
           }
           }
           }
           }
          }
          
          
          
     778  void GeometryPage::addEntityToBoundingBox(  Ogre::Entity *ent,   const Ogre::Vector3 &position,   const Ogre::Quaternion &rotation,   const Ogre::Vector3 &scale )
          {
           //Update bounding box
           Ogre::Matrix4 mat(  rotation );
           mat.setScale(  scale );
           Ogre::AxisAlignedBox entBounds = ent->getBoundingBox(   );
           entBounds.transform(  mat );
          
           Ogre::Vector3 relPosition = position - _centerPoint;
           if (  _trueBoundsUndefined ){
           _trueBounds.setMinimum(  entBounds.getMinimum(   ) + relPosition );
           _trueBounds.setMaximum(  entBounds.getMaximum(   ) + relPosition );
           _trueBoundsUndefined = false;
           } else {
           Ogre::Vector3 min = _trueBounds.getMinimum(   );
           Ogre::Vector3 max = _trueBounds.getMaximum(   );
           min.makeFloor(  entBounds.getMinimum(   ) + relPosition );
           max.makeCeil(  entBounds.getMaximum(   ) + relPosition );
           _trueBounds.setMinimum(  min );
           _trueBounds.setMaximum(  max );
           }
          }
          
     801  const AxisAlignedBox &GeometryPage::getBoundingBox(   )
          {
           return _trueBounds;
          }
          
     806  void GeometryPage::clearBoundingBox(   )
          {
           _trueBounds = AxisAlignedBox(  0,   0,   0,   0,   0,   0 );
           _trueBoundsUndefined = true;
          }
          }

./components/ogre/environment/pagedgeometry/source/PropertyMaps.cpp

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
          1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
          2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
          3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          #include "PropertyMaps.h"
          
          #include "OgreRoot.h"
          #include "OgrePrerequisites.h"
          #include "OgrePixelFormat.h"
          #include "OgreTexture.h"
          #include "OgreTextureManager.h"
          #include "OgreHardwarePixelBuffer.h"
          #include "OgreRenderSystem.h"
          #include "OgreString.h"
          #include "OgreStringConverter.h"
          using namespace Ogre;
          
          namespace PagedGeometry {
          
          std::map<Ogre::String,   DensityMap*> DensityMap::selfList;
          
      28  DensityMap *DensityMap::load(  const Ogre::String &fileName,   MapChannel channel )
          {
           //Load image
           TexturePtr map = TextureManager::getSingleton(   ).load(  fileName,   ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
          
           //Copy image to pixelbox
           return load(  map.getPointer(   ),   channel );
          }
          
      37  DensityMap *DensityMap::load(  Ogre::Texture *texture,   MapChannel channel )
          {
           const String key = texture->getName(   ) + StringConverter::toString(  (  int )channel );
          
           std::map<Ogre::String,   DensityMap*>::iterator i;
           i = selfList.find(  key );
          
           DensityMap *m;
           if (  i != selfList.end(   ) )
           m = i->second;
           else
           m = new DensityMap(  texture,   channel );
          
           ++(  m->refCount );
           return m;
          }
          
      54  void DensityMap::unload(   )
          {
           --refCount;
           if (  refCount == 0 )
           delete this;
          }
          
      61  DensityMap::~DensityMap(   )
          {
           assert(  pixels );
           delete[] pixels->data;
           delete pixels;
          
           //Remove self from selfList
           selfList.erase(  selfKey );
          }
          
      71  DensityMap::DensityMap(  Texture *map,   MapChannel channel )
          {
           assert(  map );
           filter = MAPFILTER_BILINEAR;
          
           //Add self to selfList
           selfKey = map->getName(   ) + StringConverter::toString(  (  int )channel );
           selfList.insert(  std::pair<String,   DensityMap*>(  selfKey,   this ) );
           refCount = 0;
          
           //Get the texture buffer
           HardwarePixelBufferSharedPtr buff = map->getBuffer(   );
          
           //Prepare a PixelBox (  8-bit greyscale ) to receive the density values
           pixels = new PixelBox(  Box(  0,   0,   buff->getWidth(   ),   buff->getHeight(   ) ),   PF_BYTE_L );
           pixels->data = new uint8[pixels->getConsecutiveSize(   )];
          
           if (  channel == CHANNEL_COLOR ){
           //Copy to the greyscale density map directly if no channel extraction is necessary
           buff->blitToMemory(  *pixels );
           } else {
           //If channel extraction is necessary,   first convert to a PF_R8G8B8A8 format PixelBox
           //This is necessary for the code below to properly extract the desired channel
           PixelBox tmpPixels(  Box(  0,   0,   buff->getWidth(   ),   buff->getHeight(   ) ),   PF_R8G8B8A8 );
           tmpPixels.data = new uint8[tmpPixels.getConsecutiveSize(   )];
           buff->blitToMemory(  tmpPixels );
          
           //Pick out a channel from the pixel buffer
           size_t channelOffset;
           switch (  channel ){
           case CHANNEL_RED: channelOffset = 3; break;
           case CHANNEL_GREEN: channelOffset = 2; break;
           case CHANNEL_BLUE: channelOffset = 1; break;
           case CHANNEL_ALPHA: channelOffset = 0; break;
           default: OGRE_EXCEPT(  0,   "Invalid channel",   "GrassLayer::setDensityMap(   )" ); break;
           }
          
           //And copy that channel into the density map
           uint8 *inputPtr = (  uint8* )tmpPixels.data + channelOffset;
           uint8 *outputPtr = (  uint8* )pixels->data;
           uint8 *outputEndPtr = outputPtr + pixels->getConsecutiveSize(   );
           while (  outputPtr != outputEndPtr ){
           *outputPtr++ = *inputPtr;
           inputPtr += 4;
           }
          
           //Finally,   delete the temporary PF_R8G8B8A8 pixel buffer
           delete[] tmpPixels.data;
           }
          }
          
          
          //Returns the density map value at the given location
          //Make sure a density map exists before calling this.
     125  float DensityMap::_getDensityAt_Unfiltered(  float x,   float z )
          {
           assert(  pixels );
          
           unsigned int mapWidth = (  unsigned int )pixels->getWidth(   );
           unsigned int mapHeight = (  unsigned int )pixels->getHeight(   );
           float boundsWidth = mapBounds.width(   );
           float boundsHeight = mapBounds.height(   );
          
           unsigned int xindex = mapWidth * (  x - mapBounds.left ) / boundsWidth;
           unsigned int zindex = mapHeight * (  z - mapBounds.top ) / boundsHeight;
           if (  xindex < 0 || zindex < 0 || xindex >= mapWidth || zindex >= mapHeight )
           return 0.0f;
          
           uint8 *data = (  uint8* )pixels->data;
           float val = data[mapWidth * zindex + xindex] / 255.0f;
          
           return val;
          }
          
          //Returns the density map value at the given location with bilinear filtering
          //Make sure a density map exists before calling this.
     147  float DensityMap::_getDensityAt_Bilinear(  float x,   float z )
          {
           assert(  pixels );
          
           unsigned int mapWidth = (  unsigned int )pixels->getWidth(   );
           unsigned int mapHeight = (  unsigned int )pixels->getHeight(   );
           float boundsWidth = mapBounds.width(   );
           float boundsHeight = mapBounds.height(   );
          
           float xIndexFloat = (  mapWidth * (  x - mapBounds.left ) / boundsWidth ) - 0.5f;
           float zIndexFloat = (  mapHeight * (  z - mapBounds.top ) / boundsHeight ) - 0.5f;
          
           unsigned int xIndex = xIndexFloat;
           unsigned int zIndex = zIndexFloat;
           if (  xIndex < 0 || zIndex < 0 || xIndex >= mapWidth-1 || zIndex >= mapHeight-1 )
           return 0.0f;
          
           float xRatio = xIndexFloat - xIndex;
           float xRatioInv = 1 - xRatio;
           float zRatio = zIndexFloat - zIndex;
           float zRatioInv = 1 - zRatio;
          
           uint8 *data = (  uint8* )pixels->data;
          
           float val11 = data[mapWidth * zIndex + xIndex] / 255.0f;
           float val21 = data[mapWidth * zIndex + xIndex + 1] / 255.0f;
           float val12 = data[mapWidth * ++zIndex + xIndex] / 255.0f;
           float val22 = data[mapWidth * zIndex + xIndex + 1] / 255.0f;
          
           float val1 = xRatioInv * val11 + xRatio * val21;
           float val2 = xRatioInv * val12 + xRatio * val22;
          
           float val = zRatioInv * val1 + zRatio * val2;
          
           return val;
          }
          
          
          
          //----------------------------------------------------------------------------------------------
          
          std::map<Ogre::String,   ColorMap*> ColorMap::selfList;
          
     190  ColorMap *ColorMap::load(  const Ogre::String &fileName,   MapChannel channel )
          {
           //Load image
           TexturePtr map = TextureManager::getSingleton(   ).load(  fileName,   ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
          
           //Copy image to pixelbox
           return load(  map.getPointer(   ),   channel );
          }
          
     199  ColorMap *ColorMap::load(  Ogre::Texture *texture,   MapChannel channel )
          {
           const String key = texture->getName(   ) + StringConverter::toString(  (  int )channel );
          
           std::map<Ogre::String,   ColorMap*>::iterator i;
           i = selfList.find(  key );
          
           ColorMap *m;
           if (  i != selfList.end(   ) )
           m = i->second;
           else
           m = new ColorMap(  texture,   channel );
          
           ++(  m->refCount );
           return m;
          }
          
     216  void ColorMap::unload(   )
          {
           --refCount;
           if (  refCount == 0 )
           delete this;
          }
          
     223  ColorMap::~ColorMap(   )
          {
           assert(  pixels );
           delete[] pixels->data;
           delete pixels;
          
           //Remove self from selfList
           selfList.erase(  selfKey );
          }
          
     233  ColorMap::ColorMap(  Texture *map,   MapChannel channel )
          {
           assert(  map );
           filter = MAPFILTER_BILINEAR;
          
           //Add self to selfList
           selfKey = map->getName(   ) + StringConverter::toString(  (  int )channel );
           selfList.insert(  std::pair<String,   ColorMap*>(  selfKey,   this ) );
           refCount = 0;
          
           //Get the texture buffer
           HardwarePixelBufferSharedPtr buff = map->getBuffer(   );
          
           //Prepare a PixelBox (  24-bit RGB ) to receive the color values
           VertexElementType format = Root::getSingleton(   ).getRenderSystem(   )->getColourVertexElementType(   );
           switch (  format ){
           case VET_COLOUR_ARGB:
           //DirectX9
           pixels = new PixelBox(  Box(  0,   0,   buff->getWidth(   ),   buff->getHeight(   ) ),   PF_A8R8G8B8 );
           break;
           case VET_COLOUR_ABGR:
           //OpenGL
           pixels = new PixelBox(  Box(  0,   0,   buff->getWidth(   ),   buff->getHeight(   ) ),   PF_A8B8G8R8 );
           //Patch for Ogre's incorrect blitToMemory(   ) when copying from PF_L8 in OpenGL
           if (  buff->getFormat(   ) == PF_L8 )
           channel = CHANNEL_RED;
           break;
           default:
           OGRE_EXCEPT(  0,   "Unknown RenderSystem color format",   "GrassLayer::setColorMap(   )" );
           break;
           }
          
           pixels->data = new uint8[pixels->getConsecutiveSize(   )];
          
           if (  channel == CHANNEL_COLOR ){
           //Copy to the color map directly if no channel extraction is necessary
           buff->blitToMemory(  *pixels );
           } else {
           //If channel extraction is necessary,   first convert to a PF_R8G8B8A8 format PixelBox
           //This is necessary for the code below to properly extract the desired channel
           PixelBox tmpPixels(  Box(  0,   0,   buff->getWidth(   ),   buff->getHeight(   ) ),   PF_R8G8B8A8 );
           tmpPixels.data = new uint8[tmpPixels.getConsecutiveSize(   )];
           buff->blitToMemory(  tmpPixels );
          
           //Pick out a channel from the pixel buffer
           size_t channelOffset;
           switch (  channel ){
           case CHANNEL_RED: channelOffset = 3; break;
           case CHANNEL_GREEN: channelOffset = 2; break;
           case CHANNEL_BLUE: channelOffset = 1; break;
           case CHANNEL_ALPHA: channelOffset = 0; break;
           default: OGRE_EXCEPT(  0,   "Invalid channel",   "ColorMap::ColorMap(   )" ); break;
           }
          
           //And copy that channel into the density map
           uint8 *inputPtr = (  uint8* )tmpPixels.data + channelOffset;
           uint8 *outputPtr = (  uint8* )pixels->data;
           uint8 *outputEndPtr = outputPtr + pixels->getConsecutiveSize(   );
           while (  outputPtr != outputEndPtr ){
           *outputPtr++ = *inputPtr;
           *outputPtr++ = *inputPtr;
           *outputPtr++ = *inputPtr;
           *outputPtr++ = 0xFF; //Full alpha
           inputPtr += 4;
           }
          
           //Finally,   delete the temporary PF_R8G8B8A8 pixel buffer
           delete[] tmpPixels.data;
           }
          }
          
          //Returns the color map value at the given location
     305  uint32 ColorMap::_getColorAt(  float x,   float z )
          {
           assert(  pixels );
          
           unsigned int mapWidth = (  unsigned int )pixels->getWidth(   );
           unsigned int mapHeight = (  unsigned int )pixels->getHeight(   );
           float boundsWidth = mapBounds.width(   );
           float boundsHeight = mapBounds.height(   );
          
           unsigned int xindex = mapWidth * (  x - mapBounds.left ) / boundsWidth;
           unsigned int zindex = mapHeight * (  z - mapBounds.top ) / boundsHeight;
           if (  xindex < 0 || zindex < 0 || xindex >= mapWidth || zindex >= mapHeight )
           return 0xFFFFFFFF;
          
           uint32 *data = (  uint32* )pixels->data;
           return data[mapWidth * zindex + xindex];
          }
          
     323  uint32 ColorMap::_interpolateColor(  uint32 color1,   uint32 color2,   float ratio,   float ratioInv )
          {
           uint8 a1,   b1,   c1,   d1;
           a1 = (  color1 & 0xFF );
           b1 = (  color1 >> 8 & 0xFF );
           c1 = (  color1 >> 16 & 0xFF );
           d1 = (  color1 >> 24 & 0xFF );
          
           uint8 a2,   b2,   c2,   d2;
           a2 = (  color2 & 0xFF );
           b2 = (  color2 >> 8 & 0xFF );
           c2 = (  color2 >> 16 & 0xFF );
           d2 = (  color2 >> 24 & 0xFF );
          
           uint8 a,   b,   c,   d;
           a = ratioInv * a1 + ratio * a2;
           b = ratioInv * b1 + ratio * b2;
           c = ratioInv * c1 + ratio * c2;
           d = ratioInv * d1 + ratio * d2;
          
           uint32 clr = a | (  b << 8 ) | (  c << 16 ) | (  d << 24 );
           return clr;
          }
          
     347  uint32 ColorMap::_getColorAt_Bilinear(  float x,   float z )
          {
           assert(  pixels );
          
           unsigned int mapWidth = (  unsigned int )pixels->getWidth(   );
           unsigned int mapHeight = (  unsigned int )pixels->getHeight(   );
           float boundsWidth = mapBounds.width(   );
           float boundsHeight = mapBounds.height(   );
          
           float xIndexFloat = (  mapWidth * (  x - mapBounds.left ) / boundsWidth ) - 0.5f;
           float zIndexFloat = (  mapHeight * (  z - mapBounds.top ) / boundsHeight ) - 0.5f;
          
           unsigned int xIndex = xIndexFloat;
           unsigned int zIndex = zIndexFloat;
           if (  xIndex < 0 || zIndex < 0 || xIndex >= mapWidth-1 || zIndex >= mapHeight-1 )
           return 0.0f;
          
           float xRatio = xIndexFloat - xIndex;
           float xRatioInv = 1 - xRatio;
           float zRatio = zIndexFloat - zIndex;
           float zRatioInv = 1 - zRatio;
          
           uint32 *data = (  uint32* )pixels->data;
          
           uint32 val11 = data[mapWidth * zIndex + xIndex];
           uint32 val21 = data[mapWidth * zIndex + xIndex + 1];
           uint32 val12 = data[mapWidth * ++zIndex + xIndex];
           uint32 val22 = data[mapWidth * zIndex + xIndex + 1];
          
           uint32 val1 = _interpolateColor(  val11,   val21,   xRatio,   xRatioInv );
           uint32 val2 = _interpolateColor(  val12,   val22,   xRatio,   xRatioInv );
          
           uint32 val = _interpolateColor(  val1,   val2,   zRatio,   zRatioInv );
          
           return val;
          }
          }

./components/ogre/environment/pagedgeometry/source/StaticBillboardSet.cpp

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          //StaticBillboardSet.h
          //Provides a method of displaying billboards faster than Ogre's built-in BillboardSet
          //functions by taking advantage of the static nature of billboards (  note: StaticBillboardSet
          //does not allow billboards to be moved or deleted individually in real-time )
          //-------------------------------------------------------------------------------------
          
          #include "StaticBillboardSet.h"
          
          #include "OgreRoot.h"
          #include "OgreCamera.h"
          #include "OgreVector3.h"
          #include "OgreMeshManager.h"
          #include "OgreMesh.h"
          #include "OgreSubMesh.h"
          #include "OgreMaterialManager.h"
          #include "OgreMaterial.h"
          #include "OgreBillboardSet.h"
          #include "OgreBillboard.h"
          #include "OgreSceneNode.h"
          #include "OgreString.h"
          #include "OgreStringConverter.h"
          #include "OgreRenderSystem.h"
          #include "OgreRenderSystemCapabilities.h"
          #include "OgreHighLevelGpuProgramManager.h"
          #include "OgreHighLevelGpuProgram.h"
          #include "OgreHardwareBufferManager.h"
          #include "OgreHardwareBuffer.h"
          #include "OgreLogManager.h"
          #include "OgreEntity.h"
          using namespace Ogre;
          
          namespace PagedGeometry {
          
          //-------------------------------------------------------------------------------------
          
          unsigned long StaticBillboardSet::GUID = 0;
          unsigned int StaticBillboardSet::selfInstances = 0;
          StaticBillboardSet::FadedMaterialMap StaticBillboardSet::fadedMaterialMap;
          
      50  StaticBillboardSet::StaticBillboardSet(  SceneManager *mgr,   SceneNode *rootSceneNode,   BillboardMethod method )
          {
           sceneMgr = mgr;
           renderMethod = method;
           visible = true;
           fadeEnabled = false;
           bbOrigin = BBO_CENTER;
          
           //Fall back to BB_METHOD_COMPATIBLE if vertex shaders are not available
           if (  renderMethod == BB_METHOD_ACCELERATED ){
           const RenderSystemCapabilities *caps = Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   );
           if (  !caps->hasCapability(  RSC_VERTEX_PROGRAM ) )
           renderMethod = BB_METHOD_COMPATIBLE;
           }
          
           node = rootSceneNode->createChildSceneNode(   );
           entityName = getUniqueID(  "SBSentity" );
          
           if (  renderMethod == BB_METHOD_ACCELERATED ){
           //Accelerated billboard method
           entity = 0;
          
           uFactor = 1.0f;
           vFactor = 1.0f;
          
           //Load vertex shader to align billboards to face the camera (  if not loaded already )
           if (  ++selfInstances == 1 ){
           //First shader,   simple camera-alignment
           HighLevelGpuProgramPtr vertexShader;
           vertexShader = HighLevelGpuProgramManager::getSingleton(   ).getByName(  "Sprite_vp" );
           if (  vertexShader.isNull(   ) ){
           String vertexProg =
           "void Sprite_vp(   \n"
           " float4 position : POSITION,   \n"
           " float3 normal : NORMAL,   \n"
           " float4 color : COLOR,   \n"
           " float2 uv : TEXCOORD0,   \n"
           " out float4 oPosition : POSITION,   \n"
           " out float2 oUv : TEXCOORD0,   \n"
           " out float4 oColor : COLOR,   \n"
           " out float4 oFog : FOG,   \n"
           " uniform float4x4 worldViewProj,   \n"
           " uniform float uScroll,   \n"
           " uniform float vScroll,   \n"
           " uniform float4 preRotatedQuad[4]  ) \n"
           "{ \n"
           //Face the camera
           " float4 vCenter = float4(   position.x,   position.y,   position.z,   1.0f  ); \n"
           " float4 vScale = float4(   normal.x,   normal.y,   normal.x,   1.0f  ); \n"
           " oPosition = mul(   worldViewProj,   vCenter + (  preRotatedQuad[normal.z] * vScale )  ); \n"
          
           //Color
           " oColor = color; \n"
          
           //UV Scroll
           " oUv = uv; \n"
           " oUv.x += uScroll; \n"
           " oUv.y += vScroll; \n"
          
           //Fog
           " oFog.x = oPosition.z; \n"
           "}";
          
           vertexShader = HighLevelGpuProgramManager::getSingleton(   )
           .createProgram(  "Sprite_vp",  
           ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,  
           "cg",   GPT_VERTEX_PROGRAM );
           vertexShader->setSource(  vertexProg );
           vertexShader->setParameter(  "profiles",   "vs_1_1 arbvp1" );
           vertexShader->setParameter(  "entry_point",   "Sprite_vp" );
           vertexShader->load(   );
           }
          
           //Second shader,   camera alignment and distance based fading
           HighLevelGpuProgramPtr vertexShader2;
           vertexShader2 = HighLevelGpuProgramManager::getSingleton(   ).getByName(  "SpriteFade_vp" );
           if (  vertexShader2.isNull(   ) ){
           String vertexProg2 =
           "void SpriteFade_vp(   \n"
           " float4 position : POSITION,   \n"
           " float3 normal : NORMAL,   \n"
           " float4 color : COLOR,   \n"
           " float2 uv : TEXCOORD0,   \n"
           " out float4 oPosition : POSITION,   \n"
           " out float2 oUv : TEXCOORD0,   \n"
           " out float4 oColor : COLOR,   \n"
           " out float4 oFog : FOG,   \n"
           " uniform float4x4 worldViewProj,   \n"
          
           " uniform float3 camPos,   \n"
           " uniform float fadeGap,   \n"
           " uniform float invisibleDist,   \n"
          
           " uniform float uScroll,   \n"
           " uniform float vScroll,   \n"
           " uniform float4 preRotatedQuad[4]  ) \n"
           "{ \n"
           //Face the camera
           " float4 vCenter = float4(   position.x,   position.y,   position.z,   1.0f  ); \n"
           " float4 vScale = float4(   normal.x,   normal.y,   normal.x,   1.0f  ); \n"
           " oPosition = mul(   worldViewProj,   vCenter + (  preRotatedQuad[normal.z] * vScale )  ); \n"
          
           " oColor.rgb = color.rgb; \n"
          
           //Fade out in the distance
           " float dist = distance(  camPos.xz,   position.xz ); \n"
           " oColor.a = (  invisibleDist - dist ) / fadeGap; \n"
          
           //UV scroll
           " oUv = uv; \n"
           " oUv.x += uScroll; \n"
           " oUv.y += vScroll; \n"
          
           //Fog
           " oFog.x = oPosition.z; \n"
           "}";
          
           vertexShader2 = HighLevelGpuProgramManager::getSingleton(   )
           .createProgram(  "SpriteFade_vp",  
           ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,  
           "cg",   GPT_VERTEX_PROGRAM );
           vertexShader2->setSource(  vertexProg2 );
           vertexShader2->setParameter(  "profiles",   "vs_1_1 arbvp1" );
           vertexShader2->setParameter(  "entry_point",   "SpriteFade_vp" );
           vertexShader2->load(   );
           }
          
           }
           } else {
           //Compatible billboard method
           fallbackSet = sceneMgr->createBillboardSet(  getUniqueID(  "SBS" ),   100 );
           node->attachObject(  fallbackSet );
           }
          }
          
     185  StaticBillboardSet::~StaticBillboardSet(   )
          {
           if (  renderMethod == BB_METHOD_ACCELERATED ){
           //Delete mesh data
           clear(   );
          
           //Delete scene node
           sceneMgr->destroySceneNode(  node->getName(   ) );
          
           //Update material reference list
           if (  !materialPtr.isNull(   ) ) SBMaterialRef::removeMaterialRef(  materialPtr );
           if (  !fadeMaterialPtr.isNull(   ) ) SBMaterialRef::removeMaterialRef(  fadeMaterialPtr );
          
           //Delete vertex shaders and materials if no longer in use
           if (  --selfInstances == 0 ){
           //Delete fade materials
           fadedMaterialMap.clear(   );
           }
           } else {
           //Delete scene node
           sceneMgr->destroySceneNode(  node->getName(   ) );
          
           //Remove billboard set
           sceneMgr->destroyBillboardSet(  fallbackSet );
           }
          }
          
     212  void StaticBillboardSet::clear(   )
          {
           if (  renderMethod == BB_METHOD_ACCELERATED ){
           //Delete the entity and mesh data
           if (  entity ){
           //Delete entity
           node->detachAllObjects(   );
           sceneMgr->destroyEntity(  entity );
           entity = 0;
          
           //Delete mesh
           assert(  !mesh.isNull(   ) );
           String meshName(  mesh->getName(   ) );
           mesh.setNull(   );
           if (  MeshManager::getSingletonPtr(   ) )
           MeshManager::getSingleton(   ).remove(  meshName );
           }
          
           //Remove any billboard data which might be left over if the user forgot to call build(   )
           std::vector<StaticBillboard*>::iterator i1,   i2;
           i1 = billboardBuffer.begin(   );
           i2 = billboardBuffer.end(   );
           while (  i1 != i2 )
           {
           delete (  *i1 );
           ++i1;
           }
           billboardBuffer.clear(   );
           } else {
           fallbackSet->clear(   );
           }
          }
          
     245  void StaticBillboardSet::build(   )
          {
           if (  renderMethod == BB_METHOD_ACCELERATED ){
           //Delete old entity and mesh data
           if (  entity ){
           //Delete entity
           node->detachAllObjects(   );
           sceneMgr->destroyEntity(  entity );
           entity = 0;
          
           //Delete mesh
           assert(  !mesh.isNull(   ) );
           String meshName(  mesh->getName(   ) );
           mesh.setNull(   );
           if (  MeshManager::getSingletonPtr(   ) )
           MeshManager::getSingleton(   ).remove(  meshName );
           }
          
           //If there are no billboards to create,   exit
           if (  billboardBuffer.empty(   ) )
           return;
          
           //Create manual mesh to store billboard quads
           mesh = MeshManager::getSingleton(   ).createManual(  getUniqueID(  "SBSmesh" ),   ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
           subMesh = mesh->createSubMesh(   );
           subMesh->useSharedVertices = false;
          
           //Setup vertex format information
           subMesh->vertexData = new VertexData;
           subMesh->vertexData->vertexStart = 0;
           subMesh->vertexData->vertexCount = 4 * billboardBuffer.size(   );
          
           VertexDeclaration* dcl = subMesh->vertexData->vertexDeclaration;
           size_t offset = 0;
           dcl->addElement(  0,   offset,   VET_FLOAT3,   VES_POSITION );
           offset += VertexElement::getTypeSize(  VET_FLOAT3 );
           dcl->addElement(  0,   offset,   VET_FLOAT3,   VES_NORMAL );
           offset += VertexElement::getTypeSize(  VET_FLOAT3 );
           dcl->addElement(  0,   offset,   VET_COLOUR,   VES_DIFFUSE );
           offset += VertexElement::getTypeSize(  VET_COLOUR );
           dcl->addElement(  0,   offset,   VET_FLOAT2,   VES_TEXTURE_COORDINATES );
           offset += VertexElement::getTypeSize(  VET_FLOAT2 );
          
           //Populate a new vertex buffer
           HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton(   )
           .createVertexBuffer(  offset,   subMesh->vertexData->vertexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
           float* pReal = static_cast<float*>(  vbuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          
           float minX = Math::POS_INFINITY,   minY = Math::POS_INFINITY,   minZ = Math::POS_INFINITY;
           float maxX = Math::NEG_INFINITY,   maxY = Math::NEG_INFINITY,   maxZ = Math::NEG_INFINITY;
          
           std::vector<StaticBillboard*>::iterator i1,   i2;
           i1 = billboardBuffer.begin(   );
           i2 = billboardBuffer.end(   );
           while (  i1 != i2 )
           {
           StaticBillboard *bb = (  *i1 );
           float halfXScale = bb->xScale * 0.5f;
           float halfYScale = bb->yScale * 0.5f;
          
           // position
           *pReal++ = bb->position.x;
           *pReal++ = bb->position.y;
           *pReal++ = bb->position.z;
           // normals (  actually used as scale / translate info for vertex shader )
           *pReal++ = halfXScale;
           *pReal++ = halfYScale;
           *pReal++ = 0.0f;
           // color
           *(  (  uint32* )pReal++ ) = bb->color;
           // uv
           *pReal++ = (  bb->texcoordIndexU * uFactor );
           *pReal++ = (  bb->texcoordIndexV * vFactor );
          
           // position
           *pReal++ = bb->position.x;
           *pReal++ = bb->position.y;
           *pReal++ = bb->position.z;
           // normals (  actually used as scale / translate info for vertex shader )
           *pReal++ = halfXScale;
           *pReal++ = halfYScale;
           *pReal++ = 1.0f;
           // color
           *(  (  uint32* )pReal++ ) = bb->color;
           // uv
           *pReal++ = (  (  bb->texcoordIndexU + 1 ) * uFactor );
           *pReal++ = (  bb->texcoordIndexV * vFactor );
          
           // position
           *pReal++ = bb->position.x;
           *pReal++ = bb->position.y;
           *pReal++ = bb->position.z;
           // normals (  actually used as scale / translate info for vertex shader )
           *pReal++ = halfXScale;
           *pReal++ = halfYScale;
           *pReal++ = 2.0f;
           // color
           *(  (  uint32* )pReal++ ) = bb->color;
           // uv
           *pReal++ = (  bb->texcoordIndexU * uFactor );
           *pReal++ = (  (  bb->texcoordIndexV + 1 ) * vFactor );
          
           // position
           *pReal++ = bb->position.x;
           *pReal++ = bb->position.y;
           *pReal++ = bb->position.z;
           // normals (  actually used as scale / translate info for vertex shader )
           *pReal++ = halfXScale;
           *pReal++ = halfYScale;
           *pReal++ = 3.0f;
           // color
           *(  (  uint32* )pReal++ ) = bb->color;
           // uv
           *pReal++ = (  (  bb->texcoordIndexU + 1 ) * uFactor );
           *pReal++ = (  (  bb->texcoordIndexV + 1 ) * vFactor );
          
           //Update bounding box
           if (  bb->position.x - halfXScale < minX ) minX = bb->position.x - halfXScale;
           if (  bb->position.x + halfXScale > maxX ) maxX = bb->position.x + halfXScale;
           if (  bb->position.y - halfYScale < minY ) minY = bb->position.y - halfYScale;
           if (  bb->position.y + halfYScale > maxY ) maxY = bb->position.y + halfYScale;
           if (  bb->position.z - halfXScale < minZ ) minZ = bb->position.z - halfXScale;
           if (  bb->position.z + halfXScale > maxZ ) maxZ = bb->position.z + halfXScale;
          
           delete bb;
           ++i1;
           }
           AxisAlignedBox bounds(  minX,   minY,   minZ,   maxX,   maxY,   maxZ );
          
           vbuf->unlock(   );
           subMesh->vertexData->vertexBufferBinding->setBinding(  0,   vbuf );
          
           //Populate index buffer
           subMesh->indexData->indexStart = 0;
           subMesh->indexData->indexCount = 6 * billboardBuffer.size(   );
           subMesh->indexData->indexBuffer = HardwareBufferManager::getSingleton(   )
           .createIndexBuffer(  HardwareIndexBuffer::IT_16BIT,   subMesh->indexData->indexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY );
           Ogre::uint16* pI = static_cast<Ogre::uint16*>(  subMesh->indexData->indexBuffer->lock(  HardwareBuffer::HBL_DISCARD ) );
           for (  Ogre::uint16 i = 0; i < billboardBuffer.size(   ); ++i )
           {
           Ogre::uint16 offset = i * 4;
          
           *pI++ = 0 + offset;
           *pI++ = 2 + offset;
           *pI++ = 1 + offset;
          
           *pI++ = 1 + offset;
           *pI++ = 2 + offset;
           *pI++ = 3 + offset;
           }
          
           subMesh->indexData->indexBuffer->unlock(   );
          
           //Finish up mesh
           mesh->_setBounds(  bounds );
           Vector3 temp = bounds.getMaximum(   ) - bounds.getMinimum(   );
           mesh->_setBoundingSphereRadius(  temp.length(   ) * 0.5f );
          
           LogManager::getSingleton(   ).setLogDetail(  static_cast<LoggingLevel>(  0 ) );
           mesh->load(   );
           LogManager::getSingleton(   ).setLogDetail(  LL_NORMAL );
          
           //Empty the billboardBuffer now,   because all billboards have been built
           billboardBuffer.clear(   );
          
           //Create an entity for the mesh
           entity = sceneMgr->createEntity(  entityName,   mesh->getName(   ) );
           entity->setCastShadows(  false );
          
           //Apply texture
           if (  fadeEnabled ) {
           assert(  !fadeMaterialPtr.isNull(   ) );
           entity->setMaterialName(  fadeMaterialPtr->getName(   ) );
           } else {
           assert(  !materialPtr.isNull(   ) );
           entity->setMaterialName(  materialPtr->getName(   ) );
           }
          
           //Add to scene
           node->attachObject(  entity );
           entity->setVisible(  visible );
           }
          }
          
     429  void StaticBillboardSet::setMaterial(  const String &materialName )
          {
           if (  renderMethod == BB_METHOD_ACCELERATED ){
           if (  materialPtr.isNull(   ) || materialPtr->getName(   ) != materialName ){
           //Update material reference list
           if (  fadeEnabled ) {
           assert(  !fadeMaterialPtr.isNull(   ) );
           SBMaterialRef::removeMaterialRef(  fadeMaterialPtr );
           } else {
           if (  !materialPtr.isNull(   ) )
           SBMaterialRef::removeMaterialRef(  materialPtr );
           }
          
           materialPtr = MaterialManager::getSingleton(   ).getByName(  materialName );
           if (  fadeEnabled ) {
           fadeMaterialPtr = getFadeMaterial(  fadeVisibleDist,   fadeInvisibleDist );
           SBMaterialRef::addMaterialRef(  fadeMaterialPtr,   bbOrigin );
           } else {
           SBMaterialRef::addMaterialRef(  materialPtr,   bbOrigin );
           }
          
           //Apply material to entity
           if (  entity ){
           if (  fadeEnabled ){
           entity->setMaterialName(  fadeMaterialPtr->getName(   ) );
           } else {
           entity->setMaterialName(  materialPtr->getName(   ) );
           }
           }
           }
           } else {
           if (  materialPtr.isNull(   ) || materialPtr->getName(   ) != materialName ){
           materialPtr = MaterialManager::getSingleton(   ).getByName(  materialName );
           fallbackSet->setMaterialName(  materialPtr->getName(   ) );
           }
           }
          }
          
     467  void StaticBillboardSet::setFade(  bool enabled,   Real visibleDist,   Real invisibleDist )
          {
           if (  renderMethod == BB_METHOD_ACCELERATED ){
           if (  enabled ){
           if (  materialPtr.isNull(   ) )
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,   "Billboard fading cannot be enabled without a material applied first",   "StaticBillboardSet::setFade(   )" );
          
           //Update material reference list
           if (  fadeEnabled ) {
           assert(  !fadeMaterialPtr.isNull(   ) );
           SBMaterialRef::removeMaterialRef(  fadeMaterialPtr );
           } else {
           assert(  !materialPtr.isNull(   ) );
           SBMaterialRef::removeMaterialRef(  materialPtr );
           }
          
           fadeMaterialPtr = getFadeMaterial(  visibleDist,   invisibleDist );
           SBMaterialRef::addMaterialRef(  fadeMaterialPtr,   bbOrigin );
          
           //Apply material to entity
           if (  entity )
           entity->setMaterialName(  fadeMaterialPtr->getName(   ) );
          
           fadeEnabled = enabled;
           fadeVisibleDist = visibleDist;
           fadeInvisibleDist = invisibleDist;
           } else {
           if (  fadeEnabled ){
           //Update material reference list
           assert(  !fadeMaterialPtr.isNull(   ) );
           assert(  !materialPtr.isNull(   ) );
           SBMaterialRef::removeMaterialRef(  fadeMaterialPtr );
           SBMaterialRef::addMaterialRef(  materialPtr,   bbOrigin );
          
           //Apply material to entity
           if (  entity )
           entity->setMaterialName(  materialPtr->getName(   ) );
          
           fadeEnabled = enabled;
           fadeVisibleDist = visibleDist;
           fadeInvisibleDist = invisibleDist;
           }
           }
           }
          }
          
     513  void StaticBillboardSet::setTextureStacksAndSlices(  Ogre::uint16 stacks,   Ogre::uint16 slices )
          {
           uFactor = 1.0f / slices;
           vFactor = 1.0f / stacks;
          }
          
     519  MaterialPtr StaticBillboardSet::getFadeMaterial(  Real visibleDist,   Real invisibleDist )
          {
           StringUtil::StrStreamType materialSignature;
           materialSignature << entityName << "|";
           materialSignature << visibleDist << "|";
           materialSignature << invisibleDist << "|";
           materialSignature << materialPtr->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  0 )->getTextureUScroll(   ) << "|";
           materialSignature << materialPtr->getTechnique(  0 )->getPass(  0 )->getTextureUnitState(  0 )->getTextureVScroll(   ) << "|";
          
           FadedMaterialMap::iterator it = fadedMaterialMap.find(  materialSignature.str(   ) );
           MaterialPtr fadeMaterial;
          
           //If a correctly faded version of the material exists...
           if (  it != fadedMaterialMap.end(   ) ){
           //Use the existing fade material
           fadeMaterial = it->second;
           } else {
           //Otherwise clone the material
           fadeMaterial = materialPtr->clone(  getUniqueID(  "ImpostorFade" ) );
          
           //And apply the fade shader
           for (  unsigned short t = 0; t < fadeMaterial->getNumTechniques(   ); ++t ){
           Technique *tech = fadeMaterial->getTechnique(  t );
           for (  unsigned short p = 0; p < tech->getNumPasses(   ); ++p ){
           Pass *pass = tech->getPass(  p );
          
           //Setup vertex program
           pass->setVertexProgram(  "SpriteFade_vp" );
           GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters(   );
           params->setNamedAutoConstant(  "worldViewProj",   GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX );
           params->setNamedAutoConstant(  "uScroll",   GpuProgramParameters::ACT_CUSTOM );
           params->setNamedAutoConstant(  "vScroll",   GpuProgramParameters::ACT_CUSTOM );
           params->setNamedAutoConstant(  "preRotatedQuad[0]",   GpuProgramParameters::ACT_CUSTOM );
           params->setNamedAutoConstant(  "preRotatedQuad[1]",   GpuProgramParameters::ACT_CUSTOM );
           params->setNamedAutoConstant(  "preRotatedQuad[2]",   GpuProgramParameters::ACT_CUSTOM );
           params->setNamedAutoConstant(  "preRotatedQuad[3]",   GpuProgramParameters::ACT_CUSTOM );
          
           params->setNamedAutoConstant(  "camPos",   GpuProgramParameters::ACT_CAMERA_POSITION_OBJECT_SPACE );
           params->setNamedAutoConstant(  "fadeGap",   GpuProgramParameters::ACT_CUSTOM );
           params->setNamedAutoConstant(  "invisibleDist",   GpuProgramParameters::ACT_CUSTOM );
          
           //Set fade ranges
           params->setNamedConstant(  "invisibleDist",   invisibleDist );
           params->setNamedConstant(  "fadeGap",   invisibleDist - visibleDist );
          
           pass->setSceneBlending(  SBT_TRANSPARENT_ALPHA );
           //pass->setAlphaRejectFunction(  CMPF_ALWAYS_PASS );
           //pass->setDepthWriteEnabled(  false );
           }
           }
          
           //Add it to the list so it can be reused later
           fadedMaterialMap.insert(  std::pair<String,   MaterialPtr>(  materialSignature.str(   ),   fadeMaterial ) );
           }
          
           return fadeMaterial;
          }
          
     577  void StaticBillboardSet::updateAll(  const Vector3 &cameraDirection )
          {
           if (  selfInstances > 0 ){ //selfInstances will only be greater than 0 if one or more StaticBillboardSet's are using BB_METHOD_ACCELERATED
           //Set shader parameter so material will face camera
           Vector3 forward = cameraDirection;
           Vector3 vRight = forward.crossProduct(  Vector3::UNIT_Y );
           Vector3 vUp = forward.crossProduct(  vRight );
           vRight.normalise(   );
           vUp.normalise(   );
          
           //Even if camera is upside down,   the billboards should remain upright
           if (  vUp.y < 0 ) vUp *= -1;
          
           //For each material in use by the billboard system..
           SBMaterialRefList::iterator i1,   i2;
           i1 = SBMaterialRef::getList(   ).begin(   );
           i2 = SBMaterialRef::getList(   ).end(   );
           while (  i1 != i2 ){
           Material *mat = i1->second->getMaterial(   );
           BillboardOrigin bbOrigin = i1->second->getOrigin(   );
          
           Vector3 vPoint0,   vPoint1,   vPoint2,   vPoint3;
           if (  bbOrigin == BBO_CENTER ){
           vPoint0 = (  -vRight + vUp );
           vPoint1 = (   vRight + vUp );
           vPoint2 = (  -vRight - vUp );
           vPoint3 = (   vRight - vUp );
           }
           else if (  bbOrigin == BBO_BOTTOM_CENTER ){
           vPoint0 = (  -vRight + vUp + vUp );
           vPoint1 = (   vRight + vUp + vUp );
           vPoint2 = (  -vRight );
           vPoint3 = (   vRight );
           }
          
           //single prerotated quad oriented towards the camera
           float preRotatedQuad[16] = {
           vPoint0.x,   vPoint0.y,   vPoint0.z,   0.0f,  
           vPoint1.x,   vPoint1.y,   vPoint1.z,   0.0f,  
           vPoint2.x,   vPoint2.y,   vPoint2.z,   0.0f,  
           vPoint3.x,   vPoint3.y,   vPoint3.z,   0.0f
           };
          
           //Ensure material is set up with the vertex shader
           Pass *p = mat->getTechnique(  0 )->getPass(  0 );
           if(  !p->hasVertexProgram(   ) ){
           p->setVertexProgram(  "Sprite_vp" );
           p->getVertexProgramParameters(   )->setNamedAutoConstant(  "worldViewProj",   GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX );
           p->getVertexProgramParameters(   )->setNamedAutoConstant(  "uScroll",   GpuProgramParameters::ACT_CUSTOM );
           p->getVertexProgramParameters(   )->setNamedAutoConstant(  "vScroll",   GpuProgramParameters::ACT_CUSTOM );
           p->getVertexProgramParameters(   )->setNamedAutoConstant(  "preRotatedQuad[0]",   GpuProgramParameters::ACT_CUSTOM );
           p->getVertexProgramParameters(   )->setNamedAutoConstant(  "preRotatedQuad[1]",   GpuProgramParameters::ACT_CUSTOM );
           p->getVertexProgramParameters(   )->setNamedAutoConstant(  "preRotatedQuad[2]",   GpuProgramParameters::ACT_CUSTOM );
           p->getVertexProgramParameters(   )->setNamedAutoConstant(  "preRotatedQuad[3]",   GpuProgramParameters::ACT_CUSTOM );
           }
          
           //Update the vertex shader parameters
           GpuProgramParametersSharedPtr params = p->getVertexProgramParameters(   );
           params->setNamedConstant(  "preRotatedQuad[0]",   preRotatedQuad,   4 );
           params->setNamedConstant(  "uScroll",   p->getTextureUnitState(  0 )->getTextureUScroll(   ) );
           params->setNamedConstant(  "vScroll",   p->getTextureUnitState(  0 )->getTextureVScroll(   ) );
          
           ++i1;
           }
           }
          }
          
     644  void StaticBillboardSet::setBillboardOrigin(  BillboardOrigin origin )
          {
           if (  origin != BBO_CENTER && origin != BBO_BOTTOM_CENTER )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Invalid origin - only BBO_CENTER and BBO_BOTTOM_CENTER is supported",   "StaticBillboardSet::setBillboardOrigin(   )" );
          
           if (  renderMethod == BB_METHOD_ACCELERATED ){
           bbOrigin = origin;
           } else {
           bbOrigin = origin;
           fallbackSet->setBillboardOrigin(  origin );
           }
          }
          
          
          //-------------------------------------------------------------------------------------
          
          SBMaterialRefList SBMaterialRef::selfList;
          
     662  void SBMaterialRef::addMaterialRef(  const MaterialPtr &matP,   Ogre::BillboardOrigin o )
          {
           Material *mat = matP.getPointer(   );
          
           SBMaterialRef *matRef;
           SBMaterialRefList::iterator it;
           it = selfList.find(  mat );
          
           if (  it != selfList.end(   ) ){
           //Material already exists in selfList - increment refCount
           matRef = it->second;
           ++matRef->refCount;
           } else {
           //Material does not exist in selfList - add it
           matRef = new SBMaterialRef(  mat,   o );
           selfList[mat] = matRef;
           //No need to set refCount to 1 here because the SBMaterialRef
           //constructor sets refCount to 1.
           }
          }
          
     683  void SBMaterialRef::removeMaterialRef(  const MaterialPtr &matP )
          {
           Material *mat = matP.getPointer(   );
          
           SBMaterialRef *matRef;
           SBMaterialRefList::iterator it;
          
           //Find material in selfList
           it = selfList.find(  mat );
           if (  it != selfList.end(   ) ){
           //Decrease the reference count,   and remove the item if refCount == 0
           matRef = it->second;
           if (  --matRef->refCount == 0 ){
           delete matRef;
           selfList.erase(  it );
           }
           }
          }
          
     702  SBMaterialRef::SBMaterialRef(  Material *mat,   Ogre::BillboardOrigin o )
          {
           material = mat;
           origin = o;
           refCount = 1;
          }
          }

./components/ogre/environment/pagedgeometry/source/TreeLoader2D.cpp

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
           1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
           2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
           3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          #include "TreeLoader2D.h"
          #include "PagedGeometry.h"
          #include "PropertyMaps.h"
          
          #include "OgreRoot.h"
          #include "OgreException.h"
          #include "OgreVector3.h"
          #include "OgreQuaternion.h"
          #include "OgreLogManager.h"
          #include "OgreStringConverter.h"
          using namespace Ogre;
          
          namespace PagedGeometry {
          
      25  TreeLoader2D::TreeLoader2D(  PagedGeometry *geom,   const TRect<Real> &bounds )
          {
           //Calculate grid size
           TreeLoader2D::geom = geom;
           pageSize = geom->getPageSize(   );
          
           //Reset height function
           heightFunction = NULL;
           heightFunctionUserData = NULL;
          
           //Make sure the bounds are aligned with PagedGeometry's grid,   so the TreeLoader's grid tiles will have a 1:1 relationship
           actualBounds = bounds;
           gridBounds = bounds;
           gridBounds.left = pageSize * Math::Floor(  (  gridBounds.left - geom->getBounds(   ).left ) / pageSize ) + geom->getBounds(   ).left;
           gridBounds.top = pageSize * Math::Floor(  (  gridBounds.top - geom->getBounds(   ).top ) / pageSize ) + geom->getBounds(   ).top;
           gridBounds.right = pageSize * Math::Ceil(  (  gridBounds.right - geom->getBounds(   ).left ) / pageSize ) + geom->getBounds(   ).left;
           gridBounds.bottom = pageSize * Math::Ceil(  (  gridBounds.bottom - geom->getBounds(   ).top ) / pageSize ) + geom->getBounds(   ).top;
          
           //Calculate page grid size
           pageGridX = Math::Ceil(  gridBounds.width(   ) / pageSize ) + 1;
           pageGridZ = Math::Ceil(  gridBounds.height(   ) / pageSize ) + 1;
          
           //Reset color map
           colorMap = NULL;
           colorMapFilter = MAPFILTER_NONE;
          
           //Default scale range
           maximumScale = 2.0f;
           minimumScale = 0.0f;
          }
          
      56  TreeLoader2D::~TreeLoader2D(   )
          {
           //Delete all page grids
           PageGridListIterator i;
           for (  i = pageGridList.begin(   ); i != pageGridList.end(   ); ++i ){
           delete[] i->second;
           }
           pageGridList.clear(   );
          }
          
      66  void TreeLoader2D::addTree(  Entity *entity,   const Vector3 &position,   Degree yaw,   Real scale )
          {
           //First convert the coordinate to PagedGeometry's local system
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           Vector3 pos = geom->_convertToLocal(  position );
           #else
           Vector3 pos = position;
           #endif
          
           //If the tree is slightly out of bounds (  due to imprecise coordinate conversion ),   fix it
           if (  pos.x < actualBounds.left )
           pos.x = actualBounds.left;
           else if (  pos.x > actualBounds.right )
           pos.x = actualBounds.right;
          
           if (  pos.z < actualBounds.top )
           pos.z = actualBounds.top;
           else if (  pos.x > actualBounds.bottom )
           pos.z = actualBounds.bottom;
          
           Real x = pos.x;
           Real z = pos.z;
          
           //Check that the tree is within bounds (  DEBUG )
           #ifdef _DEBUG
           const Real smallVal = 0.01f;
           if (  pos.x < actualBounds.left-smallVal || pos.x > actualBounds.right+smallVal || pos.z < actualBounds.top-smallVal || pos.z > actualBounds.bottom+smallVal )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Tree position is out of bounds",   "TreeLoader::addTree(   )" );
           if (  scale < minimumScale || scale > maximumScale )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Tree scale out of range",   "TreeLoader::addTree(   )" );
           #endif
          
           //Find the appropriate page grid for the entity
           PageGridListIterator i;
           i = pageGridList.find(  entity );
          
           std::vector<TreeDef> *pageGrid;
           if (  i != pageGridList.end(   ) ){
           //If it exists,   get the page grid
           pageGrid = i->second;
           } else {
           //If it does not exist,   create a new page grid
           pageGrid = new std::vector<TreeDef>[pageGridX * pageGridZ];
          
           //Register the new page grid in the pageGridList for later retrieval
           pageGridList.insert(  PageGridListValue(  entity,   pageGrid ) );
           }
          
           //Calculate the gridbounds-relative position of the tree
           Real xrel = x - gridBounds.left;
           Real zrel = z - gridBounds.top;
          
           //Get the appropriate grid element based on the new tree's position
           int pageX = Math::Floor(  xrel / pageSize );
           int pageZ = Math::Floor(  zrel / pageSize );
           std::vector<TreeDef> &treeList = _getGridPage(  pageGrid,   pageX,   pageZ );
          
           //Create the new tree
           TreeDef tree;
           tree.xPos = 65535 * (  xrel - (  pageX * pageSize ) ) / pageSize;
           tree.zPos = 65535 * (  zrel - (  pageZ * pageSize ) ) / pageSize;
           tree.rotation = 255 * (  yaw.valueDegrees(   ) / 360.0f );
           tree.scale = 255 * (  (  scale - minimumScale ) / maximumScale );
          
           //Add it to the tree list
           treeList.push_back(  tree );
          
           //Rebuild geometry if necessary
           geom->reloadGeometryPage(  Vector3(  x,   0,   z ) );
          }
          
     137  void TreeLoader2D::deleteTrees(  const Ogre::Vector3 &position,   Real radius,   Entity *type )
          {
           //First convert the coordinate to PagedGeometry's local system
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           Vector3 pos = geom->_convertToLocal(  position );
           #else
           Vector3 pos = position;
           #endif
          
           //If the position is slightly out of bounds,   fix it
           if (  pos.x < actualBounds.left )
           pos.x = actualBounds.left;
           else if (  pos.x > actualBounds.right )
           pos.x = actualBounds.right;
          
           if (  pos.z < actualBounds.top )
           pos.z = actualBounds.top;
           else if (  pos.x > actualBounds.bottom )
           pos.z = actualBounds.bottom;
          
           Real x = pos.x;
           Real z = pos.z;
          
           //Determine the grid blocks which might contain the requested trees
           int minPageX = Math::Floor(  (  (  x-radius ) - gridBounds.left ) / pageSize );
           int minPageZ = Math::Floor(  (  (  z-radius ) - gridBounds.top ) / pageSize );
           int maxPageX = Math::Floor(  (  (  x+radius ) - gridBounds.left ) / pageSize );
           int maxPageZ = Math::Floor(  (  (  z+radius ) - gridBounds.top ) / pageSize );
           Real radiusSq = radius * radius;
          
           PageGridListIterator it,   end;
           if (  type == NULL ){
           //Scan all entity types
           it = pageGridList.begin(   );
           end = pageGridList.end(   );
           } else {
           //Only scan entities of the given type
           it = pageGridList.find(  type );
           assert(  it != pageGridList.end(   ) );
           end = it; ++end;
           }
          
           //Scan all the grid blocks
           while (  it != end ){
           std::vector<TreeDef> *pageGrid = it->second;
          
           for (  int tileZ = minPageZ; tileZ <= maxPageZ; ++tileZ ){
           for (  int tileX = minPageX; tileX <= maxPageX; ++tileX ){
           bool modified = false;
          
           //Scan all trees in grid block
           std::vector<TreeDef> &treeList = _getGridPage(  pageGrid,   tileX,   tileZ );
           std::vector<TreeDef>::iterator i;
           for (  i = treeList.begin(   ); i != treeList.end(   );  ){
           //Get tree distance
           float distX = (  gridBounds.left + (  tileX * pageSize ) + (  (  Real )i->xPos / 65535 ) * pageSize ) - x;
           float distZ = (  gridBounds.top + (  tileZ * pageSize ) + (  (  Real )i->zPos / 65535 ) * pageSize ) - z;
           float distSq = distX * distX + distZ * distZ;
          
           if (  distSq <= radiusSq ){
           //If it's within the radius,   delete it
           *i = treeList.back(   );
           treeList.pop_back(   );
           modified = true;
           }
           else
           ++i;
           }
          
           //Rebuild geometry if necessary
           if (  modified ){
           Vector3 pos(  gridBounds.left + (  (  0.5f + tileX ) * pageSize ),   0,   gridBounds.top + (  (  0.5f + tileZ ) * pageSize ) );
           geom->reloadGeometryPage(  pos );
           }
           }
           }
          
           ++it;
           }
          }
          
     218  void TreeLoader2D::setColorMap(  const Ogre::String &mapFile,   MapChannel channel )
          {
           if (  colorMap ){
           colorMap->unload(   );
           colorMap = NULL;
           }
           if (  mapFile != "" ){
           colorMap = ColorMap::load(  mapFile,   channel );
           colorMap->setMapBounds(  actualBounds );
           colorMap->setFilter(  colorMapFilter );
           }
          }
          
     231  void TreeLoader2D::setColorMap(  Ogre::Texture *map,   MapChannel channel )
          {
           if (  colorMap ){
           colorMap->unload(   );
           colorMap = NULL;
           }
           if (  map ){
           colorMap = ColorMap::load(  map,   channel );
           colorMap->setMapBounds(  actualBounds );
           colorMap->setFilter(  colorMapFilter );
           }
          }
          
     244  void TreeLoader2D::loadPage(  PageInfo &page )
          {
           //Calculate x/z indexes for the grid array
           page.xIndex -= Math::Floor(  gridBounds.left / pageSize );
           page.zIndex -= Math::Floor(  gridBounds.top / pageSize );
          
           //Check if the requested page is in bounds
           if (  page.xIndex < 0 || page.zIndex < 0 || page.xIndex >= pageGridX || page.zIndex >= pageGridZ )
           return;
          
           //For each tree type...
           PageGridListIterator i;
           for (  i = pageGridList.begin(   ); i != pageGridList.end(   ); ++i ){
           //Get the appropriate tree list for the specified page
           std::vector<TreeDef> *pageGrid = i->second;
           std::vector<TreeDef> &treeList = _getGridPage(  pageGrid,   page.xIndex,   page.zIndex );
           Entity *entity = i->first;
          
           //Load the listed trees into the page
           std::vector<TreeDef>::iterator o;
           for (  o = treeList.begin(   ); o != treeList.end(   ); ++o ){
           //Get position
           Vector3 pos;
           pos.x = page.bounds.left + (  (  Real )o->xPos / 65535 ) * pageSize;
           pos.z = page.bounds.top + (  (  Real )o->zPos / 65535 ) * pageSize;
          
           //Calculate terrain height at pos.x / pos.z to get pos.y
           if (  heightFunction != NULL )
           pos.y = heightFunction(  pos.x,   pos.z,   heightFunctionUserData );
           else
           pos.y = 0.0f;
          
           //Get rotation
           Degree angle(  (  Real )o->rotation * (  360.0f / 255 ) );
           Quaternion rot(  angle,   Vector3::UNIT_Y );
          
           //Get scale
           Vector3 scale;
           scale.y = (  Real )o->scale * (  maximumScale / 255 ) + minimumScale;
           scale.x = scale.y;
           scale.z = scale.y;
          
           //Get color
           ColourValue color;
           if (  colorMap )
           color = colorMap->getColorAt_Unpacked(  pos.x,   pos.z );
           else
           color = ColourValue::White;
          
           addEntity(  entity,   pos,   rot,   scale,   color );
           }
           }
          }
          
     298  TreeIterator2D TreeLoader2D::getTrees(   )
          {
           return TreeIterator2D(  this );
          }
          
          
          
     305  TreeIterator2D::TreeIterator2D(  TreeLoader2D *trees )
          {
           TreeIterator2D::trees = trees;
          
           //Setup iterators
           currentGrid = trees->pageGridList.begin(   );
           currentX = 0; currentZ = 0;
           currentTreeList = &trees->_getGridPage(  currentGrid->second,   currentX,   currentZ );
           currentTree = currentTreeList->begin(   );
           hasMore = true;
          
           //If there's not tree in the first page,   keep looking
           if (  currentTree == currentTreeList->end(   ) )
           moveNext(   );
          
           //Read the first tree's data
           _readTree(   );
          
           //Read one more tree,   so peekNext(   ) will properly return the first item,   while the system
           //actually is looking ahead one item (  this way it can detect the end of the list before
           //it's too late )
           if (  hasMore )
           moveNext(   );
          }
          
     330  TreeRef TreeIterator2D::getNext(   )
          {
           TreeRef tree = peekNext(   );
           moveNext(   );
           return tree;
          }
          
     337  void TreeIterator2D::moveNext(   )
          {
           //Out of bounds check
           if (  !hasMore )
           OGRE_EXCEPT(  1,   "Cannot read past end of TreeIterator list",   "TreeIterator::moveNext(   )" );
          
           //Preserve the last tree
           prevTreeDat = currentTreeDat;
          
           //Incriment iterators to the next tree
           ++currentTree;
           while (  currentTree == currentTreeList->end(   ) ){
           if (  ++currentX >= trees->pageGridX ){
           currentX = 0;
           if (  ++currentZ >= trees->pageGridZ ){
           ++currentGrid;
           if (  currentGrid == trees->pageGridList.end(   ) ){
           //No more trees left
           hasMore = false;
           return;
           }
           currentX = 0; currentZ = 0;
           }
           }
          
           currentTreeList = &trees->_getGridPage(  currentGrid->second,   currentX,   currentZ );
           currentTree = currentTreeList->begin(   );
           }
          
           //Read the current tree data
           _readTree(   );
          }
          
     370  void TreeIterator2D::_readTree(   )
          {
           TreeLoader2D::TreeDef treeDef = *currentTree;
          
           //Get position
           Real boundsLeft = trees->gridBounds.left + trees->pageSize * currentX;
           Real boundsTop = trees->gridBounds.top + trees->pageSize * currentZ;
           currentTreeDat.position.x = boundsLeft + (  (  Real )treeDef.xPos / 65535 ) * trees->pageSize;
           currentTreeDat.position.z = boundsTop + (  (  Real )treeDef.zPos / 65535 ) * trees->pageSize;
          
           //Calculate terrain height at x / z to get y
           if (  trees->heightFunction != NULL )
           currentTreeDat.position.y = trees->heightFunction(  currentTreeDat.position.x,   currentTreeDat.position.z,   trees->heightFunctionUserData );
           else
           currentTreeDat.position.y = 0.0f;
          
           //Get rotation
           currentTreeDat.yaw = Degree(  (  Real )treeDef.rotation * (  360.0f / 255 ) );
          
           //Get scale
           currentTreeDat.scale = (  Real )treeDef.scale * (  trees->maximumScale / 255 ) + trees->minimumScale;
          
           //Get entity
           currentTreeDat.entity = currentGrid->first;
          }
          }

./components/ogre/environment/pagedgeometry/source/TreeLoader3D.cpp

       1  /*-------------------------------------------------------------------------------------
          Copyright (  c ) 2006 John Judnich
          
          This software is provided 'as-is',   without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
          Permission is granted to anyone to use this software for any purpose,   including commercial applications,   and to alter it and redistribute it freely,   subject to the following restrictions:
          1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product,   an acknowledgment in the product documentation would be appreciated but is not required.
          2. Altered source versions must be plainly marked as such,   and must not be misrepresented as being the original software.
          3. This notice may not be removed or altered from any source distribution.
          -------------------------------------------------------------------------------------*/
          
          #include "TreeLoader3D.h"
          #include "PagedGeometry.h"
          #include "PropertyMaps.h"
          
          #include "OgreRoot.h"
          #include "OgreException.h"
          #include "OgreVector3.h"
          #include "OgreQuaternion.h"
          using namespace Ogre;
          
          namespace PagedGeometry {
          
      23  TreeLoader3D::TreeLoader3D(  PagedGeometry *geom,   const TRect<Real> &bounds )
          {
           //Calculate grid size
           TreeLoader3D::geom = geom;
           pageSize = geom->getPageSize(   );
          
           //Make sure the bounds are aligned with PagedGeometry's grid,   so the TreeLoader's grid tiles will have a 1:1 relationship
           actualBounds = bounds;
           gridBounds = bounds;
           gridBounds.left = pageSize * Math::Floor(  (  gridBounds.left - geom->getBounds(   ).left ) / pageSize ) + geom->getBounds(   ).left;
           gridBounds.top = pageSize * Math::Floor(  (  gridBounds.top - geom->getBounds(   ).top ) / pageSize ) + geom->getBounds(   ).top;
           gridBounds.right = pageSize * Math::Ceil(  (  gridBounds.right - geom->getBounds(   ).left ) / pageSize ) + geom->getBounds(   ).left;
           gridBounds.bottom = pageSize * Math::Ceil(  (  gridBounds.bottom - geom->getBounds(   ).top ) / pageSize ) + geom->getBounds(   ).top;
          
           //Calculate page grid size
           pageGridX = Math::Ceil(  gridBounds.width(   ) / pageSize ) + 1;
           pageGridZ = Math::Ceil(  gridBounds.height(   ) / pageSize ) + 1;
          
           //Reset color map
           colorMap = NULL;
           colorMapFilter = MAPFILTER_NONE;
          
           //Default scale range
           maximumScale = 2.0f;
           minimumScale = 0.0f;
          }
          
      50  TreeLoader3D::~TreeLoader3D(   )
          {
           //Delete all page grids
           PageGridListIterator i;
           for (  i = pageGridList.begin(   ); i != pageGridList.end(   ); ++i ){
           delete[] i->second;
           }
           pageGridList.clear(   );
          }
          
      60  void TreeLoader3D::addTree(  Entity *entity,   const Ogre::Vector3 &position,   Degree yaw,   Real scale )
          {
           //First convert the coordinate to PagedGeometry's local system
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           Vector3 pos = geom->_convertToLocal(  position );
           #else
           Vector3 pos = position;
           #endif
          
           //If the tree is slightly out of bounds (  due to imprecise coordinate conversion ),   fix it
           if (  pos.x < actualBounds.left )
           pos.x = actualBounds.left;
           else if (  pos.x > actualBounds.right )
           pos.x = actualBounds.right;
          
           if (  pos.z < actualBounds.top )
           pos.z = actualBounds.top;
           else if (  pos.x > actualBounds.bottom )
           pos.z = actualBounds.bottom;
          
           //Check that the tree is within bounds (  DEBUG )
           #ifdef _DEBUG
           const Real smallVal = 0.01f;
           if (  pos.x < actualBounds.left-smallVal || pos.x > actualBounds.right+smallVal || pos.z < actualBounds.top-smallVal || pos.z > actualBounds.bottom+smallVal )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Tree position is out of bounds",   "TreeLoader::addTree(   )" );
           if (  scale < minimumScale || scale > maximumScale )
           OGRE_EXCEPT(  Exception::ERR_INVALIDPARAMS,   "Tree scale out of range",   "TreeLoader::addTree(   )" );
           #endif
          
           //Find the appropriate page grid for the entity
           PageGridListIterator i;
           i = pageGridList.find(  entity );
          
           std::vector<TreeDef> *pageGrid;
           if (  i != pageGridList.end(   ) ){
           //If it exists,   get the page grid
           pageGrid = i->second;
           } else {
           //If it does not exist,   create a new page grid
           pageGrid = new std::vector<TreeDef>[pageGridX * pageGridZ];
          
           //Register the new page grid in the pageGridList for later retrieval
           pageGridList.insert(  PageGridListValue(  entity,   pageGrid ) );
           }
          
           //Calculate the gridbounds-relative position of the tree
           Real xrel = pos.x - gridBounds.left;
           Real zrel = pos.z - gridBounds.top;
          
           //Get the appropriate grid element based on the new tree's position
           int pageX = Math::Floor(  xrel / pageSize );
           int pageZ = Math::Floor(  zrel / pageSize );
           std::vector<TreeDef> &treeList = _getGridPage(  pageGrid,   pageX,   pageZ );
          
           //Create the new tree
           TreeDef tree;
           tree.yPos = pos.y;
           tree.xPos = 65535 * (  xrel - (  pageX * pageSize ) ) / pageSize;
           tree.zPos = 65535 * (  zrel - (  pageZ * pageSize ) ) / pageSize;
           tree.rotation = 255 * (  yaw.valueDegrees(   ) / 360.0f );
           tree.scale = 255 * (  (  scale - minimumScale ) / maximumScale );
          
           //Add it to the tree list
           treeList.push_back(  tree );
          
           //Rebuild geometry if necessary
           geom->reloadGeometryPage(  pos );
          }
          
     129  void TreeLoader3D::deleteTrees(  const Ogre::Vector3 &position,   Real radius,   Entity *type )
          {
           //First convert the coordinate to PagedGeometry's local system
           #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM
           Vector3 pos = geom->_convertToLocal(  position );
           #else
           Vector3 pos = position;
           #endif
          
           //If the position is slightly out of bounds,   fix it
           if (  pos.x < actualBounds.left )
           pos.x = actualBounds.left;
           else if (  pos.x > actualBounds.right )
           pos.x = actualBounds.right;
          
           if (  pos.z < actualBounds.top )
           pos.z = actualBounds.top;
           else if (  pos.x > actualBounds.bottom )
           pos.z = actualBounds.bottom;
          
           //Determine the grid blocks which might contain the requested trees
           int minPageX = Math::Floor(  (  (  pos.x-radius ) - gridBounds.left ) / pageSize );
           int minPageZ = Math::Floor(  (  (  pos.z-radius ) - gridBounds.top ) / pageSize );
           int maxPageX = Math::Floor(  (  (  pos.x+radius ) - gridBounds.left ) / pageSize );
           int maxPageZ = Math::Floor(  (  (  pos.z+radius ) - gridBounds.top ) / pageSize );
           Real radiusSq = radius * radius;
          
           PageGridListIterator it,   end;
           if (  type == NULL ){
           //Scan all entity types
           it = pageGridList.begin(   );
           end = pageGridList.end(   );
           } else {
           //Only scan entities of the given type
           it = pageGridList.find(  type );
           assert(  it != pageGridList.end(   ) );
           end = it; ++end;
           }
          
           //Scan all the grid blocks
           while (  it != end ){
           std::vector<TreeDef> *pageGrid = it->second;
          
           for (  int tileZ = minPageZ; tileZ <= maxPageZ; ++tileZ ){
           for (  int tileX = minPageX; tileX <= maxPageX; ++tileX ){
           bool modified = false;
          
           //Scan all trees in grid block
           std::vector<TreeDef> &treeList = _getGridPage(  pageGrid,   tileX,   tileZ );
           std::vector<TreeDef>::iterator i;
           for (  i = treeList.begin(   ); i != treeList.end(   );  ){
           //Get tree distance
           float distX = (  gridBounds.left + (  tileX * pageSize ) + (  (  Real )i->xPos / 65535 ) * pageSize ) - pos.x;
           float distZ = (  gridBounds.top + (  tileZ * pageSize ) + (  (  Real )i->zPos / 65535 ) * pageSize ) - pos.z;
           float distSq = distX * distX + distZ * distZ;
          
           if (  distSq <= radiusSq ){
           //If it's within the radius,   delete it
           *i = treeList.back(   );
           treeList.pop_back(   );
           modified = true;
           }
           else
           ++i;
           }
          
           //Rebuild geometry if necessary
           if (  modified ){
           Vector3 pos(  gridBounds.left + (  (  0.5f + tileX ) * pageSize ),   0,   gridBounds.top + (  (  0.5f + tileZ ) * pageSize ) );
           geom->reloadGeometryPage(  pos );
           }
           }
           }
          
           ++it;
           }
          }
          
     207  void TreeLoader3D::setColorMap(  const Ogre::String &mapFile,   MapChannel channel )
          {
           if (  colorMap ){
           colorMap->unload(   );
           colorMap = NULL;
           }
           if (  mapFile != "" ){
           colorMap = ColorMap::load(  mapFile,   channel );
           colorMap->setMapBounds(  actualBounds );
           colorMap->setFilter(  colorMapFilter );
           }
          }
          
     220  void TreeLoader3D::setColorMap(  Ogre::Texture *map,   MapChannel channel )
          {
           if (  colorMap ){
           colorMap->unload(   );
           colorMap = NULL;
           }
           if (  map ){
           colorMap = ColorMap::load(  map,   channel );
           colorMap->setMapBounds(  actualBounds );
           colorMap->setFilter(  colorMapFilter );
           }
          }
          
     233  void TreeLoader3D::loadPage(  PageInfo &page )
          {
           //Calculate x/z indexes for the grid array
           page.xIndex -= Math::Floor(  gridBounds.left / pageSize );
           page.zIndex -= Math::Floor(  gridBounds.top / pageSize );
          
           //Check if the requested page is in bounds
           if (  page.xIndex < 0 || page.zIndex < 0 || page.xIndex >= pageGridX || page.zIndex >= pageGridZ )
           return;
          
           //For each tree type...
           PageGridListIterator i;
           for (  i = pageGridList.begin(   ); i != pageGridList.end(   ); ++i ){
           //Get the appropriate tree list for the specified page
           std::vector<TreeDef> *pageGrid = i->second;
           std::vector<TreeDef> &treeList = _getGridPage(  pageGrid,   page.xIndex,   page.zIndex );
           Entity *entity = i->first;
          
           //Load the listed trees into the page
           std::vector<TreeDef>::iterator o;
           for (  o = treeList.begin(   ); o != treeList.end(   ); ++o ){
           //Get position
           Vector3 pos;
           pos.x = page.bounds.left + (  (  Real )o->xPos / 65535 ) * pageSize;
           pos.z = page.bounds.top + (  (  Real )o->zPos / 65535 ) * pageSize;
           pos.y = o->yPos;
          
           //Get rotation
           Degree angle(  (  Real )o->rotation * (  360.0f / 255 ) );
           Quaternion rot(  angle,   Vector3::UNIT_Y );
          
           //Get scale
           Vector3 scale;
           scale.y = (  Real )o->scale * (  maximumScale / 255 ) + minimumScale;
           scale.x = scale.y;
           scale.z = scale.y;
          
           //Get color
           ColourValue color;
           if (  colorMap )
           color = colorMap->getColorAt_Unpacked(  pos.x,   pos.z );
           else
           color = ColourValue::White;
          
           addEntity(  entity,   pos,   rot,   scale,   color );
           }
           }
          }
          
     282  TreeIterator3D TreeLoader3D::getTrees(   )
          {
           return TreeIterator3D(  this );
          }
          
          
          
     289  TreeIterator3D::TreeIterator3D(  TreeLoader3D *trees )
          {
           TreeIterator3D::trees = trees;
          
           //Setup iterators
           currentGrid = trees->pageGridList.begin(   );
           currentX = 0; currentZ = 0;
           currentTreeList = &trees->_getGridPage(  currentGrid->second,   currentX,   currentZ );
           currentTree = currentTreeList->begin(   );
           hasMore = true;
          
           //If there's not tree in the first page,   keep looking
           if (  currentTree == currentTreeList->end(   ) )
           moveNext(   );
          
           //Read the first tree's data
           _readTree(   );
          
           //Read one more tree,   so peekNext(   ) will properly return the first item,   while the system
           //actually is looking ahead one item (  this way it can detect the end of the list before
           //it's too late )
           if (  hasMore )
           moveNext(   );
          }
          
     314  TreeRef TreeIterator3D::getNext(   )
          {
           TreeRef tree = peekNext(   );
           moveNext(   );
           return tree;
          }
          
     321  void TreeIterator3D::moveNext(   )
          {
           //Out of bounds check
           if (  !hasMore )
           OGRE_EXCEPT(  1,   "Cannot read past end of TreeIterator list",   "TreeIterator::moveNext(   )" );
          
           //Preserve the last tree
           prevTreeDat = currentTreeDat;
          
           //Incriment iterators to the next tree
           ++currentTree;
           while (  currentTree == currentTreeList->end(   ) ){
           if (  ++currentX >= trees->pageGridX ){
           currentX = 0;
           if (  ++currentZ >= trees->pageGridZ ){
           ++currentGrid;
           if (  currentGrid == trees->pageGridList.end(   ) ){
           //No more trees left
           hasMore = false;
           return;
           }
           currentX = 0; currentZ = 0;
           }
           }
          
           currentTreeList = &trees->_getGridPage(  currentGrid->second,   currentX,   currentZ );
           currentTree = currentTreeList->begin(   );
           }
          
           //Read the current tree data
           _readTree(   );
          }
          
     354  void TreeIterator3D::_readTree(   )
          {
           TreeLoader3D::TreeDef treeDef = *currentTree;
          
           //Get position
           Real boundsLeft = trees->gridBounds.left + trees->pageSize * currentX;
           Real boundsTop = trees->gridBounds.top + trees->pageSize * currentZ;
           currentTreeDat.position.x = boundsLeft + (  (  Real )treeDef.xPos / 65535 ) * trees->pageSize;
           currentTreeDat.position.z = boundsTop + (  (  Real )treeDef.zPos / 65535 ) * trees->pageSize;
           currentTreeDat.position.y = treeDef.yPos;
          
           //Get rotation
           currentTreeDat.yaw = Degree(  (  Real )treeDef.rotation * (  360.0f / 255 ) );
          
           //Get scale
           currentTreeDat.scale = (  Real )treeDef.scale * (  trees->maximumScale / 255 ) + trees->minimumScale;
          
           //Get entity
           currentTreeDat.entity = currentGrid->first;
          }
          }

./components/ogre/gui/ActiveWidgetHandler.cpp

       1  //
          // C++ Implementation: ActiveWidgetHandler
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "ActiveWidgetHandler.h"
          
          #include "../GUIManager.h"
          #include <CEGUI.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
      36  ActiveWidgetHandler::ActiveWidgetHandler(  ::EmberOgre::GUIManager& guiManager )
          : mGuiManager(  guiManager )
          {
          
           ///connect to the changing of input mode since we want to deactivate the current active input window when switching from gui mode to movement mode
           Input::getSingleton(   ).EventChangedInputMode.connect(  sigc::mem_fun(  *this,   &ActiveWidgetHandler::Input_InputModeChanged ) );
          
          }
          
          
      46  ActiveWidgetHandler::~ActiveWidgetHandler(   )
          {
          }
          
      50  void ActiveWidgetHandler::Input_InputModeChanged(  Input::InputMode mode )
          {
           if (  mode != Input::IM_GUI && mLastMode == Input::IM_GUI ) {
           ///save the current active widget
           CEGUI::Window* window = mGuiManager.getMainSheet(   )->getActiveChild(   );
           if (  window ) {
           mLastActiveWidgetName = window->getName(   ).c_str(   );
           window->deactivate(   );
           ///deactivate all parents
           while (  (  window = window->getParent(   ) ) ) {
           window->deactivate(   );
           }
           } else {
           mLastActiveWidgetName = "";
           }
           mLastMode = mode;
           } else if (  mode == Input::IM_GUI ) {
           if (  mLastActiveWidgetName != "" ) {
           ///restore the previously active widget
           try {
           CEGUI::Window* window = CEGUI::WindowManager::getSingleton(   ).getWindow(  mLastActiveWidgetName );
           if (  window )
           {
           window->activate(   );
           }
           } catch (  ... )
           {
           S_LOG_WARNING(  "Error when trying to restore previously captured window." );
           }
           mLastActiveWidgetName = "";
           }
           mLastMode = mode;
           }
          }
          
          
          }
          
          }

./components/ogre/gui/ActiveWidgetHandler.h

       1  //
          // C++ Interface: ActiveWidgetHandler
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUIACTIVEWIDGETHANDLER_H
          #define EMBEROGRE_GUIACTIVEWIDGETHANDLER_H
          #include "../input/Input.h"
          
          namespace EmberOgre {
      28  class GUIManager;
          
          namespace Gui {
          
          /**
           Responsible for deactivating the current input focused window when we switch to movement mode,   and returning it when we switch back to gui mode.
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      36  class ActiveWidgetHandler{
          public:
      38   ActiveWidgetHandler(  ::EmberOgre::GUIManager& guiManager );
          
      40   ~ActiveWidgetHandler(   );
          
          protected:
      43   void Input_InputModeChanged(  Input::InputMode mode );
          
           /**
           The name of the window which last had input when we switched to movement mode. This is a string and not a pointer since the window might have been destroyed in between. One other possibility is to keep a pointer ref and listen for the Destroyed event.
           */
      48   std::string mLastActiveWidgetName;
          
           /**
           The last mode we were in.
           */
           Input::InputMode mLastMode;
          
           /**
           A reference to the gui manager.
           */
           ::EmberOgre::GUIManager& mGuiManager;
          };
          
          }
          
          }
          
          #endif

./components/ogre/image/OgreILCodecs.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2005 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          #include <OgreStableHeaders.h>
          
          #include <OgreImage.h>
          #include <OgreCodec.h>
          #include <OgreException.h>
          #include <OgreLogManager.h>
          #include <OgreStringConverter.h>
          #include "OgreILImageCodec.h"
          #include "OgreILCodecs.h"
          
          #include <IL/il.h>
          #include <IL/ilu.h>
          
          namespace Ogre {
           std::list<ILImageCodec*> ILCodecs::codeclist;
          
           // Return IL type for a certain extension
      42   ILenum ogreIlTypeFromExt(  const String &ext )
           {
          #ifdef IL_TGA
           if (  ext=="tga" || ext=="vda" ||
           ext=="icb" || ext=="vst" )
           return IL_TGA;
          #endif
          #ifdef IL_JPG
           if (  ext=="jpg" || ext=="jpe" || ext=="jpeg" )
           return IL_JPG;
          #endif
          /*#ifdef IL_DDS
           if (  ext=="dds" )
           return IL_DDS;
          #endif*/
          #ifdef IL_PNG
           if (  ext=="png" )
           return IL_PNG;
          #endif
          #ifdef IL_BMP
           if (  ext=="bmp" || ext=="dib" )
           return IL_BMP;
          #endif
          #ifdef IL_GIF
           if (  ext=="gif" )
           return IL_GIF;
          #endif
          #ifdef IL_CUT
           if (  ext=="cut" )
           return IL_CUT;
          #endif
          #ifdef IL_HDR
           if (  ext=="hdr" )
           return IL_HDR;
          #endif
          #ifdef IL_ICO
           if (  ext=="ico" || ext=="cur" )
           return IL_ICO;
          #endif
          #ifdef IL_JNG
           if (  ext=="jng" )
           return IL_JNG;
          #endif
          #ifdef IL_LIF
           if (  ext=="lif" )
           return IL_LIF;
          #endif
          #ifdef IL_MDL
           if (  ext=="mdl" )
           return IL_MDL;
          #endif
          #ifdef IL_MNG
           if (  ext=="mng" || ext=="jng" )
           return IL_MNG;
          #endif
          #ifdef IL_PCD
           if (  ext=="pcd" )
           return IL_PCD;
          #endif
          #ifdef IL_PCX
           if (  ext=="pcx" )
           return IL_PCX;
          #endif
          #ifdef IL_PIC
           if (  ext=="pic" )
           return IL_PIC;
          #endif
          #ifdef IL_PIX
           if (  ext=="pix" )
           return IL_PIX;
          #endif
          #ifdef IL_PNM
           if (  ext=="pbm" || ext=="pgm" ||
           ext=="pnm" || ext=="ppm" )
           return IL_PNM;
          #endif
          #ifdef IL_PSD
           if (  ext=="psd" || ext=="pdd" )
           return IL_PSD;
          #endif
          #ifdef IL_PSP
           if (  ext=="psp" )
           return IL_PSP;
          #endif
          #ifdef IL_PXR
           if (  ext=="pxr" )
           return IL_PXR;
          #endif
          #ifdef IL_SGI
           if (  ext=="sgi" || ext=="bw" ||
           ext=="rgb" || ext=="rgba" )
           return IL_SGI;
          #endif
          #ifdef IL_TIF
           if (  ext=="tif" || ext=="tiff" )
           return IL_TIF;
          #endif
          #ifdef IL_WAL
           if (  ext=="wal" )
           return IL_WAL;
          #endif
          #ifdef IL_XPM
           if (  ext=="xpm" )
           return IL_XPM;
          #endif
          
           return IL_TYPE_UNKNOWN;
           }
          
          
     152   void ILCodecs::registerCodecs(  void ) {
           const char *il_version = ilGetString (   IL_VERSION_NUM  );
           if(   ilGetError(   ) != IL_NO_ERROR  )
           {
           // IL defined the version number as IL_VERSION in older versions,   so we have to scan for it
           for(  int ver=150; ver<170; ver++ )
           {
           il_version = ilGetString (   ver  );
           if(  ilGetError(   ) == IL_NO_ERROR )
           break;
           else
           il_version = "Unknown";
           }
           }
           LogManager::getSingleton(   ).logMessage(  
           LML_NORMAL,  
           "DevIL version: " + String(  il_version ) );
           const char *il_extensions = ilGetString (   IL_LOAD_EXT  );
           if(   ilGetError(   ) != IL_NO_ERROR  )
           il_extensions = "";
          
           std::stringstream ext;
           String str,   all;
           ext << il_extensions;
           while(  ext >> str )
           {
          #if 0
           String fileName = "dummy." + str;
           // DevIL doesn't export this under windows -- how weird
           int ilType = ilTypeFromext(  const_cast<char*>(  fileName.c_str(   ) ) );
          #endif
           int ilType = ogreIlTypeFromExt(  str );
           ILImageCodec *codec = new ILImageCodec(  str,   ilType );
           Codec::registerCodec(  codec );
           codeclist.push_back(  codec );
           //all += str+String(  "(  " )+StringConverter::toString(  ilType )+String(  " ) " );
           all += str+String(  " " );
           }
           // Raw format,   missing in image formats string
           ILImageCodec *cod = new ILImageCodec(  "raw",   IL_RAW );
           Codec::registerCodec(  cod );
           codeclist.push_back(  cod );
           //all += String(  "raw" )+"(  "+StringConverter::toString(  IL_RAW )+String(  " ) " );
           all += String(  "raw " );
           LogManager::getSingleton(   ).logMessage(  
           LML_NORMAL,  
           "DevIL image formats: " + all );
           }
          
     201   void ILCodecs::deleteCodecs(  void ) {
           for(  std::list<ILImageCodec*>::const_iterator i = codeclist.begin(   ); i != codeclist.end(   ); ++i )
           {
           Codec::unRegisterCodec(  *i );
           delete *i;
           }
           codeclist.clear(   );
           }
          
          }
          

./components/ogre/image/OgreILCodecs.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2005 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          
          #ifndef _DDSCodec_H__
          #define _DDSCodec_H__
          
          #include <list>
          
          namespace Ogre
          {
      34   class ILImageCodec;
          
           class _OgrePrivate ILCodecs {
           protected:
           static std::list<ILImageCodec*> codeclist;
           public:
           // Register all codecs provided by this module
           static void registerCodecs(  void );
           // Delete all codecs provided by this module
           static void deleteCodecs(  void );
           };
          
          } // namespace Ogre
          
          
          #endif // #ifndef _DDSCodec_H__
          

./components/ogre/image/OgreILImageCodec.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2005 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          
          #include <OgreStableHeaders.h>
          
          #include <OgreRoot.h>
          #include <OgreRenderSystem.h>
          #include "OgreILImageCodec.h"
          #include <OgreImage.h>
          #include <OgreException.h>
          #include "OgreILUtil.h"
          
          #include <OgreLogManager.h>
          #include <OgreStringConverter.h>
          
          #include <IL/il.h>
          #include <IL/ilu.h>
          
          namespace Ogre {
          
           bool ILImageCodec::_is_initialised = false;
           //---------------------------------------------------------------------
          
      46   ILImageCodec::ILImageCodec(  const String &type,   unsigned int ilType ):
           mType(  type ),  
           mIlType(  ilType )
           {
           initialiseIL(   );
           }
          
           //---------------------------------------------------------------------
      54   DataStreamPtr ILImageCodec::code(  MemoryDataStreamPtr& input,   Codec::CodecDataPtr& pData ) const
           {
          
           OGRE_EXCEPT(  Exception::ERR_NOT_IMPLEMENTED,   "code to memory not implemented",  
           "ILCodec::code" );
          
          
           }
           //---------------------------------------------------------------------
      63   void ILImageCodec::codeToFile(  MemoryDataStreamPtr& input,  
      64   const String& outFileName,   Codec::CodecDataPtr& pData ) const
           {
          
           ILuint ImageName;
          
           ilGenImages(   1,   &ImageName  );
           ilBindImage(   ImageName  );
          
           ImageData* pImgData = static_cast< ImageData * >(   pData.getPointer(   )  );
           PixelBox src(  pImgData->width,   pImgData->height,   pImgData->depth,   pImgData->format,   input->getPtr(   ) );
          
           // Convert image from OGRE to current IL image
           ILUtil::fromOgre(  src );
          
           iluFlipImage(   );
          
           // Implicitly pick DevIL codec
           ilSaveImage(  const_cast< char * >(   outFileName.c_str(   )  )  );
          
           // Check if everything was ok
           ILenum PossibleError = ilGetError(   ) ;
           if(   PossibleError != IL_NO_ERROR  ) {
           ilDeleteImages(  1,   &ImageName );
           OGRE_EXCEPT(   Exception::ERR_NOT_IMPLEMENTED,  
           "IL Error,   could not save file: " + outFileName,  
           iluErrorString(  PossibleError )  ) ;
           }
          
           ilDeleteImages(  1,   &ImageName );
          
           }
           //---------------------------------------------------------------------
      96   Codec::DecodeResult ILImageCodec::decode(  DataStreamPtr& input ) const
           {
          
           // DevIL variables
           ILuint ImageName;
          
           ILint ImageFormat,   BytesPerPixel,   ImageType;
           ImageData* imgData = new ImageData(   );
           MemoryDataStreamPtr output;
          
           // Load the image
           ilGenImages(   1,   &ImageName  );
           ilBindImage(   ImageName  );
          
           // Put it right side up
           ilEnable(  IL_ORIGIN_SET );
           ilSetInteger(  IL_ORIGIN_MODE,   IL_ORIGIN_UPPER_LEFT );
          
           // Keep DXTC(  compressed ) data if present
           ilSetInteger(  IL_KEEP_DXTC_DATA,   IL_TRUE );
          
           // Load image from stream,   cache into memory
           MemoryDataStream memInput(  input );
           ilLoadL(  
           mIlType,  
           memInput.getPtr(   ),  
           static_cast< ILuint >(  memInput.size(   ) ) );
          
           // Check if everything was ok
           ILenum PossibleError = ilGetError(   ) ;
           if(   PossibleError != IL_NO_ERROR  ) {
           OGRE_EXCEPT(   Exception::ERR_NOT_IMPLEMENTED,  
           "IL Error",  
           iluErrorString(  PossibleError )  ) ;
           }
          
           ImageFormat = ilGetInteger(   IL_IMAGE_FORMAT  );
           ImageType = ilGetInteger(   IL_IMAGE_TYPE  );
          
           // Convert image if ImageType is incompatible with us (  double or long )
           if(  ImageType != IL_BYTE && ImageType != IL_UNSIGNED_BYTE &&
           ImageType != IL_FLOAT &&
           ImageType != IL_UNSIGNED_SHORT && ImageType != IL_SHORT ) {
           ilConvertImage(  ImageFormat,   IL_FLOAT );
           ImageType = IL_FLOAT;
           }
           // Converted paletted images
           if(  ImageFormat == IL_COLOUR_INDEX )
           {
           ilConvertImage(  IL_BGRA,   IL_UNSIGNED_BYTE );
           ImageFormat = IL_BGRA;
           ImageType = IL_UNSIGNED_BYTE;
           }
          
           // Now sets some variables
           BytesPerPixel = ilGetInteger(   IL_IMAGE_BYTES_PER_PIXEL  );
          
           imgData->format = ILUtil::ilFormat2OgreFormat(   ImageFormat,   ImageType  );
           imgData->width = ilGetInteger(   IL_IMAGE_WIDTH  );
           imgData->height = ilGetInteger(   IL_IMAGE_HEIGHT  );
           imgData->depth = ilGetInteger(   IL_IMAGE_DEPTH  );
           imgData->num_mipmaps = ilGetInteger (   IL_NUM_MIPMAPS  );
           imgData->flags = 0;
          
           if(  imgData->format == PF_UNKNOWN )
           {
           std::stringstream err;
           err << "Unsupported devil format ImageFormat=" << std::hex << ImageFormat <<
           " ImageType="<< ImageType << std::dec;
           ilDeleteImages(   1,   &ImageName  );
          
           OGRE_EXCEPT(   Exception::ERR_NOT_IMPLEMENTED,  
           err.str(   ),  
           "ILImageCodec::decode"  ) ;
           }
          
           // Check for cubemap
           //ILuint cubeflags = ilGetInteger (   IL_IMAGE_CUBEFLAGS  );
           size_t numFaces = ilGetInteger (   IL_NUM_IMAGES  ) + 1;
           if(  numFaces == 6 )
           imgData->flags |= IF_CUBEMAP;
           else
           numFaces = 1; // Support only 1 or 6 face images for now
          
           // Keep DXT data (  if present at all and the GPU supports it )
           ILuint dxtFormat = ilGetInteger(   IL_DXTC_DATA_FORMAT  );
           if(  dxtFormat != IL_DXT_NO_COMP && Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->hasCapability(   RSC_TEXTURE_COMPRESSION_DXT  ) )
           {
           imgData->format = ILUtil::ilFormat2OgreFormat(   dxtFormat,   ImageType  );
           imgData->flags |= IF_COMPRESSED;
          
           // Validate that this devil version saves DXT mipmaps
           if(  imgData->num_mipmaps>0 )
           {
           ilBindImage(  ImageName );
           ilActiveMipmap(  1 );
           if(  (  size_t )ilGetInteger(   IL_DXTC_DATA_FORMAT  ) != dxtFormat )
           {
           imgData->num_mipmaps=0;
           LogManager::getSingleton(   ).logMessage(  
           "Warning: Custom mipmaps for compressed image "+input->getName(   )+" were ignored because they are not loaded by this DevIL version" );
           }
           }
           }
          
           // Calculate total size from number of mipmaps,   faces and size
           imgData->size = Image::calculateSize(  imgData->num_mipmaps,   numFaces,  
           imgData->width,   imgData->height,   imgData->depth,   imgData->format );
          
           // Bind output buffer
           output.bind(  new MemoryDataStream(  imgData->size ) );
           size_t offset = 0;
          
           // Dimensions of current mipmap
           size_t width = imgData->width;
           size_t height = imgData->height;
           size_t depth = imgData->depth;
          
           // Transfer data
           for(  size_t mip=0; mip<=imgData->num_mipmaps; ++mip )
           {
           for(  size_t i = 0; i < numFaces; ++i )
           {
           ilBindImage(  ImageName );
           if(  numFaces > 1 )
           ilActiveImage(  i );
           if(  imgData->num_mipmaps > 0 )
           ilActiveMipmap(  mip );
           /// Size of this face
           size_t imageSize = PixelUtil::getMemorySize(  
           width,   height,   depth,   imgData->format );
           if(  imgData->flags & IF_COMPRESSED )
           {
          
           // Compare DXT size returned by DevIL with our idea of the compressed size
           if(  imageSize == ilGetDXTCData(  NULL,   0,   dxtFormat ) )
           {
           // Retrieve data from DevIL
           ilGetDXTCData(  (  unsigned char* )output->getPtr(   )+offset,   imageSize,   dxtFormat );
           } else
           {
           LogManager::getSingleton(   ).logMessage(  
           "Warning: compressed image "+input->getName(   )+" size mismatch,   devilsize="+StringConverter::toString(  ilGetDXTCData(  NULL,   0,   dxtFormat ) )+" oursize="+
           StringConverter::toString(  imageSize ) );
           }
           }
           else
           {
           /// Retrieve data from DevIL
           PixelBox dst(  width,   height,   depth,   imgData->format,   (  unsigned char* )output->getPtr(   )+offset );
           ILUtil::toOgre(  dst );
           }
           offset += imageSize;
           }
           /// Next mip
           if(  width!=1 ) width /= 2;
           if(  height!=1 ) height /= 2;
           if(  depth!=1 ) depth /= 2;
           }
          
           // Restore IL state
           ilDisable(  IL_ORIGIN_SET );
           ilDisable(  IL_FORMAT_SET );
          
           ilDeleteImages(   1,   &ImageName  );
          
           DecodeResult ret;
           ret.first = output;
           ret.second = CodecDataPtr(  imgData );
          
          
           return ret;
           }
           //---------------------------------------------------------------------
     270   void ILImageCodec::initialiseIL(  void )
           {
           if(   !_is_initialised  )
           {
           ilInit(   );
           ilEnable(   IL_FILE_OVERWRITE  );
           _is_initialised = true;
           }
           }
           //---------------------------------------------------------------------
     280   String ILImageCodec::getType(   ) const
           {
           return mType;
           }
          }

./components/ogre/image/OgreILUtil.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2005 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          #include <OgreStableHeaders.h>
          #include "OgreILUtil.h"
          #include <OgrePixelFormat.h>
          #include <OgreBitwise.h>
          #include <OgreColourValue.h>
          #include <OgreException.h>
          
          #include <IL/il.h>
          #include <IL/ilu.h>
          
          namespace Ogre {
          
           /*************************************************************************
           * IL specific functions
           */
      40   PixelFormat ILUtil::ilFormat2OgreFormat(   int ImageFormat,   int ImageType  )
           {
           PixelFormat fmt = PF_UNKNOWN;
           switch(   ImageFormat  )
           {
           /* Compressed formats -- ignore type */
           case IL_DXT1: fmt = PF_DXT1; break;
           case IL_DXT2: fmt = PF_DXT2; break;
           case IL_DXT3: fmt = PF_DXT3; break;
           case IL_DXT4: fmt = PF_DXT4; break;
           case IL_DXT5: fmt = PF_DXT5; break;
           /* Normal formats */
           case IL_RGB:
           switch(  ImageType )
           {
           case IL_FLOAT: fmt = PF_FLOAT32_RGB; break;
           case IL_UNSIGNED_SHORT:
           case IL_SHORT: fmt = PF_SHORT_RGBA; break;
           default: fmt = PF_BYTE_RGB; break;
           }
           break;
           case IL_BGR:
           switch(  ImageType )
           {
           case IL_FLOAT: fmt = PF_FLOAT32_RGB; break;
           case IL_UNSIGNED_SHORT:
           case IL_SHORT: fmt = PF_SHORT_RGBA; break;
           default: fmt = PF_BYTE_BGR; break;
           }
           break;
           case IL_RGBA:
           switch(  ImageType )
           {
           case IL_FLOAT: fmt = PF_FLOAT32_RGBA; break;
           case IL_UNSIGNED_SHORT:
           case IL_SHORT: fmt = PF_SHORT_RGBA; break;
           default: fmt = PF_BYTE_RGBA; break;
           }
           break;
           case IL_BGRA:
           switch(  ImageType )
           {
           case IL_FLOAT: fmt = PF_FLOAT32_RGBA; break;
           case IL_UNSIGNED_SHORT:
           case IL_SHORT: fmt = PF_SHORT_RGBA; break;
           default: fmt = PF_BYTE_BGRA; break;
           }
           break;
           case IL_LUMINANCE:
           switch(  ImageType )
           {
           case IL_BYTE:
           case IL_UNSIGNED_BYTE:
           fmt = PF_L8;
           break;
           default:
           fmt = PF_L16;
           }
           break;
           case IL_LUMINANCE_ALPHA:
           fmt = PF_BYTE_LA;
           break;
           }
           return fmt;
           }
          
           //-----------------------------------------------------------------------
          
     108   ILUtil::ILFormat ILUtil::OgreFormat2ilFormat(   PixelFormat format  )
           {
           switch(  format ) {
           case PF_BYTE_L: return ILFormat(  1,   IL_LUMINANCE,   IL_UNSIGNED_BYTE );
           case PF_BYTE_A: return ILFormat(  1,   IL_LUMINANCE,   IL_UNSIGNED_BYTE );
           case PF_SHORT_L: return ILFormat(  1,   IL_LUMINANCE,   IL_UNSIGNED_SHORT );
           case PF_BYTE_LA: return ILFormat(  2,   IL_LUMINANCE_ALPHA,   IL_UNSIGNED_BYTE );
           case PF_BYTE_RGB: return ILFormat(  3,   IL_RGB,   IL_UNSIGNED_BYTE );
           case PF_BYTE_RGBA: return ILFormat(  4,   IL_RGBA,   IL_UNSIGNED_BYTE );
           case PF_BYTE_BGR: return ILFormat(  3,   IL_BGR,   IL_UNSIGNED_BYTE );
           case PF_BYTE_BGRA: return ILFormat(  4,   IL_BGRA,   IL_UNSIGNED_BYTE );
           case PF_SHORT_RGBA: return ILFormat(  4,   IL_RGBA,   IL_UNSIGNED_SHORT );
           case PF_FLOAT32_RGB: return ILFormat(  3,   IL_RGB,   IL_FLOAT );
           case PF_FLOAT32_RGBA: return ILFormat(  4,   IL_RGBA,   IL_FLOAT );
           case PF_DXT1: return ILFormat(  0,   IL_DXT1 );
           case PF_DXT2: return ILFormat(  0,   IL_DXT2 );
           case PF_DXT3: return ILFormat(  0,   IL_DXT3 );
           case PF_DXT4: return ILFormat(  0,   IL_DXT4 );
           case PF_DXT5: return ILFormat(  0,   IL_DXT5 );
           default: return ILFormat(   );
           }
           }
          
           //-----------------------------------------------------------------------
           /// Helper functions for DevIL to Ogre conversion
     133   inline void packI(  uint8 r,   uint8 g,   uint8 b,   uint8 a,   PixelFormat pf,   void* dest )
           {
           PixelUtil::packColour(  r,   g,   b,   a,   pf,   dest );
           }
     137   inline void packI(  uint16 r,   uint16 g,   uint16 b,   uint16 a,   PixelFormat pf,   void* dest )
           {
           PixelUtil::packColour(  (  float )r/65535.0f,   (  float )g/65535.0f,  
           (  float )b/65535.0f,   (  float )a/65535.0f,   pf,   dest );
           }
     142   inline void packI(  float r,   float g,   float b,   float a,   PixelFormat pf,   void* dest )
           {
           PixelUtil::packColour(  r,   g,   b,   a,   pf,   dest );
           }
     146   template <typename T> void ilToOgreInternal(  uint8 *tar,   PixelFormat ogrefmt,  
           T r,   T g,   T b,   T a )
           {
           const int ilfmt = ilGetInteger(   IL_IMAGE_FORMAT  );
           T *src = (  T* )ilGetData(   );
           T *srcend = (  T* )(  (  uint8* )ilGetData(   ) + ilGetInteger(   IL_IMAGE_SIZE_OF_DATA  ) );
           const size_t elemSize = PixelUtil::getNumElemBytes(  ogrefmt );
           while(  src < srcend ) {
           switch(  ilfmt ) {
           case IL_RGB:
           r = src[0]; g = src[1]; b = src[2];
           src += 3;
           break;
           case IL_BGR:
           b = src[0]; g = src[1]; r = src[2];
           src += 3;
           break;
           case IL_LUMINANCE:
           r = src[0]; g = src[0]; b = src[0];
           src += 1;
           break;
           case IL_LUMINANCE_ALPHA:
           r = src[0]; g = src[0]; b = src[0]; a = src[1];
           src += 2;
           break;
           case IL_RGBA:
           r = src[0]; g = src[1]; b = src[2]; a = src[3];
           src += 4;
           break;
           case IL_BGRA:
           b = src[0]; g = src[1]; r = src[2]; a = src[3];
           src += 4;
           break;
           default:
           return;
           }
           packI(  r,   g,   b,   a,   ogrefmt,   tar );
           tar += elemSize;
           }
          
           }
           //-----------------------------------------------------------------------
           /// Utility function to convert IL data types to UNSIGNED_
     189   ILenum ILabs(  ILenum in ) {
           switch(  in ) {
           case IL_INT: return IL_UNSIGNED_INT;
           case IL_BYTE: return IL_UNSIGNED_BYTE;
           case IL_SHORT: return IL_UNSIGNED_SHORT;
           default: return in;
           }
           }
           //-----------------------------------------------------------------------
     198   void ILUtil::toOgre(  const PixelBox &dst )
           {
           if(  !dst.isConsecutive(   ) )
           OGRE_EXCEPT(   Exception::ERR_NOT_IMPLEMENTED,  
           "Destination must currently be consecutive",  
           "ILUtil::ilToOgre"  ) ;
           if(  dst.getWidth(   ) != static_cast<size_t>(  ilGetInteger(   IL_IMAGE_WIDTH  ) ) ||
           dst.getHeight(   ) != static_cast<size_t>(  ilGetInteger(   IL_IMAGE_HEIGHT  ) ) ||
           dst.getDepth(   ) != static_cast<size_t>(  ilGetInteger(   IL_IMAGE_DEPTH  ) ) )
           OGRE_EXCEPT(   Exception::ERR_INVALIDPARAMS,  
           "Destination dimensions must equal IL dimension",  
           "ILUtil::ilToOgre"  ) ;
          
           int ilfmt = ilGetInteger(   IL_IMAGE_FORMAT  );
           int iltp = ilGetInteger(   IL_IMAGE_TYPE  );
          
           // Check if in-memory format just matches
           // If yes,   we can just copy it and save conversion
           ILFormat ifmt = OgreFormat2ilFormat(   dst.format  );
           if(  ifmt.format == ilfmt && ILabs(  ifmt.type ) == ILabs(  iltp ) ) {
           memcpy(  dst.data,   ilGetData(   ),   ilGetInteger(   IL_IMAGE_SIZE_OF_DATA  ) );
           return;
           }
           // Try if buffer is in a known OGRE format so we can use OGRE its
           // conversion routines
           PixelFormat bufFmt = ilFormat2OgreFormat(  (  int )ilfmt,   (  int )iltp );
          
           ifmt = OgreFormat2ilFormat(   bufFmt  );
           if(  ifmt.format == ilfmt && ILabs(  ifmt.type ) == ILabs(  iltp ) )
           {
           // IL format matches another OGRE format
           PixelBox src(  dst.getWidth(   ),   dst.getHeight(   ),   dst.getDepth(   ),   bufFmt,   ilGetData(   ) );
           PixelUtil::bulkPixelConversion(  src,   dst );
           return;
           }
          
           // Thee extremely slow method
           if(  iltp == IL_UNSIGNED_BYTE || iltp == IL_BYTE )
           {
           ilToOgreInternal(  static_cast<uint8*>(  dst.data ),   dst.format,   (  uint8 )0x00,  (  uint8 )0x00,  (  uint8 )0x00,  (  uint8 )0xFF );
           }
           else if(  iltp == IL_FLOAT )
           {
           ilToOgreInternal(  static_cast<uint8*>(  dst.data ),   dst.format,   0.0f,  0.0f,  0.0f,  1.0f );
           }
           else if(  iltp == IL_SHORT || iltp == IL_UNSIGNED_SHORT )
           {
           ilToOgreInternal(  static_cast<uint8*>(  dst.data ),   dst.format,  
           (  uint16 )0x0000,  (  uint16 )0x0000,  (  uint16 )0x0000,  (  uint16 )0xFFFF );
           }
           else
           {
           OGRE_EXCEPT(   Exception::ERR_NOT_IMPLEMENTED,  
           "Cannot convert this DevIL type",  
           "ILUtil::ilToOgre"  ) ;
           }
           }
           //-----------------------------------------------------------------------
     256   void ILUtil::fromOgre(  const PixelBox &src )
           {
           // ilTexImage http://openil.sourceforge.net/docs/il/f00059.htm
           ILFormat ifmt = OgreFormat2ilFormat(   src.format  );
           if(  src.isConsecutive(   ) && ifmt.isValid(   ) )
           {
           // The easy case,   the buffer is laid out in memory just like
           // we want it to be and is in a format DevIL can understand directly
           // We could even save the copy if DevIL would let us
           ilTexImage(  static_cast<ILuint>(  src.getWidth(   ) ),  
           static_cast<ILuint>(  src.getHeight(   ) ),  
           static_cast<ILuint>(  src.getDepth(   ) ),   ifmt.numberOfChannels,  
           ifmt.format,   ifmt.type,   src.data );
           }
           else if(  ifmt.isValid(   ) )
           {
           // The format can be understood directly by DevIL. The only
           // problem is that ilTexImage expects our image data consecutively
           // so we cannot use that directly.
          
           // Let DevIL allocate the memory for us,   and copy the data consecutively
           // to its memory
           ilTexImage(  static_cast<ILuint>(  src.getWidth(   ) ),  
           static_cast<ILuint>(  src.getHeight(   ) ),  
           static_cast<ILuint>(  src.getDepth(   ) ),   ifmt.numberOfChannels,  
           ifmt.format,   ifmt.type,   0 );
           PixelBox dst(  src.getWidth(   ),   src.getHeight(   ),   src.getDepth(   ),   src.format,   ilGetData(   ) );
           PixelUtil::bulkPixelConversion(  src,   dst );
           }
           else
           {
           // Here it gets ugly. We're stuck with a pixel format that DevIL
           // can't do anything with. We will do a bulk pixel conversion and
           // then feed it to DevIL anyway. The problem is finding the best
           // format to convert to.
          
           // most general format supported by OGRE and DevIL
           PixelFormat fmt = PixelUtil::hasAlpha(  src.format )?PF_FLOAT32_RGBA:PF_FLOAT32_RGB;
          
           // Make up a pixel format
           // We don't have to consider luminance formats as they have
           // straight conversions to DevIL,   just weird permutations of RGBA an LA
           int depths[4];
           PixelUtil::getBitDepths(  src.format,   depths );
          
           // Native endian format with all bit depths<8 can safely and quickly be
           // converted to 24/32 bit
           if(  PixelUtil::isNativeEndian(  src.format ) &&
           depths[0]<=8 && depths[1]<=8 && depths[2]<=8 && depths[3]<=8 ) {
           if(  PixelUtil::hasAlpha(  src.format ) ) {
           fmt = PF_A8R8G8B8;
           } else {
           fmt = PF_R8G8B8;
           }
           }
          
           // Let DevIL allocate the memory for us,   then do the conversion ourselves
           ifmt = OgreFormat2ilFormat(   fmt  );
           ilTexImage(  static_cast<ILuint>(  src.getWidth(   ) ),  
           static_cast<ILuint>(  src.getHeight(   ) ),  
           static_cast<ILuint>(  src.getDepth(   ) ),   ifmt.numberOfChannels,  
           ifmt.format,   ifmt.type,   0 );
           PixelBox dst(  src.getWidth(   ),   src.getHeight(   ),   src.getDepth(   ),   fmt,   ilGetData(   ) );
           PixelUtil::bulkPixelConversion(  src,   dst );
           }
           }
          
          }

./components/ogre/image/OgreILUtil.h

          /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
           (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2005 The OGRE Team
          Also see acknowledgements in Readme.html
          
          This program is free software; you can redistribute it and/or modify it under
          the terms of the GNU General Public License as published by the Free Software
          Foundation; either version 2 of the License,   or (  at your option ) any later
          version.
          
          This program is distributed in the hope that it will be useful,   but WITHOUT
          ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
          FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
          
          You should have received a copy of the GNU General Public License along with
          this program; if not,   write to the Free Software Foundation,   Inc.,   59 Temple
          Place - Suite 330,   Boston,   MA 02111-1307,   USA,   or go to
          http://www.gnu.org/copyleft/lesser.txt.
          -----------------------------------------------------------------------------
          */
          #ifndef _Ogre_ILUtil_H__
          #define _Ogre_ILUtil_H__
          
          #include <OgrePrerequisites.h>
          #include <OgreCommon.h>
          #include <OgrePixelFormat.h>
          
          namespace Ogre {
          
           /*
           * DevIL specific utility class
           **/
           class _OgrePrivate ILUtil {
           public:
           /// Structure that encapsulates a devIL image format definition
           struct ILFormat {
           /// Construct an invalidated ILFormat structure
           ILFormat(   ):
           numberOfChannels(  0 ),   format(  -1 ),   type(  -1 ) {};
          
           /// Construct a ILFormat from parameters
           ILFormat(  int channels,   int format,   int type=-1 ):
           numberOfChannels(  channels ),   format(  format ),   type(  type ) {}
          
           /// Return wether this structure represents a valid DevIL format
           bool isValid(   ) { return format!=-1; }
          
           /// Number of channels,   usually 3 or 4
           int numberOfChannels;
           /// IL_RGBA,  IL_BGRA,  IL_DXTx,   ...
           int format;
           /// IL_UNSIGNED_BYTE,   IL_UNSIGNED_SHORT,   ... may be -1 for compressed formats
           int type;
           };
          
           /** Get OGRE format to which a given IL format can be most optimally converted.
           */
      62   static PixelFormat ilFormat2OgreFormat(   int ImageFormat,   int ImageType  );
           /** Get IL format that matches a given OGRE format exactly in memory.
           @remarks Returns an invalid ILFormat (  .isValid(   )==false ) when
           there is no IL format that matches this.
           */
      67   static ILFormat OgreFormat2ilFormat(   PixelFormat format  );
           /** Convert current IL image to an OGRE format. The size of the target will be
           PixelUtil::getNumElemBytes(  fmt ) * ilGetInteger(   IL_IMAGE_WIDTH  ) * ilGetInteger(   IL_IMAGE_HEIGHT  ) * ilGetInteger(   IL_IMAGE_DEPTH  )
           The IL image type must be IL(  _UNSIGNED_ )BYTE or IL_FLOAT.
           The IL image format must be IL_RGBA,   IL_BGRA,   IL_RGB,   IL_BGR,   IL_LUMINANCE or IL_LUMINANCE_ALPHA
          
           @param tar Target pointer
           @param ogrefmt Ogre pixel format to employ
           */
      76   static void toOgre(  const PixelBox &dst );
          
           /** Convert an OGRE format image to current IL image.
           @param src Pixelbox; encapsulates source pointer,   width,   height,  
           depth and format
           */
      82   static void fromOgre(  const PixelBox &src );
           };
          
          }
          
          #endif

./components/ogre/input/IInputAdapter.h

       1  //
          // C++ Interface: IInputAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREIINPUTADAPTOR_H
          #define EMBEROGREIINPUTADAPTOR_H
          
          #include "Input.h"
          
          #include <SDL.h>
          
          
          namespace EmberOgre {
          
          
          /**
          @author Erik Hjortsberg
          */
      37  class IInputAdapter
          {
          public:
          
      41   virtual ~IInputAdapter(   ) {}
           /**
           * Injects a mouse move. Returns false if the event shouldn't be processed any more.
           * @param x
           * @param y
           * @return true if other IInputAdapters should continue handle the event,   false if no more handling should happen
           */
      48   virtual bool injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse ) = 0;
           /**
           * Injects a mouse button up event. Returns false if the event shouldn't be processed any more.
           * @param button
           * @return true if other IInputAdapters should continue handle the event,   false if no more handling should happen
           */
      54   virtual bool injectMouseButtonUp(  const Input::MouseButton& button ) = 0;
           /**
           * Injects a mouse button down event. Returns false if the event shouldn't be processed any more.
           * @param button
           * @return true if other IInputAdapters should continue handle the event,   false if no more handling should happen
           */
      60   virtual bool injectMouseButtonDown(  const Input::MouseButton& button ) = 0;
           /**
           * Injects a character. Returns false if the event shouldn't be processed any more.
           * @param character
           * @return true if other IInputAdapters should continue handle the event,   false if no more handling should happen
           */
      66   virtual bool injectChar(  char character ) = 0;
           /**
           * Injects a key down event. Returns false if the event shouldn't be processed any more.
           * @param key
           * @return true if other IInputAdapters should continue handle the event,   false if no more handling should happen
           */
      72   virtual bool injectKeyDown(  const SDLKey& key ) = 0;
           /**
           * Injects a key up event. Returns false if the event shouldn't be processed any more.
           * @param key
           * @return true if other IInputAdapters should continue handle the event,   false if no more handling should happen
           */
      78   virtual bool injectKeyUp(  const SDLKey& key ) = 0;
          };
          
          }
          
          #endif

./components/ogre/input/Input.cpp

       1  //
          // C++ Implementation: Input
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Input.h"
          // #include "../EmberOgre.h"
          #include "InputCommandMapper.h"
          
          #include "main/Application.h"
          #include "framework/scrap.h"
          #include "IInputAdapter.h"
          
          #include "framework/Tokeniser.h"
          #include "framework/ConsoleBackend.h"
          #include "services/logging/LoggingService.h"
          
          template<> EmberOgre::Input* Ember::Singleton<EmberOgre::Input>::ms_Singleton = 0;
          
          namespace EmberOgre {
          
      39  const std::string Input::BINDCOMMAND(  "bind" );
      40  const std::string Input::UNBINDCOMMAND(  "unbind" );
          
          
      43  Input::Input(   )
          :
          mCurrentInputMode(  IM_GUI )
          ,   mMouseState(  0 )
          ,   mTimeSinceLastRightMouseClick(  1000 )
          ,   mSuppressForCurrentEvent(  false )
          ,   mMovementModeEnabled(  false )
          {
          
          
           //we don't want to send a injectChar to the gui for some keys,   put them here
           mNonCharKeys.insert(  SDLK_ESCAPE );
           mNonCharKeys.insert(  SDLK_F1 );
           mNonCharKeys.insert(  SDLK_F2 );
           mNonCharKeys.insert(  SDLK_F3 );
           mNonCharKeys.insert(  SDLK_F4 );
           mNonCharKeys.insert(  SDLK_F5 );
           mNonCharKeys.insert(  SDLK_F6 );
           mNonCharKeys.insert(  SDLK_F7 );
           mNonCharKeys.insert(  SDLK_F8 );
           mNonCharKeys.insert(  SDLK_F9 );
           mNonCharKeys.insert(  SDLK_F10 );
           mNonCharKeys.insert(  SDLK_F11 );
           mNonCharKeys.insert(  SDLK_F12 );
           mNonCharKeys.insert(  SDLK_BACKSPACE );
           mNonCharKeys.insert(  SDLK_TAB );
           mNonCharKeys.insert(  SDLK_RETURN );
           mNonCharKeys.insert(  SDLK_DELETE );
          
          
           mLastTick = SDL_GetTicks(   );
          
          }
          
          
      78  Input::~Input(   )
          {
          
          }
          
      83  void Input::initialize(  int width,   int height )
          {
           SDL_ShowCursor(  0 );
           SDL_EnableUNICODE(  1 );
           SDL_EnableKeyRepeat(  SDL_DEFAULT_REPEAT_DELAY,   SDL_DEFAULT_REPEAT_INTERVAL );
          
           ///must initialize the clipboard support
           if (   init_scrap(   ) < 0  ) {
           S_LOG_FAILURE(  "Couldn't init clipboard: \n" << SDL_GetError(   ) );
           }
          
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  BINDCOMMAND,  this );
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  UNBINDCOMMAND,  this );
          
           setGeometry(  width,   height );
          
          }
          
     101  void Input::setGeometry(  int width,   int height )
          {
           mScreenWidth = width;
           mScreenHeight = height;
          }
          
     107  void Input::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  command == BINDCOMMAND )
           {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string state(  "general" );
           std::string key = tokeniser.nextToken(   );
           if (  key != "" ) {
           std::string command = tokeniser.nextToken(   );
           if (  command != "" ) {
           if (  tokeniser.nextToken(   ) != "" ) {
           state = tokeniser.nextToken(   );
           }
           InputCommandMapperStore::iterator I = mInputCommandMappers.find(  state );
           if (  I != mInputCommandMappers.end(   ) ) {
           I->second->bindCommand(  key,   command );
           }
           }
           }
           } else if (  command == UNBINDCOMMAND ) {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string state(  "general" );
           std::string key = tokeniser.nextToken(   );
           if (  key != "" ) {
           if (  tokeniser.nextToken(   ) != "" ) {
           state = tokeniser.nextToken(   );
           }
           InputCommandMapperStore::iterator I = mInputCommandMappers.find(  state );
           if (  I != mInputCommandMappers.end(   ) ) {
           I->second->unbindCommand(  key );
           }
           }
           }
          }
          
     144  void Input::suppressFurtherHandlingOfCurrentEvent(   )
          {
           mSuppressForCurrentEvent = true;
          }
          
     149  bool Input::getMovementModeEnabled(   ) const
          {
           return mMovementModeEnabled;
          }
          
     154  void Input::setMovementModeEnabled(  bool value )
          {
           mMovementModeEnabled = value;
          }
          
     159  void Input::writeToClipboard(  const std::string& text )
          {
           char basicString[text.length(   ) + 1];
           strcpy (  basicString,  text.c_str(   ) );
           put_scrap(  T(  'T',  'E',  'X',  'T' ),   text.length(   ),   basicString );
          }
          
          
          
     168  void Input::registerCommandMapper(  InputCommandMapper* mapper )
          {
           mInputCommandMappers[mapper->getState(   )] = mapper;
          }
          
     173  void Input::deregisterCommandMapper(  InputCommandMapper* mapper )
          {
           mInputCommandMappers.erase(  mInputCommandMappers.find(  mapper->getState(   ) ) );
          }
          
          
     179  bool Input::isApplicationVisible(   )
          {
           return SDL_GetAppState(   ) & SDL_APPACTIVE;
          }
          
     184  void Input::processInput(   )
          {
           uint32_t ticks = SDL_GetTicks(   );
           float secondsSinceLast = (  ticks - mLastTick ) * 1000.0f;
           mLastTick = ticks;
           pollMouse(  secondsSinceLast );
           pollEvents(  secondsSinceLast );
           SDL_PumpEvents(   );
          }
          
          
          
     196  void Input::pollMouse(  float secondsSinceLast )
          {
           int mouseX,   mouseY;
           unsigned int mouseState;
          
           mouseState = SDL_GetMouseState(   &mouseX,   &mouseY  );
          
           mTimeSinceLastRightMouseClick += secondsSinceLast;
          
          
           if (  mouseState & SDL_BUTTON_RMASK ) {
           if (  !(  mMouseState & SDL_BUTTON_RMASK ) ) {
           //right mouse button pressed
          
           //if the right mouse button is pressed,   switch from gui mode
          
           if (  mMovementModeEnabled ) {
           toggleInputMode(   );
           }
           EventMouseButtonPressed.emit(  MouseButtonRight,   mCurrentInputMode );
          
           }
           } else if (  mMouseState & SDL_BUTTON_RMASK ) {
           //right mouse button released
          
           //if there's two right mouse clicks withing 0.25 seconds from each others,   it's a double click
          /* if (  mTimeSinceLastRightMouseClick < 0.25 ) {
           toggleInputMode(   );
          
           }*/
           mTimeSinceLastRightMouseClick = 0;
           //toggleInputMode(   );
           EventMouseButtonReleased.emit(  MouseButtonRight,   mCurrentInputMode );
           }
          
          
          
          
           if (  mouseState & SDL_BUTTON_LMASK ) {
           if (  !(  mMouseState & SDL_BUTTON_LMASK ) ) {
           //left mouse button pressed
          
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ); ++I ) {
           if (  *I ) {
           if (  !(  *I )->injectMouseButtonDown(  Input::MouseButtonLeft ) ) break;
           }
           }
          
          
           EventMouseButtonPressed.emit(  MouseButtonLeft,   mCurrentInputMode );
           }
           } else if (  mMouseState & SDL_BUTTON_LMASK ) {
           //left mouse button released
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ); ++I ) {
           if (  !(  *I )->injectMouseButtonUp(  Input::MouseButtonLeft ) ) break;
           }
          
           EventMouseButtonReleased.emit(  MouseButtonLeft,   mCurrentInputMode );
          
           }
          
           if (  mouseState & SDL_BUTTON_MMASK ) {
           if (  !(  mMouseState & SDL_BUTTON_MMASK ) ) {
           //middle mouse button pressed
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ); ++I ) {
           if (  !(  *I )->injectMouseButtonDown(  Input::MouseButtonMiddle ) ) break;
           }
          
           EventMouseButtonPressed.emit(  MouseButtonMiddle,   mCurrentInputMode );
           }
           } else if (  mMouseState & SDL_BUTTON_MMASK ) {
           //middle mouse button released
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ); ++I ) {
           if (  !(  *I )->injectMouseButtonUp(  Input::MouseButtonMiddle ) ) break;
           }
          
           EventMouseButtonReleased.emit(  MouseButtonMiddle,   mCurrentInputMode );
           }
          
           mMouseState = mouseState;
          
          
          
           //has the mouse moved?
           Uint8 appState = SDL_GetAppState(   );
          // S_LOG_INFO(  (  appState & SDL_APPMOUSEFOCUS ) );
           if (  appState & SDL_APPMOUSEFOCUS ) {
           if (  mMouseX != mouseX || mMouseY != mouseY )
           {
          
           //we'll calculate the mouse movement difference and send the values to those
           //listening to the MouseMoved event
           float diffX,   diffY;
           diffX = (  mMouseX - mouseX ) / mScreenWidth;
           diffY = (  mMouseY - mouseY ) / mScreenHeight;
           MouseMotion motion;
           motion.xPosition = mouseX;
           motion.yPosition = mouseY;
           motion.xRelativeMovement = diffX;
           motion.yRelativeMovement = diffY;
           motion.xRelativeMovementInPixels = mMouseX - mouseX;
           motion.yRelativeMovementInPixels = mMouseY - mouseY;
           motion.timeSinceLastMovement = secondsSinceLast;
          
           EventMouseMoved.emit(  motion,   mCurrentInputMode );
          
           bool freezeMouse = false;
           //if we're in gui mode,   we'll just send the mouse movement on to CEGUI
           if (  mCurrentInputMode == IM_GUI ) {
          
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ); ++I ) {
           if (  !(  *I )->injectMouseMove(  motion,   freezeMouse ) ) break;
           }
          
          
           } else {
           freezeMouse = true;
           }
          
          
           if (  freezeMouse ) {
           SDL_WarpMouse(  mMouseX,   mMouseY );
           } else {
           mMouseX = mouseX;
           mMouseY = mouseY;
           }
          
           }
           }
          
          }
          
          
          
     330  void Input::pollEvents(  float secondsSinceLast )
          {
          #if __WIN32__
           //on windows,   we need to let the os have some time to do input gathering
           SDL_Delay(  1 );
          #endif
           SDL_Event event;
           while(   SDL_PollEvent(   &event  )  ){
           switch(   event.type  ){
           /* Look for a keypress */
           case SDL_KEYDOWN:
           case SDL_KEYUP:
           keyChanged(  event.key );
           break;
           case SDL_QUIT:
           Ember::Application::getSingleton(   ).requestQuit(   );
           break;
           case SDL_MOUSEBUTTONDOWN:
           if(  event.button.button == SDL_BUTTON_WHEELUP ) {
           EventMouseButtonPressed.emit(  MouseWheelUp,   mCurrentInputMode );
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ); ++I ) {
           if (  *I ) {
           if (  !(  *I )->injectMouseButtonDown(  Input::MouseWheelUp ) ) break;
           }
           }
           }
           else if(  event.button.button == SDL_BUTTON_WHEELDOWN ) {
           EventMouseButtonPressed.emit(  MouseWheelDown,   mCurrentInputMode );
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ); ++I ) {
           if (  *I ) {
           if (  !(  *I )->injectMouseButtonDown(  Input::MouseWheelDown ) ) break;
           }
           }
           }
           break;
           case SDL_ACTIVEEVENT:
           if (  event.active.state & SDL_APPACTIVE ) {
           EventWindowActive.emit(  event.active.gain );
           }
           break;
           }
           }
          }
          
     374  void Input::pasteFromClipboard(   )
          {
           static char *scrap = 0;
           int scraplen;
          
           get_scrap(  T(  'T',  'E',  'X',  'T' ),   &scraplen,   &scrap );
           for (  int i = 0; i < scraplen; ++i ) {
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ); ++I ) {
           if (  !(  *I )->injectChar(  scrap[i] ) ) break;
           }
           }
          }
          
     387  void Input::keyChanged(  const SDL_KeyboardEvent &keyEvent )
          {
           //catch paste key presses
          
           //check for paste actions
           if (  (  keyEvent.keysym.mod & KMOD_CTRL || keyEvent.keysym.mod & KMOD_LCTRL || keyEvent.keysym.mod & KMOD_RCTRL ) && keyEvent.keysym.sym == SDLK_v ) {
           if (  keyEvent.type == SDL_KEYDOWN ) {
           pasteFromClipboard(   );
           }
           } else {
           if (  keyEvent.type == SDL_KEYDOWN ) {
           mKeysPressed.insert(  keyEvent.keysym.sym );
           keyPressed(  keyEvent );
           } else {
           mKeysPressed.erase(  keyEvent.keysym.sym );
           keyReleased(  keyEvent );
           }
           }
          
          }
          
     408  const bool Input::isKeyDown(  const SDLKey &key ) const
          {
           return mKeysPressed.find(  key ) != mKeysPressed.end(   );
          }
          
     413  void Input::keyPressed (  const SDL_KeyboardEvent &keyEvent )
          {
           mSuppressForCurrentEvent = false;
           if (  mCurrentInputMode == IM_GUI ) {
           // do event injection
           // key down
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ) && !mSuppressForCurrentEvent; ++I ) {
           if (  !(  *I )->injectKeyDown(  keyEvent.keysym.sym ) ) break;
           }
          
          
           // now character
           if (  mNonCharKeys.find(  keyEvent.keysym.sym ) == mNonCharKeys.end(   ) ) {
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ) && !mSuppressForCurrentEvent; ++I ) {
           if (  !(  *I )->injectChar(  keyEvent.keysym.unicode ) ) break;
           }
           }
           }
           if (  !mSuppressForCurrentEvent ) {
           EventKeyPressed(  keyEvent.keysym,   mCurrentInputMode );
           }
           mSuppressForCurrentEvent = false;
          
          }
          
          
          
          
     441  void Input::keyReleased (  const SDL_KeyboardEvent &keyEvent )
          {
           mSuppressForCurrentEvent = false;
           if (  mCurrentInputMode == IM_GUI ) {
           for (  IInputAdapterStore::reverse_iterator I = mAdapters.rbegin(   ); I != mAdapters.rend(   ) && !mSuppressForCurrentEvent; ++I ) {
           if (  !(  *I )->injectKeyUp(  keyEvent.keysym.sym ) ) break;
           }
           }
           if (  !mSuppressForCurrentEvent ) {
           EventKeyReleased(  keyEvent.keysym,   mCurrentInputMode );
           }
           mSuppressForCurrentEvent = false;
          }
          
          
     456  void Input::setInputMode(  InputMode mode )
          {
           mCurrentInputMode = mode;
           EventChangedInputMode.emit(  mode );
          }
          
     462  Input::InputMode Input::getInputMode(   ) const
          {
           return mCurrentInputMode;
          }
          
          
     468  Input::InputMode Input::toggleInputMode(   )
          {
           if (  mCurrentInputMode == IM_GUI )
           {
           setInputMode(  IM_MOVEMENT );
           return IM_MOVEMENT;
           } else {
           setInputMode(  IM_GUI );
           return IM_GUI;
           }
          
          }
          
     481  void Input::addAdapter(  IInputAdapter* adapter )
          {
           mAdapters.push_back(  adapter );
          }
          
          
     487  void Input::removeAdapter(  IInputAdapter* adapter )
          {
           for(  IInputAdapterStore::iterator I = mAdapters.begin(   ); I != mAdapters.end(   ); ++I ) {
           if (  *I == adapter ) {
           mAdapters.erase(  I );
           return;
           }
           }
          }
          
          };

./components/ogre/input/Input.h

       1  //
          // C++ Interface: Input
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREINPUT_H
          #define EMBEROGREINPUT_H
          
          // #include "../EmberOgrePrerequisites.h"
          #include <sigc++/slot.h>
          #include <sigc++/signal.h>
          #include <SDL_events.h>
          #include "framework/ConsoleObject.h"
          #include "framework/Singleton.h"
          
          #include <set>
          #include <list>
          #include <map>
          
          namespace EmberOgre {
          
      39  class IInputAdapter;
      40  class InputCommandMapper;
          
          typedef std::set<SDLKey> KeysSet;
          typedef std::list<IInputAdapter*> IInputAdapterStore;
          
          
          
          /**
          struct for a mouse movement
          */
          struct MouseMotion
          {
           /**
           the position of the mouse
           */
           int xPosition;
           int yPosition;
           /**
           the relative movement measures as percentage of the total with of the window
           */
           float xRelativeMovement;
           float yRelativeMovement;
          
           /**
           the relative movement in pixels
           */
           int xRelativeMovementInPixels;
           int yRelativeMovementInPixels;
           float timeSinceLastMovement;
          };
          
          /**
          @author Erik Hjortsberg
          
          This class takes care of all input and routes it to the correct place in Ember.
          Right now that means that when in GUI mode,   all input will be routed to CEGUI,   and when in non-gui mode (  ie. movement mode ),  
          all input will be routed to Ember.
          
          We use SDL for now. Perhaps in the future we'll add support for other input mechanisms (  such as DirectInput )
          
          Note that while keyboard input is buffered,   mouse input is not.
          */
      82  class Input : public Ember::ConsoleObject,   public Ember::Singleton<Input>
          {
      84  friend class InputCommandMapper;
          
          public:
          
           /**
           Command for binding keys to commands.
           */
      91   static const std::string BINDCOMMAND;
          
           /**
           Command for unbinding keys to commands.
           */
      96   static const std::string UNBINDCOMMAND;
          
          
           enum MouseButton
           {
           MouseButtonLeft,  
           MouseButtonRight,  
           MouseButtonMiddle,  
           MouseWheelUp,  
           MouseWheelDown,  
           };
          
           /**
           Describes different input modes.
           */
           enum InputMode
           {
           /**
           In gui mode,   the mouse will move the cursor and allow interaction with the GUI system
           */
           IM_GUI,  
          
           /**
           In movement mode,   the mouse will move the camera and the keys will move the player. Interaction with the gui is not possible.
           */
           IM_MOVEMENT
           };
          
     124   Input(   );
          
     126   virtual ~Input(   );
          
           /**
           * Initializes the input object. Call this before you want to recieve input.
           * @param width
           * @param heigh
           */
     133   void initialize(  int width,   int height );
          
           /**
           * starts processing all input for a frame
           * @param evt
           */
     139   void processInput(   );
          
     141   bool isApplicationVisible(   );
          
           /**emitted when a key has been pressed in movement mode
           @param the key event
           @param true if ember is in gui mode
           */
     147   sigc::signal<void,   const SDL_keysym&,   Input::InputMode> EventKeyPressed;
          
           /**emitted when a key has been released in movement mode
           @param the key event
           @param true if ember is in gui mode
           */
     153   sigc::signal<void,   const SDL_keysym&,   Input::InputMode> EventKeyReleased;
          
           /**emitted when the mouse has moved
           note that when in non-gui mode,   the x and y position for the mouse will always be the same for consecutive signals
           although the relative position will have changed
           @param the mouse motion
           @param true if ember is in gui mode
           */
     161   sigc::signal<void,   const MouseMotion&,   InputMode> EventMouseMoved;
          
          
           /**
           emitted when a mouse button is pressed
           @param the mouse button
           @param true if ember is in gui mode
           */
     169   sigc::signal<void,   MouseButton,   InputMode> EventMouseButtonPressed;
          
           /**
           emitted when a mouse button is released
           @param the mouse button
           @param true if ember is in gui mode
           */
     176   sigc::signal<void,   MouseButton,   InputMode> EventMouseButtonReleased;
          
           /**
           Emitted when the input mode has been changed.
           @param the new input mode
           */
     182   sigc::signal<void,   InputMode> EventChangedInputMode;
          
           /**
           Emitted when the window is minimized or un-mininized.
           */
     187   sigc::signal<void,   bool> EventWindowActive;
          
           /**
           * returns true if the supplied key is down
           * @param
           * @return
           */
     194   const bool isKeyDown(  const SDLKey& ) const;
          
          
          
           /**
           * Sets the window geometry. Call this whenever the size of the window has changed.
           * @param width
           * @param heigh
           */
     203   void setGeometry(  int width,   int heigh );
          
           /**
           * Sets the new input mode.
           * @param mode
           */
     209   void setInputMode(  InputMode mode );
          
           /**
           * Gets the current input mode.
           * @return
           */
     215   InputMode getInputMode(   ) const;
          
          
           /**
           * Toggles between different input modes,   returning the new mode.
           * @return the new input mode
           */
     222   InputMode toggleInputMode(   );
          
          
           /**
           * Adds an adaptor to which input event will be sent. Note that event will be sent to adapters added later first,   allowing them to decide whether events should be sent to previous added adapters. This allows later added adapters to override current behaviour.
           * @param adaptor
           */
     229   void addAdapter(  IInputAdapter* adapter );
          
          
           /**
           * Removed an adaptor from the list of adaptors.
           * @param adaptor
           */
     236   void removeAdapter(  IInputAdapter* adapter );
          
          
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
     245   virtual void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           Suppress all further event handling of the current event. Call this inside event handling methods to prevent further event handling.
           */
     250   void suppressFurtherHandlingOfCurrentEvent(   );
          
           /**
           Gets whether the movement mode is enabled,   at which all mouse right click events will toggle between movement mode and mouse mode.
           */
     255   bool getMovementModeEnabled(   ) const;
          
           /**
           Sets whether the movement mode is enabled,   at which all mouse right click events will toggle between movement mode and mouse mode.
           */
     260   void setMovementModeEnabled(  bool value );
          
           /**
           * Writes the supplied text to the system clipboard.
           * @param text
           */
     266   void writeToClipboard(  const std::string& text );
          
          protected:
          
           typedef std::map<std::string,   InputCommandMapper*> InputCommandMapperStore;
          
          
           /**
           * Registers a command mapper.
           * @param mapper
           */
     277   void registerCommandMapper(  InputCommandMapper* mapper );
          
           /**
           * Deregisters a command mapper.
           * @param mapper
           */
     283   void deregisterCommandMapper(  InputCommandMapper* mapper );
          
          
           /**
           The current input mode.
           */
           InputMode mCurrentInputMode;
          
           /**
           * polls all input for the mouse
           * @param evt
           */
     295   void pollMouse(  float secondsSinceLast );
     296   void pollEvents(  float secondsSinceLast );
          
     298   void keyChanged(  const SDL_KeyboardEvent &keyEvent );
          
     300   void keyPressed(  const SDL_KeyboardEvent &keyEvent );
     301   void keyReleased(  const SDL_KeyboardEvent &keyEvent );
          
          
           /**
           keys which should not be injected as chars,   ie. enter,   backspace etc.
           */
     307   KeysSet mNonCharKeys;
          
          
           /**
           a set of the keys that are currently pressed
           */
     313   KeysSet mKeysPressed;
          
           /**
           saves the last mouse state
           */
           unsigned int mMouseState;
          
           /**
           the last positions of the mouse
           */
           int mMouseY,   mMouseX;
          
           /**
           the amount of time since the last right mouse click
           used for detecting double clicks
           */
     329   uint32_t mTimeSinceLastRightMouseClick;
          
     331   uint32_t mLastTick;
          
           /**
           * gets the text in the clipboard and pastes it to the gui system
           */
     336   void pasteFromClipboard(   );
          
           /**
           A store of adapters to which input event will be sent.
           */
     341   IInputAdapterStore mAdapters;
          
           /**
           The dimensions of the window.
           */
           float mScreenWidth,   mScreenHeight;
          
          
           /**
           A store of InputCommandMappers with their state as the key.
           */
     352   InputCommandMapperStore mInputCommandMappers;
          
     354   bool mSuppressForCurrentEvent;
          
     356   bool mMovementModeEnabled;
          };
          
          };
          
          #endif

./components/ogre/input/InputCommandMapper.cpp

       1  //
          // C++ Implementation: InputCommandMapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          // Copyright (  C ) 2001 - 2005 Simon Goodall,   University of Southampton
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "InputCommandMapper.h"
          #include "framework/ConsoleBackend.h"
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include "services/logging/LoggingService.h"
          
          namespace EmberOgre {
          
          
      33  InputCommandMapper::InputCommandMapper(  const std::string& state ) : mState(  state ),   mEnabled(  true ),   mInput(  0 )
          {
           initKeyMap(   );
          }
          
      38  InputCommandMapper::InputCommandMapper(  const std::string& state,   const std::string& configSection ) : mState(  state ),   mEnabled(  true ),   mInput(  0 )
          {
           initKeyMap(   );
           readFromConfigSection(  configSection );
          }
          
      44  InputCommandMapper::~InputCommandMapper(   )
          {
           if (  mInput ) {
           mInput->deregisterCommandMapper(  this );
           }
          }
          
      51  void InputCommandMapper::readFromConfigSection(  const std::string& sectionName )
          {
          
           ///get the mappings from the config service
           const Ember::ConfigService::SectionMap& section = Ember::EmberServices::getSingleton(   ).getConfigService(   )->getSection(  sectionName );
          
           for (  Ember::ConfigService::SectionMap::const_iterator I = section.begin(   ); I != section.end(   ); ++I ) {
           bindCommand(  std::string(  I->first ),   std::string(  I->second ) );
           }
          
          }
          
      63  void InputCommandMapper::Input_EventKeyPressed(  const SDL_keysym& key,   Input::InputMode inputMode )
          {
           if (  mEnabled && isActiveForInputMode(  inputMode ) ) {
           ///check if we have any key with a matching command
           const std::string& command = getCommandForKey(  key.sym );
           if (  command != "" ) {
           Ember::ConsoleBackend* myBackend = Ember::ConsoleBackend::getMainConsole(   );
           myBackend->runCommand(  command,   false );
           }
           }
          }
          
          
      76  void InputCommandMapper::Input_EventKeyReleased(  const SDL_keysym& key,   Input::InputMode inputMode )
          {
           if (  mEnabled && isActiveForInputMode(  inputMode ) ) {
           ///check if we have any key with a matching command
           ///only check for commands that start with a "+"
           const std::string& command = getCommandForKey(  key.sym );
           if (  command != "" ) {
           Ember::ConsoleBackend* myBackend = Ember::ConsoleBackend::getMainConsole(   );
           if (  command[0] == '+' ) {
           ///remove the "+" and replace it with "-"
           myBackend->runCommand(  "-" + std::string(  command ).erase(  0,   1 ),   false );
           }
           }
           }
          }
          
      92  void InputCommandMapper::bindToInput(  Input& input )
          {
           input.EventKeyPressed.connect(  sigc::mem_fun(  *this,   &InputCommandMapper::Input_EventKeyPressed ) );
           input.EventKeyReleased.connect(  sigc::mem_fun(  *this,   &InputCommandMapper::Input_EventKeyReleased ) );
           input.registerCommandMapper(  this );
           mInput = &input;
          }
          
     100  bool InputCommandMapper::isActiveForInputMode(  Input::InputMode mode ) const
          {
           ///if there's no restriction,   return true
           if (  mInputModesRestriction.size(   ) == 0 ) {
           return true;
           } else {
           return std::find(  mInputModesRestriction.begin(   ),   mInputModesRestriction.end(   ),   mode ) != mInputModesRestriction.end(   );
           }
          }
          
          
     111  void InputCommandMapper::bindCommand(  const std::string& key,   const std::string& command )
          {
           S_LOG_INFO(  "Binding key " << key << " to command " << command << " for state " << getState(   ) << "." );
           mKeyCommands[key] = command;
          }
          
     117  void InputCommandMapper::unbindCommand(  const std::string& key )
          {
           S_LOG_INFO(  "Unbinding key " << key << " for state " << getState(   ) << "." );
           mKeyCommands.erase(  key );
          }
          
     123  const std::string& InputCommandMapper::getCommandForKey(  SDLKey key )
          {
           KeyMapStore::const_iterator I = mKeymap.find(  key );
           if (  I != mKeymap.end(   ) ) {
           KeyCommandStore::const_iterator J = mKeyCommands.find(  I->second );
           if (  J != mKeyCommands.end(   ) ) {
           return J->second;
           }
           }
           ///if we don't find anything,   return an empty string
           static std::string empty(  "" );
           return empty;
          }
          
          
          // std::string Bindings::getBindingForKeysym(  const SDL_keysym& key ) {
          //
          // std::map<int,   std::string>::const_iterator I = m_keymap.find(  key.sym );
          // if (  I == m_keymap.end(   ) ) return ""; // un-mapped basic keysym
          // const std::string & plainName = I->second;
          // std::string decoratedName = plainName;
          //
          // if (  key.mod & KMOD_SHIFT )
          // decoratedName = "shift_" + decoratedName;
          //
          // if (  key.mod & KMOD_ALT )
          // decoratedName = "alt_" + decoratedName;
          //
          // if (  key.mod & KMOD_CTRL )
          // decoratedName = "ctrl_" + decoratedName;
          //
          // m_bindings->clean(  decoratedName );
          // if (  m_bindings->findItem(  "key_bindings",   decoratedName ) )
          // return m_bindings->getItem(  "key_bindings",   decoratedName );
          //
          // if (  m_bindings->findItem(  "key_bindings",   plainName ) )
          // return m_bindings->getItem(  "key_bindings",   plainName );
          //
          // std::cout << "no binding specified for key " << decoratedName << std::endl;
          // return "";
          // }
          
     165  void InputCommandMapper::initKeyMap(   ) {
           /// Assign keys to textual representation
           mKeymap[SDLK_BACKSPACE] = "backspace";
           mKeymap[SDLK_TAB] = "tab";
           mKeymap[SDLK_CLEAR] = "clear";
           mKeymap[SDLK_RETURN] = "return";
           mKeymap[SDLK_PAUSE] = "pause";
           mKeymap[SDLK_ESCAPE] = "escape";
           mKeymap[SDLK_SPACE] = "space";
           mKeymap[SDLK_EXCLAIM] = "exclaim";
           mKeymap[SDLK_QUOTEDBL] = "dbl_quote";
           mKeymap[SDLK_HASH] = "hash";
           mKeymap[SDLK_DOLLAR] = "dollar";
           mKeymap[SDLK_AMPERSAND] = "ampersand";
           mKeymap[SDLK_QUOTE] = "quote";
           mKeymap[SDLK_LEFTPAREN] = "left_paren";
           mKeymap[SDLK_RIGHTPAREN] = "right_paren";
           mKeymap[SDLK_ASTERISK] = "asterisk";
           mKeymap[SDLK_PLUS] = "plus";
           mKeymap[SDLK_COMMA] = "comma";
           mKeymap[SDLK_MINUS] = "-";
           mKeymap[SDLK_PERIOD] = "period";
           mKeymap[SDLK_SLASH] = "slash";
           mKeymap[SDLK_0] = "0";
           mKeymap[SDLK_1] = "1";
           mKeymap[SDLK_2] = "2";
           mKeymap[SDLK_3] = "3";
           mKeymap[SDLK_4] = "4";
           mKeymap[SDLK_5] = "5";
           mKeymap[SDLK_6] = "6";
           mKeymap[SDLK_7] = "7";
           mKeymap[SDLK_8] = "8";
           mKeymap[SDLK_9] = "9";
           mKeymap[SDLK_COLON] = "colon";
           mKeymap[SDLK_SEMICOLON] = "semi_colon";
           mKeymap[SDLK_LESS] = "less_than";
           mKeymap[SDLK_EQUALS] = "equals";
           mKeymap[SDLK_GREATER] = "greater_then";
           mKeymap[SDLK_QUESTION] = "question";
           mKeymap[SDLK_AT] = "at";
           mKeymap[SDLK_LEFTBRACKET] = "left_brace";
           mKeymap[SDLK_BACKSLASH] = "backslash";
           mKeymap[SDLK_RIGHTBRACKET] = "right_brace";
           mKeymap[SDLK_CARET] = "caret";
           mKeymap[SDLK_UNDERSCORE] = "_";
           mKeymap[SDLK_BACKQUOTE] = "backquote";
           mKeymap[SDLK_a] = "a";
           mKeymap[SDLK_b] = "b";
           mKeymap[SDLK_c] = "c";
           mKeymap[SDLK_d] = "d";
           mKeymap[SDLK_e] = "e";
           mKeymap[SDLK_f] = "f";
           mKeymap[SDLK_g] = "g";
           mKeymap[SDLK_h] = "h";
           mKeymap[SDLK_i] = "i";
           mKeymap[SDLK_j] = "j";
           mKeymap[SDLK_k] = "k";
           mKeymap[SDLK_l] = "l";
           mKeymap[SDLK_m] = "m";
           mKeymap[SDLK_n] = "n";
           mKeymap[SDLK_o] = "o";
           mKeymap[SDLK_p] = "p";
           mKeymap[SDLK_q] = "q";
           mKeymap[SDLK_r] = "r";
           mKeymap[SDLK_s] = "s";
           mKeymap[SDLK_t] = "t";
           mKeymap[SDLK_u] = "u";
           mKeymap[SDLK_v] = "v";
           mKeymap[SDLK_w] = "w";
           mKeymap[SDLK_x] = "x";
           mKeymap[SDLK_y] = "y";
           mKeymap[SDLK_z] = "z";
           mKeymap[SDLK_DELETE] = "delete";
           mKeymap[SDLK_KP0] = "kp_0";
           mKeymap[SDLK_KP1] = "kp_1";
           mKeymap[SDLK_KP2] = "kp_2";
           mKeymap[SDLK_KP3] = "kp_3";
           mKeymap[SDLK_KP4] = "kp_4";
           mKeymap[SDLK_KP5] = "kp_5";
           mKeymap[SDLK_KP6] = "kp_6";
           mKeymap[SDLK_KP7] = "kp_7";
           mKeymap[SDLK_KP8] = "kp_8";
           mKeymap[SDLK_KP9] = "kp_9";
           mKeymap[SDLK_KP_PERIOD] = "kp_period";
           mKeymap[SDLK_KP_DIVIDE] = "kp_divide";
           mKeymap[SDLK_KP_MULTIPLY] = "kp_multi";
           mKeymap[SDLK_KP_MINUS] = "kp_minus";
           mKeymap[SDLK_KP_PLUS] = "kp_plus";
           mKeymap[SDLK_KP_ENTER] = "kp_enter";
           mKeymap[SDLK_KP_EQUALS] = "kp_equals";
           mKeymap[SDLK_UP] = "up";
           mKeymap[SDLK_DOWN] = "down";
           mKeymap[SDLK_RIGHT] = "right";
           mKeymap[SDLK_LEFT] = "left";
           mKeymap[SDLK_INSERT] = "insert";
           mKeymap[SDLK_HOME] = "home";
           mKeymap[SDLK_END] = "end";
           mKeymap[SDLK_PAGEUP] = "page_up";
           mKeymap[SDLK_PAGEDOWN] = "page_down";
           mKeymap[SDLK_F1] = "f1";
           mKeymap[SDLK_F2] = "f2";
           mKeymap[SDLK_F3] = "f3";
           mKeymap[SDLK_F4] = "f4";
           mKeymap[SDLK_F5] = "f5";
           mKeymap[SDLK_F6] = "f6";
           mKeymap[SDLK_F7] = "f7";
           mKeymap[SDLK_F8] = "f8";
           mKeymap[SDLK_F9] = "f9";
           mKeymap[SDLK_F10] = "f10";
           mKeymap[SDLK_F11] = "f11";
           mKeymap[SDLK_F12] = "f12";
           mKeymap[SDLK_F13] = "f13";
           mKeymap[SDLK_F14] = "f14";
           mKeymap[SDLK_F15] = "f15";
          
           mKeymap[SDLK_NUMLOCK] = "num";
           mKeymap[SDLK_CAPSLOCK] = "caps";
           mKeymap[SDLK_SCROLLOCK] = "srcoll";
           mKeymap[SDLK_RSHIFT] = "right_shift";
           mKeymap[SDLK_LSHIFT] = "left_shift";
           mKeymap[SDLK_RCTRL] = "right_ctrl";
           mKeymap[SDLK_LCTRL] = "left_ctrl";
           mKeymap[SDLK_RALT] = "right_alt";
           mKeymap[SDLK_LALT] = "left_alt";
           mKeymap[SDLK_RMETA] = "right_meta";
           mKeymap[SDLK_LMETA] = "left_meta";
           mKeymap[SDLK_LSUPER] = "left_super";
           mKeymap[SDLK_RSUPER] = "right_super";
           mKeymap[SDLK_MODE]= "mode";
           mKeymap[SDLK_COMPOSE] = "compose";
           mKeymap[SDLK_PRINT] = "print";
           mKeymap[SDLK_SYSREQ] = "sysreq";
           mKeymap[SDLK_BREAK] = "break";
           mKeymap[SDLK_MENU] = "menu";
           mKeymap[SDLK_POWER] = "power";
           mKeymap[SDLK_EURO] = "euro";
          }
          
          }

./components/ogre/input/InputCommandMapper.h

       1  //
          // C++ Interface: InputCommandMapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          // Copyright (  C ) 2001 - 2005 Simon Goodall,   University of Southampton
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREINPUTCOMMANDMAPPER_H
          #define EMBEROGREINPUTCOMMANDMAPPER_H
          
          #include <SDL.h>
          #include "Input.h"
          #include <vector>
          
          namespace EmberOgre {
          
          
          /**
          
           Listens for input (  key presses,   mouse movements etc ) and maps this input to commands that are then executed (  such as +move_forward etc. )
          
           It's expected that more than one instance of this should exists,   one for each different game "state",   such as "movement mode",   "general" etc.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      42  class InputCommandMapper : public sigc::trackable
          {
          public:
           typedef std::map<std::string,   std::string> KeyCommandStore;
           typedef std::map<SDLKey,   std::string> KeyMapStore;
           typedef std::vector<Input::InputMode> InputModeStore;
          
           /**
           * Constructor.
           * @param state The state which this instance should apply to,   such as "general" or "gui"
           * @return
           */
      54   InputCommandMapper(  const std::string& state );
          
           /**
           * Constructor which also reads values from the config and sets up bindings.
           * @param state The state which this instance should apply to,   such as "general" or "gui"
           * @param configSection The name of the config section to read values from.
           * @return
           */
      62   InputCommandMapper(  const std::string& state,   const std::string& configSection );
          
           /**
           * At destruction the instance is also deregistered from the Input instance.
           * @return
           */
      68   virtual ~InputCommandMapper(   );
          
           /**
           * Binds a command to a key.
           * @param key The name of the key.
           * @param command The full command to execute,   such as "/show_inventory" or "+run"
           */
      75   void bindCommand(  const std::string& key,   const std::string& command );
          
           /**
           * Removes a binding for a certain key.
           * @param key The name of the key to remove bindings for.
           */
      81   void unbindCommand(  const std::string& key );
          
           /**
           * The name of the state that this instance applies to.
           * @return
           */
      87   inline const std::string& getState(   ) const;
          
           /**
           * Reads a section from the config and sets up bindings accordingly.
           * @param sectionName The name of the section,   such as "key_bindings_general".
           */
      93   void readFromConfigSection(  const std::string& sectionName );
          
           /**
           * Sets whether this instance is enabled or not.
           * @param enabled
           */
      99   inline void setEnabled(  bool enabled );
          
           /**
           * Returns whether this instance is enabled or not.
           * @return
           */
     105   inline bool getEnabled(   ) const;
          
           /**
           * Binds the instance to a Input object. Call this to start recieving input.
           * @param input
           */
     111   void bindToInput(  Input& input );
          
           /**
           * Sets which modes this instance should be restricted to. An empty list will make it listen for all modes.
           * @param modes
           */
     117   inline void restrictToInputModes(  InputModeStore modes );
          
           /**
           * Sets which mode this instance should be restricted to.
           * @param mode
           */
     123   inline void restrictToInputMode(  Input::InputMode mode );
          
          protected:
          
           /**
           * At keypress time,   see what command to run.
           * @param key
           * @param inputMode
           */
     132   void Input_EventKeyPressed(  const SDL_keysym& key,   Input::InputMode inputMode );
           /**
           * At keyrelease time,   see if there's a command prefixed with "+",   such as "+run",   which should have its "-" twin command sent out.
           * @param key
           * @param inputMode
           */
     138   void Input_EventKeyReleased(  const SDL_keysym& key,   Input::InputMode inputMode );
          
           /**
           A store of the mapping between keys and commands.
           */
     143   KeyCommandStore mKeyCommands;
          
           /**
           The state which this instance applies to.
           */
     148   std::string mState;
          
           /**
           * Gets the name of the command registered to the key,   or an empty string if no could be found.
           * @param key
           * @return
           */
     155   const std::string& getCommandForKey(  SDLKey key );
          
           /**
           Mappings between SDLKeys and their names.
           */
     160   KeyMapStore mKeymap;
          
           /**
           * Creates the mapping between SDLKeys and their names.
           */
     165   void initKeyMap(   );
          
           /**
           Whether this is enabled or not.
           */
     170   bool mEnabled;
          
           /**
           Stores the InputModes that this instance is restricted to listen to,   if any.
           */
     175   InputModeStore mInputModesRestriction;
          
           /**
           * Returns true if this instance is active for the current input mode.
           * @param mode
           * @return
           */
     182   bool isActiveForInputMode(  Input::InputMode mode ) const;
          
           /**
           We'll keep a reference to the Input object which we will use at dispose time.
           */
     187   Input* mInput;
          };
          
     190  const std::string& InputCommandMapper::getState(   ) const {return mState;}
          
     192  void InputCommandMapper::setEnabled(  bool enabled ) {mEnabled = enabled;}
     193  bool InputCommandMapper::getEnabled(   ) const {return mEnabled; }
          
     195  void InputCommandMapper::restrictToInputModes(  InputModeStore modes ) {mInputModesRestriction = modes; }
     196  void InputCommandMapper::restrictToInputMode(  Input::InputMode mode ) {
          InputModeStore modes;
          modes.push_back(  mode );
          restrictToInputModes(  modes );
          }
          
          
          }
          
          #endif

./components/ogre/jesus/Jesus.cpp

       1  //
          // C++ Implementation: Jesus
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Jesus.h"
          #include "../carpenter/Carpenter.h"
          #include "../carpenter/BluePrint.h"
          #include "../model/Model.h"
          #include "JesusPickerObject.h"
          
          
          
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          
          #include "../MathConverter.h"
          
          
          namespace EmberOgre {
          
          
          
          
      43  Jesus::Jesus(  Carpenter::Carpenter* carpenter )
          : mCarpenter(  carpenter )
          {
          
           mNormalTypes["NORTH"] = WFMath::Vector<3>(  0,  1,  0 );
           mNormalTypes["SOUTH"] = WFMath::Vector<3>(  0,  -1,  0 );
           mNormalTypes["WEST"] = WFMath::Vector<3>(  -1,  0,  0 );
           mNormalTypes["EAST"] = WFMath::Vector<3>(  1,  0,  0 );
           mNormalTypes["UP"] = WFMath::Vector<3>(  0,  0,  1 );
           mNormalTypes["DOWN"] = WFMath::Vector<3>(  0,  0,  -1 );
          
          }
          
          
      57  Jesus::~Jesus(   )
          {
           delete mCarpenter;
          }
          
      62  AttachPointNode::AttachPointNode(  ModelBlock* modelBlock,   Ogre::SceneNode* modelNode,   const Carpenter::AttachPoint* attachPoint,   Ogre::ColourValue colour,  Ogre::BillboardSet* billboardSet  )
          : mModelBlock(  modelBlock ),   mModelNode(  modelNode ),   mAttachPoint(  attachPoint ),   mColour(  colour ),   mController(  0 )
          {
           Ogre::Vector3 position = Atlas2Ogre(  attachPoint->getPosition(   ) );
           std::string name = modelNode->getName(   ) + "_" + attachPoint->getAttachPair(   )->getName(   ) + "_" + attachPoint->getName(   );
          
          /* mPointerNode = mModelNode->createChildSceneNode (   );
          
           mPointerEntity = EmberOgre::getSingleton(   ).getSceneManager(   )->createEntity(  name + "entity",   "arrow.mesh" );
          
           mPointerNode->attachObject(  mPointerEntity );
           mPointerNode->setPosition(  position );
           WFMath::Quaternion quat;
           quat.rotation(  WFMath::Vector<3>(  1,  -1,  1 ),   attachPoint->getNormal(   ) );
          
           //Ogre::Vector3 normal = Atlas2Ogre(  attachPoint->getNormal(   ) );
           mPointerNode->setOrientation(  Atlas2Ogre(  quat ) );*/
          
          // mFlare = billboardSet->createBillboard(  modelBlock->getBuildingBlock(   )->getWorldPositionForPoint(  attachPoint ) ,   colour );
           mFlare = billboardSet->createBillboard(  position ,   colour );
          // mFlare = billboardSet->createBillboard(  0,  0,  0 ,   colour );
          
          }
          
      86  AttachPointNode::~AttachPointNode(   )
          {
           Ogre::ControllerManager::getSingleton(   ).destroyController(  mController );
          }
          
          
      92  void Jesus::addAttachPointType(  const std::string & type )
          {
          
           AttachPointColourValueMap::iterator J = mColourMap.find(  type );
           if (  J == mColourMap.end(   ) ) {
           Ogre::ColourValue colour = Ogre::ColourValue(  0.5,  0.5,  0.1 * mColourMap.size(   ) );
           mColourMap.insert(  AttachPointColourValueMap::value_type(  type,   colour ) );
           }
          
          }
          
          
     104  bool Jesus::addBluePrint(  Carpenter::BluePrint* blueprint )
          {
           if (  mBlueprints.find(  blueprint->getName(   ) ) != mBlueprints.end(   ) ) {
           //there is already a blueprint with that name
           return false;
           }
           mBlueprints.insert(  std::map<std::string,   Carpenter::BluePrint*>::value_type(  blueprint->getName(   ),   blueprint ) );
           return true;
          }
          
     114  Carpenter::BluePrint* Jesus::getBluePrint(  const std::string& name ) const
          {
           std::map<std::string,   Carpenter::BluePrint*>::const_iterator I = mBlueprints.find(  name );
           if (  I != mBlueprints.end(   ) )
           {
           return I->second;
           }
           return 0;
          
          }
          
          
          
     127  Construction::Construction(  Carpenter::BluePrint* bluePrint,   Jesus* jesus,   Ogre::SceneNode* node )
          :
          mBlueprint(  bluePrint ),  
          mBaseNode(  node ),  
          mJesus(  jesus )
          {
          
          
          }
          
     137  Construction::~Construction(   )
          {
           for (  std::vector<ModelBlock*>::iterator I = mModelBlocks.begin(   ); I != mModelBlocks.end(   ); ++I ) {
           delete *I;
           }
          // mBaseNode->removeAndDestroyAllChildren(   );
          }
          
     145  void Construction::buildFromBluePrint(  bool createAttachPointNodes )
          {
           std::vector<Carpenter::BuildingBlock*> buildingBlocks = mBlueprint->getAttachedBlocks(   );
          
           std::vector<Carpenter::BuildingBlock*>::const_iterator J = buildingBlocks.begin(   );
           std::vector<Carpenter::BuildingBlock*>::const_iterator J_end = buildingBlocks.end(   );
          
           for (  ;J != J_end; ++J )
           {
           Carpenter::BuildingBlock* block = *J;
           if (  block->isAttached(   ) ) {
           createModelBlock(  block,   createAttachPointNodes );
           }
           }
          
          }
          
     162  ModelBlock* Construction::createModelBlock(  const Carpenter::BuildingBlock* buildingBlock,   bool createAttachPointNodes )
          {
           std::string blockSpecName = buildingBlock->getBuildingBlockSpec(   )->getName(   );
          
           Model::Model* model = mJesus->createModelForBlockType(  blockSpecName,   mBaseNode->getName(   ) + buildingBlock->getName(   ) );
           ModelBlock* modelBlock = new ModelBlock(  mBaseNode,   buildingBlock,   model,   this );
          
           if (  createAttachPointNodes )
           modelBlock->createAttachPointNodes(   );
           mModelBlocks.push_back(  modelBlock );
           return modelBlock;
          }
          
     175  bool Construction::remove(  ModelBlock* modelBlock )
          {
           bool result = mBlueprint->remove(  modelBlock->getBuildingBlock(   ) );
           if (  result ) {
           std::vector<ModelBlock*>::iterator pos = mModelBlocks.end(   );
           for (  std::vector<ModelBlock*>::iterator I = mModelBlocks.begin(   ); I != mModelBlocks.end(   ); ++I ) {
           if (  modelBlock == *I ) {
           pos = I;
           break;
           }
           }
           if (  pos != mModelBlocks.end(   ) ) {
           mModelBlocks.erase(  pos );
           }
           delete modelBlock;
          
           }
           return result;
          }
          
          
     196  std::vector<ModelBlock*> Construction::getModelBlocks(   ) const
          {
           return mModelBlocks;
          }
          
     201  std::vector<AttachPointNode*> ModelBlock::getAttachPointNodes(   ) const
          {
           return mAttachPointNodes;
          }
          
          
     207  Model::Model* Jesus::createModelForBlockType(  const std::string& blockType,   const std::string& modelName )
          {
           std::map<std::string,   std::string>::iterator I = mModelMappings.find(  blockType );
           if (  I == mModelMappings.end(   ) ) {
           return 0;
           }
           Model::Model* aModel = Model::Model::createModel(  EmberOgre::getSingleton(   ).getSceneManager(   ),   I->second,   modelName );
           //aModel->create(  I->second );
           return aModel;
          // return Model::Create(  I->second + ".modeldef.xml",   modelName );
          }
          
     219  ModelBlock::~ModelBlock(   )
          {
           mNode->getCreator(   )->destroyBillboardSet(  mPointBillBoardSet );
           if (  mModelNode )
           mNode->getCreator(   )->destroySceneNode (  mModelNode->getName(   ) );
          
           delete mModel;
          
           std::vector<AttachPointNode* >::iterator I = mAttachPointNodes.begin(   );
           std::vector<AttachPointNode* >::iterator I_end = mAttachPointNodes.end(   );
           for(  ; I != I_end; ++I ) {
           delete *I;
           }
           mNode->getParent(   )->removeChild(  mNode );
           mNode->getCreator(   )->destroySceneNode (  mNode->getName(   ) );
          
          
          }
          
          
     239  ModelBlock::ModelBlock(  Ogre::SceneNode* baseNode,  const Carpenter::BuildingBlock* buildingBlock,   Model::Model* model,   Construction* construction )
          : mBuildingBlock(  buildingBlock )
          ,   mModel(  model )
          ,   mModelNode(  0 )
          ,   mConstruction(  construction )
          {
          
          
           mNode = baseNode->createChildSceneNode(  Atlas2Ogre(  buildingBlock->getPosition(   ) ),   Atlas2Ogre(  buildingBlock->getOrientation(   ) ) );
          
          
           mPointBillBoardSet = mNode->getCreator(   )->createBillboardSet(   std::string(  "__construction_" ) + construction->getBluePrint(   )->getName(   ) + "_" + buildingBlock->getName(   ) + "_billboardset__" + mNode->getName(   ) );
           mPointBillBoardSet->setDefaultDimensions(  1,   1 );
           mPointBillBoardSet->setMaterialName(  "carpenter/flare" );
           mPointBillBoardSet->setVisible(  false );
          // Ogre::SceneNode* aNode = EmberOgre::getSingleton(   ).getSceneManager(   )->getRootSceneNode(   )->createChildSceneNode(   );
           mNode->attachObject(  mPointBillBoardSet );
          
          
           if (  model ) {
           JesusPickerObject* pickerObject = new JesusPickerObject(  this,   0 );
           model->setUserObject(  pickerObject );
          
          
           mModelNode = mNode->createChildSceneNode(   );
           mModelNode->attachObject(  model );
           model->setQueryFlags(  Jesus::CM_MODELBLOCK );
          
           //only autoscale the model if we've not set the scale in the modeldefinition
           //TODO: it would of course be best if all models were correctly scaled and this code could be removed
           if (  model->getDefinition(   )->getScale(   ) == 0 ) {
           const Ogre::AxisAlignedBox ogreBoundingBox = model->getBoundingBox(   );
           const Ogre::Vector3 ogreMax = ogreBoundingBox.getMaximum(   );
           const Ogre::Vector3 ogreMin = ogreBoundingBox.getMinimum(   );
          
          
           const WFMath::AxisBox<3> wfBoundingBox = buildingBlock->getBuildingBlockSpec(   )->getBlockSpec(   )->getBoundingBox(   );
           const WFMath::Point<3> wfMax = wfBoundingBox.highCorner(   );
           const WFMath::Point<3> wfMin = wfBoundingBox.lowCorner(   );
          
           Ogre::Real scaleX;
           Ogre::Real scaleY;
           Ogre::Real scaleZ;
          
           scaleX = fabs(  (  wfMax.x(   ) - wfMin.x(   ) ) / (  ogreMax.x - ogreMin.x ) );
           scaleY = fabs(  (  wfMax.z(   ) - wfMin.z(   ) ) / (  ogreMax.y - ogreMin.y ) );
           scaleZ = fabs(  (  wfMax.y(   ) - wfMin.y(   ) ) / (  ogreMax.z - ogreMin.z ) );
          
           mModelNode->setScale(  scaleX,   scaleY,   scaleZ );
           }
          
           }
          
          }
          
     294  void ModelBlock::createAttachPointNodes(    )
          {
           std::vector<const Carpenter::AttachPoint* > allPoints = mBuildingBlock->getAllPoints(   );
          
           std::vector<const Carpenter::AttachPoint* >::const_iterator I = allPoints.begin(   );
           std::vector<const Carpenter::AttachPoint* >::const_iterator I_end = allPoints.end(   );
          
           for(  ; I != I_end; ++I ) {
           Ogre::ColourValue colour = mConstruction->getJesus(   )->getColourForAttachPoint(  *I );
           AttachPointNode* pointNode = new AttachPointNode(  this,   mNode,   *I,   colour,   mPointBillBoardSet );
           mAttachPointNodes.push_back(  pointNode );
           }
          }
          
     308  void ModelBlock::select(   )
          {
           if (  mModelNode )
           mModelNode->showBoundingBox(  true );
           if (  mPointBillBoardSet )
           mPointBillBoardSet->setVisible(  true );
          }
          
     316  void ModelBlock::deselect(   )
          {
           if (  mModelNode )
           mModelNode->showBoundingBox(  false );
           if (  mPointBillBoardSet )
           mPointBillBoardSet->setVisible(  false );
          }
          
          
     325  Ogre::ColourValue Jesus::getColourForAttachPoint(  const Carpenter::AttachPoint* point ) const
          {
           AttachPointColourValueMap::const_iterator I = mColourMap.find(  point->getAttachPair(   )->getType(   ) );
           if (  I == mColourMap.end(   ) ) {
           return Ogre::ColourValue(  1,  1,  1 );
           }
           return I->second;
          }
          
     334  void AttachPointNode::select(   )
          {
           Ogre::ControllerFunctionRealPtr func = Ogre::ControllerFunctionRealPtr(  
           new Ogre::WaveformControllerFunction(  Ogre::WFT_SINE,   0.0,   2 ) );
           Ogre::ControllerManager& contMgr = Ogre::ControllerManager::getSingleton(   );
          
           Ogre::ControllerValueRealPtr val = Ogre::ControllerValueRealPtr(  
           new LightWibbler(  mColour,   mFlare ) );
           mController = contMgr.createController(  contMgr.getFrameTimeSource(   ),   val,   func );
          }
          
     345  void AttachPointNode::deselect(   )
          {
           mFlare->setDimensions(  1,  1 );
           mFlare->setColour(  mColour );
           Ogre::ControllerManager::getSingleton(   ).destroyController(  mController );
           mController = 0;
          }
          
     353  LightWibbler::LightWibbler(  const Ogre::ColourValue& originalColour,   Ogre::Billboard* billboard )
          {
           mOriginalColour = originalColour;
           mBillboard = billboard;
          }
          
     359  Ogre::Real LightWibbler::getValue (  void ) const
          {
           return intensity;
          }
          
     364  void LightWibbler::setValue (  Ogre::Real value )
          {
           intensity = value;
          
           Ogre::ColourValue newColour(  intensity,   intensity,   intensity );
          
           mBillboard->setColour(  mOriginalColour * newColour );
           mBillboard->setDimensions(  1 + (  intensity * 2 ),  1 + (  intensity * 2 ) );
          
          }
          
          
          };
          
          
          
          

./components/ogre/jesus/Jesus.h

       1  //
          // C++ Interface: Jesus
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREJESUS_H
          #define EMBEROGREJESUS_H
          
          
          #include "../EmberOgrePrerequisites.h"
          #include <string>
          #include <map>
          
          #include "../EmberOgre.h"
          #include <wfmath/vector.h>
          
          namespace Carpenter
          {
      36  class AttachPair;
      37  class AttachPoint;
      38  class BlockSpec;
      39  class BuildingBlock;
      40  class BuildingBlockSpec;
      41  class BuildingBlockSpecDefinition;
      42  class BuildingBlockBinding;
      43  class BuildingBlockBindingDefinition;
      44  class BuildingBlockDefinition;
      45  class BluePrint;
      46  class Carpenter;
          
          };
          
          
          namespace EmberOgre {
          
      53  TYPEDEF_STL_MAP(  const std::string,   Ogre::ColourValue,   AttachPointColourValueMap );
          
          namespace Model {
      56   class Model;
          }
          
      59  class ModelBlock;
      60  class Construction;
          
          /**
          @author Erik Hjortsberg
          
          Classes for handling Carpenter instances and building creation in Ember. These classes should also allow for real time editing of blueprints,   and serializing them into different formats (  xml,   Atlas etc. ).
          
          */
      68  class Jesus{
      69   friend class XMLJesusSerializer;
          
           public:
          
           enum ClickMasks
           {
           CM_MODELBLOCK = 1<<13,  
           CM_ATTACHPOINT = 1<<14
           };
          
      79   Jesus(  Carpenter::Carpenter* carpenter );
          
      81   ~Jesus(   );
          
          
          
           /**
           * Creates a new Model instance for the supplied block type.
           * If there's no Model defined for the supplies block type,   a null pointer will be returned.
           * @param blockType
           * @param modelName
           * @return A Model instance or 0
           */
      92   Model::Model* createModelForBlockType(  const std::string& blockType,   const std::string& modelName );
          
          
           /**
           * Finds the colour associated to the supplied attachpoint. If no colour is registered,   a ColourValue of 1,  1,  1 will be returned
           * @param point
           * @return
           */
     100   Ogre::ColourValue getColourForAttachPoint(  const Carpenter::AttachPoint* point ) const;
          
           /**
           * Accessor for the Carpenter object.
           * @return
           */
     106   inline Carpenter::Carpenter* getCarpenter(   ) const { return mCarpenter; }
          
           /**
           * adds a blueprint
           * @param blueprint
           * @return false if there's already a blueprint with the same name as the supplied blueprint
           */
     113   bool addBluePrint(  Carpenter::BluePrint* blueprint );
          
           /**
           * returns a blueprint with the supplied name
           * note that the blueprint must already be loaded and added to Jesus with addBluePrint(  ... )
           * @see addBluePrint(  Carpenter::BluePrint* )
           * @param name
           * @return
           */
     122   Carpenter::BluePrint* getBluePrint(  const std::string& name ) const;
          
          
     125   inline const std::map<std::string ,   Carpenter::BluePrint* > * getAllBluePrints(   ) const {return &mBlueprints;}
          
          protected:
          
           /**
           a map of what Model should represent a certain Carpenter::BuildingBlockSpec
           the first value is the name of the Carpenter::BuildingBlockSpec and the second value is the name of the Model
           */
     133   std::map<std::string,   std::string> mModelMappings;
     134   Carpenter::Carpenter* mCarpenter;
          
           /**
           * Convenience map of commonly used normals,   such as NORTH,   UP,   WEST etc.
           */
     139   std::map<const std::string,   WFMath::Vector<3> > mNormalTypes;
          
           /**
           Map of colours for Attach point types.
           */
     144   AttachPointColourValueMap mColourMap;
          
     146   void addAttachPointType(  const std::string & type );
          
           /**
           all blueprints are stored here
           */
     151   std::map<std::string ,   Carpenter::BluePrint* > mBlueprints;
          
          };
          
          
          /** This class 'wibbles' the billboard */
     157  class LightWibbler : public Ogre::ControllerValue<Ogre::Real>
          {
          public:
     160   LightWibbler(  const Ogre::ColourValue& originalColour,   Ogre::Billboard* billboard );
          
     162   virtual Ogre::Real getValue (  void ) const;
     163   virtual void setValue (  Ogre::Real value );
          protected:
     165   Ogre::Billboard* mBillboard;
     166   Ogre::ColourValue mOriginalColour;
     167   Ogre::Real intensity;
          };
          
          
     171  class AttachPointNode
          {
          public:
     174   AttachPointNode(  ModelBlock* modelBlock,   Ogre::SceneNode* modelNode,   const Carpenter::AttachPoint* attachPoint,   Ogre::ColourValue colour,   Ogre::BillboardSet* billboardSet );
     175   ~AttachPointNode(   );
     176   void select(   );
     177   void deselect(   );
     178   inline const Carpenter::AttachPoint* getAttachPoint(   ) const { return mAttachPoint;}
          
          protected:
     181   const ModelBlock* mModelBlock;
     182   Ogre::SceneNode* mModelNode;
     183   const Carpenter::AttachPoint* mAttachPoint;
     184   Ogre::Billboard* mFlare;
     185   Ogre::ColourValue mColour;
     186   Ogre::Controller<Ogre::Real>* mController;
     187   Ogre::SceneNode* mPointerNode;
     188   Ogre::Entity* mPointerEntity;
          };
          
          
          /**
          
          A mapping between a Carpenter::BuildingBlock and an Ember::Model.
          */
     196  class ModelBlock
          {
          public:
     199   ModelBlock(  Ogre::SceneNode* baseNode,   const Carpenter::BuildingBlock* buildingBlock,   Model::Model* model,   Construction* construction );
     200   ~ModelBlock(   );
           //void selectAttachPointNode(  AttachPointNode* selectedNode );
          
     203   inline const Carpenter::BuildingBlock* getBuildingBlock(   ) const { return mBuildingBlock; }
     204   inline Construction* getConstruction(   ) const { return mConstruction; }
     205   void createAttachPointNodes(   );
     206   void select(   );
     207   void deselect(   );
          
     209   std::vector<AttachPointNode*> getAttachPointNodes(   ) const;
          
     211   const Model::Model* getModel(   ) const { return mModel;}
     212   const Ogre::SceneNode* getNode(   ) const { return mNode;}
          protected:
     214   const Carpenter::BuildingBlock* mBuildingBlock;
     215   Model::Model* mModel;
          
     217   std::vector<AttachPointNode*> mAttachPointNodes;
     218   Ogre::SceneNode *mNode,   *mModelNode;
     219   Ogre::BillboardSet* mPointBillBoardSet;
     220   Construction* mConstruction;
           //Jesus* mJesus;
          };
          
          /**
           Mapping between a Carpenter block type and a Ember Model.
          */
     227  struct ModelMapping
          {
          
          public:
     231   const std::string model;
     232   const std::string blocktype;
          };
          
          /**
          
          An Ember representation of a BluePrint.
          
          */
     240  class Construction
          {
          public:
     243   Construction(  Carpenter::BluePrint* blueprint,   Jesus* jesus,   Ogre::SceneNode* node );
     244   ~Construction(   );
           //inline Ogre::BillboardSet* getBillBoardSet(   ) const { return mPointBillBoardSet; }
     246   inline Jesus* getJesus(   ) const { return mJesus; }
     247   inline Carpenter::BluePrint* getBluePrint(   ) const { return mBlueprint; }
          
          
     250   void buildFromBluePrint(  bool createAttachPointNodes );
          
          
           /**
           * Creates a new ModelBlock and adds it to the construction.
           * @param buildingBlock
           * @return
           */
     258   ModelBlock* createModelBlock(  const Carpenter::BuildingBlock* buildingBlock,   bool createAttachPointNodes );
          
     260   std::vector<ModelBlock*> getModelBlocks(   ) const;
          
     262   bool remove(  ModelBlock* modelBlock );
          
          protected:
     265   Carpenter::BluePrint* mBlueprint;
     266   Ogre::SceneNode* mBaseNode;
     267   Jesus* mJesus;
          
     269   std::vector<ModelBlock*> mModelBlocks;
          
          };
          
          
          
          };
          
          #endif

./components/ogre/jesus/JesusMousePicker.cpp

       1  //
          // C++ Implementation: JesusMousePicker
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "JesusMousePicker.h"
          #include "Jesus.h"
          #include "JesusPickerObject.h"
          #include "../AvatarCamera.h"
          
          namespace EmberOgre {
          
      30  JesusMousePicker::JesusMousePicker(   )
           : MousePicker(   )
          {
          }
          
          
      36  JesusMousePicker::~JesusMousePicker(   )
          {
          }
          
      40  void JesusMousePicker::doMousePicking(  const Ogre::Real x,   const Ogre::Real y,  const MousePickerArgs& args )
          {
          // AvatarCamera* camera = EmberOgre::getSingleton(   ).getMainCamera(   );
          
          
          // JesusPickerObject* pickerObject = 0;
          // std::vector<Ogre::UserDefinedObject*> exclude;
          // unsigned long test = Jesus::CM_MODELBLOCK;
          // test |= Jesus::CM_ATTACHPOINT;
          // std::vector<Ogre::RaySceneQueryResultEntry> result = camera->pickObject(  x,   y,   exclude,   test );
          // if (  result.size(   ) ) {
          // Ogre::UserDefinedObject* object = (  *result.begin(   ) ).movable->getUserObject(   );
          // JesusPickerObject* pickerObject = static_cast<JesusPickerObject*>(  object );
          // if (  pickerObject ) {
          // if (  pickerObject->getModelBlock(   ) ) {
          // onEventPickedModelBlock(  pickerObject->getModelBlock(   ),   args );
          // } else {
          // onEventPickedAttachPointNode(  pickerObject->getPointNode(   ),   args );
          // }
          // }
          // } else {
          // onEventPickedNothing(  args );
          // }
          
          }
          
      66  void JesusMousePicker::onEventPickedModelBlock(  ModelBlock* modelBlock,   const MousePickerArgs& args )
          {
           EventPickedModelBlock.emit(  modelBlock,   args );
          }
          
      71  void JesusMousePicker::onEventPickedAttachPointNode(  AttachPointNode* node,   const MousePickerArgs& args )
          {
           EventPickedAttachPointNode.emit(  node,   args );
          }
          
      76  void JesusMousePicker::initializePickingContext(   )
          {
          }
          
          }

./components/ogre/jesus/JesusMousePicker.h

       1  //
          // C++ Interface: JesusMousePicker
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREJESUSMOUSEPICKER_H
          #define EMBEROGREJESUSMOUSEPICKER_H
          
          #include "../EmberOgrePrerequisites.h"
          #include "../MousePicker.h"
          
          
          namespace EmberOgre {
          
      32  class ModelBlock;
      33  class AttachPointNode;
          
          /**
          @author Erik Hjortsberg
          */
      38  class JesusMousePicker : public MousePicker
          {
          public:
      41   JesusMousePicker(   );
          
      43   virtual ~JesusMousePicker(   );
          
      45   virtual void doMousePicking(  const Ogre::Real x,   const Ogre::Real y,   const MousePickerArgs& args );
      46   virtual void initializePickingContext(   );
           /**
           Called when the picking is over,   either because one of the processPickResult calls set continuePicking to false,   or because there are no more objects to pick.
           */
      50   virtual void endPickingContext(  const MousePickerArgs& mousePickerArgs ) {}
          
      52   sigc::signal<void,   ModelBlock*,   const MousePickerArgs&> EventPickedModelBlock;
      53   sigc::signal<void,   AttachPointNode*,   const MousePickerArgs&> EventPickedAttachPointNode;
          
          
          protected:
          
      58   virtual void onEventPickedModelBlock(  ModelBlock* modelBlock,   const MousePickerArgs& args );
      59   virtual void onEventPickedAttachPointNode(  AttachPointNode* node,   const MousePickerArgs& args );
          
          
          
          
          };
          }
          
          #endif

./components/ogre/jesus/JesusPickerObject.cpp

       1  //
          // C++ Implementation: JesusPickerObject
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "JesusPickerObject.h"
          #include "Jesus.h"
          
          
          namespace EmberOgre {
          
          const Ogre::String JesusPickerObject::s_TypeName = "JesusPickerObject";
          
      31  JesusPickerObject::JesusPickerObject(  ModelBlock* modelBlock,   AttachPointNode* pointNode )
          : mModelBlock(  modelBlock ),   mPointNode(  pointNode )
          {
          }
          
          
      37  JesusPickerObject::~JesusPickerObject(   )
          {
          }
          
      41  const Ogre::String & JesusPickerObject::getTypeName (  void ) const
          {
           return s_TypeName;
          }
          
          
          }

./components/ogre/jesus/JesusPickerObject.h

       1  //
          // C++ Interface: JesusPickerObject
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREJESUSPICKEROBJECT_H
          #define EMBEROGREJESUSPICKEROBJECT_H
          
          #include "../EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
      30  class ModelBlock;
      31  class AttachPointNode;
          
          /**
          @author Erik Hjortsberg
          */
      36  class JesusPickerObject : public Ogre::UserDefinedObject
          {
          public:
      39   static const std::string s_TypeName;
      40   JesusPickerObject(  ModelBlock* modelBlock,   AttachPointNode* pointNode );
          
      42   ~JesusPickerObject(   );
          
      44   inline ModelBlock* getModelBlock(   ) const { return mModelBlock; }
      45   inline AttachPointNode* getPointNode(   ) const { return mPointNode; }
      46   virtual const Ogre::String & getTypeName (  void ) const;
          protected:
      48  ModelBlock* mModelBlock;
      49  AttachPointNode* mPointNode;
          
          };
          
          }
          
          #endif

./components/ogre/jesus/XMLJesusSerializer.cpp

       1  //
          // C++ Implementation: XMLJesusSerializer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "XMLJesusSerializer.h"
          #include "Jesus.h"
          #include "../carpenter/Carpenter.h"
          #include "../carpenter/BluePrint.h"
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          
          #include "framework/osdir.h"
          
          #ifdef __WIN32__
          #include <direct.h>
          #endif
          
          namespace EmberOgre {
          
      39  XMLJesusSerializer::XMLJesusSerializer(  Jesus* jesus )
          : mJesus(  jesus )
          {
          }
          
          
      45  XMLJesusSerializer::~XMLJesusSerializer(   )
          {
          }
          
          
      50  bool XMLJesusSerializer::loadModelBlockMapping(  const std::string& filename )
          {
           if (  filename == "" || filename == "." || filename == ".." || std::ifstream(  filename.c_str(   ) ,   std::ios::in  ).fail(   ) ) {
           return false;
           }
          
           Ember::TiXmlDocument _XMLDoc;
           bool success = _XMLDoc.LoadFile(  filename.c_str(   ) ); //load from data stream
          
           if (  !success ) {
           std::string errorDesc = _XMLDoc.ErrorDesc(   );
           int errorLine = _XMLDoc.ErrorRow(   );
           int errorColumn = _XMLDoc.ErrorCol(   );
           std::stringstream ss;
           ss << "Failed to load load model block mapping file '" << filename << "'! Error at column: " << errorColumn << " line: " << errorLine << ". Error message: " << errorDesc;
           S_LOG_FAILURE(  ss.str(   ) );
           return false;
           }
          
          
           Ember::TiXmlElement* rootElem = _XMLDoc.RootElement(   );
          
           for (  Ember::TiXmlElement* smElem = rootElem->FirstChildElement(   );
           smElem != 0; smElem = smElem->NextSiblingElement(   ) )
           {
           const char* tmp = smElem->Attribute(  "model" );
           if (  !tmp ) {
           continue;
           }
          
           std::string model(  tmp );
          
           tmp = smElem->Attribute(  "blocktype" );
           if (  !tmp ) {
           continue;
           }
          
           std::string blocktype(  tmp );
          
           mJesus->mModelMappings[blocktype] = model;
           }
          
           return true;
          
          }
          
          
          template <typename T>
      98  void XMLJesusSerializer::fillFromElement(  Ember::TiXmlElement* elem,   T& geometryObject )
          {
           WFMath::CoordType x = atof(  elem->Attribute(  "x" ) );
           WFMath::CoordType y = atof(  elem->Attribute(  "y" ) );
           WFMath::CoordType z = atof(  elem->Attribute(  "z" ) );
          
           geometryObject.x(   ) = x;
           geometryObject.y(   ) = y;
           geometryObject.z(   ) = z;
          
           geometryObject.setValid(  true );
          
          
          }
          
     113  bool XMLJesusSerializer::loadBlockSpec(  const std::string& filename )
          {
          
           if (  filename == "" || filename == "." || filename == ".." || std::ifstream(  filename.c_str(   ) ,   std::ios::in  ).fail(   ) ) {
           return false;
           }
          
           Ember::TiXmlDocument _XMLDoc;
           bool success = _XMLDoc.LoadFile(  filename.c_str(   ) ); //load from data stream
          
           if (  !success ) {
           std::string errorDesc = _XMLDoc.ErrorDesc(   );
           int errorLine = _XMLDoc.ErrorRow(   );
           int errorColumn = _XMLDoc.ErrorCol(   );
           std::stringstream ss;
           ss << "Failed to load load block spec file '" << filename << "'! Error at column: " << errorColumn << " line: " << errorLine << ". Error message: " << errorDesc;
           S_LOG_FAILURE(  ss.str(   ) );
           return false;
           }
          
           Ember::TiXmlElement* elem;
          
          
           Ember::TiXmlElement* rootElem = _XMLDoc.RootElement(   );
          
           for (  Ember::TiXmlElement* smElem = rootElem->FirstChildElement(   );
           smElem != 0; smElem = smElem->NextSiblingElement(   ) )
           {
          
           const char* tmp = smElem->Attribute(  "name" );
           if (  !tmp ) {
           continue;
           }
          
           std::string name(  tmp );
          
           Carpenter::BlockSpec *blockSpec = mJesus->getCarpenter(   )->createBlockSpec(  name );
          
           elem = smElem->FirstChildElement(  "bbox" );
          
           if (  elem )
           {
           WFMath::Point<3> bboxPoint_temp;
          
           fillFromElement(  elem,   bboxPoint_temp );
           WFMath::Point<3> bboxPoint1(  bboxPoint_temp.x(   ) * 0.5,   bboxPoint_temp.y(   ) * 0.5,   bboxPoint_temp.z(   ) * 0.5 );
           WFMath::Point<3> bboxPoint2(  -bboxPoint_temp.x(   ) * 0.5,   -bboxPoint_temp.y(   ) * 0.5,   -bboxPoint_temp.z(   ) * 0.5 );
           //(  -bboxPoint1.x(   ),  -bboxPoint1.y(   ),  -bboxPoint1.z(   ) );
          
           WFMath::AxisBox<3> bbox(  bboxPoint1,   bboxPoint2 );
           blockSpec->setBoundingBox(  bbox );
           }
          
          
           elem = smElem->FirstChildElement(  "attachpairs" );
          
           readAttachPairs(  blockSpec,   elem );
          
          
           }
           return true;
          }
          
          
     177  Carpenter::AttachPoint* XMLJesusSerializer::readAttachPoint(  Ember::TiXmlElement* elem )
          {
           const char* tmp = 0;
          
           tmp = elem->Attribute(  "name" );
           if (  !tmp ) {
           return 0;
           }
           std::string name(  tmp );
          
           Ember::TiXmlElement* normalElem = elem->FirstChildElement(  "normal" );
          
           tmp = normalElem->Attribute(  "type" );
           if (  !tmp ) {
           return 0;
           }
           std::string type(  tmp );
          
           if (  mJesus->mNormalTypes.find(  type ) == mJesus->mNormalTypes.end(   ) ) {
           return 0;
           }
           WFMath::Vector<3> normal = mJesus->mNormalTypes.find(  type )->second;
          
           Ember::TiXmlElement* positionElem = elem->FirstChildElement(  "position" );
           if (  !positionElem ) {
           return 0;
           }
          
           WFMath::Point<3> position;
           fillFromElement(  positionElem,   position );
          
           return new Carpenter::AttachPoint(  name,   position,   normal );
          
          
          }
          
          
     214  void XMLJesusSerializer::readAttachPairs(  Carpenter::BlockSpec *blockSpec,   Ember::TiXmlElement* parentElem )
          {
          
           const char* tmp = 0;
          
           for (  Ember::TiXmlElement* elem = parentElem->FirstChildElement(   );
           elem != 0; elem = elem->NextSiblingElement(   ) )
           {
           tmp = elem->Attribute(  "name" );
           if (  !tmp ) {
           continue;
           }
           std::string name(  tmp );
          
          
           tmp = elem->Attribute(  "type" );
           if (  !tmp ) {
           continue;
           }
           std::string type(  tmp );
          
          
           Ember::TiXmlElement* attachPointElem = elem->FirstChildElement(  "attachpoint" );
           //make sure that there are two attach points
           if (  !attachPointElem->NextSiblingElement(   ) ) {
           continue;
           }
          
           Carpenter::AttachPoint* point1 = readAttachPoint(  attachPointElem );
           Carpenter::AttachPoint* point2 = readAttachPoint(  attachPointElem->NextSiblingElement(   ) );
          
           if (  !point1 || !point2 ) {
           delete point1;
           delete point2;
           continue;
           }
           Carpenter::AttachPair* pair = new Carpenter::AttachPair(  name,   type,   *point1,   *point2 );
           delete point1;
           delete point2;
          
           blockSpec->addAttachPair(  pair );
          
          
           mJesus->addAttachPointType(  type );
           }
          
          }
          
          
          
     264  bool XMLJesusSerializer::loadBuildingBlockSpecDefinition(  const std::string& filename )
          {
          
           if (  filename == "" || filename == "." || filename == ".." || std::ifstream(  filename.c_str(   ) ,   std::ios::in  ).fail(   ) ) {
           return false;
           }
          
           Ember::TiXmlDocument _XMLDoc;
           bool success = _XMLDoc.LoadFile(  filename.c_str(   ) ); //load from data stream
          
           if (  !success ) {
           S_LOG_FAILURE(  "Failed to load modeldefinition file!" );
           return false;
           }
          
          
           Ember::TiXmlElement* rootElem = _XMLDoc.RootElement(   );
          
           for (  Ember::TiXmlElement* smElem = rootElem->FirstChildElement(   );
           smElem != 0; smElem = smElem->NextSiblingElement(   ) )
           {
          
           Carpenter::BuildingBlockSpecDefinition buildingBlockSpecDef;
           const char* tmp = smElem->Attribute(  "name" );
           if (  !tmp ) {
           continue;
           }
           buildingBlockSpecDef.mName = tmp;
          
           tmp = smElem->Attribute(  "blockspec" );
           if (  !tmp ) {
           continue;
           }
           buildingBlockSpecDef.mBlockSpecName = tmp;
          
           mJesus->getCarpenter(   )->createBuildingBlockSpec(  buildingBlockSpecDef );
           }
          
           return true;
          
          }
          
          
          
          
     309  Carpenter::BluePrint* XMLJesusSerializer::loadBlueprint(  const std::string& filename )
          {
           if (  filename == "" || filename == "." || filename == ".." || std::ifstream(  filename.c_str(   ) ,   std::ios::in  ).fail(   ) ) {
           return false;
           }
          
           Ember::TiXmlDocument _XMLDoc;
           bool success = _XMLDoc.LoadFile(  filename.c_str(   ) ); //load from data stream
          
           if (  !success ) {
           S_LOG_FAILURE(  "Failed to load modeldefinition file!" );
           return 0;
           }
          
          
           Ember::TiXmlElement* rootElem = _XMLDoc.RootElement(   );
          
           const char* tmp;
          
           tmp = rootElem->Attribute(  "startingblock" );
           if (  !tmp ) {
           return 0;
           }
           std::string startingBlockName(  tmp );
          
           tmp = rootElem->Attribute(  "name" );
           if (  !tmp ) {
           return 0;
           }
           std::string name(  tmp );
          
          
           Carpenter::BluePrint* blueprint = mJesus->getCarpenter(   )->createBlueprint(  name );
          
           for (  Ember::TiXmlElement* bbElem = rootElem->FirstChildElement(  "buildingblocks" );
           bbElem != 0; bbElem = bbElem->NextSiblingElement(   ) )
           {
           for (  Ember::TiXmlElement* smElem = bbElem->FirstChildElement(  "buildingblock" );
           smElem != 0; smElem = smElem->NextSiblingElement(   ) )
           {
           tmp = smElem->Attribute(  "name" );
           if (  !tmp ) {
           continue;
           }
           std::string blockDefName(  tmp );
          
           tmp = smElem->Attribute(  "blocktype" );
           if (  !tmp ) {
           continue;
           }
           std::string blockDefType(  tmp );
          
          
           Carpenter::BuildingBlockDefinition bBlockDef;
           bBlockDef.mName = blockDefName;
           bBlockDef.mBuildingBlockSpec = blockDefType;
          
           blueprint->createBuildingBlock(  bBlockDef );
          
           if (  bBlockDef.mName == startingBlockName ) {
           blueprint->setStartingBlock(  startingBlockName );
           }
           }
           }
          
           for (  Ember::TiXmlElement* bindingsElem = rootElem->FirstChildElement(  "bindings" );
           bindingsElem != 0; bindingsElem = bindingsElem->NextSiblingElement(   ) )
           {
           for (  Ember::TiXmlElement* smElem = bindingsElem->FirstChildElement(  "binding" );
           smElem != 0; smElem = smElem->NextSiblingElement(   ) )
           {
           Carpenter::BuildingBlockBindingDefinition bindingDef;
          
           bindingDef.mBlock1Name = smElem->Attribute(  "block1" );
           bindingDef.mPoint1Name = smElem->Attribute(  "point1" );
           bindingDef.mBlock2Name = smElem->Attribute(  "block2" );
           bindingDef.mPoint2Name = smElem->Attribute(  "point2" );
          
          
           //HACK
           size_t slashposition;
           slashposition = bindingDef.mPoint1Name.find(  '/' );
           bindingDef.mPair1Name = bindingDef.mPoint1Name.substr(  0,   slashposition );
           bindingDef.mPoint1Name = bindingDef.mPoint1Name.substr(  slashposition + 1,   bindingDef.mPoint1Name.size(   ) - slashposition );
          
           slashposition = bindingDef.mPoint2Name.find(  '/' );
           bindingDef.mPair2Name = bindingDef.mPoint2Name.substr(  0,   slashposition );
           bindingDef.mPoint2Name = bindingDef.mPoint2Name.substr(  slashposition + 1,   bindingDef.mPoint2Name.size(   ) - slashposition );
          
           blueprint->addBinding(  bindingDef );
          
           }
           }
          
           return blueprint;
          
          
          }
          
     408  void XMLJesusSerializer::saveBlueprintToFile(  Carpenter::BluePrint* blueprint,   const std::string& filename )
          {
           saveBlueprintToFile(  blueprint,   filename,   blueprint->getName(   ) );
          }
          
     413  void XMLJesusSerializer::saveBlueprintToFile(  Carpenter::BluePrint* blueprint,   const std::string& filename,   const std::string& name )
          {
           if (  filename == "" || filename == "." || filename == ".." ) {
           return;
           }
          
           Ember::TiXmlDocument _XMLDoc;
          
          
          
          
           try
           {
           //make sure the directory exists
           std::string dir = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ) + "/carpenter/blueprints";
          
           oslink::directory osdir(  dir );
          
           if (  !osdir ) {
          #ifdef __WIN32__
           mkdir(  (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ) + "carpenter" ).c_str(   ) );
           mkdir(  dir.c_str(   ) );
          #else
           mkdir(  (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ) + "carpenter" ).c_str(   ),   S_IRWXU );
           mkdir(  dir.c_str(   ),   S_IRWXU );
          #endif
           }
          
          
          
          
          
           Ember::TiXmlElement elem(  "blueprint" );
           elem.SetAttribute(  "startingblock",   blueprint->getStartingBlock(   )->getName(   ).c_str(   ) );
           elem.SetAttribute(  "name",   name.c_str(   ) );
          
           Ember::TiXmlElement buildingBlocksElem(  "buildingblocks" );
           //now iterate over all building blocks
          
           const std::vector< Carpenter::BuildingBlock*> bblocks = blueprint->getAttachedBlocks(   );
          
           std::vector< Carpenter::BuildingBlock*>::const_iterator I = bblocks.begin(   );
           std::vector< Carpenter::BuildingBlock*>::const_iterator I_end = bblocks.end(   );
          
           for (  ;I != I_end; ++I ) {
           Ember::TiXmlElement buildingBlockElem(  "buildingblock" );
           buildingBlockElem.SetAttribute(  "blocktype",   (  *I )->getBuildingBlockSpec(   )->getName(   ).c_str(   )  );
           buildingBlockElem.SetAttribute(  "name",   (  *I )->getName(   ).c_str(   ) );
           buildingBlocksElem.InsertEndChild(  buildingBlockElem );
           }
          
          
           //iterate over the bindings
           Ember::TiXmlElement bindingsElem(  "bindings" );
          
           const std::list< Carpenter::BuildingBlockBinding>* bindings = blueprint->getBindings(   );
           std::list< Carpenter::BuildingBlockBinding>::const_iterator J = bindings->begin(   );
           std::list< Carpenter::BuildingBlockBinding>::const_iterator J_end = bindings->end(   );
          
           for (  ;J != J_end; ++J ) {
           Ember::TiXmlElement bindingElem(  "binding" );
           bindingElem.SetAttribute(  "block1",   (  *J ).getBlock1(   )->getName(   ).c_str(   ) );
           bindingElem.SetAttribute(  "block2",   (  *J ).getBlock2(   )->getName(   ).c_str(   ) );
           const Carpenter::AttachPoint* point1 = (  *J ).getAttachPoint1(   );
           std::string point1Name = point1->getAttachPair(   )->getName(   ) + "/" + point1->getName(   );
           const Carpenter::AttachPoint* point2 = (  *J ).getAttachPoint2(   );
           std::string point2Name = point2->getAttachPair(   )->getName(   ) + "/" + point2->getName(   );
           bindingElem.SetAttribute(  "point1",   point1Name.c_str(   ) );
           bindingElem.SetAttribute(  "point2",   point2Name.c_str(   ) );
          
           bindingsElem.InsertEndChild(  bindingElem );
          
           }
          
           elem.InsertEndChild(  bindingsElem );
           elem.InsertEndChild(  buildingBlocksElem );
           _XMLDoc.InsertEndChild(  elem );
          
           _XMLDoc.SaveFile(  filename.c_str(   ) );
           }
           catch (  ... )
           {
           S_LOG_FAILURE(  "An error occurred creating the document."  );
           }
          
          
          
          
          }
          
          
          
          };

./components/ogre/jesus/XMLJesusSerializer.h

       1  //
          // C++ Interface: XMLJesusSerializer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREXMLJESUSSERIALIZER_H
          #define EMBEROGREXMLJESUSSERIALIZER_H
          
          #include "../OgreIncludes.h"
          #include "framework/tinyxml/tinyxml.h"
          
          namespace Carpenter
          {
      31   class BluePrint;
      32   class AttachPoint;
      33   class BlockSpec;
          };
          
          namespace EmberOgre {
          
      38  class Jesus;
          /**
          @author Erik Hjortsberg
          */
      42  class XMLJesusSerializer{
          public:
      44   XMLJesusSerializer(  Jesus* jesus );
          
      46   ~XMLJesusSerializer(   );
          
           /**
           * Loads BlockSpecs from a xml file
           * @param filename
           * @return
           */
      53   bool loadBlockSpec(  const std::string & filename );
          
          
           /**
           * Loads BuildingBlockSpecDefinitions from a xml file.
           * @param filename
           * @return
           */
      61   bool loadBuildingBlockSpecDefinition(  const std::string& filename );
          
          
           /**
           * Loads ModelBlockMappings from a xml file.
           * @param filename
           * @return
           */
      69   bool loadModelBlockMapping(  const std::string& filename );
          
          
           /**
           * Loads and creates an instance of a BluePrint from a xml file.
           * Note that you have to call compile(   ) on the resulting BluePrint to get it to arrange the BuildingBlocks.
           * NOTE: this should perhaps be moved to another class
           * @param filename
           * @return
           */
      79   Carpenter::BluePrint* loadBlueprint(  const std::string& filename );
          
           /**
           * Saves the supplied blueprint to a xml filename
           * @param blueprint
           * @param filename
           * @return
           */
      87   void saveBlueprintToFile(  Carpenter::BluePrint* blueprint,   const std::string& filename );
      88   void saveBlueprintToFile(  Carpenter::BluePrint* blueprint,   const std::string& filename,   const std::string& name );
          
          private:
      91   Jesus* mJesus;
          
      93   Carpenter::AttachPoint* readAttachPoint(  Ember::TiXmlElement* elem );
      94   void readAttachPairs(  Carpenter::BlockSpec *blockSpec,   Ember::TiXmlElement* parentElem );
          
           /**
           * Utility method to fill the supplied WFMath object (  for example a Vector or a Point ) with xyz values from the Xerces Node
           * @param
           * @param
           */
           template <typename T> void fillFromElement(  Ember::TiXmlElement* ,   T&  );
          
          
          };
          
          };
          
          #endif

./components/ogre/manipulation/EntityMoveAdapter.cpp

       1  //
          // C++ Implementation: EntityMoveAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityMoveAdapter.h"
          #include "../EmberOgre.h"
          #include "IEntityMoveBridge.h"
          #include "EntityMoveManager.h"
          #include "../AvatarCamera.h"
          #include "../GUIManager.h"
          #include "../MathConverter.h"
          //#include "../input/Input.h"
          
          using namespace WFMath;
          
          namespace EmberOgre {
          
      36  EntityMoveAdapter::EntityMoveAdapter(  EntityMoveManager* manager )
          : mBridge(  0 ),   mMovementSpeed(  10 ),   mManager(  manager )
          {}
          
      40  EntityMoveAdapter::~EntityMoveAdapter(   )
          {}
          
      43  void EntityMoveAdapter::finalizeMovement(   )
          {
           mBridge->finalizeMovement(   );
           removeAdapter(   );
           mManager->EventFinishedMoving.emit(   );
          }
          
      50  void EntityMoveAdapter::cancelMovement(   )
          {
           mBridge->cancelMovement(   );
           removeAdapter(   );
           mManager->EventCancelledMoving.emit(   );
          }
          
      57  bool EntityMoveAdapter::injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse )
          {
           ///this will move the entity instead of the mouse
          
           Vector<3> direction;
           direction.zero(   );
           direction.x(   ) = -motion.xRelativeMovement;
           direction.y(   ) = motion.yRelativeMovement;
           direction = direction * mMovementSpeed;
           ///hard coded to allow the shift button to increase the speed
           if (  Input::getSingleton(   ).isKeyDown(  SDLK_RSHIFT ) || Input::getSingleton(   ).isKeyDown(  SDLK_LSHIFT ) ) {
           direction = direction * 5;
           }
          
           ///move it relative to the camera
           direction = direction.rotate(  Ogre2Atlas(  EmberOgre::getSingleton(   ).getMainCamera(   )->getOrientation(   ) ) );
          
           mBridge->move(   direction );
          
           ///we don't want to move the cursor
           freezeMouse = true;
          
           return false;
          }
          
      82  bool EntityMoveAdapter::injectMouseButtonUp(  const Input::MouseButton& button )
          {
           if (  button == Input::MouseButtonLeft )
           {
           finalizeMovement(   );
           }
           else if(  button == Input::MouseButtonRight )
           {
           }
           else
           {
           return false;
           }
          
           return false;
          }
          
      99  bool EntityMoveAdapter::injectMouseButtonDown(  const Input::MouseButton& button )
          {
           if (  button == Input::MouseButtonLeft )
           {
           }
           else if(  button == Input::MouseButtonRight )
           {
          
           }
           else if(  button == Input::MouseButtonMiddle )
           {
          
           }
           else if(  button == Input::MouseWheelUp )
           {
           int movementDegrees = 10;
           if (  GUIManager::getSingleton(   ).getInput(   ).isKeyDown(  SDLK_LSHIFT ) ||GUIManager::getSingleton(   ).getInput(   ).isKeyDown(  SDLK_RSHIFT ) ) {
           movementDegrees = 1;
           }
           mBridge->yaw(  movementDegrees );
           }
           else if(  button == Input::MouseWheelDown )
           {
           int movementDegrees = 10;
           if (  GUIManager::getSingleton(   ).getInput(   ).isKeyDown(  SDLK_LSHIFT ) ||GUIManager::getSingleton(   ).getInput(   ).isKeyDown(  SDLK_RSHIFT ) ) {
           movementDegrees = 1;
           }
           mBridge->yaw(  -movementDegrees );
           }
          
           return false;
          }
          
     132  bool EntityMoveAdapter::injectChar(  char character )
          {
           return true;
          }
          
     137  bool EntityMoveAdapter::injectKeyDown(  const SDLKey& key )
          {
           return true;
          }
          
     142  bool EntityMoveAdapter::injectKeyUp(  const SDLKey& key )
          {
           if (  key == SDLK_ESCAPE ) {
           cancelMovement(   );
           return false;
           }
           return true;
          }
          
     151  void EntityMoveAdapter::attachToBridge(  IEntityMoveBridge* bridge )
          {
           mBridge = bridge;
           addAdapter(   );
          }
          
     157  void EntityMoveAdapter::detach(   )
          {
           delete mBridge;
           mBridge = 0;
           removeAdapter(   );
          }
          
     164  void EntityMoveAdapter::removeAdapter(   )
          {
           GUIManager::getSingleton(   ).getInput(   ).removeAdapter(  this );
          }
          
     169  void EntityMoveAdapter::addAdapter(   )
          {
           GUIManager::getSingleton(   ).getInput(   ).addAdapter(  this );
          }
          
          }

./components/ogre/manipulation/EntityMoveAdapter.h

       1  //
          // C++ Interface: EntityMoveAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREENTITYMOVEADAPTER_H
          #define EMBEROGREENTITYMOVEADAPTER_H
          
          #include "../EmberOgrePrerequisites.h"
          #include "../input/IInputAdapter.h"
          
          
          namespace EmberOgre {
          
      32  class IEntityMoveBridge;
      33  class EntityMoveManager;
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
           @author Lennart Sauerbeck
          
           Provides an adapter for moving objects in the world.
          */
      41  class EntityMoveAdapter : public IInputAdapter {
          public:
          
      44   EntityMoveAdapter(  EntityMoveManager* manager );
      45   ~EntityMoveAdapter(   );
          
      47   virtual bool injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse );
      48   virtual bool injectMouseButtonUp(  const Input::MouseButton& button );
      49   virtual bool injectMouseButtonDown(  const Input::MouseButton& button );
      50   virtual bool injectChar(  char character );
      51   virtual bool injectKeyDown(  const SDLKey& key );
      52   virtual bool injectKeyUp(  const SDLKey& key );
          
           /**
           * Attaches the adapter to the suppied IEntityMoveBridge,   allowing it to be moved. This will activate the adapter.
           * @param bridge
           */
      58   void attachToBridge(  IEntityMoveBridge* bridge );
          
           /**
           * Detaches the adapter from the current bridge. This will deactive the adapter.
           */
      63   void detach(   );
          
          private:
      66   void removeAdapter(   );
      67   void addAdapter(   );
          
           /**
           * Cancels the current movement,   returning the IEntityMoveBridge to it's original place.
           */
      72   void cancelMovement(   );
           /**
           * Finalizes the current movement,   sending updates for the IEntityMoveBridge to the server.
           */
      76   void finalizeMovement(   );
          
          
      79   IEntityMoveBridge* mBridge;
           float mMovementSpeed;
      81   EntityMoveManager* mManager;
          
          };
          
          }
          
          #endif

./components/ogre/manipulation/EntityMoveAdjuster.cpp

       1  //
          // C++ Implementation: EntityMoveAdjuster
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityMoveAdjuster.h"
          #include "../EmberEntity.h"
          #include "EntityMoveManager.h"
          
          namespace EmberOgre {
          
      29  EntityMoveAdjustmentInstance::EntityMoveAdjustmentInstance(  EntityMoveAdjuster* moveAdjuster,   EmberEntity* entity )
          : mEntity(  entity ),   mTimeout(  1500 ),   mMoveAdjuster(  moveAdjuster )
          {
           mTimeout.Expired.connect(  sigc::mem_fun(  this,   &EntityMoveAdjustmentInstance::timout_Expired ) );
          }
          
      35  void EntityMoveAdjustmentInstance::timout_Expired(   )
          {
           mEntity->synchronizeWithServer(   );
           mMoveAdjuster->removeInstance(  this );
          }
          
          
      42  EntityMoveAdjuster::EntityMoveAdjuster(  EntityMoveManager* manager ) : mManager(  manager )
          {
           mManager->EventStartMoving.connect(  sigc::mem_fun(  *this,   &EntityMoveAdjuster::EntityMoveManager_StartMoving ) );
           mManager->EventFinishedMoving.connect(  sigc::mem_fun(  *this,   &EntityMoveAdjuster::EntityMoveManager_FinishedMoving ) );
           mManager->EventCancelledMoving.connect(  sigc::mem_fun(  *this,   &EntityMoveAdjuster::EntityMoveManager_CancelledMoving ) );
          
          }
          
      50  void EntityMoveAdjuster::removeInstance(  EntityMoveAdjustmentInstance* instance )
          {
           MoveAdjustmentInstanceStore::iterator I = std::find(  mInstances.begin(   ),   mInstances.end(   ),   instance );
           delete *I;
           mInstances.erase(  I );
          }
          
      57  void EntityMoveAdjuster::EntityMoveManager_FinishedMoving(   )
          {
           if (  mActiveEntity ) {
           EntityMoveAdjustmentInstance* instance = new EntityMoveAdjustmentInstance(  this,   mActiveEntity );
           mInstances.push_back(  instance );
           mActiveEntity = 0;
           }
          }
          
      66  void EntityMoveAdjuster::EntityMoveManager_CancelledMoving(   )
          {
           mActiveEntity = 0;
          }
          
      71  void EntityMoveAdjuster::EntityMoveManager_StartMoving(  EmberEntity* entity )
          {
           mActiveEntity = entity;
          }
          
          }

./components/ogre/manipulation/EntityMoveAdjuster.h

       1  //
          // C++ Interface: EntityMoveAdjuster
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREENTITYMOVEADJUSTER_H
          #define EMBEROGREENTITYMOVEADJUSTER_H
          
          #include <Eris/Timeout.h>
          
          namespace EmberOgre {
          
      30  class EmberEntity;
      31  class EntityMoveAdjuster;
      32  class EntityMoveManager;
          
          /**
           @see EntityMoveAdjuster
           An instance of a adjustment operation. After time out,   the entity encapsuled by this instance will be synchronized with the server.
          */
      38  class EntityMoveAdjustmentInstance
          {
          public:
           /**
           * Default ctor.
           * @param moveAdjuster
           * @param entity
           * @return
           */
      47   EntityMoveAdjustmentInstance(  EntityMoveAdjuster* moveAdjuster,   EmberEntity* entity );
          
          private:
           /**
           The actual entity.
           */
      53   EmberEntity* mEntity;
          
           /**
           The timeout object which provides timeout functionality.
           */
      58   Eris::Timeout mTimeout;
          
           /**
           * Called when the time has expired.
           */
      63   void timout_Expired(   );
          
           /**
           A reference to the owner object.
           */
      68   EntityMoveAdjuster* mMoveAdjuster;
          };
          
          /**
          This class is responsible for adjusting moved entities to their correct place.
          Basically,   when an entity is moved the client sends the updates to the server,   but it's not clear at that time whether the movement is allowed. This can only be seen by waiting to see whether the movement went through,   i.e. if the entity was updated.
          So what this class does,   together with EntityMoveAdjustmentInstance,   waiting a couple of milleseconds and then telling the entity that was moved to synchronize with the server. If the movement didn't go through,   this will lead to the entity "snapping" back to the original position. If it did go through nothing will happen.
          */
      76  class EntityMoveAdjuster
          {
      78  friend class EntityMoveAdjustmentInstance;
          public:
           /**
           * Default ctor.
           * @param manager
           * @return
           */
      85   EntityMoveAdjuster(  EntityMoveManager* manager );
          private:
           typedef std::vector<EntityMoveAdjustmentInstance*> MoveAdjustmentInstanceStore;
          
           /**
           Holds all instances of EntityMoveAdjustmentInstance.
           */
      92   MoveAdjustmentInstanceStore mInstances;
          
           /**
           * Removes the supplied instance from the list of instances.
           * @param
           */
      98   void removeInstance(  EntityMoveAdjustmentInstance* );
          
           /**
           * When movement has finished,   i.e. something has been moved,   create an EntityMoveAdjustmentInstance which will update the entity at expiration.
           */
     103   void EntityMoveManager_FinishedMoving(   );
          
           /**
           * When movement has been cancelled,   there's no need to create any EntityMoveAdjustmentInstance,   but we want to clean up.
           */
     108   void EntityMoveManager_CancelledMoving(   );
          
           /**
           * When movement starts,   register the entity that is being moved.
           * @param entity
           */
     114   void EntityMoveManager_StartMoving(  EmberEntity* entity );
          
           /**
           The entity that is being moved.
           */
     119   EmberEntity* mActiveEntity;
          
           /**
           A reference to the manager.
           */
     124   EntityMoveManager* mManager;
          };
          
          }
          
          #endif

./components/ogre/manipulation/EntityMoveManager.cpp

          //
          // C++ Implementation: EntityMoveManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "EntityMoveManager.h"
          #include "EntityMoveAdapter.h"
          #include "EntityMover.h"
          #include "../GUIManager.h"
          #include "framework/Tokeniser.h"
          #include "framework/ConsoleBackend.h"
          #include "../EmberOgre.h"
          #include "../EmberEntity.h"
          
          
          
          namespace EmberOgre {
          
          
      38  EntityMoveManager::EntityMoveManager(   ) :
      39  Move(  "move",   this,   "Moves an entity." ),   mMoveAdapter(  this ),   mAdjuster(  this )
          {
           GUIManager::getSingleton(   ).EventEntityAction.connect(  sigc::mem_fun(  *this,   &EntityMoveManager::GuiManager_EntityAction ) );
          }
          
          
          
      46  void EntityMoveManager::GuiManager_EntityAction(  const std::string& action,   EmberEntity* entity ) {
          
           if (  action == "move" ) {
           startMove(  entity );
           }
          }
          
      53  void EntityMoveManager::startMove(  EmberEntity* entity )
          {
           ///disallow moving of the root entity
           if (  entity->getLocation(   ) ) {
           EntityMover* mover = new EntityMover(  entity );
           mMoveAdapter.attachToBridge(  mover );
           EventStartMoving.emit(  entity );
           }
          }
          
      63  void EntityMoveManager::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  Move == command )
           {
           //the first argument must be a valid entity id
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string entityId = tokeniser.nextToken(   );
           if (  entityId != "" ) {
           EmberEntity* entity = EmberOgre::getSingleton(   ).getEntity(  entityId );
           if (  entity != 0 ) {
           startMove(  entity );
           }
           } else {
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  "You must specifify a valid entity id to move." );
           }
          
           }
          }
          
          }

./components/ogre/manipulation/EntityMoveManager.h

       1  //
          // C++ Interface: EntityMoveManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #ifndef EMBEROGREENTITYMOVEMANAGER_H
          #define EMBEROGREENTITYMOVEMANAGER_H
          
          #include "../EmberOgrePrerequisites.h"
          #include "framework/ConsoleObject.h"
          #include "EntityMoveAdapter.h"
          #include "EntityMoveAdjuster.h"
          
          namespace EmberOgre {
          
      34  class EmberEntity;
      35  class EntityMoveManager;
          
          
          /**
          Responsible for allowing movement of entities in the world by the user.
          */
      41  class EntityMoveManager : public Ember::ConsoleObject,   public sigc::trackable
          {
          public:
      44   EntityMoveManager(   );
          
      46   const Ember::ConsoleCommandWrapper Move;
          
           /**
           * Starts moving of an entity.
           * @param entity
           */
      52   void startMove(  EmberEntity* entity );
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
      59   virtual void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           * Emitted when the movement of an entity starts
           */
      64   sigc::signal<void,   EmberEntity*> EventStartMoving;
          
           /**
           * Emitted when the movement of an entity has finished.
           */
      69   sigc::signal<void> EventFinishedMoving;
          
           /**
           * Emitted when the movement of an entity has been cancelled.
           */
      74   sigc::signal<void> EventCancelledMoving;
          
          protected:
           /**
           Main adapter which will intercept mouse and keyboard input to allow for movement of an entity.
           */
      80   EntityMoveAdapter mMoveAdapter;
          
          
           /**
           * Listen for entityActions from the gui (  "move" ).
           * @param action
           * @param entity
           */
      88   void GuiManager_EntityAction(  const std::string& action,   EmberEntity* entity );
          
           /**
           Responsible for making sure that entities that cannot be moved are returned to their correct place.
           */
      93   EntityMoveAdjuster mAdjuster;
          
          };
          
          }
          
          #endif

./components/ogre/manipulation/EntityMover.cpp

       1  //
          // C++ Implementation: EntityMover
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityMover.h"
          #include "services/EmberServices.h"
          #include "services/server/ServerService.h"
          #include "../EmberEntity.h"
          #include "../MathConverter.h"
          
          
          namespace EmberOgre {
          
      32  EntityMover::EntityMover(  EmberEntity* entity ) : mEntity(  entity )
          {
          }
          
      36  const WFMath::Quaternion& EntityMover::getOrientation(   ) const
          {
           mOrientation = Ogre2Atlas(  mEntity->getSceneNode(   )->getOrientation(   ) );
           return mOrientation;
          }
          
      42  const WFMath::Point<3>& EntityMover::getPosition(   ) const
          {
           mPosition = Ogre2Atlas(  mEntity->getSceneNode(   )->getPosition(   ) );
           return mPosition;
          }
      47  void EntityMover::setPosition(  const WFMath::Point<3>& position )
          {
           if (  position.isValid(   ) ) {
           mEntity->getSceneNode(   )->setPosition(  Atlas2Ogre(  position ) );
           ///adjust it so that it moves according to the ground for example
           mEntity->adjustPosition(  mEntity->getSceneNode(   )->getPosition(   ) );
           }
          }
      55  void EntityMover::move(  const WFMath::Vector<3> directionVector )
          {
           if (  directionVector.isValid(   ) ) {
           mEntity->getSceneNode(   )->translate(  Atlas2Ogre(  directionVector ) );
           ///adjust it so that it moves according to the ground for example
           mEntity->adjustPosition(  mEntity->getSceneNode(   )->getPosition(   ) );
           }
          }
      63  void EntityMover::setRotation (  int axis,   WFMath::CoordType angle )
          {
           ///not implemented yet
          }
          
      68  void EntityMover::yaw(  WFMath::CoordType angle )
          {
           mEntity->getSceneNode(   )->yaw(  Ogre::Degree(  angle ) );
          }
          
      73  void EntityMover::setOrientation(  const WFMath::Quaternion& rotation )
          {
           if (  rotation.isValid(   ) ) {
           mEntity->getSceneNode(   )->setOrientation(  Atlas2Ogre(  rotation ) );
           }
          }
          
      80  void EntityMover::finalizeMovement(   )
          {
           if (  mEntity->getLocation(   ) ) {
           ///send to server
           Ember::EmberServices::getSingleton(   ).getServerService(   )->place(  mEntity,   mEntity->getLocation(   ),   Ogre2Atlas(  mEntity->getSceneNode(   )->getPosition(   ) ),   Ogre2Atlas(  mEntity->getSceneNode(   )->getOrientation(   ) ) );
           }
          
          }
      88  void EntityMover::cancelMovement(   )
          {
           mEntity->synchronizeWithServer(   );
          }
          
          
          }

./components/ogre/manipulation/EntityMover.h

       1  //
          // C++ Interface: EntityMover
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREENTITYMOVER_H
          #define EMBEROGREENTITYMOVER_H
          
          #include "../EmberOgrePrerequisites.h"
          #include "IEntityMoveBridge.h"
          #include <wfmath/point.h>
          
          namespace EmberOgre {
          
      32  class EmberEntity;
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          
           An implementation of IEntityMoveBridge which allows for EmberEntity instances to be moved.
          */
      39  class EntityMover : public IEntityMoveBridge
          {
          public:
          
      43   EntityMover(  EmberEntity* entity );
      44   virtual ~EntityMover(   ) {}
          
      46   virtual const WFMath::Quaternion& getOrientation(   ) const;
      47   virtual const WFMath::Point<3>& getPosition(   ) const;
      48   virtual void setPosition(  const WFMath::Point<3>& position );
      49   virtual void move(  const WFMath::Vector<3> directionVector );
      50   virtual void setRotation (  int axis,   WFMath::CoordType angle );
      51   virtual void setOrientation(  const WFMath::Quaternion& rotation );
      52   virtual void yaw(  WFMath::CoordType angle );
          
      54   virtual void finalizeMovement(   );
      55   virtual void cancelMovement(   );
          
          private:
          
      59   EmberEntity* mEntity;
           mutable WFMath::Quaternion mOrientation;
           mutable WFMath::Point<3> mPosition;
          };
          
          }
          
          #endif

./components/ogre/manipulation/IEntityMoveBridge.h

       1  //
          // C++ Interface: IEntityMoveBridge
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREIENTITYMOVEBRIDGE_H
          #define EMBEROGREIENTITYMOVEBRIDGE_H
          
          #include "../EmberOgrePrerequisites.h"
          #include <wfmath/quaternion.h>
          
          namespace EmberOgre {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      34  class IEntityMoveBridge
          {
          public:
          
      38   virtual ~IEntityMoveBridge(   ) {}
          
      40   virtual const WFMath::Quaternion& getOrientation(   ) const = 0;
      41   virtual const WFMath::Point<3>& getPosition(   ) const = 0;
      42   virtual void setPosition(  const WFMath::Point<3>& position ) = 0;
      43   virtual void move(  const WFMath::Vector<3> directionVector ) = 0;
      44   virtual void setRotation (  int axis,   WFMath::CoordType angle ) = 0;
      45   virtual void setOrientation(  const WFMath::Quaternion& rotation ) = 0;
      46   virtual void yaw(  WFMath::CoordType angle ) = 0;
          
      48   virtual void finalizeMovement(   ) = 0;
      49   virtual void cancelMovement(   ) = 0;
          
          };
          
          }
          
          #endif

./components/ogre/manipulation/MaterialEditor.cpp

          //
          // C++ Implementation: MaterialEditor
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "MaterialEditor.h"
          #include "framework/Tokeniser.h"
          
          namespace EmberOgre {
          
      28  MaterialEditor::MaterialEditor(   )
          : AlterMaterial(  "alter_material",   this,   "Alters a material. Usage: <material name> <technique index> <pass index> [<tecture unit index>] <property> <value>" )
          {
          }
          
          
          MaterialEditor::~MaterialEditor(   )
          {
          }
          
          void MaterialEditor::runCommand(  const std::string &command,   const std::string &args )
          {
          
           if (  AlterMaterial == command ) {
           try {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
          
           std::vector<std::string> tokens;
           std::string token;
           while (  (  token = tokeniser.nextToken(   ) ) != "" ) {
           tokens.push_back(  token );
           }
          
           std::string materialName = tokens[0];
          
           Ogre::MaterialPtr materialPtr = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton(   ).getByName(  materialName ) );
           if (  !materialPtr.isNull(   ) ) {
           std::string techniqueIndexString = tokens[1];
           if (  techniqueIndexString != "" ) {
           int techniqueIndex = Ogre::StringConverter::parseInt(  techniqueIndexString );
           Ogre::Technique* technique = materialPtr->getTechnique(  techniqueIndex );
           if (  technique ) {
           std::string passIndexString = tokens[2];
           if (  passIndexString != "" ) {
           int passIndex = Ogre::StringConverter::parseInt(  passIndexString );
           Ogre::Pass* pass = technique->getPass(  passIndex );
           ///is texture unit specified
           if (  tokens.size(   ) == 6 ) {
           std::string textureUnitIndexString = tokens[3];
           std::string property = tokens[4];
           std::string value = tokens[5];
          
           int textureUnitIndex = Ogre::StringConverter::parseInt(  textureUnitIndexString );
          
           Ogre::TextureUnitState* textureUnit = pass->getTextureUnitState(  textureUnitIndex );
           if (  textureUnit ) {
          
           }
           } else {
           std::string property = tokens[3];
           std::string value = tokens[4];
           if (  property == "alpha_rejection" ) {
           pass->setAlphaRejectValue(  Ogre::StringConverter::parseInt(  value )  );
           }
           }
           }
           }
           }
           }
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_WARNING(  "Error when altering material. \n" << ex.getFullDescription(   ) );
           } catch (  ... ) {
           S_LOG_WARNING(  "Error when altering material." );
           }
           }
          }
          
          }

./components/ogre/manipulation/MaterialEditor.h

       1  //
          // C++ Interface: MaterialEditor
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREMATERIALEDITOR_H
          #define EMBEROGREMATERIALEDITOR_H
          
          #include <sigc++/trackable.h>
          
          #include "../EmberOgrePrerequisites.h"
          
          #include "framework/ConsoleObject.h"
          
          namespace EmberOgre {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      37  class MaterialEditor :
      38  public sigc::trackable,  
      39  public Ember::ConsoleObject
          {
          public:
      42   MaterialEditor(   );
          
      44   ~MaterialEditor(   );
          
           //updateMaterial(  const std::string& materialName,   const std::string&  );
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
      52   virtual void runCommand(  const std::string &command,   const std::string &args );
          
      54   const Ember::ConsoleCommandWrapper AlterMaterial;
          
          };
          
          }
          
          #endif

./components/ogre/model/Action.cpp

       1  //
          // C++ Implementation: Action
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Action.h"
          
          namespace EmberOgre {
          
          
          
          }

./components/ogre/model/Action.h

       1  //
          // C++ Interface: Action
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREACTION_H
          #define EMBEROGREACTION_H
          #include "AnimationSet.h"
          namespace EmberOgre {
          namespace Model {
          
          /**
          @author Erik Hjortsberg
          */
      32  class Action
          {
          public:
      35   inline AnimationSet& getAnimations(   ) { return mAnimations; }
      36   inline void setName(  const std::string& name ) { mName = name; }
      37   inline const std::string& getName(   ) { return mName; }
          
          
          protected:
      41   std::string mName;
      42   AnimationSet mAnimations;
          };
          
          }
          }
          #endif

./components/ogre/model/AnimationSet.cpp

       1  //
          // C++ Implementation: AnimationSet
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AnimationSet.h"
          
          namespace EmberOgre {
          namespace Model {
          
          
      29  AnimationSet::AnimationSet(   ) : mAccumulatedTime(  0 ),   mCurrentAnimationSetIndex(  0 ),   mSpeed(  1.0 )
          {
          }
          
      33  AnimationSet::~AnimationSet(   )
          {
          /* for (  AnimationStore::iterator I = mAnimations.begin(   ); I != mAnimations.end(   ); ++I ) {
           delete *I;
           }*/
          }
          
      40  void AnimationSet::addTime(  Ogre::Real timeSlice )
          {
           static bool discardThis;
           addTime(  timeSlice,   discardThis );
          }
          
          
      47  void AnimationSet::addTime(  Ogre::Real timeSlice,   bool& continueAnimation )
          {
           if (  mAnimations.size(   ) > 0 ) {
           continueAnimation = true;
           Animation* animation = &mAnimations[mCurrentAnimationSetIndex];
           float animationLength = animation->getLengthOfOneIteration(   );
           Ogre::Real calculatedTime = timeSlice * mSpeed;
           if (  animationLength == 0 ) {
           ///Ogre will throw an assert exception if an animtion with zero length is activated
           } else {
           ///see if we've done enough iterations to either advance to the next animation,   or the mark this animation as done
           if (  fabs(  mAccumulatedTime ) >= animation->getLengthOfOneIteration(   ) * animation->getIterations(   ) ) {
           animation->setEnabled(  false );
           mAccumulatedTime = 0;
           if (  mAnimations.size(   ) > (  mCurrentAnimationSetIndex + 1 ) ) {
           ++mCurrentAnimationSetIndex;
           continueAnimation = true;
           } else {
           mCurrentAnimationSetIndex = 0;
           continueAnimation = false;
           }
           animation = &mAnimations[mCurrentAnimationSetIndex];
           animation->setTime(  0 );
           }
          
           Ogre::Real calculatedTime = timeSlice * mSpeed;
           animation->setEnabled(  true );
           animation->addTime(  calculatedTime );
           }
           mAccumulatedTime += calculatedTime;
           }
          
          }
          
      81  void AnimationSet::reset(   )
          {
           if (  mAnimations.size(   ) > 0 ) {
           Animation& animation = mAnimations[mCurrentAnimationSetIndex];
           animation.setEnabled(  false );
           }
           mCurrentAnimationSetIndex = 0;
           mAccumulatedTime = 0;
          }
          
      91  void AnimationSet::addAnimation(  Animation animation )
          {
           mAnimations.push_back(  animation );
          }
          
          
      97  Animation::Animation(  int iterations ) : mIterationLength(  0 ),   mIterations(  iterations ) {}
          
      99  void Animation::addAnimationPart(  AnimationPart part )
          {
           mAnimationParts.push_back(  part );
           mIterationLength = std::max<Ogre::Real>(  part.state->getLength(   ),   mIterationLength );
          }
          
     105  void Animation::addTime(  Ogre::Real timeSlice )
          {
           AnimationPartSet::iterator I = mAnimationParts.begin(   );
           for (  ; I != mAnimationParts.end(   ); ++I ) {
           ///we'll get an assert error if we try to add time to an animation with zero length
           if (  I->state->getLength(   ) != 0 ) {
           I->state->addTime(  timeSlice );
           }
           }
          }
          
     116  void Animation::setTime(  Ogre::Real time )
          {
           AnimationPartSet::iterator I = mAnimationParts.begin(   );
           for (  ; I != mAnimationParts.end(   ); ++I ) {
           ///we'll get an assert error if we try to add time to an animation with zero length
           if (  I->state->getLength(   ) != 0 ) {
           I->state->setTimePosition(  time );
           }
           }
          }
          
     127  void Animation::setEnabled(  bool state )
          {
           AnimationPartSet::iterator I = mAnimationParts.begin(   );
           for (  ; I != mAnimationParts.end(   ); ++I ) {
           ///we'll get an assert error if we try to enable an animation with zero length
           if (  I->state->getLength(   ) != 0 ) {
           if (  I->state->getEnabled(   ) != state ) {
           I->state->setEnabled(  state );
           }
           }
           }
          }
          
          // bool Animation::hasCompleted(   ) const
          // {
          // AnimationPartSet::const_iterator I = mAnimations.begin(   );
          // for (  ; I != mAnimations.end(   ); ++I ) {
          // if (  I->state->getTimePosition(   ) < I->state->getLength(   ) ) {
          // return false;
          // }
          // }
          // return true;
          // }
          
          }
          }

./components/ogre/model/AnimationSet.h

       1  //
          // C++ Interface: AnimationSet
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREANIMATIONSET_H
          #define EMBEROGREANIMATIONSET_H
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          // #include "ModelDefinition.h"
          
          namespace EmberOgre {
          namespace Model {
          
          struct AnimationPart
          {
           Ogre::AnimationState* state;
           Ogre::Real weight;
          };
          
      38  class Animation;
          
          typedef std::vector<AnimationPart> AnimationPartSet;
          typedef std::vector<Animation> AnimationStore;
          
          /**
          @author Erik Hjortsberg
          */
      46  class Animation
          {
          public:
      49   Animation(  int iterations );
      50   void addAnimationPart(  AnimationPart part );
      51   void setEnabled(  bool state );
          
      53   void addTime(  Ogre::Real timeSlice );
      54   void setTime(  Ogre::Real time );
          
      56   inline int getIterations(   ) const;
      57   inline Ogre::Real getLengthOfOneIteration(   ) const;
          protected:
      59   AnimationPartSet mAnimationParts;
      60   Ogre::Real mIterationLength;
           int mIterations;
          };
          
      64  class AnimationSet
          {
          public:
      67   AnimationSet(   );
      68   ~AnimationSet(   );
          
           /**
           * Adds time to the animation,   thus advancing it.
           * @param timeSlice The time to add in seconds.
           * @param continueAnimation Upon completion,   this is either true if the animation hasn't been completed yet,   or false if has completed.
           */
      75   void addTime(  Ogre::Real timeSlice,   bool& continueAnimation );
          
           /**
           * Adds time to the animation,   thus advancing it.
           * @param timeSlice The time to add in seconds.
           */
      81   void addTime(  Ogre::Real timeSlice );
          
           /**
           * Adds a single animation to this set.
           * @param animation
           */
      87   void addAnimation(  Animation animation );
          
          
           /**
           * Resets the animations to it's initial status,   also disabling it.
           */
      93   void reset(   );
          
           /**
           * returns true if all animation parts have been played
           * @return
           */
          // bool hasCompleted(   ) const;
          
     101   inline void setSpeed(  Ogre::Real speed );
     102   inline Ogre::Real getSpeed(   ) const;
          
          protected:
     105   Ogre::Real mAccumulatedTime;
     106   size_t mCurrentAnimationSetIndex;
     107   AnimationStore mAnimations;
     108   Ogre::Real mSpeed;
          };
          
     111  void AnimationSet::setSpeed(  Ogre::Real speed ) { mSpeed = speed;}
     112  Ogre::Real AnimationSet::getSpeed(   ) const { return mSpeed; }
          
          
     115  Ogre::Real Animation::getLengthOfOneIteration(   ) const
          {
           return mIterationLength;
          }
          
     120  inline int Animation::getIterations(   ) const
          {
           return mIterations;
          }
          
          }
          }
          
          #endif

./components/ogre/model/Model.cpp

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
           Copyright (  c ) 2005 The Cataclysmos Team
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          
          #include "Model.h"
          #include "SubModel.h"
          #include "SubModelPart.h"
          #include "AnimationSet.h"
          #include "Action.h"
          #include "ParticleSystem.h"
          #include "ParticleSystemBinding.h"
          
          
          #include "components/ogre/EmberOgre.h"
          #include "ModelDefinitionManager.h"
          #include "ModelDefinition.h"
          
          
          #include <OgreTagPoint.h>
          
          namespace EmberOgre {
          namespace Model {
          
          
          const Ogre::String Model::sMovableType = "Model";
          unsigned long Model::msAutoGenId = 0;
          
          // Model::Model(   )
          // : mScale(  0 )
          // ,   mRotation(  Ogre::Quaternion::IDENTITY )
          // ,   mSkeletonInstance(  0 )
          // // ,   mAnimationStateSet(  0 )
          // ,   mSkeletonOwnerEntity(  0 )
          // {
          // std::stringstream ss;
          // ss << "__AutogenModel_" << msAutoGenId++;
          // mName = ss.str(   );
          // mVisible = true;
          // }
          
      57  Model::Model(  const std::string& name )
          : Ogre::MovableObject(  name )
          ,   mSkeletonOwnerEntity(  0 )
          ,   mSkeletonInstance(  0 )
          ,   mScale(  0 )
          ,   mRotation(  Ogre::Quaternion::IDENTITY )
          ,   mAnimationStateSet(  0 )
          ,   mAttachPoints(  0 )
          {
           mVisible = true;
          }
      68  Model::~Model(   )
          {
           resetSubmodels(   );
           resetParticles(   );
           if (  !mMasterModel.isNull(   ) ) {
           mMasterModel->removeModelInstance(  this );
           }
          }
          
      77  void Model::reset(   )
          {
           Resetting.emit(   );
          // resetAnimations(   );
           resetSubmodels(   );
           resetParticles(   );
           mScale = 0;
           mRotation = Ogre::Quaternion::IDENTITY;
           mSkeletonInstance = 0;
          // ,   mAnimationStateSet(  0 )
           mSkeletonOwnerEntity = 0;
           mAttachPoints = std::auto_ptr<AttachPointWrapperStore>(  0 );
          
          }
          
      92  void Model::reload(   )
          {
          // resetAnimations(   );
          /* resetSubmodels(   );
           resetParticles(   ); */
           reset(   );
           createFromDefn(   );
           //if we are attached,   we have to nofify the new entities,   else they won't appear in the scene
           if (  mParentNode != 0 ) {
           Ogre::Node* theParent = mParentNode;
           _notifyAttached(  0,   false );
           _notifyAttached(  theParent,   mParentIsTagPoint );
           }
           Reloaded.emit(   );
          }
          
     108  bool Model::create(  const std::string& modelType )
          {
           if (  !mMasterModel.isNull(   ) && mMasterModel->isValid(   ) ) {
           S_LOG_WARNING(  "Trying to call create(  '" + modelType + "' ) on a Model instance that already have been created as a '" + mMasterModel->getName(   ) + "'." );
           return false;
           }
          
           static const Ogre::String groupName(  "ModelDefinitions" );
           //Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME;
           try {
           mMasterModel= ModelDefinitionManager::instance(   ).load(  modelType,   groupName );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "Could not load model of type " << modelType << " from group " << groupName << ".\nMessage: " << ex.getFullDescription(   ) );
           return false;
           }
           if (  false && !mMasterModel->isValid(   ) ) {
           S_LOG_FAILURE(  "Model of type " << modelType << " from group " << groupName << " is not valid." );
           return false;
           }
           else
           {
           mMasterModel->addModelInstance(  this );
           return true;
          /* bool success = createFromDefn(   );
           if (  !success ) {
           reset(   );
           }
           return success;*/
           }
          }
          
     139  void Model::_notifyManager(  Ogre::SceneManager* man )
          {
           Ogre::MovableObject::_notifyManager(  man );
           bool success = createFromDefn(   );
           if (  !success ) {
           reset(   );
           }
          }
          
          
          
     150  bool Model::createFromDefn(   )
          {
           // create instance of model from definition
           Ogre::SceneManager* sceneManager = _getManager(   );
           assert(  sceneManager );
           mScale=mMasterModel->mScale ;
           mRotation = mMasterModel->mRotation;
           setRenderingDistance(  mMasterModel->getRenderingDistance(   ) );
          
           std::vector<std::string> showPartVector;
          
          /* const SubModelDefinitionsStore&
           std::vector<ModelDefinition::SubModelDefinition>::iterator I_subModels = mMasterModel->mSubModels.begin(   );
           std::vector<ModelDefinition::SubModelDefinition>::iterator I_subModels_end = mMasterModel->mSubModels.end(   );*/
           S_LOG_VERBOSE(  "Number of submodels: " << mMasterModel->getSubModelDefinitions(   ).size(   ) );
          
           for (  SubModelDefinitionsStore::const_iterator I_subModels = mMasterModel->getSubModelDefinitions(   ).begin(   ); I_subModels != mMasterModel->getSubModelDefinitions(   ).end(   ); ++I_subModels )
           {
           std::string entityName = mName + "/" + (  *I_subModels )->getMeshName(   );
           try {
          // bool firstLoad = false;
          // Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton(   ).getByName(  (  *I_subModels ).Mesh );
          // if (  !mesh.isNull(   ) ) {
          // if (  !mesh->isLoaded(   ) ) {
          // firstLoad = true;
          // }
          // }
           Ogre::Entity* entity = sceneManager->createEntity(  entityName,   (  *I_subModels )->getMeshName(   ) );
           if (  mMasterModel->getRenderingDistance(   ) ) {
           entity->setRenderingDistance(  mMasterModel->getRenderingDistance(   ) );
           }
           entity->setNormaliseNormals(  true );
          
          // //for convenience,   if it's a new mesh,   check if there's a skeleton file in the same directory
          // //if so,   use that
          // // if (  !entity->getMesh(   )->isLoaded(   ) ) {
          // /* std::string fileName;
          // std::string path;
          // Ogre::StringUtil::splitFilename(  (  *I_subModels ).Mesh,   fileName,   path );*/
          // if (  firstLoad ) {
          // std::string meshname = (  *I_subModels ).Mesh.substr(  0,   (  *I_subModels ).Mesh.size(   ) - 5 );
          //
          // /* std::vector<Ogre::String> strings = Ogre::StringUtil::split(  (  *I_subModels ).Mesh,   ".mesh" );
          // if (  strings.size(   ) > 0 ) {
          // meshname = strings[0];*/
          // entity->getMesh(   )->setSkeletonName(  meshname + ".skeleton" );
          // }
          // // }
          //
          // // }
          
           SubModel* submodel = new SubModel(  entity );
           //Model::SubModelPartMapping* submodelPartMapping = new Model::SubModelPartMapping(   );
          
           for (  PartDefinitionsStore::const_iterator I_parts = (  *I_subModels )->getPartDefinitions(   ).begin(   ); I_parts != (  *I_subModels )->getPartDefinitions(   ).end(   ); ++I_parts ) {
           SubModelPart* part = submodel->createSubModelPart(  (  *I_parts )->getName(   ) );
           std::string groupName(  "" );
          
           if (  (  *I_parts )->getSubEntityDefinitions(   ).size(   ) > 0 )
           {
           for (  SubEntityDefinitionsStore::const_iterator I_subEntities = (  *I_parts )->getSubEntityDefinitions(   ).begin(   ); I_subEntities != (  *I_parts )->getSubEntityDefinitions(   ).end(   ); ++I_subEntities ) {
           Ogre::SubEntity* subEntity;
           //try with a submodelname first
           if (  (  *I_subEntities )->getSubEntityName(   ) != "" ) {
           subEntity = entity->getSubEntity(  (  *I_subEntities )->getSubEntityName(   ) );
           } else {
           //no name specified,   use the index instead
           subEntity = entity->getSubEntity(  (  *I_subEntities )->getSubEntityIndex(   ) );
           }
           part->addSubEntity(  subEntity,   *I_subEntities );
          
           if (  (  *I_subEntities )->getMaterialName(   ) != "" ) {
           subEntity->setMaterialName(  (  *I_subEntities )->getMaterialName(   ) );
           }
           }
           } else {
           //if no subentities are defined,   add all subentities
           unsigned int numSubEntities = entity->getNumSubEntities(   );
           for (  unsigned int i = 0;i < numSubEntities; ++i ) {
           part->addSubEntity(  entity->getSubEntity(  i ),   0 );
           }
           }
           if (  (  *I_parts )->getGroup(   ) != "" ) {
           mGroupsToPartMap[(  *I_parts )->getGroup(   )].push_back(  (  *I_parts )->getName(   ) );
           //mPartToGroupMap[(  *I_parts )->getName(   )] = (  *I_parts )->getGroup(   );
           }
          
           if (  (  *I_parts )->getShow(   ) ) {
           showPartVector.push_back(  (  *I_parts )->getName(   ) );
           }
          
           ModelPart& modelPart = mModelParts[(  *I_parts )->getName(   )];
           modelPart.addSubModelPart(  part );
           modelPart.setGroupName(  (  *I_parts )->getGroup(   ) );
           }
           addSubmodel(  submodel );
          
           }
           catch (  const Ogre::Exception& e )
           {
           S_LOG_FAILURE(   "Submodel load error for " + entityName + ". \nOgre error: " + e.getFullDescription(   ) );
           return false;
           }
           }
          
           createActions(   );
          
           createParticles(   );
          
          
          
          
          
           std::vector<std::string>::const_iterator I = showPartVector.begin(   );
           std::vector<std::string>::const_iterator I_end = showPartVector.end(   );
           for (  ;I != I_end; I++ ) {
           showPart(  *I );
           }
           return true;
          }
          
     271  void Model::createActions(   )
          {
           ActionDefinitionsStore::const_iterator I_actions = mMasterModel->getActionDefinitions(   ).begin(   );
           ActionDefinitionsStore::const_iterator I_actions_end = mMasterModel->getActionDefinitions(   ).end(   );
           for (  ;I_actions != I_actions_end; ++I_actions ) {
           //std::multiset< Model::AnimationPart* >* animationPartSet = new std::multiset< Model::AnimationPart* >(   );
           Action action;
           action.setName(  (  *I_actions )->getName(   ) );
           action.getAnimations(   ).setSpeed(  (  *I_actions )->getAnimationSpeed(   ) );
          
           if (  getSkeleton(   ) && getAllAnimationStates(   ) ) {
           if (  mSubmodels.size(   ) ) {
           AnimationDefinitionsStore::const_iterator I_anims = (  *I_actions )->getAnimationDefinitions(   ).begin(   );
           AnimationDefinitionsStore::const_iterator I_anims_end = (  *I_actions )->getAnimationDefinitions(   ).end(   );
           for (  ;I_anims != I_anims_end; ++I_anims ) {
           Animation animation(  (  *I_anims )->getIterations(   ) );
           AnimationPartDefinitionsStore::const_iterator I_animParts = (  *I_anims )->getAnimationPartDefinitions(   ).begin(   );
           AnimationPartDefinitionsStore::const_iterator I_animParts_end = (  *I_anims )->getAnimationPartDefinitions(   ).end(   );
           for (  ;I_animParts != I_animParts_end; ++I_animParts ) {
           if (  getAllAnimationStates(   )->hasAnimationState(  (  *I_animParts )->Name ) ) {
           AnimationPart animPart;
           try {
           Ogre::AnimationState* state = getAnimationState(  (  *I_animParts )->Name );
           animPart.state = state;
           animPart.weight = (  *I_animParts )->Weight;
           animation.addAnimationPart(  animPart );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "Error when loading animation: " << (  *I_animParts )->Name << ".\n" + ex.getFullDescription(   )  );
           }
           }
           }
           action.getAnimations(   ).addAnimation(  animation );
           }
           }
           }
          
           //TODO: add sounds too
          
           mActions[(  *I_actions )->getName(   )] = action;
           }
          }
          
     313  void Model::createParticles(   )
          {
           std::vector<ModelDefinition::ParticleSystemDefinition>::const_iterator I_particlesys = mMasterModel->mParticleSystems.begin(   );
           std::vector<ModelDefinition::ParticleSystemDefinition>::const_iterator I_particlesys_end = mMasterModel->mParticleSystems.end(   );
           for (  ;I_particlesys != I_particlesys_end; ++I_particlesys ) {
           //first try to create the ogre particle system
           std::string name(  mName + "/particle" + I_particlesys->Script );
           Ogre::ParticleSystem* ogreParticleSystem;
           try {
           ogreParticleSystem = _getManager(   )->createParticleSystem(  name,   I_particlesys->Script );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "Could not create particle system: " + name );
           std::cerr << ex.getFullDescription(   ) + "\n";
           continue;
           }
           if (  ogreParticleSystem ) {
           //ogreParticleSystem->setDefaultDimensions(  1,   1 );
           ParticleSystem* particleSystem = new ParticleSystem(  ogreParticleSystem );
           for (  ModelDefinition::BindingSet::const_iterator I = I_particlesys->Bindings.begin(   ); I != I_particlesys->Bindings.end(   ); ++I ) {
           ParticleSystemBinding* binding = particleSystem->addBinding(  I->EmitterVar,   I->AtlasAttribute );
           mAllParticleSystemBindings.push_back(  binding );
           }
           mParticleSystems.push_back(  particleSystem );
           }
          
           }
          }
          
          
     342  bool Model::hasParticles(   ) const
          {
           return mParticleSystems.size(   ) > 0;
          }
          
     347  const ParticleSystemBindingsPtrSet& Model::getAllParticleSystemBindings(   ) const
          {
           return mAllParticleSystemBindings;
          }
          
     352  ParticleSystemSet& Model::getParticleSystems(   )
          {
           return mParticleSystems;
          }
          
          
     358  bool Model::addSubmodel(  SubModel* submodel )
          {
           ///if the submodel has a skeleton,   check if it should be shared with existing models
           if (  submodel->getEntity(   )->getSkeleton(   ) ) {
           if (  mSkeletonOwnerEntity != 0 ) {
           submodel->getEntity(   )->shareSkeletonInstanceWith(  mSkeletonOwnerEntity );
           } else {
           mSkeletonOwnerEntity = submodel->getEntity(   );
          // mAnimationStateSet = submodel->getEntity(   )->getAllAnimationStates(   );
           }
           }
           mSubmodels.insert(  submodel );
           return true;
          }
          
     373  bool Model::removeSubmodel(  SubModel* submodel )
          {
           mSubmodels.erase(  submodel );
           return true;
          }
          
          // SubModel* Model::getSubModel(  const std::string& name )
          // {
          // SubModelSet::const_iterator I = mSubmodels.begin(   );
          // SubModelSet::const_iterator I_end = mSubmodels.end(   );
          // for (  ; I != I_end; ++I ) {
          // if (  (  *I )->getName(   ) == name ) {
          // return *I;
          // }
          // }
          // S_LOG_FAILURE(  "Could not find submodel with name "<< name << " in model " << getName(   ) );
          // return 0:
          //
          // }
          
     393  SubModel* Model::getSubModel(  size_t index )
          {
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           size_t i = 0;
           for (  ; I != I_end; ++I ) {
           if (  i == index ) {
           return *I;
           }
           }
           S_LOG_FAILURE(  "Could not find submodel with index "<< index << " in model " << getName(   ) );
           return 0;
          
          }
          
     408  ModelPart::ModelPart(   ) : mShown(  false ),   mVisible(  false )
          {
          }
          
          
     413  void ModelPart::show(   )
          {
           mVisible = true;
           for (  SubModelPartStore::iterator I = mSubModelParts.begin(   ); I != mSubModelParts.end(   ); ++I ) {
           (  *I )->show(   );
           }
          }
          
     421  void ModelPart::hide(   )
          {
           for (  SubModelPartStore::iterator I = mSubModelParts.begin(   ); I != mSubModelParts.end(   ); ++I ) {
           (  *I )->hide(   );
           }
          }
          
     428  bool ModelPart::getVisible(   ) const
          {
           return mVisible;
          }
          
     433  void ModelPart::setVisible(  bool visible )
          {
           mVisible = visible;
          }
          
          
     439  const std::string& ModelPart::getGroupName(   ) const
          {
           return mGroupName;
          }
          
     444  void ModelPart::setGroupName(  const std::string& groupName )
          {
           mGroupName = groupName;
          }
          
     449  void ModelPart::addSubModelPart(  SubModelPart* part )
          {
           mSubModelParts.push_back(  part );
          }
          
          
          
     456  void Model::showPart(  const std::string& partName,   bool hideOtherParts )
          {
           ModelPartStore::iterator I = mModelParts.find(  partName );
           if (  I != mModelParts.end(   ) ) {
           ModelPart& modelPart = I->second;
           if (  hideOtherParts ) {
           const std::string& groupName = modelPart.getGroupName(   );
           ///make sure that all other parts in the same group are hidden
           PartGroupStore::iterator partBucketI = mGroupsToPartMap.find(  groupName );
           if (  partBucketI != mGroupsToPartMap.end(   ) ) {
           for (  std::vector< std::string >::iterator I = partBucketI->second.begin(   ); I != partBucketI->second.end(   ); ++I ) {
           if (  *I != partName ) {
           hidePart(  *I,   true );
           }
           }
           }
           }
          
           modelPart.show(   );
           }
          }
          
     478  void Model::hidePart(  const std::string& partName,   bool dontChangeVisibility )
          {
           ModelPartStore::iterator I = mModelParts.find(  partName );
           if (  I != mModelParts.end(   ) ) {
           ModelPart& modelPart = I->second;
           modelPart.hide(   );
           if (  !dontChangeVisibility ) {
           modelPart.setVisible(  false );
           const std::string& groupName = modelPart.getGroupName(   );
           ///if some part that was hidden before now should be visible
           PartGroupStore::iterator partBucketI = mGroupsToPartMap.find(  groupName );
           if (  partBucketI != mGroupsToPartMap.end(   ) ) {
           for (  std::vector< std::string >::iterator J = partBucketI->second.begin(   ); J != partBucketI->second.end(   ); ++J ) {
           if (  *J != partName ) {
           ModelPartStore::iterator I_modelPart = mModelParts.find(  partName );
           if (  I_modelPart != mModelParts.end(   ) ) {
           if (  I_modelPart->second.getVisible(   ) ) {
           I_modelPart->second.show(   );
           break;
           }
           }
           }
           }
           }
          
           }
           }
          
          
          }
          
     509  void Model::setVisible(  bool visible )
          {
           mVisible = visible;
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->setVisible(  visible );
           }
          
          }
          
          
          
     522  const Ogre::Real Model::getScale(   ) const
          {
           return mScale;
          }
          
     527  const Ogre::Quaternion& Model::getRotation(   ) const
          {
           return mRotation;
          }
          
     532  const ModelDefinition::UseScaleOf Model::getUseScaleOf(   ) const
          {
           return mMasterModel->getUseScaleOf(   );
          }
          
          
     538  Action* Model::getAction(  const std::string& name )
          {
           ActionStore::iterator I = mActions.find(  name );
           if (  I == mActions.end(   ) ) {
           return 0;
           }
           return &(  I->second );
          }
          
          // void Model::startAnimation(  const std::string& nameOfAnimation )
          // {
          // enableAnimation(  nameOfAnimation,  true );
          // }
          //
          // void Model::stopAnimation(  const std::string& nameOfAnimation )
          // {
          // enableAnimation(  nameOfAnimation,  false );
          // }
          
          
          
          // void Model::enableAnimation(  const std::string& nameOfAnimation,  bool enable )
          // {
          // if (  mAnimationStateSet )
          // {
          // AnimationPartMap::iterator partmap_iter = mAnimationPartMap.find(  nameOfAnimation );
          // if (  partmap_iter != mAnimationPartMap.end(   ) )
          // {
          // std::multiset< AnimationPart* >* part = partmap_iter->second;
          // std::multiset< AnimationPart* >::const_iterator I = part->begin(   );
          // std::multiset< AnimationPart* >::const_iterator I_end = part->end(   );
          // for (  ; I != I_end; ++I )
          // { // go through each anim part and update its related anim state
          // Ogre::AnimationStateSet::iterator J = mAnimationStateSet->find(  (  *I )->name );
          // if (  J != mAnimationStateSet->end(   ) ) {
          // if (  enable ) {
          // //also set the weight of the animations part
          // J->second.setWeight(  (  *I )->weight );
          // MotionManager::getSingleton(   ).addAnimation(  &J->second );
          // } else {
          // MotionManager::getSingleton(   ).removeAnimation(  &J->second );
          // }
          // } else {
          // S_LOG_FAILURE(  "The subanimation " << (  *I )->name << " does not exist." );
          // }
          // }
          // }
          // }
          // }
          //
          //
          // void Model::resetAnimations(   )
          // {
          // if (  mAnimationStateSet )
          // {
          // AnimationPartMap::iterator it;
          // for (   it= mAnimationPartMap.begin(   );it != mAnimationPartMap.end(   );it++ )
          // {
          // std::multiset< AnimationPart* >* part = it->second;
          // std::multiset< AnimationPart* >::const_iterator I = part->begin(   );
          // std::multiset< AnimationPart* >::const_iterator I_end = part->end(   );
          // for (  ; I != I_end; ++I )
          // { // go through each anim part and update its related anim state
          // Ogre::AnimationStateSet::iterator J = mAnimationStateSet->find(  (  *I )->name );
          // if (  J != mAnimationStateSet->end(   ) ) {
          // MotionManager::getSingleton(   ).removeAnimation(  &J->second );
          // } else {
          // S_LOG_FAILURE(  "The subanimation " << (  *I )->name << " does not exist." );
          // }
          //
          //
          // }
          // }
          // }
          // }
          
     614  void Model::resetSubmodels(   )
          {
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           delete *I;
          /* SubModel* submodel = *I;
           Ogre::SceneManager* sceneManager = ModelDefinitionManager::instance(   ).getSceneManager(   );
           sceneManager->removeEntity(  submodel->getEntity(   ) );*/
           }
           mSubmodels.clear(   );
           mModelParts.clear(   );
          }
          
     628  void Model::resetParticles(   )
          {
           ParticleSystemSet::const_iterator I = mParticleSystems.begin(   );
           ParticleSystemSet::const_iterator I_end = mParticleSystems.end(   );
           for (  ; I != I_end; ++I ) {
           ParticleSystem* system = *I;
           delete system;
           }
           mParticleSystems.clear(   );
           mAllParticleSystemBindings.clear(   );
          }
          
     640  Ogre::TagPoint* Model::attachObjectToAttachPoint(  const Ogre::String &attachPointName,   Ogre::MovableObject *pMovable,   const Ogre::Vector3 &scale,   const Ogre::Quaternion &offsetOrientation,   const Ogre::Vector3 &offsetPosition )
          {
           for (  AttachPointDefinitionStore::iterator I = mMasterModel->mAttachPoints.begin(   ); I != mMasterModel->mAttachPoints.end(   ); ++I ) {
           if (  I->Name == attachPointName ) {
           const std::string& boneName = I->BoneName;
           ///use the rotation in the attach point def
           Ogre::TagPoint* tagPoint = attachObjectToBone(  boneName,   pMovable,   offsetOrientation * I->Rotation,   offsetPosition,   scale );
           if (  !mAttachPoints.get(   ) ) {
           mAttachPoints = std::auto_ptr<AttachPointWrapperStore>(  new AttachPointWrapperStore(   ) );
           }
           AttachPointWrapper wrapper;
           wrapper.TagPoint = tagPoint;
           wrapper.AttachPointName = attachPointName;
           wrapper.Movable = pMovable;
           mAttachPoints->push_back(  wrapper );
           }
           }
           return 0;
          }
          
     660  bool Model::hasAttachPoint(  const std::string& attachPoint ) const
          {
           for (  AttachPointDefinitionStore::iterator I = mMasterModel->mAttachPoints.begin(   ); I != mMasterModel->mAttachPoints.end(   ); ++I ) {
           if (  I->Name == attachPoint ) {
           return true;
           }
           }
           return false;
          }
          
          
          
     672  Ogre::AnimationState* Model::getAnimationState(  const Ogre::String& name )
          {
           if (  mSubmodels.size(   ) && mSkeletonOwnerEntity ) {
           return mSkeletonOwnerEntity->getAnimationState(  name );
           } else {
           return 0;
           }
          }
          
     681  Ogre::AnimationStateSet* Model::getAllAnimationStates(   )
          {
           if (  mSubmodels.size(   ) && mSkeletonOwnerEntity ) {
           return mSkeletonOwnerEntity->getAllAnimationStates(   );
           } else {
           return 0;
           }
          }
          
          
     691  Ogre::SkeletonInstance * Model::getSkeleton (   )
          {
           if (  mSubmodels.size(   ) && mSkeletonOwnerEntity ) {
           return mSkeletonOwnerEntity->getSkeleton(   );
           } else {
           return 0;
           }
          }
          
     700  Ogre::TagPoint* Model::attachObjectToBone (  const Ogre::String &boneName,   Ogre::MovableObject *pMovable,   const Ogre::Quaternion &offsetOrientation,   const Ogre::Vector3 &offsetPosition )
          {
           return attachObjectToBone(  boneName,   pMovable,   offsetOrientation,   offsetPosition,   Ogre::Vector3::UNIT_SCALE );
          }
          
     705  Ogre::TagPoint* Model::attachObjectToBone (  const Ogre::String &boneName,   Ogre::MovableObject *pMovable,   const Ogre::Quaternion &offsetOrientation,   const Ogre::Vector3 &offsetPosition,   const Ogre::Vector3 &scale )
          {
           if (  mSubmodels.size(   ) ) {
           Ogre::Entity* entity = mSkeletonOwnerEntity;
          
           Ogre::TagPoint* tagPoint = entity->attachObjectToBone(  boneName,   pMovable,   offsetOrientation,   offsetPosition );
          
           if (  mParentNode ) {
           //since we're using inherit scale on the tagpoint,   divide by the parent's scale now,   so it evens out later on when the TagPoint is scaled in TagPoint::_updateFromParent(  
           Ogre::Vector3 parentScale = mParentNode->_getDerivedScale(   );
           tagPoint->setScale(  scale / parentScale );
           } else {
           //no parent node,   this is not good...
           tagPoint->setScale(  scale );
           }
           return tagPoint;
          
          
           } else {
           OGRE_EXCEPT(  Ogre::Exception::ERR_ITEM_NOT_FOUND,   "There are no entities loaded!",   "Model::attachObjectToBone" );
           }
          }
          
          
          
     730  Ogre::MovableObject * Model::detachObjectFromBone (  const Ogre::String &movableName )
          {
          
           if (  mSubmodels.size(   ) && mSkeletonOwnerEntity ) {
           if (  mAttachPoints.get(   ) ) {
           for (  AttachPointWrapperStore::iterator I = mAttachPoints->begin(   ); I != mAttachPoints->end(   ); ++I ) {
           if (  I->Movable->getName(   ) == movableName ) {
           mAttachPoints->erase(  I );
           break;
           }
           }
           }
          
           return mSkeletonOwnerEntity->detachObjectFromBone(  movableName );
          
           } else {
           OGRE_EXCEPT(  Ogre::Exception::ERR_ITEM_NOT_FOUND,   "There are no entities loaded!",   "Model::detachObjectFromBone" );
           }
          
          }
          
          
          //-----------------------------------------------------------------------
     753  void Model::detachAllObjectsFromBone(  void )
          {
           if (  mSubmodels.size(   ) && mSkeletonOwnerEntity ) {
           mSkeletonOwnerEntity->detachAllObjectsFromBone(   );
           mAttachPoints = std::auto_ptr<AttachPointWrapperStore>(  0 );
          
           } else {
           OGRE_EXCEPT(  Ogre::Exception::ERR_ITEM_NOT_FOUND,   "There are no entities loaded!",   "Model::detachAllObjectsFromBone" );
           }
          }
          
          
          
          
          
          /** Overridden - see MovableObject.
          */
     770  void Model::_notifyCurrentCamera(  Ogre::Camera* cam )
          {
           MovableObject::_notifyCurrentCamera(  cam );
           if (  isVisible(   ) ) {
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           if (  mVisible ) {
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->_notifyCurrentCamera(  cam );
           }
          
           // Notify any child objects
           Ogre::Entity::ChildObjectList::iterator child_itr = mChildObjectList.begin(   );
           Ogre::Entity::ChildObjectList::iterator child_itr_end = mChildObjectList.end(   );
           for(   ; child_itr != child_itr_end; child_itr++ )
           {
           child_itr->second->_notifyCurrentCamera(  cam );
           }
           }
           }
          
          }
          
     793  void Model::setUserObject (  Ogre::UserDefinedObject *obj )
          {
           Ogre::MovableObject::setUserObject(  obj );
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->setUserObject(  obj );
           }
          }
          
          
          /// Overridden - see MovableObject.
     805  void Model::setRenderQueueGroup(  Ogre::RenderQueueGroupID queueID )
          {
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->setRenderQueueGroup(  queueID );
           }
          
          }
          
          /** Overridden - see MovableObject.
          */
     817  const Ogre::AxisAlignedBox& Model::getBoundingBox(  void ) const
          {
           mFull_aa_box.setNull(   );
          
           SubModelSet::const_iterator child_itr = mSubmodels.begin(   );
           SubModelSet::const_iterator child_itr_end = mSubmodels.end(   );
           for(   ; child_itr != child_itr_end; child_itr++ )
           {
           mFull_aa_box.merge(  (  *child_itr )->getEntity(   )->getBoundingBox(   ) );
           }
          
           return mFull_aa_box;
          }
          
          /** Overridden - see MovableObject.
          */
     833  const Ogre::AxisAlignedBox& Model::getWorldBoundingBox(  bool derive ) const
          {
           mWorldFull_aa_box.setNull(   );
          
           SubModelSet::const_iterator child_itr = mSubmodels.begin(   );
           SubModelSet::const_iterator child_itr_end = mSubmodels.end(   );
          
           for(   ; child_itr != child_itr_end; child_itr++ )
           {
           mWorldFull_aa_box.merge(  (  *child_itr )->getEntity(   )->getWorldBoundingBox(  derive ) );
           }
          
           return mWorldFull_aa_box;
          }
          
     848  Ogre::Real Model::getBoundingRadius(   ) const
          {
           Ogre::Real rad(  0 );
           SubModelSet::const_iterator child_itr = mSubmodels.begin(   );
           SubModelSet::const_iterator child_itr_end = mSubmodels.end(   );
           for(   ; child_itr != child_itr_end; child_itr++ )
           {
           rad = std::max<Ogre::Real>(  rad,   (  *child_itr )->getEntity(   )->getBoundingRadius(   ) );
           }
           return rad;
          
          }
          
          
          
          
          /** Overridden - see MovableObject.
          */
     866  void Model::_updateRenderQueue(  Ogre::RenderQueue* queue )
          {
           ///check with both the model visibility setting and with the general model setting to see whether the model should be shown
           if (  isVisible(   ) ) {
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->_updateRenderQueue(  queue );
           }
          
           if (  getSkeleton(   ) != 0 ) {
           //updateAnimation(   );
           Ogre::Entity::ChildObjectList::iterator child_itr = mChildObjectList.begin(   );
           Ogre::Entity::ChildObjectList::iterator child_itr_end = mChildObjectList.end(   );
           for(   ; child_itr != child_itr_end; child_itr++ )
           {
           ///make sure to do _update here,   else attached entities won't be updated if no animation is playing
           child_itr->second->getParentNode(   )->_update(  true,   true );
           if (  child_itr->second->isVisible(   ) )
           child_itr->second->_updateRenderQueue(  queue );
           }
           }
          
           }
          
          
          }
          
          
          /** Overridden from MovableObject */
          // const Ogre::String& Model::getName(  void ) const
          // {
          // return mName;
          // }
          
          /** Overridden from MovableObject */
     902  const Ogre::String& Model::getMovableType(  void ) const
          {
           return sMovableType;
          }
          
     907  void Model::setRenderingDistance (  Ogre::Real dist )
          {
           MovableObject::setRenderingDistance(  dist );
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->setRenderingDistance(  dist );
           }
          }
          
     917  void Model::setQueryFlags(  unsigned long flags )
          {
           MovableObject::setQueryFlags(  flags );
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->setQueryFlags(  flags );
           }
          }
          
     927  void Model::addQueryFlags(  unsigned long flags )
          {
           MovableObject::addQueryFlags(  flags );
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->addQueryFlags(  flags );
           }
          
          }
          
          
     939  void Model::removeQueryFlags(  unsigned long flags )
          {
           //for now,   only return. This is because this is often called at shutdown,   when the entities already have been destroyed
           //and we don't want segfaults
          // return;
           MovableObject::removeQueryFlags(  flags );
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->removeQueryFlags(  flags );
           }
          
          }
          
          
          /** Overridden from MovableObject */
     955  void Model::_notifyAttached(  Ogre::Node* parent,   bool isTagPoint )
          {
           MovableObject::_notifyAttached(  parent,   isTagPoint );
           SubModelSet::const_iterator I = mSubmodels.begin(   );
           SubModelSet::const_iterator I_end = mSubmodels.end(   );
           for (  ; I != I_end; ++I ) {
           (  *I )->getEntity(   )->_notifyAttached(  parent,   isTagPoint );
           }
          }
          
     965  bool Model::isVisible (  void ) const
          {
           ///check with both the model visibility setting and with the general model setting to see whether the model should be shown
           return Ogre::MovableObject::isVisible(   ) && ModelDefinitionManager::getSingleton(   ).getShowModels(   );
          }
          
          
     972  Model* Model::createModel(  Ogre::SceneManager* sceneManager,   const std::string& modelType,   const std::string& name )
          {
          
           Ogre::String modelName(  name );
           if (  name == "" ) {
           std::stringstream ss;
           ss << "__AutogenModel_" << Model::msAutoGenId++;
           modelName = ss.str(   );
           }
          
           // delegate to factory implementation
           Ogre::NameValuePairList params;
           params["modeldefinition"] = modelType;
           return static_cast<Model*>(  sceneManager->createMovableObject(  modelName,   ModelFactory::FACTORY_TYPE_NAME,   &params ) );
          
          }
          
          
     990  const Model::AttachPointWrapperStore* Model::getAttachedPoints(   ) const
          {
           return mAttachPoints.get(   );
          }
          
          
          Ogre::String ModelFactory::FACTORY_TYPE_NAME = "Model";
          //-----------------------------------------------------------------------
     998  const Ogre::String& ModelFactory::getType(  void ) const
          {
           return FACTORY_TYPE_NAME;
          }
          //-----------------------------------------------------------------------
    1003  Ogre::MovableObject* ModelFactory::createInstanceImpl(   const Ogre::String& name,  
    1004   const Ogre::NameValuePairList* params )
          {
          
           // must have mesh parameter
           if (  params != 0 )
           {
           Ogre::NameValuePairList::const_iterator ni = params->find(  "modeldefinition" );
           if (  ni != params->end(   ) )
           {
           Model* model = new Model(  name );
           model->create(  ni->second );
           return model;
           }
          
           }
           OGRE_EXCEPT(  Ogre::Exception::ERR_INVALIDPARAMS,  
           "'modeldefinition' parameter required when constructing a Model.",  
           "ModelFactory::createInstance" );
          
          }
          //-----------------------------------------------------------------------
    1025  void ModelFactory::destroyInstance(   Ogre::MovableObject* obj )
          {
           delete obj;
          }
          
          
          
          }
          }

./components/ogre/model/Model.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
           Copyright (  c ) 2005 The Cataclysmos Team
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef MODEL_H
          #define MODEL_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "ModelDefinition.h"
          #include "ParticleSystem.h"
          #include <sigc++/signal.h>
          
          namespace EmberOgre {
          namespace Model {
          
      31  class SubModel;
      32  class SubModelPart;
      33  class ModelDefinition;
      34  class ParticleSystemBinding;
      35  class ParticleSystem;
      36  class Action;
          
          typedef std::vector<ParticleSystem*> ParticleSystemSet;
          typedef std::vector<ParticleSystemBinding> ParticleSystemBindingsSet;
          
      41  class ModelPart
          {
          public:
           typedef std::vector<SubModelPart*> SubModelPartStore;
      45   ModelPart(   );
          
      47   void addSubModelPart(  SubModelPart* part );
          
      49   void hide(   );
      50   void show(   );
          
      52   bool getVisible(   ) const;
      53   void setVisible(  bool visible );
          
      55   const std::string& getGroupName(   ) const;
      56   void setGroupName(  const std::string& groupName );
          
          protected:
      59   bool mShown;
      60   bool mVisible;
          
      62   SubModelPartStore mSubModelParts;
          
      64   std::string mGroupName;
          };
          
          /**
           * This is the standard model used in Ember.
           * A model can be made out of different entities,   just as long as they share a skeleton.
           * The model consists of different parts,   represented by instances of SubModelPart.
           * Typical parts would be a body or a shirt. These parts can be turned on or off.
           * That allows for the use of a single mesh with many different submeshes.
           *
           * A model is typically instanciated from a modeldef.xml file through the use
           * of createFromXML(  ... )
           */
      77  class Model : public Ogre::MovableObject
          {
          
      80  friend class ModelDefinition;
      81  friend class ModelFactory;
          
          public:
          
          
           typedef std::map<std::string,   Action> ActionStore;
          
           typedef std::set<SubModel*> SubModelSet;
           typedef std::set<std::string> StringSet;
           typedef std::map<std::string,   StringSet > SubModelPartMapping;
           typedef std::map<std::string,   ModelPart> ModelPartStore;
          
           typedef std::map<std::string,   std::vector<std::string > > PartGroupStore;
          
           struct AttachPointWrapper
           {
           Ogre::TagPoint* TagPoint;
           std::string AttachPointName;
           Ogre::MovableObject *Movable;
           };
           typedef std::vector<AttachPointWrapper> AttachPointWrapperStore;
          
     103   static const Ogre::String sMovableType;
          
           /**
           * Creates a new Model instance.
           * The name of the model will be autogenerated.
           * Remember to call create(  ... ) to create the actual meshes.
           * @return
           */
          // Model(   );
          
     113   virtual ~Model(   );
          
          
          
           /** Notify the object of it's manager (  internal use only ) */
     118   virtual void _notifyManager(  Ogre::SceneManager* man );
          
     120   static Model* createModel(  Ogre::SceneManager* sceneManager,   const std::string& modelType,   const std::string& name = "" );
          
           /**
           * Reloads the model from the modeldefinition.
           */
     125   void reload(   );
          
          
           /**
           * Emitted when the model is reloaded
           */
     131   sigc::signal<void> Reloaded;
          
           /**
           * Emitted when the model is about to be resetted.
           */
     136   sigc::signal<void> Resetting;
          
          
     139   bool addSubmodel(  SubModel* submodel );
     140   bool removeSubmodel(  SubModel* submodel );
          
     142   Action* getAction(  const std::string& name );
          
          
     145   ModelPart& getPart(  const std::string& partName );
          
           /**
           * hides and shows a certain part of the model
           */
     150   void showPart(  const std::string& partName,   bool hideOtherParts = true );
     151   void hidePart(  const std::string& partName,   bool dontChangeVisibility = false );
     152   void setVisible(  bool visible );
          
           /**
           * if defined in the modeldef,   returns a scaler by which the node containing
           * the model can be scaled
           */
     158   const Ogre::Real getScale(   ) const;
          
           /**
           * Defines how much the model should be rotated.
           */
     163   const Ogre::Quaternion& getRotation(   ) const;
          
           /**
           * if defined in the modeldef,   returns an axis by which the model can be scaled
           * I.e. when dealing with something such as a fir tree,   you want to use the
           * height of the tree to determine how much it should be scaled,   since the
           * bounding box supplied by eris doesn't take the branches into account
           */
     171   const ModelDefinition::UseScaleOf getUseScaleOf(   ) const;
          
          
          // inline const SubModelPartStoreMap& getSubmodelParts(   ) const;
          
     176   inline const SubModelSet& getSubmodels(   ) const;
          
           //SubModel* getSubModel(  const std::string& name );
     179   SubModel* getSubModel(  size_t index );
          
          
     182   Ogre::AnimationState* getAnimationState(  const Ogre::String& name );
     183   Ogre::AnimationStateSet* getAllAnimationStates(   );
     184   Ogre::SkeletonInstance * getSkeleton (   );
     185   Ogre::TagPoint* attachObjectToBone (  const Ogre::String &boneName,   Ogre::MovableObject *pMovable,   const Ogre::Quaternion &offsetOrientation=Ogre::Quaternion::IDENTITY,   const Ogre::Vector3 &offsetPosition=Ogre::Vector3::ZERO );
     186   Ogre::MovableObject * detachObjectFromBone (  const Ogre::String &movableName );
     187   void detachAllObjectsFromBone(  void );
          
           /** @see Ogre::MovableObject::setRenderingDistance(  Ogre::Real dist )
           */
     191   virtual void setRenderingDistance (  Ogre::Real dist );
           //inline bool isAnimated(   ) { return mAnimationPartMap.size(   ); }
          
           /** Overridden - see MovableObject.
           */
          // inline virtual Ogre::Real getRenderingDistance (   void  ) const;
          
           /** Overridden - see MovableObject.
           */
     200   virtual void _notifyCurrentCamera(  Ogre::Camera* cam );
          
           /** Overridden - see MovableObject.
           */
     204   virtual void setUserObject (  Ogre::UserDefinedObject *obj );
          
           /// Overridden - see MovableObject.
     207   virtual void setRenderQueueGroup(  Ogre::RenderQueueGroupID queueID );
          
           /** Overridden - see MovableObject.
           */
     211   virtual const Ogre::AxisAlignedBox& getBoundingBox(  void ) const;
          
           /** Overridden - see MovableObject.
           */
     215   virtual const Ogre::AxisAlignedBox& getWorldBoundingBox(  bool derive ) const;
          
     217   virtual Ogre::Real getBoundingRadius(   ) const;
          
           /** Overridden - see MovableObject.
           */
     221   virtual void _updateRenderQueue(  Ogre::RenderQueue* queue );
          
           /** Overridden from MovableObject */
          // virtual const Ogre::String& getName(  void ) const;
          
           /** Overridden from MovableObject */
     227   virtual const Ogre::String& getMovableType(  void ) const;
          
           /** Overridden from MovableObject */
     230   virtual void setQueryFlags(  unsigned long flags );
          
           /** Overridden from MovableObject */
     233   virtual void addQueryFlags(  unsigned long flags );
          
           /** Overridden from MovableObject */
     236   virtual void removeQueryFlags(  unsigned long flags );
          
           /** Overridden from MovableObject */
     239   virtual void _notifyAttached(  Ogre::Node* parent,   bool isTagPoint = false );
          
           /** Overridden from MovableObject */
     242   virtual bool isVisible (  void ) const;
          
           /**
           * returns a pointer to the defintion of the Model
           * @return
           */
     248   inline ModelDefnPtr getDefinition(   ) const;
          
          
     251   Ogre::TagPoint* attachObjectToBone(  const Ogre::String &boneName,   Ogre::MovableObject *pMovable,   const Ogre::Quaternion &offsetOrientation=Ogre::Quaternion::IDENTITY,   const Ogre::Vector3 &offsetPosition=Ogre::Vector3::ZERO,   const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE );
     252   Ogre::TagPoint* attachObjectToAttachPoint(  const Ogre::String &boneName,   Ogre::MovableObject *pMovable,   const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE,   const Ogre::Quaternion &offsetOrientation=Ogre::Quaternion::IDENTITY,   const Ogre::Vector3 &offsetPosition=Ogre::Vector3::ZERO );
           //void attachObjectToAttachPoint(  const Ogre::String &attachPointName,   Ogre::MovableObject *pMovable,   const Ogre::Quaternion &offsetOrientation=Ogre::Quaternion::IDENTITY,   const Ogre::Vector3 &offsetPosition=Ogre::Vector3::ZERO );
          
     255   bool hasAttachPoint(  const std::string& attachPoint ) const;
          
     257   const ParticleSystemBindingsPtrSet& getAllParticleSystemBindings(   ) const;
          
     259   ParticleSystemSet& getParticleSystems(   );
          
     261   bool hasParticles(   ) const;
          
           /**
           Returns a store of AttachPointWrapper objects,   which represents all attached objects.
           @returns a pointer to an AttachPointWrapperStore instance,   or null
           */
     267   const AttachPointWrapperStore* getAttachedPoints(   ) const;
          
          protected:
          
           /**
           * Creates a new Model instance with the specified name.
           * Remember to call create(  ... ) to create the actual meshes.
           * @param name
           * @return
           */
     277   Model(  const std::string& name );
          
           /**
           * Try to create the needed meshes from the specified modeldef.
           * Returns true if successful,   else false.
           * @param modelType
           * @return
           */
     285   bool create(  const std::string& modelType ); // create model of specific type
          
           static unsigned long msAutoGenId;
     288   ParticleSystemBindingsPtrSet mAllParticleSystemBindings;
     289   ParticleSystemSet mParticleSystems;
           /**
           * Clears all the submodels
           */
     293   void resetSubmodels(   );
          
     295   void createActions(   );
     296   void createParticles(   );
          
           /**
           * Clears all the particles
           */
     301   void resetParticles(   );
          
           /**
           * Resets the whole model.
           */
     306   void reset(   );
          
          
     309   Ogre::Entity::ChildObjectList mChildObjectList;
          
           mutable Ogre::AxisAlignedBox mFull_aa_box;
           mutable Ogre::AxisAlignedBox mWorldFull_aa_box;
          
          
           /**
           if the model has a skeleton,   it can be shared between many different entities
           this denotes the "owning" entity
           */
           Ogre::Entity* mSkeletonOwnerEntity;
          
          
           /**
           all actions belonging to the model
           */
           ActionStore mActions;
          
          
           /**
           the name of the model
           */
          // std::string mName;
          
           /**
           modeldef this was copied from
           */
           ModelDefnPtr mMasterModel;
          
           /**
           a set of all submodels belonging to the model
           */
           SubModelSet mSubmodels;
           /**
           a set of all submodelparts belonging to the model (  in reality they belong to the submodels though )
           */
          // SubModelPartStoreMap mSubModelPartMap;
          
           ModelPartStore mModelParts;
          
           PartGroupStore mGroupsToPartMap;
          
           Ogre::SkeletonInstance* mSkeletonInstance;
          
           /**
           how much to scale the model from it's initial size
           */
           Ogre::Real mScale;
           /**
           how much the model should be rotated around the Y-axis from it's initial position
           */
           Ogre::Quaternion mRotation;
          
          
           /**
           set of all animation states
           */
           Ogre::AnimationStateSet* mAnimationStateSet;
          
          
           bool createFromDefn(   );
          
           std::auto_ptr<AttachPointWrapperStore> mAttachPoints;
           //void enableAnimation(  const std::string& nameOfAnimation,  bool enable );
          };
          
          // Ogre::Real Model::getRenderingDistance (   void  ) const
          // {
          // return _masterModel->getRenderingDistance(   );
          // }
          
     380  ModelDefnPtr Model::getDefinition(   ) const { return mMasterModel; }
          
          // // const Model::SubModelPartStoreMap& Model::getSubmodelParts(   ) const
          // // {
          // // return mSubModelPartMap;
          // // }
          
     387  const Model::SubModelSet& Model::getSubmodels(   ) const
          {
           return mSubmodels;
          }
          
          
          
          
          
          
          
           /** Factory object for creating Model instances */
     399   class ModelFactory : public Ogre::MovableObjectFactory
           {
           protected:
     402   Ogre::MovableObject* createInstanceImpl(   const Ogre::String& name,   const Ogre::NameValuePairList* params );
           public:
     404   ModelFactory(   ) {}
     405   ~ModelFactory(   ) {}
          
     407   static Ogre::String FACTORY_TYPE_NAME;
          
     409   const Ogre::String& getType(  void ) const;
     410   void destroyInstance(   Ogre::MovableObject* obj );
          
           };
          
          }
          }
          #endif // MODEL_H

./components/ogre/model/ModelDefinition.cpp

          //
          // C++ Implementation: ModelDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          // Copyright (  c ) 2005 The Cataclysmos Team
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          
          #include "ModelDefinition.h"
          #include "Model.h"
          #include "SubModel.h"
          #include "SubModelPart.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
      35  ModelDefinition::ModelDefinition(  Ogre::ResourceManager* creator,   const Ogre::String& name,   Ogre::ResourceHandle handle,  
      36   const Ogre::String& group,   bool isManual,   Ogre::ManualResourceLoader* loader )
           : Resource(  creator,   name,   handle,   group,   isManual,   loader )
           ,   mRenderingDistance(  0.0f )
      39   ,   mUseScaleOf(  MODEL_ALL )
           ,   mScale(  0 )
           ,   mRotation(  Ogre::Quaternion::IDENTITY )
           ,   mContentOffset(  Ogre::Vector3::ZERO )
           ,   mShowContained(  true )
           ,   mTranslate(  0,  0,  0 )
           ,   mIsValid(  false )
           ,   mRenderingDef(  0 )
          {
           if (  createParamDictionary(  "ModelDefinition" ) )
           {
           // no custom params
           }
          }
          
      54  ModelDefinition::~ModelDefinition(   )
          {
           for (  SubModelDefinitionsStore::iterator I = mSubModels.begin(   ); I != mSubModels.end(   ); ++I ) {
           delete *I;
           }
           for (  ActionDefinitionsStore::iterator I = mActions.begin(   ); I != mActions.end(   ); ++I ) {
           delete *I;
           }
           for (  ViewDefinitionStore::iterator I = mViews.begin(   ); I != mViews.end(   ); ++I ) {
           delete I->second;
           }
           delete mRenderingDef;
          // delete(  mContentOffset );
           // have to call this here reather than in Resource destructor
           // since calling virtual methods in base destructors causes crash
           unload(   );
          }
          
      72  void ModelDefinition::loadImpl(  void )
          {
          // XMLModelDefinitionSerializer serializer;
          //
          // Ogre::String filename = mName + ".modeldef.xml";
          //
          // S_LOG_INFO(   "ModelDefinition: Loading " + filename  );
          //
          // Ogre::DataStreamPtr stream =
          // Ogre::ResourceGroupManager::getSingleton(   ).openResource(  filename,   mGroup );
          //
          // serializer.importModelDefinition(  stream,   this );
          //
          // mIsValid = true;
          // mIsLoaded = true;
          
          }
          
          
      91  void ModelDefinition::addModelInstance(  Model* model )
          {
           mModelInstances[model->getName(   )] = model;
          }
          
      96  void ModelDefinition::removeModelInstance(  Model* model )
          {
           mModelInstances.erase(  model->getName(   ) );
          }
          
     101  void ModelDefinition::unloadImpl(  void )
          {
          }
          
     105  bool ModelDefinition::isValid(  void )
          {
           return mIsValid;
          }
          
     110  ViewDefinition* ModelDefinition::createViewDefinition(  const std::string& viewname )
          {
           if (  mViews.find(  viewname ) != mViews.end(   ) ) {
           return mViews.find(  viewname )->second;
           } else {
           ViewDefinition* def = new ViewDefinition(   );
           def->Name = viewname;
           def->Distance = 0;
           def->Rotation = Ogre::Quaternion::IDENTITY;
           mViews.insert(  ViewDefinitionStore::value_type(  viewname,   def ) );
           return def;
           }
          }
          
     124  const ViewDefinitionStore& ModelDefinition::getViewDefinitions(   )
          {
           return mViews;
          }
          
     129  void ModelDefinition::removeViewDefinition(  const std::string name )
          {
           mViews.erase(  name );
          // for (  ViewDefinitionStore::iterator I = mViews.begin(   ); I != mViews.end(   ); ++I ) {
          // if (  I->second == def ) {
          //
          // }
          // }
           //ViewDefinitionStore::iterator I =
          // ModelDefinition::removeDefinition(  def,   mViews );
          /* SubModelDefinitionsStore::iterator I;
           for (  I = mSubModels.begin(   ); I != mSubModels.end(   ); ++I ) {
           if (  *I == def )
           break;
           }
           if (  I != mSubModels.end(   ) ) {
           mSubModels.erase(  I );
           }*/
          }
          
          
          
     151  const Ogre::Vector3& ModelDefinition::getTranslate(   ) const
          {
           return mTranslate;
          }
          
     156  void ModelDefinition::setTranslate(  const Ogre::Vector3 translate )
          {
           mTranslate = translate;
          }
          
          
     162  bool ModelDefinition::getShowContained(   ) const
          {
           return mShowContained;
          }
          
     167  void ModelDefinition::getShowContained(  bool show )
          {
           mShowContained = show;
          }
          
          
          
     174  const Ogre::Quaternion& ModelDefinition::getRotation(   ) const
          {
           return mRotation;
          }
          
     179  void ModelDefinition::setRotation(  const Ogre::Quaternion rotation )
          {
           mRotation = rotation;
          }
          
     184  const RenderingDefinition* ModelDefinition::getRenderingDefinition(   ) const
          {
           return mRenderingDef;
          }
          
          
          
     191  void ModelDefinition::reloadAllInstances(   )
          {
           for (  ModelInstanceStore::iterator I = mModelInstances.begin(   ); I != mModelInstances.end(   ); ++I ) {
           I->second->reload(   );
           }
          // std::for_each(  mModelInstances.begin(   ),   mModelInstances.end(   ),   std::mem_fun(  &EmberOgre::Model::Model::reload ) );
          }
          
          
     200  SubModelDefinition* ModelDefinition::createSubModelDefinition(  const std::string& meshname )
          {
           SubModelDefinition* def = new SubModelDefinition(  meshname,   *this );
           mSubModels.push_back(  def );
           return def;
          }
          
     207  const std::vector<SubModelDefinition*>& ModelDefinition::getSubModelDefinitions(   )
          {
           return mSubModels;
          }
          
     212  void ModelDefinition::removeSubModelDefinition(  SubModelDefinition* def )
          {
           ModelDefinition::removeDefinition(  def,   mSubModels );
          /* SubModelDefinitionsStore::iterator I;
           for (  I = mSubModels.begin(   ); I != mSubModels.end(   ); ++I ) {
           if (  *I == def )
           break;
           }
           if (  I != mSubModels.end(   ) ) {
           mSubModels.erase(  I );
           }*/
          }
          
     225  ActionDefinition* ModelDefinition::createActionDefinition(  const std::string& actionname )
          {
           ActionDefinition* def = new ActionDefinition(  actionname );
           mActions.push_back(  def );
           return def;
          }
          
     232  const ActionDefinitionsStore& ModelDefinition::getActionDefinitions(   )
          {
           return mActions;
          }
          
     237  const AttachPointDefinitionStore& ModelDefinition::getAttachPointsDefinitions(   )
          {
           return mAttachPoints;
          }
          
          
     243  void ModelDefinition::removeActionDefinition(  ActionDefinition* def )
          {
           ModelDefinition::removeDefinition(  def,   mActions );
          /* SubModelDefinitionsStore::iterator I;
           for (  I = mSubModels.begin(   ); I != mSubModels.end(   ); ++I ) {
           if (  *I == def )
           break;
           }
           if (  I != mSubModels.end(   ) ) {
           mSubModels.erase(  I );
           }*/
          }
          
          
          template <typename T,   typename T1>
     258  void ModelDefinition::removeDefinition(  T* def,   T1& store )
          {
           typename T1::iterator I = std::find(  store.begin(   ),   store.end(   ),   def );
           if (  I != store.end(   ) ) {
           store.erase(  I );
           }
          }
          
          
          
          
          
          
          
          
     273  SubModelDefinition::SubModelDefinition(  const std::string& meshname,   ModelDefinition& modelDef )
          : mMeshName(  meshname ),   mModelDef(  modelDef )
          {
          }
          
     278  SubModelDefinition::~SubModelDefinition(   )
          {
           for (  std::vector<PartDefinition*>::iterator I = mParts.begin(   ); I != mParts.end(   ); ++I ) {
           delete *I;
           }
          }
          
     285  ModelDefinition& SubModelDefinition::getModelDefinition(   )
          {
           return mModelDef;
          }
          
     290  const std::string& SubModelDefinition::getMeshName(   ) const
          {
           return mMeshName;
          }
          
          
     296  PartDefinition* SubModelDefinition::createPartDefinition(  const std::string& partname )
          {
           PartDefinition* def = new PartDefinition(  partname,   *this );
           mParts.push_back(  def );
           return def;
          
          }
     303  const std::vector<PartDefinition*>& SubModelDefinition::getPartDefinitions(   )
          {
           return mParts;
          }
          
     308  void SubModelDefinition::removePartDefinition(  PartDefinition* def )
          {
           ModelDefinition::removeDefinition(  def,   mParts );
          /* std::vector<PartDefinition*>::iterator I;
           for (  I = mParts.begin(   ); I != mParts.end(   ); ++I ) {
           if (  *I == def )
           break;
           }
           if (  I != mParts.end(   ) ) {
           mParts.erase(  I );
           }*/
          }
          
          
          
          
     324  PartDefinition::PartDefinition(  const std::string& name,   SubModelDefinition& subModelDef ) : mName(  name ),   mSubModelDef(  subModelDef )
          {
          }
          
     328  PartDefinition::~PartDefinition(   )
          {
           for (  std::vector<SubEntityDefinition*>::iterator I = mSubEntities.begin(   ); I != mSubEntities.end(   ); ++I ) {
           delete *I;
           }
          }
          
     335  SubModelDefinition& PartDefinition::getSubModelDefinition(   )
          {
           return mSubModelDef;
          }
          
     340  void PartDefinition::setName(  const std::string& name )
          {
           mName = name;
          }
          
     345  const std::string& PartDefinition::getName(   ) const
          {
           return mName;
          }
          
     350  void PartDefinition::setGroup(  const std::string& group )
          {
           mGroup = group;
          }
          
     355  const std::string& PartDefinition::getGroup(   ) const
          {
           return mGroup;
          }
          
          
     361  void PartDefinition::setShow(  bool show )
          {
           mShow = show;
          }
     365  bool PartDefinition::getShow(   ) const
          {
           return mShow;
          }
          
     370  SubEntityDefinition* PartDefinition::createSubEntityDefinition(  const std::string& subEntityName )
          {
           SubEntityDefinition* def = new SubEntityDefinition(  subEntityName,   *this );
           mSubEntities.push_back(  def );
           return def;
          
          }
          
     378  SubEntityDefinition* PartDefinition::createSubEntityDefinition(  unsigned int subEntityIndex )
          {
           SubEntityDefinition* def = new SubEntityDefinition(  subEntityIndex,   *this );
           mSubEntities.push_back(  def );
           return def;
          }
          
     385  const std::vector<SubEntityDefinition*>& PartDefinition::getSubEntityDefinitions(   )
          {
           return mSubEntities;
          }
     389  void PartDefinition::removeSubEntityDefinition(  SubEntityDefinition* def )
          {
           ModelDefinition::removeDefinition(  def,   mSubEntities );
          /* std::vector<SubEntityDefinition*>::iterator I;
           for (  I = mSubEntities.begin(   ); I != mSubEntities.end(   ); ++I ) {
           if (  *I == def )
           break;
           }
           if (  I != mSubEntities.end(   ) ) {
           mSubEntities.erase(  I );
           }*/
          }
          
          
     403  SubEntityDefinition::SubEntityDefinition(  unsigned int subEntityIndex,   PartDefinition& partdef ) : mSubEntityIndex(  subEntityIndex ),   mPartDef(  partdef )
          {
          }
          
     407  SubEntityDefinition::SubEntityDefinition(  const std::string& subEntityName,   PartDefinition& partdef ) : mSubEntityName(  subEntityName ),   mPartDef(  partdef )
          {
          /* SubEntityDefinition* def = new SubEntityDefinition(  subEntityName );
           mSubEntities.push_back(  def );
           return def;*/
          }
          
     414  PartDefinition& SubEntityDefinition::getPartDefinition(   )
          {
           return mPartDef;
          }
     418  const std::string& SubEntityDefinition::getSubEntityName(   ) const
          {
           return mSubEntityName;
          }
          
     423  unsigned int SubEntityDefinition::getSubEntityIndex(   ) const
          {
           return mSubEntityIndex;
          }
          //void setSubEntityName(  const std::string& );
          
     429  const std::string& SubEntityDefinition::getMaterialName(   ) const
          {
           return mMaterialName;
          }
          
     434  void SubEntityDefinition::setMaterialName(  const std::string& materialName )
          {
           mMaterialName = materialName;
          }
          
          
     440  AnimationDefinition::AnimationDefinition(  int iterations ) : mIterations(  iterations )
          {
          }
          
     444  AnimationPartDefinition* AnimationDefinition::createAnimationPartDefinition(  const std::string& ogreAnimationName,   Ogre::Real weight )
          {
           AnimationPartDefinition* def = new AnimationPartDefinition(   );
           def->Name = ogreAnimationName;
           def->Weight = weight;
           mAnimationParts.push_back(  def );
           return def;
          }
          
     453  const AnimationPartDefinitionsStore& AnimationDefinition::getAnimationPartDefinitions(   )
          {
           return mAnimationParts;
          }
          
     458  void AnimationDefinition::removeAnimationPartDefinition(  AnimationPartDefinition* def )
          {
           ModelDefinition::removeDefinition(  def,   mAnimationParts );
          }
          
          
          
          
     466  ActionDefinition::ActionDefinition(  const std::string& name ) : mName(  name ),   mAnimationSpeed(  1.0 )
          {
          }
          
     470  ActionDefinition::~ActionDefinition(   )
          {
           for (  AnimationDefinitionsStore::iterator I = mAnimations.begin(   ); I != mAnimations.end(   ); ++I ) {
           delete *I;
           }
           for (  SoundDefinitionsStore::iterator I = mSounds.begin(   ); I != mSounds.end(   ); ++I ) {
           delete *I;
           }
          
          }
          
     481  AnimationDefinition* ActionDefinition::createAnimationDefinition(  int iterations )
          {
           AnimationDefinition* def = new AnimationDefinition(  iterations );
           mAnimations.push_back(  def );
           return def;
          }
          
     488  const AnimationDefinitionsStore& ActionDefinition::getAnimationDefinitions(   )
          {
           return mAnimations;
          }
          
     493  void ActionDefinition::removeAnimationDefinition(  AnimationDefinition* def )
          {
           ModelDefinition::removeDefinition(  def,   mAnimations );
          }
          
          
     499  SoundDefinition* ActionDefinition::createSoundDefinition(  const std::string& name,   bool repeat,   Ogre::Real volume )
          {
           SoundDefinition* def = new SoundDefinition(   );
           def->Name = name;
           def->Repeat = repeat;
           def->Volume = volume;
           mSounds.push_back(  def );
           return def;
          }
          
     509  const SoundDefinitionsStore& ActionDefinition::getSoundDefinitions(   )
          {
           return mSounds;
          }
          
     514  void ActionDefinition::removeSoundDefinition(  SoundDefinition* def )
          {
           ModelDefinition::removeDefinition(  def,   mSounds );
          }
          
     519  const std::string& ActionDefinition::getName(   ) const
          {
           return mName;
          }
          
     524  const std::string& RenderingDefinition::getScheme(   ) const
          {
           return mScheme;
          }
     528  void RenderingDefinition::setScheme(  const std::string& scheme )
          {
           mScheme = scheme;
          }
     532  const StringParamStore& RenderingDefinition::getParameters(   ) const
          {
           return mParams;
          }
          
          
          
          };
          };

./components/ogre/model/ModelDefinition.h

          //
          // C++ Interface: ModelDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          // Copyright (  c ) 2005 The Cataclysmos Team
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREMODELDEFINITION_H
          #define EMBEROGREMODELDEFINITION_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          //#include <ext/hash_map>
          
          namespace EmberOgre {
          namespace Model {
          
          
      34  class Model;
      35  class PartDefinition;
      36  class SubModelDefinition;
      37  class ModelDefinition;
      38  class SubEntityDefinition;
          
      40  class ActionDefinition;
          struct SoundDefinition;
      42  class AnimationDefinition;
          struct AnimationPartDefinition;
          struct AttachPointDefinition;
          struct ViewDefinition;
          
          typedef std::map<std::string,   Model*> ModelInstanceStore;
          
          typedef std::vector<SubModelDefinition*> SubModelDefinitionsStore;
          typedef std::vector<PartDefinition*> PartDefinitionsStore;
          typedef std::vector<SubEntityDefinition*> SubEntityDefinitionsStore;
          typedef std::vector<AnimationDefinition*> AnimationDefinitionsStore;
          typedef std::vector<AnimationPartDefinition*> AnimationPartDefinitionsStore;
          typedef std::vector<SoundDefinition*> SoundDefinitionsStore;
          typedef std::vector<ActionDefinition*> ActionDefinitionsStore;
          typedef std::vector<AttachPointDefinition> AttachPointDefinitionStore;
          typedef std::map<std::string,   ViewDefinition*> ViewDefinitionStore;
          typedef std::map<std::string,   std::string> StringParamStore;
          
          /**
          A rendering definition. This allows you to specify a different render method than the default one (  regular Model ).
          All of this requires that you create functionality for implementing the different schemes that might be specified.
          */
      64  class RenderingDefinition
          {
      66  friend class XMLModelDefinitionSerializer;
          public:
          
          /**
           * Gets the scheme which will be used.
           * @return
           */
      73  const std::string& getScheme(   ) const;
          /**
           * Sets the scheme.
           * @param scheme
           */
      78  void setScheme(  const std::string& scheme );
          /**
           * Gets a collection of parameters for the rendering scheme.
           * @return
           */
      83  const StringParamStore& getParameters(   ) const;
          
          private:
      86  StringParamStore mParams;
      87  std::string mScheme;
          };
          
      90  class SubEntityDefinition
          {
      92  friend class PartDefinition;
          public:
      94   const std::string& getSubEntityName(   ) const;
      95   unsigned int getSubEntityIndex(   ) const;
           //void setSubEntityName(  const std::string& );
          
      98   const std::string& getMaterialName(   ) const;
      99   void setMaterialName(  const std::string& materialName );
          
     101   PartDefinition& getPartDefinition(   );
          
          private:
     104   SubEntityDefinition(  const std::string& subEntityName,   PartDefinition& partdef );
     105   SubEntityDefinition(  unsigned int subEntityIndex,   PartDefinition& partdef );
     106   std::string mSubEntityName;
     107   std::string mMaterialName;
           unsigned int mSubEntityIndex;
     109   PartDefinition& mPartDef;
          };
          
          
     113  class PartDefinition
          {
     115  friend class SubModelDefinition;
          public:
     117   ~PartDefinition(   );
          
     119   void setName(  const std::string& name );
     120   const std::string& getName(   ) const;
          
     122   void setGroup(  const std::string& group );
     123   const std::string& getGroup(   ) const;
          
     125   void setShow(  bool show );
     126   bool getShow(   ) const;
          
     128   SubEntityDefinition* createSubEntityDefinition(  const std::string& subEntityName );
     129   SubEntityDefinition* createSubEntityDefinition(  unsigned int subEntityIndex );
     130   const SubEntityDefinitionsStore& getSubEntityDefinitions(   );
     131   void removeSubEntityDefinition(  SubEntityDefinition* def );
          
     133   SubModelDefinition& getSubModelDefinition(   );
          
          private:
     136   PartDefinition(  const std::string& name,   SubModelDefinition& subModelDef );
     137   std::string mName;
     138   bool mShow;
     139   std::string mGroup;
     140   SubEntityDefinitionsStore mSubEntities;
     141   SubModelDefinition& mSubModelDef;
          };
          
          
     145  class SubModelDefinition
          {
     147  friend class ModelDefinition;
          public:
     149   ~SubModelDefinition(   );
          
     151   const std::string& getMeshName(   ) const;
          
     153   PartDefinition* createPartDefinition(  const std::string& partname );
     154   const PartDefinitionsStore& getPartDefinitions(   );
     155   void removePartDefinition(  PartDefinition* def );
          
     157   ModelDefinition& getModelDefinition(   );
          
          private:
     160   SubModelDefinition(  const std::string& meshname,   ModelDefinition& modelDef );
     161   std::string mMeshName;
     162   PartDefinitionsStore mParts;
     163   ModelDefinition& mModelDef;
          };
          
          /**
          A simple struct for defining a certain view of the Model. These settings needs to be applied to the camera rendering the Model.
          */
          struct ViewDefinition
          {
           /**
           The name of the view.
           */
           std::string Name;
          
           /**
           The rotation of the camera related to the Model.
           */
           Ogre::Quaternion Rotation;
          
           /**
           The distance of the camera from the Model.
           */
           float Distance;
          };
          
          struct AttachPointDefinition
          {
           std::string Name;
           std::string BoneName;
           Ogre::Quaternion Rotation;
          };
          
          struct AnimationPartDefinition
          {
           std::string Name;
           Ogre::Real Weight;
          };
          
     200  class AnimationDefinition
          {
     202  friend class ActionDefinition;
          public:
     204   AnimationPartDefinition* createAnimationPartDefinition(  const std::string& ogreAnimationName,   Ogre::Real weight = 1 );
     205   const AnimationPartDefinitionsStore& getAnimationPartDefinitions(   );
     206   void removeAnimationPartDefinition(  AnimationPartDefinition* def );
          
     208   inline const std::string& getName(   ) const;
     209   inline int getIterations(   ) const;
          
          private:
     212   AnimationDefinition(  int iterations );
          
     214   AnimationPartDefinitionsStore mAnimationParts;
     215   std::string mName;
           int mIterations;
          };
          
          struct SoundDefinition
          {
           std::string Name;
           bool Repeat;
           Ogre::Real Volume;
          };
          
     226  class ActionDefinition
          {
     228  friend class ModelDefinition;
          public:
     230   ~ActionDefinition(   );
          
     232   AnimationDefinition* createAnimationDefinition(  int iterations = 1 );
     233   const AnimationDefinitionsStore& getAnimationDefinitions(   );
     234   void removeAnimationDefinition(  AnimationDefinition* def );
          
     236   SoundDefinition* createSoundDefinition(  const std::string& name,   bool repeat,   Ogre::Real volume );
     237   const SoundDefinitionsStore& getSoundDefinitions(   );
     238   void removeSoundDefinition(  SoundDefinition* def );
          
     240   const std::string& getName(   ) const;
     241   Ogre::Real getAnimationSpeed(   ) const { return mAnimationSpeed; }
     242   void setAnimationSpeed(  Ogre::Real speed ) { mAnimationSpeed = speed; }
          
          private:
     245   ActionDefinition(  const std::string& name );
          
          
     248   std::string mName;
     249   AnimationDefinitionsStore mAnimations;
     250   SoundDefinitionsStore mSounds;
     251   Ogre::Real mAnimationSpeed;
          };
          
          
          /**
          @author Erik Hjortsberg
          */
     258  class ModelDefinition : public Ogre::Resource {
          
     260   friend class XMLModelDefinitionSerializer;
     261   friend class Model;
          
          public:
          
           /**
           whether to use a certain axis for scaling
           for example,   if you use a model of a human you probably want to scale according to the height
           this might mean that width and depths aren't correct though
           */
           enum UseScaleOf {
           MODEL_ALL = 0,  
           MODEL_NONE = 1,  
           MODEL_WIDTH = 2,  
           MODEL_DEPTH = 3,  
           MODEL_HEIGHT = 4
           };
          
          
           //th ModelDefinition(  const Ogre::String& name,   const Ogre::String& path );
          
     281   ModelDefinition(  Ogre::ResourceManager* creator,   const Ogre::String& name,   Ogre::ResourceHandle handle,  
     282   const Ogre::String& group,   bool isManual = false,   Ogre::ManualResourceLoader* loader = 0 );
          
     284   virtual ~ModelDefinition(   );
          
     286   bool isValid(  void );
     287   inline void setValid(  bool valid );
          
           //Ogre resource virtual functions
     290   void loadImpl(  void );
          
     292   void unloadImpl(  void );
          
     294   inline size_t calculateSize(  void ) const;
          
           //Model* createModel(  Ogre::String name,   Ogre::SceneManager* sceneManager );
          
           /**
           * Gets the amount of scale that needs to be applied to derived Models.
           * @return
           */
     302   inline Ogre::Real getScale(   ) const;
     303   inline void setScale(  Ogre::Real scale );
          
           /**
           * Gets how derived Models needs to be scaled.
           Defaults to "ALL"
           * @return
           */
     310   inline const UseScaleOf getUseScaleOf(   ) const;
     311   inline void setUseScaleOf(  const UseScaleOf useScale );
          
           /**
           * Gets an optional translation vector which should be applied to derived Models.
           * @return
           */
     317   const Ogre::Vector3& getTranslate(   ) const;
     318   void setTranslate(  const Ogre::Vector3 translate );
          
           /**
           * Whether contained entities should be shown or not.
           Defaults to true.
           * @return true if contained entities should be shown,   else false
           */
     325   bool getShowContained(   ) const;
     326   void getShowContained(  bool show );
          
           /**
           * If set to something else than 0,   all models beyond this distance won't be shown.
           * @return
           */
     332   inline float getRenderingDistance(   ) const;
     333   inline void setRenderingDistance(  float distance );
          
           /**
           * Returns a vector defining how much,   if ever,   contained entities should be offset.
           * If they shouldn't,   Ogre::Vector3::ZERO will be returned.
           * @return A offset vector.
           */
     340   inline const Ogre::Vector3& getContentOffset(   ) const;
     341   inline void setContentOffset(  const Ogre::Vector3& );
          
           /**
           * Gets the rotation of the model.
           * @return
           */
     347   const Ogre::Quaternion& getRotation(   ) const;
          
           /**
           * Sets the rotation of the model.
           * @param rotation
           */
     353   void setRotation(  const Ogre::Quaternion rotation );
          
          
           /**
           * Gets a path to an icon resource,   if defined.
           * @return a path to an image which can be used as an icon for the model
           */
     360   inline const std::string& getIconPath(   ) const;
          
          
           /**
           * Creates and returns a new sub model definition for the supplied mesh name.
           * @param meshname The name of the mesh to base the new sub model on. Must be a valid mesh.
           * @return
           */
     368   SubModelDefinition* createSubModelDefinition(  const std::string& meshname );
          
           /**
           * Returns all SubModelDefinitions defined.
           * @return The SubModelDefinitions store.
           */
     374   const SubModelDefinitionsStore& getSubModelDefinitions(   );
          
           /**
           * Removes a certain SubModelDefinition.
           * @param def The definition to remove.
           */
     380   void removeSubModelDefinition(  SubModelDefinition* def );
          
           /**
           * Creates and returns a new ActionDefintion with the given name.
           * @param actionname The name of the new ActionDefinition.
           * @return A pointer to the new ActionDefinition.
           */
     387   ActionDefinition* createActionDefinition(  const std::string& actionname );
          
           /**
           * Returns all ActionDefinitions defined.
           * @return
           */
     393   const ActionDefinitionsStore& getActionDefinitions(   );
          
           /**
           * Removes a certain ActionDefinition.
           * @param def The definition to remove.
           */
     399   void removeActionDefinition(  ActionDefinition* def );
          
     401   const AttachPointDefinitionStore& getAttachPointsDefinitions(   );
          
           /**
           Creates and returns a new ViewDefinition with the supplied name.
           @param viewname The name of the view
           @return A pointer to the new view.
           */
     408   ViewDefinition* createViewDefinition(  const std::string& viewname );
          
           /**
           * Returns all views defined.
           * @return
           */
     414   const ViewDefinitionStore& getViewDefinitions(   );
          
           /**
           * Removed a named view. If no view can be found,   no exception will be thrown.
           * @param name The name of the view to to remove.
           */
     420   void removeViewDefinition(  const std::string name );
          
          
           /**
           * Utility method for removing a defintion from a non-associative stores (  vector,   list etc. )
           * @param def The defintion to remove.
           * @param store The store to remove from.
           */
           template <typename T,   typename T1>
           static void removeDefinition(  T* def,   T1& store );
          
          
           /**
           * Reloads all the Model instances that uses this definition.
           */
           void reloadAllInstances(   );
          
           /**
           * Gets a pointer to the rendering scheme definition,   or null if none specified.
           * @return
           */
           const RenderingDefinition* getRenderingDefinition(   ) const;
          
          private:
          
          
           struct BindingDefinition
           {
           std::string EmitterVar;
           std::string AtlasAttribute;
           };
          
           typedef std::vector<BindingDefinition> BindingSet;
          
           struct ParticleSystemDefinition
           {
           std::string Script;
           BindingSet Bindings;
           };
          
           typedef std::vector<ParticleSystemDefinition> ParticleSystemSet;
          
          
          
          
           /**
           * Adds a model instance to the internal store of instances. This method should be called from the class Model when a new Model is created.
           * @param
           */
     469   void addModelInstance(  Model* );
           /**
           * Removed a model instance from the internal store of instances. This method should be called from the class Model when a new Model is removed.
           * @param
           */
     474   void removeModelInstance(  Model* );
          
           /**
           A store of all model instances of this definition.
           This can be used to update all instances at once.
           */
           ModelInstanceStore mModelInstances;
          
          
           /**
           The minimum distance at which the model will be shown.
           */
           float mRenderingDistance;
          
           SubModelDefinitionsStore mSubModels;
           ActionDefinitionsStore mActions;
           ParticleSystemSet mParticleSystems;
          
           AttachPointDefinitionStore mAttachPoints;
          
           UseScaleOf mUseScaleOf;
           Ogre::Real mScale;
           Ogre::Quaternion mRotation;
          // const Ogre::String mPath;
          
           /**
           Defines how much contained entities should be offset. ZERO if not.
           */
           Ogre::Vector3 mContentOffset;
          
           /**
           Whether contained entities should be shown or not.
           Defaults to true.
           */
           bool mShowContained;
          
           /**
           How,   if any,   to transform the model from the base position.
           Defaults to a zeroed vector.
           */
           Ogre::Vector3 mTranslate;
          
           bool mIsValid;
          
           ViewDefinitionStore mViews;
          
           /**
           A path to an image resource which can be shown as an icon for the model.
           */
           std::string mIconPath;
          
           RenderingDefinition* mRenderingDef;
          
          };
          
          /** Specialisation of SharedPtr to allow SharedPtr to be assigned to ModelDefnPtr
          @note Has to be a subclass since we need operator=.
          We could templatise this instead of repeating per Resource subclass,  
          except to do so requires a form VC6 does not support i.e.
          ResourceSubclassPtr<T> : public SharedPtr<T>
          */
     535  class ModelDefnPtr : public Ogre::SharedPtr<ModelDefinition>
          {
          public:
     538   ModelDefnPtr(   ) : Ogre::SharedPtr<ModelDefinition>(   ) {}
     539   explicit ModelDefnPtr(  ModelDefinition* rep ) : Ogre::SharedPtr<ModelDefinition>(  rep ) {}
     540   ModelDefnPtr(  const ModelDefnPtr& r ) : Ogre::SharedPtr<ModelDefinition>(  r ) {}
     541   ModelDefnPtr(  const Ogre::ResourcePtr& r ) : Ogre::SharedPtr<ModelDefinition>(   )
           {
           // lock & copy other mutex pointer
           OGRE_LOCK_MUTEX(  *r.OGRE_AUTO_MUTEX_NAME )
           OGRE_COPY_AUTO_SHARED_MUTEX(  r.OGRE_AUTO_MUTEX_NAME )
           pRep = static_cast<ModelDefinition*>(  r.getPointer(   ) );
           pUseCount = r.useCountPointer(   );
           if (  pUseCount )
           {
           ++(  *pUseCount );
           }
           }
          
           /// Operator used to convert a ResourcePtr to a ModelDefnPtr
     555   ModelDefnPtr& operator=(  const Ogre::ResourcePtr& r )
           {
           if (  pRep == static_cast<ModelDefinition*>(  r.getPointer(   ) ) )
           return *this;
           release(   );
           // lock & copy other mutex pointer
           OGRE_LOCK_MUTEX(  *r.OGRE_AUTO_MUTEX_NAME )
           OGRE_COPY_AUTO_SHARED_MUTEX(  r.OGRE_AUTO_MUTEX_NAME )
           pRep = static_cast<ModelDefinition*>(  r.getPointer(   ) );
           pUseCount = r.useCountPointer(   );
           if (  pUseCount )
           {
           ++(  *pUseCount );
           }
           return *this;
           }
          };
          
          typedef ModelDefnPtr ModelDefinitionPtr;
          
          
          ///implementations
          
     578  const Ogre::Vector3& ModelDefinition::getContentOffset(   ) const
          {
           return mContentOffset;
          }
     582  void ModelDefinition::setContentOffset(  const Ogre::Vector3& offset )
          {
           mContentOffset = offset;
          }
          
     587  void ModelDefinition::setValid(  bool valid )
          {
           mIsValid = valid;
          }
          
     592  size_t ModelDefinition::calculateSize(  void ) const
          {
           //TODO:implement this
           return 0;
          }
          
     598  Ogre::Real ModelDefinition::getScale(   ) const
          {
           return mScale;
          }
     602  void ModelDefinition::setScale(  Ogre::Real scale )
          {
           mScale = scale;
          }
          
     607  const ModelDefinition::UseScaleOf ModelDefinition::getUseScaleOf(   ) const
          {
           return mUseScaleOf;
          }
     611  void ModelDefinition::setUseScaleOf(  const UseScaleOf useScale )
          {
           mUseScaleOf = useScale;
          }
          
     616  float ModelDefinition::getRenderingDistance(   ) const
          {
           return mRenderingDistance;
          }
          
     621  void ModelDefinition::setRenderingDistance(  float distance )
          {
           mRenderingDistance = distance;
          }
          
     626  const std::string& ModelDefinition::getIconPath(   ) const
          {
           return mIconPath;
          }
          
     631  int AnimationDefinition::getIterations(   ) const
          {
           return mIterations;
          }
          
          
          
          
          }
          }
          #endif

./components/ogre/model/ModelDefinitionManager.cpp

       1  //
          // C++ Implementation: ModelDefinitionManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          // Copyright (  c ) 2005 The Cataclysmos Team
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          //perhaps this will make it build in debug mode without getting memory manager compile errors...
          
          #include "ModelDefinitionManager.h"
          #include "ModelDefinition.h"
          #include "Model.h"
          
          #include "XMLModelDefinitionSerializer.h"
          
          
          template<> EmberOgre::Model::ModelDefinitionManager* Ember::Singleton<EmberOgre::Model::ModelDefinitionManager>::ms_Singleton = 0;
          namespace EmberOgre
          {
          namespace Model {
          
      39  ModelDefinitionManager::ModelDefinitionManager(   ) : mShowModels(  true )
          {
           mLoadOrder = 300.0f;
           mResourceType = "ModelDefinition";
          
           mScriptPatterns.push_back(  "*.modeldef" );
           mScriptPatterns.push_back(  "*.modeldef.xml" );
           Ogre::ResourceGroupManager::getSingleton(   )._registerScriptLoader(  this );
          
           Ogre::ResourceGroupManager::getSingleton(   )._registerResourceManager(  mResourceType,   this );
          
          
           ///register factories
           ModelFactory* modelFactory = new ModelFactory(   );
           Ogre::Root::getSingleton(   ).addMovableObjectFactory(  modelFactory );
          
          }
          
          
          
      59  ModelDefinitionManager::~ModelDefinitionManager(   )
          {
           Ogre::ResourceGroupManager::getSingleton(   )._unregisterResourceManager(  mResourceType );
           Ogre::ResourceGroupManager::getSingleton(   )._unregisterScriptLoader(  this );
           ///we need to make sure that all Models are destroyed before Ogre begins destroying other movable objects (  such as Entities )
           ///this is because Model internally uses Entities,   so if those Entities are destroyed by Ogre before the Models are destroyed,   the Models will try to delete them again,   causing segfaults and other wickedness
           Ogre::SceneManagerEnumerator::SceneManagerIterator sceneManagerIterator = Ogre::SceneManagerEnumerator::getSingleton(   ).getSceneManagerIterator(   );
           while (  sceneManagerIterator.hasMoreElements(   ) ) {
           sceneManagerIterator.getNext(   )->destroyAllMovableObjectsByType(  Model::sMovableType );
           }
          }
          
          
          
          
      74  Ogre::ResourcePtr ModelDefinitionManager::create(  const Ogre::String& name,   const Ogre::String& group,  
      75  bool isManual,   Ogre::ManualResourceLoader* loader,  
      76  const Ogre::NameValuePairList* createParams )
          {
           Ogre::ResourcePtr ret = getByName(  name );
           if (  ret.isNull(   ) )
           {
           return Ogre::ResourceManager::create(  name,   group,   isManual,   loader,   createParams );
           }
           S_LOG_FAILURE(  "ModelDefinition with name " << name << " already exists." );
           return Ogre::ResourcePtr(   );
          
          }
          
      88  void ModelDefinitionManager::parseScript (  Ogre::DataStreamPtr &stream,   const Ogre::String &groupName )
          {
           XMLModelDefinitionSerializer serializer;
           serializer.parseScript(  stream,   groupName );
          }
          
      94  void ModelDefinitionManager::exportScript(  ModelDefnPtr definition )
          {
           XMLModelDefinitionSerializer serializer;
           serializer.exportScript(  definition,   definition->getName(   ) + ".modeldef" );
          }
          
     100  Ogre::Resource* ModelDefinitionManager::createImpl(  const Ogre::String& name,   Ogre::ResourceHandle handle,  
     101   const Ogre::String& group,   bool isManual,   Ogre::ManualResourceLoader* loader,  
     102   const Ogre::NameValuePairList* createParams )
          {
           return new ModelDefinition(  this,   name,   handle,   group,   isManual,   loader );
          }
          
     107  const std::vector<std::string> ModelDefinitionManager::getAllMeshes(   ) const
          {
           std::vector<std::string> meshes;
           Ogre::StringVectorPtr meshesVector = Ogre::ResourceGroupManager::getSingleton(   ).findResourceNames(  "General",   "*.mesh" );
           for (  Ogre::StringVector::iterator I = meshesVector->begin(   ); I != meshesVector->end(   ); ++I ) {
           meshes.push_back(  std::string(  *I ) );
           }
           meshesVector.setNull(   );
           return meshes;
          }
          
     118  bool ModelDefinitionManager::getShowModels(   ) const
          {
           return mShowModels;
          }
          
     123  void ModelDefinitionManager::setShowModels(  bool show )
          {
           mShowModels = show;
          }
          
          
          }
          }

./components/ogre/model/ModelDefinitionManager.h

       1  //
          // C++ Interface: ModelManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          // Copyright (  c ) 2005 The Cataclysmos Team
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREMODELMANAGER_H
          #define EMBEROGREMODELMANAGER_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          #include <OgreResourceManager.h>
          #include "framework/Singleton.h"
          #include "ModelDefinition.h"
          
          namespace EmberOgre {
          namespace Model {
          
          /**
          @author Erik Hjortsberg
          */
      39  class ModelDefinitionManager: public Ogre::ResourceManager,   public Ember::Singleton<ModelDefinitionManager>
          {
          public:
           /// Constructor
      43   ModelDefinitionManager(   );
      44   virtual ~ModelDefinitionManager(   );
          
      46   virtual Ogre::ResourcePtr create(  const Ogre::String& name,   const Ogre::String& group,  
      47   bool isManual = false,   Ogre::ManualResourceLoader* loader = 0,  
      48   const Ogre::NameValuePairList* createParams = 0 );
          
      50   virtual void parseScript (  Ogre::DataStreamPtr &stream,   const Ogre::String &groupName );
          
           /**
           * Exports a modeldefinition to a file.
           * @param definition
           */
      56   void exportScript(  ModelDefnPtr definition );
          
           /**
           * Gets a vector of all mesh names.
           * @return
           */
      62   const std::vector<std::string> getAllMeshes(   ) const;
          
           /**
           * Returns whether models should be shown.
           * @return
           */
      68   bool getShowModels(   ) const;
          
           /**
           * Sets whether models should be shown.
           * @param show
           */
      74   void setShowModels(  bool show );
          
          protected:
          
      78   Ogre::Resource* createImpl(  const Ogre::String& name,   Ogre::ResourceHandle handle,  
      79   const Ogre::String& group,   bool isManual,   Ogre::ManualResourceLoader* loader,  
      80   const Ogre::NameValuePairList* createParams );
          
           /**
           Determines whether models should be shown.
           */
      85   bool mShowModels;
          
          };
          
          }
          };
          
          #endif

./components/ogre/model/ParticleSystem.cpp

       1  //
          // C++ Implementation: ParticleSystem
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ParticleSystem.h"
          #include "ParticleSystemBinding.h"
          
          namespace EmberOgre {
          namespace Model {
          
      29  Ogre::ParticleSystem* ParticleSystem::getOgreParticleSystem(   )
          {
           return mOgreParticleSystem;
          }
          
      34  ParticleSystem::ParticleSystem(  Ogre::ParticleSystem* ogreParticleSystem ) :
           mOgreParticleSystem(  ogreParticleSystem )
          {
           assert(  ogreParticleSystem );
          }
          
      40  ParticleSystem::~ParticleSystem(   )
          {
           //make sure all bindings are removed
           ParticleSystemBindingsPtrSet::const_iterator I = mBindings.begin(   );
           ParticleSystemBindingsPtrSet::const_iterator I_end = mBindings.end(   );
           for (  ; I != I_end; ++I ) {
           delete *I;
           }
           mBindings.clear(   );
          
           //and then destroy the system to save resources
           mOgreParticleSystem->_getManager(   )->destroyParticleSystem(  mOgreParticleSystem );
          
          }
          
          
      56  ParticleSystemBindingsPtrSet& ParticleSystem::getBindings(    )
          {
           return mBindings;
          }
          
      61  ParticleSystemBinding * ParticleSystem::addBinding(   const std::string & emitterVal,   const std::string & variableName  )
          {
           ParticleSystemBinding* binding = new ParticleSystemBinding(  this,   emitterVal,   variableName );
           mBindings.push_back(  binding );
           return binding;
          }
          
          }
          }

./components/ogre/model/ParticleSystem.h

       1  //
          // C++ Interface: ParticleSystem
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREPARTICLESYSTEM_H
          #define EMBEROGREPARTICLESYSTEM_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include <vector>
          
          namespace EmberOgre {
          namespace Model {
          
      32  class ParticleSystemBinding;
          
          typedef std::vector<ParticleSystemBinding*> ParticleSystemBindingsPtrSet;
          
          /**
          @author Erik Hjortsberg
          */
      39  class ParticleSystem
          {
          public:
      42   ParticleSystem(  Ogre::ParticleSystem* ogreParticleSystem );
      43   virtual ~ParticleSystem(   );
      44   Ogre::ParticleSystem* getOgreParticleSystem(   );
          
           /**
           * Adds a new binding.
           * @param emitterVal the name of the particle emitter
           * @param variableName the name of the atlas attribute
           * @return a pointer to the newly created binding
           */
      52   ParticleSystemBinding* addBinding(  const std::string& emitterVal,   const std::string& variableName );
      53   ParticleSystemBindingsPtrSet& getBindings(   );
          protected:
           Ogre::ParticleSystem* mOgreParticleSystem;
      56   ParticleSystemBindingsPtrSet mBindings;
          
          };
          
          }
          }
          
          #endif

./components/ogre/model/ParticleSystemBinding.cpp

       1  //
          // C++ Implementation: ParticleSystemBinding
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ParticleSystemBinding.h"
          #include "ParticleSystem.h"
          
          namespace EmberOgre {
          namespace Model {
          
      29  ParticleSystemBinding::ParticleSystemBinding(  ParticleSystem* parentSystem,   const std::string& emitterVal,   const std::string& variableName ) :
          mEmitterVal(  emitterVal )
          ,   mVariableName(  variableName )
          ,   mParticleSystem(  parentSystem )
          ,   mOriginalValue(  0 )
          {
           //TODO: add more emitter values to bind
           if (  mEmitterVal == "emission_rate" ) {
           Ogre::ParticleEmitter* emitter = mParticleSystem->getOgreParticleSystem(   )->getEmitter(  0 );
           if (  emitter ) {
           mOriginalValue = emitter->getEmissionRate(   );
           }
           }
          
          }
          
      45  void ParticleSystemBinding::scaleValue(  Ogre::Real scaler )
          {
          
           //TODO: add more emitter values to bind
           if (  mEmitterVal == "emission_rate" ) {
           Ogre::ParticleEmitter* emitter = mParticleSystem->getOgreParticleSystem(   )->getEmitter(  0 );
           if (  emitter ) {
           emitter->setEmissionRate(  mOriginalValue * scaler );
           }
           }
          }
          
          }
          }

./components/ogre/model/ParticleSystemBinding.h

       1  //
          // C++ Interface: ParticleSystemBinding
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREPARTICLESYSTEMBINDING_H
          #define EMBEROGREPARTICLESYSTEMBINDING_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include <string>
          
          namespace EmberOgre {
          namespace Model {
          
      32  class ParticleSystem;
          /**
          @author Erik Hjortsberg
          */
      36  class ParticleSystemBinding
          {
          public:
      39   ParticleSystemBinding(  ParticleSystem* parentSystem,   const std::string& emitterVal,   const std::string& variableName );
      40   void scaleValue(  Ogre::Real scaler );
          private:
      42   std::string mEmitterVal;
      43   std::string mVariableName;
      44   ParticleSystem* mParticleSystem;
      45   Ogre::Real mOriginalValue;
          public:
      47   inline const std::string& getEmitterVal(   ) const {return mEmitterVal;}
      48   inline const std::string& getVariableName(   ) const {return mVariableName;}
          
          };
          }
          }
          #endif

./components/ogre/model/SubModel.cpp

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "SubModel.h"
          #include "Model.h"
          
          #include "SubModelPart.h"
          #include "ModelDefinitionManager.h"
          
          namespace EmberOgre {
          namespace Model {
          
      28  SubModel::SubModel(  Ogre::Entity* entity ) :
          mEntity(  entity )
          {
           //begin by hiding all subentities
           unsigned int numSubEntities = mEntity->getNumSubEntities(   );
           for (  unsigned int i = 0;i < numSubEntities; ++i ) {
           mEntity->getSubEntity(  i )->setVisible(  false );
           }
          
          }
      38  SubModel::~SubModel(   )
          {
           for (  SubModelPartMap::iterator I = mSubModelParts.begin(   ); I != mSubModelParts.end(   ); ++I ) {
           delete I->second;
           }
           if (  mEntity ) {
           Ogre::SceneManager* sceneManager = mEntity->_getManager(   );
           sceneManager->destroyEntity(  mEntity );
           }
          
          }
          
      50  std::map<std::string,   SubModelPart*>* SubModel::getSubModelPartMap(   )
          {
           return &mSubModelParts;
          
          }
          
      56  SubModelPart* SubModel::createSubModelPart(  const std::string& name )
          {
           SubModelPart* part = new SubModelPart(  name );
           mSubModelParts.insert(  SubModelPartMap::value_type(  name,   part ) );
           return part;
          
          }
          
          // void SubModel::createSubModelParts(  SubModelPartMapping* submodelPartMapping )
          // {
          // SubModelPartMapping::const_iterator I = submodelPartMapping->begin(   );
          // SubModelPartMapping::const_iterator I_end = submodelPartMapping->end(   );
          //
          // for (  ;I != I_end; ++I ) {
          // std::string partname = I->first;
          // SubModelPart* part = new SubModelPart(  partname );
          // std::set<std::string>::const_iterator J = I->second.begin(   );
          // std::set<std::string>::const_iterator J_end = I->second.end(   );
          // if (  J == J_end ) {
          // //if the set is empty add all subentities
          // unsigned int numSubEntities = mEntity->getNumSubEntities(   );
          // for (  unsigned int i = 0;i < numSubEntities; ++i ) {
          // part->addSubEntity(  mEntity->getSubEntity(  i ) );
          // }
          // } else {
          // for (  ;J != J_end; ++J ) {
          // part->addSubEntity(  mEntity->getSubEntity(  *J ) );
          // }
          // }
          // mSubModelParts.insert(  SubModelPartMap::value_type(  partname,   part ) );
          //
          // }
          //
          //
          // }
          
      92  Ogre::Entity* SubModel::getEntity(   ) const
          {
           return mEntity;
          }
          
          
          
          /*
          bool SubModel::addEntity(  Ogre::Entity* entity )
          {
           mEntities.insert(  entity );
           return true;
          }
          
          bool SubModel::removeEntity(  Ogre::Entity* entity )
          {
           mEntities.erase(  entity );
           return true;
          }
          */
          
          }
          }

./components/ogre/model/SubModel.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef SUBMODEL_H
          #define SUBMODEL_H
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include <OgreEntity.h>
          #include <OgreMovableObject.h>
          
          namespace EmberOgre {
          namespace Model {
          
      28  class Model;
      29  class SubModelPart;
      30  class ModelDefinition;
          
      32  class SubModel{
      33  friend class ModelDefinition;
          public:
           typedef std::map<std::string,   std::set<std::string> > SubModelPartMapping;
           typedef std::map<std::string,   SubModelPart*> SubModelPartMap;
          
      38   SubModel(  Ogre::Entity* entity );
      39   virtual ~SubModel(   );
          
      41   SubModelPart* createSubModelPart(  const std::string& name );
          
      43   SubModelPartMap* getSubModelPartMap(   );
          
      45   Ogre::Entity* getEntity(   ) const;
          
          protected:
      48   Ogre::Entity* mEntity;
      49   SubModelPartMap mSubModelParts;
          
          };
          
          }
          }
          
          #endif // SUBMODEL_H

./components/ogre/model/SubModelPart.cpp

       1  /*
          -------------------------------------------------------------------------------
           This source file is part of Cataclysmos
           For the latest info,   see http://www.cataclysmos.org/
          
           Copyright (  c ) 2005 The Cataclysmos Team
           Copyright (  C ) 2005 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or
           modify it under the terms of the GNU General Public License
           as published by the Free Software Foundation; either version 2
           of the License,   or (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   59 Temple Place - Suite 330,   Boston,   MA 02111-1307,   USA.
          -------------------------------------------------------------------------------
          */
          #include "SubModelPart.h"
          #include "Model.h"
          #include "SubModel.h"
          
          namespace EmberOgre {
          namespace Model {
          
      31  SubModelPart::SubModelPart(  std::string name )
          : mName(  name )
          {}
      34  SubModelPart::~SubModelPart(   )
          {
           //no need to try to delete the Ogre::Subentities in the mSubEntities store,   since Ogre will take care of this
          }
          
          
      40  bool SubModelPart::addSubEntity(  Ogre::SubEntity* subentity,   SubEntityDefinition* definition )
          {
           SubModelPartEntity modelPartEntity;
           modelPartEntity.Definition = definition;
           modelPartEntity.SubEntity = subentity;
           mSubEntities.push_back(  modelPartEntity );
           return true;
          }
      48  bool SubModelPart::removeSubEntity(  Ogre::SubEntity* subentity )
          {
           for (  SubModelPartEntityStore::iterator I = mSubEntities.begin(   ); I != mSubEntities.end(   ); ++I )
           {
           if (  I->SubEntity == subentity ) {
           mSubEntities.erase(  I );
           return true;
           }
           }
           return false;
          }
          
      60  const std::string& SubModelPart::getName(   ) const
          {
           return mName;
          }
          
      65  void SubModelPart::show(   )
          {
           SubModelPartEntityStore::const_iterator I;
           for (  I = mSubEntities.begin(   ); I != mSubEntities.end(   ); I++ ) {
           if (  I->Definition && I->Definition->getMaterialName(   ) != "" ) {
           I->SubEntity->setMaterialName(  I->Definition->getMaterialName(   ) );
           } else {
           ///if no material name is set in the ModelDefinition,   use the default one from the mesh
           I->SubEntity->setMaterialName(  I->SubEntity->getSubMesh(   )->getMaterialName(   ) );
           }
          
           I->SubEntity->setVisible(  true );
           }
          }
          
      80  void SubModelPart::hide(   )
          {
           SubModelPartEntityStore::const_iterator I;
           for (  I = mSubEntities.begin(   ); I != mSubEntities.end(   ); I++ ) {
           I->SubEntity->setVisible(  false );
           }
          }
          
      88  const SubModelPart::SubModelPartEntityStore& SubModelPart::getSubentities(   ) const
          {
           return mSubEntities;
          }
          
          }
          }

./components/ogre/model/SubModelPart.h

       1  /*
          -------------------------------------------------------------------------------
           This source file is part of Cataclysmos
           For the latest info,   see http://www.cataclysmos.org/
          
           Copyright (  c ) 2005 The Cataclysmos Team
           Copyright (  C ) 2005 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or
           modify it under the terms of the GNU General Public License
           as published by the Free Software Foundation; either version 2
           of the License,   or (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   59 Temple Place - Suite 330,   Boston,   MA 02111-1307,   USA.
          -------------------------------------------------------------------------------
          */
          #ifndef SUBMODELPART_H
          #define SUBMODELPART_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include <OgreEntity.h>
          #include <OgreMovableObject.h>
          
          namespace EmberOgre {
          namespace Model {
          
      34  class SubModel;
      35  class Model;
      36  class ModelDefinition;
      37  class SubEntityDefinition;
          
          struct SubModelPartEntity
          {
          public:
           SubEntityDefinition* Definition;
           Ogre::SubEntity* SubEntity;
          };
          
          
      47  class SubModelPart{
      48  friend class ModelDefinition;
          public:
           typedef std::set<Ogre::SubEntity*> SubEntitySet;
           typedef std::vector<SubModelPartEntity> SubModelPartEntityStore;
          
      53   SubModelPart(  std::string name );
      54   virtual ~SubModelPart(   );
          
          
      57   bool addSubEntity(  Ogre::SubEntity* subentity,   SubEntityDefinition* definition );
      58   bool removeSubEntity(  Ogre::SubEntity* subentity );
          
      60   void show(   );
      61   void hide(   );
          
      63   const std::string& getName(   ) const;
          
      65   const SubModelPartEntityStore& getSubentities(   ) const;
          
          protected:
      68   std::string mName;
      69   SubModelPartEntityStore mSubEntities;
          };
          
          }
          }
          #endif // SUBMODELPART_H

./components/ogre/model/XMLModelDefinitionSerializer.cpp

       1  /*
          -------------------------------------------------------------------------------
           This source file is part of Cataclysmos
           For the latest info,   see http://www.cataclysmos.org/
          
           Copyright (  c ) 2005 The Cataclysmos Team
           Copyright (  C ) 2005 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or
           modify it under the terms of the GNU General Public License
           as published by the Free Software Foundation; either version 2
           of the License,   or (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   59 Temple Place - Suite 330,   Boston,   MA 02111-1307,   USA.
          -------------------------------------------------------------------------------
          */
          // Includes
          #include "XMLModelDefinitionSerializer.h"
          #include "ModelDefinition.h"
          #include "Model.h"
          #include "components/ogre/XMLHelper.h"
          
          #include "ModelDefinitionManager.h"
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          
          #ifdef WIN32
           #include <tchar.h>
           #define snprintf _snprintf
           #include <io.h> // for _access,   Win32 version of stat(   )
           #include <direct.h> // for _mkdir
          // #include <sys/stat.h>
          
          
           //#include <iostream>
           //#include <fstream>
           //#include <ostream>
          #endif
          
          #include "framework/osdir.h"
          
          namespace EmberOgre {
          namespace Model {
          
      53  XMLModelDefinitionSerializer::XMLModelDefinitionSerializer(   )
          {}
          
      56  XMLModelDefinitionSerializer::~XMLModelDefinitionSerializer(   )
          {}
      58  void XMLModelDefinitionSerializer::importModelDefinition(  Ogre::DataStreamPtr& stream,   ModelDefinition* pModelDef )
          {
          }
          
      62  void XMLModelDefinitionSerializer::parseScript(  Ogre::DataStreamPtr& stream,   const Ogre::String& groupName )
          {
           Ember::TiXmlDocument xmlDoc;
           XMLHelper xmlHelper;
           if (  !xmlHelper.Load(  xmlDoc,   stream ) ) {
           return;
           }
          
           Ember::TiXmlElement* rootElem = xmlDoc.RootElement(   );
          
           for (  Ember::TiXmlElement* smElem = rootElem->FirstChildElement(   );
           smElem != 0; smElem = smElem->NextSiblingElement(   ) )
           {
           const char* tmp = smElem->Attribute(  "name" );
           std::string name;
           if (  !tmp ) {
           continue;
           } else {
           name = tmp;
           }
          
           try {
           ModelDefinitionPtr modelDef = ModelDefinitionManager::getSingleton(   ).create(  name,   groupName );
           if (  !modelDef.isNull(   ) ) {
           readModel(  modelDef,   smElem );
           modelDef->setValid(  true );
           }
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  ex.getFullDescription(   ) );
           //std::cerr << ex.getFullDescription(   );
           }
          
           //modelDef->_notifyOrigin(  context.filename );
           }
          
          }
          
      99  void XMLModelDefinitionSerializer::readModel(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* modelNode )
          {
           Ember::TiXmlElement* elem;
           //root elements
           //scale
           const char* tmp = modelNode->Attribute(  "scale" );
           if (  tmp )
           modelDef->mScale=Ogre::StringConverter::parseReal(  tmp );
          
          /* //rotation
           ///TODO: change this into a better system,   perhaps using quaternions,   instead of like now just rotating around the y-axis
           tmp = modelNode->Attribute(  "rotation" );
           if (  tmp )
           modelDef->mRotation = Ogre::StringConverter::parseReal(  tmp );*/
          
           //showcontained
           tmp = modelNode->Attribute(  "showcontained" );
           if (  tmp )
           modelDef->mShowContained = Ogre::StringConverter::parseBool(  tmp );
          
           //usescaleof
           tmp = modelNode->Attribute(  "usescaleof" );
           if (  tmp )
           {
           std::string useScaleOf(  tmp );
           if (  useScaleOf == "height" )
           modelDef->mUseScaleOf = ModelDefinition::MODEL_HEIGHT;
           else if (  useScaleOf == "width" )
           modelDef->mUseScaleOf = ModelDefinition::MODEL_WIDTH;
           else if (  useScaleOf == "depth" )
           modelDef->mUseScaleOf = ModelDefinition::MODEL_DEPTH;
           else if (  useScaleOf == "none" )
           modelDef->mUseScaleOf = ModelDefinition::MODEL_NONE;
           }
          
           tmp = modelNode->Attribute(  "renderingdistance" );
           if (  tmp )
           {
           modelDef->setRenderingDistance(  Ogre::StringConverter::parseReal(  tmp ) );
           }
          
           tmp = modelNode->Attribute(  "icon" );
           if (  tmp ) {
           modelDef->mIconPath = tmp;
           }
          
          
           //submodels
           elem = modelNode->FirstChildElement(  "submodels" );
           if (  elem )
           readSubModels(  modelDef,   elem );
          
           //actions
           elem = modelNode->FirstChildElement(  "actions" );
           if (  elem )
           readActions(  modelDef,   elem );
          
           //attachpoints
           elem = modelNode->FirstChildElement(  "attachpoints" );
           if (  elem )
           readAttachPoints(  modelDef,   elem );
          
           //attachpoints
           elem = modelNode->FirstChildElement(  "particlesystems" );
           if (  elem )
           readParticleSystems(  modelDef,   elem );
          
           //views
           elem = modelNode->FirstChildElement(  "views" );
           if (  elem )
           readViews(  modelDef,   elem );
          
           elem = modelNode->FirstChildElement(  "translate" );
           if (  elem )
           {
           modelDef->mTranslate = fillVector3FromElement(  elem );
           }
          
           elem = modelNode->FirstChildElement(  "rotation" );
           if (  elem )
           {
           modelDef->setRotation(  fillQuaternionFromElement(  elem ) );
           }
          
           elem = modelNode->FirstChildElement(  "contentoffset" );
           if (  elem )
           {
           Ogre::Vector3 offset = fillVector3FromElement(  elem );
           modelDef->setContentOffset(  offset );
           }
          
           elem = modelNode->FirstChildElement(  "rendering" );
           if (  elem )
           {
           modelDef->mRenderingDef = new RenderingDefinition(   );
           tmp = elem->Attribute(  "scheme" );
           if (  tmp ) {
           modelDef->mRenderingDef->setScheme(  tmp );
           }
           for (  Ember::TiXmlElement* paramElem = elem->FirstChildElement(  "param" );
           paramElem != 0; paramElem = paramElem->NextSiblingElement(   ) )
           {
           tmp = paramElem->Attribute(  "key" );
           if (  tmp ) {
           modelDef->mRenderingDef->mParams.insert(  StringParamStore::value_type(  tmp,   paramElem->GetText(   ) ) );
           }
           }
           }
          
          }
          
          
          
     212  void XMLModelDefinitionSerializer::readSubModels(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* mSubModelNode )
          {
           S_LOG_VERBOSE(   "Read Submodels"  );
           const char* tmp = 0;
           Ember::TiXmlElement* elem;
           bool notfound = true;
          
           for (  Ember::TiXmlElement* smElem = mSubModelNode->FirstChildElement(   );
           smElem != 0; smElem = smElem->NextSiblingElement(   ) )
           {
           notfound = false;
          
           tmp = smElem->Attribute(  "mesh" );
           if (  tmp )
           {
           SubModelDefinition* subModelDef = modelDef->createSubModelDefinition(  tmp );
          
           S_LOG_VERBOSE(   " Add submodel : "+ subModelDef->getMeshName(   )  );
           try
           {
           //preload
           //FIX Ogre::MeshManager::getSingleton(   ).load(  subModelDef.Mesh );
          /* Ogre::MeshManager::getSingleton(   ).load(   subModelDef.Mesh,  
           Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME  );*/
          
           //parts
          
           elem = smElem->FirstChildElement(  "parts" );
           if (  elem )
           readParts(  elem,   subModelDef );
          
          // modelDef->mSubModels.push_back(  subModelDef );
          
           }
           catch (  const Ogre::Exception& e )
           {
           S_LOG_FAILURE(  "Load error : " << tmp );
           }
           }
           }
          
           if(  notfound )
           {
           S_LOG_VERBOSE(   "No submodel found." );
           }
          }
          
     259  void XMLModelDefinitionSerializer::readParts(  Ember::TiXmlElement* mPartNode,   SubModelDefinition* def )
          {
           Ember::TiXmlElement* elem;
           const char* tmp = 0;
           bool notfound = true;
          
           for (  Ember::TiXmlElement* partElem = mPartNode->FirstChildElement(   );
           partElem != 0; partElem = partElem->NextSiblingElement(   ) )
           {
          
           // name
           tmp = partElem->Attribute(  "name" );
           if (  tmp ) {
           notfound = false;
          
           PartDefinition* partDef = def->createPartDefinition(  tmp );
          
           S_LOG_VERBOSE(   " Add part : "+ partDef->getName(   )  );
          
           // show
           tmp = partElem->Attribute(  "show" );
           if (  tmp )
           partDef->setShow(  Ogre::StringConverter::parseBool(  tmp ) );
          
           tmp = partElem->Attribute(  "group" );
           if (  tmp )
           partDef->setGroup(  tmp );
          
           elem = partElem->FirstChildElement(  "subentities" );
           if (  elem )
           readSubEntities(  elem,   partDef );
          
           } else {
           S_LOG_FAILURE(   "A name must be specified for each part."  );
           }
           }
          
           if(  notfound )
           {
           S_LOG_VERBOSE(   "No part found."  );
           }
          }
          
     302  void XMLModelDefinitionSerializer::readSubEntities(  Ember::TiXmlElement* mSubEntNode,   PartDefinition* def )
          {
          
           const char* tmp = 0;
           bool notfound = true;
          
           for (  Ember::TiXmlElement* seElem = mSubEntNode->FirstChildElement(   );
           seElem != 0; seElem = seElem->NextSiblingElement(   ) )
           {
           SubEntityDefinition* subEntityDef = 0;
           // name
           tmp = seElem->Attribute(  "index" );
           if (  tmp ) {
           notfound = false;
           subEntityDef = def->createSubEntityDefinition(  Ogre::StringConverter::parseInt(  tmp ) );
           S_LOG_VERBOSE(   " Add sub entity with index: " << subEntityDef->getSubEntityIndex(   ) );
           } else {
           tmp = seElem->Attribute(  "name" );
           if (  tmp ) {
           notfound = false;
           subEntityDef = def->createSubEntityDefinition(  tmp );
           S_LOG_VERBOSE(   " Add sub entity: " << subEntityDef->getSubEntityName(   ) );
           }
           }
           if (  !notfound ) {
           //material
           tmp = seElem->Attribute(  "material" );
           if (  tmp )
           {
           subEntityDef->setMaterialName(  tmp );
           //preload subEntityDef.Material
           //Ogre::MaterialManager::getSingleton(   ).load(   subEntityDef.Material,  
           //Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME  );
          
           }
          
           } else {
           S_LOG_FAILURE(   "A subentity name or index must be specified for each subentity."  );
           }
           }
          
           if(  notfound )
           {
           S_LOG_VERBOSE(   "No sub entity found."  );
           }
          }
          
     349  void XMLModelDefinitionSerializer::readActions(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* mAnimNode )
          {
           Ember::TiXmlElement* elem;
           const char* tmp = 0;
           bool notfound = true;
           S_LOG_VERBOSE(   "Read Actions"  );
          
           for (  Ember::TiXmlElement* animElem = mAnimNode->FirstChildElement(   );
           animElem != 0; animElem = animElem->NextSiblingElement(   ) )
           {
           notfound=false;
          
           tmp = animElem->Attribute(  "name" );
           if (  tmp ) {
           ActionDefinition* actionDef = modelDef->createActionDefinition(  tmp );
           S_LOG_VERBOSE(   " Add action : "<< tmp  );
          
           tmp = animElem->Attribute(  "speed" );
           if (  tmp ) {
           actionDef->setAnimationSpeed(  Ogre::StringConverter::parseReal(  tmp ) );
           }
          
          
           elem = animElem->FirstChildElement(  "animations" );
           if (  elem )
           readAnimations(  elem,   actionDef );
          
           elem = animElem->FirstChildElement(  "sound" );
           if (  elem ) {
           //only attach one sound to each action
           std::string name;
           bool repeat = false;
           Ogre::Real volume = 1.0f;
           tmp = animElem->Attribute(  "name" );
           if (  tmp ) {
           name = tmp;
           tmp = animElem->Attribute(  "repeat" );
           if (  tmp ) {
           repeat = Ogre::StringConverter::parseBool(  tmp );
           }
           tmp = animElem->Attribute(  "volume" );
           if (  tmp ) {
           volume = Ogre::StringConverter::parseReal(  tmp );
           }
           actionDef->createSoundDefinition(  name,   repeat,   volume );
           }
           }
           }
          
           }
          
           if(  notfound )
           {
           S_LOG_VERBOSE(   "No actions found."  );
           }
          
          }
          
     407  void XMLModelDefinitionSerializer::readAnimations(  Ember::TiXmlElement* mAnimationsNode,   ActionDefinition* action )
          {
           const char* tmp = 0;
           bool nopartfound = true;
          
          
           for (  Ember::TiXmlElement* animElem = mAnimationsNode->FirstChildElement(   );
           animElem != 0; animElem = animElem->NextSiblingElement(   ) )
           {
           int iterations(  1 );
           nopartfound = false;
          
           // name
           tmp = animElem->Attribute(  "iterations" );
           if (  tmp ) {
           iterations = Ogre::StringConverter::parseInt(  tmp );
           }
          
           AnimationDefinition* animDef = action->createAnimationDefinition(  iterations );
           readAnimationParts(  animElem,   animDef );
           }
          
           if(  nopartfound )
           {
           S_LOG_VERBOSE(   " No animations found!!"  );
           }
          
          }
          
     436  void XMLModelDefinitionSerializer::readAnimationParts(  Ember::TiXmlElement* mAnimPartNode,   AnimationDefinition* animDef )
          {
           const char* tmp = 0;
           bool nopartfound = true;
          
           for (  Ember::TiXmlElement* apElem = mAnimPartNode->FirstChildElement(   );
           apElem != 0; apElem = apElem->NextSiblingElement(   ) )
           {
           std::string name;
           Ogre::Real weight = 1.0f;
           nopartfound = false;
          
           // name
           tmp = apElem->Attribute(  "name" );
           if (  tmp ) {
           name = tmp;
           S_LOG_VERBOSE(   " Add animation : "+ name  );
           }
          
          
           // weight
           tmp = apElem->Attribute(  "weight" );
           if (  tmp )
           weight = Ogre::StringConverter::parseReal(  tmp );
          
           animDef->createAnimationPartDefinition(  name,   weight );
           }
          
           if(  nopartfound )
           {
           S_LOG_VERBOSE(   " No anim parts found."  );
           }
          }
          
          
     471  void XMLModelDefinitionSerializer::readAttachPoints(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* mAnimPartNode )
          {
           AttachPointDefinitionStore & attachPoints = modelDef->mAttachPoints;
          
           const char* tmp = 0;
           bool nopartfound = true;
          
           for (  Ember::TiXmlElement* apElem = mAnimPartNode->FirstChildElement(   );
           apElem != 0; apElem = apElem->NextSiblingElement(   ) )
           {
           AttachPointDefinition attachPointDef;
           nopartfound = false;
          
           // name
           tmp = apElem->Attribute(  "name" );
           if (  tmp )
           attachPointDef.Name = tmp;
           S_LOG_VERBOSE(   " Add attachpoint : "+ attachPointDef.Name  );
          
           // weight
           tmp = apElem->Attribute(  "bone" );
           if (  tmp )
           attachPointDef.BoneName = tmp;
          
           Ember::TiXmlElement* elem = apElem->FirstChildElement(  "rotation" );
           if (  elem )
           {
           attachPointDef.Rotation = fillQuaternionFromElement(  elem );
           } else {
           attachPointDef.Rotation = Ogre::Quaternion::IDENTITY;
           }
          
           attachPoints.push_back(  attachPointDef );
           }
          
          }
          
     508  void XMLModelDefinitionSerializer::readParticleSystems(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* mParticleSystemsNode )
          {
           Ember::TiXmlElement* elem;
           ModelDefinition::ParticleSystemSet& particleSystems = modelDef->mParticleSystems;
          
           const char* tmp = 0;
           bool nopartfound = true;
          
           for (  Ember::TiXmlElement* apElem = mParticleSystemsNode->FirstChildElement(   );
           apElem != 0; apElem = apElem->NextSiblingElement(   ) )
           {
           ModelDefinition::ParticleSystemDefinition def;
           nopartfound = false;
          
           // name
           tmp = apElem->Attribute(  "script" );
           if (  tmp )
           def.Script = tmp;
           S_LOG_VERBOSE(   " Add particlescript : "+ def.Script  );
          
           elem = apElem->FirstChildElement(  "bindings" );
           if (  elem )
           readParticleSystemsBindings(  def,   elem );
          
          
           particleSystems.push_back(  def );
           }
          }
          
     537  void XMLModelDefinitionSerializer::readParticleSystemsBindings(  ModelDefinition::ParticleSystemDefinition& def,   Ember::TiXmlElement* mParticleSystemsNode )
          {
           const char* tmp = 0;
          // bool nopartfound = true;
          
           for (  Ember::TiXmlElement* apElem = mParticleSystemsNode->FirstChildElement(   );
           apElem != 0; apElem = apElem->NextSiblingElement(   ) )
           {
           ModelDefinition::BindingDefinition binding;
          
           // name
           tmp = apElem->Attribute(  "emittervar" );
           if (  tmp )
           binding.EmitterVar = tmp;
           else
           continue;
          
           // weight
           tmp = apElem->Attribute(  "atlasattribute" );
           if (  tmp )
           binding.AtlasAttribute = tmp;
           else
           continue;
          
           S_LOG_VERBOSE(   " Add binding between "<< binding.EmitterVar << " and " << binding.AtlasAttribute << "."  );
          
          
           def.Bindings.push_back(  binding );
           }
          
          }
          
     569  void XMLModelDefinitionSerializer::readViews(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* viewsNode )
          {
           Ember::TiXmlElement* elem;
          
           const char* tmp = 0;
          
           for (  Ember::TiXmlElement* viewElem = viewsNode->FirstChildElement(   );
           viewElem != 0; viewElem = viewElem->NextSiblingElement(   ) )
           {
          
           // name
           tmp = viewElem->Attribute(  "name" );
           if (  tmp ) {
           std::string name(  tmp );
          
           ViewDefinition* def = modelDef->createViewDefinition(  name );
          
           S_LOG_VERBOSE(   " Add View : "+ def->Name  );
          
           elem = viewElem->FirstChildElement(  "rotation" );
           if (  elem ) {
           def->Rotation = fillQuaternionFromElement(  elem );
           } else {
           def->Rotation = Ogre::Quaternion::IDENTITY;
           }
          
           elem = viewElem->FirstChildElement(  "distance" );
           if (  elem ) {
           def->Distance = Ogre::StringConverter::parseReal(  elem->GetText(   ) );
           } else {
           def->Distance = 0;
           }
          
           }
           }
          }
          
          
     607  Ogre::Vector3 XMLModelDefinitionSerializer::fillVector3FromElement(  Ember::TiXmlElement* elem )
          {
           Ogre::Real x=0.0f,   y=0.0f,   z=0.0f;
           if (  elem->Attribute(  "x" ) ) {
           x = atof(  elem->Attribute(  "x" ) );
           }
           if (  elem->Attribute(  "y" ) ) {
           y = atof(  elem->Attribute(  "y" ) );
           }
           if (  elem->Attribute(  "z" ) ) {
           z = atof(  elem->Attribute(  "z" ) );
           }
          
           return Ogre::Vector3(  x,  y,  z );
          }
          
          
     624  void XMLModelDefinitionSerializer::fillElementFromVector3(  Ember::TiXmlElement& elem,   Ogre::Vector3 vector )
          {
           elem.SetDoubleAttribute(  "x",   vector.x );
           elem.SetDoubleAttribute(  "y",   vector.y );
           elem.SetDoubleAttribute(  "z",   vector.z );
          }
          
     631  Ogre::Quaternion XMLModelDefinitionSerializer::fillQuaternionFromElement(  Ember::TiXmlElement* elem )
          {
           Ogre::Vector3 vector = fillVector3FromElement(  elem );
           Ogre::Degree degrees;
           ///first check if degrees is specified,   but also allow for radians to be specified
           if (  elem->Attribute(  "degrees" ) ) {
           degrees = atof(  elem->Attribute(  "degrees" ) );
           } else if (  elem->Attribute(  "radians" ) ) {
           degrees = Ogre::Radian(  atof(  elem->Attribute(  "radians" ) ) );
           }
           Ogre::Quaternion q;
           q.FromAngleAxis(  degrees,   vector );
           return q;
          
          }
          
     647  void XMLModelDefinitionSerializer::fillElementFromQuaternion(  Ember::TiXmlElement& elem,   Ogre::Quaternion quaternion )
          {
           ///split the quaternion into an axis and a degree (  our format allows us to store the angle element as a radian too,   but I prefer degrees )
           Ogre::Degree degrees;
           Ogre::Vector3 axis;
           quaternion.ToAngleAxis(   degrees,   axis );
           fillElementFromVector3(  elem,   axis );
           elem.SetDoubleAttribute(  "degrees",   degrees.valueDegrees(   ) );
          }
          
          
     658  void XMLModelDefinitionSerializer::exportScript(  ModelDefinitionPtr modelDef,   const std::string& filename )
          {
           if (  filename == "" ) {
           return;
           }
          
           Ember::TiXmlDocument xmlDoc;
          
           try
           {
           //make sure the directory exists
           std::string dir = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ) + "/user-media";
          
           if (  !oslink::directory(  dir ).isExisting(   ) ) {
           S_LOG_INFO(  "Creating directory " << dir );
          #ifdef __WIN32__
           mkdir(  dir.c_str(   ) );
          #else
           mkdir(  dir.c_str(   ),   S_IRWXU );
          #endif
           }
          
          
          
          
           dir = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ) + "/user-media/modeldefinitions/";
          
           if (  !oslink::directory(  dir ).isExisting(   ) ) {
           S_LOG_INFO(  "Creating directory " << dir );
          #ifdef __WIN32__
           mkdir(  dir.c_str(   ) );
          #else
           mkdir(  dir.c_str(   ),   S_IRWXU );
          #endif
           }
          
           Ember::TiXmlElement elem(  "models" );
           Ember::TiXmlElement modelElem(  "model" );
           modelElem.SetAttribute(  "name",   modelDef->getName(   ).c_str(   ) );
          
           std::string useScaleOf;
           switch (  modelDef->getUseScaleOf(   ) ) {
           case ModelDefinition::MODEL_ALL:
           useScaleOf = "all";
           break;
           case ModelDefinition::MODEL_DEPTH:
           useScaleOf = "depth";
           break;
           case ModelDefinition::MODEL_HEIGHT:
           useScaleOf = "height";
           break;
           case ModelDefinition::MODEL_NONE:
           useScaleOf = "none";
           break;
           case ModelDefinition::MODEL_WIDTH:
           useScaleOf = "width";
           break;
           }
           modelElem.SetAttribute(  "usescaleof",   useScaleOf.c_str(   ) );
          
           if (  modelDef->getRenderingDistance(   ) != 0.0f ) {
           modelElem.SetDoubleAttribute(  "renderingdistance",   modelDef->getRenderingDistance(   ) );
           }
          
           if (  modelDef->getScale(   ) != 0 ) {
           modelElem.SetDoubleAttribute(  "scale",   modelDef->getScale(   ) );
           }
          
           modelElem.SetAttribute(  "showcontained",   modelDef->getShowContained(   ) ? "true" : "false" );
          
           if (  modelDef->getContentOffset(   ) != Ogre::Vector3::ZERO ) {
           Ember::TiXmlElement contentOffset(  "contentoffset" );
           fillElementFromVector3(  contentOffset,   modelDef->getContentOffset(   ) );
           modelElem.InsertEndChild(  contentOffset );
           }
          
           Ember::TiXmlElement translate(  "translate" );
           fillElementFromVector3(  translate,   modelDef->getTranslate(   ) );
           modelElem.InsertEndChild(  translate );
          
           Ember::TiXmlElement rotation(  "rotation" );
           fillElementFromQuaternion(  rotation,   modelDef->getRotation(   ) );
           modelElem.InsertEndChild(  rotation );
          
           modelElem.SetAttribute(  "icon",   modelDef->getIconPath(   ).c_str(   ) );
          
           if (  modelDef->getRenderingDefinition(   ) ) {
           Ember::TiXmlElement rendering(  "rendering" );
           rendering.SetAttribute(  "scheme",   modelDef->getRenderingDefinition(   )->getScheme(   ).c_str(   ) );
           for (  StringParamStore::const_iterator I = modelDef->getRenderingDefinition(   )->getParameters(   ).begin(   ); I != modelDef->getRenderingDefinition(   )->getParameters(   ).end(   ); ++I ) {
           Ember::TiXmlElement param(  "param" );
           param.SetAttribute(  "key",   I->first.c_str(   ) );
           param.SetValue(  I->second.c_str(   ) );
           }
           }
          
           //start with submodels
           exportSubModels(  modelDef,   modelElem );
          
           //now do actions
           exportActions(  modelDef,   modelElem );
          
           exportAttachPoints(  modelDef,   modelElem );
          
           exportViews(  modelDef,   modelElem );
          
           elem.InsertEndChild(  modelElem );
          
           xmlDoc.InsertEndChild(  elem );
           xmlDoc.SaveFile(  (  dir + filename ).c_str(   ) );
           S_LOG_INFO(  "Saved file " << (  dir + filename ) );
           }
           catch (  ... )
           {
           S_LOG_FAILURE(  "An error occurred saving the modeldefinition for "<< modelDef->getName(   ) << "."  );
           }
          
          
          }
          
     778  void XMLModelDefinitionSerializer::exportViews(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement& modelElem )
          {
           Ember::TiXmlElement viewsElem(  "views" );
          
           for (  ViewDefinitionStore::const_iterator I = modelDef->getViewDefinitions(   ).begin(   ); I != modelDef->getViewDefinitions(   ).end(   ); ++I ) {
           Ember::TiXmlElement viewElem(  "view" );
           viewElem.SetAttribute(  "name",   I->second->Name.c_str(   ) );
          
           Ember::TiXmlElement distanceElem(  "distance" );
           std::stringstream ss;
           ss << I->second->Distance;
           distanceElem.InsertEndChild(  Ember::TiXmlText(  ss.str(   ).c_str(   ) ) );
           viewElem.InsertEndChild(  distanceElem );
          
           Ember::TiXmlElement rotation(  "rotation" );
           fillElementFromQuaternion(  rotation,   I->second->Rotation );
           viewElem.InsertEndChild(  rotation );
          
           viewsElem.InsertEndChild(  viewElem );
           }
           modelElem.InsertEndChild(  viewsElem );
          }
          
     801  void XMLModelDefinitionSerializer::exportActions(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement& modelElem )
          {
           Ember::TiXmlElement actionsElem(  "actions" );
          
           for (  ActionDefinitionsStore::const_iterator I = modelDef->getActionDefinitions(   ).begin(   ); I != modelDef->getActionDefinitions(   ).end(   ); ++I ) {
           Ember::TiXmlElement actionElem(  "action" );
           actionElem.SetAttribute(  "name",   (  *I )->getName(   ).c_str(   ) );
           actionElem.SetDoubleAttribute(  "speed",   (  *I )->getAnimationSpeed(   ) );
          
           if (  (  *I )->getAnimationDefinitions(   ).size(   ) > 0 ) {
           Ember::TiXmlElement animationsElem(  "animations" );
           for (  AnimationDefinitionsStore::const_iterator J = (  *I )->getAnimationDefinitions(   ).begin(   ); J != (  *I )->getAnimationDefinitions(   ).end(   ); ++J ) {
           Ember::TiXmlElement animationElem(  "animation" );
           animationElem.SetAttribute(  "iterations",   (  *J )->getIterations(   ) );
          
           for (  AnimationPartDefinitionsStore::const_iterator K = (  *J )->getAnimationPartDefinitions(   ).begin(   ); K != (  *J )->getAnimationPartDefinitions(   ).end(   ); ++K ) {
           Ember::TiXmlElement animationPartElem(  "animationpart" );
           animationPartElem.SetAttribute(  "name",   (  *K )->Name.c_str(   ) );
           animationPartElem.SetDoubleAttribute(  "weight",   (  *K )->Weight );
           animationElem.InsertEndChild(  animationPartElem );
           }
          
           animationsElem.InsertEndChild(  animationElem );
           }
           actionElem.InsertEndChild(  animationsElem );
           }
          
           //for now,   only allow one sound
           if (  (  *I )->getSoundDefinitions(   ).size(   ) > 0 ) {
           SoundDefinition* def = *(  *I )->getSoundDefinitions(   ).begin(   );
           Ember::TiXmlElement soundElem(  "sound" );
           soundElem.SetAttribute(  "name",   def->Name.c_str(   ) );
           soundElem.SetAttribute(  "repeat",   def->Repeat );
           soundElem.SetDoubleAttribute(  "volume",   def->Volume );
           actionElem.InsertEndChild(  soundElem );
           }
           actionsElem.InsertEndChild(  actionElem );
           }
           modelElem.InsertEndChild(  actionsElem );
          }
          
     842  void XMLModelDefinitionSerializer::exportSubModels(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement& modelElem )
          {
           Ember::TiXmlElement submodelsElem(  "submodels" );
          
           for (  SubModelDefinitionsStore::const_iterator I = modelDef->getSubModelDefinitions(   ).begin(   ); I != modelDef->getSubModelDefinitions(   ).end(   ); ++I ) {
           Ember::TiXmlElement submodelElem(  "submodel" );
           submodelElem.SetAttribute(  "mesh",   (  *I )->getMeshName(   ).c_str(   ) );
           Ember::TiXmlElement partsElem(  "parts" );
          
           for (  PartDefinitionsStore::const_iterator J = (  *I )->getPartDefinitions(   ).begin(   ); J != (  *I )->getPartDefinitions(   ).end(   ); ++J ) {
           Ember::TiXmlElement partElem(  "part" );
           partElem.SetAttribute(  "name",   (  *J )->getName(   ).c_str(   ) );
           if (  (  *J )->getGroup(   ) != "" ) {
           partElem.SetAttribute(  "group",   (  *J )->getGroup(   ).c_str(   ) );
           }
           partElem.SetAttribute(  "show",   (  *J )->getShow(   ) ? "true" : "false" );
          
           if (  (  *J )->getSubEntityDefinitions(   ).size(   ) > 0 ) {
           Ember::TiXmlElement subentitiesElem(  "subentities" );
           for (  SubEntityDefinitionsStore::const_iterator K = (  *J )->getSubEntityDefinitions(   ).begin(   ); K != (  *J )->getSubEntityDefinitions(   ).end(   ); ++K ) {
           Ember::TiXmlElement subentityElem(  "subentity" );
           if (  (  *K )->getSubEntityName(   ) != "" ) {
           subentityElem.SetAttribute(  "name",   (  *K )->getSubEntityName(   ).c_str(   ) );
           } else {
           subentityElem.SetAttribute(  "index",   (  *K )->getSubEntityIndex(   ) );
           }
           if (  (  *K )->getMaterialName(   ) != "" ) {
           subentityElem.SetAttribute(  "material",   (  *K )->getMaterialName(   ).c_str(   ) );
           }
           subentitiesElem.InsertEndChild(  subentityElem );
           }
           partElem.InsertEndChild(  subentitiesElem );
           }
           partsElem.InsertEndChild(  partElem );
           }
           submodelElem.InsertEndChild(  partsElem );
           submodelsElem.InsertEndChild(  submodelElem );
           }
           modelElem.InsertEndChild(  submodelsElem );
          
          }
          
     884  void XMLModelDefinitionSerializer::exportAttachPoints(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement& modelElem )
          {
           Ember::TiXmlElement attachpointsElem(  "attachpoints" );
          
           for (  AttachPointDefinitionStore::const_iterator I = modelDef->getAttachPointsDefinitions(   ).begin(   ); I != modelDef->getAttachPointsDefinitions(   ).end(   ); ++I ) {
           Ember::TiXmlElement attachpointElem(  "attachpoint" );
           attachpointElem.SetAttribute(  "name",   I->Name.c_str(   ) );
           attachpointElem.SetAttribute(  "bone",   I->BoneName.c_str(   ) );
           Ember::TiXmlElement rotationElem(  "rotation" );
           fillElementFromQuaternion(  rotationElem,   I->Rotation );
           attachpointElem.InsertEndChild(  rotationElem );
          
           attachpointsElem.InsertEndChild(  attachpointElem );
           }
           modelElem.InsertEndChild(  attachpointsElem );
          }
          
          } //end namespace
          }

./components/ogre/model/XMLModelDefinitionSerializer.h

       1  /*
          -------------------------------------------------------------------------------
           This source file is part of Cataclysmos
           For the latest info,   see http://www.cataclysmos.org/
          
           Copyright (  c ) 2005 The Cataclysmos Team
           Copyright (  C ) 2005 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or
           modify it under the terms of the GNU General Public License
           as published by the Free Software Foundation; either version 2
           of the License,   or (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   59 Temple Place - Suite 330,   Boston,   MA 02111-1307,   USA.
          -------------------------------------------------------------------------------
          */
          
          #ifndef __XMLModelDefinitionSerializer__
          #define __XMLModelDefinitionSerializer__
          
          // Includes
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          #include "ModelDefinition.h"
          #include "framework/tinyxml/tinyxml.h"
          
          // Namespaces
          namespace EmberOgre {
          namespace Model {
          
          // Classes
      40  class XMLModelDefinitionSerializer
          {
          public :
      43   XMLModelDefinitionSerializer(   );
      44   virtual ~XMLModelDefinitionSerializer(   );
          
      46   void importModelDefinition(  Ogre::DataStreamPtr& stream,   ModelDefinition* pmModelDef );
      47   void parseScript(  Ogre::DataStreamPtr& stream,   const Ogre::String& groupName );
          
      49   void exportScript(  ModelDefinitionPtr modelDef,   const std::string& filename );
          
          private:
           //Ember::TiXmlDocument* _XMLDoc;
           //ModelDefinition* _pModelDef;
          
      55   void readModel(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* modelNode );
      56   void readSubModels(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* mSubModelNode );
      57   void readParts(  Ember::TiXmlElement* mPartNode,   SubModelDefinition* def );
      58   void readSubEntities(  Ember::TiXmlElement* mSubEntNode,   PartDefinition* def );
      59   void readActions(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* mAnimNode );
      60   void readAnimations(  Ember::TiXmlElement* mAnimationsNode,   ActionDefinition* action );
      61   void readAnimationParts(  Ember::TiXmlElement* mAnimPartNode,   AnimationDefinition* animDef );
      62   void readAttachPoints(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* mAnimPartNode );
      63   void readParticleSystems(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* mParticleSystemsNode );
      64   void readParticleSystemsBindings(  ModelDefinition::ParticleSystemDefinition& def,   Ember::TiXmlElement* mParticleSystemsNode );
      65   void readViews(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement* viewsNode );
          
      67   Ogre::Vector3 fillVector3FromElement(  Ember::TiXmlElement* elem );
      68   void fillElementFromVector3(  Ember::TiXmlElement& elem,   Ogre::Vector3 vector );
          
      70   Ogre::Quaternion fillQuaternionFromElement(  Ember::TiXmlElement* elem );
      71   void fillElementFromQuaternion(  Ember::TiXmlElement& elem,   Ogre::Quaternion quaternion );
          
      73   void exportSubModels(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement& modelElem );
      74   void exportActions(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement& modelElem );
      75   void exportAttachPoints(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement& modelElem );
      76   void exportViews(  ModelDefinitionPtr modelDef,   Ember::TiXmlElement& modelElem );
          
          };
          
          }
          }
          #endif

./components/ogre/model/mapping/Actions/Action.cpp

       1  //
          // C++ Implementation: Action
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Action.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Actions {
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Actions/Action.h

       1  //
          // C++ Interface: Action
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_ACTIONSACTION_H
          #define EMBEROGRE_MODEL_MAPPING_ACTIONSACTION_H
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Cases
          {
      32  class CaseBase;
          }
          
          namespace Mapping {
          
          namespace Actions {
          
          /**
           Base class for actions. Applications are requested to implement their own subclasses.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      44  class Action
          {
          public:
      47   virtual ~Action(   ) {};
          
           /**
           Activate the action.
           */
      52   virtual void activate(   ) = 0;
          
           /**
           Deactivate the action.
           */
      57   virtual void deactivate(   ) = 0;
          
           /**
           Sets the case this action belongs to.
           */
      62   inline void setCase(  Cases::CaseBase* ownerCase );
          
           /**
           * Gets the case that this action belongs to.
           * @return The owner case.
           */
      68   inline Cases::CaseBase* getCase(   ) const;
          
          protected:
      71   Cases::CaseBase* mOwnerCase;
          };
          
      74  void Action::setCase(  Cases::CaseBase* ownerCase )
          {
           mOwnerCase = ownerCase;
          }
      78  Cases::CaseBase* Action::getCase(   ) const
          {
           return mOwnerCase;
          }
          
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Actions/DummyAction.cpp

       1  //
          // C++ Implementation: DummyAction
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "DummyAction.h"
          #include <iostream>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Actions {
          
      34  void DummyAction::activate(   )
          {
           std::cout << "Dummy action activated." << std::endl;
          };
          
      39  void DummyAction::deactivate(   )
          {
           std::cout << "Dummy action deactivated." << std::endl;
          };
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Actions/DummyAction.h

       1  //
          // C++ Interface: DummyAction
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_ACTIONSDUMMYACTION_H
          #define EMBEROGRE_MODEL_MAPPING_ACTIONSDUMMYACTION_H
          
          #include "Action.h"
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Actions {
          
          /**
           Dummy action for testing purposes.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      39  class DummyAction : public Action
          {
          public:
      42   virtual void activate(   );
          
      44   virtual void deactivate(   );
          
          protected:
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeCase.cpp

       1  //
          // C++ Implementation: AttributeCase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AttributeCase.h"
          #include "AttributeComparers/AttributeComparerWrapper.h"
          #include "AttributeComparers/StringComparerWrapper.h"
          #include "AttributeComparers/StringComparer.h"
          
          #include <memory>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
      38  AttributeCase::AttributeCase(  AttributeComparers::AttributeComparerWrapper* comparerWrapper )
          : mComparerWrapper(  std::auto_ptr<AttributeComparers::AttributeComparerWrapper>(  comparerWrapper ) )
          {
          }
          
          
      44  bool AttributeCase::testMatch(  const Atlas::Message::Element& attribute )
          {
           if (  mComparerWrapper.get(   ) ) {
           if (  mComparerWrapper->testAttribute(  attribute ) ) {
           setState(  true );
           return true;
           }
           }
           setState(  false );
           return false;
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeCase.h

       1  //
          // C++ Interface: AttributeCase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASESATTRIBUTECASE_H
          #define EMBEROGRE_MODEL_MAPPING_CASESATTRIBUTECASE_H
          
          #include "Case.h"
          
          #include <Atlas/Message/Element.h>
          #include "AttributeComparers/AttributeComparerWrapper.h"
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
      37  class AttributeMatch;
          }
          }
          }
          }
          
          #include "../Matches/AttributeMatch.h"
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          
          /**
           A child case to an AttributeMatch. This will look for changes to a certain attribute.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      60  class AttributeCase : public Case<Matches::AttributeMatch>
          {
          public:
      63   AttributeCase(  AttributeComparers::AttributeComparerWrapper* comparerWrapper );
      64   ~AttributeCase(   ) {};
      65   bool testMatch(  const Atlas::Message::Element& attribute );
          
          protected:
      68   std::auto_ptr<AttributeComparers::AttributeComparerWrapper> mComparerWrapper;
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/AttributeComparerWrapper.cpp

       1  //
          // C++ Implementation: AttributeComparerWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AttributeComparerWrapper.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/AttributeComparerWrapper.h

       1  //
          // C++ Interface: AttributeComparerWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSATTRIBUTECOMPARERWRAPPER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSATTRIBUTECOMPARERWRAPPER_H
          
          #include <Atlas/Message/Element.h>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Abtract base class for an wrapper that compares attributes.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      42  class AttributeComparerWrapper
          {
          public:
      45   virtual ~AttributeComparerWrapper(   ) {}
           /**
           Test the attribute.
           */
      49   virtual bool testAttribute(  const Atlas::Message::Element& attribute ) = 0;
          };
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/HeightComparerWrapper.cpp

       1  //
          // C++ Implementation: HeightComparerWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "HeightComparerWrapper.h"
          #include "NumericComparer.h"
          #include <Eris/Entity.h>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      37  HeightComparerWrapper::HeightComparerWrapper(  NumericComparer* comparer,   Eris::Entity* entity )
          : mNumericComparer(  comparer ),   mEntity(  entity )
          {
          }
          
      42  bool HeightComparerWrapper::testAttribute(  const Atlas::Message::Element& attribute )
          {
           return mEntity->hasBBox(   ) && (  mNumericComparer->test(  mEntity->getBBox(   ).upperBound(  2 ) - mEntity->getBBox(   ).lowerBound(  2 ) ) );
          }
          
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/HeightComparerWrapper.h

       1  //
          // C++ Interface: HeightComparerWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSHEIGHTCOMPARERWRAPPER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSHEIGHTCOMPARERWRAPPER_H
          
          #include "AttributeComparerWrapper.h"
          
          namespace Eris
          {
      30  class Entity;
          }
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      44  class NumericComparer;
          
          /**
           Compares the height of an entity. The height is calculated from the bounding box.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      50  class HeightComparerWrapper : public AttributeComparerWrapper
          {
          public:
           /**
           * Default constructor.
           * @param comparer The NumericComparer to use for comparison.
           * @param entity
           */
      58   HeightComparerWrapper(  NumericComparer* comparer,   Eris::Entity* entity );
      59   virtual ~HeightComparerWrapper(   ) {}
          
           /**
           Test the height. The attribute passed will be ignored.
           */
      64   virtual bool testAttribute(  const Atlas::Message::Element& attribute );
          
          protected:
      67   std::auto_ptr<NumericComparer> mNumericComparer;
      68   Eris::Entity* mEntity;
          };
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/NumericComparer.cpp

       1  //
          // C++ Implementation: NumericComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumericComparer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/NumericComparer.h

       1  //
          // C++ Interface: NumericComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICCOMPARER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICCOMPARER_H
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Base class for all numeric comparers.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      40  class NumericComparer
          {
          public:
      43   virtual ~NumericComparer(   ) {}
           /**
           Test the supplied value.
           @param value The value to test.
           */
      48   virtual bool test(  float value ) = 0;
          
          protected:
          };
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/NumericComparerWrapper.cpp

       1  //
          // C++ Implementation: NumericComparerWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumericComparerWrapper.h"
          #include "NumericComparer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      36  NumericComparerWrapper::NumericComparerWrapper(  NumericComparer* comparer )
          : mNumericComparer(  comparer )
          {
          }
          
      41  bool NumericComparerWrapper::testAttribute(  const Atlas::Message::Element& attribute )
          {
           if (  attribute.isNum(   ) ) {
           return mNumericComparer->test(  attribute.asNum(   ) );
           }
           return false;
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/NumericComparerWrapper.h

       1  //
          // C++ Interface: NumericComparerWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICCOMPARERWRAPPER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICCOMPARERWRAPPER_H
          
          #include "AttributeComparerWrapper.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      38  class NumericComparer;
          
          /**
           An attribute comparer wrapper that handles numeric values.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      44  class NumericComparerWrapper : public AttributeComparerWrapper
          {
          public:
      47   NumericComparerWrapper(  NumericComparer* comparer );
      48   virtual ~NumericComparerWrapper(   ) {}
      49   virtual bool testAttribute(  const Atlas::Message::Element& attribute );
          private:
      51   std::auto_ptr<NumericComparer> mNumericComparer;
          };
          
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/NumericEqualsComparer.cpp

       1  //
          // C++ Implementation: NumericEqualsComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumericEqualsComparer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      35  NumericEqualsComparer::NumericEqualsComparer(  float value ) : NumericValueHolder(  value )
          {
          }
          
      39  bool NumericEqualsComparer::test(  float value )
          {
           return value == mValue;
          }
          
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/NumericEqualsComparer.h

       1  //
          // C++ Interface: NumericEqualsComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICEQUALSCOMPARER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICEQUALSCOMPARER_H
          
          #include "NumericComparer.h"
          #include "NumericValueHolder.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Test for numeric equality.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      43  class NumericEqualsComparer : public NumericComparer,   private NumericValueHolder
          {
          public:
      46   NumericEqualsComparer(  float value );
      47   virtual ~NumericEqualsComparer(   ) {}
           /**
           Returns true if the supplied value is equal to the held value.
           */
      51   virtual bool test(  float value );
          
          protected:
          };
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/NumericEqualsOrGreaterComparer.cpp

       1  //
          // C++ Implementation: NumericEqualsOrGreaterComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumericEqualsOrGreaterComparer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      35  NumericEqualsOrGreaterComparer::NumericEqualsOrGreaterComparer(  float value ) : NumericValueHolder(  value )
          {
          }
          
      39  bool NumericEqualsOrGreaterComparer::test(  float value )
          {
           return value >= mValue ;
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/NumericEqualsOrGreaterComparer.h

       1  //
          // C++ Interface: NumericEqualsOrGreaterComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICEQUALSORGREATERCOMPARER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICEQUALSORGREATERCOMPARER_H
          
          #include "NumericComparer.h"
          #include "NumericValueHolder.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Test for numeric equality or greater.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      43  class NumericEqualsOrGreaterComparer : public NumericComparer,   private NumericValueHolder
          {
          public:
      46   NumericEqualsOrGreaterComparer(  float value );
      47   virtual ~NumericEqualsOrGreaterComparer(   ) {}
          
           /**
           Returns true if the supplied value is equal or greater than the held value.
           */
      52   virtual bool test(  float value );
          
          protected:
          };
          
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/NumericEqualsOrLesserComparer.cpp

       1  //
          // C++ Implementation: NumericEqualsOrLesserComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumericEqualsOrLesserComparer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      35  NumericEqualsOrLesserComparer::NumericEqualsOrLesserComparer(  float value ) : NumericValueHolder(  value )
          {
          }
          
      39  bool NumericEqualsOrLesserComparer::test(  float value )
          {
           return value <= mValue;
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/NumericEqualsOrLesserComparer.h

       1  //
          // C++ Interface: NumericEqualsOrLesserComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICEQUALSORLESSERCOMPARER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICEQUALSORLESSERCOMPARER_H
          
          #include "NumericComparer.h"
          #include "NumericValueHolder.h"
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Test for numeric equality or lesser.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      44  class NumericEqualsOrLesserComparer : public NumericComparer,   private NumericValueHolder
          {
          public:
      47   NumericEqualsOrLesserComparer(  float value );
      48   virtual ~NumericEqualsOrLesserComparer(   ) {}
           /**
           Returns true if the supplied value is equal or lesser than the held value.
           */
      52   virtual bool test(  float value );
          
          protected:
          };
          
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/NumericGreaterComparer.cpp

       1  //
          // C++ Implementation: NumericGreaterComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumericGreaterComparer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      35  NumericGreaterComparer::NumericGreaterComparer(  float value ) : NumericValueHolder(  value )
          {
          }
          
      39  bool NumericGreaterComparer::test(  float value )
          {
           return value > mValue;
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/NumericGreaterComparer.h

       1  //
          // C++ Interface: NumericGreaterComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICGREATERCOMPARER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICGREATERCOMPARER_H
          
          #include "NumericComparer.h"
          #include "NumericValueHolder.h"
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Test for greater.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      44  class NumericGreaterComparer : public NumericComparer,   private NumericValueHolder
          {
          public:
      47   NumericGreaterComparer(  float value );
      48   virtual ~NumericGreaterComparer(   ) {}
           /**
           Returns true if the supplied value is greater than the held value.
           */
      52   virtual bool test(  float value );
          
          protected:
          };
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/NumericLesserComparer.cpp

       1  //
          // C++ Implementation: NumericLesserComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumericLesserComparer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      35  NumericLesserComparer::NumericLesserComparer(  float value ) : NumericValueHolder(  value )
          {
          }
          
      39  bool NumericLesserComparer::test(  float value )
          {
           return value < mValue;
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/NumericLesserComparer.h

       1  //
          // C++ Interface: NumericLesserComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICLESSERCOMPARER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICLESSERCOMPARER_H
          
          #include "NumericComparer.h"
          #include "NumericValueHolder.h"
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Test for lesser.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      44  class NumericLesserComparer : public NumericComparer,   private NumericValueHolder
          {
          public:
      47   NumericLesserComparer(  float value );
      48   virtual ~NumericLesserComparer(   ) {}
           /**
           Returns true if the supplied value is lesser than the held value.
           */
      52   virtual bool test(  float value );
          
          protected:
          };
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/NumericRangeComparer.cpp

       1  //
          // C++ Implementation: NumericRangeComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumericRangeComparer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      35  NumericRangeComparer::NumericRangeComparer(  NumericComparer* minComparer,   NumericComparer* maxComparer )
          : mMinComparer(  minComparer ),   mMaxComparer(  maxComparer )
          {
          }
          
          
      41  bool NumericRangeComparer::test(  float value )
          {
           return mMinComparer->test(  value ) && mMinComparer->test(  value );
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/NumericRangeComparer.h

       1  //
          // C++ Interface: NumericRangeComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICRANGECOMPARER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICRANGECOMPARER_H
          
          #include "NumericComparer.h"
          #include <memory>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Test for values being in a certain range. The range is defined by two different NumericComparer instances.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      43  class NumericRangeComparer : public NumericComparer
          {
          public:
      46   NumericRangeComparer(  NumericComparer* minComparer,   NumericComparer* maxComparer );
      47   virtual ~NumericRangeComparer(   ) {}
           /**
           Returns true if the supplied value is true for both the used comparers.
           */
      51   virtual bool test(  float value );
          
          protected:
      54   std::auto_ptr<NumericComparer> mMinComparer;
      55   std::auto_ptr<NumericComparer> mMaxComparer;
          };
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/NumericValueHolder.cpp

       1  //
          // C++ Implementation: NumericValueHolder
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumericValueHolder.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      35  NumericValueHolder::NumericValueHolder(  float value ) : mValue(  value )
          {
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/NumericValueHolder.h

       1  //
          // C++ Interface: NumericValueHolder
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICVALUEHOLDER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSNUMERICVALUEHOLDER_H
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Base class for all comparers that must hold a value.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      40  class NumericValueHolder
          {
          public:
      43   NumericValueHolder(  float value );
          
          protected:
           float mValue;
          };
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/StringComparer.cpp

       1  //
          // C++ Implementation: StringComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "StringComparer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
      35  StringComparer::StringComparer(  std::string value ) : mValue(  value )
          {
          }
          
      39  bool StringComparer::test(  const std::string& value )
          {
           return mValue == value;
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/StringComparer.h

       1  //
          // C++ Interface: StringComparer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSSTRINGCOMPARER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSSTRINGCOMPARER_H
          
          #include <string>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          /**
           Tests for string equality. This is case sensitive.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      42  class StringComparer
          {
          public:
      45   StringComparer(  std::string value );
      46   virtual ~StringComparer(   ) {}
           /**
           Returns true if the supplied value equals the stored value. The comparison is case sensitive.
           @param value
           */
      51   virtual bool test(  const std::string& value );
          
          protected:
      54   std::string mValue;
          };
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/AttributeComparers/StringComparerWrapper.cpp

       1  //
          // C++ Implementation: StringComparerWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "StringComparerWrapper.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          
      36  StringComparerWrapper::StringComparerWrapper(  StringComparer* comparer )
          : mStringComparer(  comparer )
          {
          }
          
      41  bool StringComparerWrapper::testAttribute(  const Atlas::Message::Element& attribute )
          {
           return attribute.isString(   ) && mStringComparer->test(  attribute.asString(   ) );
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/AttributeComparers/StringComparerWrapper.h

       1  //
          // C++ Interface: StringComparerWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSSTRINGCOMPARERWRAPPER_H
          #define EMBEROGRE_MODEL_MAPPING_CASES_ATTRIBUTECOMPARERSSTRINGCOMPARERWRAPPER_H
          
          #include <Atlas/Message/Element.h>
          #include "StringComparer.h"
          #include "AttributeComparerWrapper.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          namespace AttributeComparers {
          
          
          /**
           Wraps a string comparison comparer.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      45  class StringComparerWrapper : public AttributeComparerWrapper
          {
          public:
      48   StringComparerWrapper(  StringComparer* comparer );
      49   virtual ~StringComparerWrapper(   ) {}
      50   virtual bool testAttribute(  const Atlas::Message::Element& attribute );
          private:
      52   std::auto_ptr<StringComparer> mStringComparer;
          };
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/Case.cpp

       1  //
          // C++ Implementation: Case
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Case.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/Case.h

       1  //
          // C++ Interface: Case
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASESCASE_H
          #define EMBEROGRE_MODEL_MAPPING_CASESCASE_H
          
          #include "CaseBase.h"
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          /**
           Base class for all Cases that has a parent Match.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
          template <class TMatch>
      40  class Case : public CaseBase
          {
          public:
          
      44   Case(   )
           : mParentMatch(  0 )
           {}
          
      48   virtual ~Case(   )
           {}
          
           /**
           Sets the parent Match instance.
           */
      54   inline void setParentMatch(  TMatch* aMatch );
          
          
          protected:
          
      59   TMatch* mParentMatch;
          
          };
          
          template <class TMatch>
      64  void Case<TMatch>::setParentMatch(  TMatch* aMatch )
          {
           mParentMatch = aMatch;
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/CaseBase.cpp

       1  //
          // C++ Implementation: CaseBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "CaseBase.h"
          
          #include "../ModelMapping.h"
          #include "../Actions/Action.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
      36  CaseBase::CaseBase(   )
          : mParentCase(  0 ),   mIsTrue(  false ),   mIsActive(  false )
          {
          }
          
      41  CaseBase::~CaseBase(   ) {
           Mapping::cleanVector(  mActions );
           Mapping::cleanVector(  mMatches );
          }
          
      46  void CaseBase::addAction(  Actions::Action* action ) {
           mActions.push_back(  action );
           action->setCase(  this );
          }
          
      51  void CaseBase::evaluateChanges(  ChangeContext& changeContext )
          {
           ///if we're true to the root,   but not yet active,   add ourself to the activation queue. If the opposite,   i.e. we're no longer true to the root but active,   we need to be deactivated.
           if (  getIsTrueToRoot(   ) ) {
           if (  !getIsActive(   ) ) {
           changeContext.addCaseToActivate(  this );
           }
           } else {
           if (  getIsActive(   ) ) {
           changeContext.addCaseToDeactivate(  this );
           }
           }
           ///recursively iterate over the child matches
           MatchBaseStore::iterator I = mMatches.begin(   );
           for (   ; I != mMatches.end(   ); ++I ) {
           (  *I )->evaluateChanges(  changeContext );
           }
          
          }
      70  void CaseBase::activateActions(   )
          {
           for (  ActionStore::iterator I = mActions.begin(   ); I != mActions.end(   ); ++I ) {
           (  *I )->activate(   );
           }
           mIsActive = true;
          }
      77  void CaseBase::deactivateActions(   )
          {
           for (  ActionStore::iterator I = mActions.begin(   ); I != mActions.end(   ); ++I ) {
           (  *I )->deactivate(   );
           }
           mIsActive = false;
          }
          
      85  void CaseBase::addMatch(  Matches::MatchBase* match ) {
           mMatches.push_back(  match );
          }
          
      89  void CaseBase::setEntity(  Eris::Entity* entity )
          {
           MatchBaseStore::iterator I = mMatches.begin(   );
           for (   ; I != mMatches.end(   ); ++I ) {
           (  *I )->setEntity(  entity );
           }
          }
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/CaseBase.h

       1  //
          // C++ Interface: CaseBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASESCASEBASE_H
          #define EMBEROGRE_MODEL_MAPPING_CASESCASEBASE_H
          
          #include <vector>
          #include "../ChangeContext.h"
          
          namespace Eris {
      30  class Entity;
          }
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Actions {
      41  class Action;
          }
          
      44  namespace Matches {
          class MatchBase;
          }
          
          namespace Cases {
          
          /**
           Base class for all Cases.
           A Case containes zero or many Actions,   which will be activated when the Case is activated. A Case also contains zero or many child Matches.
           A Case is activated when it's true and all it's parent cases,   all the way up to the root of the ModelMapping,   also are true.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      56  class CaseBase
          {
          public:
           typedef std::vector<Actions::Action*> ActionStore;
           typedef std::vector<Matches::MatchBase*> MatchBaseStore;
          
      62   CaseBase(   );
      63   virtual ~CaseBase(   );
          
      65   inline void setParentCase(  CaseBase* aCase );
          
           /**
           * Returns whether this invidivual case is true.
           * @return
           */
      71   inline bool getIsTrue(   );
          
           /**
           * Returns whether this case is active.
           * @return
           */
      77   inline bool getIsActive(   );
          
           /**
           * Returns whether this case is true and all of its parent cases,   all the way up to the root,   also are true.
           * @return
           */
      83   inline bool getIsTrueToRoot(   );
          
           /**
           Adds an Action to this case.
           */
      88   void addAction(  Actions::Action* action );
           /**
           Gets a list of all the actions contained by this Case.
           */
      92   inline const ActionStore& getActions(   );
          
           /**
           Activates all actions in the Case. Also switches the mActive flag.
           */
      97   void activateActions(   );
           /**
           Deactivates all actions in the Case. Also switches the mActive flag.
           */
     101   void deactivateActions(   );
          
           /**
           Adds an child Match to this case.
           */
     106   void addMatch(  Matches::MatchBase* match );
           /**
           Gets a list of all the Matches contained by this Case.
           */
     110   inline const MatchBaseStore& getMatches(   );
          
           /**
           Evaluates all changes,   and if a change has occurred,   adds itself to the supplied ChangeContext instance.
           */
     115   void evaluateChanges(  ChangeContext& changeContext );
          
           /**
           Sets the entity that this Case will attach itself to.
           */
     120   virtual void setEntity(  Eris::Entity* entity );
          
          protected:
     123   ActionStore mActions;
          
           CaseBase* mParentCase;
     126   bool mIsTrue,   mIsActive;
          
     128   inline void setState(  bool state );
          
     130   MatchBaseStore mMatches;
          
          };
          
     134  void CaseBase::setState(  bool state )
          {
           mIsTrue = state;
          }
          
     139  const CaseBase::MatchBaseStore& CaseBase::getMatches(   )
          {
           return mMatches;
          }
          
     144  const CaseBase::ActionStore& CaseBase::getActions(   )
          {
           return mActions;
          };
          
     149  void CaseBase::setParentCase(  CaseBase* aCase ) {
           mParentCase = aCase;
          }
          
     153  bool CaseBase::getIsTrue(   )
          {
           return mIsTrue;
          }
          
     158  bool CaseBase::getIsActive(   )
          {
           return mIsActive;
          }
          
     163  bool CaseBase::getIsTrueToRoot(   ) {
           if (  !mParentCase ) {
           return mIsTrue;
           } else {
           return mIsTrue && mParentCase->getIsTrueToRoot(   );
           }
          }
          
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/EntityBaseCase.cpp

       1  //
          // C++ Implementation: EntityBaseCase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityBaseCase.h"
          #include <Eris/Entity.h>
          #include <Eris/TypeInfo.h>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
      35  bool EntityBaseCase::testMatch(  Eris::Entity* entity )
          {
           ///Check for entity types recursively for all of the supplied entity parents.
           if (  entity ) {
           Eris::TypeInfo* type = entity->getType(   );
           for (  std::vector<Eris::TypeInfo*>::iterator I = mEntityTypes.begin(   ); I != mEntityTypes.end(   ); ++I ) {
           if (  type->isA(  *I ) ) {
           _setState(  true );
           return true;
           }
           }
           }
           _setState(  false );
           return false;
          }
          
      51  void EntityBaseCase::addEntityType(  Eris::TypeInfoPtr typeInfo )
          {
           mEntityTypes.push_back(  typeInfo );
          }
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/EntityBaseCase.h

       1  //
          // C++ Interface: EntityBaseCase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASESENTITYBASECASE_H
          #define EMBEROGRE_MODEL_MAPPING_CASESENTITYBASECASE_H
          
          #include <vector>
          namespace Eris
          {
      29  class Entity;
      30  class TypeInfo;
          }
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          /**
           A Case which triggers on the type of the entity.
           Entity type matching takes into account inheritance,   so for example,   if the type Settler is a child of the type Character,   and this case is set to be valid for the type Character,   it will also be valid for all Settlers.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      47  class EntityBaseCase
          {
          public:
          
      51   virtual ~EntityBaseCase(   ) {}
          
      53   bool testMatch(  Eris::Entity* entity );
          
           /**
           Adds an entity type to the list of valid entity types for this instance.
           */
      58   void addEntityType(  Eris::TypeInfo* typeInfo );
          
          protected:
      61   std::vector<Eris::TypeInfo*> mEntityTypes;
      62   virtual void _setState(  bool state ) = 0;
          };
          
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/EntityTypeCase.cpp

       1  //
          // C++ Implementation: EntityTypeCase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityTypeCase.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
      33  void EntityTypeCase::_setState(  bool state )
          {
           setState(  state );
          }
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/EntityTypeCase.h

       1  //
          // C++ Interface: EntityTypeCase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASESENTITYTYPECASE_H
          #define EMBEROGRE_MODEL_MAPPING_CASESENTITYTYPECASE_H
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
      33  class EntityTypeMatch;
          }
          }
          }
          }
          
          #include "../Matches/EntityTypeMatch.h"
          #include "EntityBaseCase.h"
          #include "Case.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          /**
           An entity type triggering case that is a child of an EntityTypeMatch
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      55  class EntityTypeCase : public Case<Matches::EntityTypeMatch>,   public EntityBaseCase
          {
          public:
          
          protected:
      60   virtual void _setState(  bool state );
          };
          
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Cases/OutfitCase.cpp

       1  //
          // C++ Implementation: OutfitCase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OutfitCase.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
      33  void OutfitCase::_setState(  bool state )
          {
           setState(  state );
          }
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Cases/OutfitCase.h

       1  //
          // C++ Interface: OutfitCase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_CASESOUTFITCASE_H
          #define EMBEROGRE_MODEL_MAPPING_CASESOUTFITCASE_H
          
          #include "../Matches/OutfitMatch.h"
          #include "EntityBaseCase.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
          
          /**
           A case that is a child of an OutfitMatch.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      41  class OutfitCase : public Case<Matches::OutfitMatch>,   public EntityBaseCase
          {
          public:
      44   OutfitCase(   ) {};
      45   ~OutfitCase(   ) {};
          protected:
      47   virtual void _setState(  bool state );
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/ChangeContext.cpp

       1  //
          // C++ Implementation: ChangeContext
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ChangeContext.h"
          #include "Cases/CaseBase.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          
          
      34  ChangeContext::ChangeContext(   )
          {
          }
          
          
      39  ChangeContext::~ChangeContext(   )
          {
          }
          
      43  void ChangeContext::addCaseToActivate(  Cases::CaseBase* aCase )
          {
           mActivateQueue.push_back(  aCase );
          }
          
      48  void ChangeContext::addCaseToDeactivate(  Cases::CaseBase* aCase )
          {
           mDeactivateQueue.push_back(  aCase );
          }
          
      53  void ChangeContext::performActions(   )
          {
           for (  CaseStore::iterator I = mDeactivateQueue.begin(   ); I != mDeactivateQueue.end(   ); ++I ) {
           (  *I )->deactivateActions(   );
           }
           for (  CaseStore::iterator I = mActivateQueue.begin(   ); I != mActivateQueue.end(   ); ++I ) {
           (  *I )->activateActions(   );
           }
          
          }
          
          
          }
          
          }
          
          }

./components/ogre/model/mapping/ChangeContext.h

       1  //
          // C++ Interface: ChangeContext
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPINGCHANGECONTEXT_H
          #define EMBEROGRE_MODEL_MAPPINGCHANGECONTEXT_H
          #include <vector>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
      34  class CaseBase;
          }
          
          /**
           Whenever something has changed in the values that affects the Model,   cases will need to be reevaluated and actions may be activated or deactivated. A ChangeContext wraps these events into one class. This is an internal class which will be created and acted upon by the mapping framework.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      41  class ChangeContext
          {
          public:
          
           typedef std::vector<Cases::CaseBase*> CaseStore;
          
      47   ChangeContext(   );
          
      49   ~ChangeContext(   );
          
           /**
           * Adds a Case that needs to be activated to the context. Activation will happen upon calls to performActions(   ).
           * @param aCase
           */
      55   void addCaseToActivate(  Cases::CaseBase* aCase );
           /**
           * Adds a Case that needs to be deactivated to the context. Deactivation will happen upon calls to performActions(   ).
           * @param aCase
           */
      60   void addCaseToDeactivate(  Cases::CaseBase* aCase );
          
           /**
           * Performs the actions that should be activated and deactivated.
           */
      65   void performActions(   );
          
          protected:
          
          /**
          A store of those cases that should be activated.
          */
      72  CaseStore mActivateQueue;
          
          /**
          A store of those cases that should be deactivated.
          */
      77  CaseStore mDeactivateQueue;
          
          };
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Definitions/ActionDefinition.cpp

       1  //
          // C++ Implementation: ActionDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ActionDefinition.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
      33  const std::string& ActionDefinition::getValue(   ) const
          {
           return mValue;
          }
          
      38  void ActionDefinition::setValue(  std::string value )
          {
           mValue = value;
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Definitions/ActionDefinition.h

       1  //
          // C++ Interface: ActionDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPINGACTIONDEFINITION_H
          #define EMBEROGRE_MODEL_MAPPINGACTIONDEFINITION_H
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "DefinitionBase.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
          /**
           A definition for an Action.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      44  class ActionDefinition : public DefinitionBase
          {
          public:
      47   const std::string& getValue(   ) const;
      48   void setValue(  std::string type );
          protected:
      50   std::string mValue;
          
          };
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Definitions/CaseDefinition.cpp

       1  //
          // C++ Implementation: CaseDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "CaseDefinition.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
      33  CaseDefinition::MatchStore& CaseDefinition::getMatches(   )
          {
           return mMatches;
          }
          
      38  const CaseDefinition::MatchStore& CaseDefinition::getMatches(   ) const
          {
           return mMatches;
          }
          
      43  CaseDefinition::ActionStore& CaseDefinition::getActions(   )
          {
           return mActions;
          }
          
      48  const CaseDefinition::ActionStore& CaseDefinition::getActions(   ) const
          {
           return mActions;
          }
          
      53  CaseDefinition::ParameterStore& CaseDefinition::getCaseParameters(   )
          {
           return mParameters;
          }
          
      58  const CaseDefinition::ParameterStore& CaseDefinition::getCaseParameters(   ) const
          {
           return mParameters;
          }
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Definitions/CaseDefinition.h

       1  //
          // C++ Interface: CaseDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_DEFINITIONSCASEDEFINITION_H
          #define EMBEROGRE_MODEL_MAPPING_DEFINITIONSCASEDEFINITION_H
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
      36  class MatchDefinition;
          }
          }
          }
          }
          
          #include "DefinitionBase.h"
          #include "MatchDefinition.h"
          #include "ActionDefinition.h"
          #include <vector>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
          /**
           A definition for a Case.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      59  class CaseDefinition : public DefinitionBase
          {
          public:
           typedef std::vector<MatchDefinition> MatchStore;
           typedef std::vector<ActionDefinition> ActionStore;
           typedef std::pair<std::string,   std::string> ParameterEntry;
           typedef std::vector<ParameterEntry> ParameterStore;
          
      67   MatchStore& getMatches(   );
      68   const MatchStore& getMatches(   ) const;
      69   ActionStore& getActions(   );
      70   const ActionStore& getActions(   ) const;
      71   ParameterStore& getCaseParameters(   );
      72   const ParameterStore& getCaseParameters(   ) const;
          
          protected:
      75   MatchStore mMatches;
      76   ActionStore mActions;
      77   ParameterStore mParameters;
          };
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Definitions/DefinitionBase.cpp

       1  //
          // C++ Implementation: DefinitionBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "DefinitionBase.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
          
      34  DefinitionBase::PropertiesMap& DefinitionBase::getProperties(   )
          {
           return mProperties;
          }
          
      39  const DefinitionBase::PropertiesMap& DefinitionBase::getProperties(   ) const
          {
           return mProperties;
          }
          
      44  const std::string& DefinitionBase::getType(   ) const
          {
           return mType;
          }
      48  void DefinitionBase::setType(  std::string type )
          {
           mType = type;
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Definitions/DefinitionBase.h

       1  //
          // C++ Interface: DefinitionBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPINGDEFINITIONBASE_H
          #define EMBEROGRE_MODEL_MAPPINGDEFINITIONBASE_H
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          
          #include <string>
          #include <map>
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
          
          /**
           Base class for all Definitions.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      48  class DefinitionBase
          {
          public:
           typedef std::map<std::string,   std::string> PropertiesMap;
           /**
           Returns a map of arbitrary properties.
           */
      55   PropertiesMap& getProperties(   );
          
           /**
           Returns a map of arbitrary properties.
           */
      60   const PropertiesMap& getProperties(   ) const;
          
           /**
           Gets the type of this definition.
           */
      65   const std::string& getType(   ) const;
      66   void setType(  std::string type );
          
          protected:
      69   std::map<std::string,   std::string> mProperties;
      70   std::string mType;
          };
          
          }
          
          }
          
          }
          
          }
          
          
          #endif

./components/ogre/model/mapping/Definitions/MatchDefinition.cpp

       1  //
          // C++ Implementation: MatchDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "MatchDefinition.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
          
      34  MatchDefinition::CaseStore& MatchDefinition::getCases(   )
          {
           return mCases;
          }
          
      39  const MatchDefinition::CaseStore& MatchDefinition::getCases(   ) const
          {
           return mCases;
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Definitions/MatchDefinition.h

       1  //
          // C++ Interface: MatchDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPINGMATCHDEFINITION_H
          #define EMBEROGRE_MODEL_MAPPINGMATCHDEFINITION_H
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
          
      39  class CaseDefinition;
          }
          }
          }
          }
          #include "DefinitionBase.h"
          #include "CaseDefinition.h"
          #include <vector>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
          
          /**
           A definition for a Match.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      61  class MatchDefinition : public DefinitionBase
          {
          public:
           typedef std::vector<CaseDefinition> CaseStore;
          
      66   CaseStore& getCases(   );
      67   const CaseStore& getCases(   ) const;
          
          protected:
      70   CaseStore mCases;
          };
          }
          
          }
          
          }
          
          }
          
          
          #endif

./components/ogre/model/mapping/Definitions/ModelMappingDefinition.cpp

       1  //
          // C++ Implementation: ModelMappingDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ModelMappingDefinition.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
      33  ModelMappingDefinition::ModelMappingDefinition(   )
          {
          }
          
      37  ModelMappingDefinition::~ModelMappingDefinition(   )
          {
          }
          
          
      42  const std::string& ModelMappingDefinition::getName(   ) const
          {
           return mName;
          }
      46  void ModelMappingDefinition::setName(  std::string name )
          {
           mName = name;
          }
          
      51  MatchDefinition& ModelMappingDefinition::getRoot(   )
          {
           return mRootMatch;
          }
          
      56  const MatchDefinition& ModelMappingDefinition::getRoot(   ) const
          {
           return mRootMatch;
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Definitions/ModelMappingDefinition.h

       1  //
          // C++ Interface: ModelMappingDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPINGMODELMAPPINGDEFINITION_H
          #define EMBEROGRE_MODEL_MAPPINGMODELMAPPINGDEFINITION_H
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          
          #include <vector>
          #include <map>
          #include <string>
          
          #include "MatchDefinition.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
          
          
          
          /**
           A definition for a ModelMapping.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      51  class ModelMappingDefinition
          {
          public:
      54   ModelMappingDefinition(   );
          
      56   ~ModelMappingDefinition(   );
          
      58   const std::string& getName(   ) const;
      59   void setName(  std::string name );
          
      61   MatchDefinition& getRoot(   );
      62   const MatchDefinition& getRoot(   ) const;
          protected:
      64   MatchDefinition mRootMatch;
      65   std::string mName;
          };
          
          
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/EmberModelMappingManager.cpp

       1  //
          // C++ Implementation: EmberModelMappingManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EmberModelMappingManager.h"
          #include "framework/tinyxml/tinyxml.h"
          
          #include "services/EmberServices.h"
          #include "services/server/ServerService.h"
          #include "components/ogre/XMLHelper.h"
          
          #include <Eris/Connection.h>
          
          using namespace EmberOgre::Model::Mapping;
          
          
          template<> EmberOgre::Model::Mapping::EmberModelMappingManager* Ember::Singleton<EmberOgre::Model::Mapping::EmberModelMappingManager>::ms_Singleton = 0;
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
      43  EmberModelMappingManager::EmberModelMappingManager(   ) : mModelMappingManager(   ),   mXmlSerializer(  mModelMappingManager )
          {
           mLoadOrder = 300.0f;
           mResourceType = "ModelMappingDefinition";
          
           mScriptPatterns.push_back(  "*.modelmap" );
           mScriptPatterns.push_back(  "*.modelmap.xml" );
           Ogre::ResourceGroupManager::getSingleton(   )._registerScriptLoader(  this );
          
           Ogre::ResourceGroupManager::getSingleton(   )._registerResourceManager(  mResourceType,   this );
          
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->GotConnection.connect(  sigc::mem_fun(  *this,   &EmberModelMappingManager::ServerService_GotConnection ) );
          
          
          }
          
          
      60  EmberModelMappingManager::~EmberModelMappingManager(   )
          {
           Ogre::ResourceGroupManager::getSingleton(   )._unregisterResourceManager(  mResourceType );
           Ogre::ResourceGroupManager::getSingleton(   )._unregisterScriptLoader(  this );
          }
          
          
      67  void EmberModelMappingManager::parseScript (  Ogre::DataStreamPtr &stream,   const Ogre::String &groupName )
          {
           Ember::TiXmlDocument xmlDoc;
           XMLHelper xmlHelper;
           if (  !xmlHelper.Load(  xmlDoc,   stream ) ) {
           return;
           }
          
           mXmlSerializer.parseScript(  xmlDoc );
          }
          
      78  Ogre::Resource* EmberModelMappingManager::createImpl(  const Ogre::String& name,   Ogre::ResourceHandle handle,  
      79   const Ogre::String& group,   bool isManual,   Ogre::ManualResourceLoader* loader,  
      80   const Ogre::NameValuePairList* createParams )
          {
           return 0;
          }
          
          
      86  void EmberModelMappingManager::ServerService_GotConnection(  Eris::Connection* connection ) {
           mModelMappingManager.setTypeService(  connection->getTypeService(   ) );
          }
          
          
          
          
          }
          
          }
          
          }

./components/ogre/model/mapping/EmberModelMappingManager.h

       1  //
          // C++ Interface: EmberModelMappingManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREEMBERMODELMAPPINGMANAGER_H
          #define EMBEROGREEMBERMODELMAPPINGMANAGER_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          #include <OgreResourceManager.h>
          #include "framework/Singleton.h"
          
          #include "ModelMappingManager.h"
          #include "XMLModelMappingDefinitionSerializer.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          
          /**
           Uses the Ogre::ResourceManager framework to provide managing of model mapping definitions.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      46  class EmberModelMappingManager :
      47  public Ogre::ResourceManager,  
      48  public Ember::Singleton<EmberModelMappingManager>,  
      49  public sigc::trackable
          {
          public:
      52   EmberModelMappingManager(   );
          
      54   ~EmberModelMappingManager(   );
          
           /**
           Accessor for the main ModelMappingManager instance.
           */
      59   inline ModelMappingManager& getManager(   );
          
           /**
           Method called by Ogre. Will parse the script supplied in the stream object.
           */
      64   virtual void parseScript (  Ogre::DataStreamPtr &stream,   const Ogre::String &groupName );
          
          protected:
           /**
           Internal instance of the ModelMappingManager.
           */
      70   ModelMappingManager mModelMappingManager;
          
           /**
           Serializer for xml.
           */
      75   XMLModelMappingDefinitionSerializer mXmlSerializer;
          
           /**
           Internal method called by Ogre.
           */
      80   virtual Ogre::Resource* createImpl(  const Ogre::String& name,   Ogre::ResourceHandle handle,  
      81   const Ogre::String& group,   bool isManual,   Ogre::ManualResourceLoader* loader,  
      82   const Ogre::NameValuePairList* createParams );
          
           /**
           When we get a connection,   set the TypeService on the mModelMappingManager instance.
           */
      87   void ServerService_GotConnection(  Eris::Connection* connection );
          
          };
          
      91  ModelMappingManager& EmberModelMappingManager::getManager(   )
          {
           return mModelMappingManager;
          }
          
          }
          }
          }
          
          #endif

./components/ogre/model/mapping/IActionCreator.h

       1  //
          // C++ Interface: IActionCreator
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Definitions/CaseDefinition.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
      32  class CaseBase;
          }
          
      35  class ModelMapping;
          
          /**
          Interface that allows for client specific actions to be created.
          
          Clients that use the Mapping framework are required to implement this interface. This interface is used in ModelMappingManager::createMapping(  ... )
          */
      42  class IActionCreator
          {
          public:
      45   virtual ~IActionCreator(   ) {}
          
           /**
           Creates actions for the supplied case.
           Use Cases::CaseBase::addAction(  ... ) to add the actions to the case.
           */
      51   virtual void createActions(  ModelMapping& modelMapping,   Cases::CaseBase* aCase,   Definitions::CaseDefinition& caseDefinition ) = 0;
          private:
          };
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Matches/AbstractMatch.cpp

       1  //
          // C++ Implementation: AbstractMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AbstractMatch.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Matches/AbstractMatch.h

       1  //
          // C++ Interface: AbstractMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_MATCHESABSTRACTMATCH_H
          #define EMBEROGRE_MODEL_MAPPING_MATCHESABSTRACTMATCH_H
          
          #include "MatchBase.h"
          #include <vector>
          #include "../ChangeContext.h"
          
          namespace Eris
          {
      32  class Entity;
          }
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          
          /**
          Utility method for cleaning a std::vector,   deleting all instances held.
          */
          template <typename T>
      48  static void cleanVector(  T& theVector )
          {
           typename T::iterator I = theVector.begin(   );
           for (  ;I != theVector.end(   ); ++I ) {
           delete *I;
           }
           theVector.clear(   );
          }
          
          /**
           Base class for all matches which includes templated definitions of the kind of Case it will hold.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
          template <class TCase>
      62  class AbstractMatch : public MatchBase
          {
          public:
          
      66   AbstractMatch(   );
          
      68   virtual ~AbstractMatch(   );
          
           /**
           * Adds a child case.
           * @param aCase
           */
      74   void addCase(  TCase* aCase );
          
           /**
           Gets all child cases.
           */
      79   std::vector<TCase*>& getCases(   );
          
           /**
           Sets the Eris::Entity.
           */
      84   virtual void setEntity(  Eris::Entity* entity );
          
           /**
           Evaluate all changes starting from this Match.
           */
      89   void evaluateChanges(   );
          
           /**
           Evaluate all changes and add changed Cases to the supplied ChangeContext.
           */
      94   virtual void evaluateChanges(  ChangeContext& changeContext );
          
          protected:
      97   std::vector<TCase*> mCases;
          };
          
          template <class TCase>
     101  AbstractMatch<TCase>::AbstractMatch(   )
          {
          }
          
          template <class TCase>
     106  AbstractMatch<TCase>::~AbstractMatch(   )
          {
           cleanVector(  mCases );
          }
          
          
          template <class TCase>
     113  void AbstractMatch<TCase>::setEntity(  Eris::Entity* entity )
          {
           typename std::vector< TCase* >::iterator I = mCases.begin(   );
           for (   ; I != mCases.end(   ); ++I ) {
           (  *I )->setEntity(  entity );
           }
          }
          
          template <class TCase>
     122  std::vector<TCase*>& AbstractMatch<TCase>::getCases(   )
          {
           return mCases;
          }
          
          template <class TCase>
     128  void AbstractMatch<TCase>::addCase(  TCase* aCase ) {
           mCases.push_back(  aCase );
           aCase->setParentCase(  mParentCase );
          }
          
          template <class TCase>
     134  void AbstractMatch<TCase>::evaluateChanges(  ChangeContext& changeContext ) {
          
           ///we want to make sure that we start with deactivating actions,   and then after that activate those that should be activated
          
           typename std::vector<TCase*>::iterator endI = mCases.end(   );
           for (  typename std::vector<TCase*>::iterator I = mCases.begin(   ); I != endI; ++I ) {
           (  *I )->evaluateChanges(  changeContext );
           }
          }
          
          template <class TCase>
     145  void AbstractMatch<TCase>::evaluateChanges(   ) {
          
           ///we want to make sure that we start with deactivating actions,   and then after that activate those that should be activated
          
           ChangeContext changeContext;
          
           evaluateChanges(  changeContext );
          
           changeContext.performActions(   );
          }
          
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Matches/AttributeDependentMatch.cpp

       1  //
          // C++ Implementation: AttributeDependentMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AttributeDependentMatch.h"
          #include "Observers/AttributeObserver.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          
          
      36  AttributeDependentMatch::AttributeDependentMatch(   )
          : mAttributeObserver(  0 )
          {
          }
          
      41  AttributeDependentMatch::~AttributeDependentMatch(   )
          {
          }
          
      45  void AttributeDependentMatch::setAttributeObserver(  Observers::AttributeObserver* observer )
          {
           mAttributeObserver = std::auto_ptr<Observers::AttributeObserver>(  observer );
          }
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Matches/AttributeDependentMatch.h

       1  //
          // C++ Interface: AttributeDependentMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_MATCHESATTRIBUTEDEPENDENTMATCH_H
          #define EMBEROGRE_MODEL_MAPPING_MATCHESATTRIBUTEDEPENDENTMATCH_H
          
          #include <Atlas/Message/Element.h>
          #include "Observers/AttributeObserver.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          
          /**
           Base class for all Matches that are dependent on an attribute.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      42  class AttributeDependentMatch
          {
          public:
      45   AttributeDependentMatch(   );
      46   virtual ~AttributeDependentMatch(   );
          
           /**
           Test changes to the attribute.
           */
      51   virtual void testAttribute(  const Atlas::Message::Element& attribute,   bool triggerEvaluation = false ) = 0;
          
           /**
           Use the supplied observer to observe changes to the attribute. The supplied observer will be managed by this class.
           */
      56   void setAttributeObserver(  Observers::AttributeObserver* observer );
          
          protected:
          
      60   std::auto_ptr<Observers::AttributeObserver> mAttributeObserver;
          };
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Matches/AttributeMatch.cpp

       1  //
          // C++ Implementation: AttributeMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AttributeMatch.h"
          #include "../Cases/AttributeCase.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
      34  AttributeMatch::AttributeMatch(  const std::string& attributeName )
          : mAttributeName(  attributeName ),   mInternalAttributeName(  attributeName )
          {
          }
          
      39  AttributeMatch::AttributeMatch(  const std::string& attributeName,   const std::string& internalAttributeName )
          : mAttributeName(  attributeName ),   mInternalAttributeName(  internalAttributeName )
          {
          }
          
          
      45  void AttributeMatch::testAttribute(  const Atlas::Message::Element& attribute,   bool triggerEvaluation )
          {
           for (  std::vector<Cases::AttributeCase*>::iterator I = mCases.begin(   ); I != mCases.end(   ); ++I ) {
           (  *I )->testMatch(  attribute );
           }
           if (  triggerEvaluation ) {
           evaluateChanges(   );
           }
          }
          
      55  void AttributeMatch::setEntity(  Eris::Entity* entity )
          {
           AbstractMatch<Cases::AttributeCase>::setEntity(  entity );
           ///observe the attribute by the use of an AttributeObserver
           mAttributeObserver->observeEntity(  entity );
           if (  entity ) {
           if (  entity->hasAttr(  mInternalAttributeName ) ) {
           testAttribute(  entity->valueOfAttr(  mInternalAttributeName ),   false );
           } else {
           testAttribute(  Atlas::Message::Element(   ),   false );
           }
           }
          }
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Matches/AttributeMatch.h

       1  //
          // C++ Interface: AttributeMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_MATCHESATTRIBUTEMATCH_H
          #define EMBEROGRE_MODEL_MAPPING_MATCHESATTRIBUTEMATCH_H
          
          #include "AbstractMatch.h"
          #include "AttributeDependentMatch.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
      36  class AttributeCase;
          }
          }
          }
          }
          
          #include "../Cases/AttributeCase.h"
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          /**
           A Match that inspects a certain attribute.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      57  class AttributeMatch : public AbstractMatch<Cases::AttributeCase>,   public AttributeDependentMatch
          {
          public:
          
           /**
           Creates a new instance that watches for changes to the supplied attribute.
           */
      64   AttributeMatch(  const std::string& attributeName );
          
           /**
           Creates a new instance that watches for changes to the supplied attribute. The attribute that is watched differs from the name of the attribute. (  Such as when using a function comparer for "height",   where the internal attribute watched is "bbox". )
           */
      69   AttributeMatch(  const std::string& attributeName,   const std::string& internalAttributeName );
          
      71   virtual void testAttribute(  const Atlas::Message::Element& attribute,   bool triggerEvaluation = false );
          
           /**
           Gets the name of the attribute that is watched.
           */
      76   inline const std::string& getAttributeName(   );
          
           /**
           Sets the Entity to watch.
           */
      81   virtual void setEntity(  Eris::Entity* entity );
          
          protected:
          
      85   std::string mAttributeName,   mInternalAttributeName;
          };
          
      88  const std::string& AttributeMatch::getAttributeName(   )
          {
           return mAttributeName;
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Matches/EntityTypeMatch.cpp

       1  //
          // C++ Implementation: EntityTypeMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityTypeMatch.h"
          
          #include "AbstractMatch.h"
          #include "../Cases/EntityTypeCase.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
      36  void EntityTypeMatch::setEntity(  Eris::Entity* entity )
          {
           AbstractMatch<Cases::EntityTypeCase>::setEntity(   entity );
           testEntity(  entity );
          }
          
      42  void EntityTypeMatch::testEntity(  Eris::Entity* entity )
          {
           for (  std::vector<Cases::EntityTypeCase*>::iterator I = mCases.begin(   ); I != mCases.end(   ); ++I ) {
           (  *I )->testMatch(  entity );
           }
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Matches/EntityTypeMatch.h

       1  //
          // C++ Interface: EntityTypeMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_MATCHESENTITYTYPEMATCH_H
          #define EMBEROGRE_MODEL_MAPPING_MATCHESENTITYTYPEMATCH_H
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
      33  class EntityTypeCase;
          }
          }
          }
          }
          
          #include "../Cases/EntityTypeCase.h"
          #include "AbstractMatch.h"
          namespace Eris
          {
      43  class Entity;
          }
          
      46  namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          /**
           Watches for certain entity types.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
          class EntityTypeMatch : public AbstractMatch<Cases::EntityTypeCase>
          {
          public:
          
           void testEntity(  Eris::Entity* entity );
           virtual void setEntity(  Eris::Entity* entity );
          
          protected:
          
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Matches/MatchBase.cpp

       1  //
          // C++ Implementation: MatchBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "MatchBase.h"
          #include "../ChangeContext.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Matches/MatchBase.h

       1  //
          // C++ Interface: MatchBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_MATCHESMATCHBASE_H
          #define EMBEROGRE_MODEL_MAPPING_MATCHESMATCHBASE_H
          
          #include "../Cases/CaseBase.h"
          namespace Eris
          {
      29  class Entity;
          }
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
          
      44  class MatchBase
          {
          public:
          
      48   MatchBase(   ) : mParentCase(  0 ) {}
      49   virtual ~MatchBase(   ) {}
      50   inline void setParentCase(  Cases::CaseBase* aCase );
      51   virtual void setEntity(  Eris::Entity* entity ) = 0;
      52   virtual void evaluateChanges(  ChangeContext& changeContext ) = 0;
          
          
          protected:
      56   Cases::CaseBase* mParentCase;
          };
          
      59  void MatchBase::setParentCase(  Cases::CaseBase* aCase )
          {
           mParentCase = aCase;
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Matches/Observers/AttributeObserver.cpp

       1  //
          // C++ Implementation: AttributeObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AttributeObserver.h"
          
          #include "../../ModelMapping.h"
          #include <Atlas/Message/Element.h>
          #include <sigc++/slot.h>
          #include "../AttributeDependentMatch.h"
          #include "../AttributeMatch.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          namespace Observers {
          
      41  AttributeObserver::AttributeObserver(  Matches::AttributeDependentMatch* match,  const std::string& attributeName )
          : mMatch(  match ),   mAttributeName(  attributeName )
          {
          }
          
      46  AttributeObserver::AttributeObserver(  Matches::AttributeMatch* match )
          : mMatch(  match ),   mAttributeName(  match->getAttributeName(   ) )
          {
          }
          
      51  void AttributeObserver::attributeChanged(   const Atlas::Message::Element& attributeValue )
          {
           mMatch->testAttribute(  attributeValue,   true );
          }
          
      56  void AttributeObserver::observeEntity(  Eris::Entity* entity )
          {
           mSlot.disconnect(   );
           if (  entity ) {
           mSlot = sigc::mem_fun(  *this,   &AttributeObserver::attributeChanged );
           entity->observe(  mAttributeName,   mSlot );
           }
          }
          
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Matches/Observers/AttributeObserver.h

       1  //
          // C++ Interface: AttributeObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_MATCHES_OBSERVERSATTRIBUTEOBSERVER_H
          #define EMBEROGRE_MODEL_MAPPING_MATCHES_OBSERVERSATTRIBUTEOBSERVER_H
          
          #include <sigc++/trackable.h>
          #include "../../ModelMapping.h"
          #include "../AbstractMatch.h"
          
          #include <Eris/Entity.h>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
      40  class AttributeMatch;
      41  class AttributeDependentMatch;
          
          namespace Observers {
          
          /**
           Observes changes to a specific attribute and automatically pass changes on the Match that the observer is attached to.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      49  class AttributeObserver : public sigc::trackable
          {
          public:
          
      53   AttributeObserver(  AttributeMatch* match ) ;
      54   AttributeObserver(  AttributeDependentMatch* match,   const std::string& attributeName );
          
           /**
           Sets the entity to observe.
           */
      59   void observeEntity(  Eris::Entity* entity );
          
          protected:
      62   Eris::Entity::AttrChangedSlot mSlot;
          
      64   void attributeChanged(  const Atlas::Message::Element& attributeValue );
          
      66   AttributeDependentMatch* mMatch;
          
      68   std::string mAttributeName;
          
          };
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Matches/Observers/EntityCreationObserver.cpp

       1  //
          // C++ Implementation: EntityCreationObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityCreationObserver.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          namespace Observers {
          
      35  EntityCreationObserver::EntityCreationObserver(  OutfitMatch& outfitMatch )
          : mOutfitMatch(  outfitMatch )
          {
          }
      39  EntityCreationObserver::~EntityCreationObserver(   )
          {
           mSlot.disconnect(   );
          }
          
      44  void EntityCreationObserver::observeCreation(  Eris::View* view,   const std::string& entityId )
          {
           mSlot.disconnect(   );
           mSlot = sigc::mem_fun(  *this,   &EntityCreationObserver::entitySeen );
           view->notifyWhenEntitySeen(  entityId,   mSlot );
          }
          
      51  void EntityCreationObserver::entitySeen(  Eris::Entity* entity )
          {
           mSlot.disconnect(   );
           mOutfitMatch.testEntity(  entity );
          }
          
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Matches/Observers/EntityCreationObserver.h

       1  //
          // C++ Interface: EntityCreationObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_MATCHES_OBSERVERSENTITYCREATIONOBSERVER_H
          #define EMBEROGRE_MODEL_MAPPING_MATCHES_OBSERVERSENTITYCREATIONOBSERVER_H
          
          #include <sigc++/trackable.h>
          #include "../OutfitMatch.h"
          #include "../../ModelMapping.h"
          #include <Eris/View.h>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          namespace Observers {
          
          /**
           Observes for the creation of a specific entity in the world and automatically trigger the Match the observer is attached to when that entity is created.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      45  class EntityCreationObserver : public sigc::trackable
          {
          public:
          
      49   EntityCreationObserver(  OutfitMatch& outfitMatch );
      50   ~EntityCreationObserver(   );
          
      52   void observeCreation(  Eris::View* view,   const std::string& entityId );
          
          protected:
          
      56   OutfitMatch& mOutfitMatch;
          
      58   Eris::View::EntitySightSlot mSlot;
          
      60   void entitySeen(  Eris::Entity* entity );
          
          };
          
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/Matches/OutfitMatch.cpp

       1  //
          // C++ Implementation: OutfitMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OutfitMatch.h"
          #include "Observers/EntityCreationObserver.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
      34  OutfitMatch::OutfitMatch(  const std::string& outfitName,   Eris::View* view )
          : mOutfitName(  outfitName ),   mView(  view ),   mEntityObserver(  0 )
          {
          }
          
      39  void OutfitMatch::testAttribute(  const Atlas::Message::Element& attribute,   bool triggerEvaluation )
          {
           if (  attribute.isMap(   ) ) {
           Eris::Entity* entity(  0 );
           const Atlas::Message::MapType & tmap = attribute.asMap(   );
           Atlas::Message::MapType::const_iterator I = tmap.find(  mOutfitName );
           if (  I != tmap.end(   ) && I->second.isString(   ) ) {
           entity = mView->getEntity(  I->second.asString(   ) );
           ///the entity might not be available yet,   so we need to create an observer for it
           if (  !entity ) {
           if (  mEntityObserver.get(   ) ) {
           mEntityObserver->observeCreation(  mView,   I->second.asString(   ) );
           }
           } else {
           testEntity(  entity );
           }
           } else {
           testEntity(  entity );
           }
           }
           if (  triggerEvaluation ) {
           evaluateChanges(   );
           }
          }
          
      64  void OutfitMatch::setEntity(  Eris::Entity* entity )
          {
           ///observe the attribute by the use of an AttributeObserver
           mAttributeObserver->observeEntity(  entity );
          }
          
      70  void OutfitMatch::setEntityCreationObserver(  Observers::EntityCreationObserver* observer )
          {
           mEntityObserver = std::auto_ptr<Observers::EntityCreationObserver>(  observer );
          }
          
      75  void OutfitMatch::testEntity(  Eris::Entity* entity )
          {
          // if (  entity ) {
          // mEntityObserver.release(   );
          // }
          
           AbstractMatch<Cases::OutfitCase>::setEntity(  entity );
          
           for (  std::vector<Cases::OutfitCase*>::iterator I = mCases.begin(   ); I != mCases.end(   ); ++I ) {
           (  *I )->testMatch(  entity );
           }
           evaluateChanges(   );
          
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/Matches/OutfitMatch.h

       1  //
          // C++ Interface: OutfitMatch
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPING_MATCHESOUTFITMATCH_H
          #define EMBEROGRE_MODEL_MAPPING_MATCHESOUTFITMATCH_H
          
          #include "AbstractMatch.h"
          #include "AttributeDependentMatch.h"
          #include "../Cases/OutfitCase.h"
          #include <Eris/View.h>
          #include <Atlas/Message/Element.h>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Matches {
          
          namespace Observers {
      41  class EntityCreationObserver;
          }
          
          /**
           Watches for changes to a specific outfit point,   such as "body" or "feet". Whenever an entity is outfitted or removed this will trigger.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      48  class OutfitMatch : public AbstractMatch<Cases::OutfitCase>,   public AttributeDependentMatch
          {
      50  friend class Observers::EntityCreationObserver;
          public:
          
      53   OutfitMatch(  const std::string& outfitName,   Eris::View* view );
          
      55   virtual void testAttribute(  const Atlas::Message::Element& attribute,   bool triggerEvaluation = false );
          
      57   inline const std::string& getOutfitName(   );
      58   virtual void setEntity(  Eris::Entity* entity );
          
      60   void setEntityCreationObserver(  Observers::EntityCreationObserver* observer );
          
          protected:
          
      64   void testEntity(  Eris::Entity* entity );
      65   std::string mOutfitName;
      66   Eris::View* mView;
      67   std::auto_ptr<Observers::EntityCreationObserver> mEntityObserver;
          };
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/ModelMapping.cpp

       1  //
          // C++ Implementation: ModelMapping
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ModelMapping.h"
          #include <Eris/View.h>
          #include "Cases/CaseBase.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          
      34  ModelMapping::ModelMapping(  Eris::Entity* entity ): mEntity(  entity )
          {
          }
          
      38  ModelMapping::~ModelMapping(   )
          {
          }
          
      42  Matches::EntityTypeMatch& ModelMapping::getRootEntityMatch(   )
          {
           return mRootEntityMatch;
          }
          
          
      48  void ModelMapping::initialize(   )
          {
           mRootEntityMatch.evaluateChanges(   );
          }
          
          
          }
          
          }
          
          }

./components/ogre/model/mapping/ModelMapping.h

       1  //
          // C++ Interface: ModelMapping
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPINGMODELMAPPING_H
          #define EMBEROGRE_MODEL_MAPPINGMODELMAPPING_H
          
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include <vector>
          #include <iostream>
          #include <memory>
          
          #include <Atlas/Objects/Entity.h>
          
          #include <Eris/Entity.h>
          
          #include "Matches/EntityTypeMatch.h"
          
          
          namespace Eris
          {
      44  class Entity;
      45  class View;
          }
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Cases {
      55  class OutfitCase;
      56  class CaseBase;
      57  class EntityTypeCase;
      58  class AttributeCase;
          
          namespace AttributeComparers {
      61  class AttributeComparerWrapper;
          }
          
          }
          namespace Matches {
      66  class EntityTypeMatch;
      67  class MatchBase;
      68  class Match;
      69  class AttributeMatch;
      70  class OutfitMatch;
          
          namespace Observers {
      73  class AttributeObserver;
      74  class EntityCreationObserver;
          
          }
          
          }
          
          
          /**
          Utility method for deleting all object held in a std::vector.
          */
      84  template <typename T>
          static void cleanVector(  T& theVector )
          {
           typename T::iterator I = theVector.begin(   );
           for (  ;I != theVector.end(   ); ++I ) {
           delete *I;
           }
           theVector.clear(   );
          }
          
          
          
          /**
           Instances of this are connected to Eris::Entity instances,   and listen for changes in attributes and contained entities. When a change occurs,   a client defined action is activated or deactivated,   leading to client side changes. A typucal case is the changing of a model's appearance.
          
           The ModelMapping contains three different types of object: Matches,   Cases and Actions.
           A Match tells the framework what needs to be tested. Examples are specific attributes or entity types
           Each Match has one or many Cases,   which defines valid cases of the value that the Match is set to test for. The Cases are not mutually exclusive,   so one or many cases can be true at the same time.
           Each Case can then contain either Actions or more Matches,   or both. Actions are client defined,   and can be to display a certain model,   or to change a texture.
          
           These elements are arranged in a node tree structure,   contained by the ModelMapping. The ModelMapping is self contained and uses it's own oberservers to watch for changes in the values that will result in changes. At the top of the node tree is an EntityTypeMatch instance,   held directly by the ModelMapping. From this instance's Cases the framework determines what ModelMapping to use for a certain Eris::Type.
          
           Instances of this class are normally not created directly by the application,   instead ModelMappingManager::createMapping(  ... ) is used.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
     110  class ModelMapping
          {
          public:
           typedef std::vector<Cases::CaseBase*> CaseBaseStore;
           typedef std::vector<Matches::Observers::AttributeObserver*> AttributeObserverStore;
     115   ModelMapping(  Eris::Entity* entity );
          
     117   ~ModelMapping(   );
          
           /**
           Gets the root entity match instance.
           */
     122   Matches::EntityTypeMatch& getRootEntityMatch(   );
          
           /**
           Initializes the mapping. Clients are required to call this on all new instances.
           */
     127   void initialize(   );
          
          
          protected:
          
     132   Matches::EntityTypeMatch mRootEntityMatch;
          
     134   Eris::Entity* mEntity;
          };
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/ModelMappingCreator.cpp

       1  //
          // C++ Implementation: ModelMappingCreator
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ModelMappingCreator.h"
          #include "ModelMapping.h"
          #include "ModelMappingManager.h"
          
          #include "Cases/OutfitCase.h"
          #include "Cases/AttributeCase.h"
          #include "Cases/EntityTypeCase.h"
          
          #include "Cases/AttributeComparers/AttributeComparerWrapper.h"
          #include "Cases/AttributeComparers/HeightComparerWrapper.h"
          #include "Cases/AttributeComparers/NumericComparer.h"
          #include "Cases/AttributeComparers/NumericComparerWrapper.h"
          #include "Cases/AttributeComparers/NumericEqualsComparer.h"
          #include "Cases/AttributeComparers/NumericEqualsOrGreaterComparer.h"
          #include "Cases/AttributeComparers/NumericEqualsOrLesserComparer.h"
          #include "Cases/AttributeComparers/NumericGreaterComparer.h"
          #include "Cases/AttributeComparers/NumericLesserComparer.h"
          #include "Cases/AttributeComparers/NumericRangeComparer.h"
          #include "Cases/AttributeComparers/NumericValueHolder.h"
          #include "Cases/AttributeComparers/StringComparer.h"
          #include "Cases/AttributeComparers/StringComparerWrapper.h"
          
          
          #include "Matches/OutfitMatch.h"
          #include "Matches/AttributeMatch.h"
          #include "Matches/EntityTypeMatch.h"
          #include "Matches/Observers/AttributeObserver.h"
          #include "Matches/Observers/EntityCreationObserver.h"
          
          #include "IActionCreator.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          using namespace Definitions;
          using namespace Matches;
          using namespace Observers;
          using namespace Cases;
          using namespace AttributeComparers;
          
      66  static const CaseDefinition::ParameterEntry* findCaseParameter(  const CaseDefinition::ParameterStore& parameters,   const std::string& type )
          {
           for (  CaseDefinition::ParameterStore::const_iterator I = parameters.begin(   ); I != parameters.end(   ); ++I ) {
           if (  I->first == type ) {
           return &(  *I );
           }
           }
           return 0;
          }
          
      76  ModelMappingCreator::ModelMappingCreator(  ModelMappingDefinition* definition,   Eris::Entity* entity,   IActionCreator* actionCreator,   Eris::TypeService* typeService ) : mActionCreator(  actionCreator ),   mEntity(  entity ),   mModelMap(  0 ),   mDefinition(  definition ),   mTypeService(  typeService )
          {
          }
          
          
      81  ModelMappingCreator::~ModelMappingCreator(   )
          {
          }
          
      85  ModelMapping* ModelMappingCreator::create(   )
          {
           return createMapping(   );
          }
          
          
      91  ModelMapping* ModelMappingCreator::createMapping(   ) {
           mModelMap = new ModelMapping(  mEntity );
           addEntityTypeCases(  &mModelMap->getRootEntityMatch(   ),   mDefinition->getRoot(   ) );
          
           ///since we already have the entity,   we can perform a check right away
           mModelMap->getRootEntityMatch(   ).setEntity(  mEntity );
          // mModelMap->getRootEntityMatch(   ).testEntity(  mEntity );
           return mModelMap;
          }
          
     101  void ModelMappingCreator::addEntityTypeCases(  EntityTypeMatch* entityTypeMatch,   MatchDefinition& matchDefinition ) {
           MatchDefinition::CaseStore::iterator endI = matchDefinition.getCases(   ).end(   );
           for (  MatchDefinition::CaseStore::iterator I = matchDefinition.getCases(   ).begin(   ); I != endI; ++I ) {
           if (  mTypeService ) {
           EntityTypeCase* aCase = new EntityTypeCase(   );
          
           for (  CaseDefinition::ParameterStore::iterator J = I->getCaseParameters(   ).begin(   ); J != I->getCaseParameters(   ).end(   ); ++J ) {
           if (  J->first == "equals" ) {
           aCase->addEntityType(  mTypeService->getTypeByName(  J->second ) );
           }
           }
          
          /* const std::string& entityName = I->getProperties(   )["equals"];
           std::vector<std::string> splitNames = ModelMappingManager::splitString(  entityName,   "|",   100 );
           for (  std::vector<std::string>::const_iterator J = splitNames.begin(   ); J != splitNames.end(   ); ++J ) {
           aCase->addEntityType(  mTypeService->getTypeByName(  *J ) );
           }*/
           if (  mActionCreator ) {
           mActionCreator->createActions(  *mModelMap,   aCase,   *I );
           }
          
           CaseDefinition::MatchStore::iterator endJ = I->getMatches(   ).end(   );
           for (  CaseDefinition::MatchStore::iterator J = I->getMatches(   ).begin(   ); J != endJ; ++J ) {
           addMatch(  aCase,   *J );
           }
           entityTypeMatch->addCase(   aCase );
           aCase->setParentMatch(   entityTypeMatch );
           }
           }
          }
          
     132  void ModelMappingCreator::addOutfitCases(  OutfitMatch* match,   MatchDefinition& matchDefinition )
          {
           MatchDefinition::CaseStore::iterator endI = matchDefinition.getCases(   ).end(   );
           for (  MatchDefinition::CaseStore::iterator I = matchDefinition.getCases(   ).begin(   ); I != endI; ++I ) {
           if (  mTypeService ) {
           OutfitCase* aCase = new OutfitCase(   );
          
           for (  CaseDefinition::ParameterStore::iterator J = I->getCaseParameters(   ).begin(   ); J != I->getCaseParameters(   ).end(   ); ++J ) {
           if (  J->first == "equals" ) {
           aCase->addEntityType(  mTypeService->getTypeByName(  J->second ) );
           }
           }
          /* const std::string& entityName = I->getProperties(   )["equals"];
           std::vector<std::string> splitNames = ModelMappingManager::splitString(  entityName,   "|",   100 );
           for (  std::vector<std::string>::const_iterator J = splitNames.begin(   ); J != splitNames.end(   ); ++J ) {
           aCase->addEntityType(  mTypeService->getTypeByName(  *J ) );
           }*/
           if (  mActionCreator ) {
           mActionCreator->createActions(  *mModelMap,   aCase,   *I );
           }
          
           CaseDefinition::MatchStore::iterator endJ = I->getMatches(   ).end(   );
           for (  CaseDefinition::MatchStore::iterator J = I->getMatches(   ).begin(   ); J != endJ; ++J ) {
           addMatch(  aCase,   *J );
           }
           match->addCase(   aCase );
           aCase->setParentMatch(   match );
           }
           }
          }
          
          
     164  Cases::AttributeComparers::AttributeComparerWrapper* ModelMappingCreator::getAttributeCaseComparer(  AttributeMatch* match,   MatchDefinition& matchDefinition,   CaseDefinition& caseDefinition )
          {
           const std::string& matchType = matchDefinition.getProperties(   )["type"];
          
           if (  (  matchType == "" ) || (  matchType == "string" ) ) {
           ///default is string comparison
           if (  const CaseDefinition::ParameterEntry* param = findCaseParameter(  caseDefinition.getCaseParameters(   ),   "equals" ) ) {
           return new AttributeComparers::StringComparerWrapper(  new AttributeComparers::StringComparer(  param->second ) );
           } else {
           return new AttributeComparers::StringComparerWrapper(  new AttributeComparers::StringComparer(  "" ) );
           }
          /*
           const std::string& attributeValue = caseDefinition.getProperties(   )["equals"];
           return new AttributeComparers::StringComparerWrapper(  new AttributeComparers::StringComparer(  attributeValue ) );*/
           } else if (  matchType == "numeric" ) {
           return new AttributeComparers::NumericComparerWrapper(  createNumericComparer(  caseDefinition ) );
           } else if (  matchType == "function" ) {
           if (  match->getAttributeName(   ) == "height" ) {
           return new AttributeComparers::HeightComparerWrapper(  createNumericComparer(  caseDefinition ),   mEntity );
           }
           }
           return 0;
          
          }
          
     189  AttributeComparers::NumericComparer* ModelMappingCreator::createNumericComparer(  CaseDefinition& caseDefinition )
          {
           const CaseDefinition::ParameterEntry* param(  0 );
          
          // DefinitionBase::PropertiesMap::const_iterator value;
          // DefinitionBase::PropertiesMap::const_iterator end = caseDefinition.getProperties(   ).end(   );
          // value = caseDefinition.getProperties(   ).find(  "equals" );
          
           if (  (  param = findCaseParameter(  caseDefinition.getCaseParameters(   ),   "equals" ) ) ) {
           return new AttributeComparers::NumericEqualsComparer(  atof(  param->second.c_str(   ) ) );
           }
          
           ///If both a min and max value is set,   it's a range comparer
           AttributeComparers::NumericComparer *mMin(  0 ),   *mMax(  0 );
           if (  (  param = findCaseParameter(  caseDefinition.getCaseParameters(   ),   "lesser" ) ) ) {
           mMin = new AttributeComparers::NumericLesserComparer(  atof(  param->second.c_str(   ) ) );
           } else if (  (  param = findCaseParameter(  caseDefinition.getCaseParameters(   ),   "lesserequals" ) ) ) {
           mMin = new AttributeComparers::NumericEqualsOrLesserComparer(  atof(  param->second.c_str(   ) ) );
           }
          
           if (  (  param = findCaseParameter(  caseDefinition.getCaseParameters(   ),   "greater" ) ) ) {
           mMax = new AttributeComparers::NumericGreaterComparer(  atof(  param->second.c_str(   ) ) );
           } else if (  (  param = findCaseParameter(  caseDefinition.getCaseParameters(   ),   "greaterequals" ) ) ) {
           mMax = new AttributeComparers::NumericEqualsOrGreaterComparer(  atof(  param->second.c_str(   ) ) );
           }
          
           ///check if we have both min and max set,   and if so we should use a range comparer
           if (  mMin && mMax ) {
           return new AttributeComparers::NumericRangeComparer(  mMin,   mMax );
           } else if (  !mMax && mMin ) {
           return mMin;
           } else if (  mMax && !mMin ) {
           return mMax;
           }
           ///invalid,   could not find anything to compare against
           return 0;
          }
          
          
     228  void ModelMappingCreator::addAttributeCases(  AttributeMatch* match,   MatchDefinition& matchDefinition ) {
           MatchDefinition::CaseStore::iterator endI = matchDefinition.getCases(   ).end(   );
           for (  MatchDefinition::CaseStore::iterator I = matchDefinition.getCases(   ).begin(   ); I != endI; ++I ) {
           Cases::AttributeComparers::AttributeComparerWrapper* wrapper = getAttributeCaseComparer(  match,   matchDefinition,   *I );
           if (  wrapper ) {
           AttributeCase* aCase = new AttributeCase(  wrapper );
          
           if (  mActionCreator ) {
           mActionCreator->createActions(  *mModelMap,   aCase,   *I );
           }
          
           CaseDefinition::MatchStore::iterator endJ = I->getMatches(   ).end(   );
           for (  CaseDefinition::MatchStore::iterator J = I->getMatches(   ).begin(   ); J != endJ; ++J ) {
           addMatch(  aCase,   *J );
           }
           match->addCase(   aCase );
           aCase->setParentMatch(   match );
           }
           }
          
          }
          
     250  void ModelMappingCreator::addMatch(  CaseBase* aCase,   MatchDefinition& matchDefinition ) {
           if (  matchDefinition.getType(   ) == "attribute" ) {
           addAttributeMatch(  aCase,   matchDefinition );
           } else if (  matchDefinition.getType(   ) == "entitytype" ) {
           addEntityTypeMatch(  aCase,   matchDefinition );
           } else if (  matchDefinition.getType(   ) == "outfit" ) {
           addOutfitMatch(  aCase,   matchDefinition );
           }
          }
          
     260  void ModelMappingCreator::addAttributeMatch(  CaseBase* aCase,   MatchDefinition& matchDefinition ) {
           const std::string& attributeName = matchDefinition.getProperties(   )["attribute"];
          
           std::string internalAttributeName(  "" );
           const std::string& matchType = matchDefinition.getProperties(   )["type"];
           ///TODO: make this check better
           if (  matchType == "function" ) {
           if (  attributeName == "height" ) {
           internalAttributeName = "bbox";
           }
           }
           if (  internalAttributeName == "" ) {
           internalAttributeName = attributeName;
           }
          
           AttributeMatch* match = new AttributeMatch(  attributeName,   internalAttributeName );
           aCase->addMatch(   match );
          
           AttributeObserver* observer = new AttributeObserver(  match,   internalAttributeName );
           match->setAttributeObserver(  observer );
          
           addAttributeCases(  match,   matchDefinition );
          
          }
          
     285  void ModelMappingCreator::addEntityTypeMatch(  CaseBase* aCase,   MatchDefinition& matchDefinition ) {
           EntityTypeMatch* match = new EntityTypeMatch(   );
           aCase->addMatch(   match );
           addEntityTypeCases(  match,   matchDefinition );
          
           ///since we already have the entity,   we can perform a check right away
          // match->testEntity(  mEntity );
          }
          
     294  void ModelMappingCreator::addOutfitMatch(  CaseBase* aCase,   MatchDefinition& matchDefinition )
          {
           const std::string& attachmentName = matchDefinition.getProperties(   )["attachment"];
           OutfitMatch* match = new OutfitMatch(  attachmentName,   mEntity->getView(   ) );
           aCase->addMatch(   match );
          
           addOutfitCases(  match,   matchDefinition );
          
          
           ///observe the attribute by the use of an AttributeObserver
           AttributeObserver* observer= new AttributeObserver(  match,   "outfit" );
           match->setAttributeObserver(  observer );
          
           EntityCreationObserver* entityObserver = new EntityCreationObserver(  *match );
           match->setEntityCreationObserver(  entityObserver );
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/ModelMappingCreator.h

       1  //
          // C++ Interface: ModelMappingCreator
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPINGMODELMAPPINGCREATOR_H
          #define EMBEROGRE_MODEL_MAPPINGMODELMAPPINGCREATOR_H
          
          #include "Definitions/ModelMappingDefinition.h"
          namespace Eris
          {
      29  class Entity;
      30  class TypeService;
          }
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          namespace Definitions {
      40  class ModelMappingDefinition;
          }
          
      43  namespace Matches {
          class EntityTypeMatch;
          class AttributeMatch;
          class OutfitMatch;
          }
          namespace Cases {
          
          namespace AttributeComparers {
      51   class NumericComparer;
      52   class AttributeComparerWrapper;
          }
          
          class AttributeCase;
      56  class OutfitCase;
      57  class CaseBase;
          }
      59  class ModelMapping;
      60  class IActionCreator;
          /**
           Creates a ModelMapping instances from the supplied definition.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
          
      67  class ModelMappingCreator
          {
          public:
           /**
           * Default constructor.
           * @param definition The definition to use.
           * @param entity Entity to attach to.
           * @param actionCreator Client supplied action creator.
           * @param typeService A valid typeservice instance.
           */
      77   ModelMappingCreator(   Definitions::ModelMappingDefinition* definition,   Eris::Entity* entity,   IActionCreator* actionCreator,   Eris::TypeService* typeService );
          
      79   ~ModelMappingCreator(   );
          
          
           /**
           * Creates a new ModelMapping instance.
           */
      85   ModelMapping* create(   );
          
          protected:
          
           /**
           Main entry point for mapping creation.
           */
      92   ModelMapping* createMapping(   );
          
           /**
           * Adds EntityTypeCases to the supplied match.
           * @param entityTypeMatch
           * @param matchDefinition
           */
      99   void addEntityTypeCases(  Matches::EntityTypeMatch* entityTypeMatch,   Definitions::MatchDefinition& matchDefinition );
          
           /**
           * Adds AttributeCases to the supplied match.
           * @param match
           * @param matchDefinition
           */
     106   void addAttributeCases(  Matches::AttributeMatch* match,   Definitions::MatchDefinition& matchDefinition );
          
           /**
           * Adds OutfitCases to the supplied match.
           * @param match
           * @param matchDefinition
           */
     113   void addOutfitCases(  Matches::OutfitMatch* match,   Definitions::MatchDefinition& matchDefinition );
          
           /**
           * Adds matches to the supplied case.
           * @param aCase
           * @param matchDefinition
           */
     120   void addMatch(  Cases::CaseBase* aCase,   Definitions::MatchDefinition& matchDefinition );
          
           /**
           * Adds attribute matches to the supplied case.
           * @param aCase
           * @param matchDefinition
           */
     127   void addAttributeMatch(  Cases::CaseBase* aCase,   Definitions::MatchDefinition& matchDefinition );
          
           /**
           * Adds entity type matches to the supplied case.
           * @param aCase
           * @param matchDefinition
           */
     134   void addEntityTypeMatch(  Cases::CaseBase* aCase,   Definitions::MatchDefinition& matchDefinition );
          
           /**
           * Adds outfit matches to the supplied case.
           * @param aCase
           * @param matchDefinition
           */
     141   void addOutfitMatch(  Cases::CaseBase* aCase,   Definitions::MatchDefinition& matchDefinition );
          
           /**
           * Creates and returns a numeric comparer for the supplied case.
           * @param caseDefinition
           */
     147   Cases::AttributeComparers::NumericComparer* createNumericComparer(  Definitions::CaseDefinition& caseDefinition );
          
           /**
           * Creates and returns suitable attribute comparer for the supplied attribute case.
           * @param match
           * @param matchDefinition
           * @param caseDefinition
           * @returns An AttributeComparers::AttributeComparerWrapper instance or null.
           */
     156   Cases::AttributeComparers::AttributeComparerWrapper* getAttributeCaseComparer(  Matches::AttributeMatch* match,   Definitions::MatchDefinition& matchDefinition,   Definitions::CaseDefinition& caseDefinition );
          
     158   IActionCreator* mActionCreator;
     159   Eris::Entity* mEntity;
     160   ModelMapping* mModelMap;
     161   Definitions::ModelMappingDefinition* mDefinition;
     162   Eris::TypeService* mTypeService;
          };
          
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/ModelMappingManager.cpp

       1  //
          // C++ Implementation: ModelMappingManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ModelMappingManager.h"
          
          #include "ModelMappingCreator.h"
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          using namespace Definitions;
          
      34  ModelMappingManager::ModelMappingManager(   )
          : mTypeService(  0 )
          {
          }
          
          
      40  ModelMappingManager::~ModelMappingManager(   )
          {
           for (  ModelMappingDefinitionStore::iterator I = mDefinitions.begin(   ); I != mDefinitions.end(   ); ++I ) {
           delete I->second;
           }
          }
          
          
      48  std::vector<std::string> ModelMappingManager::splitString(   const std::string& str,   const std::string& delims,   unsigned int maxSplits )
          {
           // static unsigned dl;
           std::vector<std::string> ret;
           unsigned int numSplits = 0;
          
           // Use STL methods
           size_t start,   pos;
           start = 0;
           do
           {
           pos = str.find_first_of(  delims,   start );
           if (  pos == start )
           {
           // Do nothing
           start = pos + 1;
           }
           else if (  pos == std::string::npos || (  maxSplits && numSplits == maxSplits ) )
           {
           // Copy the rest of the string
           ret.push_back(   str.substr(  start )  );
           break;
           }
           else
           {
           // Copy up to delimiter
           ret.push_back(   str.substr(  start,   pos - start )  );
           start = pos + 1;
           }
           // parse up to next real data
           start = str.find_first_not_of(  delims,   start );
           ++numSplits;
          
           } while (  pos != std::string::npos );
          
          
          
           return ret;
          }
          
      88  void ModelMappingManager::addDefinition(  ModelMappingDefinition* definition )
          {
           mDefinitions[definition->getName(   )] = definition;
          
           MatchDefinition::CaseStore::iterator endI = definition->getRoot(   ).getCases(   ).end(   );
           for (  MatchDefinition::CaseStore::iterator I = definition->getRoot(   ).getCases(   ).begin(   ); I != endI; ++I ) {
           for (  CaseDefinition::ParameterStore::const_iterator J = I->getCaseParameters(   ).begin(   ); J != I->getCaseParameters(   ).end(   ); ++J ) {
           if (  J->first == "equals" ) {
           mEntityTypeMappings[J->second] = definition;
           }
           }
          /* const std::string& entityName = I->getProperties(   )["equals"];
           std::vector<std::string> splitNames = splitString(  entityName,   "|",   100 );
           for (  std::vector<std::string>::const_iterator I = splitNames.begin(   ); I != splitNames.end(   ); ++I ) {
           mEntityTypeMappings[*I] = definition;
           }*/
           }
          }
          
     107  ModelMappingDefinition* ModelMappingManager::getDefinitionForType(  Eris::TypeInfo* typeInfo ) {
           bool noneThere = false;
           while (  !noneThere ) {
           std::map<std::string,   ModelMappingDefinition*>::iterator I = mEntityTypeMappings.find(  typeInfo->getName(   ) );
           if (  I != mEntityTypeMappings.end(   ) ) {
           return I->second;
           } else {
           if (  typeInfo->getParents(   ).size(   ) == 0 ) {
           noneThere = true;
           } else {
           typeInfo = *(  typeInfo->getParents(   ).begin(   ) );
           }
           }
           }
           return 0;
          }
          
     124  ModelMapping* ModelMappingManager::createMapping(  Eris::Entity* entity,   IActionCreator* actionCreator ) {
           Eris::TypeInfo* type = entity->getType(   );
           ModelMappingDefinition* definition = getDefinitionForType(  type );
           if (  definition ) {
           ModelMappingCreator creator(  definition,   entity,   actionCreator,   mTypeService );
           return creator.create(   );
           }
           return 0;
          }
          
          }
          
          }
          
          }

./components/ogre/model/mapping/ModelMappingManager.h

       1  //
          // C++ Interface: ModelMappingManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPINGMODELMAPPINGMANAGER_H
          #define EMBEROGRE_MODEL_MAPPINGMODELMAPPINGMANAGER_H
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          
          #include <vector>
          #include <map>
          
          //#include <Atlas/Objects/Entity.h>
          
          //#include <sigc++/trackable.h>
          
          
          
          #include <Eris/TypeInfo.h>
          #include <Eris/Entity.h>
          
          #include "Definitions/ModelMappingDefinition.h"
          #include "ModelMapping.h"
          
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
      53  class ModelMapping;
      54  class IActionCreator;
          
          
          
          /**
           Handles all ModelMapping instances,   as well as creation and setup.
          
           Applications are expected to add definitions to the manager through the addDefinition(  ... ) method. Definitions are managed by the manager and will be deleted by this upon destruction.
           New ModelMapping instances are created by calling createMapping(  ... ). It's up to the application to delete all ModelMapping instances created by the manager.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      66  class ModelMappingManager{
          public:
           typedef std::map<std::string,   Definitions::ModelMappingDefinition*> ModelMappingDefinitionStore;
          
           /**
           Default constructor.
           */
      73   ModelMappingManager(   );
          
      75   ~ModelMappingManager(   );
          
           /**
           Sets the type service. Applications are required to set this before calling createMapping(  ... )
           @param typeService An Eris::TypeService instance.
           */
      81   inline void setTypeService(  Eris::TypeService* typeService );
          
           /**
           Adds a definition to the manager. This definition will be deleted by the manager upon destruction.
           @param definition A valid definition.
           */
      87   void addDefinition(  Definitions::ModelMappingDefinition* definition );
          
          
           /**
           Queries the internal list of definitions and return the defintion that's most suited for the supplied type.
           @param typeInfo An eris type info instance.
           */
      94   Definitions::ModelMappingDefinition* getDefinitionForType(  Eris::TypeInfo* typeInfo );
          
           /**
           Creates a new ModelMapping instance. This will not be handled by the manager and needs to be deleted by the application when suitable.
           Remember to call ModelMapping::initialize(  ... ).
           @param entity An eris type info instance.
           @param actionCreator An eris type info instance.
           */
     102   ModelMapping* createMapping(  Eris::Entity* entity,   IActionCreator* actionCreator );
          
           /**
           * Utility method for splitting a string into a vector of strings
           * @param str The original string.
           * @param delims A delimiter
           * @param maxSplits Maximum number of splits to return.
           * @return A vector of strings.
           */
     111   static std::vector<std::string> splitString(   const std::string& str,   const std::string& delims,   unsigned int maxSplits = 300 );
          
          protected:
          
          
          
     117   ModelMappingDefinitionStore mDefinitions;
          
     119   ModelMappingDefinitionStore mEntityTypeMappings;
          
     121   Eris::TypeService* mTypeService;
          
          };
          
     125  void ModelMappingManager::setTypeService(  Eris::TypeService* typeService )
          {
           mTypeService = typeService;
          }
          
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/model/mapping/XMLModelMappingDefinitionSerializer.cpp

       1  //
          // C++ Implementation: XMLModelMappingDefinitionSerializer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "XMLModelMappingDefinitionSerializer.h"
          //#include "components/ogre/EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          using namespace Definitions;
          
      34  XMLModelMappingDefinitionSerializer::XMLModelMappingDefinitionSerializer(  EmberOgre::Model::Mapping::ModelMappingManager& modelMappingManager )
          : mModelMappingManager(  modelMappingManager )
          {
          }
          
          
      40  XMLModelMappingDefinitionSerializer::~XMLModelMappingDefinitionSerializer(   )
          {
          }
          
      44  void XMLModelMappingDefinitionSerializer::parseScript(  Ember::TiXmlDocument& xmlDocument )
          {
          
           Ember::TiXmlElement* rootElem = xmlDocument.RootElement(   );
          
           for (  Ember::TiXmlElement* smElem = rootElem->FirstChildElement(  "modelmapping" );
           smElem != 0; smElem = smElem->NextSiblingElement(  "modelmapping" ) )
           {
           const char* tmp = smElem->Attribute(  "name" );
           std::string name;
           if (  !tmp ) {
           continue;
           } else {
           name = tmp;
           }
          
           try {
           ModelMappingDefinition* definition = new ModelMappingDefinition(   );
           definition->setName(  name );
           Ember::TiXmlElement* matchElement = smElem->FirstChildElement(   );
           parseMatchElement(  *definition,   definition->getRoot(   ),   matchElement );
           mModelMappingManager.addDefinition(  definition );
           } catch (  std::exception ex ) {
           //S_LOG_FAILURE(  ex.what(   ) );
           } catch (  ... ) {
           //S_LOG_FAILURE(  "Error when reading model mapping with name " << name );
           }
           }
          
           ///Check for automodelmapping elements,   which allow for a quick mapping between a entity type and a model.
           ///format: <automodelmapping name="oak">
           ///or: <automodelmapping name="oak" modelname="oak_1">
           for (  Ember::TiXmlElement* smElem = rootElem->FirstChildElement(  "automodelmapping" );
           smElem != 0; smElem = smElem->NextSiblingElement(  "automodelmapping" ) )
           {
           const char* tmp = smElem->Attribute(  "name" );
           std::string name;
           if (  !tmp ) {
           continue;
           } else {
           name = tmp;
           }
          
           try {
           ModelMappingDefinition* definition = new ModelMappingDefinition(   );
           definition->setName(  name );
           definition->getRoot(   ).setType(  "entitytype" );
           CaseDefinition caseDef;
           caseDef.setType(  "entitytypecase" );
           caseDef.getCaseParameters(   ).push_back(  CaseDefinition::ParameterEntry(  "equals",   name ) );
           ActionDefinition actionDef;
           actionDef.setType(  "display-model" );
          
           ///check if a model name is set
           const char* tmpModelName = smElem->Attribute(  "modelname" );
           if (  tmpModelName ) {
           actionDef.setValue(  std::string(  tmpModelName ) );
           } else {
           actionDef.setValue(  name );
           }
          
           caseDef.getActions(   ).push_back(  actionDef );
           definition->getRoot(   ).getCases(   ).push_back(  caseDef );
          
           mModelMappingManager.addDefinition(  definition );
           } catch (  std::exception ex ) {
           //S_LOG_FAILURE(  ex.what(   ) );
           } catch (  ... ) {
           //S_LOG_FAILURE(  "Error when reading model mapping with name " << name );
           }
           }
          }
          
     117  void XMLModelMappingDefinitionSerializer::parseMatchElement(  ModelMappingDefinition& definition,   MatchDefinition& matchDef,   Ember::TiXmlElement* element )
          {
           std::string caseType(  "" );
           if (  std::string(  element->Value(   ) ) == std::string(  "entitymatch" ) ) {
           matchDef.setType(  "entitytype" );
           caseType = "entitytypecase";
           } else if (  std::string(  element->Value(   ) ) == std::string(  "attributematch" ) ) {
           matchDef.setType(  "attribute" );
           caseType = "attributecase";
          
          /* const char* tmp = smElem->Attribute(  "attribute" );
           matchDef.getProperties(   )["attribute"] = std::string(  tmp );*/
           } else if (  std::string(  element->Value(   ) ) == std::string(  "outfitmatch" ) ) {
           matchDef.setType(  "outfit" );
           caseType = "outfitcase";
           }
          
           for (  Ember::TiXmlAttribute* attribute = element->FirstAttribute(   );
           attribute != 0; attribute = attribute->Next(   ) )
           {
           matchDef.getProperties(   )[attribute->Name(   )] = attribute->Value(   );
           }
          
           if (  !element->NoChildren(   ) ) {
           for (  Ember::TiXmlElement* childElement = element->FirstChildElement(   );
           childElement != 0; childElement = childElement->NextSiblingElement(   ) )
           {
           CaseDefinition caseDef;
           caseDef.setType(  caseType );
           parseCaseElement(  definition,   caseDef,   childElement );
           matchDef.getCases(   ).push_back(  caseDef );
           }
           }
          }
          
     152  void XMLModelMappingDefinitionSerializer::parseCaseElement(  ModelMappingDefinition& definition,   CaseDefinition& caseDef,   Ember::TiXmlElement* element )
          {
           for (  Ember::TiXmlAttribute* attribute = element->FirstAttribute(   );
           attribute != 0; attribute = attribute->Next(   ) )
           {
           caseDef.getProperties(   )[attribute->Name(   )] = attribute->Value(   );
           }
          
          
           if (  !element->NoChildren(   ) ) {
           for (  Ember::TiXmlElement* childElement = element->FirstChildElement(   );
           childElement != 0; childElement = childElement->NextSiblingElement(   ) )
           {
           if (  std::string(  childElement->Value(   ) ) == std::string(  "action" ) ) {
           ActionDefinition actionDef;
           parseActionElement(  definition,   actionDef,   childElement );
           caseDef.getActions(   ).push_back(  actionDef );
           } else if (  std::string(  childElement->Value(   ) ) == std::string(  "caseparam" ) ){
           ///it's a case parameter
           if (  const char* attributeValue = childElement->Attribute(  "type" ) ) {
           if (  Ember::TiXmlNode* textNode = childElement->FirstChild(   ) ) {
           std::string type(  attributeValue );
           std::string value(  textNode->Value(   ) );
           caseDef.getCaseParameters(   ).push_back(  std::pair<std::string,   std::string>(  type,   value ) );
           }
           }
           } else {
           ///we'll assume it's a match
           MatchDefinition matchDef;
           parseMatchElement(  definition,   matchDef,   childElement );
           caseDef.getMatches(   ).push_back(  matchDef );
           }
           }
           }
          }
          
     188  void XMLModelMappingDefinitionSerializer::parseActionElement(  ModelMappingDefinition& definition,   ActionDefinition& actionDef,   Ember::TiXmlElement* element )
          {
           for (  Ember::TiXmlAttribute* attribute = element->FirstAttribute(   );
           attribute != 0; attribute = attribute->Next(   ) )
           {
           actionDef.getProperties(   )[attribute->Name(   )] = attribute->Value(   );
           }
           actionDef.setType(  element->Attribute(  "type"  ) );
           Ember::TiXmlNode* textNode = element->FirstChild(   );
           if (  textNode ) {
           actionDef.setValue(  textNode->Value(   ) );
           }
          
          }
          }
          
          }
          
          }

./components/ogre/model/mapping/XMLModelMappingDefinitionSerializer.h

       1  //
          // C++ Interface: XMLModelMappingDefinitionSerializer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_MODEL_MAPPINGXMLMODELMAPPINGDEFINITIONSERIALIZER_H
          #define EMBEROGRE_MODEL_MAPPINGXMLMODELMAPPINGDEFINITIONSERIALIZER_H
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          #include "framework/tinyxml/tinyxml.h"
          #include "Definitions/ModelMappingDefinition.h"
          #include "ModelMappingManager.h"
          
          #include <vector>
          
          namespace EmberOgre {
          
          namespace Model {
          
          namespace Mapping {
          
          /**
           Serialized model definitions from xml files.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      45  class XMLModelMappingDefinitionSerializer{
          public:
      47   XMLModelMappingDefinitionSerializer(  ModelMappingManager& modelMappingManager );
          
      49   ~XMLModelMappingDefinitionSerializer(   );
          
           /**
           Parse the xml document and create definitions from the data.
           @param xmlDocument A valid xml document instance.
           */
      55   void parseScript(  Ember::TiXmlDocument& xmlDocument );
          protected:
      57   void parseMatchElement(  Definitions::ModelMappingDefinition& definition,   Definitions::MatchDefinition& matchDef,   Ember::TiXmlElement* element );
      58   void parseCaseElement(  Definitions::ModelMappingDefinition& definition,   Definitions::CaseDefinition& caseDef,   Ember::TiXmlElement* element );
      59   void parseActionElement(  Definitions::ModelMappingDefinition& definition,   Definitions::ActionDefinition& actionDef,   Ember::TiXmlElement* element );
          
      61   ModelMappingManager& mModelMappingManager;
          
          
          };
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/ogreopcode/include/BP_Endpoint.h

       1  /*
          * SOLID - Software Library for Interference Detection
          * Copyright (  c ) 2001 Dtecta <gino@dtecta.com>
          *
          * All rights reserved.
          */
          
          #ifndef BP_ENDPOINT_H
          #define BP_ENDPOINT_H
          
          #include "GEN_List.h"
          //#include "MT_Scalar.h"
          
          namespace OgreOpcode
          {
           namespace Details
           {
          
      19   class BP_Scene;
      20   class BP_Proxy;
          
           typedef bool (  *T_Overlap )(  const BP_Proxy&,   const BP_Proxy& );
          
      24   class BP_Endpoint : public GEN_Link {
           public:
           enum Type { MINIMUM,   MAXIMUM };
          
      28   BP_Endpoint(   ) : m_proxy(  0 ) {}
      29   BP_Endpoint(  Ogre::Real pos,   Type type,   BP_Proxy *proxy,  
      30   GEN_List& endpointList );
      31   ~BP_Endpoint(   );
          
      33   Ogre::Real getPos(   ) const { return m_pos; }
      34   void setPos(  Ogre::Real pos ) { m_pos = pos; }
          
      36   void move(  Ogre::Real x,   BP_Scene& scene,   T_Overlap );
          
      38   friend void encounters(  const BP_Endpoint& a,   const BP_Endpoint& b,  
      39   BP_Scene& scene,   T_Overlap overlap );
          
      41   friend bool operator<(  const BP_Endpoint& a,   const BP_Endpoint& b );
          
           private:
      44   Ogre::Real m_pos;
           Type m_type;
      46   BP_Proxy *m_proxy;
          
      48   inline int MT_sign(  Ogre::Real x )
           {
           return x < Ogre::Real(  0.0 ) ? -1 : x > Ogre::Real(  0.0 ) ? 1 : 0;
           }
           };
          
      54   inline bool operator<(  const BP_Endpoint& a,   const BP_Endpoint& b ) {
           return a.m_pos < b.m_pos || (  a.m_pos == b.m_pos && a.m_type < b.m_type );
           }
          
           }
          }
          
          #endif

./components/ogre/ogreopcode/include/BP_Proxy.h

       1  /*
          * SOLID - Software Library for Interference Detection
          * Copyright (  c ) 2001 Dtecta <gino@dtecta.com>
          *
          * All rights reserved.
          */
          
          #ifndef BP_PROXY_H
          #define BP_PROXY_H
          
          #include "BP_Endpoint.h"
          namespace OgreOpcode
          {
           namespace Details
           {
          
      17   class BP_Scene;
          
      19   class BP_Proxy {
           public:
      21   BP_Proxy(  void *object,  
      22   BP_Scene& scene,  
      23   const Ogre::Vector3& min,  
      24   const Ogre::Vector3& max );
          
      26   void setBBox(  const Ogre::Vector3& min,   const Ogre::Vector3& max );
          
      28   void *getObject(   ) { return m_object; }
          
      30   Ogre::Real getMin(  int i ) const { return m_min[i].getPos(   ); }
      31   Ogre::Real getMax(  int i ) const { return m_max[i].getPos(   ); }
          
           private:
           void *m_object;
      35   BP_Scene& m_scene;
      36   BP_Endpoint m_min[3];
      37   BP_Endpoint m_max[3];
           };
          
      40   inline bool BP_overlap(  const BP_Proxy& a,   const BP_Proxy& b )
           {
           return a.getMin(  0 ) <= b.getMax(  0 ) && b.getMin(  0 ) <= a.getMax(  0 ) &&
           a.getMin(  1 ) <= b.getMax(  1 ) && b.getMin(  1 ) <= a.getMax(  1 ) &&
           a.getMin(  2 ) <= b.getMax(  2 ) && b.getMin(  2 ) <= a.getMax(  2 );
           }
          
           }
          }
          
          #endif

./components/ogre/ogreopcode/include/BP_Scene.h

       1  /*
          * SOLID - Software Library for Interference Detection
          * Copyright (  c ) 2001 Dtecta <gino@dtecta.com>
          *
          * All rights reserved.
          */
          
          #ifndef BP_SCENE_H
          #define BP_SCENE_H
          
          #include <vector>
          
          #include "OgreBroadPhase.h"
          #include "GEN_List.h"
          namespace OgreOpcode
          {
           namespace Details
           {
          
      20   class BP_Proxy;
      21   class Ogre::Vector3;
          
      23   class BP_Scene {
           public:
      25   BP_Scene(  void *client_data,  
      26   BP_Callback beginOverlap,  
      27   BP_Callback endOverlap ) :
           m_client_data(  client_data ),  
           m_beginOverlap(  beginOverlap ),  
           m_endOverlap(  endOverlap ) {}
          
      32   ~BP_Scene(   );
          
      34   BP_Proxy *createProxy(  void *object,  
      35   const Ogre::Vector3& min,  
      36   const Ogre::Vector3& max );
          
      38   void deleteProxy(  BP_Proxy *proxy );
          
      40   void callBeginOverlap(  void *object1,   void *object2 ) {
           m_beginOverlap(  m_client_data,   object1,   object2 );
           }
          
      44   void callEndOverlap(  void *object1,   void *object2 ) {
           m_endOverlap(  m_client_data,   object1,   object2 );
           }
          
      48   GEN_List *getLists(   ) { return m_endpointList; }
          
           private:
           typedef std::vector<BP_Proxy *> T_ProxyList;
          
           void *m_client_data;
      54   BP_Callback m_beginOverlap;
      55   BP_Callback m_endOverlap;
      56   T_ProxyList m_proxyList;
      57   GEN_List m_endpointList[3];
           };
           }
          }
          
          #endif
          
          
          
          
          
          
          

./components/ogre/ogreopcode/include/GEN_List.h

          /*
          SOLID - Software Library for Interference Detection
          Copyright (  C ) 1997-1998 Gino van den Bergen
          
          This library is free software; you can redistribute it and/or
          modify it under the terms of the GNU Library General Public
          License as published by the Free Software Foundation; either
          version 2 of the License,   or (  at your option ) any later version.
          
          This library is distributed in the hope that it will be useful,  
          but WITHOUT ANY WARRANTY; without even the implied warranty of
          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          Library General Public License for more details.
          
          You should have received a copy of the GNU Library General Public
          License along with this library; if not,   write to the Free
          Software Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          
          Please send remarks,   questions and bug reports to gino@win.tue.nl,  
          or write to:
          Gino van den Bergen
          Department of Mathematics and Computing Science
          Eindhoven University of Technology
          P.O. Box 513,   5600 MB Eindhoven,   The Netherlands
          */
          
          #ifndef GEN_LIST_H
          #define GEN_LIST_H
          
          #include <Ogre.h>
          
          namespace OgreOpcode
          {
           namespace Details
           {
          
      37   class GEN_Link {
           public:
      39   GEN_Link(   ) : m_next(  0 ),   m_prev(  0 ) {}
      40   GEN_Link(  GEN_Link *next,   GEN_Link *prev ) : m_next(  next ),   m_prev(  prev ) {}
          
      42   GEN_Link *getNext(   ) const { return m_next; }
      43   GEN_Link *getPrev(   ) const { return m_prev; }
          
      45   bool isHead(   ) const { return m_prev == 0; }
      46   bool isTail(   ) const { return m_next == 0; }
          
      48   void attachBefore(  GEN_Link *link ) {
           m_next = link;
           link->m_prev = this;
           }
          
      53   void attachAfter(  GEN_Link *link ) {
           m_prev = link;
           link->m_next = this;
           }
          
      58   void insertBefore(  GEN_Link *link ) {
           attachAfter(  link->m_prev );
           attachBefore(  link );
           }
          
      63   void insertAfter(  GEN_Link *link ) {
           attachBefore(  link->m_next );
           attachAfter(  link );
           }
          
      68   void remove(   ) {
           m_next->m_prev = m_prev;
           m_prev->m_next = m_next;
           m_next = m_prev = 0;
           }
          
           private:
           GEN_Link *m_next;
           GEN_Link *m_prev;
           };
          
          
      80   class GEN_List {
           public:
           GEN_List(   ) : m_head(  &m_tail,   0 ),   m_tail(  0,   &m_head ) {}
          
      84   GEN_Link *getHead(   ) const { return m_head.getNext(   ); }
      85   GEN_Link *getTail(   ) const { return m_tail.getPrev(   ); }
          
      87   void clear(   ) { m_head.attachBefore(  &m_tail ); }
          
      89   void addHead(  GEN_Link *link ) { link->insertAfter(  &m_head ); }
      90   void addTail(  GEN_Link *link ) { link->insertBefore(  &m_tail ); }
          
      92   void appendHead(  GEN_List& list ) {
           list.getTail(   )->attachBefore(  getHead(   ) );
           list.getHead(   )->attachAfter(  &m_head );
           list.clear(   );
           }
          
      98   void appendTail(  GEN_List& list ) {
           list.getHead(   )->attachAfter(  getTail(   ) );
           list.getTail(   )->attachBefore(  &m_tail );
           list.clear(   );
           }
          
     104   bool isEmpty(   ) const { return getHead(   )->isTail(   ); }
          
           private:
           GEN_Link m_head;
           GEN_Link m_tail;
           };
          
           }
          }
          
          #endif
          
          
          

./components/ogre/ogreopcode/include/IOgreCollisionShape.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file IOgreCollisionShape.h
          /// @brief Abstract base class for collision shapes
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __IOgreCollisionShape_h__
          # define __IOgreCollisionShape_h__
          
          # include <Ogre.h>
          
          #include "OgreOpcodeExports.h"
          
          #include "OgreCollisionTypes.h"
          #include "OgreOpcodeDebugObject.h"
          #include "Opcode/Opcode.h"
          #include "OgreOpcodeMath.h"
          #include "OgreCollisionReporter.h"
          
          namespace OgreOpcode
          {
      43   class CollisionPair;
          
           /// Describes shapes for collision system.
           /// Holds a triangle list describing a collision shape.
           class _OgreOpcode_Export ICollisionShape
           {
           public:
           /// Constructs a ICollisionShape
      51   ICollisionShape(  const Ogre::String& name );
           virtual ~ICollisionShape(   );
          
           void update(  Ogre::Real dt );
          
           /// visualize the collide shape
           virtual void visualize(  Details::OgreOpcodeDebugger* activeDebugger );
           /// Clear visualization buffer
           virtual void clearViz(   )
           {
           mDebugObject->clear(   );
           }
          
           virtual void setStatic(  bool newstatic = true )
           {
           mShapeIsStatic = newstatic;
           }
           /// visualise OPCODE AABB tree
           virtual void visualizeAABBs(  Details::OgreOpcodeDebugger* activeDebugger );
           /// return current center in world space
           virtual Ogre::Vector3& getCenter(   );
           /// return current center in object space
           virtual Ogre::Vector3& getLocalCenter(   );
           /// returns the name of the shape
           virtual Ogre::String& getName(   );
           /// get radius of collide mesh
           virtual Ogre::Real& getRadius(   );
           /// return the full transformation matrix
           virtual Ogre::Matrix4 getFullTransform(  void ) const;
           /// return the local transformation matrix
           virtual Ogre::Matrix4& getLocalTransform(  void ) const;
           ///
           virtual void setTransform(  const Ogre::Matrix4 newTransform );
           /// returns the scenenode which this shape is attached to
           virtual Ogre::SceneNode* getParentSceneNode(  void ) const;
          
           ///// returns the IceMaths::AABB used for pruning
           //virtual IceMaths::AABB* getIceABB(  void ) const;
          
           /// is this shape a static?
           virtual const bool isStatic(   ) const
           {
           return mShapeIsStatic;
           };
          
           /// Retrieve current vertex data from mesh and refit collision tree.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           virtual bool refit(   ) { return true; };
           int getRefitRate(   );
           void setRefitRate(  unsigned int NumFramesPerRefit );
           /// return current world space AABB min and max
           virtual void getMinMax(  Ogre::Vector3& bMin,   Ogre::Vector3& bMax ) const;
           /// return current object space AABB min and max
           virtual void getLocalMinMax(  Ogre::Vector3& bMin,   Ogre::Vector3& bMax ) const;
           /// perform collision with other ICollisionShape
           virtual bool collide(  CollisionType collType,   Ogre::Matrix4& ownMatrix,   ICollisionShape* otherShape,   Ogre::Matrix4& otherMatrix,   CollisionPair& collPair );
           /// perform collision with line
           virtual bool rayCheck(  CollisionType collType,   const Ogre::Matrix4& ownMatrix,   const Ogre::Ray& line,   const Ogre::Real dist,   CollisionPair& collPair,   bool rayCulling );
           /// perform a sphere check
           virtual bool sphereCheck(  CollisionType collType,   const Ogre::Matrix4& ownMatrix,   const Ogre::Sphere& ball,   CollisionPair& collPair );
           /// perform a swept sphere check
           virtual bool sweptSphereCheck(  CollisionType collType,   const Ogre::Matrix4& ownMatrix,   const Ogre::Vector3& position,   const Ogre::Vector3& movementVector,   const Ogre::Real& radius,   CollisionPair& collPair );
           /// get tri coords from tri index
           virtual void getTriCoords(  size_t index,   Ogre::Vector3& v0,   Ogre::Vector3& v1,   Ogre::Vector3& v2 );
          
           /////////////////////////////////////////
           // DAVE:
           inline bool getLowestRoot(  Ogre::Real a,   Ogre::Real b,   Ogre::Real c,   Ogre::Real maxR,   Ogre::Real* root );
           void sphereEdgeCheck(  Ogre::Vector3 &velocity,   Ogre::Vector3 &edge,   Ogre::Vector3 &baseToVertex,   Ogre::Real &t,   bool &foundCollision,   Ogre::Vector3 &collisionPoint,   Ogre::Vector3 &pnt );
           bool testTriangleIntersection(  Ogre::Vector3 position,   Ogre::Vector3 movementVector,   Ogre::Real radius,   Ogre::Vector3 v0,   Ogre::Vector3 v1,   Ogre::Vector3 v2,   CollisionPair *cp );
          
           Opcode::Model opcModel;
          
           ///// calculate SAP AABB
           //virtual void computeIceABB(   );
          
           protected:
          
           /// has object been initialized?
           virtual bool isInitialized(   );
           /// visualize the AABBTree of the opcode model
           virtual void visualizeAABBCollisionNode(  const Opcode::AABBCollisionNode* node );
           /// visualize the AABBTree of the opcode model (  for no leaf trees )
           virtual void visualizeAABBNoLeafNode(  const Opcode::AABBNoLeafNode* node );
           /// prepare OPCODE parameters
           virtual void _prepareOpcodeCreateParams(  Opcode::OPCODECREATE& opcc );
           /// calculates the shape radius
           virtual void calculateSize(   );
          
           Opcode::BVTCache* opcTreeCache; ///<
           Opcode::CollisionFaces* opcFaceCache; ///<
           Opcode::MeshInterface opcMeshAccess; ///<
           size_t numVertices; ///<
           size_t numFaces; ///<
           float* mVertexBuf; ///<
           size_t* mFaceBuf; ///<
           Ogre::Real mRadius; ///<
           Ogre::SceneNode* mParentNode; ///<
           Ogre::String mName; ///<
           bool mInitialized; ///<
           bool mShapeIsStatic; ///<
           bool mHasCostumTransform; ///<
           bool mDoVisualizeAABBNodes; ///<
           int refCount; ///<
           mutable Ogre::Matrix4 mFullTransform; ///<
           mutable Ogre::Matrix4 mLocalTransform; ///<
           //IceMaths::AABB* mIceABB; ///<
           Ogre::Vector3 mCenter; ///<
           Ogre::Vector3 mLocalCenter; ///<
           Details::OgreOpcodeDebugger* mActiveDebugger;
           Ogre::ManualObject* mDebugObject;
          
           int mNumFramesPerRefit;
           int mRefitCounter;
           };
           inline
           bool
           ICollisionShape::isInitialized(   )
           {
           return mInitialized;
           }
          
           inline Ogre::SceneNode* ICollisionShape::getParentSceneNode(  void ) const
           {
           return mParentNode;
           }
          
           inline
           Ogre::Real&
           ICollisionShape::getRadius(   )
           {
           return mRadius;
           }
          
           /// Extract triangle coordinates from triangle index.
           inline
           void
           ICollisionShape::getTriCoords(  size_t index,   Ogre::Vector3& v0,   Ogre::Vector3& v1,   Ogre::Vector3& v2 )
           {
           size_t* indexPtr = &(  mFaceBuf[3 * index] );
           float* vp0 = &(  mVertexBuf[3 * indexPtr[0]] );
           float* vp1 = &(  mVertexBuf[3 * indexPtr[1]] );
           float* vp2 = &(  mVertexBuf[3 * indexPtr[2]] );
           v0 = Ogre::Vector3(  vp0[0],   vp0[1],   vp0[2] );
           v1 = Ogre::Vector3(  vp1[0],   vp1[1],   vp1[2] );
           v2 = Ogre::Vector3(  vp2[0],   vp2[1],   vp2[2] );
           }
          }; // namespace OgreOpcode
          
          #endif // __IOgreCollisionShape_h__

./components/ogre/ogreopcode/include/OgreBoxCollisionShape.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreBoxCollisionShape.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreBoxCollisionShape_h__
          # define __OgreBoxCollisionShape_h__
          
          #include "OgreOpcodeExports.h"
          # include <Ogre.h>
          
          #include "IOgreCollisionShape.h"
          #include "OgreCollisionTypes.h"
          #include "OgreOpcodeDebugObject.h"
          #include "Opcode/Opcode.h"
          
          namespace OgreOpcode
          {
      41   class CollisionPair;
          
           /// Describes shapes for collision system.
           /// Holds a triangle list describing a collision shape.
           /// One BoxCollisionShape object may be shared between several
           /// CollisionObject%s. 2 BoxCollisionShape objects may also
           /// be queried directly whether they intersect.
           ///
           /// BoxCollisionShape objects are also able to load themselves
           /// from a mesh file.
           class _OgreOpcode_Export BoxCollisionShape : public ICollisionShape
           {
           public:
           /// Constructs a BoxCollisionShape
      55   BoxCollisionShape(  const Ogre::String& name );
           virtual ~BoxCollisionShape(   );
          
           /// load collide geometry from mesh,   and build a collision tree
           virtual bool load(  Ogre::SceneNode* scnNode,   int height,   int width,   int depth );
          
           protected:
           virtual void _prepareOpcodeCreateParams(  Opcode::OPCODECREATE& opcc );
          
           private:
           /// prevent default construction
           BoxCollisionShape(   );
          
           };
          
          }; // namespace OgreOpcode
          
          #endif // __OgreBoxCollisionShape_h__

./components/ogre/ogreopcode/include/OgreBroadPhase.h

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreBroadPhase.h
          /// @brief
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreBroadPhase_h__
          #define __OgreBroadPhase_h__
          
          namespace OgreOpcode
          {
           namespace Details
           {
           typedef void (  *BP_Callback )(  void *client_data,   void *object1,   void *object2 );
           }
          }
          
          #endif // __OgreBroadPhase_h__

./components/ogre/ogreopcode/include/OgreCapsule.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCapsule.h
          /// @brief This class represents a Capsule,   which is defined by 2 endpoints and a radius.
          /// You can interpret it as a sphere that is sweept along a line.
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOpcodeCapsule_h__
          #define __OgreOpcodeCapsule_h__
          
          #include "OgreOpcodeLine.h"
          
          namespace OgreOpcode
          {
           namespace Details
           {
           /// Represents a Capsule defined by 2 endpoints and a radius
           /// TODO: add methods to this capsule.
           class _OgreOpcode_Export Capsule
           {
           public:
          
           /** Default constructor: degenerated as an unitary sphere at origin
           */
      46   Capsule(   ):start(   ),  end(   ),  radius(  1.0 )
           {
           }
          
           /** Copy-constructor
           */
      52   Capsule(  const Capsule& c ):start(  c.start ),  end(  c.end ),  radius(  c.radius )
           {
           }
          
           /** Complete constructor
           */
      58   Capsule(  const Ogre::Vector3& s,   const Ogre::Vector3& e,   Ogre::Real r  ):start(  s ),  end(  e ),  radius(  r )
           {
           }
          
           /** Complete,   headache constructor
           */
      64   Capsule(   Ogre::Real sx,   Ogre::Real sy,   Ogre::Real sz,  
           Ogre::Real ex,   Ogre::Real ey,   Ogre::Real ez,  
           Ogre::Real r
            ):start(  sx,  sy,  sz ),  end(  ex,  ey,  ez ),  radius(  r )
           {
           }
          
           /// Gets the length of this line segment
      72   Ogre::Real length(   ) const { return (  start - end ).length(   ); }
           /// Gets the squared length of this line segment
      74   Ogre::Real length2(   ) const { return (  start - end ).squaredLength(   ); }
          
           /// Gets the surface area of this capsule
      77   Ogre::Real area(   ) const
           {
           return Ogre::Math::TWO_PI*radius*(  2.0*radius + length(   )  );
           }
          
           /// Gets the volume are this capsule
      83   Ogre::Real volume(   ) const
           {
           return Ogre::Math::PI*radius*radius*(   1.333333333333333*length(   )  );
           }
          // --------------------------------------------------------------------
          // intersection tests
          
           /** Does this capsule contain the given point?
           */
      92   bool contains(   const Ogre::Vector3& point  ) const;
          
           /** Tests intersection between this capsule and the given Axis-Aligned
           * Bounding Box
           */
      97   bool intersects(   const Aabb& aabb  ) const;
          
           /** Tests intersection between this capsule and the given sphere
           */
     101   bool intersects(   const sphere& s  ) const;
          
           /** Tests intersection between this capsule and the given Oriented Bounding Box
           */
     105   bool intersects(   const OrientedBox& obb  ) const;
          
           /** Tests intersection between this capsule and the given one
           */
     109   bool intersects(   const Capsule& cap  ) const;
          
          
           /** The start point of this capsule.
           */
           Ogre::Vector3 start;
           /** The end point of this capsule.
           */
           Ogre::Vector3 end;
           /** The radius of this capsule.
           */
           Ogre::Real radius;
           };
           }
          }
          
          #endif

./components/ogre/ogreopcode/include/OgreCollisionContext.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCollisionContext.h
          /// @brief Contains the definition of the CollisionContext class.
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreCollisionContext_h__
          #define __OgreCollisionContext_h__
          
          #include <Ogre.h>
          #include "OgreNodes.h"
          #include "OgreCollisionReporter.h"
          #include "OgreCollisionTypes.h"
          #include "OgreOpcodeDebugObject.h"
          //#include "BP_Scene.h"
          #include "Opcode/Opcode.h"
          
          namespace OgreOpcode
          {
      41   class CollisionObject;
          
           namespace Details
           {
           typedef int CollisionClass;
          
      47   class BP_Scene;
          
      49   class Encounter
           {
           public:
      52   CollisionObject* obj1;
      53   CollisionObject* obj2;
          
      55   Encounter(  CollisionObject* o1,   CollisionObject* o2 )
           {
           obj1 = o2;
           obj2 = o1;
           }
           };
          
      62   inline bool operator<(  const Encounter& x,   const Encounter& y )
           {
           return x.obj1 < y.obj1 || (  !(  y.obj1 < x.obj1 ) && x.obj2 < y.obj2 );
           }
          
           };
          
           /// Defines a collision space.
           /// A CollisionContext creates a collision context,   defined by
           /// a collection of CollisionObject%s which can collide with
           /// each other. CollisionObject%s can be added and removed
           /// from the context at any time.
           // class _OgreOpcode_Export CollisionContext : public nNode
           class _OgreOpcode_Export CollisionContext
           {
           public:
           /// constructor
      79   CollisionContext(  const Ogre::String& name );
           /// destructor
           virtual ~CollisionContext(   );
           /// create a collide object
           virtual CollisionObject *createObject(  const Ogre::String& name );
           /// kills a collide object
           virtual void destroyObject(  CollisionObject *collObj );
           /// add collide object to context
           virtual void addObject(  CollisionObject *collObj );
           /// remove collide object from context
           virtual void removeObject(  CollisionObject *collObj );
           /// compute contacts between collision objects in context
           virtual int collide(  Ogre::Real dt=1.0 );
           /// debug visualization of the collide context
           virtual void visualize(  bool doVisualize,   bool doRadii,   bool doContacts,   bool doBBs,   bool doShapes,   bool doAABBs );
           /// get the collide reports for the collisions computed inside collide(   )
           virtual int getCollisions(  CollisionObject *collObj,   CollisionPair **&cpPtr );
           /// get reporter for for last collide(   ) call.
           const CollisionReporter& getCollisionReport(   );
           /// get reporter for for last Check...(   ) call.
           const CollisionReporter& getCheckReport(   );
           /// get number of collisions for last collide call.
           const int getNumCollisions(   );
           /// do a "moving sphere" check against collide object radii in the context
           virtual int sweptSphereCheck(  const Ogre::Vector3& position,   const Ogre::Vector3& translateVector,   Ogre::Real radius,   Details::CollisionClass collClass,   CollisionPair **& cpPtr,   Ogre::String ignorename="" );
           /// do a line-model check
           virtual int rayCheck(  const Ogre::Ray line,   const Ogre::Real dist,   CollisionType collType,   Details::CollisionClass collClass,   CollisionPair**& cpPtr );
           /// do a sphere-model check
           virtual int sphereCheck(  const Ogre::Sphere& ball,   CollisionType collType,   Details::CollisionClass collClass,   CollisionPair**& cpPtr );
           /// reset position and timestamp of all objects
           void reset(   );
           ///
           void update(  Ogre::Real dt=1.0 );
          
           Details::BP_Scene* getBroadPhase(   ) { return mBroadPhase; };
           ///
          
           virtual const Ogre::String& getName(   ) { return mName; };
          
           ///
           virtual CollisionObject* getAttachedObject(  Ogre::String name );
          
           ///
           virtual const std::vector<CollisionObject*> getAttachedObjects(   )
           {
           return attached_list;
           };
          
           ///
           virtual const std::list<CollisionObject*>& getPotentialColliders(  const CollisionObject* collidee );
          
           ///
           virtual const std::vector<CollisionObject*> getOwnedObjects(   )
           {
           return owned_list;
           };
          
           ///
           virtual const int getAttachedObjectCount(   )
           {
           return static_cast< int >(   attached_list.size(   )  );
           }
          
           ///
           virtual const int getOwnedObjectCount(   )
           {
           return static_cast< int >(   owned_list.size(   )  );
           }
          
           ///
           virtual void setRayCulling(  bool rayCulling = true )
           {
           mRayCulling = rayCulling;
           }
          
           Details::OgreOpcodeDebugger* getVisualDebugger(   )
           {
           return mVisualDebugger;
           }
          
           private:
          
           friend class CollisionObject; ///<
          
           static const int max_aabbs = 256; ///<
           static const int maxnum_collisions = 4096; ///<
          
           CollisionReporter collideReportHandler; ///< collide reports for collide(   )
           CollisionReporter checkReportHandler; ///< collide reports for Check(   ) functions
          
           IceMaths::AABB* aabb_array[max_aabbs]; ///<
           typedef std::multimap<int,  CollisionObject*> CollObjAABBPairs;///<
           typedef CollObjAABBPairs::const_iterator CollObjAABBPair_Iterator;///<
           CollObjAABBPairs collAABB_pairs; ///<
           Details::BP_Scene* mBroadPhase; ///<
           typedef std::vector<CollisionObject*>::iterator rw_attached_list_iterator; ///<
           typedef std::vector<CollisionObject*>::iterator rw_owned_list_iterator; ///<
           typedef std::set<Details::Encounter> ProxList;
           ProxList proxList;
          
           static void addPair(  void *client_data,   void *object1,   void *object2 )
           {
           (  (  ProxList * )client_data )->insert(  Details::Encounter(  (  CollisionObject* )object1,   (  CollisionObject* )object2 ) );
           }
          
           static void removePair(  void *client_data,   void *object1,   void *object2 )
           {
           (  (  ProxList * )client_data )->erase(  Details::Encounter(  (  CollisionObject* )object1,   (  CollisionObject* )object2 ) );
           }
          
           protected:
           std::vector<CollisionObject*> owned_list; ///< list of CollisionObject%s created by this context
           typedef std::vector<CollisionObject*>::const_iterator owned_list_iterator; ///<
           std::vector<CollisionObject*> attached_list; ///< the list of objects currently attached to the context
           typedef std::vector<CollisionObject*>::const_iterator attached_list_iterator; ///<
           int unique_id; ///<
           Ogre::String mName; ///<
           bool mRayCulling; ///<
           bool mIsSAPDirty; ///<
           std::list<CollisionInfo> mRecentContactList; ///<
           Details::OgreOpcodeDebugger* mVisualDebugger; ///<
           };
          }
          
          #endif // __OgreCollisionContext_h__

./components/ogre/ogreopcode/include/OgreCollisionManager.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCollisionManager.h
          /// @brief Collision Manager
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreCollisionManager_h__
          #define __OgreCollisionManager_h__
          
          #include "OgreOpcodeExports.h"
          #include <Ogre.h>
          #include "OgreCollisionTypes.h"
          #include "OgreNodes.h"
          #include "OgreCollisionContext.h"
          #include "Opcode/Opcode.h"
          #include "IOgreCollisionShape.h"
          
          #include <list>
          #include <map>
          
          /// Main %OgreOpcode namespace
          namespace OgreOpcode
          {
           namespace Details
           {
           typedef int CollisionClass;
           };
          
           /// Shape types
           enum ShapeType
           {
           SHAPETYPE_ENTITY = 0,   ///< entity based shape
           SHAPETYPE_MESH = 1,   ///< mesh based shape
           SHAPETYPE_PTR = 2,   ///< raw ptr based shape
           SHAPETYPE_BOX = 3,   ///< box shape
           SHAPETYPE_SPHERE = 4,   ///< sphere shape
           SHAPETYPE_CAPSULE = 5,   ///< capsule shape
           SHAPETYPE_TERRAIN = 6 ///< terrain shape
           };
          
      62   class MeshCollisionShape;
      63   class EntityCollisionShape;
      64   class BoxCollisionShape;
      65   class SphereMeshCollisionShape;
      66   class PtrCollisionShape;
      67   class TerrainCollisionShape;
          
           /// Collision manager.
           /// The CollisionManager object serves as factory object of the
           /// different classes of the collision system,   namely
           /// CollisionContext and ICollisionShape. A CollisionContext
           /// serves as factory for CollisionObject%s.
           class _OgreOpcode_Export CollisionManager : public Ogre::Singleton<CollisionManager>
           {
           //friend class EntityCollisionShape;
           public:
           ///TODO: Put these back into the private section!!
           Opcode::AABBTreeCollider opcTreeCollider; ///<
           Opcode::RayCollider opcRayCollider; ///<
           Opcode::SphereCollider opcSphereCollider; ///<
           Opcode::PlanesCollider opcPlanesCollider; ///<
           Opcode::LSSCollider opcSweptSphereCollider; ///<
           Opcode::BVTCache opcTreeCache; ///<
           Opcode::CollisionFaces opcFaceCache; ///<
           Opcode::SphereCache opcSphereCache; ///<
           Opcode::PlanesCache opcPlanesCache; ///<
           Opcode::LSSCache opcSweptSphereCache; ///<
          
      90   CollisionManager(  Ogre::SceneManager * );
           virtual ~CollisionManager(   );
          
           static CollisionManager& getSingleton(  void );
           static CollisionManager* getSingletonPtr(  void );
          
           ///
           CollisionContext *createContext(  const Ogre::String& );
           ///
           void destroyContext(  CollisionContext * );
          
           ///
           MeshCollisionShape* createMeshCollisionShape(  const Ogre::String& );
           ///
           EntityCollisionShape* createEntityCollisionShape(  const Ogre::String& );
           ///
           BoxCollisionShape* createBoxCollisionShape(  const Ogre::String& );
           ///
           SphereMeshCollisionShape* createSphereMeshCollisionShape(  const Ogre::String& );
           ///
           PtrCollisionShape* createPtrCollisionShape(  const Ogre::String& );
           ///
           TerrainCollisionShape* createTerrainCollisionShape(  const Ogre::String& );
          
           ///
           void destroyShape(  ICollisionShape * );
          
           ///
           void attachContext(  CollisionContext * );
           ///
           void attachShape(  ICollisionShape * );
           ///
           void detachContext(  CollisionContext * );
           ///
           void detachShape(  ICollisionShape * );
          
           ///
           CollisionContext *getDefaultContext(  void );
           ///
           CollisionContext *getContext(  const Ogre::String& name );
           ///
           Ogre::SceneManager *getSceneManager(  void );
           ///
           void setSceneManager(  Ogre::SceneManager* newSceneMgr )
           {
           mSceneMgr = newSceneMgr;
           }
          
           ///
           const int getShapeCount(   )
           {
           return static_cast< int >(   shape_list.size(   )  );
           }
          
           // define collision classes and collision check relationships
           ///
           void addCollClass(  const Ogre::String & );
           ///
           void addCollType(  const Ogre::String&,   const Ogre::String&,   CollisionType );
           ///
           Details::CollisionClass queryCollClass(  const Ogre::String& );
           ///
           CollisionType queryCollType(  const Ogre::String&,   const Ogre::String& );
           ///
           CollisionType queryCollType(  Details::CollisionClass cc1,   Details::CollisionClass cc2 );
           ///
           Ogre::String getCollisionTypeEnum(  CollisionType colltype );
          
           protected:
           ///
           ICollisionShape *createShape(  const Ogre::String&,   const ShapeType shpType = SHAPETYPE_MESH );
          
           int unique_id; ///<
           typedef std::map<Ogre::String,  CollisionContext*> ContextList;///<
           typedef ContextList::const_iterator ContextIterator;///<
           ContextList context_list;///<
          
           typedef HashMap<Ogre::String,  ICollisionShape*> ShapeList;///<
           // TODO: Do I own these shapes? Or do I pass the responsibility on?
           ShapeList shape_list;///<
           typedef ShapeList::const_iterator ShapeIterator;///<
          
           typedef std::map<Ogre::String,   Details::CollisionClass> CollClassList;///<
           CollClassList collclass_list;///<
           typedef CollClassList::const_iterator CollClassIterator;///<
           typedef std::map<int,   CollisionType> CollTypeList;///<
           CollTypeList colltype_table;///<
           typedef CollTypeList::const_iterator CollTypeIterator;///<
          
           CollisionContext *default_context;///<
          
           Ogre::SceneManager *mSceneMgr;///<
           ///
           Ogre::String getResourceID(  const Ogre::String& );
           private:
          
           // Merge the 2 object id's into 1 32 bit id,  
           // order them,   so that any combination of 2 id's
           // results in the same merged id. Return true
           // a swap happened (  because other attributes
           // may have to be swapped as well ).
           bool get_merged_id(  int id1,   int id2,   int& mrg )
           {
           if (  id1 > id2 )
           {
           mrg = (  (  id2 & 0xffff )<<16 ) | (  id1 & 0xffff );
           return true;
           } else
           {
           mrg = (  (  id1 & 0xffff )<<16 ) | (  id2 & 0xffff );
           return false;
           }
           };
           };
          
          }; // namespace OgreOpcode
          
          #endif // __OgreCollisionManager_h__

./components/ogre/ogreopcode/include/OgreCollisionObject.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCollisionObject.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreCollisionObject_h__
          #define __OgreCollisionObject_h__
          
          #include <Ogre.h>
          #include "OgreNodes.h"
          #include "OgreCollisionManager.h"
          #include "OgreCollisionContext.h"
          #include "OgreOpcodeMath.h"
          
          namespace OgreOpcode
          {
      39   class CollisionContext;
      40   class CollisionPair;
          
           namespace Details
           {
      44   class BP_Proxy;
           }
           /// Collision system object.
           /// CollisionObject is an actual collision system object which can
           /// be positioned and oriented in space. It points to an
           /// EntityCollisionShape which describes the actual shape of the
           /// object.
           /// CollisionObject%s are kept in sorted list (  one for each dimension )
           /// by the CollisionContext they belong to.
           class _OgreOpcode_Export CollisionObject : public Ogre::Node::Listener
           {
      55   friend class CollisionContext;
          
           public:
           CollisionObject(  const Ogre::String& name )
           : mName(  name ),  
           mContext(  0 ),  
           mRadius(  0.0f ),  
           //old_center_offset(  0,  0,  0 ),  
           //new_center_offset(  0,  0,  0 ),  
           old_matrix(  Ogre::Matrix4::IDENTITY ),  
           old_pos(  0,  0,  0 ),  
           new_matrix(  Ogre::Matrix4::IDENTITY ),  
           new_pos(  0,  0,  0 ),  
           mShape(  0 ),  
           coll_class(  0 ),  
           m_tdelta(  -1.0 ),  
           client_data(  0 ),  
           is_attached(  false ),  
           num_colls(  0 ),  
           mNeedsUpdating(  true ),  
           mForcedUpdate(  true ),  
           mProxy(  0 )
           {
           mRecentContactList.clear(   );
           };
          
           virtual ~CollisionObject(   )
           {
           //remove_broadphase(   );
           getShape(   )->getParentSceneNode(   )->setListener(  0 );
           }
          
           void setForcedUpdate(  bool newupdate = true )
           {
           mForcedUpdate = newupdate;
           };
          
           /// <TODO: insert function description here>
           /// @param [in,   out] c CollisionContext * <TODO: insert parameter description here>
           /// @return void <TODO: insert return value description here>
           void setContext(  CollisionContext *c )
           {
           // c may be 0!!!
           mContext = c;
           };
          
           /// <TODO: insert function description here>
           /// @return CollisionContext * <TODO: insert return value description here>
           CollisionContext *getContext(  void )
           {
           return mContext;
           };
          
           /// <TODO: insert function description here>
           /// @param [in] i int <TODO: insert parameter description here>
           /// @return void <TODO: insert return value description here>
           void setId(  int i )
           {
           id = i;
           };
          
           /// <TODO: insert function description here>
           /// @return int <TODO: insert return value description here>
           int getId(  void )
           {
           return id;
           };
          
           Ogre::String getName(   ) const
           {
           return mName;
           };
          
           /// <TODO: insert function description here>
           /// @param [in] b bool <TODO: insert parameter description here>
           /// @return void <TODO: insert return value description here>
           void setAttached(  bool b )
           {
           is_attached = b;
           };
          
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
           bool isAttached(  void )
           {
           return is_attached;
           };
          
           /// <TODO: insert function description here>
           /// @param [in] f float <TODO: insert parameter description here>
           /// @return void <TODO: insert return value description here>
           void setRadius(  float f )
           {
           mRadius = f;
           };
          
           /// <TODO: insert function description here>
           /// @return float <TODO: insert return value description here>
           float getRadius(  void )
           {
           return mRadius;
           };
          
           /// <TODO: insert function description here>
           /// @param [in,   out] s EntityCollisionShape * <TODO: insert parameter description here>
           /// @return void <TODO: insert return value description here>
           void setShape(  ICollisionShape *s )
           {
           mShape = s;
           if (  s )
           {
           setRadius(  s->getRadius(   ) );
           getShape(   )->getParentSceneNode(   )->setListener(  this );
           }
           else
           {
           setRadius(  0.0f );
           }
           };
          
           /// <TODO: insert function description here>
           /// @return EntityCollisionShape * <TODO: insert return value description here>
           ICollisionShape *getShape(  void )
           {
           return mShape;
           };
          
           /// <TODO: insert function description here>
           /// @param [in] cc CollisionClass <TODO: insert parameter description here>
           /// @return void
           void setCollClass(  Details::CollisionClass cc )
           {
           coll_class = cc;
           };
          
           /// <TODO: insert function description here>
           /// @param [in] ccstr registered CollisionClass string
           /// @return void
           void setCollClass(  const char *ccstr )
           {
           coll_class = CollisionManager::getSingletonPtr(   )->queryCollClass(  ccstr );
           };
          
           /// <TODO: insert function description here>
           /// @return CollisionClass <TODO: insert return value description here>
           Details::CollisionClass getCollClass(  void )
           {
           return coll_class;
           };
          
           /// <TODO: insert function description here>
           /// @param [in,   out] d void * <TODO: insert parameter description here>
           /// @return void <TODO: insert return value description here>
           void setClientData(  void *d )
           {
           client_data = d;
           };
          
           /// <TODO: insert function description here>
           /// @return void * <TODO: insert return value description here>
           void *getClientData(  void )
           {
           return client_data;
           };
          
           /// <TODO: insert function description here>
           /// @return const Matrix4 & <TODO: insert return value description here>
           const Ogre::Matrix4& getTransform(  void )
           {
           new_matrix = getShape(   )->getFullTransform(   );
           //getShape(   )->getEntity(   )->getSubEntity(  0 )->getWorldTransforms(  &new_matrix );
           return new_matrix;
           };
          
           /// <TODO: insert function description here>
           /// @return const Matrix4 & <TODO: insert return value description here>
           const Ogre::Matrix4& getPrevTransform(  void )
           {
           return old_matrix;
           };
          
           /// Return the 'time' between the current and previous transforms
           /// @return Real The elapsed 'time' (  actually just whatever the user
           /// told us it was when calling update(   ) ). Negative if no
           /// update(   )'s have been performed since the last reset(   )
           Ogre::Real getTimeDelta(  void )
           {
           return m_tdelta;
           };
          
           /// <TODO: insert function description here>
           /// @return void <TODO: insert return value description here>
           void clearCollisions(  void )
           {
           num_colls = 0;
           };
          
           /// <TODO: insert function description here>
           /// @return int <TODO: insert return value description here>
           int getNumCollisions(  void )
           {
           return num_colls;
           };
          
           /// Retrieve current vertex data from mesh and refit collision tree
           void refit(   )
           {
           if (  mShape )
           mShape->refit(   );
           }
          
           void update(  Ogre::Real tdelta )
           {
           Ogre::Matrix4 m;
           OgreOpcode::ICollisionShape* ics = getShape(   );
           ics->update(  tdelta );
           m = ics->getFullTransform(   );
           //getShape(   )->getEntity(   )->getSubEntity(  0 )->getWorldTransforms(  &m );
          
           update(  tdelta,  m );
           }
          
           /// update the object to its new position/orientation,   update the dimensional nodes and the bounding box.
           /// @param [in] t Real 'time' delta. Doesn't have to be real time though.
           /// Just pass in 1.0 every time if you don't care about actual time.
           /// This comes into play when collisions are sub-stepped.
           /// You can get back the portion of t that passed before
           /// a collision occurred from the CollisionPair::tstamp member.
           /// @param [in] m const Matrix4 & new world transform
           void update(  Ogre::Real t,   Ogre::Matrix4& m );
          
           /// Check whether 2 moving collide objects have contact.
           bool contact(  CollisionObject *other,   // the other object
           CollisionType ct,  
           CollisionPair& cr );
          
           /// For each overlapping object in all 3 dimensions,  
           /// which doesn't fall into the ignore_types category,  
           /// do a collision check,   and if the check is positive,  
           /// record collision by doing an addCollision(   ).
           void collide(  void );
          
           /// Return collision reports for all collisions this object is involved in.
           int getCollisions(  CollisionPair **&crp )
           {
           assert(  mContext );
           assert(  is_attached );
           return mContext->collideReportHandler.getCollisions(  this,  crp );
           return 0;
           };
          
           /// get SAP min max values
           virtual void getSAPMinMax(  Ogre::Vector3& sapMin,   Ogre::Vector3& sapMax ) const;
          
           bool hasCollisions(   )
           {
           assert(  mContext );
           assert(  is_attached );
           if (   mContext->collideReportHandler.getCollisions(  this ) > 0 ) return true;
           return false;
           };
          
           bool hasCheckCollisions(   )
           {
           assert(  mContext );
           assert(  is_attached );
           if (   mContext->checkReportHandler.getCollisions(  this ) > 0 ) return true;
           return false;
           };
          
           const bool needsUpdate(   ) const
           {
           return mNeedsUpdating;
           }
          
           /// visualize stuff in local coordinate space.
           void visualizeRadii(   );
          
           /// visualize stuff in global space.
           void visualizeContacts(   );
          
           ///
           void visualizeBoundingBoxes(   );
          
           ///
           void addToCollideList(  CollisionObject* collObj );
          
           /// @see Node::Listener::nodeUpdated
           void nodeUpdated(  const Ogre::Node* node );
          
           ///
           void do_broadphase(   );
          
           ///
           void remove_broadphase(   );
          
           protected:
           std::list<CollisionObject*> collideList;
           typedef std::list<CollisionObject*>::const_iterator collideListIterator;
           int id; ///< a unique 32 bit id for this object
           Ogre::String mName; ///<
           CollisionContext *mContext; ///< the collide context this object is currently attached to
          
           Ogre::Real mRadius; ///< radius of the collision object (  normally provided by shape )
           ICollisionShape *mShape; ///< the triangle exact collision shape (  optional )
           Details::CollisionClass coll_class; ///< the application defined collision type
          
           Ogre::Vector3 minv; ///< the min/max coordinates in each dimension
           Ogre::Vector3 maxv;
          
           Ogre::Vector3 old_minv,   old_maxv;
          
           Ogre::Matrix4 old_matrix; ///< the previous orientation of the object
           Ogre::Vector3 old_pos; ///< the previous position of the object
           Ogre::Matrix4 new_matrix; ///< the new orientation of the object
           Ogre::Vector3 new_pos; ///< the new position of the object
           Ogre::Real m_tdelta; ///< the 'time' between old and new transform
           //Vector3 old_center_offset; ///< the world offset of the shape center
           //Vector3 new_center_offset; ///< the world offset of the shape center
          
           void *client_data; ///< user defined client data field
           bool is_attached; ///< currently attached to a context
           bool mNeedsUpdating; ///< do we need to update collisions?
           bool mForcedUpdate; ///< force update even if we haven't moved
           int num_colls; ///< number of collisions this object is involved in
          
           Details::BP_Proxy* mProxy;
          
           std::list<CollisionInfo> mRecentContactList;
           };
          };
          
          #endif // __OgreCollisionObject_h__

./components/ogre/ogreopcode/include/OgreCollisionReporter.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCollisionReporter.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreCollisionReporter_h__
          #define __OgreCollisionReporter_h__
          
          #include <Ogre.h>
          #include "OgreOpcodeExports.h"
          #include <set>
          #include <map>
          
          namespace OgreOpcode
          {
      38   class CollisionObject;
          
           class _OgreOpcode_Export CollisionInfo
           {
           public:
      43   CollisionInfo(   )
           : this_contact(  Ogre::Vector3::ZERO ),  
           other_contact(  Ogre::Vector3::ZERO ),  
           contact(  Ogre::Vector3::ZERO ),  
           distance(  0.0f ),  
           this_normal(  Ogre::Vector3::ZERO ),  
           other_normal(  Ogre::Vector3::ZERO )
           {};
           Ogre::Vector3 this_contact; ///< first objects contact point
           Ogre::Vector3 other_contact; ///< second objects contact point
           Ogre::Vector3 contact; ///< the point of contact computed
           Ogre::Real distance; ///< distance to point of contact (  for ray checks )
           Ogre::Vector3 this_normal; ///< First objects collision plane normal
           Ogre::Vector3 other_normal; ///< Second objects collision plane normal
          
           Ogre::Vector3 this_tri_verts[3]; ///< First objects collision triangle
           Ogre::Vector3 other_tri_verts[3]; ///< Second objects collision triangle
           };
          
           /// Describes a contact between 2 CollisionObject%s.
           class _OgreOpcode_Export CollisionPair
           {
           public:
           CollisionPair(   )
           : this_object(  0 ),  
           other_object(  0 ),  
           this_contact(  Ogre::Vector3::ZERO ),  
           other_contact(  Ogre::Vector3::ZERO ),  
           contact(  Ogre::Vector3::ZERO ),  
           distance(  0.0f ),  
           this_normal(  Ogre::Vector3::ZERO ),  
           other_normal(  Ogre::Vector3::ZERO ),  
           tstamp(  0.0f ),  
           numBVBVTests(  0 ),  
           numBVPrimTests(  0 ),  
           numPrimPrimTests(  0 )
           {};
          
           CollisionObject *this_object; ///< the first object involved in the collision
           CollisionObject *other_object; ///< the second object involved in the collision
           // Why are we duplicating this?
           // Because if there is only one collision,   there is no need
           // to iterate the CollisionVector
           Ogre::Vector3 this_contact; ///< first objects contact point
           Ogre::Vector3 other_contact; ///< second objects contact point
           Ogre::Vector3 contact; ///< the point of contact computed
           Ogre::Real distance; ///< distance to point of contact (  for ray checks )
           Ogre::Vector3 this_normal; ///< First objects collision plane normal
           Ogre::Vector3 other_normal; ///< Second objects collision plane normal
           Ogre::Real tstamp; ///< the timestamp at which the collision occurred
           typedef std::vector<CollisionInfo> CollisionVector; ///< a vector containing all collisions between the two objects
           CollisionVector collInfos;
           unsigned int numBVBVTests; ///<
           unsigned int numBVPrimTests; ///<
           unsigned int numPrimPrimTests; ///<
           };
          
           /// Collect and manage CollisionPair%s.
           /// Manages a set of collision pairs. Makes sure that each collision
           /// between 2 objects is only tested/reported once,   to help
           /// the CollisionContext avoid redundant checks.
           class _OgreOpcode_Export CollisionReporter
           {
           typedef std::vector<CollisionPair> CollPairVector;
           static const int max_reports_per_object = 256; ///<
           typedef std::set<unsigned int> UIntSet; ///<
           typedef std::map<unsigned int,   CollisionPair> CollPairMap; ///<
           UIntSet test_pairs; ///<
           CollPairMap coll_pairs; ///<
           CollisionPair *report_array[max_reports_per_object]; ///<
          
           public:
           // Misc stats
           unsigned int mTotalObjObjTests; ///<
           unsigned int mTotalBVBVTests; ///<
           unsigned int mTotalBVPrimTests; ///<
           unsigned int mTotalPrimPrimTests; ///<
          
           private:
          
           // Merge the 2 object id's into 1 32 bit id,  
           // order them,   so that any combination of 2 id's
           // results in the same merged id. Return true
           // a swap happened (  because other attributes
           // may have to be swapped as well ).
           bool get_merged_id(  int id1,   int id2,   unsigned int& mrg )
           {
           if (  id1 > id2 )
           {
           mrg = (  (  id2 & 0xffff )<<16 ) | (  id1 & 0xffff );
           return true;
           } else
           {
           mrg = (  (  id1 & 0xffff )<<16 ) | (  id2 & 0xffff );
           return false;
           }
           };
           public:
           CollisionReporter(   )
           {}
          
           /// initialize data for new collision frame
           void beginFrame(   )
           {
           test_pairs.clear(   );
           coll_pairs.clear(   );
           memset(  report_array,  0,  sizeof(  report_array ) );
           mTotalObjObjTests=0;
           mTotalBVBVTests=0;
           mTotalBVPrimTests=0;
           mTotalPrimPrimTests=0;
           };
          
           /// check if a collision has already been reported
           bool collisionExists(  int id1,   int id2 )
           {
           // generate the merged 32 bit id,   and query key array
           // for the collision
           unsigned int key;
           get_merged_id(  id1,  id2,  key );
           return (   coll_pairs.find(  key )!= coll_pairs.end(   )  );
           };
          
           /// add a new collision
           void addCollision(  CollisionPair& cr,   int id1,   int id2 )
           {
           // generate the merged 32 bit id and add collision report
           unsigned int key;
           get_merged_id(  id1,  id2,  key );
           // Add check for existence in debug mode??
           coll_pairs.insert(  CollPairMap::value_type(  key,   cr ) );
           };
          
           /// check if a collision has already been tested for
           bool collisionTested(  int id1,   int id2 )
           {
           // generate the merged 32 bit id,   and query key array
           // for the collision
           unsigned int key;
           get_merged_id(  id1,  id2,  key );
           return (  test_pairs.find(  key )!=test_pairs.end(   ) );
           };
          
           /// Register that a test has been performed already
           void addCollisionTest(  int id1,   int id2 )
           {
           // generate the merged 32 bit id and add record
           unsigned int key;
           get_merged_id(  id1,  id2,  key );
           test_pairs.insert(  key );
           };
          
           /// end a collision frame
           void endFrame(   ) { };
          
           /// get overall number of collisions recorded
           int getNumCollisions(   )
           {
           return coll_pairs.size(   );
           };
          
           /// get overall number of tests performed
           int getNumCollisionTests(   )
           {
           return test_pairs.size(   );
           };
          
           /// report collisions for a specific object.
           /// @param co [in] pointer to CollisionObject
           /// @param cr_ptr [out] pointer to collide report pointer array
           /// @return number of collisions this object is involved in
           int getCollisions(  CollisionObject *co,   CollisionPair **& cr_ptr )
           {
           // fill report array with all collisions which this
           // object is involved in.
           assert(  co );
           int num_reports = 0;
           int num = coll_pairs.size(   );
          
           if (  num > max_reports_per_object )
           {
           num = max_reports_per_object;
           }
           CollPairMap::iterator icp=coll_pairs.begin(   ),   iend=coll_pairs.end(   );
           for (  ; icp!=iend; ++icp )
           {
           CollisionPair &cp = icp->second;
           if (  (  cp.this_object == co ) || (  cp.other_object == co ) )
           {
           report_array[num_reports++] = &cp;
           }
           }
           cr_ptr = report_array;
           return num_reports;
           }
          
           /// report collisions for a specific object.
           /// @param co [in] pointer to CollisionObject
           /// @return number of collisions this object is involved in
           int getCollisions(  CollisionObject *co )
           {
           // fill report array with all collisions which this
           // object is involved in.
           assert(  co );
           int num_reports = 0;
           int num = coll_pairs.size(   );
          
           if (  num > max_reports_per_object )
           {
           num = max_reports_per_object;
           }
           CollPairMap::iterator icp=coll_pairs.begin(   ),   iend=coll_pairs.end(   );
           for (  ; icp!=iend; ++icp )
           {
           CollisionPair &cp = icp->second;
           if (  (  cp.this_object == co ) || (  cp.other_object == co ) )
           {
           num_reports++;
           }
           }
           return num_reports;
           }
          
           /// get all recorded collisions.
           /// @param cr_ptr [out] pointer to collide report pointer array
           /// @return number of collisions
           int getAllCollisions(  CollisionPair **& cr_ptr )
           {
           //coll_pairs.sort(   )
          
           int num = coll_pairs.size(   );
           int i;
          
           if (  num > max_reports_per_object )
           {
           num = max_reports_per_object;
           }
          
           CollPairMap::iterator icp=coll_pairs.begin(   ),   iend=coll_pairs.end(   );
           for (  i=0; icp!=iend; ++icp )
           {
           report_array[i++] = &icp->second;
           }
           cr_ptr = report_array;
           return num;
           }
          
           /// Get the collision closest to given point.
           /// @param v [in] origin coordinate
           /// @param crPtr [out] pointer to collide report pointer array
           /// @return number of entries in collide report pointer array (  0 or 1 )
           int getClosestCollision(  const Ogre::Vector3& v,   CollisionPair **& crPtr )
           {
           // THIS NEEDS TO BE RE-IMPLEMENTED!
          
           //int num = coll_pairs.size(   );
           //if (  0 == num )
           //{
           // crPtr = 0;
           // return 0;
           //}
          
           ////Ogre::Vector3 distVec;
           //CollisionPair* minPtr = &coll_pairs.begin(   )->second;
           ////float minDist = Vector3(  minPtr->contact - v ).squaredLength(   );
           //float minDist = minPtr->distance;
           //CollPairMap::iterator icp=coll_pairs.begin(   ),   iend=coll_pairs.end(   );
           //for (  ; icp!=iend; ++icp )
           //{
           // CollisionPair* curPtr = &icp->second;
           // //distVec = curPtr->contact - v;
           // //Ogre::Real dist = distVec.squaredLength(   );
           // Ogre::Real dist = curPtr->distance;
           // if (  dist < minDist )
           // {
           // minDist = dist;
           // minPtr = curPtr;
           // }
           //}
           //report_array[0] = minPtr;
           //crPtr = report_array;
           return 1;
           }
           };
          }
          
          #endif // __OgreCollisionReporter_h__

./components/ogre/ogreopcode/include/OgreCollisionTypes.h

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCollisionTypes.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreCollisionTypes_h__
          #define __OgreCollisionTypes_h__
          
          namespace OgreOpcode
          {
          
           /// Define the collision types for collision queries.
           enum CollisionType
           {
           COLLTYPE_IGNORE = 1,   ///< no collisions
           COLLTYPE_QUICK = 2,   ///< quick sphere-2-sphere collision
           COLLTYPE_BBOX = 3,   ///< OBB collision
           COLLTYPE_CONTACT = 4,   ///< first contact only
           COLLTYPE_EXACT = 5,   ///< all contacts
           };
          
           /// special case values for the CollClass check.
           enum CollisionTypeOverride
           {
           COLLTYPE_ALWAYS_IGNORE = -1,  
           COLLTYPE_ALWAYS_QUICK = -2,  
           COLLTYPE_ALWAYS__BBOX = -3,  
           COLLTYPE_ALWAYS_CONTACT = -4,  
           COLLTYPE_ALWAYS_EXACT = -5,  
           };
          
          }
          
          
          #endif // __OgreCollisionTypes_h__

./components/ogre/ogreopcode/include/OgreEntityCollisionShape.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreEntityCollisionShape.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreEntityCollisionShape_h__
          # define __OgreEntityCollisionShape_h__
          
          #include "OgreOpcodeExports.h"
          # include <Ogre.h>
          
          #include "IOgreCollisionShape.h"
          #include "OgreCollisionTypes.h"
          #include "OgreOpcodeDebugObject.h"
          #include "Opcode/Opcode.h"
          
          namespace OgreOpcode
          {
      41   class CollisionPair;
          
           /// Describes shapes for collision system.
           /// Holds a triangle list describing a collision shape.
           /// One EntityCollisionShape object may be shared between several
           /// CollisionObject%s. 2 EntityCollisionShape objects may also
           /// be queried directly whether they intersect.
           ///
           /// EntityCollisionShape objects are also able to load themselves
           /// from a mesh file.
           class _OgreOpcode_Export EntityCollisionShape : public ICollisionShape
           {
           public:
           /// Constructs a EntityCollisionShape
      55   EntityCollisionShape(  const Ogre::String& name );
           virtual ~EntityCollisionShape(   );
          
           /// load collide geometry from mesh,   and build a collision tree
           virtual bool load(  Ogre::Entity* ent );
          
           /// Retrieve current vertex data from mesh and refit collision tree.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           virtual bool refit(   );
          
           protected:
          
           /// Reload the collision geometry from mesh,   rebuild collision tree from scratch.
           /// Potentially very slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases RefitToMesh(   ) is sufficient,   and much faster.
           /// Under usual circumstances there is no need to call this method.
           virtual bool rebuild(   );
           /// Refits the collision tree to the currently cached vertex data.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the EntityCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _refitToCachedData(   );
           /// rebuild collision tree from scratch using currently cached vertex data
           /// This is potentially quite slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases _RefitToCachedGeometry(   ) is sufficient,   and much faster.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the EntityCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _rebuildFromCachedData(   );
          
           ///
           virtual void createDummyNode(   );
          
           private:
           Ogre::Entity* mEntity; /// <
           Ogre::SceneNode* mDummyNode;/// <
           bool mDummyCreated;/// <
          
           /// Count up the total number of vertices and indices in the Ogre mesh
           void countIndicesAndVertices(  Ogre::Entity * entity,   size_t & index_count,   size_t & vertex_count );
           /// Convert ogre Mesh to simple float and int arrays
           void convertMeshData(  Ogre::Entity * entity,   float * vertexData,   size_t vertex_count,   size_t * faceData=0,   size_t index_count=0 );
          
           /// prevent default construction
           EntityCollisionShape(   );
          
           };
          
          }; // namespace OgreOpcode
          
          #endif // __OgreEntityCollisionShape_h__

./components/ogre/ogreopcode/include/OgreMeshCollisionShape.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreMeshCollisionShape.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreMeshCollisionShape_h__
          # define __OgreMeshCollisionShape_h__
          
          #include "OgreOpcodeExports.h"
          # include <Ogre.h>
          
          #include "IOgreCollisionShape.h"
          #include "OgreCollisionTypes.h"
          #include "OgreOpcodeDebugObject.h"
          #include "Opcode/Opcode.h"
          
          namespace OgreOpcode
          {
      41   class CollisionPair;
          
           /// Describes shapes for collision system.
           /// Holds a triangle list describing a collision shape.
           /// One MeshCollisionShape object may be shared between several
           /// CollisionObject%s. 2 MeshCollisionShape objects may also
           /// be queried directly whether they intersect.
           ///
           /// MeshCollisionShape objects are also able to load themselves
           /// from a mesh file.
           class _OgreOpcode_Export MeshCollisionShape : public ICollisionShape
           {
           public:
           /// Constructs a MeshCollisionShape
      55   MeshCollisionShape(  const Ogre::String& name );
           virtual ~MeshCollisionShape(   );
          
           /// load collide geometry from mesh,   and build a collision tree
           virtual bool load(  const Ogre::String& meshName,   const Ogre::Quaternion& orientation = Ogre::Quaternion::IDENTITY,   const Ogre::Vector3& position = Ogre::Vector3(  0,  0,  0 ) );
          
           /// Retrieve current vertex data from mesh and refit collision tree.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           virtual bool refit(   );
          
           protected:
          
           /// Reload the collision geometry from mesh,   rebuild collision tree from scratch.
           /// Potentially very slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases RefitToMesh(   ) is sufficient,   and much faster.
           /// Under usual circumstances there is no need to call this method.
           virtual bool rebuild(   );
           /// Refits the collision tree to the currently cached vertex data.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the MeshCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _refitToCachedData(   );
           /// rebuild collision tree from scratch using currently cached vertex data
           /// This is potentially quite slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases _RefitToCachedGeometry(   ) is sufficient,   and much faster.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the MeshCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _rebuildFromCachedData(   );
           ///
           virtual void createDummyNode(   );
          
           private:
           Ogre::Entity* mEntity;/// <
           Ogre::SceneNode* mDummyNode;/// <
           bool mDummyCreated;/// <
          
           /// Count up the total number of vertices and indices in the Ogre mesh
           void countIndicesAndVertices(  Ogre::Entity * entity,   size_t & index_count,   size_t & vertex_count );
           /// Convert ogre Mesh to simple float and int arrays
           void convertMeshData(  Ogre::Entity * entity,   float * vertexData,   size_t vertex_count,   size_t * faceData=0,   size_t index_count=0 );
          
           /// prevent default construction
           MeshCollisionShape(   );
          
           };
          
          }; // namespace OgreOpcode
          
          #endif // __OgreMeshCollisionShape_h__

./components/ogre/ogreopcode/include/OgreNodes.h

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreNodes.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 30-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreNodes_h__
          #define __OgreNodes_h__
          
          namespace OgreOpcode
          {
           namespace Details
           {
           }
          }
          
          #endif // __OgreNodes_h__

./components/ogre/ogreopcode/include/OgreOpcode.h

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcode.h
          /// @brief Main include file for clients.
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOpcode_h__
          #define __OgreOpcode_h__
          
          #include "OgreOpcodeExports.h"
          
          #include "OgreCollisionManager.h"
          #include "OgreCollisionContext.h"
          #include "OgreCollisionObject.h"
          #include "OgreCollisionTypes.h"
          #include "OgreMeshCollisionShape.h"
          #include "OgreEntityCollisionShape.h"
          #include "OgrePtrCollisionShape.h"
          #include "OgreBoxCollisionShape.h"
          #include "OgreSphereMeshCollisionShape.h"
          #include "OgreTerrainCollisionShape.h"
          #include "OgreCollisionReporter.h"
          
          #include "OgreOpcodeCharacterController.h"
          #include "OgreOpcodeTerrainData.h"
          
          #endif // __OgreOpcode_h__

./components/ogre/ogreopcode/include/OgreOpcodeCharacterController.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeCharacterController.h
          /// @brief
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef OGREOPCODECHARACTERCONTROLLER_H
          #define OGREOPCODECHARACTERCONTROLLER_H
          
          #include "OgreOpcode.h"
          #include "Ogre.h"
          
          namespace OgreOpcode
          {
           class _OgreOpcode_Export CharacterController
           {
           public:
      39   CharacterController(  Ogre::SceneNode* CharacterBaseNode,   Ogre::Real CharacterRadius,   Ogre::Real CharacterHeight,   Ogre::Vector3 Gravity = Ogre::Vector3(  0,  -9.8,  0 ),   Ogre::Degree SlopeThreshold = Ogre::Degree(  60 ),   Ogre::Real UnitsPerMeter = 1.0 );
      40   ~CharacterController(   );
          
           struct CollisionPacket
           {
           Ogre::Vector3 eRadius; // ellipsoid radius
           // Information about the move being requested: (  in R3 )
           Ogre::Vector3 R3Velocity;
           Ogre::Vector3 R3Position;
           // Information about the move being requested: (  in eSpace )
           Ogre::Vector3 velocity;
           Ogre::Vector3 normalizedVelocity;
           Ogre::Vector3 basePoint;
           // Hit information
           bool foundCollision;
           Ogre::Real nearestDistance;
           Ogre::Vector3 intersectionPoint;
           };
          
      58   Ogre::SceneNode* getBaseNode(   );
      59   Ogre::Real getHeight(   );
      60   Ogre::Real getRadius(   );
      61   Ogre::Vector3 getGravity(   );
      62   Ogre::Degree getSlopeThreshold(   );
          
      64   void move(  Ogre::Vector3 velocity );
          
      66   void setHeight(  Ogre::Real Height );
      67   void setRadius(  Ogre::Real Radius );
      68   void setGravity(  const Ogre::Vector3& Gravity );
      69   void setSlopeThreshold(  const Ogre::Degree& SlopeThreshold );
          
           protected:
           Ogre::SceneNode* mBaseNode;
           // radius of the capsule shape representing the character.
           Ogre::Real mRadius;
           // height of the capsule shape representing the character.
           Ogre::Real mHeight;
           // Force applied to character at all times.
           // (  optimized to not apply to characters at rest )
           Ogre::Vector3 mGravity;
           // The maximum slope the character will slide against.
           Ogre::Degree mSlopeThreshold;
           // used to derive close distances between objects.
           Ogre::Real mUnitsPerMeter;
           Ogre::Real mVeryCloseDistance;
          
           Ogre::String mContactName;
          
           private:
           /** Collides a sphere with world.
           @param pos
           The colliding sphere position.
           @param vel
           The colliding sphere velocity.
           @param radius
           The colliding sphere radius.
           @param gravity
           The amount of gravity in the world.
           @param slopeSlideThresold
           (  optional ) The steepness thresold for sliding.
           @return
           New position for collided sphere.
           */
           Ogre::Vector3 _collideAndSlide(  const Ogre::Vector3& vel );
           Ogre::Vector3 _collideWithWorld(  int recursionDepth,   const Ogre::Vector3& pos,   const Ogre::Vector3& vel,   CollisionPacket& colData,   bool gravityStep,   const Ogre::Degree& slopeSlideThresold );
           void _doOgreOpcodeCollision(  CollisionPacket& colData,   float sweepOffset );
           };
          }
          
          #endif

./components/ogre/ogreopcode/include/OgreOpcodeDebugObject.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeDebugObject.h
          /// @brief <TODO: insert file description here>
          /// @remarks Based directly on code from OgreNewt,   by Walaber.
          /// @author The OgreOpcode Team
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOpcodeDebugObject_h__
          #define __OgreOpcodeDebugObject_h__
          
          #include "OgreOpcodeExports.h"
          # include "Ogre.h"
          
          namespace OgreOpcode
          {
           namespace Details
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           class _OgreOpcode_Export DebugLines : public Ogre::SimpleRenderable
           {
           public:
      41   DebugLines(  void );
      42   ~DebugLines(  void );
          
      44   void addLine(  const Ogre::Vector3 &start,  const Ogre::Vector3 &end )
           {
           clear(   );
          
           _points.push_back(  start );
           _points.push_back(  end );
           }
      51   void addLine(  Ogre::Real start_x,  Ogre::Real start_y,  Ogre::Real start_z,  Ogre::Real end_x,  Ogre::Real end_y,  Ogre::Real end_z )
           {
           addLine(  Ogre::Vector3(  start_x,  start_y,  start_z ),  Ogre::Vector3(  end_x,  end_y,  end_z ) );
           }
      55   void draw(   );
      56   void clear(   );
          
      58   Real getSquaredViewDepth(  const Ogre::Camera *cam ) const;
      59   Real getBoundingRadius(  void ) const;
          
           protected:
          
           std::vector<Ogre::Vector3> _points;
           bool _drawn;
           };
          #endif
          
           class _OgreOpcode_Export OgreOpcodeDebugger
           {
           public:
           OgreOpcodeDebugger(  const Ogre::String& name,   Ogre::SceneManager* sceneMgr );
           virtual ~OgreOpcodeDebugger(   );
          
           void addRadiiLine(  Ogre::Real lx1,   Ogre::Real ly1,   Ogre::Real lz1,   Ogre::Real lx2,   Ogre::Real ly2,   Ogre::Real lz2 );
           void addContactLine(  Ogre::Real lx1,   Ogre::Real ly1,   Ogre::Real lz1,   Ogre::Real lx2,   Ogre::Real ly2,   Ogre::Real lz2 );
           void addContactNormalsLine(  Ogre::Real lx1,   Ogre::Real ly1,   Ogre::Real lz1,   Ogre::Real lx2,   Ogre::Real ly2,   Ogre::Real lz2 );
           void addBBLine(  Ogre::Real lx1,   Ogre::Real ly1,   Ogre::Real lz1,   Ogre::Real lx2,   Ogre::Real ly2,   Ogre::Real lz2 );
           void addShapeLine(  Ogre::Real lx1,   Ogre::Real ly1,   Ogre::Real lz1,   Ogre::Real lx2,   Ogre::Real ly2,   Ogre::Real lz2 );
           void addAABBLine(  Ogre::Real lx1,   Ogre::Real ly1,   Ogre::Real lz1,   Ogre::Real lx2,   Ogre::Real ly2,   Ogre::Real lz2 );
          
           void clearAll(   );
          
           void clearRadii(   );
           void beginRadii(   );
           void endRadii(   );
           void clearContacts(   );
           void beginContacts(   );
           void endContacts(   );
           void clearContactNormals(   );
           void beginContactNormals(   );
           void endContactNormals(   );
           void clearBBs(   );
           void beginBBs(   );
           void endBBs(   );
           void clearShapes(   );
           void beginShapes(   );
           void endShapes(   );
           void clearAABBs(   );
           void beginAABBs(   );
           void endAABBs(   );
          
           private:
          
           Ogre::SceneManager* mSceneMgr;
           Ogre::String mName;
           Ogre::SceneNode* mRadiiDebugNode;
           Ogre::SceneNode* mContactsDebugNode;
           Ogre::SceneNode* mContactNormalsDebugNode;
           Ogre::SceneNode* mBBsDebugNode;
           Ogre::SceneNode* mShapesDebugNode;
           Ogre::SceneNode* mAABBsDebugNode;
          
          #ifdef BUILD_AGAINST_AZATHOTH
           DebugLines* mRadiiDebugObject;
           DebugLines* mContactsDebugObject;
           DebugLines* mContactNormalsDebugObject;
           DebugLines* mBBsDebugObject;
           DebugLines* mShapesDebugObject;
           DebugLines* mAABBsDebugObject;
          #else
           Ogre::ManualObject* mRadiiDebugObject;
           Ogre::ManualObject* mContactsDebugObject;
           Ogre::ManualObject* mContactNormalsDebugObject;
           Ogre::ManualObject* mBBsDebugObject;
           Ogre::ManualObject* mShapesDebugObject;
           Ogre::ManualObject* mAABBsDebugObject;
          #endif
           };
          
           } // namespace Details
          
          } // namespace OgreOpcode
          
          #endif // __OgreOpcodeDebugObject_h__

./components/ogre/ogreopcode/include/OgreOpcodeExports.h

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeExports.h
          /// @brief Export macros and common stuff.
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOpcodeExports_h__
          #define __OgreOpcodeExports_h__
          
          #pragma warning(   disable: 4267  ) // conversion from 'size_t' to whatever
          
          // Turn deprecation warnings off when using VC8
          #if (  _MSC_VER >= 1400 )
          #pragma warning (  disable : 4996 )
          #ifndef _CRT_SECURE_NO_DEPRECATE
          #define _CRT_SECURE_NO_DEPRECATE 1
          #endif
          #ifndef _CRT_NONSTDC_NO_DEPRECATE
          #define _CRT_NONSTDC_NO_DEPRECATE 1
          #endif
          #endif //VC8
          
          #include "Ogre.h"
          #include "OgrePrerequisites.h"
          
          #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 && !defined (   __MINGW32__  )
          # if defined(   OGREOPCODE_EXPORTS  )
          # define _OgreOpcode_Export __declspec(   dllexport  )
          # else
          # define _OgreOpcode_Export __declspec(   dllimport  )
          # endif
          #else
          # define _OgreOpcode_Export
          #endif
          
          // Uncomment the next line to build against Azathoth .. ;- )
          //#define BUILD_AGAINST_AZATHOTH
          
          #endif // __OgreOpcodeExports_h__

./components/ogre/ogreopcode/include/OgreOpcodeLine.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreLine.h
          /// @brief TODO.
          ///
          /// @author The OgreOpcode Team @date 23-02-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOpcodeLineClass_h__
          #define __OgreOpcodeLineClass_h__
          
          #include "OgreOpcodeMath.h"
          
          namespace OgreOpcode
          {
           namespace Details
           {
           /// Represents a Line segment defined by 2 endpoints.
           /// TODO: add methods to this class.
           class _OgreOpcode_Export Line
           {
           public:
          
           /** Default contructor,   making start=end=ZERO
           */
      45   Line(   ):start(   ),  end(   )
           {
           }
          
           /** Complete contructor
           */
      51   Line(   const Ogre::Vector3& p0,   const Ogre::Vector3& p1  ):start(  p0 ),  end(  p1 )
           {
           }
          
           /** Complete,   headache contructor
           */
      57   Line(   Ogre::Real x0,   Ogre::Real y0,   Ogre::Real z0,  
           Ogre::Real x1,   Ogre::Real y1,   Ogre::Real z1  ):start(  x0,  y0,  z0 ),  end(  x1,  y1,  z1 )
           {
           }
          
           /** Copy-contructor
           */
      64   Line(   const Line& line  ):start(  line.start ),  end(  line.end )
           {
           }
          
           /// Setups this line
      69   void set(   const Line& line  )
           {
           start = line.start;
           end = line.end;
           }
          
           /// Sets this line segment
      76   void set(   Ogre::Real x0,   Ogre::Real y0,   Ogre::Real z0,  
           Ogre::Real x1,   Ogre::Real y1,   Ogre::Real z1  )
           {
           start.x = x0;
           start.y = y0;
           start.z = z0;
           end.x = x1;
           end.y = y1;
           end.z = z1;
           }
          
           /// Setups this line
      88   void set(   const Ogre::Vector3& p0,   const Ogre::Vector3& p1  )
           {
           start = p0;
           end = p1;
           }
          
           /** Computes the <em>squared</em> distance from this line to the given point.
           * The linear delta will be stored in t,   if not null.
           */
      97   Ogre::Real squaredDistance(   const Ogre::Vector3& point,   Ogre::Real *t =NULL  ) const;
          
           /** Computes the distance from this line to the given point.
           * The linear delta will be stored in t,   if not null.
           */
     102   Ogre::Real distance(   const Ogre::Vector3& point,   Ogre::Real *t =NULL  ) const;
          
           /** Computes the <em>squared</em> distance from this line to the given one.
           * The vector pointers p0 and p1 will hold the linear deltas to obtain the
           * closest points in the respective line segments.
           */
     108   Ogre::Real squaredDistance(   const Line& line,   Ogre::Real* p0 = NULL,   Ogre::Real* p1 = NULL  ) const;
          
           /** Computes the distance from this line to the given one.
           * The vector pointers p0 and p1 will hold the linear deltas to obtain the
           * closest points in the respective line segments.
           */
     114   Ogre::Real distance(   const Line& line,   Ogre::Real* p0 = NULL,   Ogre::Real* p1 = NULL  ) const;
          
          
           /** Computes the <em>squared</em> distance from this line segment to the given Oriented Bounding Box.
           */
     119   Ogre::Real squaredDistance(   const OrientedBox& obb  ) const;
          
           /** Computes the distance from this line segment to the given Oriented Bounding Box.
           */
     123   Ogre::Real distance(   const OrientedBox& obb  ) const;
          
           ///Sets the starting point
     126   void setStart(   Ogre::Real x,   Ogre::Real y,   Ogre::Real z  )
           {
           start.x = x;
           start.y = y;
           start.z = z;
           }
           ///Sets the starting point
     133   void setStart(   const Ogre::Vector3& v  ) { start = v; }
          
           ///Sets the ending point
     136   void setEnd(   Ogre::Real x,   Ogre::Real y,   Ogre::Real z  )
           {
           end.x = x;
           end.y = y;
           end.z = z;
           }
           ///Sets the ending point
     143   void setEnd(   const Ogre::Vector3& v  ) { end = v; }
          
           /// Gets the length of this line segment
     146   Ogre::Real length(   ) const { return (  start-end ).length(   ); }
           /// Gets the squared length of this line segment
     148   Ogre::Real length2(   ) const { return (  start-end ).squaredLength(   ); }
          
           /// Gets the non-normalized direction of this line segment
     151   Ogre::Vector3 getDirection(   ) const { return end - start; }
          // --------------------------------------------------------------------
          // Intersection methods
          
           /** Intersection test between this line and the given AABB.
           */
     157   bool intersect(   const Aabb& aabb  ) const;
          
           /** Intersection test between this line and the given OBB.
           */
     161   bool intersect(   const OrientedBox& obb  ) const;
          
           /** Intersection test between this line and the given Sphere.
           */
     165   bool intersect(   const Ogre::Sphere& sphere  ) const;
          
           /** Intersection test between this line and the given Capsule.
           */
     169   bool intersect(   const Capsule& capsule  ) const;
          
           /** Generates the parametric point at a given parametric value,   using the linear combination.
           * @return v = start*(  1-delta ) + end*delta
           */
     174   Ogre::Vector3 getPointAt(   Ogre::Real delta  ) const
           {
           return start + delta*(  start-end );
           }
          
          // --------------------------------------------------------------------
          // Picking methods
          
           /** Picking test between this line and the given AABB.
           * @param dist Reference to a floating point representing the closest
           * intersection point trough the distance from the ray origin.
           */
     186   bool pick(   const Aabb& aabb,   Ogre::Real& dist  ) const;
          
           /** Picking test between this line and the given OBB.
           * @param dist Reference to a floating point representing the closest
           * intersection point trough the distance from the ray origin.
           */
     192   bool pick(   const OrientedBox& obb,   Ogre::Real& dist  ) const;
          
           /** Picking test between this line and the given Sphere.
           * @param dist Reference to a floating point representing the closest
           * intersection point trough the distance from the ray origin.
           */
     198   bool pick(   const Ogre::Sphere& sphere,   Ogre::Real& dist  ) const;
          
           /** The start point of this line.
           */
           Ogre::Vector3 start;
           /** The end point of this line.
           */
           Ogre::Vector3 end;
           };
           }
          }
          
          #endif

./components/ogre/ogreopcode/include/OgreOpcodeMath.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeMath.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOpcodeMath_h__
          #define __OgreOpcodeMath_h__
          
          #include <Ogre.h>
          #include "OgreOpcodeExports.h"
          
          namespace OgreOpcode
          {
           namespace Details
           {
           // -----------------------------------------------------------------------
           // Overridden operators
          
           /// Dot product operator
      42   inline Ogre::Real operator | (   const Ogre::Vector3& u,   const Ogre::Vector3& v  )
           {
           return (  u.x*v.x + u.y*v.y + u.z*v.z );
           }
          
           /// Cross product operator
      48   inline Ogre::Vector3 operator ^ (   const Ogre::Vector3& u,   const Ogre::Vector3& v  )
           {
           return u.crossProduct(   v  );
           }
          
           // forward declarations
      54   class Capsule;
      55   class Line;
      56   class OrientedBox;
          
      58   class line3
           {
           public:
      61   Ogre::Vector3 b;
      62   Ogre::Vector3 m;
          
      64   line3(   ) {};
      65   line3(  const Ogre::Vector3& v0,   const Ogre::Vector3& v1 ) : b(  v0 ),   m(  v1-v0 ) {};
      66   line3(  const line3& l ) : b(  l.b ),   m(  l.m ) {};
          
      68   void set(  const Ogre::Vector3& v0,   const Ogre::Vector3& v1 )
           {
           b = v0;
           m = v1-v0;
           };
          
      74   const Ogre::Vector3& start(  void ) const
           {
           return b;
           };
          
      79   Ogre::Vector3 end(  void ) const
           {
           return (  b+m );
           };
          
      84   Ogre::Real length(  void ) const
           {
           return m.length(   );
           };
          
           //--- minimal distance of point to line -------------------------
      90   Ogre::Real distance(  const Ogre::Vector3& p )
           {
           Ogre::Vector3 diff(  p-b );
           Ogre::Real l = m.dotProduct(  m );
           if (  l > 0.0f ) {
           Ogre::Real t = m.dotProduct(  diff ) / l;
           diff = diff - m*t;
           return diff.length(   );
           } else
           {
           // line is really a point...
           Ogre::Vector3 v(  p-b );
           return v.length(   );
           }
           };
          
           //--- get 3d point on line given t ------------------------------
     107   Ogre::Vector3 ipol(  const Ogre::Real t ) const {
           return Ogre::Vector3(  b + m*t );
           };
           };
          
           //-------------------------------------------------------------------
           // Triangle points are tri(  s,  t )=b + s*e0 + t*e1 where
           // 0<=s<=1,   0<=t<=1 and 0<=s+t<=1
           //-------------------------------------------------------------------
     116   class triangle
           {
           public:
     119   Ogre::Vector3 b,  e0,  e1;
          
     121   triangle(   ) {};
     122   triangle(  const Ogre::Vector3& v0,   const Ogre::Vector3& v1,   const Ogre::Vector3& v2 )
           : b(  v0 ),   e0(  v1-v0 ),   e1(  v2-v0 ) {};
     124   triangle(  const triangle& t )
           : b(  t.b ),   e0(  t.e0 ),   e1(  t.e1 ) {};
          
     127   void set(  const Ogre::Vector3& v0,   const Ogre::Vector3& v1,   const Ogre::Vector3& v2 ) {
           b = v0;
           e0 = v1-v0;
           e1 = v2-v0;
           };
          
           //--- get the face normal of the triangle ---------------------------------
     134   Ogre::Vector3 normal(  void ) const
           {
           Ogre::Vector3 cross = e0.crossProduct(  e1 );
           cross.normalise(   );
           return cross;
           };
          
           //--- get the midpoint (  center of gravity ) of the triangle ----------------
     142   Ogre::Vector3 midpoint(  void ) const {
           return b + (  (  e0+e1 )/3.0f );
           };
          
           //--- get the plane of the triangle ---------------------------------------
     147   Ogre::Plane getplane(  void ) const
           {
           return Ogre::Plane(  b,  b+e0,  b+e1 );
           };
          
           //--- get one the edge points ---------------------------------------------
     153   Ogre::Vector3 point(  int i ) const
           {
           switch (  i )
           {
           case 0: return b;
           case 1: return b + e0;
           case 2: return b + e1;
           default: return Ogre::Vector3(  0.0f,   0.0f,   0.0f );
           }
           };
          
     164   bool isPointInsideFast(  Ogre::Vector3 &p )
           {
           Ogre::Vector3 f = point(  1 ) - point(  0 );
           Ogre::Vector3 g = point(  2 ) - point(  0 );
          
           Ogre::Real a = f.dotProduct(  f );
           Ogre::Real _b = f.dotProduct(  g );
           Ogre::Real c = g.dotProduct(  g );
          
           Ogre::Real ac_bb = (  a*c )-(  _b*_b );
           Ogre::Vector3 vp = p - point(  0 );
          
           Ogre::Real d = vp.dotProduct(  f );
           Ogre::Real e = vp.dotProduct(  g );
           Ogre::Real x = (  d*c )-(  e*_b );
           Ogre::Real y = (  e*a )-(  d*_b );
           Ogre::Real z = x+y-ac_bb;
          
           return (  (   (  (  unsigned int& )z )& ~(  (  (  unsigned int& )x )|(  (  unsigned int& )y ) ) ) & 0x80000000 )!=0;
           }
          
           //--- check if and where line intersects triangle -------------------------
           // Taken from Magic Software (  http://www.cs.unc.edu/~eberly )
           // Return false if line is parallel to triangle or hits its backside.
           //
     189   bool intersect(  const line3& line,   Ogre::Real& ipos )
           {
          
           // Compute plane of triangle,   Dot(  normal,  X-tri.b ) = 0 where 'normal' is
           // the plane normal. If the angle between the line direction and normal
           // is small,   then the line is effectively parallel to the triangle.
           const Ogre::Real fTolerance = 1e-04f;
           Ogre::Vector3 norm = e0.crossProduct(  e1 );
           Ogre::Real fDenominator = norm.dotProduct(  line.m );
           //Real fLLenSqr = line.m % line.m;
           //Real fNLenSqr = norm % norm;
          
           // check if intersecting backface or parallel...
           if (  fDenominator >= -fTolerance ) return false;
          
           //if (  (  fDenominator*fDenominator ) <= (  fTolerance*fLLenSqr*fNLenSqr ) ) {
           // // line and triangle are parallel
           // return false;
           //}
          
           // The line is X(  t ) = line.b + t*line.m. Compute line parameter t for
           // intersection of line and plane of triangle. Substitute in the plane
           // equation to get Dot(  normal,  line.b-tri.b ) + t*Dot(  normal,  line.m )
           Ogre::Vector3 kDiff0(  line.b - b );
           Ogre::Real fTime = -(  norm.dotProduct(  kDiff0 ) ) / fDenominator;
           if (  (  fTime<-fTolerance ) || (  fTime>(  1.0f+fTolerance ) ) ) return false;
          
           // Find difference of intersection point of line with plane and vertex
           // of triangle.
           Ogre::Vector3 kDiff1(  kDiff0 + line.m*fTime );
          
           // Compute if intersection point is inside triangle. Write
           // kDiff1 = s0*E0 + s1*E1 and solve for s0 and s1.
           Ogre::Real fE00 = e0.dotProduct(  e0 );
           Ogre::Real fE01 = e0.dotProduct(  e1 );
           Ogre::Real fE11 = e1.dotProduct(  e1 );
           Ogre::Real fDet = (  Ogre::Real ) fabs(  fE00*fE11-fE01*fE01 ); // = |normal|^2 > 0
           Ogre::Real fR0 = e0.dotProduct(  kDiff1 );
           Ogre::Real fR1 = e1.dotProduct(  kDiff1 );
          
           Ogre::Real fS0 = fE11*fR0 - fE01*fR1;
           Ogre::Real fS1 = fE00*fR1 - fE01*fR0;
          
           if (  (  fS0>=-fTolerance ) && (  fS1>=-fTolerance ) && (  fS0+fS1<=fDet+fTolerance ) ) {
           // intersection is inside triangle
           ipos = fTime;
           return true;
           } else {
           // intersection is outside triangle
           return false;
           }
           };
          
           //--- check if and where line intersects triangle -------------------------
           // Taken from Magic Software (  http://www.cs.unc.edu/~eberly )
           // Return false if line is parallel to triangle
           //
     246   bool intersect_both_sides(  const line3& line,   Ogre::Real& ipos ) {
          
           // Compute plane of triangle,   Dot(  normal,  X-tri.b ) = 0 where 'normal' is
           // the plane normal. If the angle between the line direction and normal
           // is small,   then the line is effectively parallel to the triangle.
           const Ogre::Real fTolerance = 1e-04f;
           Ogre::Vector3 norm = e0.crossProduct(  e1 );
           Ogre::Real fDenominator = norm.dotProduct(  line.m );
           Ogre::Real fLLenSqr = line.m.dotProduct(  line.m );
           Ogre::Real fNLenSqr = norm.dotProduct(  norm );
          
           // check if intersecting backface or parallel...
           if (  fDenominator*fDenominator <= fTolerance*fLLenSqr*fNLenSqr ) return false;
          
           //if (  (  fDenominator*fDenominator ) <= (  fTolerance*fLLenSqr*fNLenSqr ) ) {
           // // line and triangle are parallel
           // return false;
           //}
          
           // The line is X(  t ) = line.b + t*line.m. Compute line parameter t for
           // intersection of line and plane of triangle. Substitute in the plane
           // equation to get Dot(  normal,  line.b-tri.b ) + t*Dot(  normal,  line.m )
           Ogre::Vector3 kDiff0(  line.b - b );
           Ogre::Real fTime = -(  norm.dotProduct(  kDiff0 ) ) / fDenominator;
           if (  (  fTime<-fTolerance ) || (  fTime>(  1.0f+fTolerance ) ) ) return false;
          
           // Find difference of intersection point of line with plane and vertex
           // of triangle.
           Ogre::Vector3 kDiff1(  kDiff0 + line.m*fTime );
          
           // Compute if intersection point is inside triangle. Write
           // kDiff1 = s0*E0 + s1*E1 and solve for s0 and s1.
           Ogre::Real fE00 = e0.dotProduct(  e0 );
           Ogre::Real fE01 = e0.dotProduct(  e1 );
           Ogre::Real fE11 = e1.dotProduct(  e1 );
           Ogre::Real fDet = (  Ogre::Real ) fabs(  fE00*fE11-fE01*fE01 ); // = |normal|^2 > 0
           Ogre::Real fR0 = e0.dotProduct(  kDiff1 );
           Ogre::Real fR1 = e1.dotProduct(  kDiff1 );
          
           Ogre::Real fS0 = fE11*fR0 - fE01*fR1;
           Ogre::Real fS1 = fE00*fR1 - fE01*fR0;
          
           if (  (  fS0>=-fTolerance ) && (  fS1>=-fTolerance ) && (  fS0+fS1<=fDet+fTolerance ) ) {
           // intersection is inside triangle
           ipos = fTime;
           return true;
           } else {
           // intersection is outside triangle
           return false;
           }
           };
           };
          
          #define TINY (  0.0000001 )
          #define n_max(  a,  b ) (  (  (  a ) > (  b ) ) ? (  a ) : (  b ) )
          #define n_min(  a,  b ) (  (  (  a ) < (  b ) ) ? (  a ) : (  b ) )
          
     303   class bbox3
           {
           public:
     306   Ogre::Vector3 vmin;
     307   Ogre::Vector3 vmax;
          
           enum
           {
           CLIP_LEFT = (  1<<0 ),  
           CLIP_RIGHT = (  1<<1 ),  
           CLIP_BOTTOM = (  1<<2 ),  
           CLIP_TOP = (  1<<3 ),  
           CLIP_NEAR = (  1<<4 ),  
           CLIP_FAR = (  1<<5 ),  
           };
          
           enum
           {
           OUTSIDE = 0,  
           ISEQUAL = (  1<<0 ),  
           ISCONTAINED = (  1<<1 ),  
           CONTAINS = (  1<<2 ),  
           CLIPS = (  1<<3 ),  
           };
          
           //--- constructors ----------------------------------------------
     329   bbox3(   ) {};
     330   bbox3(  const Ogre::Vector3& _vmin,   const Ogre::Vector3& _vmax ) : vmin(  _vmin ),   vmax(  _vmax ) {};
     331   bbox3(  const bbox3& bb ) : vmin(  bb.vmin ),   vmax(  bb.vmax ) {};
          
           //--- initialize from Vector3 cloud -----------------------------
     334   bbox3(  Ogre::Vector3 *varray,   int num )
           {
           vmin = varray[0];
           vmax = varray[0];
           int i;
           for (  i=0; i<num; i++ )
           {
           if (  varray[i].x<vmin.x ) vmin.x=varray[i].x;
           else if (  varray[i].x>vmax.x ) vmax.x=varray[i].x;
           if (  varray[i].y<vmin.y ) vmin.y=varray[i].y;
           else if (  varray[i].y>vmax.y ) vmax.y=varray[i].y;
           if (  varray[i].z<vmin.z ) vmin.z=varray[i].z;
           else if (  varray[i].z>vmax.z ) vmax.z=varray[i].z;
           }
           };
          
           //--- utility getters ------------------------------------------
     351   Ogre::Vector3 getCenter(   ) const { return (  vmin + vmax )*0.5; }
     352   void getCenter(  Ogre::Vector3& v ) const { v = (  vmin + vmax )*0.5; }
          
     354   Ogre::Vector3 getExtents(   ) const { return (  vmax - vmin )*0.5; }
     355   void getExtents(   Ogre::Vector3& v ) const { v = (  vmax - vmin )*0.5; }
          
           //--- setting elements ------------------------------------------
     358   void set(  const Ogre::Vector3& _vmin,   const Ogre::Vector3& _vmax )
           {
           vmin = _vmin;
           vmax = _vmax;
           };
     363   void set(  Ogre::Vector3 *varray,   int num )
           {
           vmin = varray[0];
           vmax = varray[0];
           int i;
           for (  i=0; i<num; i++ )
           {
           if (  varray[i].x<vmin.x ) vmin.x=varray[i].x;
           else if (  varray[i].x>vmax.x ) vmax.x=varray[i].x;
           if (  varray[i].y<vmin.y ) vmin.y=varray[i].y;
           else if (  varray[i].y>vmax.y ) vmax.y=varray[i].y;
           if (  varray[i].z<vmin.z ) vmin.z=varray[i].z;
           else if (  varray[i].z>vmax.z ) vmax.z=varray[i].z;
           }
           };
          
           //--- invalidate bounding box to prepare for growing ------------
     380   void begin_grow(  void )
           {
           vmin = Ogre::Vector3(  +1000000.0f,  +1000000.0f,  +1000000.0f );
           vmax = Ogre::Vector3(  -1000000.0f,  -1000000.0f,  -1000000.0f );
           };
     385   void grow(  const Ogre::Vector3& v )
           {
           if (  v.x<vmin.x ) vmin.x=v.x;
           if (  v.x>vmax.x ) vmax.x=v.x;
           if (  v.y<vmin.y ) vmin.y=v.y;
           if (  v.y>vmax.y ) vmax.y=v.y;
           if (  v.z<vmin.z ) vmin.z=v.z;
           if (  v.z>vmax.z ) vmax.z=v.z;
           };
     394   void grow(  Ogre::Vector3 *varray,   int num )
           {
           int i;
           for (  i=0; i<num; i++ )
           {
           grow(  varray[i] );
           }
           };
          
     403   void grow(  const bbox3& bb )
           {
           if (  bb.vmin.x<vmin.x ) vmin.x=bb.vmin.x;
           if (  bb.vmin.y<vmin.y ) vmin.y=bb.vmin.y;
           if (  bb.vmin.z<vmin.z ) vmin.z=bb.vmin.z;
           if (  bb.vmax.x>vmax.x ) vmax.x=bb.vmax.x;
           if (  bb.vmax.y>vmax.y ) vmax.y=bb.vmax.y;
           if (  bb.vmax.z>vmax.z ) vmax.z=bb.vmax.z;
           };
          
           // get point of intersection of 3d line with planes
           // on const x,  y,  z
     415   bool isect_const_x(  const float x,   const line3& l,   Ogre::Vector3& out ) const
           {
           if (  l.m.x != 0.0f )
           {
           float t = (  x - l.b.x ) / l.m.x;
           if (  (  t>=0.0f ) && (  t<=1.0f ) )
           {
           // point of intersection...
           out = l.ipol(  t );
           return true;
           }
           }
           return false;
           }
          
     430   bool isect_const_y(  const float y,   const line3& l,   Ogre::Vector3& out ) const
           {
           if (  l.m.y != 0.0f )
           {
           float t = (  y - l.b.y ) / l.m.y;
           if (  (  t>=0.0f ) && (  t<=1.0f ) )
           {
           // point of intersection...
           out = l.ipol(  t );
           return true;
           }
           }
           return false;
           }
          
     445   bool isect_const_z(  const float z,   const line3& l,   Ogre::Vector3& out ) const
           {
           if (  l.m.z != 0.0f )
           {
           float t = (  z - l.b.z ) / l.m.z;
           if (  (  t>=0.0f ) && (  t<=1.0f ) )
           {
           // point of intersection...
           out = l.ipol(  t );
           return true;
           }
           }
           return false;
           }
          
           // point in polygon check for sides with constant x,  y and z
     461   bool pip_const_x(  const Ogre::Vector3& p ) const
           {
           if (  (  p.y>=vmin.y )&&(  p.y<=vmax.y )&&(  p.z>=vmin.z )&&(  p.z<=vmax.z ) ) return true;
           else return false;
           }
          
     467   bool pip_const_y(  const Ogre::Vector3& p ) const
           {
           if (  (  p.x>=vmin.x )&&(  p.x<=vmax.x )&&(  p.z>=vmin.z )&&(  p.z<=vmax.z ) ) return true;
           else return false;
           }
          
     473   bool pip_const_z(  const Ogre::Vector3& p ) const
           {
           if (  (  p.x>=vmin.x )&&(  p.x<=vmax.x )&&(  p.y>=vmin.y )&&(  p.y<=vmax.y ) ) return true;
           else return false;
           }
          
           //--- check if box intersects or contains line ------------------
     480   bool intersect(  const line3& line ) const
           {
           // For each side of box,   check if point of intersection
           // lies within this sides 2d rectangle. If at least one
           // intersection occurs,   the line intersects the box
           // (  usually,   there will be 2 intersections ).
           // The line parameter t for the intersection is computed
           // by resolving the formula:
           // p = line.b + line.m*t
           // after t:
           // t = (  p - line.b ) / line.m
           // if line.m is zero,   the line is parallel to the plane in
           // question.
           // MAY BE EXTENDED TO RETURN CLOSEST POINT OF INTERSECTION!
          
           // check if at least one of the 2 points is included in the volume
           Ogre::Vector3 s(  line.start(   ) );
           Ogre::Vector3 e(  line.end(   ) );
           if (  (  (  s.x>=vmin.x ) && (  s.y>=vmin.y ) && (  s.z>=vmin.z ) &&
           (  s.x<=vmax.x ) && (  s.y<=vmax.y ) && (  s.z<=vmax.z ) ) ||
           (  (  e.x>=vmin.x ) && (  e.y>=vmin.y ) && (  e.z>=vmin.z ) &&
           (  e.x<=vmax.x ) && (  e.y<=vmax.y ) && (  e.z<=vmax.z ) ) )
           {
           return true;
           } else
           {
           // otherwise do intersection check
           int i;
           Ogre::Vector3 ipos;
           for (  i=0; i<6; i++ )
           {
           switch (  i )
           {
           // left side,   vmin.x is constant
           case 0:
           if (  isect_const_x(  vmin.x,  line,  ipos ) && pip_const_x(  ipos ) ) return true;
           break;
           case 1:
           if (  isect_const_x(  vmax.x,  line,  ipos ) && pip_const_x(  ipos ) ) return true;
           break;
           case 2:
           if (  isect_const_y(  vmin.y,  line,  ipos ) && pip_const_y(  ipos ) ) return true;
           break;
           case 3:
           if (  isect_const_y(  vmax.y,  line,  ipos ) && pip_const_y(  ipos ) ) return true;
           break;
           case 4:
           if (  isect_const_z(  vmin.z,  line,  ipos ) && pip_const_z(  ipos ) ) return true;
           break;
           case 5:
           if (  isect_const_z(  vmax.z,  line,  ipos ) && pip_const_z(  ipos ) ) return true;
           break;
           }
           }
           }
           return false;
           }
          
           /**
           @brief Gets closest intersection with AABB.
           If the line starts inside the box,   start point is returned in ipos.
           @param line the pick ray
           @param ipos closest point of intersection if successful,   trash otherwise
           @return true if an intersection occurs
           */
     545   bool intersect(  const line3& line,   Ogre::Vector3& ipos ) const
           {
           // Handle special case for start point inside box
           if (  line.b.x >= vmin.x && line.b.y >= vmin.y && line.b.z >= vmin.z &&
           line.b.x <= vmax.x && line.b.y <= vmax.y && line.b.z <= vmax.z )
           {
           ipos = line.b;
           return true;
           }
          
           // Order planes to check,   closest three only
           int plane[3];
           if (  line.m.x > 0 ) plane[0] = 0;
           else plane[0] = 1;
           if (  line.m.y > 0 ) plane[1] = 2;
           else plane[1] = 3;
           if (  line.m.z > 0 ) plane[2] = 4;
           else plane[2] = 5;
          
           for (  int i = 0; i < 3; ++i )
           {
           switch (  plane[i] )
           {
           case 0:
           if (  isect_const_x(  vmin.x,  line,  ipos ) && pip_const_x(  ipos ) ) return true;
           break;
           case 1:
           if (  isect_const_x(  vmax.x,  line,  ipos ) && pip_const_x(  ipos ) ) return true;
           break;
           case 2:
           if (  isect_const_y(  vmin.y,  line,  ipos ) && pip_const_y(  ipos ) ) return true;
           break;
           case 3:
           if (  isect_const_y(  vmax.y,  line,  ipos ) && pip_const_y(  ipos ) ) return true;
           break;
           case 4:
           if (  isect_const_z(  vmin.z,  line,  ipos ) && pip_const_z(  ipos ) ) return true;
           break;
           case 5:
           if (  isect_const_z(  vmax.z,  line,  ipos ) && pip_const_z(  ipos ) ) return true;
           break;
           }
           }
          
           return false;
           }
          
           //--- check if box intersects,   contains or is contained in other box
           //--- by doing 3 projection tests for each dimension,   if all 3 test
           //--- return true,   then the 2 boxes intersect
     595   int line_test(  float v0,   float v1,   float w0,   float w1 )
           {
           // quick rejection test
           if (  (  v1<w0 ) || (  v0>w1 ) ) return OUTSIDE;
           else if (  (  v0==w0 ) && (  v1==w1 ) ) return ISEQUAL;
           else if (  (  v0>=w0 ) && (  v1<=w1 ) ) return ISCONTAINED;
           else if (  (  v0<=w0 ) && (  v1>=w1 ) ) return CONTAINS;
           else return CLIPS;
           }
          
     605   int intersect(  bbox3 box )
           {
           int and_code = 0xffff;
           int or_code = 0;
           int cx,  cy,  cz;
           cx = line_test(  vmin.x,  vmax.x,  box.vmin.x,  box.vmax.x );
           and_code&=cx; or_code|=cx;
           cy = line_test(  vmin.y,  vmax.y,  box.vmin.y,  box.vmax.y );
           and_code&=cy; or_code|=cy;
           cz = line_test(  vmin.z,  vmax.z,  box.vmin.z,  box.vmax.z );
           and_code&=cz; or_code|=cz;
           if (  or_code == 0 ) return OUTSIDE;
           else if (  and_code != 0 )
           {
           return and_code;
           } else
           {
           // only if all test produced a non-outside result,  
           // an intersection has occured
           if (  cx && cy && cz ) return CLIPS;
           else return OUTSIDE;
           }
           }
           };
          
           /// Just for ease of use,   let bbox be an AABB. :P
           typedef bbox3 Aabb;
          
     633   class sphere
           {
           public:
     636   Ogre::Vector3 p; // position
     637   Ogre::Real r; // radius
          
           //--- constructors ----------------------------------------------
           sphere(   ) : r(  1.0f ) {};
     641   sphere(  const Ogre::Vector3& _p,   Ogre::Real _r ) : p(  _p ),   r(  _r ) {};
     642   sphere(  const sphere& s ) : p(  s.p ),   r(  s.r ) {};
     643   sphere(  Ogre::Real _x,   Ogre::Real _y,   Ogre::Real _z,   Ogre::Real _r )
           : r(  _r )
           {
           p = Ogre::Vector3(  _x,  _y,  _z );
           };
          
           //--- set position and radius ---
     650   void set(  const Ogre::Vector3& _p,   Ogre::Real _r )
           {
           p = _p;
           r = _r;
           };
     655   void set(  Ogre::Real _x,   Ogre::Real _y,   Ogre::Real _z,   Ogre::Real _r )
           {
           p = Ogre::Vector3(  _x,   _y,   _z );
           r = _r;
           };
          
           //--- check if 2 spheres overlap,   without contact point ---------
     662   bool intersects(  const sphere& s ) const
           {
           Ogre::Vector3 d(  s.p-p );
           Ogre::Real rsum = s.r+r;
           if (  d.squaredLength(   ) <= (  rsum*rsum ) ) return true;
           else return false;
           };
          
           //--- check if 2 moving spheres have contact --------------------
           //--- taken from "Simple Intersection Tests For Games" ----------
           //--- article in Gamasutra,   Oct 18 1999 -------------------------
     673   bool intersect_sweep(  const Ogre::Vector3& va,   // in: distance travelled by 'this'
           const sphere& sb,   // in: the other sphere
           const Ogre::Vector3& vb,   // in: distance travelled by 'sb'
           Ogre::Real& u0,   // out: normalized intro contact u0
           Ogre::Real& u1 ) // out: normalized outro contact u1
           {
           Ogre::Vector3 vab(  vb - va );
           Ogre::Vector3 ab(  sb.p - p );
           Ogre::Real rab = r + sb.r;
          
           // check if spheres are currently overlapping...
           if (  (  ab.dotProduct(  ab ) ) <= (  rab*rab ) )
           {
           u0 = 0.0f;
           u1 = 0.0f;
           return true;
           } else
           {
           // check if they hit each other
           Ogre::Real a = vab.dotProduct(  vab );
           if (  (  a<-TINY ) || (  a>+TINY ) )
           {
           // if a is '0' then the objects don't move relative to each other
           Ogre::Real b = (  vab.dotProduct(  ab ) ) * 2.0f;
           Ogre::Real c = (  ab.dotProduct(  ab ) ) - (  rab * rab );
           Ogre::Real q = b*b - 4*a*c;
           if (  q >= 0.0f ) {
           // 1 or 2 contacts
           Ogre::Real sq = (  Ogre::Real )sqrt(  q );
           Ogre::Real d = 1.0f / (  2.0f*a );
           Ogre::Real r1 = (  -b + sq ) * d;
           Ogre::Real r2 = (  -b - sq ) * d;
           if (  r1 < r2 )
           {
           u0 = r1;
           u1 = r2;
           } else
           {
           u0 = r2;
           u1 = r1;
           }
           return true;
           } else
           return false;
           } else
           return false;
           }
           };
           };
          
           // includes the OBB header. looks strange,   huh ? :P
           //#include "OgreOrientedBox.h"
          
           /* Triangle/triangle intersection test routine,  
           * by Tomas Moller,   1997.
           * See article "A Fast Triangle-Triangle Intersection Test",  
           * Journal of Graphics Tools,   2(  2 ),   1997
           * updated: 2001-06-20 (  added line of intersection )
           *
           * 2005-04-15 ported to CS by Andrew Dai
          
           * 2006-06-21 ported to Ogre by Jacob Moen
           */
           /**
           * A 3D line segment. (  Nicked from CrystalSpace )
           */
           class Segment3
           {
           private:
           /// Start.
           Ogre::Vector3 _start;
           /// End.
           Ogre::Vector3 _end;
          
           public:
           /// Make a new segment and initialize with the given values.
           Segment3 (  const Ogre::Vector3& s,   const Ogre::Vector3& e ) { _start = s; _end = e; }
           /// Make a new uninitialized segment.
           Segment3 (   ) { }
          
           /// Set segment to given values.
           inline void set (  const Ogre::Vector3& s,   const Ogre::Vector3& e )
           { _start = s; _end = e; }
          
           /// Set the start of the segment.
           inline void setStart (  const Ogre::Vector3& s ) { _start = s; }
          
           /// Set the end of the segment.
           inline void setEnd (  const Ogre::Vector3& e ) { _end = e; }
          
           /// Get the start of the segment.
           inline const Ogre::Vector3& start (   ) const { return _start; }
          
           /// Get the end of the segment.
           inline const Ogre::Vector3& end (   ) const { return _end; }
          
           /// Get the start of the segment.
           inline Ogre::Vector3& start (   ) { return _start; }
          
           /// Get the end of the segment.
           inline Ogre::Vector3& end (   ) { return _end; }
           };
          
           class Intersect3
           {
           public:
           /**
           * Test intersection between two triangles.
           * \param tri1 Vertices of triangle 1
           * \param tri2 Vertices of triangle 2
           * \return true if the triangles intersect,   otherwise false
           */
           static bool triangleTriangle (  const Ogre::Vector3 tri1[3],  
           const Ogre::Vector3 tri2[3] );
          
           /**
           * Calculate intersection between two triangles and return it
           * in isectline.
           * \param tri1 Vertices of triangle 1
           * \param tri2 Vertices of triangle 2
           * \param[out] isectline The line segment where they intersect
           * \param[out] coplanar Returns whether the triangles are coplanar
           * \return true if the triangles intersect,   otherwise false
           */
           static bool triangleTriangle (  const Ogre::Vector3 tri1[3],  
           const Ogre::Vector3 tri2[3],  
           Segment3& isectline,   bool& coplanar );
          
           };
          
           Ogre::String decimalToBinary(  unsigned int i );
          
           bool powerOf2(  unsigned int i );
           }
          }
          
          
          #endif // __OgreOpcodeMath_h__

./components/ogre/ogreopcode/include/OgreOpcodeRay.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreRay.h
          /// @brief TODO.
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOpcodeRayClass_h__
          #define __OgreOpcodeRayClass_h__
          
          #include "OgreOpcodeMath.h"
          
          namespace OgreOpcode
          {
           namespace Details
           {
           /// Represents a Ray (  semi-line ) defined by a starting point and a direction.
           /// TODO: add methods to this class.
           class _OgreOpcode_Export Ray3
           {
           public:
          
           /// Default constructor: ray from origin looking at -Z
      44   Ray3(   ):origin(   ),  direction(  -Ogre::Vector3::UNIT_Z )
           {
           }
          
           /// Copy-constructor
           Ray3(   const Ray3& ray  ):origin(  ray.origin ),  direction(  ray.direction )
           {
           }
          
           /// Full constructor
           Ray3(   const Ogre::Vector3& ori,   const Ogre::Vector3& dir  ):origin(  ori ),  direction(  dir )
           {
           direction.normalise(   );
           }
          
           /// Full constructor
           Ray3(   Ogre::Real ox,   Ogre::Real oy,   Ogre::Real oz,  
           Ogre::Real dx,   Ogre::Real dy,   Ogre::Real dz  ):origin(  ox,  oy,  oz ),  direction(  dx,  dy,  dz )
           {
           direction.normalise(   );
           }
          
           /// Setups this ray
           void set(   const Ray3& ray  )
           {
           origin = ray.origin;
           direction = ray.direction;
           }
          
           /// Setups this ray
           void set(   Ogre::Real ox,   Ogre::Real oy,   Ogre::Real oz,  
           Ogre::Real dx,   Ogre::Real dy,   Ogre::Real dz  )
           {
           origin.x = ox;
           origin.y = oy;
           origin.z = oz;
          
           direction.x = dx;
           direction.x = dy;
           direction.x = dz;
           direction.normalise(   );
           }
          
           /// Setups this ray
           void set(   const Ogre::Vector3& ori,   const Ogre::Vector3& dir  )
           {
           origin = ori;
           direction = dir;
           direction.normalise(   );
           }
          
           /// Sets the origin of this ray
           void setOrigin(   Ogre::Real x,   Ogre::Real y,   Ogre::Real z  )
           {
           origin.x = x;
           origin.y = y;
           origin.z = z;
           }
           /// Sets the origin of this ray
           void setOrigin(   const Ogre::Vector3& v ) { origin = v; }
          
           /** Sets the direction of this ray
           * @param x,   y,   z Coordinates for direction
           * @param normalize If true,   the input vector needs to be normalized
           */
           void setDirection(   Ogre::Real x,   Ogre::Real y,   Ogre::Real z,   bool normalize = true  )
           {
           direction.x = x;
           direction.y = y;
           direction.z = z;
           if(   normalize  )
           direction.normalise(   );
           }
          
           /** Sets the direction of this ray
           * @param v Direction vector
           * @param normalize If true,   the input vector needs to be normalized
           */
           void setDirection(   const Ogre::Vector3& v,   bool normalize = true  )
           {
           direction = v;
           if(   normalize  )
           direction.normalise(   );
           }
          
           /// Gets the origin of this ray
           const Ogre::Vector3& getOrigin(   ) const { return origin; }
           /// Gets the direction of this ray
           const Ogre::Vector3& getDirection(   ) const { return direction; }
          
           /** Gets the point in this ray at (  oriented ) distance delta from the origin
           */
           Ogre::Vector3 getPointAt(   Ogre::Real delta  ) const
           {
           return origin + delta*direction;
           }
          
          // --------------------------------------------------------------------
          // Distance methods
          
           /** Computes the <em>squared</em> distance from this ray to a point
           */
           Ogre::Real squaredDistance(   const Ogre::Vector3& point  ) const;
          
           /** Computes the distance from this ray to a point
           */
           Ogre::Real distance(   const Ogre::Vector3& point  ) const;
          
           /** Computes the <em>squared</em> distance from this ray to a line
           */
           Ogre::Real squaredDistance(   const Line& line  ) const;
          
           /** Computes the distance from this ray to a line
           */
           Ogre::Real distance(   const Line& line  ) const;
          
          // --------------------------------------------------------------------
          // Intersection methods
          
           /** Intersection test between this line and the given AABB.
           */
           bool intersect(   const bbox3& aabb  ) const;
          
           /** Intersection test between this line and the given OBB.
           */
           bool intersect(   const OrientedBox& obb  ) const;
          
           /** Intersection test between this line and the given Sphere.
           */
           bool intersect(   const Ogre::Sphere& sphere  ) const;
          
           /** Intersection test between this line and the given Capsule.
           */
           bool intersect(   const Capsule& capsule  ) const;
          
          // --------------------------------------------------------------------
          // Picking methods
          
           /** Picking test between this ray and the given OBB.
           * @param dist Reference to a floating point representing the closest
           * intersection point trough the distance from the ray origin.
           */
           bool pick(   const Aabb& aabb,   Ogre::Real& dist  ) const;
          
           /** Picking test between this ray and the given OBB.
           * @param dist Reference to a floating point representing the closest
           * intersection point trough the distance from the ray origin.
           */
           bool pick(   const OrientedBox& obb,   Ogre::Real& dist  ) const;
          
           /** Picking test between this ray and the given Sphere.
           * @param dist Reference to a floating point representing the closest
           * intersection point trough the distance from the ray origin.
           */
           bool pick(   const Ogre::Sphere& sphere,   Ogre::Real& dist  ) const;
          
           /// Holds the origin of this ray
           Ogre::Vector3 origin;
           /// Holds the direction of this ray
           Ogre::Vector3 direction;
          
           };
           }
          }
          
          #endif

./components/ogre/ogreopcode/include/OgreOpcodeTerrainData.h

          #ifndef __OgreOpcodeTerrainData_h__
          #define __OgreOpcodeTerrainData_h__
          
          #include "OgrePtrCollisionShape.h"
          #include <vector>
          
          namespace OgreOpcode
          {
           /// OgreOpcode container for data related to a particular terrain.
           /// Uses data to derive PtrCollisionShape objects in the form of Tiles.
           class _OgreOpcode_Export TerrainData
           {
           public:
           // Constructor supporting Data that can be retrieved from ET::TerrainInfo derived Terrain.
      15   TerrainData(  const std::vector<float>& HeightmapData,   size_t Width,   size_t Depth,   Ogre::Vector3 Scale,   Ogre::Vector3 Offset = Ogre::Vector3::ZERO );
      16   ~TerrainData(   );
          
           /** Retrieves a value from the heightmap. */
      19   const float& at(  size_t x,   size_t y ) { return (  *mHeightmapData )[x + y*mWidth]; }
          
           // It is up to the user to properly destroy the created Tile Shapes,   just like all other created shapes!
      22   std::vector<OgreOpcode::PtrCollisionShape*>* createTileShapes(  unsigned int numTilesX = 2,   unsigned int numTilesZ = 2 );
          
      24   size_t getDepth(   );
      25   Ogre::Vector3 getOffset(   );
      26   Ogre::Vector3 getScale(   );
      27   size_t getWidth(   );
          
           protected:
           private:
           const std::vector<float>* mHeightmapData;
           size_t mWidth;
           size_t mDepth;
           // ETM does not require terrain be at position 0,  0,  0.
           // In fact,   you can even have multiple terrain rendered.
           Ogre::Vector3 mOffset; // origin of the terrain
           Ogre::Vector3 mScale; // ratio of vertices to 3d coordinate space,   in user defined dimensions
          
           std::vector<OgreOpcode::PtrCollisionShape*> mTileShapes;
           };
          }
          
          #endif

./components/ogre/ogreopcode/include/OgreOpcodeUtils.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeUtils.h
          /// @brief This header file contains utility methods for OgreOpcode. Most of
          /// them are for type conversions between IceMaths and Ogre.
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOpcodeUtils_h__
          #define __OgreOpcodeUtils_h__
          
          namespace OgreOpcode
          {
           namespace Details
           {
           /// This utility class is used to convert types from/to Ogre,   OgreOpcode and Opcode.
           /// Thus,   it contributes for better,   cleaner code and ease of maintenance in the project.
           class _OgreOpcode_Export OgreOpcodeUtils
           {
           public:
          
           /// Converts from an Ogre's vector into an IceMaths' one
      43   static void ogreToIceVector3(   const Ogre::Vector3& ogreVec,   IceMaths::Point& opcPoint  )
           {
           opcPoint.x = ogreVec.x;
           opcPoint.y = ogreVec.y;
           opcPoint.z = ogreVec.z;
           }
          
      50   static void ogreQuatPosToIceMatrix4(  const Ogre::Quaternion& quat,   const Ogre::Vector3& pos,   IceMaths::Matrix4x4& opcMatrix )
           {
           Ogre::Matrix3 rot;
           Ogre::Vector3 xcol,   ycol,   zcol;
          
           quat.ToRotationMatrix(   rot  ); // creates a 3x3 rotation matrix from the Quaternion.
          
           xcol = rot.GetColumn(  0 );
           ycol = rot.GetColumn(  1 );
           zcol = rot.GetColumn(  2 );
          
           // now fill the final matrix with the appropriate data:
           opcMatrix[0][0] = xcol.x;
           opcMatrix[0][1] = xcol.y;
           opcMatrix[0][2] = xcol.z;
           opcMatrix[0][3] = 0.0f;
          
           opcMatrix[1][0] = ycol.x;
           opcMatrix[1][1] = ycol.y;
           opcMatrix[1][2] = ycol.z;
           opcMatrix[1][3] = 0.0f;
          
           opcMatrix[2][0] = zcol.x;
           opcMatrix[2][1] = zcol.y;
           opcMatrix[2][2] = zcol.z;
           opcMatrix[2][3] = 0.0f;
          
           opcMatrix[3][0] = pos.x;
           opcMatrix[3][1] = pos.y;
           opcMatrix[3][2] = pos.z;
           opcMatrix[3][3] = 1.0;
          
           }
          
           /// Converts from an Ogre's matrix4x4 into an IceMaths' one
      85   static void ogreToIceMatrix4(   const Ogre::Matrix4& ogreMatrix,   IceMaths::Matrix4x4& opcMatrix  )
           {
           for(  unsigned int i = 0; i < 4; i++ )
           {
           opcMatrix.m[0][i] = ogreMatrix[i][0];
           opcMatrix.m[1][i] = ogreMatrix[i][1];
           opcMatrix.m[2][i] = ogreMatrix[i][2];
           opcMatrix.m[3][i] = ogreMatrix[i][3];
           }
           }
          
           /// Converts from an Ogre's ray into an IceMaths' one
      97   static void ogreToIceRay(   const Ogre::Ray& from,   IceMaths::Ray& opcRay  )
           {
           opcRay.mOrig.x = from.getOrigin(   ).x;
           opcRay.mOrig.y = from.getOrigin(   ).y;
           opcRay.mOrig.z = from.getOrigin(   ).z;
          
           opcRay.mDir.x = from.getDirection(   ).x;
           opcRay.mDir.y = from.getDirection(   ).y;
           opcRay.mDir.z = from.getDirection(   ).z;
           opcRay.mDir.Normalize(   );
           }
          
           /// Converts from an Ogre's sphere into an IceMaths' one
     110   static void ogreToIceSphere(   const Ogre::Sphere& from,   IceMaths::Sphere& to  )
           {
           to.Set(   IceMaths::Point(  from.getCenter(   ).x,  from.getCenter(   ).y,  from.getCenter(   ).z ),   from.getRadius(   )  );
           }
          
           };
           } // namespace Details
          } // namespace OgreOpcode
          
          
          #endif // __OgreOpcodeUtils_h__

./components/ogre/ogreopcode/include/OgreOrientedBox.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOBB.h
          /// @brief This class represents an Oriented Bounding Box,   which is composed by
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOrientedBoundingBoxes_h__
          #define __OgreOrientedBoundingBoxes_h__
          
          #include "OgreOpcodeMath.h"
          
          namespace OgreOpcode
          {
           namespace Details
           {
           /// Defines an Oriented Bounding Box (  OBB ). Courtesy from Gilvan Maia :P
           /// Differently from AABB's (  Axis-Aligned Bounding-Boxes ),   OBBs are not
           /// limited to be aligned with the coordinate axes. Thus,   it can fit objects
           /// much more tightly just because it is adaptive to the object's orientation,  
           /// ie,   its orientation can be adjusted in order to reduce its volume - this is.
           /// why it would be preferred for collision detection.
           class _OgreOpcode_Export OrientedBox
           {
           public:
          
           /// Builds an unitary box at origin,   aligned with the coordinated axes.
      48   OrientedBox(   ):center(   ),  extents(  0.5,  0.5,  0.5 ),  rot(  Ogre::Matrix3::IDENTITY )
           {
           }
          
      52   OrientedBox(   const Details::bbox3& box  ):rot(  Ogre::Matrix3::IDENTITY )
           {
           extents = (  box.vmax - box.vmin )*0.5;
           center = box.vmin + extents;
           }
          
           /// Copy-constructor
      59   OrientedBox(  const OrientedBox& obb  ):center(  obb.center ),  extents(  obb.extents ),  rot(  obb.rot )
           {
           }
          
           /// "Complete" constructor
      64   OrientedBox(  const Ogre::Vector3& c,   const Ogre::Vector3& ex,   const Ogre::Matrix3& axes  ):center(  c ),  extents(  ex ),  rot(  axes )
           {
           }
          
           /// Gets the volume of this OBB
      69   inline Ogre::Real volume(   ) const
           {
           return extents.x *extents.y *extents.z * 8.0;
           }
          
           /// returns true if the given point is inside this box
      75   bool contains(  const Ogre::Vector3& point  ) const
           {
           Ogre::Vector3 L = point - center;
          
           Ogre::Real coord = rot.GetColumn(  0 ).dotProduct(   L  );
           if(   coord > extents.x || coord < -extents.x  ) return false;
          
           coord = rot.GetColumn(  1 ).dotProduct(   L  );
           if(   coord > extents.y || coord < -extents.y  ) return false;
          
           coord = rot.GetColumn(  2 ).dotProduct(   L  );
           if(   coord > extents.z || coord < -extents.z  ) return false;
          
           return true;
           }
          
           /** Checks intersection againts an Axis-Aligned Bounding Box
           */
      93   bool intersects(   const bbox3& box  ) const;
          
           /** Is this oriented box intersecting the given one?
           */
      97   bool intersects(   const OrientedBox& obb  ) const;
          
           /** Is this oriented box intersecting the given sphere?
           */
     101   bool intersects(   const sphere& s  )
           {
           // Modified from Magic-Software http://www.magic-software.com
           Ogre::Vector3 kCDiff = s.p - center;
          
           Ogre::Real fAx = Ogre::Math::Abs(  kCDiff.dotProduct(  rot.GetColumn(  0 ) )  );
           Ogre::Real fAy = Ogre::Math::Abs(  kCDiff.dotProduct(  rot.GetColumn(  1 ) )  );
           Ogre::Real fAz = Ogre::Math::Abs(  kCDiff.dotProduct(  rot.GetColumn(  2 ) )  );
           Ogre::Real fDx = fAx - extents.x;
           Ogre::Real fDy = fAy - extents.y;
           Ogre::Real fDz = fAz - extents.z;
          
           if (   fAx <= extents[0]  )
           {
           if (   fAy <= extents[1]  )
           {
           if (   fAz <= extents[2]  )
           // sphere center inside box
           return true;
           else
           // potential sphere-face intersection with face z
           return fDz <= s.r;
           }
           else
           {
           if (   fAz <= extents[2]  )
           // potential sphere-face intersection with face y
           return fDy <= s.r;
           else
           // potential sphere-edge intersection with edge formed
           // by faces y and z
           return fDy*fDy + fDz*fDz <= (  s.r*s.r );
           }
           }
           else
           {
           if (   fAy <= extents[1]  )
           {
           if (   fAz <= extents[2]  )
           // potential sphere-face intersection with face x
           return fDx <= s.r;
           else
           // potential sphere-edge intersection with edge formed
           // by faces x and z
           return fDx*fDx + fDz*fDz <= (  s.r*s.r );
           }
           else
           {
           if (   fAz <= extents[2]  )
           // potential sphere-edge intersection with edge formed
           // by faces x and y
           return fDx*fDx + fDy*fDy <= (  s.r*s.r );
           else
           // potential sphere-vertex intersection at corner formed
           // by faces x,  y,  z
           return fDx*fDx + fDy*fDy + fDz*fDz <= (  s.r*s.r );
           }
           }
           }
          
           /// Gets the extents of this oriented box
     162   const Ogre::Vector3& getExtents(   ) const
           {
           return extents;
           }
          
           /// Gets the center of this oriented box
     168   const Ogre::Vector3& getCenter(   ) const
           {
           return center;
           }
          
     173   const Ogre::Matrix3& getOrientation(   ) const
           {
           return rot;
           }
          
          
           public:
          
           /// Center of this box
           Ogre::Vector3 center;
          
           /// The extents of this box,   ie,   the semi-lengths of this box 0.5*(  width,  height,  depth  )
           Ogre::Vector3 extents;
          
           /// A rotation matrix describing the orientation of this box.
           /// Each of its collumns define the axes corresponding to the orientation of this box.
           Ogre::Matrix3 rot;
           };
          
           /// Just for ease of use,   let OrientedBox be an OBB. :P
           typedef OrientedBox OBB;
          
          
           } // namespace Details
          } // namespace OgreOpcode
          
          
          #endif // __OgreCollisionTypes_h__

./components/ogre/ogreopcode/include/OgrePtrCollisionShape.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgrePtrCollisionShape.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgrePtrCollisionShape_h__
          # define __OgrePtrCollisionShape_h__
          
          #include "OgreOpcodeExports.h"
          # include <Ogre.h>
          
          #include "IOgreCollisionShape.h"
          #include "OgreCollisionTypes.h"
          #include "OgreOpcodeDebugObject.h"
          #include "Opcode/Opcode.h"
          
          namespace OgreOpcode
          {
      41   class CollisionPair;
          
           /// Describes shapes for collision system.
           /// Holds a triangle list describing a collision shape.
           /// One PtrCollisionShape object may be shared between several
           /// CollisionObject%s. 2 PtrCollisionShape objects may also
           /// be queried directly whether they intersect.
           ///
           /// PtrCollisionShape objects are also able to load themselves
           /// from a mesh file.
           class _OgreOpcode_Export PtrCollisionShape : public ICollisionShape
           {
           public:
           /// Constructs a PtrCollisionShape
      55   PtrCollisionShape(  const Ogre::String& name );
           virtual ~PtrCollisionShape(   );
          
           /// Retrieve current vertex data from mesh and refit collision tree.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           virtual bool refit(   );
          
           /// load collide geometry from mesh,   and build a collision tree
           virtual bool load(  size_t numVertices,   size_t numIndices,   float *vertices,   size_t *indices );
          
           protected:
          
           /// Reload the collision geometry from mesh,   rebuild collision tree from scratch.
           /// Potentially very slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases RefitToMesh(   ) is sufficient,   and much faster.
           /// Under usual circumstances there is no need to call this method.
           virtual bool rebuild(   );
           /// Refits the collision tree to the currently cached vertex data.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the PtrCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _refitToCachedData(   );
           /// rebuild collision tree from scratch using currently cached vertex data
           /// This is potentially quite slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases _RefitToCachedGeometry(   ) is sufficient,   and much faster.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the PtrCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _rebuildFromCachedData(   );
          
           private:
           /// prevent default construction
           PtrCollisionShape(   );
          
           };
          
          }; // namespace OgreOpcode
          
          #endif // __OgreCollisionEntity_h__

./components/ogre/ogreopcode/include/OgreSphereMeshCollisionShape.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCollisionShape.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreSphereMeshCollisionShape_h__
          # define __OgreSphereMeshCollisionShape_h__
          
          #include "OgreOpcodeExports.h"
          # include <Ogre.h>
          
          #include "IOgreCollisionShape.h"
          #include "OgreCollisionTypes.h"
          #include "OgreOpcodeDebugObject.h"
          #include "Opcode/Opcode.h"
          
          namespace OgreOpcode
          {
      41   class CollisionPair;
          
           /// Describes shapes for collision system.
           /// Holds a triangle list describing a collision shape.
           /// One SphereMeshCollisionShape object may be shared between several
           /// CollisionObject%s. 2 SphereMeshCollisionShape objects may also
           /// be queried directly whether they intersect.
           ///
           /// SphereMeshCollisionShape objects are also able to load themselves
           /// from a mesh file.
           class _OgreOpcode_Export SphereMeshCollisionShape : public ICollisionShape
           {
           public:
           /// Constructs a SphereMeshCollisionShape
      55   SphereMeshCollisionShape(  const Ogre::String& name );
           virtual ~SphereMeshCollisionShape(   );
          
           /// load collide geometry from mesh,   and build a collision tree
           virtual bool load(  const Ogre::String& name,   Ogre::SceneNode* scnNode,   const float r,   const int nRings = 16,   const int nSegments = 16 );
          
           /// Retrieve current vertex data from mesh and refit collision tree.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           virtual bool refit(   );
          
           protected:
          
           /// Reload the collision geometry from mesh,   rebuild collision tree from scratch.
           /// Potentially very slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases RefitToMesh(   ) is sufficient,   and much faster.
           /// Under usual circumstances there is no need to call this method.
           virtual bool rebuild(   );
           /// Refits the collision tree to the currently cached vertex data.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the SphereMeshCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _refitToCachedData(   );
           /// rebuild collision tree from scratch using currently cached vertex data
           /// This is potentially quite slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases _RefitToCachedGeometry(   ) is sufficient,   and much faster.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the SphereMeshCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _rebuildFromCachedData(   );
          
           private:
           Ogre::Entity* mEntity;
          
           void createSphere(  const std::string& strName,   const float r,   const int nRings = 16,   const int nSegments = 16 );
           /// Count up the total number of vertices and indices in the Ogre mesh
           void countIndicesAndVertices(  Ogre::Entity * entity,   size_t & index_count,   size_t & vertex_count );
           /// Convert ogre Mesh to simple float and int arrays
           void convertMeshData(  Ogre::Entity * entity,   float * vertexData,   size_t vertex_count,   size_t * faceData=0,   size_t index_count=0 );
          
           /// prevent default construction
           SphereMeshCollisionShape(   );
          
           };
          
          }; // namespace OgreOpcode
          
          #endif // __OgreSphereMeshCollisionShape_h__

./components/ogre/ogreopcode/include/OgreTerrainCollisionShape.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreTerrainCollisionShape.h
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreTerrainCollisionShape_h__
          # define __OgreTerrainCollisionShape_h__
          
          #include "OgreOpcodeExports.h"
          # include <Ogre.h>
          
          #include "OgrePtrCollisionShape.h"
          #include "IOgreCollisionShape.h"
          #include "OgreCollisionTypes.h"
          #include "OgreOpcodeDebugObject.h"
          #include "Opcode/Opcode.h"
          
          namespace OgreOpcode
          {
      42   class CollisionPair;
          
           /// Describes shapes for collision system.
           /// Holds a triangle list describing a collision shape.
           /// One TerrainCollisionShape object may be shared between several
           /// CollisionObject%s. 2 TerrainCollisionShape objects may also
           /// be queried directly whether they intersect.
           ///
           /// TerrainCollisionShape objects are also able to load themselves
           /// from a mesh file.
           class _OgreOpcode_Export TerrainCollisionShape : public ICollisionShape
           {
           public:
           /// Constructs a TerrainCollisionShape
      56   TerrainCollisionShape(  const Ogre::String& name );
           virtual ~TerrainCollisionShape(   );
          
           /// Retrieve current vertex data from mesh and refit collision tree.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           virtual bool refit(   );
          
           /// load collide geometry from mesh,   and build a collision tree
           virtual bool load(  int numVertices,   float *vertices,   int verticesPerRow,   int rowCount );
          
           protected:
          
           /// Reload the collision geometry from mesh,   rebuild collision tree from scratch.
           /// Potentially very slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases RefitToMesh(   ) is sufficient,   and much faster.
           /// Under usual circumstances there is no need to call this method.
           virtual bool rebuild(   );
           /// Refits the collision tree to the currently cached vertex data.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the TerrainCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _refitToCachedData(   );
           /// rebuild collision tree from scratch using currently cached vertex data
           /// This is potentially quite slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases _RefitToCachedGeometry(   ) is sufficient,   and much faster.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the TerrainCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           virtual bool _rebuildFromCachedData(   );
          
           /// get tri coords from tri index
           virtual void getTriCoords(  int index,   Ogre::Vector3& v0,   Ogre::Vector3& v1,   Ogre::Vector3& v2 );
          
           /// visualize the collide shape
           virtual void visualize(  Details::OgreOpcodeDebugger* activeDebugger );
          
           private:
           /// prevent default construction
           TerrainCollisionShape(   );
          
           int mVerticesPerRow;
          
           // data populated from load function
           // in the future we may want access to this information via this class
           std::vector<float>* mHeightmapData;
           Ogre::Real mWidth;
           Ogre::Real mDepth;
           Ogre::Vector3 mOffset;
           Ogre::Vector3 mScale;
          
           };
          
           /// Extract triangle coordinates from triangle index.
           inline
           void
           TerrainCollisionShape::getTriCoords(  int index,   Ogre::Vector3& v0,   Ogre::Vector3& v1,   Ogre::Vector3& v2 )
           {
           //uint trisPerRow = (  (  mVerticesPerRow-1 )<<1 );
          
           //uint row = index / trisPerRow;
           //uint coll = index % trisPerRow;
           //uint i0 = row*mVerticesPerRow + (  coll>>1 );
          
           //// here we use a lookup table for a good tesselation
           //uint lookup[4][3] =
           //{
           // {0,  mVerticesPerRow+1,  1},   // case 0
           // {0,  mVerticesPerRow,  mVerticesPerRow+1},  // case 1
           // {mVerticesPerRow,  mVerticesPerRow+1,  1},  // case 2
           // {0,  mVerticesPerRow,  1} // case 3
           //};
          
           //// compute key into lookup table
           //uint key = (  row%2 ) ? (  coll%2 ) | (  (  i0%2 )<<1 ) : (  3- (  (  coll%2 ) | (  (  i0%2 )<<1 ) ) );
          
           //float* vp0 = &mVertexBuf[i0 +lookup[key][0]];
           //float* vp1 = &mVertexBuf[i0 +lookup[key][1]];
           //float* vp2 = &mVertexBuf[i0 +lookup[key][2]];
           float* vp0 = &mVertexBuf[index+0];
           float* vp1 = &mVertexBuf[index+1];
           float* vp2 = &mVertexBuf[index+2];
           v0 = Ogre::Vector3(  vp0[0],   vp0[1],   vp0[2] );
           v1 = Ogre::Vector3(  vp1[0],   vp1[1],   vp1[2] );
           v2 = Ogre::Vector3(  vp2[0],   vp2[1],   vp2[2] );
           }
          }; // namespace OgreOpcode
          
          #endif // __OgreTerrainCollisionShape_h__

./components/ogre/ogreopcode/include/OgreTriangle.h

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreTriangle.h
          /// @brief This class represents a Triangle,   which is composed by
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #ifndef __OgreOpcodeTriangle_h__
          #define __OgreOpcodeTriangle_h__
          
          namespace OgreOpcode
          {
           namespace Details
           {
           /// Represents a Triangle defined by three points (  vertices ).
           /// This class is <em>strongly</em> based on OPCODE's triangle class,   but is
           /// designed to work with Ogre's vectors and haves more utility methods.
           /// There are methods for computing distances and for intersection detection.
           /// Most code is inlined. INL files implementing the inlined methods can be added later,  
           /// allowing for easier reading of this class.
           class _OgreOpcode_Export Triangle
           {
           public:
          
           /** Fast,   but <em>unsafe</em> default constructor
           */
      47   Triangle(   ) { }
          
           /** Constructor
           */
      51   Triangle(   const Ogre::Vector3& p0,   const Ogre::Vector3& p1,   const Ogre::Vector3& p2  )
           {
           vertices[0] = p0;
           vertices[1] = p1;
           vertices[2] = p2;
           }
          
           /** Copy-constructor
           */
      60   Triangle(   const Triangle& tri  )
           {
           vertices[0] = tri.vertices[0];
           vertices[1] = tri.vertices[1];
           vertices[2] = tri.vertices[2];
           }
          
           /// Dummy destructor :P
      68   ~Triangle(   ) {}
          
           /** Flips the orientation of this triangle.
           */
      72   void flip(   )
           {
           Ogre::Vector3 temp = vertices[2];
           vertices[2] = vertices[1];
           vertices[1] = temp;
           }
          
           /** Computes the area of this triangle
           */
      81   Ogre::Real area(   ) const
           {
           const Ogre::Vector3& v0 = vertices[0];
           const Ogre::Vector3& v1 = vertices[1];
           const Ogre::Vector3& v2 = vertices[2];
          
           return (  v1 - v0 ).crossProduct(  (  v2 - v0 ) ).length(   ) * 0.5;
           }
          
           /** Computes the perimeter of this triangle
           */
      92   Ogre::Real perimeter(   ) const
           {
           Ogre::Vector3 d0 = vertices[0] - vertices[1];
           Ogre::Vector3 d1 = vertices[1] - vertices[2];
           Ogre::Vector3 d2 = vertices[2] - vertices[0];
          
           return d0.length(   ) + d1.length(   ) + d2.length(   );
           }
          
           /** Computes the normal of this triangle.
           * @param N Output vector to hold the computed normal
           * @param normalize Boolean flag telling whether the normal must be normalized
           */
     105   void normal(   Ogre::Vector3& N,   bool normalize = true  ) const
           {
           const Ogre::Vector3& v0 = vertices[0];
           const Ogre::Vector3& v1 = vertices[1];
           const Ogre::Vector3& v2 = vertices[2];
          
           N = (  v1 - v0 ).crossProduct(  (  v2 - v0 ) );
          
           // normalizes the vector,   if required
           if(   normalize  )
           N.normalise(   );
           }
          
           /** Computes the center of this triangle
           * @param center Output vector parameter to hold the result
           */
     121   void center(   Ogre::Vector3& center  ) const
           {
           center = (  vertices[0] + vertices[1] + vertices[2] )/3.0;
           }
          
           /** Gets the plane where this triangle lies on.
           * @param plane Output parameter
           */
     129   Ogre::Plane plane(   ) const
           {
           return Ogre::Plane(  vertices[0],  vertices[1],  vertices[2] );
           };
          
           /** Gets the point with given baricentric uv coordinates
           */
     136   Ogre::Vector3 getPoint(   Ogre::Real U,   Ogre::Real V  ) const
           {
           const Ogre::Vector3& v0 = vertices[0];
           const Ogre::Vector3& v1 = vertices[1];
           const Ogre::Vector3& v2 = vertices[2];
          
           // convex combination
           return (  1.0 - U - V )*v0 + U*v1 + V*v2;
           }
          
           /** Inflates this triangle in order to produce a larger one with the same center
           * @param rate The rate this triangle will be inflated.
           * @param isRelative When this flag is set to true,   the triangle will be inflated
           * proportional to its size.
           */
     151   void inflate(   Ogre::Real rate,   bool isRelative = false  )
           {
           Ogre::Vector3 center = (  vertices[0] + vertices[1] + vertices[2] )/3.0;
          
           for(   int i=0;i<3;++i )
           {
           Ogre::Vector3 delta = vertices[i] - center;
           if(   !isRelative  )
           delta.normalise(   );
          
           vertices[i] += rate*delta;
           }
           }
          
           /** Computes the <em>squared</em> distance from this triangle to a given point
           * @remarks Follows code from Magic-Software at http://www.magic-software.com
           */
     168   Ogre::Real squaredDistance(   const Ogre::Vector3& point  ) const;
          
           /** Computes the distance from this triangle to a given point
           */
     172   Ogre::Real distance(   const Ogre::Vector3& point  ) const
           {
           return Ogre::Math::Sqrt(   squaredDistance(  point )  );
           }
          
           /** Checks collision against a sphere.
           * @param center The sphere's center
           * @param radius The sphere's radius
           */
     181   bool overlapsSphere(   const Ogre::Vector3& center,   Ogre::Real radius  )
           {
           return squaredDistance(  center ) <= radius*radius;
           }
          
           /// The three vertices defining this triangle
           Ogre::Vector3 vertices[3];
           };
           }
          }
          
          #endif

./components/ogre/ogreopcode/include/Opcode/Ice/IceAABB.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains AABB-related code. (  axis-aligned bounding box )
           * \file IceAABB.h
           * \author Pierre Terdiman
           * \date January,   13,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEAABB_H__
          #define __ICEAABB_H__
          
           // Forward declarations
      16   class Sphere;
          
          //! Declarations of type-independent methods (  most of them implemented in the .cpp )
          #define AABB_COMMON_METHODS \
      20   AABB& Add(  const AABB& aabb ); \
      21   float MakeCube(  AABB& cube ) const; \
      22   void MakeSphere(  Sphere& sphere ) const; \
      23   const sbyte* ComputeOutline(  const Point& local_eye,   sdword& num ) const; \
      24   float ComputeBoxArea(  const Point& eye,   const Matrix4x4& mat,   float width,   float height,   sdword& num ) const; \
      25   bool IsInside(  const AABB& box ) const; \
      26   bool ComputePlanes(  Plane* planes ) const; \
      27   bool ComputePoints(  Point* pts ) const; \
      28   const Point* GetVertexNormals(   ) const; \
      29   const udword* GetEdges(   ) const; \
      30   const Point* GetEdgeNormals(   ) const; \
           inline_ BOOL ContainsPoint(  const Point& p ) const \
           { \
      33   if(  p.x > GetMax(  0 ) || p.x < GetMin(  0 ) ) return FALSE; \
      34   if(  p.y > GetMax(  1 ) || p.y < GetMin(  1 ) ) return FALSE; \
      35   if(  p.z > GetMax(  2 ) || p.z < GetMin(  2 ) ) return FALSE; \
           return TRUE; \
           }
          
           enum AABBType
           {
           AABB_RENDER = 0,   //!< AABB used for rendering. Not visible == not rendered.
           AABB_UPDATE = 1,   //!< AABB used for dynamic updates. Not visible == not updated.
          
           AABB_FORCE_DWORD = 0x7fffffff,  
           };
          
          #ifdef USE_MINMAX
          
           struct ShadowAABB
           {
           Point mMin;
           Point mMax;
           };
          
           class AABB
           {
           public:
           //! Constructor
           inline_ AABB(   ) {}
           //! Destructor
           inline_ ~AABB(   ) {}
          
           //! Type-independent methods
           AABB_COMMON_METHODS;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups an AABB from min & max vectors.
           * \param min [in] the min point
           * \param max [in] the max point
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void SetMinMax(  const Point& min,   const Point& max ) { mMin = min; mMax = max; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups an AABB from center & extents vectors.
           * \param c [in] the center point
           * \param e [in] the extents vector
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void SetCenterExtents(  const Point& c,   const Point& e ) { mMin = c - e; mMax = c + e; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups an empty AABB.
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void SetEmpty(   ) { Point p(  MIN_FLOAT,   MIN_FLOAT,   MIN_FLOAT ); mMin = -p; mMax = p;}
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups a point AABB.
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void SetPoint(  const Point& pt ) { mMin = mMax = pt; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the size of the AABB. The size is defined as the longest extent.
           * \return the size of the AABB
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           float GetSize(   ) const { Point e; GetExtents(  e ); return e.Max(   ); }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Extends the AABB.
           * \param p [in] the next point
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void Extend(  const Point& p )
           {
           if(  p.x > mMax.x ) mMax.x = p.x;
           if(  p.x < mMin.x ) mMin.x = p.x;
          
           if(  p.y > mMax.y ) mMax.y = p.y;
           if(  p.y < mMin.y ) mMin.y = p.y;
          
           if(  p.z > mMax.z ) mMax.z = p.z;
           if(  p.z < mMin.z ) mMin.z = p.z;
           }
           // Data access
          
           //! Get min point of the box
           inline_ void GetMin(  Point& min ) const { min = mMin; }
           //! Get max point of the box
           inline_ void GetMax(  Point& max ) const { max = mMax; }
          
           //! Get component of the box's min point along a given axis
           inline_ float GetMin(  udword axis ) const { return mMin[axis]; }
           //! Get component of the box's max point along a given axis
           inline_ float GetMax(  udword axis ) const { return mMax[axis]; }
          
           //! Get box center
           inline_ void GetCenter(  Point& center ) const { center = (  mMax + mMin )*0.5f; }
           //! Get box extents
           inline_ void GetExtents(  Point& extents ) const { extents = (  mMax - mMin )*0.5f; }
          
           //! Get component of the box's center along a given axis
           inline_ float GetCenter(  udword axis ) const { return (  mMax[axis] + mMin[axis] )*0.5f; }
           //! Get component of the box's extents along a given axis
           inline_ float GetExtents(  udword axis ) const { return (  mMax[axis] - mMin[axis] )*0.5f; }
          
           //! Get box diagonal
           inline_ void GetDiagonal(  Point& diagonal ) const { diagonal = mMax - mMin; }
           inline_ float GetWidth(   ) const { return mMax.x - mMin.x; }
           inline_ float GetHeight(   ) const { return mMax.y - mMin.y; }
           inline_ float GetDepth(   ) const { return mMax.z - mMin.z; }
          
           //! Volume
           inline_ float GetVolume(   ) const { return GetWidth(   ) * GetHeight(   ) * GetDepth(   ); }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes the intersection between two AABBs.
           * \param a [in] the other AABB
           * \return true on intersection
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL Intersect(  const AABB& a ) const
           {
           if(  mMax.x < a.mMin.x
           || a.mMax.x < mMin.x
           || mMax.y < a.mMin.y
           || a.mMax.y < mMin.y
           || mMax.z < a.mMin.z
           || a.mMax.z < mMin.z ) return FALSE;
          
           return TRUE;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes the 1D-intersection between two AABBs,   on a given axis.
           * \param a [in] the other AABB
           * \param axis [in] the axis (  0,   1,   2 )
           * \return true on intersection
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL Intersect(  const AABB& a,   udword axis ) const
           {
           if(  mMax[axis] < a.mMin[axis] || a.mMax[axis] < mMin[axis] ) return FALSE;
           return TRUE;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Recomputes the AABB after an arbitrary transform by a 4x4 matrix.
           * Original code by Charles Bloom on the GD-Algorithm list. (  I slightly modified it )
           * \param mtx [in] the transform matrix
           * \param aabb [out] the transformed AABB [can be *this]
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void Rotate(  const Matrix4x4& mtx,   AABB& aabb ) const
           {
           // The three edges transformed: you can efficiently transform an X-only vector
           // by just getting the "X" column of the matrix
           Point vx,  vy,  vz;
           mtx.GetRow(  0,   vx ); vx *= (  mMax.x - mMin.x );
           mtx.GetRow(  1,   vy ); vy *= (  mMax.y - mMin.y );
           mtx.GetRow(  2,   vz ); vz *= (  mMax.z - mMin.z );
          
           // Transform the min point
           aabb.mMin = aabb.mMax = mMin * mtx;
          
           // Take the transformed min & axes and find new extents
           // Using CPU code in the right place is faster...
           if(  IS_NEGATIVE_FLOAT(  vx.x ) ) aabb.mMin.x += vx.x; else aabb.mMax.x += vx.x;
           if(  IS_NEGATIVE_FLOAT(  vx.y ) ) aabb.mMin.y += vx.y; else aabb.mMax.y += vx.y;
           if(  IS_NEGATIVE_FLOAT(  vx.z ) ) aabb.mMin.z += vx.z; else aabb.mMax.z += vx.z;
           if(  IS_NEGATIVE_FLOAT(  vy.x ) ) aabb.mMin.x += vy.x; else aabb.mMax.x += vy.x;
           if(  IS_NEGATIVE_FLOAT(  vy.y ) ) aabb.mMin.y += vy.y; else aabb.mMax.y += vy.y;
           if(  IS_NEGATIVE_FLOAT(  vy.z ) ) aabb.mMin.z += vy.z; else aabb.mMax.z += vy.z;
           if(  IS_NEGATIVE_FLOAT(  vz.x ) ) aabb.mMin.x += vz.x; else aabb.mMax.x += vz.x;
           if(  IS_NEGATIVE_FLOAT(  vz.y ) ) aabb.mMin.y += vz.y; else aabb.mMax.y += vz.y;
           if(  IS_NEGATIVE_FLOAT(  vz.z ) ) aabb.mMin.z += vz.z; else aabb.mMax.z += vz.z;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks the AABB is valid.
           * \return true if the box is valid
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL IsValid(   ) const
           {
           // Consistency condition for (  Min,   Max ) boxes: min < max
           if(  mMin.x > mMax.x ) return FALSE;
           if(  mMin.y > mMax.y ) return FALSE;
           if(  mMin.z > mMax.z ) return FALSE;
           return TRUE;
           }
          
           //! Operator for AABB *= float. Scales the extents,   keeps same center.
           inline_ AABB& operator*=(  float s )
           {
           Point Center; GetCenter(  Center );
           Point Extents; GetExtents(  Extents );
           SetCenterExtents(  Center,   Extents * s );
           return *this;
           }
          
           //! Operator for AABB /= float. Scales the extents,   keeps same center.
           inline_ AABB& operator/=(  float s )
           {
           Point Center; GetCenter(  Center );
           Point Extents; GetExtents(  Extents );
           SetCenterExtents(  Center,   Extents / s );
           return *this;
           }
          
           //! Operator for AABB += Point. Translates the box.
           inline_ AABB& operator+=(  const Point& trans )
           {
           mMin+=trans;
           mMax+=trans;
           return *this;
           }
           private:
           Point mMin; //!< Min point
           Point mMax; //!< Max point
           };
          
          #else
          
           class AABB
           {
           public:
           //! Constructor
           inline_ AABB(   ) {}
           //! Destructor
           inline_ ~AABB(   ) {}
          
           //! Type-independent methods
           AABB_COMMON_METHODS;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups an AABB from min & max vectors.
           * \param min [in] the min point
           * \param max [in] the max point
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void SetMinMax(  const Point& min,   const Point& max ) { mCenter = (  max + min )*0.5f; mExtents = (  max - min )*0.5f; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups an AABB from center & extents vectors.
           * \param c [in] the center point
           * \param e [in] the extents vector
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void SetCenterExtents(  const Point& c,   const Point& e ) { mCenter = c; mExtents = e; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups an empty AABB.
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void SetEmpty(   ) { mCenter.Zero(   ); mExtents.Set(  MIN_FLOAT,   MIN_FLOAT,   MIN_FLOAT );}
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups a point AABB.
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void SetPoint(  const Point& pt ) { mCenter = pt; mExtents.Zero(   ); }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the size of the AABB. The size is defined as the longest extent.
           * \return the size of the AABB
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           float GetSize(   ) const { return mExtents.Max(   ); }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Extends the AABB.
           * \param p [in] the next point
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           void Extend(  const Point& p )
           {
           Point Max = mCenter + mExtents;
           Point Min = mCenter - mExtents;
          
           if(  p.x > Max.x ) Max.x = p.x;
           if(  p.x < Min.x ) Min.x = p.x;
          
           if(  p.y > Max.y ) Max.y = p.y;
           if(  p.y < Min.y ) Min.y = p.y;
          
           if(  p.z > Max.z ) Max.z = p.z;
           if(  p.z < Min.z ) Min.z = p.z;
          
           SetMinMax(  Min,   Max );
           }
           // Data access
          
           //! Get min point of the box
           inline_ void GetMin(  Point& min ) const { min = mCenter - mExtents; }
           //! Get max point of the box
           inline_ void GetMax(  Point& max ) const { max = mCenter + mExtents; }
          
           //! Get component of the box's min point along a given axis
           inline_ float GetMin(  udword axis ) const { return mCenter[axis] - mExtents[axis]; }
           //! Get component of the box's max point along a given axis
           inline_ float GetMax(  udword axis ) const { return mCenter[axis] + mExtents[axis]; }
          
           //! Get box center
           inline_ void GetCenter(  Point& center ) const { center = mCenter; }
           //! Get box extents
           inline_ void GetExtents(  Point& extents ) const { extents = mExtents; }
          
           //! Get component of the box's center along a given axis
           inline_ float GetCenter(  udword axis ) const { return mCenter[axis]; }
           //! Get component of the box's extents along a given axis
           inline_ float GetExtents(  udword axis ) const { return mExtents[axis]; }
          
           //! Get box diagonal
           inline_ void GetDiagonal(  Point& diagonal ) const { diagonal = mExtents * 2.0f; }
           inline_ float GetWidth(   ) const { return mExtents.x * 2.0f; }
           inline_ float GetHeight(   ) const { return mExtents.y * 2.0f; }
           inline_ float GetDepth(   ) const { return mExtents.z * 2.0f; }
          
           //! Volume
           inline_ float GetVolume(   ) const { return mExtents.x * mExtents.y * mExtents.z * 8.0f; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes the intersection between two AABBs.
           * \param a [in] the other AABB
           * \return true on intersection
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL Intersect(  const AABB& a ) const
           {
           float tx = mCenter.x - a.mCenter.x; float ex = a.mExtents.x + mExtents.x; if(  AIR(  tx ) > IR(  ex ) ) return FALSE;
           float ty = mCenter.y - a.mCenter.y; float ey = a.mExtents.y + mExtents.y; if(  AIR(  ty ) > IR(  ey ) ) return FALSE;
           float tz = mCenter.z - a.mCenter.z; float ez = a.mExtents.z + mExtents.z; if(  AIR(  tz ) > IR(  ez ) ) return FALSE;
           return TRUE;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * The standard intersection method from Gamasutra. Just here to check its speed against the one above.
           * \param a [in] the other AABB
           * \return true on intersection
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ bool GomezIntersect(  const AABB& a )
           {
           Point T = mCenter - a.mCenter; // Vector from A to B
           return (  (  fabsf(  T.x ) <= (  a.mExtents.x + mExtents.x ) )
           && (  fabsf(  T.y ) <= (  a.mExtents.y + mExtents.y ) )
           && (  fabsf(  T.z ) <= (  a.mExtents.z + mExtents.z ) ) );
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes the 1D-intersection between two AABBs,   on a given axis.
           * \param a [in] the other AABB
           * \param axis [in] the axis (  0,   1,   2 )
           * \return true on intersection
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL Intersect(  const AABB& a,   udword axis ) const
           {
           float t = mCenter[axis] - a.mCenter[axis];
           float e = a.mExtents[axis] + mExtents[axis];
           if(  AIR(  t ) > IR(  e ) ) return FALSE;
           return TRUE;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Recomputes the AABB after an arbitrary transform by a 4x4 matrix.
           * \param mtx [in] the transform matrix
           * \param aabb [out] the transformed AABB [can be *this]
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void Rotate(  const Matrix4x4& mtx,   AABB& aabb ) const
           {
           // Compute new center
           aabb.mCenter = mCenter * mtx;
          
           // Compute new extents. FPU code & CPU code have been interleaved for improved performance.
           Point Ex(  mtx.m[0][0] * mExtents.x,   mtx.m[0][1] * mExtents.x,   mtx.m[0][2] * mExtents.x );
           IR(  Ex.x )&=0x7fffffff; IR(  Ex.y )&=0x7fffffff; IR(  Ex.z )&=0x7fffffff;
          
           Point Ey(  mtx.m[1][0] * mExtents.y,   mtx.m[1][1] * mExtents.y,   mtx.m[1][2] * mExtents.y );
           IR(  Ey.x )&=0x7fffffff; IR(  Ey.y )&=0x7fffffff; IR(  Ey.z )&=0x7fffffff;
          
           Point Ez(  mtx.m[2][0] * mExtents.z,   mtx.m[2][1] * mExtents.z,   mtx.m[2][2] * mExtents.z );
           IR(  Ez.x )&=0x7fffffff; IR(  Ez.y )&=0x7fffffff; IR(  Ez.z )&=0x7fffffff;
          
           aabb.mExtents.x = Ex.x + Ey.x + Ez.x;
           aabb.mExtents.y = Ex.y + Ey.y + Ez.y;
           aabb.mExtents.z = Ex.z + Ey.z + Ez.z;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks the AABB is valid.
           * \return true if the box is valid
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL IsValid(   ) const
           {
           // Consistency condition for (  Center,   Extents ) boxes: Extents >= 0
           if(  IS_NEGATIVE_FLOAT(  mExtents.x ) ) return FALSE;
           if(  IS_NEGATIVE_FLOAT(  mExtents.y ) ) return FALSE;
           if(  IS_NEGATIVE_FLOAT(  mExtents.z ) ) return FALSE;
           return TRUE;
           }
          
           //! Operator for AABB *= float. Scales the extents,   keeps same center.
           inline_ AABB& operator*=(  float s ) { mExtents*=s; return *this; }
          
           //! Operator for AABB /= float. Scales the extents,   keeps same center.
           inline_ AABB& operator/=(  float s ) { mExtents/=s; return *this; }
          
           //! Operator for AABB += Point. Translates the box.
           inline_ AABB& operator+=(  const Point& trans )
           {
           mCenter+=trans;
           return *this;
           }
           private:
           Point mCenter; //!< AABB Center
           Point mExtents; //!< x,   y and z extents
           };
          
          #endif
          
           inline_ void ComputeMinMax(  const Point& p,   Point& min,   Point& max )
           {
           if(  p.x > max.x ) max.x = p.x;
           if(  p.x < min.x ) min.x = p.x;
          
           if(  p.y > max.y ) max.y = p.y;
           if(  p.y < min.y ) min.y = p.y;
          
           if(  p.z > max.z ) max.z = p.z;
           if(  p.z < min.z ) min.z = p.z;
           }
          
           inline_ void ComputeAABB(  AABB& aabb,   const Point* list,   udword nb_pts )
           {
           if(  list )
           {
           Point Maxi(  MIN_FLOAT,   MIN_FLOAT,   MIN_FLOAT );
           Point Mini(  MAX_FLOAT,   MAX_FLOAT,   MAX_FLOAT );
           while(  nb_pts-- )
           {
          // _prefetch(  list+1 ); // off by one ?
           ComputeMinMax(  *list++,   Mini,   Maxi );
           }
           aabb.SetMinMax(  Mini,   Maxi );
           }
           }
          
          #endif // __ICEAABB_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceAxes.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains axes definition.
           * \file IceAxes.h
           * \author Pierre Terdiman
           * \date January,   29,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEAXES_H__
          #define __ICEAXES_H__
          
           enum PointComponent
           {
           _X = 0,  
           _Y = 1,  
           _Z = 2,  
           _W = 3,  
          
           _FORCE_DWORD = 0x7fffffff
           };
          
           enum AxisOrder
           {
           AXES_XYZ = (  _X )|(  _Y<<2 )|(  _Z<<4 ),  
           AXES_XZY = (  _X )|(  _Z<<2 )|(  _Y<<4 ),  
           AXES_YXZ = (  _Y )|(  _X<<2 )|(  _Z<<4 ),  
           AXES_YZX = (  _Y )|(  _Z<<2 )|(  _X<<4 ),  
           AXES_ZXY = (  _Z )|(  _X<<2 )|(  _Y<<4 ),  
           AXES_ZYX = (  _Z )|(  _Y<<2 )|(  _X<<4 ),  
          
           AXES_FORCE_DWORD = 0x7fffffff
           };
          
      37   class Axes
           {
           public:
          
      41   inline_ Axes(  AxisOrder order )
           {
           mAxis0 = (  order  ) & 3;
           mAxis1 = (  order>>2 ) & 3;
           mAxis2 = (  order>>4 ) & 3;
           }
      47   inline_ ~Axes(   ) {}
          
      49   udword mAxis0;
      50   udword mAxis1;
      51   udword mAxis2;
           };
          
          #endif // __ICEAXES_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceBoundingSphere.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code to compute the minimal bounding sphere.
           * \file IceBoundingSphere.h
           * \author Pierre Terdiman
           * \date January,   29,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEBOUNDINGSPHERE_H__
          #define __ICEBOUNDINGSPHERE_H__
          
           enum BSphereMethod
           {
           BS_NONE,  
           BS_GEMS,  
           BS_MINIBALL,  
          
           BS_FORCE_DWORD = 0x7fffffff
           };
          
      24   class Sphere
           {
           public:
           //! Constructor
      28   inline_ Sphere(   ) {}
           //! Constructor
      30   inline_ Sphere(  const Point& center,   float radius ) : mCenter(  center ),   mRadius(  radius ) {}
           //! Constructor
      32   Sphere(  udword nb_verts,   const Point* verts );
           //! Copy constructor
      34   inline_ Sphere(  const Sphere& sphere ) : mCenter(  sphere.mCenter ),   mRadius(  sphere.mRadius ) {}
           //! Destructor
      36   inline_ ~Sphere(   ) {}
          
      38   BSphereMethod Compute(  udword nb_verts,   const Point* verts );
      39   bool FastCompute(  udword nb_verts,   const Point* verts );
          
           // Access methods
           inline_ const Point& GetCenter(   ) const { return mCenter; }
      43   inline_ float GetRadius(   ) const { return mRadius; }
          
      45   inline_ const Point& Center(   ) const { return mCenter; }
      46   inline_ float Radius(   ) const { return mRadius; }
          
      48   inline_ Sphere& Set(  const Point& center,   float radius ) { mCenter = center; mRadius = radius; return *this; }
           inline_ Sphere& SetCenter(  const Point& center ) { mCenter = center; return *this; }
           inline_ Sphere& SetRadius(  float radius ) { mRadius = radius; return *this; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Tests if a point is contained within the sphere.
           * \param p [in] the point to test
           * \return true if inside the sphere
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ bool Contains(  const Point& p ) const
           {
           return mCenter.SquareDistance(  p ) <= mRadius*mRadius;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Tests if a sphere is contained within the sphere.
           * \param sphere [in] the sphere to test
           * \return true if inside the sphere
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ bool Contains(  const Sphere& sphere ) const
           {
           // If our radius is the smallest,   we can't possibly contain the other sphere
           if(  mRadius < sphere.mRadius ) return false;
           // So r is always positive or null now
           float r = mRadius - sphere.mRadius;
           return mCenter.SquareDistance(  sphere.mCenter ) <= r*r;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Tests if a box is contained within the sphere.
           * \param aabb [in] the box to test
           * \return true if inside the sphere
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL Contains(  const AABB& aabb ) const
           {
           // I assume if all 8 box vertices are inside the sphere,   so does the whole box.
           // Sounds ok but maybe there's a better way?
           float R2 = mRadius * mRadius;
          #ifdef USE_MIN_MAX
           const Point& Max = (  (  ShadowAABB& )&aabb ).mMax;
           const Point& Min = (  (  ShadowAABB& )&aabb ).mMin;
          #else
           Point Max; aabb.GetMax(  Max );
           Point Min; aabb.GetMin(  Min );
          #endif
           Point p;
           p.x=Max.x; p.y=Max.y; p.z=Max.z; if(  mCenter.SquareDistance(  p )>=R2 ) return FALSE;
           p.x=Min.x; if(  mCenter.SquareDistance(  p )>=R2 ) return FALSE;
           p.x=Max.x; p.y=Min.y; if(  mCenter.SquareDistance(  p )>=R2 ) return FALSE;
           p.x=Min.x; if(  mCenter.SquareDistance(  p )>=R2 ) return FALSE;
           p.x=Max.x; p.y=Max.y; p.z=Min.z; if(  mCenter.SquareDistance(  p )>=R2 ) return FALSE;
           p.x=Min.x; if(  mCenter.SquareDistance(  p )>=R2 ) return FALSE;
           p.x=Max.x; p.y=Min.y; if(  mCenter.SquareDistance(  p )>=R2 ) return FALSE;
           p.x=Min.x; if(  mCenter.SquareDistance(  p )>=R2 ) return FALSE;
          
           return TRUE;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Tests if the sphere intersects another sphere
           * \param sphere [in] the other sphere
           * \return true if spheres overlap
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ bool Intersect(  const Sphere& sphere ) const
           {
           float r = mRadius + sphere.mRadius;
           return mCenter.SquareDistance(  sphere.mCenter ) <= r*r;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks the sphere is valid.
           * \return true if the box is valid
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL IsValid(   ) const
           {
           // Consistency condition for spheres: Radius >= 0.0f
           if(  mRadius < 0.0f ) return FALSE;
           return TRUE;
           }
           public:
           Point mCenter; //!< Sphere center
           float mRadius; //!< Sphere radius
           };
          
          #endif // __ICEBOUNDINGSPHERE_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceContainer.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a simple container class.
           * \file IceContainer.h
           * \author Pierre Terdiman
           * \date February,   5,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICECONTAINER_H__
          #define __ICECONTAINER_H__
          
           #define CONTAINER_STATS
          
           enum FindMode
           {
           FIND_CLAMP,  
           FIND_WRAP,  
          
           FIND_FORCE_DWORD = 0x7fffffff
           };
          
      25   class Container
           {
           public:
           // Constructor / Destructor
      29   Container(   );
      30   Container(  const Container& object );
      31   Container(  udword size,   float growth_factor );
      32   ~Container(   );
           // Management
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * A O(  1 ) method to add a value in the container. The container is automatically resized if needed.
           * The method is inline,   not the resize. The call overhead happens on resizes only,   which is not a problem since the resizing operation
           * costs a lot more than the call overhead...
           *
           * \param entry [in] a udword to store in the container
           * \see Add(  float entry )
           * \see Empty(   )
           * \see Contains(  udword entry )
           * \return Self-Reference
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ Container& Add(  udword entry )
           {
           // Resize if needed
           if(  mCurNbEntries==mMaxNbEntries ) Resize(   );
          
           // Add new entry
           mEntries[mCurNbEntries++] = entry;
           return *this;
           }
          
      57   inline_ Container& Add(  const udword* entries,   udword nb )
           {
           // Resize if needed
           if(  mCurNbEntries+nb>mMaxNbEntries ) Resize(  nb );
          
           // Add new entry
           CopyMemory(  &mEntries[mCurNbEntries],   entries,   nb*sizeof(  udword ) );
           mCurNbEntries+=nb;
           return *this;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * A O(  1 ) method to add a value in the container. The container is automatically resized if needed.
           * The method is inline,   not the resize. The call overhead happens on resizes only,   which is not a problem since the resizing operation
           * costs a lot more than the call overhead...
           *
           * \param entry [in] a float to store in the container
           * \see Add(  udword entry )
           * \see Empty(   )
           * \see Contains(  udword entry )
           * \return Self-Reference
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ Container& Add(  float entry )
           {
           // Resize if needed
      84   if(  mCurNbEntries==mMaxNbEntries ) Resize(   );
          
           // Add new entry
      87   mEntries[mCurNbEntries++] = IR(  entry );
           return *this;
           }
          
           inline_ Container& Add(  const float* entries,   udword nb )
           {
           // Resize if needed
           if(  mCurNbEntries+nb>mMaxNbEntries ) Resize(  nb );
          
           // Add new entry
           CopyMemory(  &mEntries[mCurNbEntries],   entries,   nb*sizeof(  float ) );
           mCurNbEntries+=nb;
           return *this;
           }
          
           //! Add unique [slow]
           inline_ Container& AddUnique(  udword entry )
           {
           if(  !Contains(  entry ) ) Add(  entry );
           return *this;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Clears the container. All stored values are deleted,   and it frees used ram.
           * \see Reset(   )
           * \return Self-Reference
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           Container& Empty(   );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Resets the container. Stored values are discarded but the buffer is kept so that further calls don't need resizing again.
           * That's a kind of temporal coherence.
           * \see Empty(   )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void Reset(   )
           {
           // Avoid the write if possible
           // ### CMOV
           if(  mCurNbEntries ) mCurNbEntries = 0;
           }
          
           // HANDLE WITH CARE
           inline_ void ForceSize(  udword size )
           {
           mCurNbEntries = size;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Sets the initial size of the container. If it already contains something,   it's discarded.
           * \param nb [in] Number of entries
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           bool SetSize(  udword nb );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Refits the container and get rid of unused bytes.
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           bool Refit(   );
          
           // Checks whether the container already contains a given value.
           bool Contains(  udword entry,   udword* location=null ) const;
           // Deletes an entry - doesn't preserve insertion order.
           bool Delete(  udword entry );
           // Deletes an entry - does preserve insertion order.
           bool DeleteKeepingOrder(  udword entry );
           //! Deletes the very last entry.
           inline_ void DeleteLastEntry(   ) { if(  mCurNbEntries ) mCurNbEntries--; }
           //! Deletes the entry whose index is given
           inline_ void DeleteIndex(  udword index ) { mEntries[index] = mEntries[--mCurNbEntries]; }
          
           // Helpers
           Container& FindNext(  udword& entry,   FindMode find_mode=FIND_CLAMP );
           Container& FindPrev(  udword& entry,   FindMode find_mode=FIND_CLAMP );
           // Data access.
           inline_ udword GetNbEntries(   ) const { return mCurNbEntries; } //!< Returns the current number of entries.
           inline_ udword GetEntry(  udword i ) const { return mEntries[i]; } //!< Returns ith entry
           inline_ udword* GetEntries(   ) const { return mEntries; } //!< Returns the list of entries.
          
           inline_ udword GetFirst(   ) const { return mEntries[0]; }
           inline_ udword GetLast(   ) const { return mEntries[mCurNbEntries-1]; }
          
           // Growth control
           inline_ float GetGrowthFactor(   ) const { return mGrowthFactor; } //!< Returns the growth factor
           inline_ void SetGrowthFactor(  float growth ) { mGrowthFactor = growth; } //!< Sets the growth factor
           inline_ bool IsFull(   ) const { return mCurNbEntries==mMaxNbEntries; } //!< Checks the container is full
           inline_ BOOL IsNotEmpty(   ) const { return mCurNbEntries; } //!< Checks the container is empty
          
           //! Read-access as an array
           inline_ udword operator[](  udword i ) const { ASSERT(  i>=0 && i<mCurNbEntries ); return mEntries[i]; }
           //! Write-access as an array
           inline_ udword& operator[](  udword i ) { ASSERT(  i>=0 && i<mCurNbEntries ); return mEntries[i]; }
          
           // Stats
           udword GetUsedRam(   ) const;
          
           //! Operator for "Container A = Container B"
           void operator = (  const Container& object );
          
          #ifdef CONTAINER_STATS
           inline_ udword GetNbContainers(   ) const { return mNbContainers; }
           inline_ udword GetTotalBytes(   ) const { return mUsedRam; }
           private:
          
           static udword mNbContainers; //!< Number of containers around
           static udword mUsedRam; //!< Amount of bytes used by containers in the system
          #endif
           private:
           // Resizing
           bool Resize(  udword needed=1 );
           // Data
           udword mMaxNbEntries; //!< Maximum possible number of entries
           udword mCurNbEntries; //!< Current number of entries
           udword* mEntries; //!< List of entries
           float mGrowthFactor; //!< Resize: new number of entries = old number * mGrowthFactor
           };
          
          #endif // __ICECONTAINER_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceFPU.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains FPU related code.
           * \file IceFPU.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEFPU_H__
          #define __ICEFPU_H__
          
           #define SIGN_BITMASK 0x80000000
          
           //! Integer representation of a floating-point value.
           #define IR(  x ) (  (  udword& )(  x ) )
          
           //! Signed integer representation of a floating-point value.
           #define SIR(  x ) (  (  sdword& )(  x ) )
          
           //! Absolute integer representation of a floating-point value
           #define AIR(  x ) (  IR(  x )&0x7fffffff )
          
           //! Floating-point representation of an integer value.
           #define FR(  x ) (  (  float& )(  x ) )
          
           //! Integer-based comparison of a floating point value.
           //! Don't use it blindly,   it can be faster or slower than the FPU comparison,   depends on the context.
           #define IS_NEGATIVE_FLOAT(  x ) (  IR(  x )&0x80000000 )
          
           //! Fast fabs for floating-point values. It just clears the sign bit.
           //! Don't use it blindy,   it can be faster or slower than the FPU comparison,   depends on the context.
      35   inline_ float FastFabs(  float x )
           {
           udword FloatBits = IR(  x )&0x7fffffff;
           return FR(  FloatBits );
           }
          
           //! Fast square root for floating-point values.
      42   inline_ float FastSqrt(  float square )
           {
          #ifdef _MSC_VER
           float retval;
          
           __asm {
           mov eax,   square
           sub eax,   0x3F800000
           sar eax,   1
           add eax,   0x3F800000
           mov [retval],   eax
           }
           return retval;
          #else
           return sqrt(  square );
          #endif
           }
          
           //! Saturates positive to zero.
      61   inline_ float fsat(  float f )
           {
           udword y = (  udword& )f & ~(  (  sdword& )f >>31 );
           return (  float& )y;
           }
          
           //! Computes 1.0f / sqrtf(  x ).
      68   inline_ float frsqrt(  float f )
           {
           float x = f * 0.5f;
           udword y = 0x5f3759df - (  (  udword& )f >> 1 );
           // Iteration...
           (  float& )y = (  float& )y * (   1.5f - (   x * (  float& )y * (  float& )y  )  );
           // Result
           return (  float& )y;
           }
          
           //! Computes 1.0f / sqrtf(  x ). Comes from NVIDIA.
      79   inline_ float InvSqrt(  const float& x )
           {
           udword tmp = (  udword(  IEEE_1_0 << 1 ) + IEEE_1_0 - *(  udword* )&x ) >> 1;
           float y = *(  float* )&tmp;
           return y * (  1.47f - 0.47f * x * y * y );
           }
          
           //! Computes 1.0f / sqrtf(  x ). Comes from Quake3. Looks like the first one I had above.
           //! See http://www.magic-software.com/3DGEDInvSqrt.html
      88   inline_ float RSqrt(  float number )
           {
           long i;
           float x2,   y;
           const float threehalfs = 1.5f;
          
           x2 = number * 0.5f;
           y = number;
           i = * (  long * ) &y;
           i = 0x5f3759df - (  i >> 1 );
           y = * (  float * ) &i;
           y = y * (  threehalfs - (  x2 * y * y ) );
          
           return y;
           }
          
           //! TO BE DOCUMENTED
     105   inline_ float fsqrt(  float f )
           {
           udword y = (   (   (  sdword& )f - 0x3f800000  ) >> 1  ) + 0x3f800000;
           // Iteration...?
           // (  float& )y = (  3.0f - (  (  float& )y * (  float& )y ) / f ) * (  float& )y * 0.5f;
           // Result
           return (  float& )y;
           }
          
           //! Returns the float ranged espilon value.
     115   inline_ float fepsilon(  float f )
           {
           udword b = (  udword& )f & 0xff800000;
           udword a = b | 0x00000001;
           (  float& )a -= (  float& )b;
           // Result
           return (  float& )a;
           }
          
           //! Is the float valid ?
     125   inline_ bool IsNAN(  float value ) { return (  IR(  value )&0x7f800000 ) == 0x7f800000; }
     126   inline_ bool IsIndeterminate(  float value ) { return IR(  value ) == 0xffc00000; }
     127   inline_ bool IsPlusInf(  float value ) { return IR(  value ) == 0x7f800000; }
     128   inline_ bool IsMinusInf(  float value ) { return IR(  value ) == 0xff800000; }
          
     130   inline_ bool IsValidFloat(  float value )
           {
           if(  IsNAN(  value ) ) return false;
           if(  IsIndeterminate(  value ) ) return false;
           if(  IsPlusInf(  value ) ) return false;
           if(  IsMinusInf(  value ) ) return false;
           return true;
           }
          
           #define CHECK_VALID_FLOAT(  x ) ASSERT(  IsValidFloat(  x ) );
          
          /*
           //! FPU precision setting function.
           inline_ void SetFPU(   )
           {
           // This function evaluates whether the floating-point
           // control word is set to single precision/round to nearest/
           // exceptions disabled. If these conditions don't hold,   the
           // function changes the control word to set them and returns
           // TRUE,   putting the old control word value in the passback
           // location pointed to by pwOldCW.
           {
           uword wTemp,   wSave;
          
           __asm fstcw wSave
           if (  wSave & 0x300 || // Not single mode
           0x3f != (  wSave & 0x3f ) || // Exceptions enabled
           wSave & 0xC00 ) // Not round to nearest mode
           {
           __asm
           {
           mov ax,   wSave
           and ax,   not 300h ;; single mode
           or ax,   3fh ;; disable all exceptions
           and ax,   not 0xC00 ;; round to nearest mode
           mov wTemp,   ax
           fldcw wTemp
           }
           }
           }
           }
          */
           //! This function computes the slowest possible floating-point value (  you can also directly use FLT_EPSILON )
     173   inline_ float ComputeFloatEpsilon(   )
           {
           float f = 1.0f;
           (  (  udword& )f )^=1;
           return f - 1.0f; // You can check it's the same as FLT_EPSILON
           }
          
     180   inline_ bool IsFloatZero(  float x,   float epsilon=1e-6f )
           {
           return x*x < epsilon;
           }
          
           #define FCOMI_ST0 _asm _emit 0xdb _asm _emit 0xf0
           #define FCOMIP_ST0 _asm _emit 0xdf _asm _emit 0xf0
           #define FCMOVB_ST0 _asm _emit 0xda _asm _emit 0xc0
           #define FCMOVNB_ST0 _asm _emit 0xdb _asm _emit 0xc0
          
           #define FCOMI_ST1 _asm _emit 0xdb _asm _emit 0xf1
           #define FCOMIP_ST1 _asm _emit 0xdf _asm _emit 0xf1
           #define FCMOVB_ST1 _asm _emit 0xda _asm _emit 0xc1
           #define FCMOVNB_ST1 _asm _emit 0xdb _asm _emit 0xc1
          
           #define FCOMI_ST2 _asm _emit 0xdb _asm _emit 0xf2
           #define FCOMIP_ST2 _asm _emit 0xdf _asm _emit 0xf2
           #define FCMOVB_ST2 _asm _emit 0xda _asm _emit 0xc2
           #define FCMOVNB_ST2 _asm _emit 0xdb _asm _emit 0xc2
          
           #define FCOMI_ST3 _asm _emit 0xdb _asm _emit 0xf3
           #define FCOMIP_ST3 _asm _emit 0xdf _asm _emit 0xf3
           #define FCMOVB_ST3 _asm _emit 0xda _asm _emit 0xc3
           #define FCMOVNB_ST3 _asm _emit 0xdb _asm _emit 0xc3
          
           #define FCOMI_ST4 _asm _emit 0xdb _asm _emit 0xf4
           #define FCOMIP_ST4 _asm _emit 0xdf _asm _emit 0xf4
           #define FCMOVB_ST4 _asm _emit 0xda _asm _emit 0xc4
           #define FCMOVNB_ST4 _asm _emit 0xdb _asm _emit 0xc4
          
           #define FCOMI_ST5 _asm _emit 0xdb _asm _emit 0xf5
           #define FCOMIP_ST5 _asm _emit 0xdf _asm _emit 0xf5
           #define FCMOVB_ST5 _asm _emit 0xda _asm _emit 0xc5
           #define FCMOVNB_ST5 _asm _emit 0xdb _asm _emit 0xc5
          
           #define FCOMI_ST6 _asm _emit 0xdb _asm _emit 0xf6
           #define FCOMIP_ST6 _asm _emit 0xdf _asm _emit 0xf6
           #define FCMOVB_ST6 _asm _emit 0xda _asm _emit 0xc6
           #define FCMOVNB_ST6 _asm _emit 0xdb _asm _emit 0xc6
          
           #define FCOMI_ST7 _asm _emit 0xdb _asm _emit 0xf7
           #define FCOMIP_ST7 _asm _emit 0xdf _asm _emit 0xf7
           #define FCMOVB_ST7 _asm _emit 0xda _asm _emit 0xc7
           #define FCMOVNB_ST7 _asm _emit 0xdb _asm _emit 0xc7
          
           //! A global function to find MAX(  a,  b ) using FCOMI/FCMOV
     226   inline_ float FCMax2(  float a,   float b )
           {
          #ifdef _MSC_VER
           float Res;
           _asm fld [a]
           _asm fld [b]
           FCOMI_ST1
           FCMOVB_ST1
           _asm fstp [Res]
           _asm fcomp
           return Res;
          #else
           return (  a > b ) ? a : b;
          #endif
           }
          
           //! A global function to find MIN(  a,  b ) using FCOMI/FCMOV
     243   inline_ float FCMin2(  float a,   float b )
           {
          #ifdef _MSC_VER
           float Res;
           _asm fld [a]
           _asm fld [b]
           FCOMI_ST1
           FCMOVNB_ST1
           _asm fstp [Res]
           _asm fcomp
           return Res;
          #else
           return (  a < b ) ? a : b;
          #endif
           }
          
           //! A global function to find MAX(  a,  b,  c ) using FCOMI/FCMOV
     260   inline_ float FCMax3(  float a,   float b,   float c )
           {
          #ifdef _MSC_VER
           float Res;
           _asm fld [a]
           _asm fld [b]
           _asm fld [c]
           FCOMI_ST1
           FCMOVB_ST1
           FCOMI_ST2
           FCMOVB_ST2
           _asm fstp [Res]
           _asm fcompp
           return Res;
          #else
           return (  a > b ) ? (  (  a > c ) ? a : c ) : (  (  b > c ) ? b : c );
          #endif
           }
          
           //! A global function to find MIN(  a,  b,  c ) using FCOMI/FCMOV
     280   inline_ float FCMin3(  float a,   float b,   float c )
           {
          #ifdef _MSC_VER
           float Res;
           _asm fld [a]
           _asm fld [b]
           _asm fld [c]
           FCOMI_ST1
           FCMOVNB_ST1
           FCOMI_ST2
           FCMOVNB_ST2
           _asm fstp [Res]
           _asm fcompp
           return Res;
          #else
           return (  a < b ) ? (  (  a < c ) ? a : c ) : (  (  b < c ) ? b : c );
          #endif
           }
          
     299   inline_ int ConvertToSortable(  float f )
           {
           int& Fi = (  int& )f;
           int Fmask = (  Fi>>31 );
           Fi ^= Fmask;
           Fmask &= ~(  1<<31 );
           Fi -= Fmask;
           return Fi;
           }
          
     309   enum FPUMode
           {
           FPU_FLOOR = 0,  
           FPU_CEIL = 1,  
           FPU_BEST = 2,  
          
           FPU_FORCE_DWORD = 0x7fffffff
           };
          
           FUNCTION FPUMode GetFPUMode(   );
     319   FUNCTION void SaveFPU(   );
     320   FUNCTION void RestoreFPU(   );
     321   FUNCTION void SetFPUFloorMode(   );
     322   FUNCTION void SetFPUCeilMode(   );
     323   FUNCTION void SetFPUBestMode(   );
          
     325   FUNCTION void SetFPUPrecision24(   );
     326   FUNCTION void SetFPUPrecision53(   );
     327   FUNCTION void SetFPUPrecision64(   );
     328   FUNCTION void SetFPURoundingChop(   );
     329   FUNCTION void SetFPURoundingUp(   );
     330   FUNCTION void SetFPURoundingDown(   );
     331   FUNCTION void SetFPURoundingNear(   );
          
     333   FUNCTION int intChop(  const float& f );
     334   FUNCTION int intFloor(  const float& f );
     335   FUNCTION int intCeil(  const float& f );
          
          #endif // __ICEFPU_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceHPoint.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for homogeneous points.
           * \file IceHPoint.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEHPOINT_H__
          #define __ICEHPOINT_H__
          
      15   class HPoint : public Point
           {
           public:
          
           //! Empty constructor
      20   inline_ HPoint(   ) {}
           //! Constructor from floats
      22   inline_ HPoint(  float _x,   float _y,   float _z,   float _w=0.0f ) : Point(  _x,   _y,   _z ),   w(  _w ) {}
           //! Constructor from array
           inline_ HPoint(  const float f[4] ) : Point(  f ),   w(  f[3] ) {}
           //! Constructor from a Point
      26   inline_ HPoint(  const Point& p,   float _w=0.0f ) : Point(  p ),   w(  _w ) {}
           //! Destructor
      28   inline_ ~HPoint(   ) {}
          
           //! Clear the point
      31   inline_ HPoint& Zero(   ) { x = y = z = w = 0.0f; return *this; }
          
           //! Assignment from values
           inline_ HPoint& Set(  float _x,   float _y,   float _z,   float _w  ) { x = _x; y = _y; z = _z; w = _w; return *this; }
           //! Assignment from array
           inline_ HPoint& Set(  const float f[4] ) { x = f[_X]; y = f[_Y]; z = f[_Z]; w = f[_W]; return *this; }
           //! Assignment from another h-point
           inline_ HPoint& Set(  const HPoint& src ) { x = src.x; y = src.y; z = src.z; w = src.w; return *this; }
          
           //! Add a vector
           inline_ HPoint& Add(  float _x,   float _y,   float _z,   float _w  ) { x += _x; y += _y; z += _z; w += _w; return *this; }
           //! Add a vector
           inline_ HPoint& Add(  const float f[4] ) { x += f[_X]; y += f[_Y]; z += f[_Z]; w += f[_W]; return *this; }
          
           //! Subtract a vector
           inline_ HPoint& Sub(  float _x,   float _y,   float _z,   float _w  ) { x -= _x; y -= _y; z -= _z; w -= _w; return *this; }
           //! Subtract a vector
           inline_ HPoint& Sub(  const float f[4] ) { x -= f[_X]; y -= f[_Y]; z -= f[_Z]; w -= f[_W]; return *this; }
          
           //! Multiplies by a scalar
           inline_ HPoint& Mul(  float s ) { x *= s; y *= s; z *= s; w *= s; return *this; }
          
           //! Returns MIN(  x,   y,   z,   w );
           float Min(   ) const { return MIN(  x,   MIN(  y,   MIN(  z,   w ) ) ); }
           //! Returns MAX(  x,   y,   z,   w );
           float Max(   ) const { return MAX(  x,   MAX(  y,   MAX(  z,   w ) ) ); }
           //! Sets each element to be componentwise minimum
           HPoint& Min(  const HPoint& p ) { x = MIN(  x,   p.x ); y = MIN(  y,   p.y ); z = MIN(  z,   p.z ); w = MIN(  w,   p.w ); return *this; }
           //! Sets each element to be componentwise maximum
           HPoint& Max(  const HPoint& p ) { x = MAX(  x,   p.x ); y = MAX(  y,   p.y ); z = MAX(  z,   p.z ); w = MAX(  w,   p.w ); return *this; }
          
           //! Computes square magnitude
           inline_ float SquareMagnitude(   ) const { return x*x + y*y + z*z + w*w; }
           //! Computes magnitude
           inline_ float Magnitude(   ) const { return sqrtf(  x*x + y*y + z*z + w*w ); }
          
           //! Normalize the vector
           inline_ HPoint& Normalize(   )
           {
           float M = Magnitude(   );
           if(  M )
           {
           M = 1.0f / M;
           x *= M;
           y *= M;
           z *= M;
           w *= M;
           }
           return *this;
           }
          
           // Arithmetic operators
           //! Operator for HPoint Negate = - HPoint;
           inline_ HPoint operator-(   ) const { return HPoint(  -x,   -y,   -z,   -w ); }
          
           //! Operator for HPoint Plus = HPoint + HPoint;
           inline_ HPoint operator+(  const HPoint& p ) const { return HPoint(  x + p.x,   y + p.y,   z + p.z,   w + p.w ); }
           //! Operator for HPoint Minus = HPoint - HPoint;
           inline_ HPoint operator-(  const HPoint& p ) const { return HPoint(  x - p.x,   y - p.y,   z - p.z,   w - p.w ); }
          
           //! Operator for HPoint Mul = HPoint * HPoint;
           inline_ HPoint operator*(  const HPoint& p ) const { return HPoint(  x * p.x,   y * p.y,   z * p.z,   w * p.w ); }
           //! Operator for HPoint Scale = HPoint * float;
           inline_ HPoint operator*(  float s ) const { return HPoint(  x * s,   y * s,   z * s,   w * s ); }
           //! Operator for HPoint Scale = float * HPoint;
           inline_ friend HPoint operator*(  float s,   const HPoint& p ) { return HPoint(  s * p.x,   s * p.y,   s * p.z,   s * p.w ); }
          
           //! Operator for HPoint Div = HPoint / HPoint;
           inline_ HPoint operator/(  const HPoint& p ) const { return HPoint(  x / p.x,   y / p.y,   z / p.z,   w / p.w ); }
           //! Operator for HPoint Scale = HPoint / float;
           inline_ HPoint operator/(  float s ) const { s = 1.0f / s; return HPoint(  x * s,   y * s,   z * s,   w * s ); }
           //! Operator for HPoint Scale = float / HPoint;
           inline_ friend HPoint operator/(  float s,   const HPoint& p ) { return HPoint(  s / p.x,   s / p.y,   s / p.z,   s / p.w ); }
          
           //! Operator for float DotProd = HPoint | HPoint;
           inline_ float operator|(  const HPoint& p ) const { return x*p.x + y*p.y + z*p.z + w*p.w; }
           // No cross-product in 4D
          
           //! Operator for HPoint += HPoint;
           inline_ HPoint& operator+=(  const HPoint& p ) { x += p.x; y += p.y; z += p.z; w += p.w; return *this; }
           //! Operator for HPoint += float;
           inline_ HPoint& operator+=(  float s ) { x += s; y += s; z += s; w += s; return *this; }
          
           //! Operator for HPoint -= HPoint;
           inline_ HPoint& operator-=(  const HPoint& p ) { x -= p.x; y -= p.y; z -= p.z; w -= p.w; return *this; }
           //! Operator for HPoint -= float;
           inline_ HPoint& operator-=(  float s ) { x -= s; y -= s; z -= s; w -= s; return *this; }
          
           //! Operator for HPoint *= HPoint;
           inline_ HPoint& operator*=(  const HPoint& p ) { x *= p.x; y *= p.y; z *= p.z; w *= p.w; return *this; }
           //! Operator for HPoint *= float;
           inline_ HPoint& operator*=(  float s ) { x*=s; y*=s; z*=s; w*=s; return *this; }
          
           //! Operator for HPoint /= HPoint;
           inline_ HPoint& operator/=(  const HPoint& p ) { x /= p.x; y /= p.y; z /= p.z; w /= p.w; return *this; }
           //! Operator for HPoint /= float;
           inline_ HPoint& operator/=(  float s ) { s = 1.0f / s; x*=s; y*=s; z*=s; w*=s; return *this; }
          
           // Arithmetic operators
          
           //! Operator for Point Mul = HPoint * Matrix3x3;
           Point operator*(  const Matrix3x3& mat ) const;
           //! Operator for HPoint Mul = HPoint * Matrix4x4;
           HPoint operator*(  const Matrix4x4& mat ) const;
          
           // HPoint *= Matrix3x3 doesn't exist,   the matrix is first casted to a 4x4
           //! Operator for HPoint *= Matrix4x4
           HPoint& operator*=(  const Matrix4x4& mat );
          
           // Logical operators
          
           //! Operator for "if(  HPoint==HPoint )"
           inline_ bool operator==(  const HPoint& p ) const { return (   (  x==p.x )&&(  y==p.y )&&(  z==p.z )&&(  w==p.w ) ); }
           //! Operator for "if(  HPoint!=HPoint )"
           inline_ bool operator!=(  const HPoint& p ) const { return (   (  x!=p.x )||(  y!=p.y )||(  z!=p.z )||(  w!=p.w ) ); }
          
           // Cast operators
          
           //! Cast a HPoint to a Point. w is discarded.
          #ifdef _MSC_VER
           inline_ operator Point(   ) const { return Point(  x,   y,   z ); }
           // gcc complains that conversion to a base class will never use a type conversion operator
          #endif
          
           public:
           float w;
           };
          
          #endif // __ICEHPOINT_H__
          

./components/ogre/ogreopcode/include/Opcode/Ice/IceIndexedTriangle.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a handy indexed triangle class.
           * \file IceIndexedTriangle.h
           * \author Pierre Terdiman
           * \date January,   17,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEINDEXEDTRIANGLE_H__
          #define __ICEINDEXEDTRIANGLE_H__
          
           // Forward declarations
          #ifdef _MSC_VER
           enum CubeIndex;
          #else
           typedef int CubeIndex;
          #endif
          
           // An indexed triangle class.
      23   class IndexedTriangle
           {
           public:
           //! Constructor
      27   inline_ IndexedTriangle(   ) {}
           //! Constructor
      29   inline_ IndexedTriangle(  udword r0,   udword r1,   udword r2 ) { mVRef[0]=r0; mVRef[1]=r1; mVRef[2]=r2; }
           //! Copy constructor
      31   inline_ IndexedTriangle(  const IndexedTriangle& triangle )
           {
           mVRef[0] = triangle.mVRef[0];
           mVRef[1] = triangle.mVRef[1];
           mVRef[2] = triangle.mVRef[2];
           }
           //! Destructor
      38   inline_ ~IndexedTriangle(   ) {}
           //! Vertex-references
      40   udword mVRef[3];
          
           // Methods
      43   void Flip(   );
      44   float Area(  const Point* verts ) const;
      45   float Perimeter(  const Point* verts ) const;
      46   float Compacity(  const Point* verts ) const;
      47   void Normal(  const Point* verts,   Point& normal ) const;
      48   void DenormalizedNormal(  const Point* verts,   Point& normal ) const;
      49   void Center(  const Point* verts,   Point& center ) const;
      50   void CenteredNormal(  const Point* verts,   Point& normal ) const;
      51   void RandomPoint(  const Point* verts,   Point& random ) const;
      52   bool IsVisible(  const Point* verts,   const Point& source ) const;
      53   bool BackfaceCulling(  const Point* verts,   const Point& source ) const;
      54   float ComputeOcclusionPotential(  const Point* verts,   const Point& view ) const;
      55   bool ReplaceVertex(  udword oldref,   udword newref );
      56   bool IsDegenerate(   ) const;
      57   bool HasVertex(  udword ref ) const;
      58   bool HasVertex(  udword ref,   udword* index ) const;
      59   ubyte FindEdge(  udword vref0,   udword vref1 ) const;
      60   udword OppositeVertex(  udword vref0,   udword vref1 ) const;
           inline_ udword OppositeVertex(  ubyte edgenb ) const { return mVRef[2-edgenb]; }
           void GetVRefs(  ubyte edgenb,   udword& vref0,   udword& vref1,   udword& vref2 ) const;
           float MinEdgeLength(  const Point* verts ) const;
           float MaxEdgeLength(  const Point* verts ) const;
           void ComputePoint(  const Point* verts,   float u,   float v,   Point& pt,   udword* nearvtx=null ) const;
           float Angle(  const IndexedTriangle& tri,   const Point* verts ) const;
           inline_ Plane PlaneEquation(  const Point* verts ) const { return Plane(  verts[mVRef[0]],   verts[mVRef[1]],   verts[mVRef[2]] ); }
           bool Equal(  const IndexedTriangle& tri ) const;
           CubeIndex ComputeCubeIndex(  const Point* verts ) const;
           };
          
          #endif // __ICEINDEXEDTRIANGLE_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceLSS.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for line-swept spheres.
           * \file IceLSS.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICELSS_H__
          #define __ICELSS_H__
          
      15   class LSS : public Segment
           {
           public:
           //! Constructor
      19   inline_ LSS(   ) {}
           //! Constructor
      21   inline_ LSS(  const Segment& seg,   float radius ) : Segment(  seg ),   mRadius(  radius ) {}
           //! Destructor
      23   inline_ ~LSS(   ) {}
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes an OBB surrounding the LSS.
           * \param box [out] the OBB
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      31   void ComputeOBB(  OBB& box );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Tests if a point is contained within the LSS.
           * \param pt [in] the point to test
           * \return true if inside the LSS
           * \warning point and LSS must be in same space
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ bool Contains(  const Point& pt ) const { return SquareDistance(  pt ) <= mRadius*mRadius; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Tests if a sphere is contained within the LSS.
           * \param sphere [in] the sphere to test
           * \return true if inside the LSS
           * \warning sphere and LSS must be in same space
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      51   inline_ bool Contains(  const Sphere& sphere )
           {
           float d = mRadius - sphere.mRadius;
           if(  d>=0.0f ) return SquareDistance(  sphere.mCenter ) <= d*d;
           else return false;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Tests if an LSS is contained within the LSS.
           * \param lss [in] the LSS to test
           * \return true if inside the LSS
           * \warning both LSS must be in same space
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      66   inline_ bool Contains(  const LSS& lss )
           {
           // We check the LSS contains the two spheres at the start and end of the sweep
           return Contains(  Sphere(  lss.mP0,   lss.mRadius ) ) && Contains(  Sphere(  lss.mP0,   lss.mRadius ) );
           }
          
           float mRadius; //!< Sphere radius
           };
          
          #endif // __ICELSS_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceMatrix3x3.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for 3x3 matrices.
           * \file IceMatrix3x3.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEMATRIX3X3_H__
          #define __ICEMATRIX3X3_H__
          
           // Forward declarations
      16   class Quat;
          
           #define MATRIX3X3_EPSILON (  1.0e-7f )
          
      20   class Matrix3x3
           {
           public:
           //! Empty constructor
      24   inline_ Matrix3x3(   ) {}
           //! Constructor from 9 values
      26   inline_ Matrix3x3(  float m00,   float m01,   float m02,   float m10,   float m11,   float m12,   float m20,   float m21,   float m22 )
           {
           m[0][0] = m00; m[0][1] = m01; m[0][2] = m02;
           m[1][0] = m10; m[1][1] = m11; m[1][2] = m12;
           m[2][0] = m20; m[2][1] = m21; m[2][2] = m22;
           }
           //! Copy constructor
      33   inline_ Matrix3x3(  const Matrix3x3& mat ) { CopyMemory(  m,   &mat.m,   9*sizeof(  float ) ); }
           //! Destructor
      35   inline_ ~Matrix3x3(   ) {}
          
           //! Assign values
           inline_ void Set(  float m00,   float m01,   float m02,   float m10,   float m11,   float m12,   float m20,   float m21,   float m22 )
           {
           m[0][0] = m00; m[0][1] = m01; m[0][2] = m02;
           m[1][0] = m10; m[1][1] = m11; m[1][2] = m12;
           m[2][0] = m20; m[2][1] = m21; m[2][2] = m22;
           }
          
           //! Sets the scale from a Point. The point is put on the diagonal.
      46   inline_ void SetScale(  const Point& p ) { m[0][0] = p.x; m[1][1] = p.y; m[2][2] = p.z; }
          
           //! Sets the scale from floats. Values are put on the diagonal.
      49   inline_ void SetScale(  float sx,   float sy,   float sz ) { m[0][0] = sx; m[1][1] = sy; m[2][2] = sz; }
          
           //! Scales from a Point. Each row is multiplied by a component.
      52   inline_ void Scale(  const Point& p )
           {
           m[0][0] *= p.x; m[0][1] *= p.x; m[0][2] *= p.x;
           m[1][0] *= p.y; m[1][1] *= p.y; m[1][2] *= p.y;
           m[2][0] *= p.z; m[2][1] *= p.z; m[2][2] *= p.z;
           }
          
           //! Scales from floats. Each row is multiplied by a value.
      60   inline_ void Scale(  float sx,   float sy,   float sz )
           {
           m[0][0] *= sx; m[0][1] *= sx; m[0][2] *= sx;
           m[1][0] *= sy; m[1][1] *= sy; m[1][2] *= sy;
           m[2][0] *= sz; m[2][1] *= sz; m[2][2] *= sz;
           }
          
           //! Copy from a Matrix3x3
      68   inline_ void Copy(  const Matrix3x3& source ) { CopyMemory(  m,   source.m,   9*sizeof(  float ) ); }
          
           // Row-column access
           //! Returns a row.
      72   inline_ void GetRow(  const udword r,   Point& p ) const { p.x = m[r][0]; p.y = m[r][1]; p.z = m[r][2]; }
           //! Returns a row.
      74   inline_ const Point& GetRow(  const udword r ) const { return *(  const Point* )&m[r][0]; }
           //! Returns a row.
      76   inline_ Point& GetRow(  const udword r ) { return *(  Point* )&m[r][0]; }
           //! Sets a row.
           inline_ void SetRow(  const udword r,   const Point& p ) { m[r][0] = p.x; m[r][1] = p.y; m[r][2] = p.z; }
           //! Returns a column.
           inline_ void GetCol(  const udword c,   Point& p ) const { p.x = m[0][c]; p.y = m[1][c]; p.z = m[2][c]; }
           //! Sets a column.
           inline_ void SetCol(  const udword c,   const Point& p ) { m[0][c] = p.x; m[1][c] = p.y; m[2][c] = p.z; }
          
           //! Computes the trace. The trace is the sum of the 3 diagonal components.
           inline_ float Trace(   ) const { return m[0][0] + m[1][1] + m[2][2]; }
           //! Clears the matrix.
           inline_ void Zero(   ) { ZeroMemory(  &m,   sizeof(  m ) ); }
           //! Sets the identity matrix.
           inline_ void Identity(   ) { Zero(   ); m[0][0] = m[1][1] = m[2][2] = 1.0f; }
           //! Checks for identity
           inline_ bool IsIdentity(   ) const
           {
           if(  IR(  m[0][0] )!=IEEE_1_0 ) return false;
           if(  IR(  m[0][1] )!=0 ) return false;
           if(  IR(  m[0][2] )!=0 ) return false;
          
           if(  IR(  m[1][0] )!=0 ) return false;
           if(  IR(  m[1][1] )!=IEEE_1_0 ) return false;
           if(  IR(  m[1][2] )!=0 ) return false;
          
           if(  IR(  m[2][0] )!=0 ) return false;
           if(  IR(  m[2][1] )!=0 ) return false;
           if(  IR(  m[2][2] )!=IEEE_1_0 ) return false;
          
           return true;
           }
          
           //! Checks matrix validity
           inline_ BOOL IsValid(   ) const
           {
           for(  udword j=0;j<3;j++ )
           {
           for(  udword i=0;i<3;i++ )
           {
           if(  !IsValidFloat(  m[j][i] ) ) return FALSE;
           }
           }
           return TRUE;
           }
          
           //! Makes a skew-symmetric matrix (  a.k.a. Star(  * ) Matrix )
           //! [ 0.0 -a.z a.y ]
           //! [ a.z 0.0 -a.x ]
           //! [ -a.y a.x 0.0 ]
           //! This is also called a "cross matrix" since for any vectors A and B,  
           //! A^B = Skew(  A ) * B = - B * Skew(  A );
           inline_ void SkewSymmetric(  const Point& a )
           {
           m[0][0] = 0.0f;
           m[0][1] = -a.z;
           m[0][2] = a.y;
          
           m[1][0] = a.z;
           m[1][1] = 0.0f;
           m[1][2] = -a.x;
          
           m[2][0] = -a.y;
           m[2][1] = a.x;
           m[2][2] = 0.0f;
           }
          
           //! Negates the matrix
           inline_ void Neg(   )
           {
           m[0][0] = -m[0][0]; m[0][1] = -m[0][1]; m[0][2] = -m[0][2];
           m[1][0] = -m[1][0]; m[1][1] = -m[1][1]; m[1][2] = -m[1][2];
           m[2][0] = -m[2][0]; m[2][1] = -m[2][1]; m[2][2] = -m[2][2];
           }
          
           //! Neg from another matrix
           inline_ void Neg(  const Matrix3x3& mat )
           {
           m[0][0] = -mat.m[0][0]; m[0][1] = -mat.m[0][1]; m[0][2] = -mat.m[0][2];
           m[1][0] = -mat.m[1][0]; m[1][1] = -mat.m[1][1]; m[1][2] = -mat.m[1][2];
           m[2][0] = -mat.m[2][0]; m[2][1] = -mat.m[2][1]; m[2][2] = -mat.m[2][2];
           }
          
           //! Add another matrix
           inline_ void Add(  const Matrix3x3& mat )
           {
           m[0][0] += mat.m[0][0]; m[0][1] += mat.m[0][1]; m[0][2] += mat.m[0][2];
           m[1][0] += mat.m[1][0]; m[1][1] += mat.m[1][1]; m[1][2] += mat.m[1][2];
           m[2][0] += mat.m[2][0]; m[2][1] += mat.m[2][1]; m[2][2] += mat.m[2][2];
           }
          
           //! Sub another matrix
           inline_ void Sub(  const Matrix3x3& mat )
           {
           m[0][0] -= mat.m[0][0]; m[0][1] -= mat.m[0][1]; m[0][2] -= mat.m[0][2];
           m[1][0] -= mat.m[1][0]; m[1][1] -= mat.m[1][1]; m[1][2] -= mat.m[1][2];
           m[2][0] -= mat.m[2][0]; m[2][1] -= mat.m[2][1]; m[2][2] -= mat.m[2][2];
           }
           //! Mac
           inline_ void Mac(  const Matrix3x3& a,   const Matrix3x3& b,   float s )
           {
           m[0][0] = a.m[0][0] + b.m[0][0] * s;
           m[0][1] = a.m[0][1] + b.m[0][1] * s;
           m[0][2] = a.m[0][2] + b.m[0][2] * s;
          
           m[1][0] = a.m[1][0] + b.m[1][0] * s;
           m[1][1] = a.m[1][1] + b.m[1][1] * s;
           m[1][2] = a.m[1][2] + b.m[1][2] * s;
          
           m[2][0] = a.m[2][0] + b.m[2][0] * s;
           m[2][1] = a.m[2][1] + b.m[2][1] * s;
           m[2][2] = a.m[2][2] + b.m[2][2] * s;
           }
           //! Mac
           inline_ void Mac(  const Matrix3x3& a,   float s )
           {
           m[0][0] += a.m[0][0] * s; m[0][1] += a.m[0][1] * s; m[0][2] += a.m[0][2] * s;
           m[1][0] += a.m[1][0] * s; m[1][1] += a.m[1][1] * s; m[1][2] += a.m[1][2] * s;
           m[2][0] += a.m[2][0] * s; m[2][1] += a.m[2][1] * s; m[2][2] += a.m[2][2] * s;
           }
          
           //! this = A * s
           inline_ void Mult(  const Matrix3x3& a,   float s )
           {
           m[0][0] = a.m[0][0] * s; m[0][1] = a.m[0][1] * s; m[0][2] = a.m[0][2] * s;
           m[1][0] = a.m[1][0] * s; m[1][1] = a.m[1][1] * s; m[1][2] = a.m[1][2] * s;
           m[2][0] = a.m[2][0] * s; m[2][1] = a.m[2][1] * s; m[2][2] = a.m[2][2] * s;
           }
          
           inline_ void Add(  const Matrix3x3& a,   const Matrix3x3& b )
           {
           m[0][0] = a.m[0][0] + b.m[0][0]; m[0][1] = a.m[0][1] + b.m[0][1]; m[0][2] = a.m[0][2] + b.m[0][2];
           m[1][0] = a.m[1][0] + b.m[1][0]; m[1][1] = a.m[1][1] + b.m[1][1]; m[1][2] = a.m[1][2] + b.m[1][2];
           m[2][0] = a.m[2][0] + b.m[2][0]; m[2][1] = a.m[2][1] + b.m[2][1]; m[2][2] = a.m[2][2] + b.m[2][2];
           }
          
           inline_ void Sub(  const Matrix3x3& a,   const Matrix3x3& b )
           {
           m[0][0] = a.m[0][0] - b.m[0][0]; m[0][1] = a.m[0][1] - b.m[0][1]; m[0][2] = a.m[0][2] - b.m[0][2];
           m[1][0] = a.m[1][0] - b.m[1][0]; m[1][1] = a.m[1][1] - b.m[1][1]; m[1][2] = a.m[1][2] - b.m[1][2];
           m[2][0] = a.m[2][0] - b.m[2][0]; m[2][1] = a.m[2][1] - b.m[2][1]; m[2][2] = a.m[2][2] - b.m[2][2];
           }
          
           //! this = a * b
           inline_ void Mult(  const Matrix3x3& a,   const Matrix3x3& b )
           {
           m[0][0] = a.m[0][0] * b.m[0][0] + a.m[0][1] * b.m[1][0] + a.m[0][2] * b.m[2][0];
           m[0][1] = a.m[0][0] * b.m[0][1] + a.m[0][1] * b.m[1][1] + a.m[0][2] * b.m[2][1];
           m[0][2] = a.m[0][0] * b.m[0][2] + a.m[0][1] * b.m[1][2] + a.m[0][2] * b.m[2][2];
           m[1][0] = a.m[1][0] * b.m[0][0] + a.m[1][1] * b.m[1][0] + a.m[1][2] * b.m[2][0];
           m[1][1] = a.m[1][0] * b.m[0][1] + a.m[1][1] * b.m[1][1] + a.m[1][2] * b.m[2][1];
           m[1][2] = a.m[1][0] * b.m[0][2] + a.m[1][1] * b.m[1][2] + a.m[1][2] * b.m[2][2];
           m[2][0] = a.m[2][0] * b.m[0][0] + a.m[2][1] * b.m[1][0] + a.m[2][2] * b.m[2][0];
           m[2][1] = a.m[2][0] * b.m[0][1] + a.m[2][1] * b.m[1][1] + a.m[2][2] * b.m[2][1];
           m[2][2] = a.m[2][0] * b.m[0][2] + a.m[2][1] * b.m[1][2] + a.m[2][2] * b.m[2][2];
           }
          
           //! this = transpose(  a ) * b
           inline_ void MultAtB(  const Matrix3x3& a,   const Matrix3x3& b )
           {
           m[0][0] = a.m[0][0] * b.m[0][0] + a.m[1][0] * b.m[1][0] + a.m[2][0] * b.m[2][0];
           m[0][1] = a.m[0][0] * b.m[0][1] + a.m[1][0] * b.m[1][1] + a.m[2][0] * b.m[2][1];
           m[0][2] = a.m[0][0] * b.m[0][2] + a.m[1][0] * b.m[1][2] + a.m[2][0] * b.m[2][2];
           m[1][0] = a.m[0][1] * b.m[0][0] + a.m[1][1] * b.m[1][0] + a.m[2][1] * b.m[2][0];
           m[1][1] = a.m[0][1] * b.m[0][1] + a.m[1][1] * b.m[1][1] + a.m[2][1] * b.m[2][1];
           m[1][2] = a.m[0][1] * b.m[0][2] + a.m[1][1] * b.m[1][2] + a.m[2][1] * b.m[2][2];
           m[2][0] = a.m[0][2] * b.m[0][0] + a.m[1][2] * b.m[1][0] + a.m[2][2] * b.m[2][0];
           m[2][1] = a.m[0][2] * b.m[0][1] + a.m[1][2] * b.m[1][1] + a.m[2][2] * b.m[2][1];
           m[2][2] = a.m[0][2] * b.m[0][2] + a.m[1][2] * b.m[1][2] + a.m[2][2] * b.m[2][2];
           }
          
           //! this = a * transpose(  b )
           inline_ void MultABt(  const Matrix3x3& a,   const Matrix3x3& b )
           {
           m[0][0] = a.m[0][0] * b.m[0][0] + a.m[0][1] * b.m[0][1] + a.m[0][2] * b.m[0][2];
           m[0][1] = a.m[0][0] * b.m[1][0] + a.m[0][1] * b.m[1][1] + a.m[0][2] * b.m[1][2];
           m[0][2] = a.m[0][0] * b.m[2][0] + a.m[0][1] * b.m[2][1] + a.m[0][2] * b.m[2][2];
           m[1][0] = a.m[1][0] * b.m[0][0] + a.m[1][1] * b.m[0][1] + a.m[1][2] * b.m[0][2];
           m[1][1] = a.m[1][0] * b.m[1][0] + a.m[1][1] * b.m[1][1] + a.m[1][2] * b.m[1][2];
           m[1][2] = a.m[1][0] * b.m[2][0] + a.m[1][1] * b.m[2][1] + a.m[1][2] * b.m[2][2];
           m[2][0] = a.m[2][0] * b.m[0][0] + a.m[2][1] * b.m[0][1] + a.m[2][2] * b.m[0][2];
           m[2][1] = a.m[2][0] * b.m[1][0] + a.m[2][1] * b.m[1][1] + a.m[2][2] * b.m[1][2];
           m[2][2] = a.m[2][0] * b.m[2][0] + a.m[2][1] * b.m[2][1] + a.m[2][2] * b.m[2][2];
           }
          
           //! Makes a rotation matrix mapping vector "from" to vector "to".
           Matrix3x3& FromTo(  const Point& from,   const Point& to );
          
           //! Set a rotation matrix around the X axis.
           //! 1 0 0
           //! RX = 0 cx sx
           //! 0 -sx cx
           void RotX(  float angle );
           //! Set a rotation matrix around the Y axis.
           //! cy 0 -sy
           //! RY = 0 1 0
           //! sy 0 cy
           void RotY(  float angle );
           //! Set a rotation matrix around the Z axis.
           //! cz sz 0
           //! RZ = -sz cz 0
           //! 0 0 1
           void RotZ(  float angle );
           //! cy sx.sy -sy.cx
           //! RY.RX 0 cx sx
           //! sy -sx.cy cx.cy
           void RotYX(  float y,   float x );
          
           //! Make a rotation matrix about an arbitrary axis
           Matrix3x3& Rot(  float angle,   const Point& axis );
          
           //! Transpose the matrix.
           void Transpose(   )
           {
           IR(  m[1][0] ) ^= IR(  m[0][1] ); IR(  m[0][1] ) ^= IR(  m[1][0] ); IR(  m[1][0] ) ^= IR(  m[0][1] );
           IR(  m[2][0] ) ^= IR(  m[0][2] ); IR(  m[0][2] ) ^= IR(  m[2][0] ); IR(  m[2][0] ) ^= IR(  m[0][2] );
           IR(  m[2][1] ) ^= IR(  m[1][2] ); IR(  m[1][2] ) ^= IR(  m[2][1] ); IR(  m[2][1] ) ^= IR(  m[1][2] );
           }
          
           //! this = Transpose(  a )
           void Transpose(  const Matrix3x3& a )
           {
           m[0][0] = a.m[0][0]; m[0][1] = a.m[1][0]; m[0][2] = a.m[2][0];
           m[1][0] = a.m[0][1]; m[1][1] = a.m[1][1]; m[1][2] = a.m[2][1];
           m[2][0] = a.m[0][2]; m[2][1] = a.m[1][2]; m[2][2] = a.m[2][2];
           }
          
           //! Compute the determinant of the matrix. We use the rule of Sarrus.
           float Determinant(   ) const
           {
           return (  m[0][0]*m[1][1]*m[2][2] + m[0][1]*m[1][2]*m[2][0] + m[0][2]*m[1][0]*m[2][1] )
           - (  m[2][0]*m[1][1]*m[0][2] + m[2][1]*m[1][2]*m[0][0] + m[2][2]*m[1][0]*m[0][1] );
           }
          /*
           //! Compute a cofactor. Used for matrix inversion.
           float CoFactor(  ubyte row,   ubyte column ) const
           {
           static sdword gIndex[3+2] = { 0,   1,   2,   0,   1 };
           return (  m[gIndex[row+1]][gIndex[column+1]]*m[gIndex[row+2]][gIndex[column+2]] - m[gIndex[row+2]][gIndex[column+1]]*m[gIndex[row+1]][gIndex[column+2]] );
           }
          */
           //! Invert the matrix. Determinant must be different from zero,   else matrix can't be inverted.
           Matrix3x3& Invert(   )
           {
           float Det = Determinant(   ); // Must be !=0
           float OneOverDet = 1.0f / Det;
          
           Matrix3x3 Temp;
           Temp.m[0][0] = +(  m[1][1] * m[2][2] - m[2][1] * m[1][2] ) * OneOverDet;
           Temp.m[1][0] = -(  m[1][0] * m[2][2] - m[2][0] * m[1][2] ) * OneOverDet;
           Temp.m[2][0] = +(  m[1][0] * m[2][1] - m[2][0] * m[1][1] ) * OneOverDet;
           Temp.m[0][1] = -(  m[0][1] * m[2][2] - m[2][1] * m[0][2] ) * OneOverDet;
           Temp.m[1][1] = +(  m[0][0] * m[2][2] - m[2][0] * m[0][2] ) * OneOverDet;
           Temp.m[2][1] = -(  m[0][0] * m[2][1] - m[2][0] * m[0][1] ) * OneOverDet;
           Temp.m[0][2] = +(  m[0][1] * m[1][2] - m[1][1] * m[0][2] ) * OneOverDet;
           Temp.m[1][2] = -(  m[0][0] * m[1][2] - m[1][0] * m[0][2] ) * OneOverDet;
           Temp.m[2][2] = +(  m[0][0] * m[1][1] - m[1][0] * m[0][1] ) * OneOverDet;
          
           *this = Temp;
          
           return *this;
           }
          
           Matrix3x3& Normalize(   );
          
           //! this = exp(  a )
           Matrix3x3& Exp(  const Matrix3x3& a );
          
          void FromQuat(  const Quat &q );
          void FromQuatL2(  const Quat &q,   float l2 );
          
           // Arithmetic operators
           //! Operator for Matrix3x3 Plus = Matrix3x3 + Matrix3x3;
           inline_ Matrix3x3 operator+(  const Matrix3x3& mat ) const
           {
           return Matrix3x3(  
           m[0][0] + mat.m[0][0],   m[0][1] + mat.m[0][1],   m[0][2] + mat.m[0][2],  
           m[1][0] + mat.m[1][0],   m[1][1] + mat.m[1][1],   m[1][2] + mat.m[1][2],  
           m[2][0] + mat.m[2][0],   m[2][1] + mat.m[2][1],   m[2][2] + mat.m[2][2] );
           }
          
           //! Operator for Matrix3x3 Minus = Matrix3x3 - Matrix3x3;
           inline_ Matrix3x3 operator-(  const Matrix3x3& mat ) const
           {
           return Matrix3x3(  
           m[0][0] - mat.m[0][0],   m[0][1] - mat.m[0][1],   m[0][2] - mat.m[0][2],  
           m[1][0] - mat.m[1][0],   m[1][1] - mat.m[1][1],   m[1][2] - mat.m[1][2],  
           m[2][0] - mat.m[2][0],   m[2][1] - mat.m[2][1],   m[2][2] - mat.m[2][2] );
           }
          
           //! Operator for Matrix3x3 Mul = Matrix3x3 * Matrix3x3;
           inline_ Matrix3x3 operator*(  const Matrix3x3& mat ) const
           {
           return Matrix3x3(  
           m[0][0]*mat.m[0][0] + m[0][1]*mat.m[1][0] + m[0][2]*mat.m[2][0],  
           m[0][0]*mat.m[0][1] + m[0][1]*mat.m[1][1] + m[0][2]*mat.m[2][1],  
           m[0][0]*mat.m[0][2] + m[0][1]*mat.m[1][2] + m[0][2]*mat.m[2][2],  
          
           m[1][0]*mat.m[0][0] + m[1][1]*mat.m[1][0] + m[1][2]*mat.m[2][0],  
           m[1][0]*mat.m[0][1] + m[1][1]*mat.m[1][1] + m[1][2]*mat.m[2][1],  
           m[1][0]*mat.m[0][2] + m[1][1]*mat.m[1][2] + m[1][2]*mat.m[2][2],  
          
           m[2][0]*mat.m[0][0] + m[2][1]*mat.m[1][0] + m[2][2]*mat.m[2][0],  
           m[2][0]*mat.m[0][1] + m[2][1]*mat.m[1][1] + m[2][2]*mat.m[2][1],  
           m[2][0]*mat.m[0][2] + m[2][1]*mat.m[1][2] + m[2][2]*mat.m[2][2] );
           }
          
           //! Operator for Point Mul = Matrix3x3 * Point;
           inline_ Point operator*(  const Point& v ) const { return Point(  GetRow(  0 )|v,   GetRow(  1 )|v,   GetRow(  2 )|v ); }
          
           //! Operator for Matrix3x3 Mul = Matrix3x3 * float;
           inline_ Matrix3x3 operator*(  float s ) const
           {
           return Matrix3x3(  
           m[0][0]*s,   m[0][1]*s,   m[0][2]*s,  
           m[1][0]*s,   m[1][1]*s,   m[1][2]*s,  
           m[2][0]*s,   m[2][1]*s,   m[2][2]*s );
           }
          
           //! Operator for Matrix3x3 Mul = float * Matrix3x3;
           inline_ friend Matrix3x3 operator*(  float s,   const Matrix3x3& mat )
           {
           return Matrix3x3(  
           s*mat.m[0][0],   s*mat.m[0][1],   s*mat.m[0][2],  
           s*mat.m[1][0],   s*mat.m[1][1],   s*mat.m[1][2],  
           s*mat.m[2][0],   s*mat.m[2][1],   s*mat.m[2][2] );
           }
          
           //! Operator for Matrix3x3 Div = Matrix3x3 / float;
           inline_ Matrix3x3 operator/(  float s ) const
           {
           if (  s ) s = 1.0f / s;
           return Matrix3x3(  
           m[0][0]*s,   m[0][1]*s,   m[0][2]*s,  
           m[1][0]*s,   m[1][1]*s,   m[1][2]*s,  
           m[2][0]*s,   m[2][1]*s,   m[2][2]*s );
           }
          
           //! Operator for Matrix3x3 Div = float / Matrix3x3;
           inline_ friend Matrix3x3 operator/(  float s,   const Matrix3x3& mat )
           {
           return Matrix3x3(  
           s/mat.m[0][0],   s/mat.m[0][1],   s/mat.m[0][2],  
           s/mat.m[1][0],   s/mat.m[1][1],   s/mat.m[1][2],  
           s/mat.m[2][0],   s/mat.m[2][1],   s/mat.m[2][2] );
           }
          
           //! Operator for Matrix3x3 += Matrix3x3
           inline_ Matrix3x3& operator+=(  const Matrix3x3& mat )
           {
           m[0][0] += mat.m[0][0]; m[0][1] += mat.m[0][1]; m[0][2] += mat.m[0][2];
           m[1][0] += mat.m[1][0]; m[1][1] += mat.m[1][1]; m[1][2] += mat.m[1][2];
           m[2][0] += mat.m[2][0]; m[2][1] += mat.m[2][1]; m[2][2] += mat.m[2][2];
           return *this;
           }
          
           //! Operator for Matrix3x3 -= Matrix3x3
           inline_ Matrix3x3& operator-=(  const Matrix3x3& mat )
           {
           m[0][0] -= mat.m[0][0]; m[0][1] -= mat.m[0][1]; m[0][2] -= mat.m[0][2];
           m[1][0] -= mat.m[1][0]; m[1][1] -= mat.m[1][1]; m[1][2] -= mat.m[1][2];
           m[2][0] -= mat.m[2][0]; m[2][1] -= mat.m[2][1]; m[2][2] -= mat.m[2][2];
           return *this;
           }
          
           //! Operator for Matrix3x3 *= Matrix3x3
           inline_ Matrix3x3& operator*=(  const Matrix3x3& mat )
           {
           Point TempRow;
          
           GetRow(  0,   TempRow );
           m[0][0] = TempRow.x*mat.m[0][0] + TempRow.y*mat.m[1][0] + TempRow.z*mat.m[2][0];
           m[0][1] = TempRow.x*mat.m[0][1] + TempRow.y*mat.m[1][1] + TempRow.z*mat.m[2][1];
           m[0][2] = TempRow.x*mat.m[0][2] + TempRow.y*mat.m[1][2] + TempRow.z*mat.m[2][2];
          
           GetRow(  1,   TempRow );
           m[1][0] = TempRow.x*mat.m[0][0] + TempRow.y*mat.m[1][0] + TempRow.z*mat.m[2][0];
           m[1][1] = TempRow.x*mat.m[0][1] + TempRow.y*mat.m[1][1] + TempRow.z*mat.m[2][1];
           m[1][2] = TempRow.x*mat.m[0][2] + TempRow.y*mat.m[1][2] + TempRow.z*mat.m[2][2];
          
           GetRow(  2,   TempRow );
           m[2][0] = TempRow.x*mat.m[0][0] + TempRow.y*mat.m[1][0] + TempRow.z*mat.m[2][0];
           m[2][1] = TempRow.x*mat.m[0][1] + TempRow.y*mat.m[1][1] + TempRow.z*mat.m[2][1];
           m[2][2] = TempRow.x*mat.m[0][2] + TempRow.y*mat.m[1][2] + TempRow.z*mat.m[2][2];
           return *this;
           }
          
           //! Operator for Matrix3x3 *= float
           inline_ Matrix3x3& operator*=(  float s )
           {
           m[0][0] *= s; m[0][1] *= s; m[0][2] *= s;
           m[1][0] *= s; m[1][1] *= s; m[1][2] *= s;
           m[2][0] *= s; m[2][1] *= s; m[2][2] *= s;
           return *this;
           }
          
           //! Operator for Matrix3x3 /= float
           inline_ Matrix3x3& operator/=(  float s )
           {
           if (  s ) s = 1.0f / s;
           m[0][0] *= s; m[0][1] *= s; m[0][2] *= s;
           m[1][0] *= s; m[1][1] *= s; m[1][2] *= s;
           m[2][0] *= s; m[2][1] *= s; m[2][2] *= s;
           return *this;
           }
          
           // Cast operators
           //! Cast a Matrix3x3 to a Matrix4x4.
           operator Matrix4x4(   ) const;
           //! Cast a Matrix3x3 to a Quat.
           operator Quat(   ) const;
          
           inline_ const Point& operator[](  int row ) const { return *(  const Point* )&m[row][0]; }
           inline_ Point& operator[](  int row ) { return *(  Point* )&m[row][0]; }
          
           public:
          
           float m[3][3];
           };
          
          #endif // __ICEMATRIX3X3_H__
          

./components/ogre/ogreopcode/include/Opcode/Ice/IceMatrix4x4.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for 4x4 matrices.
           * \file IceMatrix4x4.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEMATRIX4X4_H__
          #define __ICEMATRIX4X4_H__
          
           // Forward declarations
      16   class PRS;
      17   class PR;
          
           #define MATRIX4X4_EPSILON (  1.0e-7f )
          
      21   class Matrix4x4
           {
          // void LUBackwardSubstitution(   sdword *indx,   float* b  );
          // void LUDecomposition(   sdword* indx,   float* d  );
          
           public:
           //! Empty constructor.
      28   inline_ Matrix4x4(   ) {}
           //! Constructor from 16 values
      30   inline_ Matrix4x4(   float m00,   float m01,   float m02,   float m03,  
           float m10,   float m11,   float m12,   float m13,  
           float m20,   float m21,   float m22,   float m23,  
           float m30,   float m31,   float m32,   float m33 )
           {
           m[0][0] = m00; m[0][1] = m01; m[0][2] = m02; m[0][3] = m03;
           m[1][0] = m10; m[1][1] = m11; m[1][2] = m12; m[1][3] = m13;
           m[2][0] = m20; m[2][1] = m21; m[2][2] = m22; m[2][3] = m23;
           m[3][0] = m30; m[3][1] = m31; m[3][2] = m32; m[3][3] = m33;
           }
           //! Copy constructor
      41   inline_ Matrix4x4(  const Matrix4x4& mat ) { CopyMemory(  m,   &mat.m,   16*sizeof(  float ) ); }
           //! Destructor.
      43   inline_ ~Matrix4x4(   ) {}
          
          
           //! Assign values (  rotation only )
           inline_ Matrix4x4& Set(   float m00,   float m01,   float m02,  
           float m10,   float m11,   float m12,  
           float m20,   float m21,   float m22 )
           {
           m[0][0] = m00; m[0][1] = m01; m[0][2] = m02;
           m[1][0] = m10; m[1][1] = m11; m[1][2] = m12;
           m[2][0] = m20; m[2][1] = m21; m[2][2] = m22;
           return *this;
           }
           //! Assign values
      57   inline_ Matrix4x4& Set(   float m00,   float m01,   float m02,   float m03,  
           float m10,   float m11,   float m12,   float m13,  
           float m20,   float m21,   float m22,   float m23,  
           float m30,   float m31,   float m32,   float m33 )
           {
           m[0][0] = m00; m[0][1] = m01; m[0][2] = m02; m[0][3] = m03;
           m[1][0] = m10; m[1][1] = m11; m[1][2] = m12; m[1][3] = m13;
           m[2][0] = m20; m[2][1] = m21; m[2][2] = m22; m[2][3] = m23;
           m[3][0] = m30; m[3][1] = m31; m[3][2] = m32; m[3][3] = m33;
           return *this;
           }
          
           //! Copy from a Matrix4x4
      70   inline_ void Copy(  const Matrix4x4& source ) { CopyMemory(  m,   source.m,   16*sizeof(  float ) ); }
          
           // Row-column access
           //! Returns a row.
      74   inline_ void GetRow(  const udword r,   HPoint& p ) const { p.x=m[r][0]; p.y=m[r][1]; p.z=m[r][2]; p.w=m[r][3]; }
           //! Returns a row.
      76   inline_ void GetRow(  const udword r,   Point& p ) const { p.x=m[r][0]; p.y=m[r][1]; p.z=m[r][2]; }
           //! Returns a row.
      78   inline_ const HPoint& GetRow(  const udword r ) const { return *(  const HPoint* )&m[r][0]; }
           //! Returns a row.
      80   inline_ HPoint& GetRow(  const udword r ) { return *(  HPoint* )&m[r][0]; }
           //! Sets a row.
      82   inline_ void SetRow(  const udword r,   const HPoint& p ) { m[r][0]=p.x; m[r][1]=p.y; m[r][2]=p.z; m[r][3]=p.w; }
           //! Sets a row.
      84   inline_ void SetRow(  const udword r,   const Point& p ) { m[r][0]=p.x; m[r][1]=p.y; m[r][2]=p.z; m[r][3]= (  r!=3 ) ? 0.0f : 1.0f; }
           //! Returns a column.
      86   inline_ void GetCol(  const udword c,   HPoint& p ) const { p.x=m[0][c]; p.y=m[1][c]; p.z=m[2][c]; p.w=m[3][c]; }
           //! Returns a column.
      88   inline_ void GetCol(  const udword c,   Point& p ) const { p.x=m[0][c]; p.y=m[1][c]; p.z=m[2][c]; }
           //! Sets a column.
      90   inline_ void SetCol(  const udword c,   const HPoint& p ) { m[0][c]=p.x; m[1][c]=p.y; m[2][c]=p.z; m[3][c]=p.w; }
           //! Sets a column.
      92   inline_ void SetCol(  const udword c,   const Point& p ) { m[0][c]=p.x; m[1][c]=p.y; m[2][c]=p.z; m[3][c]= (  c!=3 ) ? 0.0f : 1.0f; }
          
           // Translation
           //! Returns the translation part of the matrix.
      96   inline_ const HPoint& GetTrans(   ) const { return GetRow(  3 ); }
           //! Gets the translation part of the matrix
      98   inline_ void GetTrans(  Point& p ) const { p.x=m[3][0]; p.y=m[3][1]; p.z=m[3][2]; }
           //! Sets the translation part of the matrix,   from a Point.
     100   inline_ void SetTrans(  const Point& p ) { m[3][0]=p.x; m[3][1]=p.y; m[3][2]=p.z; }
           //! Sets the translation part of the matrix,   from a HPoint.
     102   inline_ void SetTrans(  const HPoint& p ) { m[3][0]=p.x; m[3][1]=p.y; m[3][2]=p.z; m[3][3]=p.w; }
           //! Sets the translation part of the matrix,   from floats.
     104   inline_ void SetTrans(  float tx,   float ty,   float tz ) { m[3][0]=tx; m[3][1]=ty; m[3][2]=tz; }
          
           // Scale
           //! Sets the scale from a Point. The point is put on the diagonal.
     108   inline_ void SetScale(  const Point& p ) { m[0][0]=p.x; m[1][1]=p.y; m[2][2]=p.z; }
           //! Sets the scale from floats. Values are put on the diagonal.
     110   inline_ void SetScale(  float sx,   float sy,   float sz ) { m[0][0]=sx; m[1][1]=sy; m[2][2]=sz; }
           //! Scales from a Point. Each row is multiplied by a component.
     112   void Scale(  const Point& p )
           {
           m[0][0] *= p.x; m[1][0] *= p.y; m[2][0] *= p.z;
           m[0][1] *= p.x; m[1][1] *= p.y; m[2][1] *= p.z;
           m[0][2] *= p.x; m[1][2] *= p.y; m[2][2] *= p.z;
           }
           //! Scales from floats. Each row is multiplied by a value.
     119   void Scale(  float sx,   float sy,   float sz )
           {
           m[0][0] *= sx; m[1][0] *= sy; m[2][0] *= sz;
           m[0][1] *= sx; m[1][1] *= sy; m[2][1] *= sz;
           m[0][2] *= sx; m[1][2] *= sy; m[2][2] *= sz;
           }
          /*
           //! Returns a row.
           inline_ HPoint GetRow(  const udword row ) const { return mRow[row]; }
           //! Sets a row.
           inline_ Matrix4x4& SetRow(  const udword row,   const HPoint& p ) { mRow[row] = p; return *this; }
           //! Sets a row.
           Matrix4x4& SetRow(  const udword row,   const Point& p )
           {
           m[row][0] = p.x;
           m[row][1] = p.y;
           m[row][2] = p.z;
           m[row][3] = (  row != 3 ) ? 0.0f : 1.0f;
           return *this;
           }
           //! Returns a column.
           HPoint GetCol(  const udword col ) const
           {
           HPoint Res;
           Res.x = m[0][col];
           Res.y = m[1][col];
           Res.z = m[2][col];
           Res.w = m[3][col];
           return Res;
           }
           //! Sets a column.
           Matrix4x4& SetCol(  const udword col,   const HPoint& p )
           {
           m[0][col] = p.x;
           m[1][col] = p.y;
           m[2][col] = p.z;
           m[3][col] = p.w;
           return *this;
           }
           //! Sets a column.
           Matrix4x4& SetCol(  const udword col,   const Point& p )
           {
           m[0][col] = p.x;
           m[1][col] = p.y;
           m[2][col] = p.z;
           m[3][col] = (  col != 3 ) ? 0.0f : 1.0f;
           return *this;
           }
          */
           //! Computes the trace. The trace is the sum of the 4 diagonal components.
     169   inline_ float Trace(   ) const { return m[0][0] + m[1][1] + m[2][2] + m[3][3]; }
           //! Computes the trace of the upper 3x3 matrix.
     171   inline_ float Trace3x3(   ) const { return m[0][0] + m[1][1] + m[2][2]; }
           //! Clears the matrix.
     173   inline_ void Zero(   ) { ZeroMemory(  &m,   sizeof(  m ) ); }
           //! Sets the identity matrix.
     175   inline_ void Identity(   ) { Zero(   ); m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0f; }
           //! Checks for identity
     177   inline_ bool IsIdentity(   ) const
           {
           if(  IR(  m[0][0] )!=IEEE_1_0 ) return false;
           if(  IR(  m[0][1] )!=0 ) return false;
           if(  IR(  m[0][2] )!=0 ) return false;
           if(  IR(  m[0][3] )!=0 ) return false;
          
           if(  IR(  m[1][0] )!=0 ) return false;
           if(  IR(  m[1][1] )!=IEEE_1_0 ) return false;
           if(  IR(  m[1][2] )!=0 ) return false;
           if(  IR(  m[1][3] )!=0 ) return false;
          
           if(  IR(  m[2][0] )!=0 ) return false;
           if(  IR(  m[2][1] )!=0 ) return false;
           if(  IR(  m[2][2] )!=IEEE_1_0 ) return false;
           if(  IR(  m[2][3] )!=0 ) return false;
          
           if(  IR(  m[3][0] )!=0 ) return false;
           if(  IR(  m[3][1] )!=0 ) return false;
           if(  IR(  m[3][2] )!=0 ) return false;
           if(  IR(  m[3][3] )!=IEEE_1_0 ) return false;
           return true;
           }
          
           //! Checks matrix validity
     202   inline_ BOOL IsValid(   ) const
           {
           for(  udword j=0;j<4;j++ )
           {
           for(  udword i=0;i<4;i++ )
           {
           if(  !IsValidFloat(  m[j][i] ) ) return FALSE;
           }
           }
           return TRUE;
           }
          
           //! Sets a rotation matrix around the X axis.
     215   void RotX(  float angle ) { float Cos = cosf(  angle ),   Sin = sinf(  angle ); Identity(   ); m[1][1] = m[2][2] = Cos; m[2][1] = -Sin; m[1][2] = Sin; }
           //! Sets a rotation matrix around the Y axis.
     217   void RotY(  float angle ) { float Cos = cosf(  angle ),   Sin = sinf(  angle ); Identity(   ); m[0][0] = m[2][2] = Cos; m[2][0] = Sin; m[0][2] = -Sin; }
           //! Sets a rotation matrix around the Z axis.
     219   void RotZ(  float angle ) { float Cos = cosf(  angle ),   Sin = sinf(  angle ); Identity(   ); m[0][0] = m[1][1] = Cos; m[1][0] = -Sin; m[0][1] = Sin; }
          
           //! Makes a rotation matrix about an arbitrary axis
     222   Matrix4x4& Rot(  float angle,   Point& p1,   Point& p2 );
          
           //! Transposes the matrix.
     225   void Transpose(   )
           {
           IR(  m[1][0] ) ^= IR(  m[0][1] ); IR(  m[0][1] ) ^= IR(  m[1][0] ); IR(  m[1][0] ) ^= IR(  m[0][1] );
           IR(  m[2][0] ) ^= IR(  m[0][2] ); IR(  m[0][2] ) ^= IR(  m[2][0] ); IR(  m[2][0] ) ^= IR(  m[0][2] );
           IR(  m[3][0] ) ^= IR(  m[0][3] ); IR(  m[0][3] ) ^= IR(  m[3][0] ); IR(  m[3][0] ) ^= IR(  m[0][3] );
           IR(  m[1][2] ) ^= IR(  m[2][1] ); IR(  m[2][1] ) ^= IR(  m[1][2] ); IR(  m[1][2] ) ^= IR(  m[2][1] );
           IR(  m[1][3] ) ^= IR(  m[3][1] ); IR(  m[3][1] ) ^= IR(  m[1][3] ); IR(  m[1][3] ) ^= IR(  m[3][1] );
           IR(  m[2][3] ) ^= IR(  m[3][2] ); IR(  m[3][2] ) ^= IR(  m[2][3] ); IR(  m[2][3] ) ^= IR(  m[3][2] );
           }
          
           //! Computes a cofactor. Used for matrix inversion.
     236   float CoFactor(  udword row,   udword col ) const;
           //! Computes the determinant of the matrix.
     238   float Determinant(   ) const;
           //! Inverts the matrix. Determinant must be different from zero,   else matrix can't be inverted.
     240   Matrix4x4& Invert(   );
          // Matrix& ComputeAxisMatrix(  Point& axis,   float angle );
          
           // Cast operators
           //! Casts a Matrix4x4 to a Matrix3x3.
     245   inline_ operator Matrix3x3(   ) const
           {
           return Matrix3x3(  
           m[0][0],   m[0][1],   m[0][2],  
           m[1][0],   m[1][1],   m[1][2],  
           m[2][0],   m[2][1],   m[2][2] );
           }
           //! Casts a Matrix4x4 to a Quat.
     253   operator Quat(   ) const;
           //! Casts a Matrix4x4 to a PR.
     255   operator PR(   ) const;
          
           // Arithmetic operators
           //! Operator for Matrix4x4 Plus = Matrix4x4 + Matrix4x4;
           inline_ Matrix4x4 operator+(  const Matrix4x4& mat ) const
           {
     261   return Matrix4x4(  
           m[0][0]+mat.m[0][0],   m[0][1]+mat.m[0][1],   m[0][2]+mat.m[0][2],   m[0][3]+mat.m[0][3],  
           m[1][0]+mat.m[1][0],   m[1][1]+mat.m[1][1],   m[1][2]+mat.m[1][2],   m[1][3]+mat.m[1][3],  
           m[2][0]+mat.m[2][0],   m[2][1]+mat.m[2][1],   m[2][2]+mat.m[2][2],   m[2][3]+mat.m[2][3],  
           m[3][0]+mat.m[3][0],   m[3][1]+mat.m[3][1],   m[3][2]+mat.m[3][2],   m[3][3]+mat.m[3][3] );
           }
          
           //! Operator for Matrix4x4 Minus = Matrix4x4 - Matrix4x4;
           inline_ Matrix4x4 operator-(  const Matrix4x4& mat ) const
           {
           return Matrix4x4(  
           m[0][0]-mat.m[0][0],   m[0][1]-mat.m[0][1],   m[0][2]-mat.m[0][2],   m[0][3]-mat.m[0][3],  
           m[1][0]-mat.m[1][0],   m[1][1]-mat.m[1][1],   m[1][2]-mat.m[1][2],   m[1][3]-mat.m[1][3],  
           m[2][0]-mat.m[2][0],   m[2][1]-mat.m[2][1],   m[2][2]-mat.m[2][2],   m[2][3]-mat.m[2][3],  
           m[3][0]-mat.m[3][0],   m[3][1]-mat.m[3][1],   m[3][2]-mat.m[3][2],   m[3][3]-mat.m[3][3] );
           }
          
           //! Operator for Matrix4x4 Mul = Matrix4x4 * Matrix4x4;
           inline_ Matrix4x4 operator*(  const Matrix4x4& mat ) const
           {
           return Matrix4x4(  
           m[0][0]*mat.m[0][0] + m[0][1]*mat.m[1][0] + m[0][2]*mat.m[2][0] + m[0][3]*mat.m[3][0],  
           m[0][0]*mat.m[0][1] + m[0][1]*mat.m[1][1] + m[0][2]*mat.m[2][1] + m[0][3]*mat.m[3][1],  
           m[0][0]*mat.m[0][2] + m[0][1]*mat.m[1][2] + m[0][2]*mat.m[2][2] + m[0][3]*mat.m[3][2],  
           m[0][0]*mat.m[0][3] + m[0][1]*mat.m[1][3] + m[0][2]*mat.m[2][3] + m[0][3]*mat.m[3][3],  
          
           m[1][0]*mat.m[0][0] + m[1][1]*mat.m[1][0] + m[1][2]*mat.m[2][0] + m[1][3]*mat.m[3][0],  
           m[1][0]*mat.m[0][1] + m[1][1]*mat.m[1][1] + m[1][2]*mat.m[2][1] + m[1][3]*mat.m[3][1],  
           m[1][0]*mat.m[0][2] + m[1][1]*mat.m[1][2] + m[1][2]*mat.m[2][2] + m[1][3]*mat.m[3][2],  
           m[1][0]*mat.m[0][3] + m[1][1]*mat.m[1][3] + m[1][2]*mat.m[2][3] + m[1][3]*mat.m[3][3],  
          
           m[2][0]*mat.m[0][0] + m[2][1]*mat.m[1][0] + m[2][2]*mat.m[2][0] + m[2][3]*mat.m[3][0],  
           m[2][0]*mat.m[0][1] + m[2][1]*mat.m[1][1] + m[2][2]*mat.m[2][1] + m[2][3]*mat.m[3][1],  
           m[2][0]*mat.m[0][2] + m[2][1]*mat.m[1][2] + m[2][2]*mat.m[2][2] + m[2][3]*mat.m[3][2],  
           m[2][0]*mat.m[0][3] + m[2][1]*mat.m[1][3] + m[2][2]*mat.m[2][3] + m[2][3]*mat.m[3][3],  
          
           m[3][0]*mat.m[0][0] + m[3][1]*mat.m[1][0] + m[3][2]*mat.m[2][0] + m[3][3]*mat.m[3][0],  
           m[3][0]*mat.m[0][1] + m[3][1]*mat.m[1][1] + m[3][2]*mat.m[2][1] + m[3][3]*mat.m[3][1],  
           m[3][0]*mat.m[0][2] + m[3][1]*mat.m[1][2] + m[3][2]*mat.m[2][2] + m[3][3]*mat.m[3][2],  
           m[3][0]*mat.m[0][3] + m[3][1]*mat.m[1][3] + m[3][2]*mat.m[2][3] + m[3][3]*mat.m[3][3] );
           }
          
           //! Operator for HPoint Mul = Matrix4x4 * HPoint;
           inline_ HPoint operator*(  const HPoint& v ) const { return HPoint(  GetRow(  0 )|v,   GetRow(  1 )|v,   GetRow(  2 )|v,   GetRow(  3 )|v ); }
          
           //! Operator for Point Mul = Matrix4x4 * Point;
           inline_ Point operator*(  const Point& v ) const
           {
           return Point(   m[0][0]*v.x + m[0][1]*v.y + m[0][2]*v.z + m[0][3],  
           m[1][0]*v.x + m[1][1]*v.y + m[1][2]*v.z + m[1][3],  
           m[2][0]*v.x + m[2][1]*v.y + m[2][2]*v.z + m[2][3]  );
           }
          
           //! Operator for Matrix4x4 Scale = Matrix4x4 * float;
           inline_ Matrix4x4 operator*(  float s ) const
           {
           return Matrix4x4(  
           m[0][0]*s,   m[0][1]*s,   m[0][2]*s,   m[0][3]*s,  
           m[1][0]*s,   m[1][1]*s,   m[1][2]*s,   m[1][3]*s,  
           m[2][0]*s,   m[2][1]*s,   m[2][2]*s,   m[2][3]*s,  
           m[3][0]*s,   m[3][1]*s,   m[3][2]*s,   m[3][3]*s );
           }
          
           //! Operator for Matrix4x4 Scale = float * Matrix4x4;
           inline_ friend Matrix4x4 operator*(  float s,   const Matrix4x4& mat )
           {
           return Matrix4x4(  
           s*mat.m[0][0],   s*mat.m[0][1],   s*mat.m[0][2],   s*mat.m[0][3],  
           s*mat.m[1][0],   s*mat.m[1][1],   s*mat.m[1][2],   s*mat.m[1][3],  
           s*mat.m[2][0],   s*mat.m[2][1],   s*mat.m[2][2],   s*mat.m[2][3],  
           s*mat.m[3][0],   s*mat.m[3][1],   s*mat.m[3][2],   s*mat.m[3][3] );
           }
          
           //! Operator for Matrix4x4 Div = Matrix4x4 / float;
           inline_ Matrix4x4 operator/(  float s ) const
           {
           if(  s ) s = 1.0f / s;
          
           return Matrix4x4(  
           m[0][0]*s,   m[0][1]*s,   m[0][2]*s,   m[0][3]*s,  
           m[1][0]*s,   m[1][1]*s,   m[1][2]*s,   m[1][3]*s,  
           m[2][0]*s,   m[2][1]*s,   m[2][2]*s,   m[2][3]*s,  
           m[3][0]*s,   m[3][1]*s,   m[3][2]*s,   m[3][3]*s );
           }
          
           //! Operator for Matrix4x4 Div = float / Matrix4x4;
           inline_ friend Matrix4x4 operator/(  float s,   const Matrix4x4& mat )
           {
           return Matrix4x4(  
           s/mat.m[0][0],   s/mat.m[0][1],   s/mat.m[0][2],   s/mat.m[0][3],  
           s/mat.m[1][0],   s/mat.m[1][1],   s/mat.m[1][2],   s/mat.m[1][3],  
           s/mat.m[2][0],   s/mat.m[2][1],   s/mat.m[2][2],   s/mat.m[2][3],  
           s/mat.m[3][0],   s/mat.m[3][1],   s/mat.m[3][2],   s/mat.m[3][3] );
           }
          
           //! Operator for Matrix4x4 += Matrix4x4;
           inline_ Matrix4x4& operator+=(  const Matrix4x4& mat )
           {
           m[0][0]+=mat.m[0][0]; m[0][1]+=mat.m[0][1]; m[0][2]+=mat.m[0][2]; m[0][3]+=mat.m[0][3];
           m[1][0]+=mat.m[1][0]; m[1][1]+=mat.m[1][1]; m[1][2]+=mat.m[1][2]; m[1][3]+=mat.m[1][3];
           m[2][0]+=mat.m[2][0]; m[2][1]+=mat.m[2][1]; m[2][2]+=mat.m[2][2]; m[2][3]+=mat.m[2][3];
           m[3][0]+=mat.m[3][0]; m[3][1]+=mat.m[3][1]; m[3][2]+=mat.m[3][2]; m[3][3]+=mat.m[3][3];
           return *this;
           }
          
           //! Operator for Matrix4x4 -= Matrix4x4;
           inline_ Matrix4x4& operator-=(  const Matrix4x4& mat )
           {
           m[0][0]-=mat.m[0][0]; m[0][1]-=mat.m[0][1]; m[0][2]-=mat.m[0][2]; m[0][3]-=mat.m[0][3];
           m[1][0]-=mat.m[1][0]; m[1][1]-=mat.m[1][1]; m[1][2]-=mat.m[1][2]; m[1][3]-=mat.m[1][3];
           m[2][0]-=mat.m[2][0]; m[2][1]-=mat.m[2][1]; m[2][2]-=mat.m[2][2]; m[2][3]-=mat.m[2][3];
           m[3][0]-=mat.m[3][0]; m[3][1]-=mat.m[3][1]; m[3][2]-=mat.m[3][2]; m[3][3]-=mat.m[3][3];
           return *this;
           }
          
           //! Operator for Matrix4x4 *= Matrix4x4;
           Matrix4x4& operator*=(  const Matrix4x4& mat )
           {
           HPoint TempRow;
          
           GetRow(  0,   TempRow );
           m[0][0] = TempRow.x*mat.m[0][0] + TempRow.y*mat.m[1][0] + TempRow.z*mat.m[2][0] + TempRow.w*mat.m[3][0];
           m[0][1] = TempRow.x*mat.m[0][1] + TempRow.y*mat.m[1][1] + TempRow.z*mat.m[2][1] + TempRow.w*mat.m[3][1];
           m[0][2] = TempRow.x*mat.m[0][2] + TempRow.y*mat.m[1][2] + TempRow.z*mat.m[2][2] + TempRow.w*mat.m[3][2];
           m[0][3] = TempRow.x*mat.m[0][3] + TempRow.y*mat.m[1][3] + TempRow.z*mat.m[2][3] + TempRow.w*mat.m[3][3];
          
           GetRow(  1,   TempRow );
           m[1][0] = TempRow.x*mat.m[0][0] + TempRow.y*mat.m[1][0] + TempRow.z*mat.m[2][0] + TempRow.w*mat.m[3][0];
           m[1][1] = TempRow.x*mat.m[0][1] + TempRow.y*mat.m[1][1] + TempRow.z*mat.m[2][1] + TempRow.w*mat.m[3][1];
           m[1][2] = TempRow.x*mat.m[0][2] + TempRow.y*mat.m[1][2] + TempRow.z*mat.m[2][2] + TempRow.w*mat.m[3][2];
           m[1][3] = TempRow.x*mat.m[0][3] + TempRow.y*mat.m[1][3] + TempRow.z*mat.m[2][3] + TempRow.w*mat.m[3][3];
          
           GetRow(  2,   TempRow );
           m[2][0] = TempRow.x*mat.m[0][0] + TempRow.y*mat.m[1][0] + TempRow.z*mat.m[2][0] + TempRow.w*mat.m[3][0];
           m[2][1] = TempRow.x*mat.m[0][1] + TempRow.y*mat.m[1][1] + TempRow.z*mat.m[2][1] + TempRow.w*mat.m[3][1];
           m[2][2] = TempRow.x*mat.m[0][2] + TempRow.y*mat.m[1][2] + TempRow.z*mat.m[2][2] + TempRow.w*mat.m[3][2];
           m[2][3] = TempRow.x*mat.m[0][3] + TempRow.y*mat.m[1][3] + TempRow.z*mat.m[2][3] + TempRow.w*mat.m[3][3];
          
           GetRow(  3,   TempRow );
           m[3][0] = TempRow.x*mat.m[0][0] + TempRow.y*mat.m[1][0] + TempRow.z*mat.m[2][0] + TempRow.w*mat.m[3][0];
           m[3][1] = TempRow.x*mat.m[0][1] + TempRow.y*mat.m[1][1] + TempRow.z*mat.m[2][1] + TempRow.w*mat.m[3][1];
           m[3][2] = TempRow.x*mat.m[0][2] + TempRow.y*mat.m[1][2] + TempRow.z*mat.m[2][2] + TempRow.w*mat.m[3][2];
           m[3][3] = TempRow.x*mat.m[0][3] + TempRow.y*mat.m[1][3] + TempRow.z*mat.m[2][3] + TempRow.w*mat.m[3][3];
          
           return *this;
           }
          
           //! Operator for Matrix4x4 *= float;
           inline_ Matrix4x4& operator*=(  float s )
           {
           m[0][0]*=s; m[0][1]*=s; m[0][2]*=s; m[0][3]*=s;
           m[1][0]*=s; m[1][1]*=s; m[1][2]*=s; m[1][3]*=s;
           m[2][0]*=s; m[2][1]*=s; m[2][2]*=s; m[2][3]*=s;
           m[3][0]*=s; m[3][1]*=s; m[3][2]*=s; m[3][3]*=s;
           return *this;
           }
          
           //! Operator for Matrix4x4 /= float;
           inline_ Matrix4x4& operator/=(  float s )
           {
           if(  s ) s = 1.0f / s;
           m[0][0]*=s; m[0][1]*=s; m[0][2]*=s; m[0][3]*=s;
           m[1][0]*=s; m[1][1]*=s; m[1][2]*=s; m[1][3]*=s;
           m[2][0]*=s; m[2][1]*=s; m[2][2]*=s; m[2][3]*=s;
           m[3][0]*=s; m[3][1]*=s; m[3][2]*=s; m[3][3]*=s;
           return *this;
           }
          
           inline_ const HPoint& operator[](  int row ) const { return *(  const HPoint* )&m[row][0]; }
           inline_ HPoint& operator[](  int row ) { return *(  HPoint* )&m[row][0]; }
          
           public:
          
           float m[4][4];
           };
          
           //! Quickly rotates & translates a vector,   using the 4x3 part of a 4x4 matrix
           inline_ void TransformPoint4x3(  Point& dest,   const Point& source,   const Matrix4x4& rot )
           {
           dest.x = rot.m[3][0] + source.x * rot.m[0][0] + source.y * rot.m[1][0] + source.z * rot.m[2][0];
           dest.y = rot.m[3][1] + source.x * rot.m[0][1] + source.y * rot.m[1][1] + source.z * rot.m[2][1];
           dest.z = rot.m[3][2] + source.x * rot.m[0][2] + source.y * rot.m[1][2] + source.z * rot.m[2][2];
           }
          
           //! Quickly rotates a vector,   using the 3x3 part of a 4x4 matrix
           inline_ void TransformPoint3x3(  Point& dest,   const Point& source,   const Matrix4x4& rot )
           {
           dest.x = source.x * rot.m[0][0] + source.y * rot.m[1][0] + source.z * rot.m[2][0];
           dest.y = source.x * rot.m[0][1] + source.y * rot.m[1][1] + source.z * rot.m[2][1];
           dest.z = source.x * rot.m[0][2] + source.y * rot.m[1][2] + source.z * rot.m[2][2];
           }
          
           void InvertPRMatrix(  Matrix4x4& dest,   const Matrix4x4& src );
           void InvertPRSMatrix(  Matrix4x4& dest,   const Matrix4x4& src );
           void NormalizePRSMatrix(  Matrix4x4& dest,   Point& scale,   const Matrix4x4& src );
          
          #endif // __ICEMATRIX4X4_H__
          

./components/ogre/ogreopcode/include/Opcode/Ice/IceMemoryMacros.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains all memory macros.
           * \file IceMemoryMacros.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEMEMORYMACROS_H__
          #define __ICEMEMORYMACROS_H__
          
          #undef ZeroMemory
          #undef CopyMemory
          #undef MoveMemory
          #undef FillMemory
          
           //! Clears a buffer.
           //! \param addr [in] buffer address
           //! \param size [in] buffer length
           //! \see FillMemory
           //! \see StoreDwords
           //! \see CopyMemory
           //! \see MoveMemory
      27   inline_ void ZeroMemory(  void* addr,   udword size ) { memset(  addr,   0,   size ); }
          
           //! Fills a buffer with a given byte.
           //! \param addr [in] buffer address
           //! \param size [in] buffer length
           //! \param val [in] the byte value
           //! \see StoreDwords
           //! \see ZeroMemory
           //! \see CopyMemory
           //! \see MoveMemory
      37   inline_ void FillMemory(  void* dest,   udword size,   ubyte val ) { memset(  dest,   val,   size ); }
          
           //! Fills a buffer with a given dword.
           //! \param addr [in] buffer address
           //! \param nb [in] number of dwords to write
           //! \param value [in] the dword value
           //! \see FillMemory
           //! \see ZeroMemory
           //! \see CopyMemory
           //! \see MoveMemory
           //! \warning writes nb*4 bytes !
      48   inline_ void StoreDwords(  udword* dest,   udword nb,   udword value )
           {
           // The asm code below **SHOULD** be equivalent to one of those C versions
           // or the other if your compiled is good: (  checked on VC++ 6.0 )
           //
           // 1 ) while(  nb-- ) *dest++ = value;
           //
           // 2 ) for(  udword i=0;i<nb;i++ ) dest[i] = value;
           //
          #ifdef _MSC_VER
           _asm push eax
           _asm push ecx
           _asm push edi
           _asm mov edi,   dest
           _asm mov ecx,   nb
           _asm mov eax,   value
           _asm rep stosd
           _asm pop edi
           _asm pop ecx
           _asm pop eax
          #else
           while(  nb-- ) *dest++ = value;
          #endif
           }
          
           //! Copies a buffer.
           //! \param addr [in] destination buffer address
           //! \param addr [in] source buffer address
           //! \param size [in] buffer length
           //! \see ZeroMemory
           //! \see FillMemory
           //! \see StoreDwords
           //! \see MoveMemory
      81   inline_ void CopyMemory(  void* dest,   const void* src,   udword size ) { memcpy(  dest,   src,   size ); }
          
           //! Moves a buffer.
           //! \param addr [in] destination buffer address
           //! \param addr [in] source buffer address
           //! \param size [in] buffer length
           //! \see ZeroMemory
           //! \see FillMemory
           //! \see StoreDwords
           //! \see CopyMemory
      91   inline_ void MoveMemory(  void* dest,   const void* src,   udword size ) { memmove(  dest,   src,   size ); }
          
           #define SIZEOFOBJECT sizeof(  *this ) //!< Gives the size of current object. Avoid some mistakes (  e.g. "sizeof(  this )" ).
           //#define CLEAROBJECT { memset(  this,   0,   SIZEOFOBJECT ); } //!< Clears current object. Laziness is my business. HANDLE WITH CARE.
           #define DELETESINGLE(  x ) if (  x ) { delete x; x = null; } //!< Deletes an instance of a class.
           #define DELETEARRAY(  x ) if (  x ) { delete []x; x = null; } //!< Deletes an array.
           #define SAFE_RELEASE(  x ) if (  x ) { (  x )->Release(   ); (  x ) = null; } //!< Safe D3D-style release
           #define SAFE_DESTRUCT(  x ) if (  x ) { (  x )->SelfDestruct(   ); (  x ) = null; } //!< Safe ICE-style release
          
          #ifdef __ICEERROR_H__
           #define CHECKALLOC(  x ) if(  !x ) return SetIceError(  "Out of memory.",   EC_OUT_OF_MEMORY ); //!< Standard alloc checking. HANDLE WITH CARE.
          #else
           #define CHECKALLOC(  x ) if(  !x ) return false;
          #endif
          
           //! Standard allocation cycle
           #define SAFE_ALLOC(  ptr,   type,   count ) DELETEARRAY(  ptr ); ptr = new type[count]; CHECKALLOC(  ptr );
          
          #endif // __ICEMEMORYMACROS_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceOBB.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains OBB-related code. (  oriented bounding box )
           * \file IceOBB.h
           * \author Pierre Terdiman
           * \date January,   13,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEOBB_H__
          #define __ICEOBB_H__
          
           // Forward declarations
      16   class LSS;
          
      18   class OBB
           {
           public:
           //! Constructor
      22   inline_ OBB(   ) {}
           //! Constructor
      24   inline_ OBB(  const Point& center,   const Point& extents,   const Matrix3x3& rot ) : mCenter(  center ),   mExtents(  extents ),   mRot(  rot ) {}
           //! Destructor
      26   inline_ ~OBB(   ) {}
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups an empty OBB.
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      33   void SetEmpty(   )
           {
           mCenter.Zero(   );
           mExtents.Set(  MIN_FLOAT,   MIN_FLOAT,   MIN_FLOAT );
           mRot.Identity(   );
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Tests if a point is contained within the OBB.
           * \param p [in] the world point to test
           * \return true if inside the OBB
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      47   bool ContainsPoint(  const Point& p ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Builds an OBB from an AABB and a world transform.
           * \param aabb [in] the aabb
           * \param mat [in] the world transform
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      56   void Create(  const AABB& aabb,   const Matrix4x4& mat );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Recomputes the OBB after an arbitrary transform by a 4x4 matrix.
           * \param mtx [in] the transform matrix
           * \param obb [out] the transformed OBB
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void Rotate(  const Matrix4x4& mtx,   OBB& obb ) const
           {
           // The extents remain constant
           obb.mExtents = mExtents;
           // The center gets x-formed
           obb.mCenter = mCenter * mtx;
           // Combine rotations
           obb.mRot = mRot * Matrix3x3(  mtx );
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks the OBB is valid.
           * \return true if the box is valid
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      81   inline_ BOOL IsValid(   ) const
           {
           // Consistency condition for (  Center,   Extents ) boxes: Extents >= 0.0f
           if(  mExtents.x < 0.0f ) return FALSE;
           if(  mExtents.y < 0.0f ) return FALSE;
           if(  mExtents.z < 0.0f ) return FALSE;
           return TRUE;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes the obb planes.
           * \param planes [out] 6 box planes
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      97   bool ComputePlanes(  Plane* planes ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes the obb points.
           * \param pts [out] 8 box points
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     106   bool ComputePoints(  Point* pts ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes vertex normals.
           * \param pts [out] 8 box points
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     115   bool ComputeVertexNormals(  Point* pts ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Returns edges.
           * \return 24 indices (  12 edges ) indexing the list returned by ComputePoints(   )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     123   const udword* GetEdges(   ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Returns local edge normals.
           * \return edge normals in local space
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     131   const Point* GetLocalEdgeNormals(   ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Returns world edge normal
           * \param edge_index [in] 0 <= edge index < 12
           * \param world_normal [out] edge normal in world space
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     140   void ComputeWorldEdgeNormal(  udword edge_index,   Point& world_normal ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes an LSS surrounding the OBB.
           * \param lss [out] the LSS
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     148   void ComputeLSS(  LSS& lss ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks the OBB is inside another OBB.
           * \param box [in] the other OBB
           * \return TRUE if we're inside the other box
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     157   BOOL IsInside(  const OBB& box ) const;
          
     159   inline_ const Point& GetCenter(   ) const { return mCenter; }
     160   inline_ const Point& GetExtents(   ) const { return mExtents; }
     161   inline_ const Matrix3x3& GetRot(   ) const { return mRot; }
          
     163   inline_ void GetRotatedExtents(  Matrix3x3& extents ) const
           {
           extents = mRot;
           extents.Scale(  mExtents );
           }
          
           Point mCenter; //!< B for Box
           Point mExtents; //!< B for Bounding
           Matrix3x3 mRot; //!< O for Oriented
          
           // Orientation is stored in row-major format,  
           // i.e. rows = eigen vectors of the covariance matrix
           };
          
          #endif // __ICEOBB_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IcePairs.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a simple pair class.
           * \file IcePairs.h
           * \author Pierre Terdiman
           * \date January,   13,   2003
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEPAIRS_H__
          #define __ICEPAIRS_H__
          
           //! A generic couple structure
           struct Pair
           {
           inline_ Pair(   ) {}
           inline_ Pair(  udword i0,   udword i1 ) : id0(  i0 ),   id1(  i1 ) {}
          
           udword id0; //!< First index of the pair
           udword id1; //!< Second index of the pair
           };
          
      25   class Pairs : private Container
           {
           public:
           // Constructor / Destructor
      29   Pairs(   ) {}
      30   ~Pairs(   ) {}
          
           inline_ udword GetNbPairs(   ) const { return GetNbEntries(   )>>1; }
      33   inline_ const Pair* GetPairs(   ) const { return (  const Pair* )GetEntries(   ); }
      34   inline_ const Pair* GetPair(  udword i ) const { return (  const Pair* )&GetEntries(   )[i+i]; }
          
      36   inline_ BOOL HasPairs(   ) const { return IsNotEmpty(   ); }
          
      38   inline_ void ResetPairs(   ) { Reset(   ); }
      39   inline_ void DeleteLastPair(   ) { DeleteLastEntry(   ); DeleteLastEntry(   ); }
          
      41   inline_ void AddPair(  const Pair& p ) { Add(  p.id0 ).Add(  p.id1 ); }
      42   inline_ void AddPair(  udword id0,   udword id1 ) { Add(  id0 ).Add(  id1 ); }
           };
          
          #endif // __ICEPAIRS_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IcePlane.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for planes.
           * \file IcePlane.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEPLANE_H__
          #define __ICEPLANE_H__
          
           #define PLANE_EPSILON (  1.0e-7f )
          
      17   class Plane
           {
           public:
           //! Constructor
      21   inline_ Plane(   ) { }
           //! Constructor from a normal and a distance
      23   inline_ Plane(  float nx,   float ny,   float nz,   float d ) { Set(  nx,   ny,   nz,   d ); }
           //! Constructor from a point on the plane and a normal
      25   inline_ Plane(  const Point& p,   const Point& n ) { Set(  p,   n ); }
           //! Constructor from three points
      27   inline_ Plane(  const Point& p0,   const Point& p1,   const Point& p2 ) { Set(  p0,   p1,   p2 ); }
           //! Constructor from a normal and a distance
      29   inline_ Plane(  const Point& _n,   float _d ) { n = _n; d = _d; }
           //! Copy constructor
      31   inline_ Plane(  const Plane& plane ) : n(  plane.n ),   d(  plane.d ) { }
           //! Destructor
      33   inline_ ~Plane(   ) { }
          
           inline_ Plane& Zero(   ) { n.Zero(   ); d = 0.0f; return *this; }
      36   inline_ Plane& Set(  float nx,   float ny,   float nz,   float _d ) { n.Set(  nx,   ny,   nz ); d = _d; return *this; }
      37   inline_ Plane& Set(  const Point& p,   const Point& _n ) { n = _n; d = - p | _n; return *this; }
           Plane& Set(  const Point& p0,   const Point& p1,   const Point& p2 );
          
           inline_ float Distance(  const Point& p ) const { return (  p | n ) + d; }
           inline_ bool Belongs(  const Point& p ) const { return fabsf(  Distance(  p ) ) < PLANE_EPSILON; }
          
           inline_ void Normalize(   )
           {
           float Denom = 1.0f / n.Magnitude(   );
           n.x *= Denom;
           n.y *= Denom;
           n.z *= Denom;
           d *= Denom;
           }
           public:
           // Members
           Point n; //!< The normal to the plane
           float d; //!< The distance from the origin
          
           // Cast operators
           inline_ operator Point(   ) const { return n; }
           inline_ operator HPoint(   ) const { return HPoint(  n,   d ); }
          
           // Arithmetic operators
           inline_ Plane operator*(  const Matrix4x4& m ) const
           {
           // Old code from Irion. Kept for reference.
           Plane Ret(  *this );
           return Ret *= m;
           }
          
           inline_ Plane& operator*=(  const Matrix4x4& m )
           {
           // Old code from Irion. Kept for reference.
           Point n2 = HPoint(  n,   0.0f ) * m;
           d = -(  (  Point ) (  HPoint(   -d*n,   1.0f  ) * m ) | n2 );
           n = n2;
           return *this;
           }
           };
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Transforms a plane by a 4x4 matrix. Same as Plane * Matrix4x4 operator,   but faster.
           * \param transformed [out] transformed plane
           * \param plane [in] source plane
           * \param transform [in] transform matrix
           * \warning the plane normal must be unit-length
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void TransformPlane(  Plane& transformed,   const Plane& plane,   const Matrix4x4& transform )
           {
           // Rotate the normal using the rotation part of the 4x4 matrix
           transformed.n = plane.n * Matrix3x3(  transform );
          
           // Compute new d
           transformed.d = plane.d - (  Point(  transform.GetTrans(   ) )|transformed.n );
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Transforms a plane by a 4x4 matrix. Same as Plane * Matrix4x4 operator,   but faster.
           * \param plane [in/out] source plane (  transformed on return )
           * \param transform [in] transform matrix
           * \warning the plane normal must be unit-length
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void TransformPlane(  Plane& plane,   const Matrix4x4& transform )
           {
           // Rotate the normal using the rotation part of the 4x4 matrix
           plane.n *= Matrix3x3(  transform );
          
           // Compute new d
           plane.d -= Point(  transform.GetTrans(   ) )|plane.n;
           }
          
          #endif // __ICEPLANE_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IcePoint.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for 3D vectors.
           * \file IcePoint.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEPOINT_H__
          #define __ICEPOINT_H__
          
           // Forward declarations
      16   class HPoint;
      17   class Plane;
      18   class Matrix3x3;
      19   class Matrix4x4;
          
           #define CROSS2D(  a,   b ) (  a.x*b.y - b.x*a.y )
          
           const float EPSILON2 = 1.0e-20f;
          
      25   class Point
           {
           public:
          
           //! Empty constructor
      30   inline_ Point(   ) {}
           //! Constructor from a single float
          // inline_ Point(  float val ) : x(  val ),   y(  val ),   z(  val ) {}
          // Removed since it introduced the nasty "Point T = *Matrix4x4.GetTrans(   );" bug.......
           //! Constructor from floats
      35   inline_ Point(  float _x,   float _y,   float _z ) : x(  _x ),   y(  _y ),   z(  _z ) {}
           //! Constructor from array
           inline_ Point(  const float f[3] ) : x(  f[_X] ),   y(  f[_Y] ),   z(  f[_Z] ) {}
           //! Copy constructor
      39   inline_ Point(  const Point& p ) : x(  p.x ),   y(  p.y ),   z(  p.z ) {}
           //! Destructor
      41   inline_ ~Point(   ) {}
          
           //! Clears the vector
      44   inline_ Point& Zero(   ) { x = y = z = 0.0f; return *this; }
          
           //! + infinity
           inline_ Point& SetPlusInfinity(   ) { x = y = z = MAX_FLOAT; return *this; }
           //! - infinity
           inline_ Point& SetMinusInfinity(   ) { x = y = z = MIN_FLOAT; return *this; }
          
           //! Sets positive unit random vector
           Point& PositiveUnitRandomVector(   );
           //! Sets unit random vector
           Point& UnitRandomVector(   );
          
           //! Assignment from values
           inline_ Point& Set(  float _x,   float _y,   float _z ) { x = _x; y = _y; z = _z; return *this; }
           //! Assignment from array
           inline_ Point& Set(  const float f[3] ) { x = f[_X]; y = f[_Y]; z = f[_Z]; return *this; }
           //! Assignment from another point
           inline_ Point& Set(  const Point& src ) { x = src.x; y = src.y; z = src.z; return *this; }
          
           //! Adds a vector
           inline_ Point& Add(  const Point& p ) { x += p.x; y += p.y; z += p.z; return *this; }
           //! Adds a vector
           inline_ Point& Add(  float _x,   float _y,   float _z ) { x += _x; y += _y; z += _z; return *this; }
           //! Adds a vector
           inline_ Point& Add(  const float f[3] ) { x += f[_X]; y += f[_Y]; z += f[_Z]; return *this; }
           //! Adds vectors
           inline_ Point& Add(  const Point& p,   const Point& q ) { x = p.x+q.x; y = p.y+q.y; z = p.z+q.z; return *this; }
          
           //! Subtracts a vector
           inline_ Point& Sub(  const Point& p ) { x -= p.x; y -= p.y; z -= p.z; return *this; }
           //! Subtracts a vector
           inline_ Point& Sub(  float _x,   float _y,   float _z ) { x -= _x; y -= _y; z -= _z; return *this; }
           //! Subtracts a vector
           inline_ Point& Sub(  const float f[3] ) { x -= f[_X]; y -= f[_Y]; z -= f[_Z]; return *this; }
           //! Subtracts vectors
           inline_ Point& Sub(  const Point& p,   const Point& q ) { x = p.x-q.x; y = p.y-q.y; z = p.z-q.z; return *this; }
          
           //! this = -this
           inline_ Point& Neg(   ) { x = -x; y = -y; z = -z; return *this; }
           //! this = -a
           inline_ Point& Neg(  const Point& a ) { x = -a.x; y = -a.y; z = -a.z; return *this; }
          
           //! Multiplies by a scalar
           inline_ Point& Mult(  float s ) { x *= s; y *= s; z *= s; return *this; }
          
           //! this = a * scalar
           inline_ Point& Mult(  const Point& a,   float scalar )
           {
           x = a.x * scalar;
           y = a.y * scalar;
           z = a.z * scalar;
           return *this;
           }
          
           //! this = a + b * scalar
           inline_ Point& Mac(  const Point& a,   const Point& b,   float scalar )
           {
           x = a.x + b.x * scalar;
           y = a.y + b.y * scalar;
           z = a.z + b.z * scalar;
           return *this;
           }
          
           //! this = this + a * scalar
           inline_ Point& Mac(  const Point& a,   float scalar )
           {
           x += a.x * scalar;
           y += a.y * scalar;
           z += a.z * scalar;
           return *this;
           }
          
           //! this = a - b * scalar
           inline_ Point& Msc(  const Point& a,   const Point& b,   float scalar )
           {
           x = a.x - b.x * scalar;
           y = a.y - b.y * scalar;
           z = a.z - b.z * scalar;
           return *this;
           }
          
           //! this = this - a * scalar
           inline_ Point& Msc(  const Point& a,   float scalar )
           {
           x -= a.x * scalar;
           y -= a.y * scalar;
           z -= a.z * scalar;
           return *this;
           }
          
           //! this = a + b * scalarb + c * scalarc
           inline_ Point& Mac2(  const Point& a,   const Point& b,   float scalarb,   const Point& c,   float scalarc )
           {
           x = a.x + b.x * scalarb + c.x * scalarc;
           y = a.y + b.y * scalarb + c.y * scalarc;
           z = a.z + b.z * scalarb + c.z * scalarc;
           return *this;
           }
          
           //! this = a - b * scalarb - c * scalarc
           inline_ Point& Msc2(  const Point& a,   const Point& b,   float scalarb,   const Point& c,   float scalarc )
           {
           x = a.x - b.x * scalarb - c.x * scalarc;
           y = a.y - b.y * scalarb - c.y * scalarc;
           z = a.z - b.z * scalarb - c.z * scalarc;
           return *this;
           }
          
           //! this = mat * a
           inline_ Point& Mult(  const Matrix3x3& mat,   const Point& a );
          
           //! this = mat1 * a1 + mat2 * a2
           inline_ Point& Mult2(  const Matrix3x3& mat1,   const Point& a1,   const Matrix3x3& mat2,   const Point& a2 );
          
           //! this = this + mat * a
           inline_ Point& Mac(  const Matrix3x3& mat,   const Point& a );
          
           //! this = transpose(  mat ) * a
           inline_ Point& TransMult(  const Matrix3x3& mat,   const Point& a );
          
           //! Linear interpolate between two vectors: this = a + t * (  b - a )
           inline_ Point& Lerp(  const Point& a,   const Point& b,   float t )
           {
           x = a.x + t * (  b.x - a.x );
           y = a.y + t * (  b.y - a.y );
           z = a.z + t * (  b.z - a.z );
           return *this;
           }
          
           //! Hermite interpolate between p1 and p2. p0 and p3 are used for finding gradient at p1 and p2.
           //! this = p0 * (  2t^2 - t^3 - t )/2
           //! + p1 * (  3t^3 - 5t^2 + 2 )/2
           //! + p2 * (  4t^2 - 3t^3 + t )/2
           //! + p3 * (  t^3 - t^2 )/2
           inline_ Point& Herp(  const Point& p0,   const Point& p1,   const Point& p2,   const Point& p3,   float t )
           {
           float t2 = t * t;
           float t3 = t2 * t;
           float kp0 = (  2.0f * t2 - t3 - t ) * 0.5f;
           float kp1 = (  3.0f * t3 - 5.0f * t2 + 2.0f ) * 0.5f;
           float kp2 = (  4.0f * t2 - 3.0f * t3 + t ) * 0.5f;
           float kp3 = (  t3 - t2 ) * 0.5f;
           x = p0.x * kp0 + p1.x * kp1 + p2.x * kp2 + p3.x * kp3;
           y = p0.y * kp0 + p1.y * kp1 + p2.y * kp2 + p3.y * kp3;
           z = p0.z * kp0 + p1.z * kp1 + p2.z * kp2 + p3.z * kp3;
           return *this;
           }
          
           //! this = rotpos * r + linpos
           inline_ Point& Transform(  const Point& r,   const Matrix3x3& rotpos,   const Point& linpos );
          
           //! this = trans(  rotpos ) * (  r - linpos )
           inline_ Point& InvTransform(  const Point& r,   const Matrix3x3& rotpos,   const Point& linpos );
          
           //! Returns MIN(  x,   y,   z );
           inline_ float Min(   ) const { return MIN(  x,   MIN(  y,   z ) ); }
           //! Returns MAX(  x,   y,   z );
           inline_ float Max(   ) const { return MAX(  x,   MAX(  y,   z ) ); }
           //! Sets each element to be componentwise minimum
           inline_ Point& Min(  const Point& p ) { x = MIN(  x,   p.x ); y = MIN(  y,   p.y ); z = MIN(  z,   p.z ); return *this; }
           //! Sets each element to be componentwise maximum
           inline_ Point& Max(  const Point& p ) { x = MAX(  x,   p.x ); y = MAX(  y,   p.y ); z = MAX(  z,   p.z ); return *this; }
          
           //! Clamps each element
           inline_ Point& Clamp(  float min,   float max )
           {
           if(  x<min ) x=min; if(  x>max ) x=max;
           if(  y<min ) y=min; if(  y>max ) y=max;
           if(  z<min ) z=min; if(  z>max ) z=max;
           return *this;
           }
          
           //! Computes square magnitude
           inline_ float SquareMagnitude(   ) const { return x*x + y*y + z*z; }
           //! Computes magnitude
           inline_ float Magnitude(   ) const { return sqrtf(  x*x + y*y + z*z ); }
           //! Computes volume
           inline_ float Volume(   ) const { return x * y * z; }
          
           //! Checks the point is near zero
           inline_ bool ApproxZero(   ) const { return SquareMagnitude(   ) < EPSILON2; }
          
           //! Tests for exact zero vector
           inline_ BOOL IsZero(   ) const
           {
           if(  IR(  x ) || IR(  y ) || IR(  z ) ) return FALSE;
           return TRUE;
           }
          
           //! Checks point validity
           inline_ BOOL IsValid(   ) const
           {
           if(  !IsValidFloat(  x ) ) return FALSE;
           if(  !IsValidFloat(  y ) ) return FALSE;
           if(  !IsValidFloat(  z ) ) return FALSE;
           return TRUE;
           }
          
           //! Slighty moves the point
           void Tweak(  udword coord_mask,   udword tweak_mask )
           {
           if(  coord_mask&1 ) { udword Dummy = IR(  x ); Dummy^=tweak_mask; x = FR(  Dummy ); }
           if(  coord_mask&2 ) { udword Dummy = IR(  y ); Dummy^=tweak_mask; y = FR(  Dummy ); }
           if(  coord_mask&4 ) { udword Dummy = IR(  z ); Dummy^=tweak_mask; z = FR(  Dummy ); }
           }
          
           #define TWEAKMASK 0x3fffff
           #define TWEAKNOTMASK ~TWEAKMASK
           //! Slighty moves the point out
           inline_ void TweakBigger(   )
           {
           udword Dummy = (  IR(  x )&TWEAKNOTMASK ); if(  !IS_NEGATIVE_FLOAT(  x ) ) Dummy+=TWEAKMASK+1; x = FR(  Dummy );
           Dummy = (  IR(  y )&TWEAKNOTMASK ); if(  !IS_NEGATIVE_FLOAT(  y ) ) Dummy+=TWEAKMASK+1; y = FR(  Dummy );
           Dummy = (  IR(  z )&TWEAKNOTMASK ); if(  !IS_NEGATIVE_FLOAT(  z ) ) Dummy+=TWEAKMASK+1; z = FR(  Dummy );
           }
          
           //! Slighty moves the point in
           inline_ void TweakSmaller(   )
           {
           udword Dummy = (  IR(  x )&TWEAKNOTMASK ); if(  IS_NEGATIVE_FLOAT(  x ) ) Dummy+=TWEAKMASK+1; x = FR(  Dummy );
           Dummy = (  IR(  y )&TWEAKNOTMASK ); if(  IS_NEGATIVE_FLOAT(  y ) ) Dummy+=TWEAKMASK+1; y = FR(  Dummy );
           Dummy = (  IR(  z )&TWEAKNOTMASK ); if(  IS_NEGATIVE_FLOAT(  z ) ) Dummy+=TWEAKMASK+1; z = FR(  Dummy );
           }
          
           //! Normalizes the vector
           inline_ Point& Normalize(   )
           {
           float M = x*x + y*y + z*z;
           if(  M )
           {
           M = 1.0f / sqrtf(  M );
           x *= M;
           y *= M;
           z *= M;
           }
           return *this;
           }
          
           //! Sets vector length
           inline_ Point& SetLength(  float length )
           {
           float NewLength = length / Magnitude(   );
           x *= NewLength;
           y *= NewLength;
           z *= NewLength;
           return *this;
           }
          
           //! Clamps vector length
           inline_ Point& ClampLength(  float limit_length )
           {
           if(  limit_length>=0.0f ) // Magnitude must be positive
           {
           float CurrentSquareLength = SquareMagnitude(   );
          
           if(  CurrentSquareLength > limit_length * limit_length )
           {
           float Coeff = limit_length / sqrtf(  CurrentSquareLength );
           x *= Coeff;
           y *= Coeff;
           z *= Coeff;
           }
           }
           return *this;
           }
          
           //! Computes distance to another point
           inline_ float Distance(  const Point& b ) const
           {
           return sqrtf(  (  x - b.x )*(  x - b.x ) + (  y - b.y )*(  y - b.y ) + (  z - b.z )*(  z - b.z ) );
           }
          
           //! Computes square distance to another point
           inline_ float SquareDistance(  const Point& b ) const
           {
           return (  (  x - b.x )*(  x - b.x ) + (  y - b.y )*(  y - b.y ) + (  z - b.z )*(  z - b.z ) );
           }
          
           //! Dot product dp = this|a
           inline_ float Dot(  const Point& p ) const { return p.x * x + p.y * y + p.z * z; }
          
           //! Cross product this = a x b
           inline_ Point& Cross(  const Point& a,   const Point& b )
           {
           x = a.y * b.z - a.z * b.y;
           y = a.z * b.x - a.x * b.z;
           z = a.x * b.y - a.y * b.x;
           return *this;
           }
          
           //! Vector code (   bitmask = sign(  z ) | sign(  y ) | sign(  x )  )
           inline_ udword VectorCode(   ) const
           {
           return (  IR(  x )>>31 ) | (  (  IR(  y )&SIGN_BITMASK )>>30 ) | (  (  IR(  z )&SIGN_BITMASK )>>29 );
           }
          
           //! Returns largest axis
           inline_ PointComponent LargestAxis(   ) const
           {
           const float* Vals = &x;
           PointComponent m = _X;
           if(  Vals[_Y] > Vals[m] ) m = _Y;
           if(  Vals[_Z] > Vals[m] ) m = _Z;
           return m;
           }
          
           //! Returns closest axis
           inline_ PointComponent ClosestAxis(   ) const
           {
           const float* Vals = &x;
           PointComponent m = _X;
           if(  AIR(  Vals[_Y] ) > AIR(  Vals[m] ) ) m = _Y;
           if(  AIR(  Vals[_Z] ) > AIR(  Vals[m] ) ) m = _Z;
           return m;
           }
          
           //! Returns smallest axis
           inline_ PointComponent SmallestAxis(   ) const
           {
           const float* Vals = &x;
           PointComponent m = _X;
           if(  Vals[_Y] < Vals[m] ) m = _Y;
           if(  Vals[_Z] < Vals[m] ) m = _Z;
           return m;
           }
          
           //! Refracts the point
           Point& Refract(  const Point& eye,   const Point& n,   float refractindex,   Point& refracted );
          
           //! Projects the point onto a plane
           Point& ProjectToPlane(  const Plane& p );
          
           //! Projects the point onto the screen
           void ProjectToScreen(  float halfrenderwidth,   float halfrenderheight,   const Matrix4x4& mat,   HPoint& projected ) const;
          
           //! Unfolds the point onto a plane according to edge(  a,  b )
           Point& Unfold(  Plane& p,   Point& a,   Point& b );
          
           //! Hash function from Ville Miettinen
           inline_ udword GetHashValue(   ) const
           {
           const udword* h = (  const udword* )(  this );
           udword f = (  h[0]+h[1]*11-(  h[2]*17 ) ) & 0x7fffffff; // avoid problems with +-0
           return (  f>>22 )^(  f>>12 )^(  f );
           }
          
           //! Stuff magic values in the point,   marking it as explicitely not used.
           void SetNotUsed(   );
           //! Checks the point is marked as not used
           BOOL IsNotUsed(   ) const;
          
           // Arithmetic operators
          
           //! Unary operator for Point Negate = - Point
           inline_ Point operator-(   ) const { return Point(  -x,   -y,   -z ); }
          
           //! Operator for Point Plus = Point + Point.
           inline_ Point operator+(  const Point& p ) const { return Point(  x + p.x,   y + p.y,   z + p.z ); }
           //! Operator for Point Minus = Point - Point.
           inline_ Point operator-(  const Point& p ) const { return Point(  x - p.x,   y - p.y,   z - p.z ); }
          
           //! Operator for Point Mul = Point * Point.
           inline_ Point operator*(  const Point& p ) const { return Point(  x * p.x,   y * p.y,   z * p.z ); }
           //! Operator for Point Scale = Point * float.
           inline_ Point operator*(  float s ) const { return Point(  x * s,   y * s,   z * s  ); }
           //! Operator for Point Scale = float * Point.
           inline_ friend Point operator*(  float s,   const Point& p ) { return Point(  s * p.x,   s * p.y,   s * p.z ); }
          
           //! Operator for Point Div = Point / Point.
           inline_ Point operator/(  const Point& p ) const { return Point(  x / p.x,   y / p.y,   z / p.z ); }
           //! Operator for Point Scale = Point / float.
           inline_ Point operator/(  float s ) const { s = 1.0f / s; return Point(  x * s,   y * s,   z * s ); }
           //! Operator for Point Scale = float / Point.
           inline_ friend Point operator/(  float s,   const Point& p ) { return Point(  s / p.x,   s / p.y,   s / p.z ); }
          
           //! Operator for float DotProd = Point | Point.
           inline_ float operator|(  const Point& p ) const { return x*p.x + y*p.y + z*p.z; }
           //! Operator for Point VecProd = Point ^ Point.
           inline_ Point operator^(  const Point& p ) const
           {
           return Point(  
           y * p.z - z * p.y,  
           z * p.x - x * p.z,  
           x * p.y - y * p.x  );
           }
          
           //! Operator for Point += Point.
           inline_ Point& operator+=(  const Point& p ) { x += p.x; y += p.y; z += p.z; return *this; }
           //! Operator for Point += float.
           inline_ Point& operator+=(  float s ) { x += s; y += s; z += s; return *this; }
          
           //! Operator for Point -= Point.
           inline_ Point& operator-=(  const Point& p ) { x -= p.x; y -= p.y; z -= p.z; return *this; }
           //! Operator for Point -= float.
           inline_ Point& operator-=(  float s ) { x -= s; y -= s; z -= s; return *this; }
          
           //! Operator for Point *= Point.
           inline_ Point& operator*=(  const Point& p ) { x *= p.x; y *= p.y; z *= p.z; return *this; }
           //! Operator for Point *= float.
           inline_ Point& operator*=(  float s ) { x *= s; y *= s; z *= s; return *this; }
          
           //! Operator for Point /= Point.
           inline_ Point& operator/=(  const Point& p ) { x /= p.x; y /= p.y; z /= p.z; return *this; }
           //! Operator for Point /= float.
           inline_ Point& operator/=(  float s ) { s = 1.0f/s; x *= s; y *= s; z *= s; return *this; }
          
           // Logical operators
          
           //! Operator for "if(  Point==Point )"
           inline_ bool operator==(  const Point& p ) const { return (   (  IR(  x )==IR(  p.x ) )&&(  IR(  y )==IR(  p.y ) )&&(  IR(  z )==IR(  p.z ) ) ); }
           //! Operator for "if(  Point!=Point )"
           inline_ bool operator!=(  const Point& p ) const { return (   (  IR(  x )!=IR(  p.x ) )||(  IR(  y )!=IR(  p.y ) )||(  IR(  z )!=IR(  p.z ) ) ); }
          
           // Arithmetic operators
          
           //! Operator for Point Mul = Point * Matrix3x3.
           inline_ Point operator*(  const Matrix3x3& mat ) const
           {
           class ShadowMatrix3x3{ public: float m[3][3]; }; // To allow inlining
           const ShadowMatrix3x3* Mat = (  const ShadowMatrix3x3* )&mat;
          
           return Point(  
           x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0],  
           x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1],  
           x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2]  );
           }
          
           //! Operator for Point Mul = Point * Matrix4x4.
           inline_ Point operator*(  const Matrix4x4& mat ) const
           {
           class ShadowMatrix4x4{ public: float m[4][4]; }; // To allow inlining
           const ShadowMatrix4x4* Mat = (  const ShadowMatrix4x4* )&mat;
          
           return Point(  
           x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0] + Mat->m[3][0],  
           x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1] + Mat->m[3][1],  
           x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2] + Mat->m[3][2] );
           }
          
           //! Operator for Point *= Matrix3x3.
           inline_ Point& operator*=(  const Matrix3x3& mat )
           {
           class ShadowMatrix3x3{ public: float m[3][3]; }; // To allow inlining
           const ShadowMatrix3x3* Mat = (  const ShadowMatrix3x3* )&mat;
          
           float xp = x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0];
           float yp = x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1];
           float zp = x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2];
          
           x = xp; y = yp; z = zp;
          
           return *this;
           }
          
           //! Operator for Point *= Matrix4x4.
           inline_ Point& operator*=(  const Matrix4x4& mat )
           {
           class ShadowMatrix4x4{ public: float m[4][4]; }; // To allow inlining
           const ShadowMatrix4x4* Mat = (  const ShadowMatrix4x4* )&mat;
          
           float xp = x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0] + Mat->m[3][0];
           float yp = x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1] + Mat->m[3][1];
           float zp = x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2] + Mat->m[3][2];
          
           x = xp; y = yp; z = zp;
          
           return *this;
           }
          
           // Cast operators
          
           //! Cast a Point to a HPoint. w is set to zero.
           operator HPoint(   ) const;
          
           inline_ operator const float*(   ) const { return &x; }
           inline_ operator float*(   ) { return &x; }
          
           public:
           float x,   y,   z;
           };
          
           FUNCTION void Normalize1(  Point& a );
           FUNCTION void Normalize2(  Point& a );
          
          #endif //__ICEPOINT_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IcePreprocessor.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains preprocessor stuff. This should be the first included header.
           * \file IcePreprocessor.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEPREPROCESSOR_H__
          #define __ICEPREPROCESSOR_H__
          
           // Check platform
           #if defined(   _WIN32  ) || defined(   WIN32  )
           // #pragma message(  "Compiling on Windows..." )
           #define PLATFORM_WINDOWS
           #else
           // don't issue pragmas on unknown platforms
           // #pragma message(  "Compiling on unknown platform..." )
           #endif
          
           // Check compiler
           #if defined(  _MSC_VER )
           // #pragma message(  "Compiling with VC++..." )
           #define COMPILER_VISUAL_CPP
          
           // disable annoying warnings
           #pragma warning (  disable : 4267 ) // data type conversion: size_t to BOOL,   size_t to udword,   etc )
          
           #else
           // don't issue pragmas on unknown platforms
           // #pragma message(  "Compiling with unknown compiler..." )
           #endif
          
           // Check compiler options. If this file is included in user-apps,   this
           // shouldn't be needed,   so that they can use what they like best.
           #ifndef ICE_DONT_CHECK_COMPILER_OPTIONS
           #ifdef COMPILER_VISUAL_CPP
           #if defined(  _CHAR_UNSIGNED )
           #endif
          
           #if defined(  _CPPRTTI )
           #error Please disable RTTI...
           #endif
          
           #if defined(  _CPPUNWIND )
           #error Please disable exceptions...
           #endif
          
           #if defined(  _MT )
           // Multithreading
           #endif
           #endif
           #endif
          
           // Check debug mode
           #ifdef DEBUG // May be defined instead of _DEBUG. Let's fix it.
           #ifndef _DEBUG
           #define _DEBUG
           #endif
           #endif
          
           #ifdef _DEBUG
           // Here you may define items for debug builds
           #endif
          
           #ifndef THIS_FILE
           #define THIS_FILE __FILE__
           #endif
          
           #ifndef ICE_NO_DLL
           #ifdef ICECORE_EXPORTS
           #define ICECORE_API __declspec(  dllexport )
           #else
           #define ICECORE_API __declspec(  dllimport )
           #endif
           #else
           #define ICECORE_API
           #endif
          
           // Don't override new/delete
          // #define DEFAULT_NEWDELETE
           #define DONT_TRACK_MEMORY_LEAKS
          
           #define FUNCTION extern "C"
          
           // Cosmetic stuff [mainly useful with multiple inheritance]
           #define override(  base_class ) virtual
          
           // Our own inline keyword,   so that:
           // - we can switch to __forceinline to check it's really better or not
           // - we can remove __forceinline if the compiler doesn't support it
          // #define inline_ __forceinline
          // #define inline_ inline
          
           // Contributed by Bruce Mitchener
           #if defined(  COMPILER_VISUAL_CPP )
           #define inline_ __forceinline
          // #define inline_ inline
           #elif defined(  __GNUC__ ) && __GNUC__ < 3
           #define inline_ inline
           #elif defined(  __GNUC__ )
           #define inline_ inline __attribute__ (  (  always_inline ) )
           #else
           #define inline_ inline
           #endif
          
           // Down the hatch
          #ifdef _MSC_VER
           #pragma inline_depth(   255  )
          #endif
          
           #ifdef COMPILER_VISUAL_CPP
           #pragma intrinsic(  memcmp )
           #pragma intrinsic(  memcpy )
           #pragma intrinsic(  memset )
           #pragma intrinsic(  strcat )
           #pragma intrinsic(  strcmp )
           #pragma intrinsic(  strcpy )
           #pragma intrinsic(  strlen )
           #pragma intrinsic(  abs )
           #pragma intrinsic(  labs )
           #endif
          
           // ANSI compliance
           #ifdef _DEBUG
           // Remove painful warning in debug
     130   inline_ bool __False__(   ){ return false; }
           #define for if(  __False__(   ) ){} else for
           #else
           #define for if(  0 ){} else for
           #endif
          
          #endif // __ICEPREPROCESSOR_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceRandom.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for random generators.
           * \file IceRandom.h
           * \author Pierre Terdiman
           * \date August,   9,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICERANDOM_H__
          #define __ICERANDOM_H__
          
      15   FUNCTION void SRand(  udword seed );
           FUNCTION udword Rand(   );
          
           //! Returns a unit random floating-point value
      19   inline_ float UnitRandomFloat(   ) { return float(  Rand(   ) ) * ONE_OVER_RAND_MAX; }
          
           //! Returns a random index so that 0<= index < max_index
      22   udword GetRandomIndex(  udword max_index );
          
      24   class BasicRandom
           {
           public:
          
           //! Constructor
      29   inline_ BasicRandom(  udword seed=0 ) : mRnd(  seed ) {}
           //! Destructor
      31   inline_ ~BasicRandom(   ) {}
          
      33   inline_ void SetSeed(  udword seed ) { mRnd = seed; }
           inline_ udword GetCurrentValue(   ) const { return mRnd; }
           inline_ udword Randomize(   ) { mRnd = mRnd * 2147001325 + 715136305; return mRnd; }
          
           private:
           udword mRnd;
           };
          
          #endif // __ICERANDOM_H__
          

./components/ogre/ogreopcode/include/Opcode/Ice/IceRay.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for rays.
           * \file IceRay.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICERAY_H__
          #define __ICERAY_H__
          
      15   class Ray
           {
           public:
           //! Constructor
      19   inline_ Ray(   ) {}
           //! Constructor
      21   inline_ Ray(  const Point& orig,   const Point& dir ) : mOrig(  orig ),   mDir(  dir ) {}
           //! Copy constructor
      23   inline_ Ray(  const Ray& ray ) : mOrig(  ray.mOrig ),   mDir(  ray.mDir ) {}
           //! Destructor
      25   inline_ ~Ray(   ) {}
          
      27   float SquareDistance(  const Point& point,   float* t=null ) const;
           inline_ float Distance(  const Point& point,   float* t=null ) const { return sqrtf(  SquareDistance(  point,   t ) ); }
          
           Point mOrig; //!< Ray origin
           Point mDir; //!< Normalized direction
           };
          
           inline_ void ComputeReflexionVector(  Point& reflected,   const Point& incoming_dir,   const Point& outward_normal )
           {
           reflected = incoming_dir - outward_normal * 2.0f * (  incoming_dir|outward_normal );
           }
          
           inline_ void ComputeReflexionVector(  Point& reflected,   const Point& source,   const Point& impact,   const Point& normal )
           {
           Point V = impact - source;
           reflected = V - normal * 2.0f * (  V|normal );
           }
          
           inline_ void DecomposeVector(  Point& normal_compo,   Point& tangent_compo,   const Point& outward_dir,   const Point& outward_normal )
           {
           normal_compo = outward_normal * (  outward_dir|outward_normal );
           tangent_compo = outward_dir - normal_compo;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Transforms a direction vector from world space to local space
           * \param local_dir [out] direction vector in local space
           * \param world_dir [in] direction vector in world space
           * \param world [in] world transform
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void ComputeLocalDirection(  Point& local_dir,   const Point& world_dir,   const Matrix4x4& world )
           {
           // Get world direction back in local space
          // Matrix3x3 InvWorld = world;
          // local_dir = InvWorld * world_dir;
           local_dir = Matrix3x3(  world ) * world_dir;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Transforms a position vector from world space to local space
           * \param local_pt [out] position vector in local space
           * \param world_pt [in] position vector in world space
           * \param world [in] world transform
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void ComputeLocalPoint(  Point& local_pt,   const Point& world_pt,   const Matrix4x4& world )
           {
           // Get world vertex back in local space
           Matrix4x4 InvWorld = world;
           InvWorld.Invert(   );
           local_pt = world_pt * InvWorld;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Transforms a ray from world space to local space
           * \param local_ray [out] ray in local space
           * \param world_ray [in] ray in world space
           * \param world [in] world transform
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void ComputeLocalRay(  Ray& local_ray,   const Ray& world_ray,   const Matrix4x4& world )
           {
           // Get world ray back in local space
           ComputeLocalDirection(  local_ray.mDir,   world_ray.mDir,   world );
           ComputeLocalPoint(  local_ray.mOrig,   world_ray.mOrig,   world );
           }
          
          #endif // __ICERAY_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceRevisitedRadix.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains source code from the article "Radix Sort Revisited".
           * \file IceRevisitedRadix.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICERADIXSORT_H__
          #define __ICERADIXSORT_H__
          
           //! Allocate histograms & offsets locally
           #define RADIX_LOCAL_RAM
          
           enum RadixHint
           {
           RADIX_SIGNED,   //!< Input values are signed
           RADIX_UNSIGNED,   //!< Input values are unsigned
          
           RADIX_FORCE_DWORD = 0x7fffffff
           };
          
      26   class RadixSort
           {
           public:
           // Constructor/Destructor
      30   RadixSort(   );
      31   ~RadixSort(   );
           // Sorting methods
      33   RadixSort& Sort(  const udword* input,   udword nb,   RadixHint hint=RADIX_SIGNED );
      34   RadixSort& Sort(  const float* input,   udword nb );
          
           //! Access to results. mRanks is a list of indices in sorted order,   i.e. in the order you may further process your data
           inline_ const udword* GetRanks(   ) const { return mRanks; }
          
           //! mIndices2 gets trashed on calling the sort routine,   but otherwise you can recycle it the way you want.
      40   inline_ udword* GetRecyclable(   ) const { return mRanks2; }
          
           // Stats
      43   udword GetUsedRam(   ) const;
           //! Returns the total number of calls to the radix sorter.
      45   inline_ udword GetNbTotalCalls(   ) const { return mTotalCalls; }
           //! Returns the number of eraly exits due to temporal coherence.
      47   inline_ udword GetNbHits(   ) const { return mNbHits; }
          
           private:
          #ifndef RADIX_LOCAL_RAM
           udword* mHistogram; //!< Counters for each byte
           udword* mOffset; //!< Offsets (  nearly a cumulative distribution function )
          #endif
           udword mCurrentSize; //!< Current size of the indices list
           udword* mRanks; //!< Two lists,   swapped each pass
           udword* mRanks2;
           // Stats
           udword mTotalCalls; //!< Total number of calls to the sort routine
           udword mNbHits; //!< Number of early exits due to coherence
           // Internal methods
           void CheckResize(  udword nb );
           bool Resize(  udword nb );
           };
          
          #endif // __ICERADIXSORT_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceSegment.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for segments.
           * \file IceSegment.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICESEGMENT_H__
          #define __ICESEGMENT_H__
          
      15   class Segment
           {
           public:
           //! Constructor
      19   inline_ Segment(   ) {}
           //! Constructor
      21   inline_ Segment(  const Point& p0,   const Point& p1 ) : mP0(  p0 ),   mP1(  p1 ) {}
           //! Copy constructor
      23   inline_ Segment(  const Segment& seg ) : mP0(  seg.mP0 ),   mP1(  seg.mP1 ) {}
           //! Destructor
      25   inline_ ~Segment(   ) {}
          
           inline_ const Point& GetOrigin(   ) const { return mP0; }
      28   inline_ Point ComputeDirection(   ) const { return mP1 - mP0; }
      29   inline_ void ComputeDirection(  Point& dir ) const { dir = mP1 - mP0; }
      30   inline_ float ComputeLength(   ) const { return mP1.Distance(  mP0 ); }
      31   inline_ float ComputeSquareLength(   ) const { return mP1.SquareDistance(  mP0 ); }
          
      33   inline_ void SetOriginDirection(  const Point& origin,   const Point& direction )
           {
           mP0 = mP1 = origin;
           mP1 += direction;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes a point on the segment
           * \param pt [out] point on segment
           * \param t [in] point's parameter [t=0 => pt = mP0,   t=1 => pt = mP1]
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      46   inline_ void ComputePoint(  Point& pt,   float t ) const { pt = mP0 + t * (  mP1 - mP0 ); }
          
      48   float SquareDistance(  const Point& point,   float* t=null ) const;
      49   inline_ float Distance(  const Point& point,   float* t=null ) const { return sqrtf(  SquareDistance(  point,   t ) ); }
          
           Point mP0; //!< Start of segment
           Point mP1; //!< End of segment
           };
          
          #endif // __ICESEGMENT_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceTriList.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for a triangle container.
           * \file IceTrilist.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICETRILIST_H__
          #define __ICETRILIST_H__
          
      15   class TriList : public IceCore::Container
           {
           public:
           // Constructor / Destructor
      19   TriList(   ) {}
      20   ~TriList(   ) {}
          
           inline_ udword GetNbTriangles(   ) const { return GetNbEntries(   )/9; }
      23   inline_ Triangle* GetTriangles(   ) const { return (  Triangle* )GetEntries(   ); }
          
      25   void AddTri(  const Triangle& tri )
           {
           Add(  tri.mVerts[0].x ).Add(  tri.mVerts[0].y ).Add(  tri.mVerts[0].z );
           Add(  tri.mVerts[1].x ).Add(  tri.mVerts[1].y ).Add(  tri.mVerts[1].z );
           Add(  tri.mVerts[2].x ).Add(  tri.mVerts[2].y ).Add(  tri.mVerts[2].z );
           }
          
      32   void AddTri(  const Point& p0,   const Point& p1,   const Point& p2 )
           {
           Add(  p0.x ).Add(  p0.y ).Add(  p0.z );
           Add(  p1.x ).Add(  p1.y ).Add(  p1.z );
           Add(  p2.x ).Add(  p2.y ).Add(  p2.z );
           }
           };
          
           class TriangleList : public IceCore::Container
           {
           public:
           // Constructor / Destructor
           TriangleList(   ) {}
           ~TriangleList(   ) {}
          
           inline_ udword GetNbTriangles(   ) const { return GetNbEntries(   )/3; }
           inline_ IndexedTriangle* GetTriangles(   ) const { return (  IndexedTriangle* )GetEntries(   );}
          
           void AddTriangle(  const IndexedTriangle& tri )
           {
           Add(  tri.mVRef[0] ).Add(  tri.mVRef[1] ).Add(  tri.mVRef[2] );
           }
          
           void AddTriangle(  udword vref0,   udword vref1,   udword vref2 )
           {
           Add(  vref0 ).Add(  vref1 ).Add(  vref2 );
           }
           };
          
          #endif //__ICETRILIST_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceTriangle.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a handy triangle class.
           * \file IceTriangle.h
           * \author Pierre Terdiman
           * \date January,   17,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICETRIANGLE_H__
          #define __ICETRIANGLE_H__
          
           // Forward declarations
      16   class Moment;
          
           // Partitioning values
           enum PartVal
           {
           TRI_MINUS_SPACE = 0,   //!< Triangle is in the negative space
           TRI_PLUS_SPACE = 1,   //!< Triangle is in the positive space
           TRI_INTERSECT = 2,   //!< Triangle intersects plane
           TRI_ON_PLANE = 3,   //!< Triangle and plane are coplanar
          
           TRI_FORCEDWORD = 0x7fffffff
           };
          
           // A triangle class.
      30   class Triangle
           {
           public:
           //! Constructor
      34   inline_ Triangle(   ) {}
           //! Constructor
      36   inline_ Triangle(  const Point& p0,   const Point& p1,   const Point& p2 ) { mVerts[0]=p0; mVerts[1]=p1; mVerts[2]=p2; }
           //! Copy constructor
      38   inline_ Triangle(  const Triangle& triangle )
           {
           mVerts[0] = triangle.mVerts[0];
           mVerts[1] = triangle.mVerts[1];
           mVerts[2] = triangle.mVerts[2];
           }
           //! Destructor
      45   inline_ ~Triangle(   ) {}
           //! Vertices
      47   Point mVerts[3];
          
           // Methods
      50   void Flip(   );
      51   float Area(   ) const;
      52   float Perimeter(   ) const;
      53   float Compacity(   ) const;
      54   void Normal(  Point& normal ) const;
      55   void DenormalizedNormal(  Point& normal ) const;
      56   void Center(  Point& center ) const;
           inline_ Plane PlaneEquation(   ) const { return Plane(  mVerts[0],   mVerts[1],   mVerts[2] ); }
          
      59   PartVal TestAgainstPlane(  const Plane& plane,   float epsilon ) const;
          // float Distance(  Point& cp,   Point& cq,   Tri& tri );
      61   void ComputeMoment(  Moment& m );
      62   float MinEdgeLength(   ) const;
      63   float MaxEdgeLength(   ) const;
      64   void ComputePoint(  float u,   float v,   Point& pt,   udword* nearvtx=null ) const;
      65   void Inflate(  float fat_coeff,   bool constant_border );
           };
          
          #endif // __ICETRIANGLE_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceTypes.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains custom types.
           * \file IceTypes.h
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICETYPES_H__
          #define __ICETYPES_H__
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Things to help us compile on non-windows platforms
          
          #if defined(  __MACOSX__ ) || defined(  __APPLE__ )
          #undef bool
          #define bool char
          #undef true
          #define true (  (  bool )-1 )
          #undef false
          #define false (  (  bool )0 )
          #endif // mac stuff
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
           #define USE_HANDLE_MANAGER
          
           // Constants
           #define PI 3.1415926535897932384626433832795028841971693993751f //!< PI
           #define HALFPI 1.57079632679489661923f //!< 0.5 * PI
           #define TWOPI 6.28318530717958647692f //!< 2.0 * PI
           #define INVPI 0.31830988618379067154f //!< 1.0 / PI
          
           #define RADTODEG 57.2957795130823208768f //!< 180.0 / PI,   convert radians to degrees
           #define DEGTORAD 0.01745329251994329577f //!< PI / 180.0,   convert degrees to radians
          
           #define EXP 2.71828182845904523536f //!< e
           #define INVLOG2 3.32192809488736234787f //!< 1.0 / log10(  2 )
           #define LN2 0.693147180559945f //!< ln(  2 )
           #define INVLN2 1.44269504089f //!< 1.0f / ln(  2 )
          
           #define INV3 0.33333333333333333333f //!< 1/3
           #define INV6 0.16666666666666666666f //!< 1/6
           #define INV7 0.14285714285714285714f //!< 1/7
           #define INV9 0.11111111111111111111f //!< 1/9
           #define INV255 0.00392156862745098039f //!< 1/255
          
           #define SQRT2 1.41421356237f //!< sqrt(  2 )
           #define INVSQRT2 0.707106781188f //!< 1 / sqrt(  2 )
          
           #define SQRT3 1.73205080757f //!< sqrt(  3 )
           #define INVSQRT3 0.577350269189f //!< 1 / sqrt(  3 )
          
           #define null 0 //!< our own NULL pointer
          
           // Custom types used in ICE
           typedef signed char sbyte; //!< sizeof(  sbyte ) must be 1
           typedef unsigned char ubyte; //!< sizeof(  ubyte ) must be 1
           typedef signed short sword; //!< sizeof(  sword ) must be 2
           typedef unsigned short uword; //!< sizeof(  uword ) must be 2
           typedef signed int sdword; //!< sizeof(  sdword ) must be 4
           typedef unsigned int udword; //!< sizeof(  udword ) must be 4
           typedef signed __int64 sqword; //!< sizeof(  sqword ) must be 8
           typedef unsigned __int64 uqword; //!< sizeof(  uqword ) must be 8
           typedef float float32; //!< sizeof(  float32 ) must be 4
           typedef double float64; //!< sizeof(  float64 ) must be 4
          
      71   ICE_COMPILE_TIME_ASSERT(  sizeof(  bool )==1 ); // ...otherwise things might fail with VC++ 4.2 !
      72   ICE_COMPILE_TIME_ASSERT(  sizeof(  ubyte )==1 );
      73   ICE_COMPILE_TIME_ASSERT(  sizeof(  sbyte )==1 );
      74   ICE_COMPILE_TIME_ASSERT(  sizeof(  sword )==2 );
      75   ICE_COMPILE_TIME_ASSERT(  sizeof(  uword )==2 );
      76   ICE_COMPILE_TIME_ASSERT(  sizeof(  udword )==4 );
      77   ICE_COMPILE_TIME_ASSERT(  sizeof(  sdword )==4 );
      78   ICE_COMPILE_TIME_ASSERT(  sizeof(  uqword )==8 );
      79   ICE_COMPILE_TIME_ASSERT(  sizeof(  sqword )==8 );
          
           //! TO BE DOCUMENTED
           #define DECLARE_ICE_HANDLE(  name ) struct name##__ { int unused; }; typedef struct name##__ *name
          
           typedef udword DynID; //!< Dynamic identifier
          #ifdef USE_HANDLE_MANAGER
           typedef udword KID; //!< Kernel ID
          // DECLARE_ICE_HANDLE(  KID );
          #else
           typedef uword KID; //!< Kernel ID
          #endif
           typedef udword RTYPE; //!< Relationship-type (  ! ) between owners and references
           #define INVALID_ID 0xffffffff //!< Invalid dword ID (  counterpart of null pointers )
          #ifdef USE_HANDLE_MANAGER
           #define INVALID_KID 0xffffffff //!< Invalid Kernel ID
          #else
           #define INVALID_KID 0xffff //!< Invalid Kernel ID
          #endif
           #define INVALID_NUMBER 0xDEADBEEF //!< Standard junk value
          
           // Define BOOL if needed
           #ifndef BOOL
           typedef int BOOL; //!< Another boolean type.
           #endif
          
           //! Union of a float and a sdword
           typedef union {
           float f; //!< The float
           sdword d; //!< The integer
           }scell;
          
           //! Union of a float and a udword
           typedef union {
           float f; //!< The float
           udword d; //!< The integer
           }ucell;
          
           // Type ranges
           #define MAX_SBYTE 0x7f //!< max possible sbyte value
           #define MIN_SBYTE 0x80 //!< min possible sbyte value
           #define MAX_UBYTE 0xff //!< max possible ubyte value
           #define MIN_UBYTE 0x00 //!< min possible ubyte value
           #define MAX_SWORD 0x7fff //!< max possible sword value
           #define MIN_SWORD 0x8000 //!< min possible sword value
           #define MAX_UWORD 0xffff //!< max possible uword value
           #define MIN_UWORD 0x0000 //!< min possible uword value
           #define MAX_SDWORD 0x7fffffff //!< max possible sdword value
           #define MIN_SDWORD 0x80000000 //!< min possible sdword value
           #define MAX_UDWORD 0xffffffff //!< max possible udword value
           #define MIN_UDWORD 0x00000000 //!< min possible udword value
           #define MAX_FLOAT FLT_MAX //!< max possible float value
           #define MIN_FLOAT (  -FLT_MAX ) //!< min possible float value
           #define IEEE_1_0 0x3f800000 //!< integer representation of 1.0
           #define IEEE_255_0 0x437f0000 //!< integer representation of 255.0
           #define IEEE_MAX_FLOAT 0x7f7fffff //!< integer representation of MAX_FLOAT
           #define IEEE_MIN_FLOAT 0xff7fffff //!< integer representation of MIN_FLOAT
           #define IEEE_UNDERFLOW_LIMIT 0x1a000000
          
           #define ONE_OVER_RAND_MAX (  1.0f / float(  RAND_MAX ) ) //!< Inverse of the max possible value returned by rand(   )
          
           typedef int (  __stdcall* PROC )(   ); //!< A standard procedure call.
           typedef bool (  *ENUMERATION )(  udword value,   udword param,   udword context ); //!< ICE standard enumeration call
           typedef void** VTABLE; //!< A V-Table.
          
           #undef MIN
           #undef MAX
           #define MIN(  a,   b ) (  (  a ) < (  b ) ? (  a ) : (  b ) ) //!< Returns the min value between a and b
           #define MAX(  a,   b ) (  (  a ) > (  b ) ? (  a ) : (  b ) ) //!< Returns the max value between a and b
           #define MAXMAX(  a,  b,  c ) (  (  a ) > (  b ) ? MAX (  a,  c ) : MAX (  b,  c ) ) //!< Returns the max value between a,   b and c
          
     150   template<class T> inline_ const T& TMin (  const T& a,   const T& b ) { return b < a ? b : a; }
     151   template<class T> inline_ const T& TMax (  const T& a,   const T& b ) { return a < b ? b : a; }
           template<class T> inline_ void TSetMin (  T& a,   const T& b ) { if(  a>b ) a = b; }
           template<class T> inline_ void TSetMax (  T& a,   const T& b ) { if(  a<b ) a = b; }
          
           #define SQR(  x ) (  (  x )*(  x ) ) //!< Returns x square
           #define CUBE(  x ) (  (  x )*(  x )*(  x ) ) //!< Returns x cube
          
           #define AND & //!< ...
           #define OR | //!< ...
           #define XOR ^ //!< ...
          
           #define QUADRAT(  x ) (  (  x )*(  x ) ) //!< Returns x square
          
          #ifdef _WIN32
          # define srand48(  x ) srand(  (  unsigned int ) (  x ) )
          # define srandom(  x ) srand(  (  unsigned int ) (  x ) )
          # define random(   ) (  (  double ) rand(   ) )
          # define drand48(   ) (  (  double ) (  (  (  double ) rand(   ) ) / (  (  double ) RAND_MAX ) ) )
          #endif
          
          #endif // __ICETYPES_H__

./components/ogre/ogreopcode/include/Opcode/Ice/IceUtils.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains misc. useful macros & defines.
           * \file IceUtils.h
           * \author Pierre Terdiman (  collected from various sources )
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __ICEUTILS_H__
          #define __ICEUTILS_H__
          
           #define START_RUNONCE { static bool __RunOnce__ = false; if(  !__RunOnce__ ){
           #define END_RUNONCE __RunOnce__ = true;}}
          
           //! Reverse all the bits in a 32 bit word (  from Steve Baker's Cute Code Collection )
           //! (  each line can be done in any order.
      20   inline_ void ReverseBits(  udword& n )
           {
           n = (  (  n >> 1 ) & 0x55555555 ) | (  (  n << 1 ) & 0xaaaaaaaa );
           n = (  (  n >> 2 ) & 0x33333333 ) | (  (  n << 2 ) & 0xcccccccc );
           n = (  (  n >> 4 ) & 0x0f0f0f0f ) | (  (  n << 4 ) & 0xf0f0f0f0 );
           n = (  (  n >> 8 ) & 0x00ff00ff ) | (  (  n << 8 ) & 0xff00ff00 );
           n = (  (  n >> 16 ) & 0x0000ffff ) | (  (  n << 16 ) & 0xffff0000 );
           // Etc for larger intergers (  64 bits in Java )
           // NOTE: the >> operation must be unsigned! (  >>> in java )
           }
          
           //! Count the number of '1' bits in a 32 bit word (  from Steve Baker's Cute Code Collection )
           inline_ udword CountBits(  udword n )
           {
           // This relies of the fact that the count of n bits can NOT overflow
           // an n bit interger. EG: 1 bit count takes a 1 bit interger,   2 bit counts
           // 2 bit interger,   3 bit count requires only a 2 bit interger.
           // So we add all bit pairs,   then each nible,   then each byte etc...
      38   n = (  n & 0x55555555 ) + (  (  n & 0xaaaaaaaa ) >> 1 );
      39   n = (  n & 0x33333333 ) + (  (  n & 0xcccccccc ) >> 2 );
           n = (  n & 0x0f0f0f0f ) + (  (  n & 0xf0f0f0f0 ) >> 4 );
           n = (  n & 0x00ff00ff ) + (  (  n & 0xff00ff00 ) >> 8 );
           n = (  n & 0x0000ffff ) + (  (  n & 0xffff0000 ) >> 16 );
           // Etc for larger intergers (  64 bits in Java )
           // NOTE: the >> operation must be unsigned! (  >>> in java )
           return n;
           }
          
           //! Even faster?
           inline_ udword CountBits2(  udword bits )
           {
           bits = bits - (  (  bits >> 1 ) & 0x55555555 );
           bits = (  (  bits >> 2 ) & 0x33333333 ) + (  bits & 0x33333333 );
           bits = (  (  bits >> 4 ) + bits ) & 0x0F0F0F0F;
           return (  bits * 0x01010101 ) >> 24;
           }
          
           //! Spread out bits. EG 00001111 -> 0101010101
           //! 00001010 -> 0100010000
           //! This is used to interleve to intergers to produce a `Morten Key'
           //! used in Space Filling Curves (  See DrDobbs Journal,   July 1999 )
           //! Order is important.
           inline_ void SpreadBits(  udword& n )
           {
           n = (   n & 0x0000ffff ) | (  (   n & 0xffff0000 ) << 16 );
           n = (   n & 0x000000ff ) | (  (   n & 0x0000ff00 ) << 8 );
           n = (   n & 0x000f000f ) | (  (   n & 0x00f000f0 ) << 4 );
           n = (   n & 0x03030303 ) | (  (   n & 0x0c0c0c0c ) << 2 );
           n = (   n & 0x11111111 ) | (  (   n & 0x22222222 ) << 1 );
           }
          
           // Next Largest Power of 2
           // Given a binary integer value x,   the next largest power of 2 can be computed by a SWAR algorithm
           // that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with
           // the same most significant 1 as x,   but all 1's below it. Adding 1 to that value yields the next
           // largest power of 2. For a 32-bit value:
           inline_ udword nlpo2(  udword x )
           {
           x |= (  x >> 1 );
           x |= (  x >> 2 );
           x |= (  x >> 4 );
           x |= (  x >> 8 );
           x |= (  x >> 16 );
           return x+1;
           }
          
           //! Test to see if a number is an exact power of two (  from Steve Baker's Cute Code Collection )
           inline_ bool IsPowerOfTwo(  udword n ) { return (  (  n&(  n-1 ) )==0 ); }
          
           //! Zero the least significant '1' bit in a word. (  from Steve Baker's Cute Code Collection )
           inline_ void ZeroLeastSetBit(  udword& n ) { n&=(  n-1 ); }
          
           //! Set the least significant N bits in a word. (  from Steve Baker's Cute Code Collection )
           inline_ void SetLeastNBits(  udword& x,   udword n ) { x|=~(  ~0<<n ); }
          
           //! Classic XOR swap (  from Steve Baker's Cute Code Collection )
           //! x ^= y; /* x' = (  x^y ) */
           //! y ^= x; /* y' = (  y^(  x^y ) ) = x */
           //! x ^= y; /* x' = (  x^y )^x = y */
           inline_ void Swap(  udword& x,   udword& y ) { x ^= y; y ^= x; x ^= y; }
          
           //! Little/Big endian (  from Steve Baker's Cute Code Collection )
           //!
           //! Extra comments by Kenny Hoff:
           //! Determines the byte-ordering of the current machine (  little or big endian )
           //! by setting an integer value to 1 (  so least significant bit is now 1 ); take
           //! the address of the int and cast to a byte pointer (  treat integer as an
           //! array of four bytes ); check the value of the first byte (  must be 0 or 1 ).
           //! If the value is 1,   then the first byte least significant byte and this
           //! implies LITTLE endian. If the value is 0,   the first byte is the most
           //! significant byte,   BIG endian. Examples:
           //! integer 1 on BIG endian: 00000000 00000000 00000000 00000001
           //! integer 1 on LITTLE endian: 00000001 00000000 00000000 00000000
           //!---------------------------------------------------------------------------
           //! int IsLittleEndian(   ) { int x=1; return (   (  (  char* )(  &x ) )[0]  ); }
           inline_ char LittleEndian(   ) { int i = 1; return *(  (  char* )&i ); }
          
           //!< Alternative abs function
           inline_ udword abs_(  sdword x ) { sdword y= x >> 31; return (  x^y )-y; }
          
           //!< Alternative min function
           inline_ sdword min_(  sdword a,   sdword b ) { sdword delta = b-a; return a + (  delta&(  delta>>31 ) ); }
          
           // Determine if one of the bytes in a 4 byte word is zero
           inline_ BOOL HasNullByte(  udword x ) { return (  (  x + 0xfefefeff ) & (  ~x ) & 0x80808080 ); }
          
           // To find the smallest 1 bit in a word EG: ~~~~~~10---0 => 0----010---0
           inline_ udword LowestOneBit(  udword w ) { return (  (  w ) & (  ~(  w )+1 ) ); }
          // inline_ udword LowestOneBit_(  udword w ) { return (  (  w ) & (  -(  w ) ) ); }
          
           // Most Significant 1 Bit
           // Given a binary integer value x,   the most significant 1 bit (  highest numbered element of a bit set )
           // can be computed using a SWAR algorithm that recursively "folds" the upper bits into the lower bits.
           // This process yields a bit vector with the same most significant 1 as x,   but all 1's below it.
           // Bitwise AND of the original value with the complement of the "folded" value shifted down by one
           // yields the most significant bit. For a 32-bit value:
           inline_ udword msb32(  udword x )
           {
           x |= (  x >> 1 );
           x |= (  x >> 2 );
           x |= (  x >> 4 );
           x |= (  x >> 8 );
           x |= (  x >> 16 );
           return (  x & ~(  x >> 1 ) );
           }
          
           /*
           "Just call it repeatedly with various input values and always with the same variable as "memory".
           The sharpness determines the degree of filtering,   where 0 completely filters out the input,   and 1
           does no filtering at all.
          
           I seem to recall from college that this is called an IIR (  Infinite Impulse Response ) filter. As opposed
           to the more typical FIR (  Finite Impulse Response ).
          
           Also,   I'd say that you can make more intelligent and interesting filters than this,   for example filters
           that remove wrong responses from the mouse because it's being moved too fast. You'd want such a filter
           to be applied before this one,   of course."
          
           (  JCAB on Flipcode )
           */
           inline_ float FeedbackFilter(  float val,   float& memory,   float sharpness )
           {
           ASSERT(  sharpness>=0.0f && sharpness<=1.0f && "Invalid sharpness value in feedback filter" );
           if(  sharpness<0.0f ) sharpness = 0.0f;
           else if(  sharpness>1.0f ) sharpness = 1.0f;
           return memory = val * sharpness + memory * (  1.0f - sharpness );
           }
          
           //! If you can guarantee that your input domain (  i.e. value of x ) is slightly
           //! limited (  abs(  x ) must be < (  (  1<<31u )-32767 ) ),   then you can use the
           //! following code to clamp the resulting value into [-32768,  +32767] range:
           inline_ int ClampToInt16(  int x )
           {
          // ASSERT(  abs(  x ) < (  int )(  (  1<<31u )-32767 ) );
          
           int delta = 32767 - x;
           x += (  delta>>31 ) & delta;
           delta = x + 32768;
           x -= (  delta>>31 ) & delta;
           return x;
           }
          
           // Generic functions
           template<class Type> inline_ void TSwap(  Type& a,   Type& b ) { const Type c = a; a = b; b = c; }
           template<class Type> inline_ Type TClamp(  const Type& x,   const Type& lo,   const Type& hi ) { return (  (  x<lo ) ? lo : (  x>hi ) ? hi : x ); }
          
           template<class Type> inline_ void TSort(  Type& a,   Type& b )
           {
           if(  a>b ) TSwap(  a,   b );
           }
          
           template<class Type> inline_ void TSort(  Type& a,   Type& b,   Type& c )
           {
           if(  a>b ) TSwap(  a,   b );
           if(  b>c ) TSwap(  b,   c );
           if(  a>b ) TSwap(  a,   b );
           if(  b>c ) TSwap(  b,   c );
           }
          
           // Prevent nasty user-manipulations (  strategy borrowed from Charles Bloom )
          // #define PREVENT_COPY(  curclass ) void operator = (  const curclass& object ) { ASSERT(  !"Bad use of operator =" ); }
           // ... actually this is better !
           #define PREVENT_COPY(  cur_class ) private: cur_class(  const cur_class& object ); cur_class& operator=(  const cur_class& object );
          
           //! TO BE DOCUMENTED
           #define OFFSET_OF(  Class,   Member ) (  size_t )&(  (  (  Class* )0 )->Member )
           //! TO BE DOCUMENTED
           //#define ARRAYSIZE(  p ) (  sizeof(  p )/sizeof(  p[0] ) )
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Returns the alignment of the input address.
           * \fn Alignment(   )
           * \param address [in] address to check
           * \return the best alignment (  e.g. 1 for odd addresses,   etc )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           FUNCTION udword Alignment(  udword address );
          
           #define IS_ALIGNED_2(  x ) (  (  x&1 )==0 )
           #define IS_ALIGNED_4(  x ) (  (  x&3 )==0 )
           #define IS_ALIGNED_8(  x ) (  (  x&7 )==0 )
          
           inline_ void _prefetch(  void const* ptr ) { (  void )*(  char const volatile * )ptr; }
          
           // Compute implicit coords from an index:
           // The idea is to get back 2D coords from a 1D index.
           // For example:
           //
           // 0 1 2 ... nbu-1
           // nbu nbu+1 i ...
           //
           // We have i,   we're looking for the equivalent (  u=2,   v=1 ) location.
           // i = u + v*nbu
           // <=> i/nbu = u/nbu + v
           // Since 0 <= u < nbu,   u/nbu = 0 (  integer )
           // Hence: v = i/nbu
           // Then we simply put it back in the original equation to compute u = i - v*nbu
           inline_ void Compute2DCoords(  udword& u,   udword& v,   udword i,   udword nbu )
           {
           v = i / nbu;
           u = i - (  v * nbu );
           }
          
           // In 3D: i = u + v*nbu + w*nbu*nbv
           // <=> i/(  nbu*nbv ) = u/(  nbu*nbv ) + v/nbv + w
           // u/(  nbu*nbv ) is null since u/nbu was null already.
           // v/nbv is null as well for the same reason.
           // Hence w = i/(  nbu*nbv )
           // Then we're left with a 2D problem: i' = i - w*nbu*nbv = u + v*nbu
           inline_ void Compute3DCoords(  udword& u,   udword& v,   udword& w,   udword i,   udword nbu,   udword nbu_nbv )
           {
           w = i / (  nbu_nbv );
           Compute2DCoords(  u,   v,   i - (  w * nbu_nbv ),   nbu );
           }
          
          #endif // __ICEUTILS_H__

./components/ogre/ogreopcode/include/Opcode/OPC_BaseModel.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains base model interface.
           * \file OPC_BaseModel.h
           * \author Pierre Terdiman
           * \date May,   18,   2003
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_BASEMODEL_H__
          #define __OPC_BASEMODEL_H__
          
           //! Model creation structure
           struct OPCODECREATE
           {
           //! Constructor
           OPCODECREATE(   );
          
           MeshInterface* mIMesh; //!< Mesh interface (  access to triangles & vertices ) (  * )
           BuildSettings mSettings; //!< Builder's settings
           bool mNoLeaf; //!< true => discard leaf nodes (  else use a normal tree )
           bool mQuantized; //!< true => quantize the tree (  else use a normal tree )
          #ifdef __MESHMERIZER_H__
           bool mCollisionHull; //!< true => use convex hull + GJK
          #endif // __MESHMERIZER_H__
           bool mKeepOriginal; //!< true => keep a copy of the original tree (  debug purpose )
           bool mCanRemap; //!< true => allows OPCODE to reorganize client arrays
          
           // (  * ) This pointer is saved internally and used by OPCODE until collision structures are released,  
           // so beware of the object's lifetime.
           };
          
           enum ModelFlag
           {
           OPC_QUANTIZED = (  1<<0 ),   //!< Compressed/uncompressed tree
           OPC_NO_LEAF = (  1<<1 ),   //!< Leaf/NoLeaf tree
           OPC_SINGLE_NODE = (  1<<2 ) //!< Special case for 1-node models
           };
          
      50   class BaseModel
           {
           public:
           // Constructor/Destructor
      54   BaseModel(   );
      55   virtual ~BaseModel(   );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Builds a collision model.
           * \param create [in] model creation structure
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      64   virtual bool Build(  const OPCODECREATE& create ) = 0;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the number of bytes used by the tree.
           * \return amount of bytes used
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      72   virtual udword GetUsedBytes(   ) const = 0;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Refits the collision model. This can be used to handle dynamic meshes. Usage is:
           * 1. modify your mesh vertices (  keep the topology constant! )
           * 2. refit the tree (  call this method )
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      82   virtual bool Refit(   );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the source tree.
           * \return generic tree
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ const AABBTree* GetSourceTree(   ) const { return mSource; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the tree.
           * \return the collision tree
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      98   inline_ const AABBOptimizedTree* GetTree(   ) const { return mTree; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the tree.
           * \return the collision tree
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ AABBOptimizedTree* GetTree(   ) { return mTree; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the number of nodes in the tree.
           * Should be 2*N-1 for normal trees and N-1 for optimized ones.
           * \return number of nodes
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ udword GetNbNodes(   ) const { return mTree->GetNbNodes(   ); }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks whether the tree has leaf nodes or not.
           * \return true if the tree has leaf nodes (  normal tree ),   else false (  optimized tree )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL HasLeafNodes(   ) const { return !(  mModelCode & OPC_NO_LEAF ); }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks whether the tree is quantized or not.
           * \return true if the tree is quantized
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL IsQuantized(   ) const { return mModelCode & OPC_QUANTIZED; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks whether the model has a single node or not. This special case must be handled separately.
           * \return true if the model has only 1 node
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL HasSingleNode(   ) const { return mModelCode & OPC_SINGLE_NODE; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the model's code.
           * \return model's code
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ udword GetModelCode(   ) const { return mModelCode; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the mesh interface.
           * \return mesh interface
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ const MeshInterface* GetMeshInterface(   ) const { return mIMesh; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Sets the mesh interface.
           * \param imesh [in] mesh interface
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void SetMeshInterface(  const MeshInterface* imesh ) { mIMesh = imesh; }
          
           protected:
           const MeshInterface* mIMesh; //!< User-defined mesh interface
           udword mModelCode; //!< Model code = combination of ModelFlag(  s )
           AABBTree* mSource; //!< Original source tree
           AABBOptimizedTree* mTree; //!< Optimized tree owned by the model
           // Internal methods
           void ReleaseBase(   );
           bool CreateTree(  bool no_leaf,   bool quantized );
           };
          
          #endif //__OPC_BASEMODEL_H__

./components/ogre/ogreopcode/include/Opcode/OPC_BoxBoxOverlap.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * OBB-OBB overlap test using the separating axis theorem.
           * - original code by Gomez / Gamasutra (  similar to Gottschalk's one in RAPID )
           * - optimized for AABB trees by computing the rotation matrix once (  SOLID-fashion )
           * - the fabs matrix is precomputed as well and epsilon-tweaked (  RAPID-style,   we found this almost mandatory )
           * - Class III axes can be disabled... (  SOLID & Intel fashion )
           * - ...or enabled to perform some profiling
           * - CPU comparisons used when appropriate
           * - lazy evaluation sometimes saves some work in case of early exits (  unlike SOLID )
           *
           * \param ea [in] extents from box A
           * \param ca [in] center from box A
           * \param eb [in] extents from box B
           * \param cb [in] center from box B
           * \return true if boxes overlap
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ BOOL AABBTreeCollider::BoxBoxOverlap(  const IceMaths::Point& ea_,   const IceMaths::Point& ca_,   const IceMaths::Point& eb_,   const IceMaths::Point& cb_ )
          {
           // Applies model scales
           const IceMaths::Point ea = ea_*mScale0;
           const IceMaths::Point ca = ca_*mScale0;
           const IceMaths::Point eb = eb_*mScale1;
           const IceMaths::Point cb = cb_*mScale1;
          
           // Stats
      28   mNbBVBVTests++;
          
           float t,  t2;
          
           // Class I : A's basis vectors
           float Tx = (  mR1to0.m[0][0]*cb.x + mR1to0.m[1][0]*cb.y + mR1to0.m[2][0]*cb.z ) + mT1to0.x - ca.x;
      34   t = ea.x + eb.x*mAR.m[0][0] + eb.y*mAR.m[1][0] + eb.z*mAR.m[2][0];
           if(  GREATER(  Tx,   t ) ) return FALSE;
          
           float Ty = (  mR1to0.m[0][1]*cb.x + mR1to0.m[1][1]*cb.y + mR1to0.m[2][1]*cb.z ) + mT1to0.y - ca.y;
           t = ea.y + eb.x*mAR.m[0][1] + eb.y*mAR.m[1][1] + eb.z*mAR.m[2][1];
           if(  GREATER(  Ty,   t ) ) return FALSE;
          
           float Tz = (  mR1to0.m[0][2]*cb.x + mR1to0.m[1][2]*cb.y + mR1to0.m[2][2]*cb.z ) + mT1to0.z - ca.z;
           t = ea.z + eb.x*mAR.m[0][2] + eb.y*mAR.m[1][2] + eb.z*mAR.m[2][2];
           if(  GREATER(  Tz,   t ) ) return FALSE;
          
           // Class II : B's basis vectors
           t = Tx*mR1to0.m[0][0] + Ty*mR1to0.m[0][1] + Tz*mR1to0.m[0][2]; t2 = ea.x*mAR.m[0][0] + ea.y*mAR.m[0][1] + ea.z*mAR.m[0][2] + eb.x;
           if(  GREATER(  t,   t2 ) ) return FALSE;
          
           t = Tx*mR1to0.m[1][0] + Ty*mR1to0.m[1][1] + Tz*mR1to0.m[1][2]; t2 = ea.x*mAR.m[1][0] + ea.y*mAR.m[1][1] + ea.z*mAR.m[1][2] + eb.y;
           if(  GREATER(  t,   t2 ) ) return FALSE;
          
           t = Tx*mR1to0.m[2][0] + Ty*mR1to0.m[2][1] + Tz*mR1to0.m[2][2]; t2 = ea.x*mAR.m[2][0] + ea.y*mAR.m[2][1] + ea.z*mAR.m[2][2] + eb.z;
           if(  GREATER(  t,   t2 ) ) return FALSE;
          
           // Class III : 9 cross products
           // Cool trick: always perform the full test for first level,   regardless of settings.
           // That way pathological cases (  such as the pencils scene ) are quickly rejected anyway !
           if(  mFullBoxBoxTest || mNbBVBVTests==1 )
           {
           t = Tz*mR1to0.m[0][1] - Ty*mR1to0.m[0][2]; t2 = ea.y*mAR.m[0][2] + ea.z*mAR.m[0][1] + eb.y*mAR.m[2][0] + eb.z*mAR.m[1][0]; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A0 x B0
           t = Tz*mR1to0.m[1][1] - Ty*mR1to0.m[1][2]; t2 = ea.y*mAR.m[1][2] + ea.z*mAR.m[1][1] + eb.x*mAR.m[2][0] + eb.z*mAR.m[0][0]; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A0 x B1
           t = Tz*mR1to0.m[2][1] - Ty*mR1to0.m[2][2]; t2 = ea.y*mAR.m[2][2] + ea.z*mAR.m[2][1] + eb.x*mAR.m[1][0] + eb.y*mAR.m[0][0]; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A0 x B2
           t = Tx*mR1to0.m[0][2] - Tz*mR1to0.m[0][0]; t2 = ea.x*mAR.m[0][2] + ea.z*mAR.m[0][0] + eb.y*mAR.m[2][1] + eb.z*mAR.m[1][1]; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A1 x B0
           t = Tx*mR1to0.m[1][2] - Tz*mR1to0.m[1][0]; t2 = ea.x*mAR.m[1][2] + ea.z*mAR.m[1][0] + eb.x*mAR.m[2][1] + eb.z*mAR.m[0][1]; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A1 x B1
           t = Tx*mR1to0.m[2][2] - Tz*mR1to0.m[2][0]; t2 = ea.x*mAR.m[2][2] + ea.z*mAR.m[2][0] + eb.x*mAR.m[1][1] + eb.y*mAR.m[0][1]; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A1 x B2
           t = Ty*mR1to0.m[0][0] - Tx*mR1to0.m[0][1]; t2 = ea.x*mAR.m[0][1] + ea.y*mAR.m[0][0] + eb.y*mAR.m[2][2] + eb.z*mAR.m[1][2]; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A2 x B0
           t = Ty*mR1to0.m[1][0] - Tx*mR1to0.m[1][1]; t2 = ea.x*mAR.m[1][1] + ea.y*mAR.m[1][0] + eb.x*mAR.m[2][2] + eb.z*mAR.m[0][2]; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A2 x B1
           t = Ty*mR1to0.m[2][0] - Tx*mR1to0.m[2][1]; t2 = ea.x*mAR.m[2][1] + ea.y*mAR.m[2][0] + eb.x*mAR.m[1][2] + eb.y*mAR.m[0][2]; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A2 x B2
           }
           return TRUE;
          }
          
          //! A dedicated version when one box is constant
          inline_ BOOL OBBCollider::BoxBoxOverlap(  const IceMaths::Point& extents_,   const IceMaths::Point& center_ )
          {
           // Applies the model's local scale
           const IceMaths::Point extents = extents_ * mLocalScale;
           const IceMaths::Point center = center_ * mLocalScale;
          
           // Stats
           mNbVolumeBVTests++;
          
           float t,  t2;
          
           // Class I : A's basis vectors
           float Tx = mTBoxToModel.x - center.x; t = extents.x + mBBx1; if(  GREATER(  Tx,   t ) ) return FALSE;
           float Ty = mTBoxToModel.y - center.y; t = extents.y + mBBy1; if(  GREATER(  Ty,   t ) ) return FALSE;
           float Tz = mTBoxToModel.z - center.z; t = extents.z + mBBz1; if(  GREATER(  Tz,   t ) ) return FALSE;
          
           // Class II : B's basis vectors
           t = Tx*mRBoxToModel.m[0][0] + Ty*mRBoxToModel.m[0][1] + Tz*mRBoxToModel.m[0][2];
           t2 = extents.x*mAR.m[0][0] + extents.y*mAR.m[0][1] + extents.z*mAR.m[0][2] + mBoxExtents.x;
           if(  GREATER(  t,   t2 ) ) return FALSE;
          
           t = Tx*mRBoxToModel.m[1][0] + Ty*mRBoxToModel.m[1][1] + Tz*mRBoxToModel.m[1][2];
           t2 = extents.x*mAR.m[1][0] + extents.y*mAR.m[1][1] + extents.z*mAR.m[1][2] + mBoxExtents.y;
           if(  GREATER(  t,   t2 ) ) return FALSE;
          
           t = Tx*mRBoxToModel.m[2][0] + Ty*mRBoxToModel.m[2][1] + Tz*mRBoxToModel.m[2][2];
           t2 = extents.x*mAR.m[2][0] + extents.y*mAR.m[2][1] + extents.z*mAR.m[2][2] + mBoxExtents.z;
           if(  GREATER(  t,   t2 ) ) return FALSE;
          
           // Class III : 9 cross products
           // Cool trick: always perform the full test for first level,   regardless of settings.
           // That way pathological cases (  such as the pencils scene ) are quickly rejected anyway !
           if(  mFullBoxBoxTest || mNbVolumeBVTests==1 )
           {
           t = Tz*mRBoxToModel.m[0][1] - Ty*mRBoxToModel.m[0][2]; t2 = extents.y*mAR.m[0][2] + extents.z*mAR.m[0][1] + mBB_1; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A0 x B0
           t = Tz*mRBoxToModel.m[1][1] - Ty*mRBoxToModel.m[1][2]; t2 = extents.y*mAR.m[1][2] + extents.z*mAR.m[1][1] + mBB_2; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A0 x B1
           t = Tz*mRBoxToModel.m[2][1] - Ty*mRBoxToModel.m[2][2]; t2 = extents.y*mAR.m[2][2] + extents.z*mAR.m[2][1] + mBB_3; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A0 x B2
           t = Tx*mRBoxToModel.m[0][2] - Tz*mRBoxToModel.m[0][0]; t2 = extents.x*mAR.m[0][2] + extents.z*mAR.m[0][0] + mBB_4; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A1 x B0
           t = Tx*mRBoxToModel.m[1][2] - Tz*mRBoxToModel.m[1][0]; t2 = extents.x*mAR.m[1][2] + extents.z*mAR.m[1][0] + mBB_5; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A1 x B1
           t = Tx*mRBoxToModel.m[2][2] - Tz*mRBoxToModel.m[2][0]; t2 = extents.x*mAR.m[2][2] + extents.z*mAR.m[2][0] + mBB_6; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A1 x B2
           t = Ty*mRBoxToModel.m[0][0] - Tx*mRBoxToModel.m[0][1]; t2 = extents.x*mAR.m[0][1] + extents.y*mAR.m[0][0] + mBB_7; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A2 x B0
           t = Ty*mRBoxToModel.m[1][0] - Tx*mRBoxToModel.m[1][1]; t2 = extents.x*mAR.m[1][1] + extents.y*mAR.m[1][0] + mBB_8; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A2 x B1
           t = Ty*mRBoxToModel.m[2][0] - Tx*mRBoxToModel.m[2][1]; t2 = extents.x*mAR.m[2][1] + extents.y*mAR.m[2][0] + mBB_9; if(  GREATER(  t,   t2 ) ) return FALSE; // L = A2 x B2
           }
           return TRUE;
          }
          
          //! A special version for 2 axis-aligned boxes
          inline_ BOOL AABBCollider::AABBAABBOverlap(  const IceMaths::Point& extents,   const IceMaths::Point& center )
          {
           // Stats
           mNbVolumeBVTests++;
          
           float tx = mBox.mCenter.x - center.x; float ex = extents.x + mBox.mExtents.x; if(  GREATER(  tx,   ex ) ) return FALSE;
           float ty = mBox.mCenter.y - center.y; float ey = extents.y + mBox.mExtents.y; if(  GREATER(  ty,   ey ) ) return FALSE;
           float tz = mBox.mCenter.z - center.z; float ez = extents.z + mBox.mExtents.z; if(  GREATER(  tz,   ez ) ) return FALSE;
          
           return TRUE;
          }

./components/ogre/ogreopcode/include/Opcode/OPC_BoxPruning.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for box pruning.
           * \file IceBoxPruning.h
           * \author Pierre Terdiman
           * \date January,   29,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_BOXPRUNING_H__
          #define __OPC_BOXPRUNING_H__
          
           // Optimized versions
      24   FUNCTION bool CompleteBoxPruning(  udword nb,   const IceMaths::AABB** array,   Pairs& pairs,   const IceMaths::Axes& axes );
      25   FUNCTION bool BipartiteBoxPruning(  udword nb0,   const IceMaths::AABB** array0,   udword nb1,   const IceMaths::AABB** array1,   Pairs& pairs,   const IceMaths::Axes& axes );
          
           // Brute-force versions
      28   FUNCTION bool BruteForceCompleteBoxTest(  udword nb,   const IceMaths::AABB** array,   Pairs& pairs );
      29   FUNCTION bool BruteForceBipartiteBoxTest(  udword nb0,   const IceMaths::AABB** array0,   udword nb1,   const IceMaths::AABB** array1,   Pairs& pairs );
          
          #endif //__OPC_BOXPRUNING_H__

./components/ogre/ogreopcode/include/Opcode/OPC_Collider.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains base collider class.
           * \file OPC_Collider.h
           * \author Pierre Terdiman
           * \date June,   2,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_COLLIDER_H__
          #define __OPC_COLLIDER_H__
          
           enum CollisionFlag
           {
           OPC_FIRST_CONTACT = (  1<<0 ),   //!< Report all contacts (  false ) or only first one (  true )
           OPC_TEMPORAL_COHERENCE = (  1<<1 ),   //!< Use temporal coherence or not
           OPC_CONTACT = (  1<<2 ),   //!< Final contact status after a collision query
           OPC_TEMPORAL_HIT = (  1<<3 ),   //!< There has been an early exit due to temporal coherence
           OPC_NO_PRIMITIVE_TESTS = (  1<<4 ),   //!< Keep or discard primitive-bv tests in leaf nodes (  volume-mesh queries )
          
           OPC_CONTACT_FOUND = OPC_FIRST_CONTACT | OPC_CONTACT,  
           OPC_TEMPORAL_CONTACT = OPC_TEMPORAL_HIT | OPC_CONTACT,  
          
           OPC_FORCE_DWORD = 0x7fffffff
           };
          
      37   class Collider
           {
           public:
           // Constructor / Destructor
      41   Collider(   );
      42   virtual ~Collider(   );
          
           // Collision report
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the last collision status after a collision query.
           * \return true if a collision occured
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL GetContactStatus(   ) const { return mFlags & OPC_CONTACT; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the "first contact" mode.
           * \return true if "first contact" mode is on
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      60   inline_ BOOL FirstContactEnabled(   ) const { return mFlags & OPC_FIRST_CONTACT; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the temporal coherence mode.
           * \return true if temporal coherence is on
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      68   inline_ BOOL TemporalCoherenceEnabled(   ) const { return mFlags & OPC_TEMPORAL_COHERENCE; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks a first contact has already been found.
           * \return true if a first contact has been found and we can stop a query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      76   inline_ BOOL ContactFound(   ) const { return (  mFlags&OPC_CONTACT_FOUND )==OPC_CONTACT_FOUND; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks there's been an early exit due to temporal coherence;
           * \return true if a temporal hit has occured
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      84   inline_ BOOL TemporalHit(   ) const { return mFlags & OPC_TEMPORAL_HIT; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks primitive tests are enabled;
           * \return true if primitive tests must be skipped
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      92   inline_ BOOL SkipPrimitiveTests(   ) const { return mFlags & OPC_NO_PRIMITIVE_TESTS; }
          
           // Settings
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Reports all contacts (  false ) or first contact only (  true )
           * \param flag [in] true for first contact,   false for all contacts
           * \see SetTemporalCoherence(  bool flag )
           * \see ValidateSettings(   )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     104   inline_ void SetFirstContact(  bool flag )
           {
           if(  flag ) mFlags |= OPC_FIRST_CONTACT;
           else mFlags &= ~OPC_FIRST_CONTACT;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Enable/disable temporal coherence.
           * \param flag [in] true to enable temporal coherence,   false to discard it
           * \see SetFirstContact(  bool flag )
           * \see ValidateSettings(   )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     118   inline_ void SetTemporalCoherence(  bool flag )
           {
           if(  flag ) mFlags |= OPC_TEMPORAL_COHERENCE;
           else mFlags &= ~OPC_TEMPORAL_COHERENCE;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Enable/disable primitive tests.
           * \param flag [in] true to enable primitive tests,   false to discard them
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     130   inline_ void SetPrimitiveTests(  bool flag )
           {
           if(  !flag ) mFlags |= OPC_NO_PRIMITIVE_TESTS;
           else mFlags &= ~OPC_NO_PRIMITIVE_TESTS;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Validates current settings. You should call this method after all the settings / callbacks have been defined for a collider.
           * \return null if everything is ok,   else a string describing the problem
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           virtual const char* ValidateSettings(   ) = 0;
          
           protected:
           udword mFlags; //!< Bit flags
           const BaseModel* mCurrentModel; //!< Current model for collision query (  owner of touched faces )
           // User mesh interface
           const MeshInterface* mIMesh; //!< User-defined mesh interface
          
           // Internal methods
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups current collision model
           * \param model [in] current collision model
           * \return TRUE if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL Setup(  const BaseModel* model )
           {
           // Keep track of current model
           mCurrentModel = model;
           if(  !mCurrentModel ) return FALSE;
          
           mIMesh = model->GetMeshInterface(   );
           return mIMesh!=null;
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Initializes a query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           virtual inline_ void InitQuery(   ) { mFlags &= ~OPC_TEMPORAL_CONTACT; }
           };
          
          #endif // __OPC_COLLIDER_H__

./components/ogre/ogreopcode/include/Opcode/OPC_Common.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains common classes & defs used in OPCODE.
           * \file OPC_Common.h
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_COMMON_H__
          #define __OPC_COMMON_H__
          
          // [GOTTFRIED]: Just a small change for readability.
          #ifdef OPC_CPU_COMPARE
           #define GREATER(  x,   y ) AIR(  x ) > IR(  y )
          #else
           #define GREATER(  x,   y ) fabsf(  x ) > (  y )
          #endif
          
      30   class CollisionAABB
           {
           public:
           //! Constructor
      34   inline_ CollisionAABB(   ) {}
           //! Constructor
      36   inline_ CollisionAABB(  const IceMaths::AABB& b ) { b.GetCenter(  mCenter ); b.GetExtents(  mExtents ); }
           //! Destructor
      38   inline_ ~CollisionAABB(   ) {}
          
           //! Get min point of the box
           inline_ void GetMin(  IceMaths::Point& min ) const { min = mCenter - mExtents; }
           //! Get max point of the box
      43   inline_ void GetMax(  IceMaths::Point& max ) const { max = mCenter + mExtents; }
          
           //! Get component of the box's min point along a given axis
      46   inline_ float GetMin(  udword axis ) const { return mCenter[axis] - mExtents[axis]; }
           //! Get component of the box's max point along a given axis
      48   inline_ float GetMax(  udword axis ) const { return mCenter[axis] + mExtents[axis]; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Setups an AABB from min & max vectors.
           * \param min [in] the min point
           * \param max [in] the max point
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      57   inline_ void SetMinMax(  const IceMaths::Point& min,   const IceMaths::Point& max ) { mCenter = (  max + min )*0.5f; mExtents = (  max - min )*0.5f; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks a box is inside another box.
           * \param box [in] the other box
           * \return true if current box is inside input box
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ BOOL IsInside(  const CollisionAABB& box ) const
           {
      68   if(  box.GetMin(  0 )>GetMin(  0 ) ) return FALSE;
      69   if(  box.GetMin(  1 )>GetMin(  1 ) ) return FALSE;
      70   if(  box.GetMin(  2 )>GetMin(  2 ) ) return FALSE;
      71   if(  box.GetMax(  0 )<GetMax(  0 ) ) return FALSE;
      72   if(  box.GetMax(  1 )<GetMax(  1 ) ) return FALSE;
      73   if(  box.GetMax(  2 )<GetMax(  2 ) ) return FALSE;
           return TRUE;
           }
          
           IceMaths::Point mCenter; //!< Box center
           IceMaths::Point mExtents; //!< Box extents
           };
          
           class QuantizedAABB
           {
           public:
           //! Constructor
           inline_ QuantizedAABB(   ) {}
           //! Destructor
           inline_ ~QuantizedAABB(   ) {}
          
           sword mCenter[3]; //!< Quantized center
           uword mExtents[3]; //!< Quantized extents
           };
          
           //! Quickly rotates & translates a vector
           inline_ void TransformPoint(  IceMaths::Point& dest,   const IceMaths::Point& source,   const IceMaths::Matrix3x3& rot,   const IceMaths::Point& trans )
           {
           dest.x = trans.x + source.x * rot.m[0][0] + source.y * rot.m[1][0] + source.z * rot.m[2][0];
           dest.y = trans.y + source.x * rot.m[0][1] + source.y * rot.m[1][1] + source.z * rot.m[2][1];
           dest.z = trans.z + source.x * rot.m[0][2] + source.y * rot.m[1][2] + source.z * rot.m[2][2];
           }
          
          #endif //__OPC_COMMON_H__

./components/ogre/ogreopcode/include/Opcode/OPC_HybridModel.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for hybrid models.
           * \file OPC_HybridModel.h
           * \author Pierre Terdiman
           * \date May,   18,   2003
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_HYBRIDMODEL_H__
          #define __OPC_HYBRIDMODEL_H__
          
           //! Leaf descriptor
           struct LeafTriangles
           {
           udword Data; //!< Packed data
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets number of triangles in the leaf.
           * \return number of triangles N,   with 0 < N <= 16
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ udword GetNbTriangles(   ) const { return (  Data & 15 )+1; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets triangle index for this leaf. Indexed model's array of indices retrieved with HybridModel::GetIndices(   )
           * \return triangle index
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      42   inline_ udword GetTriangleIndex(   ) const { return Data>>4; }
      43   inline_ void SetData(  udword nb,   udword index ) { ASSERT(  nb>0 && nb<=16 ); nb--; Data = (  index<<4 )|(  nb&15 ); }
           };
          
      46   class HybridModel : public BaseModel
           {
           public:
           // Constructor/Destructor
      50   HybridModel(   );
      51   virtual ~HybridModel(   );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Builds a collision model.
           * \param create [in] model creation structure
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           override(  BaseModel ) bool Build(  const OPCODECREATE& create );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the number of bytes used by the tree.
           * \return amount of bytes used
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           override(  BaseModel ) udword GetUsedBytes(   ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Refits the collision model. This can be used to handle dynamic meshes. Usage is:
           * 1. modify your mesh vertices (  keep the topology constant! )
           * 2. refit the tree (  call this method )
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           override(  BaseModel ) bool Refit(   );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets array of triangles.
           * \return array of triangles
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ const LeafTriangles* GetLeafTriangles(   ) const { return mTriangles; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets array of indices.
           * \return array of indices
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      94   inline_ const udword* GetIndices(   ) const { return mIndices; }
          
           private:
           udword mNbLeaves; //!< Number of leaf nodes in the model
           LeafTriangles* mTriangles; //!< Array of mNbLeaves leaf descriptors
           udword mNbPrimitives; //!< Number of primitives in the model
           udword* mIndices; //!< Array of primitive indices
          
           // Internal methods
           void Release(   );
           };
          
          #endif // __OPC_HYBRIDMODEL_H__

./components/ogre/ogreopcode/include/Opcode/OPC_IceHook.h

       1  
          // Should be included by Opcode.h if needed
          
           #define ICE_DONT_CHECK_COMPILER_OPTIONS
          
           // From Windows...
           typedef int BOOL;
           #ifndef FALSE
           #define FALSE 0
           #endif
          
           #ifndef TRUE
           #define TRUE 1
           #endif
          
           #include <stdio.h>
           #include <stdlib.h>
           #include <assert.h>
           #include <string.h>
           #include <float.h>
           #include <math.h>
          
           #ifndef ASSERT
           #define ASSERT(  exp ) {}
           #endif
           #define ICE_COMPILE_TIME_ASSERT(  exp ) extern char ICE_Dummy[ (  exp ) ? 1 : -1 ]
          
      28   extern void Opcode_Log (  const char* msg,   ... );
      29   extern bool Opcode_Err (  const char* msg,   ... );
          
           #define OpcodeLog Opcode_Log
           #define SetIceError Opcode_Err
          // #define Log {}
          // #define SetIceError(  a,  b ) false
          
           #define EC_OUTOFMEMORY "Out of memory"
          
           #include "Ice/IcePreprocessor.h"
          
           #include "Ice/IceTypes.h"
           #include "Ice/IceFPU.h"
           #include "Ice/IceMemoryMacros.h"
          
           namespace IceCore
           {
           #include "Ice/IceUtils.h"
           #include "Ice/IceContainer.h"
           #include "Ice/IcePairs.h"
           #include "Ice/IceRevisitedRadix.h"
           #include "Ice/IceRandom.h"
           }
           using namespace IceCore;
          
           namespace IceMaths
           {
           #include "Ice/IceAxes.h"
           #include "Ice/IcePoint.h"
           #include "Ice/IceHPoint.h"
           #include "Ice/IceMatrix3x3.h"
           #include "Ice/IceMatrix4x4.h"
           #include "Ice/IcePlane.h"
           #include "Ice/IceRay.h"
           #include "Ice/IceIndexedTriangle.h"
           #include "Ice/IceTriangle.h"
           #include "Ice/IceTriList.h"
           #include "Ice/IceAABB.h"
           #include "Ice/IceOBB.h"
           #include "Ice/IceBoundingSphere.h"
           #include "Ice/IceSegment.h"
           #include "Ice/IceLSS.h"
           }
           //using namespace IceMaths;

./components/ogre/ogreopcode/include/Opcode/OPC_LSSAABBOverlap.h

       1  
          // Following code from Magic-Software (  http://www.magic-software.com/ )
          // A bit modified for Opcode
          
       5  inline_ float OPC_PointAABBSqrDist(  const IceMaths::Point& point,   const IceMaths::Point& center,   const IceMaths::Point& extents )
          {
           // Compute coordinates of point in box coordinate system
           IceMaths::Point Closest = point - center;
          
           float SqrDistance = 0.0f;
          
           if(  Closest.x < -extents.x )
           {
           float Delta = Closest.x + extents.x;
           SqrDistance += Delta*Delta;
           }
           else if(  Closest.x > extents.x )
           {
           float Delta = Closest.x - extents.x;
           SqrDistance += Delta*Delta;
           }
          
           if(  Closest.y < -extents.y )
           {
           float Delta = Closest.y + extents.y;
           SqrDistance += Delta*Delta;
           }
           else if(  Closest.y > extents.y )
           {
           float Delta = Closest.y - extents.y;
           SqrDistance += Delta*Delta;
           }
          
           if(  Closest.z < -extents.z )
           {
           float Delta = Closest.z + extents.z;
           SqrDistance += Delta*Delta;
           }
           else if(  Closest.z > extents.z )
           {
           float Delta = Closest.z - extents.z;
           SqrDistance += Delta*Delta;
           }
           return SqrDistance;
          }
          
      47  static void Face(  int i0,   int i1,   int i2,   IceMaths::Point& rkPnt,   const IceMaths::Point& rkDir,   const IceMaths::Point& extents,   const IceMaths::Point& rkPmE,   float* pfLParam,   float& rfSqrDistance )
          {
           IceMaths::Point kPpE;
           float fLSqr,   fInv,   fTmp,   fParam,   fT,   fDelta;
          
           kPpE[i1] = rkPnt[i1] + extents[i1];
           kPpE[i2] = rkPnt[i2] + extents[i2];
           if(  rkDir[i0]*kPpE[i1] >= rkDir[i1]*rkPmE[i0] )
           {
           if(  rkDir[i0]*kPpE[i2] >= rkDir[i2]*rkPmE[i0] )
           {
           // v[i1] >= -e[i1],   v[i2] >= -e[i2] (  distance = 0 )
           if(  pfLParam )
           {
           rkPnt[i0] = extents[i0];
           fInv = 1.0f/rkDir[i0];
           rkPnt[i1] -= rkDir[i1]*rkPmE[i0]*fInv;
           rkPnt[i2] -= rkDir[i2]*rkPmE[i0]*fInv;
           *pfLParam = -rkPmE[i0]*fInv;
           }
           }
           else
           {
           // v[i1] >= -e[i1],   v[i2] < -e[i2]
           fLSqr = rkDir[i0]*rkDir[i0] + rkDir[i2]*rkDir[i2];
           fTmp = fLSqr*kPpE[i1] - rkDir[i1]*(  rkDir[i0]*rkPmE[i0] + rkDir[i2]*kPpE[i2] );
           if(  fTmp <= 2.0f*fLSqr*extents[i1] )
           {
           fT = fTmp/fLSqr;
           fLSqr += rkDir[i1]*rkDir[i1];
           fTmp = kPpE[i1] - fT;
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*fTmp + rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + fTmp*fTmp + kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if(  pfLParam )
           {
           *pfLParam = fParam;
           rkPnt[i0] = extents[i0];
           rkPnt[i1] = fT - extents[i1];
           rkPnt[i2] = -extents[i2];
           }
           }
           else
           {
           fLSqr += rkDir[i1]*rkDir[i1];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*rkPmE[i1] + rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + rkPmE[i1]*rkPmE[i1] + kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if(  pfLParam )
           {
           *pfLParam = fParam;
           rkPnt[i0] = extents[i0];
           rkPnt[i1] = extents[i1];
           rkPnt[i2] = -extents[i2];
           }
           }
           }
           }
           else
           {
           if (   rkDir[i0]*kPpE[i2] >= rkDir[i2]*rkPmE[i0]  )
           {
           // v[i1] < -e[i1],   v[i2] >= -e[i2]
           fLSqr = rkDir[i0]*rkDir[i0] + rkDir[i1]*rkDir[i1];
           fTmp = fLSqr*kPpE[i2] - rkDir[i2]*(  rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] );
           if(  fTmp <= 2.0f*fLSqr*extents[i2] )
           {
           fT = fTmp/fLSqr;
           fLSqr += rkDir[i2]*rkDir[i2];
           fTmp = kPpE[i2] - fT;
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] + rkDir[i2]*fTmp;
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] + fTmp*fTmp + fDelta*fParam;
          
           if(  pfLParam )
           {
           *pfLParam = fParam;
           rkPnt[i0] = extents[i0];
           rkPnt[i1] = -extents[i1];
           rkPnt[i2] = fT - extents[i2];
           }
           }
           else
           {
           fLSqr += rkDir[i2]*rkDir[i2];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] + rkDir[i2]*rkPmE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] + rkPmE[i2]*rkPmE[i2] + fDelta*fParam;
          
           if(  pfLParam )
           {
           *pfLParam = fParam;
           rkPnt[i0] = extents[i0];
           rkPnt[i1] = -extents[i1];
           rkPnt[i2] = extents[i2];
           }
           }
           }
           else
           {
           // v[i1] < -e[i1],   v[i2] < -e[i2]
           fLSqr = rkDir[i0]*rkDir[i0]+rkDir[i2]*rkDir[i2];
           fTmp = fLSqr*kPpE[i1] - rkDir[i1]*(  rkDir[i0]*rkPmE[i0] + rkDir[i2]*kPpE[i2] );
           if(  fTmp >= 0.0f )
           {
           // v[i1]-edge is closest
           if (   fTmp <= 2.0f*fLSqr*extents[i1]  )
           {
           fT = fTmp/fLSqr;
           fLSqr += rkDir[i1]*rkDir[i1];
           fTmp = kPpE[i1] - fT;
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*fTmp + rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + fTmp*fTmp + kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if(  pfLParam )
           {
           *pfLParam = fParam;
           rkPnt[i0] = extents[i0];
           rkPnt[i1] = fT - extents[i1];
           rkPnt[i2] = -extents[i2];
           }
           }
           else
           {
           fLSqr += rkDir[i1]*rkDir[i1];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*rkPmE[i1] + rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + rkPmE[i1]*rkPmE[i1] + kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if(  pfLParam )
           {
           *pfLParam = fParam;
           rkPnt[i0] = extents[i0];
           rkPnt[i1] = extents[i1];
           rkPnt[i2] = -extents[i2];
           }
           }
           return;
           }
          
           fLSqr = rkDir[i0]*rkDir[i0] + rkDir[i1]*rkDir[i1];
           fTmp = fLSqr*kPpE[i2] - rkDir[i2]*(  rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] );
           if(  fTmp >= 0.0f )
           {
           // v[i2]-edge is closest
           if(  fTmp <= 2.0f*fLSqr*extents[i2] )
           {
           fT = fTmp/fLSqr;
           fLSqr += rkDir[i2]*rkDir[i2];
           fTmp = kPpE[i2] - fT;
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] + rkDir[i2]*fTmp;
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] + fTmp*fTmp + fDelta*fParam;
          
           if(  pfLParam )
           {
           *pfLParam = fParam;
           rkPnt[i0] = extents[i0];
           rkPnt[i1] = -extents[i1];
           rkPnt[i2] = fT - extents[i2];
           }
           }
           else
           {
           fLSqr += rkDir[i2]*rkDir[i2];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] + rkDir[i2]*rkPmE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] + rkPmE[i2]*rkPmE[i2] + fDelta*fParam;
          
           if(  pfLParam )
           {
           *pfLParam = fParam;
           rkPnt[i0] = extents[i0];
           rkPnt[i1] = -extents[i1];
           rkPnt[i2] = extents[i2];
           }
           }
           return;
           }
          
           // (  v[i1],  v[i2] )-corner is closest
           fLSqr += rkDir[i2]*rkDir[i2];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] + rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] + kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if(  pfLParam )
           {
           *pfLParam = fParam;
           rkPnt[i0] = extents[i0];
           rkPnt[i1] = -extents[i1];
           rkPnt[i2] = -extents[i2];
           }
           }
           }
          }
          
     247  static void CaseNoZeros(  IceMaths::Point& rkPnt,   const IceMaths::Point& rkDir,   const IceMaths::Point& extents,   float* pfLParam,   float& rfSqrDistance )
          {
           IceMaths::Point kPmE(  rkPnt.x - extents.x,   rkPnt.y - extents.y,   rkPnt.z - extents.z );
          
           float fProdDxPy,   fProdDyPx,   fProdDzPx,   fProdDxPz,   fProdDzPy,   fProdDyPz;
          
           fProdDxPy = rkDir.x*kPmE.y;
           fProdDyPx = rkDir.y*kPmE.x;
           if(  fProdDyPx >= fProdDxPy )
           {
           fProdDzPx = rkDir.z*kPmE.x;
           fProdDxPz = rkDir.x*kPmE.z;
           if(  fProdDzPx >= fProdDxPz )
           {
           // line intersects x = e0
           Face(  0,   1,   2,   rkPnt,   rkDir,   extents,   kPmE,   pfLParam,   rfSqrDistance );
           }
           else
           {
           // line intersects z = e2
           Face(  2,   0,   1,   rkPnt,   rkDir,   extents,   kPmE,   pfLParam,   rfSqrDistance );
           }
           }
           else
           {
           fProdDzPy = rkDir.z*kPmE.y;
           fProdDyPz = rkDir.y*kPmE.z;
           if(  fProdDzPy >= fProdDyPz )
           {
           // line intersects y = e1
           Face(  1,   2,   0,   rkPnt,   rkDir,   extents,   kPmE,   pfLParam,   rfSqrDistance );
           }
           else
           {
           // line intersects z = e2
           Face(  2,   0,   1,   rkPnt,   rkDir,   extents,   kPmE,   pfLParam,   rfSqrDistance );
           }
           }
          }
          
     287  static void Case0(  int i0,   int i1,   int i2,   IceMaths::Point& rkPnt,   const IceMaths::Point& rkDir,   const IceMaths::Point& extents,   float* pfLParam,   float& rfSqrDistance )
          {
           float fPmE0 = rkPnt[i0] - extents[i0];
           float fPmE1 = rkPnt[i1] - extents[i1];
           float fProd0 = rkDir[i1]*fPmE0;
           float fProd1 = rkDir[i0]*fPmE1;
           float fDelta,   fInvLSqr,   fInv;
          
           if(  fProd0 >= fProd1 )
           {
           // line intersects P[i0] = e[i0]
           rkPnt[i0] = extents[i0];
          
           float fPpE1 = rkPnt[i1] + extents[i1];
           fDelta = fProd0 - rkDir[i0]*fPpE1;
           if(  fDelta >= 0.0f )
           {
           fInvLSqr = 1.0f/(  rkDir[i0]*rkDir[i0] + rkDir[i1]*rkDir[i1] );
           rfSqrDistance += fDelta*fDelta*fInvLSqr;
           if(  pfLParam )
           {
           rkPnt[i1] = -extents[i1];
           *pfLParam = -(  rkDir[i0]*fPmE0+rkDir[i1]*fPpE1 )*fInvLSqr;
           }
           }
           else
           {
           if(  pfLParam )
           {
           fInv = 1.0f/rkDir[i0];
           rkPnt[i1] -= fProd0*fInv;
           *pfLParam = -fPmE0*fInv;
           }
           }
           }
           else
           {
           // line intersects P[i1] = e[i1]
           rkPnt[i1] = extents[i1];
          
           float fPpE0 = rkPnt[i0] + extents[i0];
           fDelta = fProd1 - rkDir[i1]*fPpE0;
           if(  fDelta >= 0.0f )
           {
           fInvLSqr = 1.0f/(  rkDir[i0]*rkDir[i0] + rkDir[i1]*rkDir[i1] );
           rfSqrDistance += fDelta*fDelta*fInvLSqr;
           if(  pfLParam )
           {
           rkPnt[i0] = -extents[i0];
           *pfLParam = -(  rkDir[i0]*fPpE0+rkDir[i1]*fPmE1 )*fInvLSqr;
           }
           }
           else
           {
           if(  pfLParam )
           {
           fInv = 1.0f/rkDir[i1];
           rkPnt[i0] -= fProd1*fInv;
           *pfLParam = -fPmE1*fInv;
           }
           }
           }
          
           if(  rkPnt[i2] < -extents[i2] )
           {
           fDelta = rkPnt[i2] + extents[i2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i2] = -extents[i2];
           }
           else if (   rkPnt[i2] > extents[i2]  )
           {
           fDelta = rkPnt[i2] - extents[i2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i2] = extents[i2];
           }
          }
          
     364  static void Case00(  int i0,   int i1,   int i2,   IceMaths::Point& rkPnt,   const IceMaths::Point& rkDir,   const IceMaths::Point& extents,   float* pfLParam,   float& rfSqrDistance )
          {
           float fDelta;
          
           if(  pfLParam )
           *pfLParam = (  extents[i0] - rkPnt[i0] )/rkDir[i0];
          
           rkPnt[i0] = extents[i0];
          
           if(  rkPnt[i1] < -extents[i1] )
           {
           fDelta = rkPnt[i1] + extents[i1];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i1] = -extents[i1];
           }
           else if(  rkPnt[i1] > extents[i1] )
           {
           fDelta = rkPnt[i1] - extents[i1];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i1] = extents[i1];
           }
          
           if(  rkPnt[i2] < -extents[i2] )
           {
           fDelta = rkPnt[i2] + extents[i2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i1] = -extents[i2];
           }
           else if(  rkPnt[i2] > extents[i2] )
           {
           fDelta = rkPnt[i2] - extents[i2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i2] = extents[i2];
           }
          }
          
     400  static void Case000(  IceMaths::Point& rkPnt,   const IceMaths::Point& extents,   float& rfSqrDistance )
          {
           float fDelta;
          
           if(  rkPnt.x < -extents.x )
           {
           fDelta = rkPnt.x + extents.x;
           rfSqrDistance += fDelta*fDelta;
           rkPnt.x = -extents.x;
           }
           else if(  rkPnt.x > extents.x )
           {
           fDelta = rkPnt.x - extents.x;
           rfSqrDistance += fDelta*fDelta;
           rkPnt.x = extents.x;
           }
          
           if(  rkPnt.y < -extents.y )
           {
           fDelta = rkPnt.y + extents.y;
           rfSqrDistance += fDelta*fDelta;
           rkPnt.y = -extents.y;
           }
           else if(  rkPnt.y > extents.y )
           {
           fDelta = rkPnt.y - extents.y;
           rfSqrDistance += fDelta*fDelta;
           rkPnt.y = extents.y;
           }
          
           if(  rkPnt.z < -extents.z )
           {
           fDelta = rkPnt.z + extents.z;
           rfSqrDistance += fDelta*fDelta;
           rkPnt.z = -extents.z;
           }
           else if(  rkPnt.z > extents.z )
           {
           fDelta = rkPnt.z - extents.z;
           rfSqrDistance += fDelta*fDelta;
           rkPnt.z = extents.z;
           }
          }
          
     444  static float SqrDistance(  const IceMaths::Ray& rkLine,   const IceMaths::Point& center,   const IceMaths::Point& extents,   float* pfLParam )
          {
           // compute coordinates of line in box coordinate system
           IceMaths::Point kDiff = rkLine.mOrig - center;
           IceMaths::Point kPnt = kDiff;
           IceMaths::Point kDir = rkLine.mDir;
          
           // Apply reflections so that direction vector has nonnegative components.
           bool bReflect[3];
           for(  int i=0;i<3;i++ )
           {
           if(  kDir[i]<0.0f )
           {
           kPnt[i] = -kPnt[i];
           kDir[i] = -kDir[i];
           bReflect[i] = true;
           }
           else
           {
           bReflect[i] = false;
           }
           }
          
           float fSqrDistance = 0.0f;
          
           if(  kDir.x>0.0f )
           {
           if(  kDir.y>0.0f )
           {
           if(  kDir.z>0.0f ) CaseNoZeros(  kPnt,   kDir,   extents,   pfLParam,   fSqrDistance ); // (  +,  +,  + )
           else Case0(  0,   1,   2,   kPnt,   kDir,   extents,   pfLParam,   fSqrDistance ); // (  +,  +,  0 )
           }
           else
           {
           if(  kDir.z>0.0f ) Case0(  0,   2,   1,   kPnt,   kDir,   extents,   pfLParam,   fSqrDistance ); // (  +,  0,  + )
           else Case00(  0,   1,   2,   kPnt,   kDir,   extents,   pfLParam,   fSqrDistance ); // (  +,  0,  0 )
           }
           }
           else
           {
           if(  kDir.y>0.0f )
           {
           if(  kDir.z>0.0f ) Case0(  1,   2,   0,   kPnt,   kDir,   extents,   pfLParam,   fSqrDistance ); // (  0,  +,  + )
           else Case00(  1,   0,   2,   kPnt,   kDir,   extents,   pfLParam,   fSqrDistance ); // (  0,  +,  0 )
           }
           else
           {
           if(  kDir.z>0.0f ) Case00(  2,   0,   1,   kPnt,   kDir,   extents,   pfLParam,   fSqrDistance ); // (  0,  0,  + )
           else
           {
           Case000(  kPnt,   extents,   fSqrDistance ); // (  0,  0,  0 )
           if(  pfLParam ) *pfLParam = 0.0f;
           }
           }
           }
           return fSqrDistance;
          }
          
     502  inline_ float OPC_SegmentOBBSqrDist(  const IceMaths::Segment& segment,   const IceMaths::Point& c0,   const IceMaths::Point& e0 )
          {
           float fLP;
           float fSqrDistance = SqrDistance(  IceMaths::Ray(  segment.GetOrigin(   ),   segment.ComputeDirection(   ) ),   c0,   e0,   &fLP );
           if(  fLP>=0.0f )
           {
           if(  fLP<=1.0f ) return fSqrDistance;
           else return OPC_PointAABBSqrDist(  segment.mP1,   c0,   e0 );
           }
           else return OPC_PointAABBSqrDist(  segment.mP0,   c0,   e0 );
          }
          
     514  inline_ BOOL LSSCollider::LSSAABBOverlap(  const IceMaths::Point& center_,   const IceMaths::Point& extents_ )
          {
           // applies the model's local scale
           const IceMaths::Point& center = center_ * mLocalScale ;
           const IceMaths::Point& extents = extents_* mLocalScale;
           // Stats
           mNbVolumeBVTests++;
          
           float s2 = OPC_SegmentOBBSqrDist(  mSeg,   center,   extents );
           if(  s2<mRadius2 ) return TRUE;
          
           return FALSE;
          }

./components/ogre/ogreopcode/include/Opcode/OPC_LSSCollider.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for an LSS collider.
           * \file OPC_LSSCollider.h
           * \author Pierre Terdiman
           * \date December,   28,   2002
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_LSSCOLLIDER_H__
          #define __OPC_LSSCOLLIDER_H__
          
           struct LSSCache : VolumeCache
           {
           LSSCache(   )
           {
           Previous.mP0 = IceMaths::Point(  0.0f,   0.0f,   0.0f );
           Previous.mP1 = IceMaths::Point(  0.0f,   0.0f,   0.0f );
           Previous.mRadius = 0.0f;
           FatCoeff = 1.1f;
           }
          
           // Cached faces signature
           IceMaths::LSS Previous; //!< LSS used when performing the query resulting in cached faces
           // User settings
           float FatCoeff; //!< mRadius2 multiplier used to create a fat LSS
           };
          
      44   class LSSCollider : public VolumeCollider
           {
           public:
           // Constructor / Destructor
      48   LSSCollider(   );
      49   virtual ~LSSCollider(   );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Generic collision query for generic OPCODE models. After the call,   access the results:
           * - with GetContactStatus(   )
           * - with GetNbTouchedPrimitives(   )
           * - with GetTouchedPrimitives(   )
           *
           * \param cache [in/out] an lss cache
           * \param lss [in] collision lss in local space
           * \param model [in] Opcode model to collide with
           * \param worldl [in] lss world matrix,   or null
           * \param worldm [in] model's world matrix,   or null
           * \return true if success
           * \warning SCALE NOT SUPPORTED IN THE LSS MATRIX. The matrix must contain rotation & translation parts only.
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      67   bool Collide(  LSSCache& cache,   const IceMaths::LSS& lss,   const Model& model,   const IceMaths::Matrix4x4* worldl=null,   const IceMaths::Matrix4x4* worldm=null );
           //
      69   bool Collide(  LSSCache& cache,   const IceMaths::LSS& lss,   const AABBTree* tree );
           protected:
           // LSS in model space
      72   IceMaths::Segment mSeg; //!< Segment
           float mRadius2; //!< LSS radius squared
           // Internal methods
      75   void _Collide(  const AABBCollisionNode* node );
      76   void _Collide(  const AABBNoLeafNode* node );
      77   void _Collide(  const AABBQuantizedNode* node );
      78   void _Collide(  const AABBQuantizedNoLeafNode* node );
      79   void _Collide(  const AABBTreeNode* node );
      80   void _CollideNoPrimitiveTest(  const AABBCollisionNode* node );
      81   void _CollideNoPrimitiveTest(  const AABBNoLeafNode* node );
      82   void _CollideNoPrimitiveTest(  const AABBQuantizedNode* node );
      83   void _CollideNoPrimitiveTest(  const AABBQuantizedNoLeafNode* node );
           // Overlap tests
           inline_ BOOL LSSContainsBox(  const IceMaths::Point& bc,   const IceMaths::Point& be );
           inline_ BOOL LSSAABBOverlap(  const IceMaths::Point& center,   const IceMaths::Point& extents );
           inline_ BOOL LSSTriOverlap(  const IceMaths::Point& vert0,   const IceMaths::Point& vert1,   const IceMaths::Point& vert2 );
           // Init methods
           BOOL InitQuery(  LSSCache& cache,   const IceMaths::LSS& lss,   const IceMaths::Matrix4x4* worldl=null,   const IceMaths::Matrix4x4* worldm=null );
           };
          
      92   class HybridLSSCollider : public LSSCollider
           {
           public:
           // Constructor / Destructor
      96   HybridLSSCollider(   );
      97   virtual ~HybridLSSCollider(   );
          
      99   bool Collide(  LSSCache& cache,   const IceMaths::LSS& lss,   const HybridModel& model,   const IceMaths::Matrix4x4* worldl=null,   const IceMaths::Matrix4x4* worldm=null );
           protected:
     101   IceCore::Container mTouchedBoxes;
           };
          
          #endif // __OPC_LSSCOLLIDER_H__

./components/ogre/ogreopcode/include/Opcode/OPC_LSSTriOverlap.h

          // Following code from Magic-Software (  http://www.magic-software.com/ )
          // A bit modified for Opcode
          
          static const float gs_fTolerance = 1e-05f;
          
       6  static float OPC_PointTriangleSqrDist(  const IceMaths::Point& point,   const IceMaths::Point& p0,   const IceMaths::Point& p1,   const IceMaths::Point& p2 )
          {
           // Hook
           IceMaths::Point TriEdge0 = p1 - p0;
           IceMaths::Point TriEdge1 = p2 - p0;
          
           IceMaths::Point kDiff = p0 - point;
           float fA00 = TriEdge0.SquareMagnitude(   );
           float fA01 = TriEdge0 | TriEdge1;
           float fA11 = TriEdge1.SquareMagnitude(   );
           float fB0 = kDiff | TriEdge0;
           float fB1 = kDiff | TriEdge1;
           float fC = kDiff.SquareMagnitude(   );
           float fDet = fabsf(  fA00*fA11 - fA01*fA01 );
           float fS = fA01*fB1-fA11*fB0;
           float fT = fA01*fB0-fA00*fB1;
           float fSqrDist;
          
           if(  fS + fT <= fDet )
           {
           if(  fS < 0.0f )
           {
           if(  fT < 0.0f ) // region 4
           {
           if(  fB0 < 0.0f )
           {
           if(  -fB0 >= fA00 ) fSqrDist = fA00+2.0f*fB0+fC;
           else fSqrDist = fB0*(  -fB0/fA00 )+fC;
           }
           else
           {
           if(  fB1 >= 0.0f ) fSqrDist = fC;
           else if(  -fB1 >= fA11 ) fSqrDist = fA11+2.0f*fB1+fC;
           else fSqrDist = fB1*(  -fB1/fA11 )+fC;
           }
           }
           else // region 3
           {
           if(  fB1 >= 0.0f ) fSqrDist = fC;
           else if(  -fB1 >= fA11 ) fSqrDist = fA11+2.0f*fB1+fC;
           else fSqrDist = fB1*(  -fB1/fA11 )+fC;
           }
           }
           else if(  fT < 0.0f ) // region 5
           {
           if(  fB0 >= 0.0f ) fSqrDist = fC;
           else if(  -fB0 >= fA00 ) fSqrDist = fA00+2.0f*fB0+fC;
           else fSqrDist = fB0*(  -fB0/fA00 )+fC;
           }
           else // region 0
           {
           // minimum at interior point
           if(  fDet==0.0f )
           {
           fSqrDist = MAX_FLOAT;
           }
           else
           {
           float fInvDet = 1.0f/fDet;
           fS *= fInvDet;
           fT *= fInvDet;
           fSqrDist = fS*(  fA00*fS+fA01*fT+2.0f*fB0 ) + fT*(  fA01*fS+fA11*fT+2.0f*fB1 )+fC;
           }
           }
           }
           else
           {
           float fTmp0,   fTmp1,   fNumer,   fDenom;
          
           if(  fS < 0.0f ) // region 2
           {
           fTmp0 = fA01 + fB0;
           fTmp1 = fA11 + fB1;
           if(  fTmp1 > fTmp0 )
           {
           fNumer = fTmp1 - fTmp0;
           fDenom = fA00-2.0f*fA01+fA11;
           if(  fNumer >= fDenom )
           {
           fSqrDist = fA00+2.0f*fB0+fC;
           }
           else
           {
           fS = fNumer/fDenom;
           fT = 1.0f - fS;
           fSqrDist = fS*(  fA00*fS+fA01*fT+2.0f*fB0 ) + fT*(  fA01*fS+fA11*fT+2.0f*fB1 )+fC;
           }
           }
           else
           {
           if(  fTmp1 <= 0.0f ) fSqrDist = fA11+2.0f*fB1+fC;
           else if(  fB1 >= 0.0f ) fSqrDist = fC;
           else fSqrDist = fB1*(  -fB1/fA11 )+fC;
           }
           }
           else if(  fT < 0.0f ) // region 6
           {
           fTmp0 = fA01 + fB1;
           fTmp1 = fA00 + fB0;
           if(  fTmp1 > fTmp0 )
           {
           fNumer = fTmp1 - fTmp0;
           fDenom = fA00-2.0f*fA01+fA11;
           if(  fNumer >= fDenom )
           {
           fSqrDist = fA11+2.0f*fB1+fC;
           }
           else
           {
           fT = fNumer/fDenom;
           fS = 1.0f - fT;
           fSqrDist = fS*(  fA00*fS+fA01*fT+2.0f*fB0 ) + fT*(  fA01*fS+fA11*fT+2.0f*fB1 )+fC;
           }
           }
           else
           {
           if(  fTmp1 <= 0.0f ) fSqrDist = fA00+2.0f*fB0+fC;
           else if(  fB0 >= 0.0f ) fSqrDist = fC;
           else fSqrDist = fB0*(  -fB0/fA00 )+fC;
           }
           }
           else // region 1
           {
           fNumer = fA11 + fB1 - fA01 - fB0;
           if(  fNumer <= 0.0f )
           {
           fSqrDist = fA11+2.0f*fB1+fC;
           }
           else
           {
           fDenom = fA00-2.0f*fA01+fA11;
           if(  fNumer >= fDenom )
           {
           fSqrDist = fA00+2.0f*fB0+fC;
           }
           else
           {
           fS = fNumer/fDenom;
           fT = 1.0f - fS;
           fSqrDist = fS*(  fA00*fS+fA01*fT+2.0f*fB0 ) + fT*(  fA01*fS+fA11*fT+2.0f*fB1 )+fC;
           }
           }
           }
           }
           return fabsf(  fSqrDist );
          }
          
     153  static float OPC_SegmentSegmentSqrDist(  const IceMaths::Segment& rkSeg0,   const IceMaths::Segment& rkSeg1 )
          {
           // Hook
           IceMaths::Point rkSeg0Direction = rkSeg0.ComputeDirection(   );
           IceMaths::Point rkSeg1Direction = rkSeg1.ComputeDirection(   );
          
           IceMaths::Point kDiff = rkSeg0.mP0 - rkSeg1.mP0;
           float fA00 = rkSeg0Direction.SquareMagnitude(   );
           float fA01 = -rkSeg0Direction.Dot(  rkSeg1Direction );
           float fA11 = rkSeg1Direction.SquareMagnitude(   );
           float fB0 = kDiff.Dot(  rkSeg0Direction );
           float fC = kDiff.SquareMagnitude(   );
           float fDet = fabsf(  fA00*fA11-fA01*fA01 );
          
           float fB1,   fS,   fT,   fSqrDist,   fTmp;
          
           if(  fDet>=gs_fTolerance )
           {
           // line segments are not parallel
           fB1 = -kDiff.Dot(  rkSeg1Direction );
           fS = fA01*fB1-fA11*fB0;
           fT = fA01*fB0-fA00*fB1;
          
           if(  fS >= 0.0f )
           {
           if(  fS <= fDet )
           {
           if(  fT >= 0.0f )
           {
           if(  fT <= fDet ) // region 0 (  interior )
           {
           // minimum at two interior points of 3D lines
           float fInvDet = 1.0f/fDet;
           fS *= fInvDet;
           fT *= fInvDet;
           fSqrDist = fS*(  fA00*fS+fA01*fT+2.0f*fB0 ) + fT*(  fA01*fS+fA11*fT+2.0f*fB1 )+fC;
           }
           else // region 3 (  side )
           {
           fTmp = fA01+fB0;
           if(  fTmp>=0.0f ) fSqrDist = fA11+2.0f*fB1+fC;
           else if(  -fTmp>=fA00 ) fSqrDist = fA00+fA11+fC+2.0f*(  fB1+fTmp );
           else fSqrDist = fTmp*(  -fTmp/fA00 )+fA11+2.0f*fB1+fC;
           }
           }
           else // region 7 (  side )
           {
           if(  fB0>=0.0f ) fSqrDist = fC;
           else if(  -fB0>=fA00 ) fSqrDist = fA00+2.0f*fB0+fC;
           else fSqrDist = fB0*(  -fB0/fA00 )+fC;
           }
           }
           else
           {
           if (   fT >= 0.0  )
           {
           if (   fT <= fDet  ) // region 1 (  side )
           {
           fTmp = fA01+fB1;
           if(  fTmp>=0.0f ) fSqrDist = fA00+2.0f*fB0+fC;
           else if(  -fTmp>=fA11 ) fSqrDist = fA00+fA11+fC+2.0f*(  fB0+fTmp );
           else fSqrDist = fTmp*(  -fTmp/fA11 )+fA00+2.0f*fB0+fC;
           }
           else // region 2 (  corner )
           {
           fTmp = fA01+fB0;
           if (   -fTmp <= fA00  )
           {
           if(  fTmp>=0.0f ) fSqrDist = fA11+2.0f*fB1+fC;
           else fSqrDist = fTmp*(  -fTmp/fA00 )+fA11+2.0f*fB1+fC;
           }
           else
           {
           fTmp = fA01+fB1;
           if(  fTmp>=0.0f ) fSqrDist = fA00+2.0f*fB0+fC;
           else if(  -fTmp>=fA11 ) fSqrDist = fA00+fA11+fC+2.0f*(  fB0+fTmp );
           else fSqrDist = fTmp*(  -fTmp/fA11 )+fA00+2.0f*fB0+fC;
           }
           }
           }
           else // region 8 (  corner )
           {
           if (   -fB0 < fA00  )
           {
           if(  fB0>=0.0f ) fSqrDist = fC;
           else fSqrDist = fB0*(  -fB0/fA00 )+fC;
           }
           else
           {
           fTmp = fA01+fB1;
           if(  fTmp>=0.0f ) fSqrDist = fA00+2.0f*fB0+fC;
           else if(  -fTmp>=fA11 ) fSqrDist = fA00+fA11+fC+2.0f*(  fB0+fTmp );
           else fSqrDist = fTmp*(  -fTmp/fA11 )+fA00+2.0f*fB0+fC;
           }
           }
           }
           }
           else
           {
           if (   fT >= 0.0f  )
           {
           if (   fT <= fDet  ) // region 5 (  side )
           {
           if(  fB1>=0.0f ) fSqrDist = fC;
           else if(  -fB1>=fA11 ) fSqrDist = fA11+2.0f*fB1+fC;
           else fSqrDist = fB1*(  -fB1/fA11 )+fC;
           }
           else // region 4 (  corner )
           {
           fTmp = fA01+fB0;
           if (   fTmp < 0.0f  )
           {
           if(  -fTmp>=fA00 ) fSqrDist = fA00+fA11+fC+2.0f*(  fB1+fTmp );
           else fSqrDist = fTmp*(  -fTmp/fA00 )+fA11+2.0f*fB1+fC;
           }
           else
           {
           if(  fB1>=0.0f ) fSqrDist = fC;
           else if(  -fB1>=fA11 ) fSqrDist = fA11+2.0f*fB1+fC;
           else fSqrDist = fB1*(  -fB1/fA11 )+fC;
           }
           }
           }
           else // region 6 (  corner )
           {
           if (   fB0 < 0.0f  )
           {
           if(  -fB0>=fA00 ) fSqrDist = fA00+2.0f*fB0+fC;
           else fSqrDist = fB0*(  -fB0/fA00 )+fC;
           }
           else
           {
           if(  fB1>=0.0f ) fSqrDist = fC;
           else if(  -fB1>=fA11 ) fSqrDist = fA11+2.0f*fB1+fC;
           else fSqrDist = fB1*(  -fB1/fA11 )+fC;
           }
           }
           }
           }
           else
           {
           // line segments are parallel
           if (   fA01 > 0.0f  )
           {
           // direction vectors form an obtuse angle
           if (   fB0 >= 0.0f  )
           {
           fSqrDist = fC;
           }
           else if (   -fB0 <= fA00  )
           {
           fSqrDist = fB0*(  -fB0/fA00 )+fC;
           }
           else
           {
           fB1 = -kDiff.Dot(  rkSeg1Direction );
           fTmp = fA00+fB0;
           if (   -fTmp >= fA01  )
           {
           fSqrDist = fA00+fA11+fC+2.0f*(  fA01+fB0+fB1 );
           }
           else
           {
           fT = -fTmp/fA01;
           fSqrDist = fA00+2.0f*fB0+fC+fT*(  fA11*fT+2.0f*(  fA01+fB1 ) );
           }
           }
           }
           else
           {
           // direction vectors form an acute angle
           if (   -fB0 >= fA00  )
           {
           fSqrDist = fA00+2.0f*fB0+fC;
           }
           else if (   fB0 <= 0.0f  )
           {
           fSqrDist = fB0*(  -fB0/fA00 )+fC;
           }
           else
           {
           fB1 = -kDiff.Dot(  rkSeg1Direction );
           if (   fB0 >= -fA01  )
           {
           fSqrDist = fA11+2.0f*fB1+fC;
           }
           else
           {
           fT = -fB0/fA01;
           fSqrDist = fC+fT*(  2.0f*fB1+fA11*fT );
           }
           }
           }
           }
           return fabsf(  fSqrDist );
          }
          
     350  inline_ float OPC_SegmentRaySqrDist(  const IceMaths::Segment& rkSeg0,   const IceMaths::Ray& rkSeg1 )
          {
           return OPC_SegmentSegmentSqrDist(  rkSeg0,   IceMaths::Segment(  rkSeg1.mOrig,   rkSeg1.mOrig + rkSeg1.mDir ) );
          }
          
     355  static float OPC_SegmentTriangleSqrDist(  const IceMaths::Segment& segment,   const IceMaths::Point& p0,   const IceMaths::Point& p1,   const IceMaths::Point& p2 )
          {
           // Hook
           const IceMaths::Point TriEdge0 = p1 - p0;
           const IceMaths::Point TriEdge1 = p2 - p0;
          
           const IceMaths::Point& rkSegOrigin = segment.GetOrigin(   );
           IceMaths::Point rkSegDirection = segment.ComputeDirection(   );
          
           IceMaths::Point kDiff = p0 - rkSegOrigin;
           float fA00 = rkSegDirection.SquareMagnitude(   );
           float fA01 = -rkSegDirection.Dot(  TriEdge0 );
           float fA02 = -rkSegDirection.Dot(  TriEdge1 );
           float fA11 = TriEdge0.SquareMagnitude(   );
           float fA12 = TriEdge0.Dot(  TriEdge1 );
           float fA22 = TriEdge1.Dot(  TriEdge1 );
           float fB0 = -kDiff.Dot(  rkSegDirection );
           float fB1 = kDiff.Dot(  TriEdge0 );
           float fB2 = kDiff.Dot(  TriEdge1 );
           float fCof00 = fA11*fA22-fA12*fA12;
           float fCof01 = fA02*fA12-fA01*fA22;
           float fCof02 = fA01*fA12-fA02*fA11;
           float fDet = fA00*fCof00+fA01*fCof01+fA02*fCof02;
          
           IceMaths::Ray kTriSeg;
           IceMaths::Point kPt;
           float fSqrDist,   fSqrDist0;
          
           if(  fabsf(  fDet )>=gs_fTolerance )
           {
           float fCof11 = fA00*fA22-fA02*fA02;
           float fCof12 = fA02*fA01-fA00*fA12;
           float fCof22 = fA00*fA11-fA01*fA01;
           float fInvDet = 1.0f/fDet;
           float fRhs0 = -fB0*fInvDet;
           float fRhs1 = -fB1*fInvDet;
           float fRhs2 = -fB2*fInvDet;
          
           float fR = fCof00*fRhs0+fCof01*fRhs1+fCof02*fRhs2;
           float fS = fCof01*fRhs0+fCof11*fRhs1+fCof12*fRhs2;
           float fT = fCof02*fRhs0+fCof12*fRhs1+fCof22*fRhs2;
          
           if (   fR < 0.0f  )
           {
           if (   fS+fT <= 1.0f  )
           {
           if (   fS < 0.0f  )
           {
           if (   fT < 0.0f  ) // region 4m
           {
           // min on face s=0 or t=0 or r=0
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge1;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           fSqrDist0 = OPC_PointTriangleSqrDist(  rkSegOrigin,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else // region 3m
           {
           // min on face s=0 or r=0
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge1;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           fSqrDist0 = OPC_PointTriangleSqrDist(  rkSegOrigin,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           }
           else if (   fT < 0.0f  ) // region 5m
           {
           // min on face t=0 or r=0
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           fSqrDist0 = OPC_PointTriangleSqrDist(  rkSegOrigin,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else // region 0m
           {
           // min on face r=0
           fSqrDist = OPC_PointTriangleSqrDist(  rkSegOrigin,   p0,   p1,   p2 );
           }
           }
           else
           {
           if (   fS < 0.0f  ) // region 2m
           {
           // min on face s=0 or s+t=1 or r=0
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge1;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1-TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           fSqrDist0 = OPC_PointTriangleSqrDist(  rkSegOrigin,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else if (   fT < 0.0f  ) // region 6m
           {
           // min on face t=0 or s+t=1 or r=0
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1-TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           fSqrDist0 = OPC_PointTriangleSqrDist(  rkSegOrigin,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else // region 1m
           {
           // min on face s+t=1 or r=0
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1-TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           fSqrDist0 = OPC_PointTriangleSqrDist(  rkSegOrigin,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           }
           }
           else if (   fR <= 1.0f  )
           {
           if (   fS+fT <= 1.0f  )
           {
           if (   fS < 0.0f  )
           {
           if (   fT < 0.0f  ) // region 4
           {
           // min on face s=0 or t=0
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge1;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else // region 3
           {
           // min on face s=0
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge1;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           }
           }
           else if (   fT < 0.0f  ) // region 5
           {
           // min on face t=0
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           }
           else // region 0
           {
           // global minimum is interior,   done
           fSqrDist = fR*(  fA00*fR+fA01*fS+fA02*fT+2.0f*fB0 )
           +fS*(  fA01*fR+fA11*fS+fA12*fT+2.0f*fB1 )
           +fT*(  fA02*fR+fA12*fS+fA22*fT+2.0f*fB2 )
           +kDiff.SquareMagnitude(   );
           }
           }
           else
           {
           if (   fS < 0.0f  ) // region 2
           {
           // min on face s=0 or s+t=1
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge1;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1-TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else if (   fT < 0.0f  ) // region 6
           {
           // min on face t=0 or s+t=1
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1-TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else // region 1
           {
           // min on face s+t=1
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1-TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           }
           }
           }
           else // fR > 1
           {
           if (   fS+fT <= 1.0f  )
           {
           if (   fS < 0.0f  )
           {
           if (   fT < 0.0f  ) // region 4p
           {
           // min on face s=0 or t=0 or r=1
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge1;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           kPt = rkSegOrigin+rkSegDirection;
           fSqrDist0 = OPC_PointTriangleSqrDist(  kPt,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else // region 3p
           {
           // min on face s=0 or r=1
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge1;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kPt = rkSegOrigin+rkSegDirection;
           fSqrDist0 = OPC_PointTriangleSqrDist(  kPt,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           }
           else if (   fT < 0.0f  ) // region 5p
           {
           // min on face t=0 or r=1
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kPt = rkSegOrigin+rkSegDirection;
           fSqrDist0 = OPC_PointTriangleSqrDist(  kPt,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else // region 0p
           {
           // min face on r=1
           kPt = rkSegOrigin+rkSegDirection;
           fSqrDist = OPC_PointTriangleSqrDist(  kPt,   p0,   p1,   p2 );
           }
           }
           else
           {
           if (   fS < 0.0f  ) // region 2p
           {
           // min on face s=0 or s+t=1 or r=1
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge1;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1-TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           kPt = rkSegOrigin+rkSegDirection;
           fSqrDist0 = OPC_PointTriangleSqrDist(  kPt,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else if (   fT < 0.0f  ) // region 6p
           {
           // min on face t=0 or s+t=1 or r=1
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1-TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           kPt = rkSegOrigin+rkSegDirection;
           fSqrDist0 = OPC_PointTriangleSqrDist(  kPt,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           else // region 1p
           {
           // min on face s+t=1 or r=1
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1-TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           kPt = rkSegOrigin+rkSegDirection;
           fSqrDist0 = OPC_PointTriangleSqrDist(  kPt,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           }
           }
           }
           else
           {
           // segment and triangle are parallel
           kTriSeg.mOrig = p0;
           kTriSeg.mDir = TriEdge0;
           fSqrDist = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
          
           kTriSeg.mDir = TriEdge1;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
          
           kTriSeg.mOrig = p1;
           kTriSeg.mDir = TriEdge1 - TriEdge0;
           fSqrDist0 = OPC_SegmentRaySqrDist(  segment,   kTriSeg );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
          
           fSqrDist0 = OPC_PointTriangleSqrDist(  rkSegOrigin,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
          
           kPt = rkSegOrigin+rkSegDirection;
           fSqrDist0 = OPC_PointTriangleSqrDist(  kPt,   p0,   p1,   p2 );
           if(  fSqrDist0<fSqrDist ) fSqrDist = fSqrDist0;
           }
           return fabsf(  fSqrDist );
          }
          
          inline_ BOOL LSSCollider::LSSTriOverlap(  const IceMaths::Point& vert0_,   const IceMaths::Point& vert1_,   const IceMaths::Point& vert2_ )
          {
           // Applies the model's local scale
           const IceMaths::Point vert0 = vert0_*mLocalScale;
           const IceMaths::Point vert1 = vert1_*mLocalScale;
           const IceMaths::Point vert2 = vert2_*mLocalScale;
           // Stats
     678   mNbVolumePrimTests++;
          
           float s2 = OPC_SegmentTriangleSqrDist(  mSeg,   vert0,   vert1,   vert2 );
           if(  s2<mRadius2 ) return TRUE;
           return FALSE;
          }

./components/ogre/ogreopcode/include/Opcode/OPC_MeshInterface.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a mesh interface.
           * \file OPC_MeshInterface.h
           * \author Pierre Terdiman
           * \date November,   27,   2002
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_MESHINTERFACE_H__
          #define __OPC_MESHINTERFACE_H__
          
           struct VertexPointers
           {
           const IceMaths::Point* Vertex[3];
          
           bool BackfaceCulling(  const IceMaths::Point& source )
           {
           const IceMaths::Point& p0 = *Vertex[0];
           const IceMaths::Point& p1 = *Vertex[1];
           const IceMaths::Point& p2 = *Vertex[2];
          
           // Compute normal direction
           IceMaths::Point Normal = (  p2 - p1 )^(  p0 - p1 );
          
           // Backface culling
           return (  Normal | (  source - p0 ) ) >= 0.0f;
           }
           };
          
          #ifdef OPC_USE_CALLBACKS
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * User-callback,   called by OPCODE to request vertices from the app.
           * \param triangle_index [in] face index for which the system is requesting the vertices
           * \param triangle [out] triangle's vertices (  must be provided by the user )
           * \param user_data [in] user-defined data from SetCallback(   )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           typedef void (  *RequestCallback ) (  udword triangle_index,   VertexPointers& triangle,   void* user_data );
          #endif
          
           /// Enumerates mesh types
           enum MeshInterfaceType
           {
           /// Terrain mesh
           MESH_TERRAIN,  
           /// Simple,   triangle mesh
           MESH_TRIANGLE,  
           /// Triangle strip
           MESH_TRIANGLE_STRIP,  
           /// Triangle fan
           MESH_TRIANGLE_FAN
           };
          
      71   class MeshInterface
           {
           public:
           // Constructor / Destructor
      75   MeshInterface(   );
      76   ~MeshInterface(   );
           // Common settings
           inline_ MeshInterfaceType GetInterfaceType(   ) const { return mMIType; }
      79   inline_ udword GetNbTriangles(   ) const { return mNbTris; }
      80   inline_ udword GetNbVertices(   ) const { return mNbVerts; }
      81   inline_ udword GetNbRows(   ) const { return 1 + mNbTris/(  2*(  mNbVerts-1 ) ); }
      82   inline_ void SetNbTriangles(  udword nb ) { mNbTris = nb; }
      83   inline_ void SetNbVertices(  udword nb ) { mNbVerts = nb; }
      84   inline_ void SetInterfaceType(  MeshInterfaceType mit ) { mMIType = mit; }
          
          #ifdef OPC_USE_CALLBACKS
           // Callback settings
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Callback control: setups object callback. Must provide triangle-vertices for a given triangle index.
           * \param callback [in] user-defined callback
           * \param user_data [in] user-defined data
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      97   bool SetCallback(  RequestCallback callback,   void* user_data );
      98   inline_ void* GetUserData(   ) const { return mUserData; }
      99   inline_ RequestCallback GetCallback(   ) const { return mObjCallback; }
          #else
           // Pointers settings
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Pointers control: setups object pointers. Must provide access to faces and vertices for a given object.
           * \param tris [in] pointer to triangles
           * \param verts [in] pointer to vertices
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     111   bool SetPointers(  const IceMaths::IndexedTriangle* tris,   const IceMaths::Point* verts );
     112   inline_ const IceMaths::IndexedTriangle* GetTris(   ) const { return mTris; }
     113   inline_ const IceMaths::Point* GetVerts(   ) const { return mVerts; }
          
           #ifdef OPC_USE_STRIDE
           // Strides settings
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Strides control
           * \param tri_stride [in] size of a triangle in bytes. The first sizeof(  IndexedTriangle ) bytes are used to get vertex indices.
           * \param vertex_stride [in] size of a vertex in bytes. The first sizeof(  Point ) bytes are used to get vertex position.
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     126   bool SetStrides(  udword tri_stride=sizeof(  IceMaths::IndexedTriangle ),   udword vertex_stride=sizeof(  IceMaths::Point ) );
     127   inline_ udword GetTriStride(   ) const { return mTriStride; }
     128   inline_ udword GetVertexStride(   ) const { return mVertexStride; }
           #endif
          #endif
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Fetches a triangle given a triangle index.
           * \param vp [out] required triangle's vertex pointers
           * \param index [in] triangle index
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     139   inline_ void GetTriangle(  VertexPointers& vp,   udword index ) const
           {
          #ifdef OPC_USE_CALLBACKS
           // if we are using callbacks there is nothing to do!
           (  mObjCallback )(  index,   vp,   mUserData );
          #else
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           // START OF STRIDE CODE!
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           #ifdef OPC_USE_STRIDE
          
          
           #ifndef OPC_DOUBLE_PRECISION
           //! UTILITY macro for unpacking the K-th triangle vertex from a given index (  using strides )
           #define OPC_UNPACK_VERTEX(  K,   ind  ) \
           vp.Vertex[K] = (  const IceMaths::Point* )(  (  (  ubyte* )mVerts ) + (  ind ) * mVertexStride );
           #else
           //! UTILITY macro for shorter code when using double-precision vertices
           #define OPC_COPY_VERTEX(  K ) \
           VertexCache[K].x = (  float )v[0]; \
           VertexCache[K].x = (  float )v[1]; \
           VertexCache[K].x = (  float )v[2]; \
           vp.Vertex[K] = &VertexCache[K];
          
           //! UTILITY macro for unpacking the K-th triangle vertex from a given index (  using strides )
           #define OPC_UNPACK_VERTEX(  K,   ind  ) \
           { \
           const double* v = (  const double* )(  (  (  ubyte* )mVerts ) + (  ind ) * mVertexStride );
           OPC_COPY_VERTEX(  K )
           }
           #endif
          
           switch(   mMIType  )
           {
           case MESH_TRIANGLE:
           if(  mTris )
           {
           const IceMaths::IndexedTriangle* T = (  const IceMaths::IndexedTriangle* )(   (  (  ubyte* )mTris ) + index * mTriStride );
          
           OPC_UNPACK_VERTEX(  0,   T->mVRef[0]  )
           OPC_UNPACK_VERTEX(  1,   T->mVRef[1]  )
           OPC_UNPACK_VERTEX(  2,   T->mVRef[2]  )
          
           }else
           {
           // suppport for non-indexed meshes
           index *= 3;
          
           OPC_UNPACK_VERTEX(  0,   index  )
           OPC_UNPACK_VERTEX(  1,   index+1  )
           OPC_UNPACK_VERTEX(  2,   index+2  )
           }//else
           break;
           case MESH_TRIANGLE_STRIP:
           if(  mTris )
           {
           const IceMaths::IndexedTriangle* T = (  const IceMaths::IndexedTriangle* )(  (  (  ubyte* )mTris ) + index * mTriStride );
          
           // unpack indexed double-precision tri-trip
           OPC_UNPACK_VERTEX(  0,   T->mVRef[0]  )
           OPC_UNPACK_VERTEX(  1,   T->mVRef[index%2 ? 2 : 1]  )
           OPC_UNPACK_VERTEX(  2,   T->mVRef[index%2 ? 1 : 2] )
           }
           else
           {
           // unpack non-indexed double-precision tri-trip
           OPC_UNPACK_VERTEX(  0,   index  )
           OPC_UNPACK_VERTEX(  1,   (  index%2 ? index+2 : index+1 )  )
           OPC_UNPACK_VERTEX(  2,   (  index%2 ? index+1 : index+2 )  )
           }
           break;
          
           case MESH_TRIANGLE_FAN:
           if(  mTris )
           {
           const IceMaths::IndexedTriangle* T = (  const IceMaths::IndexedTriangle* )(  (  (  ubyte* )mTris ) + index * mTriStride );
           //const udword* inds = (  const udword* )mTris;
          
           // unpack indexed double-precision tri-fan
           OPC_UNPACK_VERTEX(  0,   mTris[0].mVRef[0]  )
           OPC_UNPACK_VERTEX(  1,   (  T->mVRef[1] )  )
           OPC_UNPACK_VERTEX(  2,   (  T->mVRef[2] )  )
           }
           else
           {
           // unpack non-indexed double-precision tri-trip
           OPC_UNPACK_VERTEX(  0,   0  )
           OPC_UNPACK_VERTEX(  1,   index+1  )
           OPC_UNPACK_VERTEX(  2,   index+2  )
           }
           break;
          
           case MESH_TERRAIN:
           // NOTE: Terrain models are always non-indexed,   so indices won't be used here.
           // What we do is compute indices. We introduce a little overhead,   but using
           // integer operations... shall we test performance??
           {
           udword trisPerRow = (  (  mNbVerts-1 )<<1 );
          
           udword row = index / trisPerRow;
           udword coll = index % trisPerRow;
           udword i0 = row*mNbVerts + (  coll>>1 );
          
           // here we use a lookup table for a good tesselation
           udword lookup[4][3] =
           {
           {0,  mNbVerts+1,  1},   // case 0
           {0,  mNbVerts,  mNbVerts+1},  // case 1
           {mNbVerts,  mNbVerts+1,  1},  // case 2
           {0,  mNbVerts,  1} // case 3
           };
          
           // compute key into lookup table
           udword key = (  row%2 ) ? (  coll%2 ) | (  (  i0%2 )<<1 ) : (  3- (  (  coll%2 ) | (  (  i0%2 )<<1 ) ) );
          
           // unpack terrain mesh here
           OPC_UNPACK_VERTEX(  0,   (  i0 + lookup[key][0] )  )
           OPC_UNPACK_VERTEX(  1,   (  i0 + lookup[key][1] )  )
           OPC_UNPACK_VERTEX(  2,   (  i0 + lookup[key][2] )  )
           }
           break;
           }
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           // END OF STRIDE CODE!
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           #else
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           // START OF NON-STRIDE CODE!
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
           #ifndef OPC_DOUBLE_PRECISION
           //! UTILITY macro for unpacking the K-th triangle vertex from a given index (  not using strides )
           #define OPC_UNPACK_VERTEX(  K,   ind  ) \
           vp.Vertex[K] = &mVerts[ind];
           #else
           //! UTILITY macro for shorter code when using double-precision vertices
           #define OPC_COPY_VERTEX(  K ) \
           VertexCache[K].x = (  float )v[0]; \
           VertexCache[K].x = (  float )v[1]; \
           VertexCache[K].x = (  float )v[2]; \
           vp.Vertex[K] = &VertexCache[K];
          
           //! UTILITY macro for unpacking the K-th triangle vertex from a given index (  not using strides )
           #define OPC_UNPACK_VERTEX(  K,   ind  ) \
           { \
           const double* v = (  const double* )(  (  (  ubyte* )mVerts ) + (  ind ) * 3*sizeof(  double ) );\
           OPC_COPY_VERTEX(  K ) \
           }
           #endif
           switch(   mMIType  )
           {
           case MESH_TRIANGLE:
           if(  mTris )
           {
           const IceMaths::IndexedTriangle* T = &mTris[index];
          
           OPC_UNPACK_VERTEX(  0,  T->mVRef[0] )
           OPC_UNPACK_VERTEX(  1,  T->mVRef[1] )
           OPC_UNPACK_VERTEX(  2,  T->mVRef[2] )
           }else
           {// support for non-indexed meshes
           index *= 3;
          
           OPC_UNPACK_VERTEX(  0,  index  )
           OPC_UNPACK_VERTEX(  1,  index+1 )
           OPC_UNPACK_VERTEX(  2,  index+2 )
           }
           break;
           case MESH_TRIANGLE_STRIP:
           if(  mTris )
           {
           const udword* inds = (  const udword* )mTris;
          
           // unpack indexed double-precision tri-trip
           OPC_UNPACK_VERTEX(  0,  inds[index]  )
           OPC_UNPACK_VERTEX(  1,  inds[index%2 ? index+2 : index+1] )
           OPC_UNPACK_VERTEX(  2,  inds[index%2 ? index+1 : index+2] )
           }
           else
           {
          
           // unpack non-indexed double-precision tri-trip
           OPC_UNPACK_VERTEX(  0,   index  )
           OPC_UNPACK_VERTEX(  1,   (  index%2 ? index+2 : index+1 )  )
           OPC_UNPACK_VERTEX(  2,   (  index%2 ? index+1 : index+2 )  )
           }
           break;
          
           case MESH_TRIANGLE_FAN:
           if(  mTris )
           {
           const udword* inds = (  const udword* )mTris;
          
           // unpack indexed double-precision tri-fan
           OPC_UNPACK_VERTEX(  0,   inds[0]  )
           OPC_UNPACK_VERTEX(  1,   inds[index+1]  )
           OPC_UNPACK_VERTEX(  2,   inds[index+2]  )
           }
           else
           {
           // unpack non-indexed double-precision tri-trip
           OPC_UNPACK_VERTEX(  0,   0  )
           OPC_UNPACK_VERTEX(  1,   (  index+1 )  )
           OPC_UNPACK_VERTEX(  2,   (  index+2 )  )
           }
           break;
          
           case MESH_TERRAIN:
           // NOTE: Terrain models are always non-indexed,   so indices won't be used here.
           // What we do is compute indices. We introduce a little overhead,   but using
           // integer operations... shall we test performance??
           {
           udword trisPerRow = (  (  mNbVerts-1 )<<1 );
          
           udword row = index / trisPerRow;
           udword coll = index % trisPerRow;
           udword i0 = row*mNbVerts + (  coll>>1 );
          
           // here we use a lookup table for a good tesselation
           udword lookup[4][3] =
           {
           {0,  mNbVerts+1,  1},   // case 0
           {0,  mNbVerts,  mNbVerts+1},  // case 1
           {mNbVerts,  mNbVerts+1,  1},  // case 2
           {0,  mNbVerts,  1} // case 3
           };
          
           // compute key into lookup table
           udword key = (  row%2 ) ? (  coll%2 ) | (  (  i0%2 )<<1 ) : (  3- (  (  coll%2 ) | (  (  i0%2 )<<1 ) ) );
          
           // unpack terrain mesh here
           OPC_UNPACK_VERTEX(  0,   (  i0 + lookup[key][0] )  )
           OPC_UNPACK_VERTEX(  1,   (  i0 + lookup[key][1] )  )
           OPC_UNPACK_VERTEX(  2,   (  i0 + lookup[key][2] )  )
           }
           break;
           }
           #endif
          #endif
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Remaps client's mesh according to a permutation.
           * \param nb_indices [in] number of indices in the permutation (  will be checked against number of triangles )
           * \param permutation [in] list of triangle indices
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     388   bool RemapClient(  udword nb_indices,   const udword* permutation ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks the mesh interface is valid,   i.e. things have been setup correctly.
           * \return true if valid
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     396   bool IsValid(   ) const;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Checks the mesh itself is valid.
           * Currently we only look for degenerate faces.
           * \return number of degenerate faces
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     405   udword CheckTopology(   ) const;
           private:
          
           udword mNbTris; //!< Number of triangles in the input model
           udword mNbVerts; //!< Number of vertices in the input model (  if this model is a terrain one,   this holds the number of vertices per row )
          
           MeshInterfaceType mMIType; //!< Mesh interface type
          #ifdef OPC_USE_CALLBACKS
           // User callback
           void* mUserData; //!< User-defined data sent to callback
           RequestCallback mObjCallback; //!< Object callback
          #else
           // User pointers
           const IceMaths::IndexedTriangle* mTris; //!< Array of indexed triangles
           const IceMaths::Point* mVerts; //!< Array of vertices
           #ifdef OPC_USE_STRIDE
           udword mTriStride; //!< Possible triangle stride in bytes [Opcode 1.3]
           udword mVertexStride; //!< Possible vertex stride in bytes [Opcode 1.3]
           #endif
          
           private:
           static IceMaths::Point VertexCache[3];
          #endif
           };
          
          #endif //__OPC_MESHINTERFACE_H__

./components/ogre/ogreopcode/include/Opcode/OPC_Model.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for OPCODE models.
           * \file OPC_Model.h
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_MODEL_H__
          #define __OPC_MODEL_H__
          
      27   class Model : public BaseModel
           {
           public:
           // Constructor/Destructor
      31   Model(   );
      32   virtual ~Model(   );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Builds a collision model.
           * \param create [in] model creation structure
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           override(  BaseModel ) bool Build(  const OPCODECREATE& create );
          
          #ifdef __MESHMERIZER_H__
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the collision hull.
           * \return the collision hull if it exists
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ const CollisionHull* GetHull(   ) const { return mHull; }
          #endif // __MESHMERIZER_H__
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the number of bytes used by the tree.
           * \return amount of bytes used
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           override(  BaseModel ) udword GetUsedBytes(   ) const;
          
           private:
          #ifdef __MESHMERIZER_H__
           CollisionHull* mHull; //!< Possible convex hull
          #endif // __MESHMERIZER_H__
           // Internal methods
           void Release(   );
           };
          
          #endif //__OPC_MODEL_H__

./components/ogre/ogreopcode/include/Opcode/OPC_Picking.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code to perform "picking".
           * \file OPC_Picking.h
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_PICKING_H__
          #define __OPC_PICKING_H__
          
          #ifdef OPC_RAYHIT_CALLBACK
          
           enum CullMode
           {
           CULLMODE_NONE = 0,  
           CULLMODE_CW = 1,  
           CULLMODE_CCW = 2
           };
          
           typedef CullMode (  *CullModeCallback )(  udword triangle_index,   void* user_data );
          
      34   OPCODE_API bool SetupAllHits (  RayCollider& collider,   CollisionFaces& contacts );
      35   OPCODE_API bool SetupClosestHit (  RayCollider& collider,   CollisionFace& closest_contact );
      36   OPCODE_API bool SetupShadowFeeler (  RayCollider& collider );
      37   OPCODE_API bool SetupInOutTest (  RayCollider& collider );
          
      39   OPCODE_API bool Picking(  
           CollisionFace& picked_face,  
           const Ray& world_ray,   const Model& model,   const Matrix4x4* world,  
           float min_dist,   float max_dist,   const Point& view_point,   CullModeCallback callback,   void* user_data );
          #endif
          
          #endif //__OPC_PICKING_H__

./components/ogre/ogreopcode/include/Opcode/OPC_PlanesAABBOverlap.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Planes-AABB overlap test.
           * - original code by Ville Miettinen,   from Umbra/dPVS (  released on the GD-Algorithms mailing list )
           * - almost used "as-is",   I even left the comments (  hence the frustum-related notes )
           *
           * \param center [in] box center
           * \param extents [in] box extents
           * \param out_clip_mask [out] bitmask for active planes
           * \param in_clip_mask [in] bitmask for active planes
           * \return TRUE if boxes overlap planes
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ BOOL PlanesCollider::PlanesAABBOverlap(  const IceMaths::Point& center_,   const IceMaths::Point& extents_,   udword& out_clip_mask,   udword in_clip_mask )
          {
           // Applies the model's local scale
           const IceMaths::Point center = center_ * mLocalScale;
           const IceMaths::Point extents = extents_ * mLocalScale;
          
           // Stats
      21   mNbVolumeBVTests++;
          
           const IceMaths::Plane* p = mPlanes;
          
           // Evaluate through all active frustum planes. We determine the relation
           // between the AABB and a plane by using the concept of "near" and "far"
           // vertices originally described by Zhang (  and later by Möller ). Our
           // variant here uses 3 fabs ops,   6 muls,   7 adds and two floating point
           // comparisons per plane. The routine early-exits if the AABB is found
           // to be outside any of the planes. The loop also constructs a new output
           // clip mask. Most FPUs have a native single-cycle fabsf(   ) operation.
          
           udword Mask = 1; // current mask index (  1,  2,  4,  8,  .. )
           udword TmpOutClipMask = 0; // initialize output clip mask into empty.
          
           while(  Mask<=in_clip_mask ) // keep looping while we have active planes left...
           {
           if(  in_clip_mask & Mask ) // if clip plane is active,   process it..
           {
           float NP = extents.x*fabsf(  p->n.x ) + extents.y*fabsf(  p->n.y ) + extents.z*fabsf(  p->n.z ); // ### fabsf could be precomputed
           float MP = center.x*p->n.x + center.y*p->n.y + center.z*p->n.z + p->d;
          
           if(  NP < MP ) // near vertex behind the clip plane...
           return FALSE; // .. so there is no intersection..
           if(  (  -NP ) < MP ) // near and far vertices on different sides of plane..
           TmpOutClipMask |= Mask; // .. so update the clip mask...
           }
           Mask+=Mask; // mk = (  1<<plane )
           p++; // advance to next plane
           }
          
           out_clip_mask = TmpOutClipMask; // copy output value (  temp used to resolve aliasing! )
           return TRUE; // indicate that AABB intersects frustum
          }

./components/ogre/ogreopcode/include/Opcode/OPC_PlanesCollider.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for a planes collider.
           * \file OPC_PlanesCollider.h
           * \author Pierre Terdiman
           * \date January,   1st,   2002
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_PLANESCOLLIDER_H__
          #define __OPC_PLANESCOLLIDER_H__
          
           struct PlanesCache : VolumeCache
           {
           PlanesCache(   )
           {
           }
           };
          
      35   class PlanesCollider : public VolumeCollider
           {
           public:
           // Constructor / Destructor
      39   PlanesCollider(   );
      40   virtual ~PlanesCollider(   );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Generic collision query for generic OPCODE models. After the call,   access the results:
           * - with GetContactStatus(   )
           * - with GetNbTouchedPrimitives(   )
           * - with GetTouchedPrimitives(   )
           *
           * \param cache [in/out] a planes cache
           * \param planes [in] list of planes in world space
           * \param nb_planes [in] number of planes
           * \param model [in] Opcode model to collide with
           * \param worldm [in] model's world matrix,   or null
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      57   bool Collide(  PlanesCache& cache,   const IceMaths::Plane* planes,   udword nb_planes,   const Model& model,   const IceMaths::Matrix4x4* worldm=null );
          
           // Mutant box-with-planes collision queries
           inline_ bool Collide(  PlanesCache& cache,   const IceMaths::OBB& box,   const Model& model,   const IceMaths::Matrix4x4* worldb=null,   const IceMaths::Matrix4x4* worldm=null )
           {
           IceMaths::Plane PL[6];
          
           if(  worldb )
           {
           // Create a new OBB in world space
           IceMaths::OBB WorldBox;
           box.Rotate(  *worldb,   WorldBox );
           // Compute planes from the sides of the box
           WorldBox.ComputePlanes(  PL );
           }
           else
           {
           // Compute planes from the sides of the box
           box.ComputePlanes(  PL );
           }
          
           // Collide with box planes
           return Collide(  cache,   PL,   6,   model,   worldm );
           }
           // Settings
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Validates current settings. You should call this method after all the settings and callbacks have been defined for a collider.
           * \return null if everything is ok,   else a string describing the problem
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           override(  Collider ) const char* ValidateSettings(   );
          
           protected:
           // Planes in model space
           udword mNbPlanes;
           IceMaths::Plane* mPlanes;
           // Leaf description
           VertexPointers mVP;
           // Internal methods
           void _Collide(  const AABBCollisionNode* node,   udword clip_mask );
           void _Collide(  const AABBNoLeafNode* node,   udword clip_mask );
           void _Collide(  const AABBQuantizedNode* node,   udword clip_mask );
           void _Collide(  const AABBQuantizedNoLeafNode* node,   udword clip_mask );
           void _CollideNoPrimitiveTest(  const AABBCollisionNode* node,   udword clip_mask );
           void _CollideNoPrimitiveTest(  const AABBNoLeafNode* node,   udword clip_mask );
           void _CollideNoPrimitiveTest(  const AABBQuantizedNode* node,   udword clip_mask );
           void _CollideNoPrimitiveTest(  const AABBQuantizedNoLeafNode* node,   udword clip_mask );
           // Overlap tests
           inline_ BOOL PlanesAABBOverlap(  const IceMaths::Point& center,   const IceMaths::Point& extents,   udword& out_clip_mask,   udword in_clip_mask );
           inline_ BOOL PlanesTriOverlap(  udword in_clip_mask );
           // Init methods
           BOOL InitQuery(  PlanesCache& cache,   const IceMaths::Plane* planes,   udword nb_planes,   const IceMaths::Matrix4x4* worldm=null );
           };
          
           class HybridPlanesCollider : public PlanesCollider
           {
           public:
           // Constructor / Destructor
           HybridPlanesCollider(   );
           virtual ~HybridPlanesCollider(   );
          
           bool Collide(  PlanesCache& cache,   const IceMaths::Plane* planes,   udword nb_planes,   const HybridModel& model,   const IceMaths::Matrix4x4* worldm=null );
           protected:
           IceCore::Container mTouchedBoxes;
           };
          
          #endif // __OPC_PLANESCOLLIDER_H__

./components/ogre/ogreopcode/include/Opcode/OPC_PlanesTriOverlap.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Planes-triangle overlap test.
           * \param in_clip_mask [in] bitmask for active planes
           * \return TRUE if triangle overlap planes
           * \warning THIS IS A CONSERVATIVE TEST !! Some triangles will be returned as intersecting,   while they're not!
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ BOOL PlanesCollider::PlanesTriOverlap(  udword in_clip_mask )
          {
           // Stats
      12   mNbVolumePrimTests++;
          
           const IceMaths::Plane* p = mPlanes;
           udword Mask = 1;
          
           while(  Mask<=in_clip_mask )
           {
           if(  in_clip_mask & Mask )
           {
           // distance with scaled vertices
           float d0 = p->Distance(   (  *mVP.Vertex[0] )*mLocalScale  );
           float d1 = p->Distance(   (  *mVP.Vertex[1] )*mLocalScale  );
           float d2 = p->Distance(   (  *mVP.Vertex[2] )*mLocalScale  );
           if(  d0>0.0f && d1>0.0f && d2>0.0f ) return FALSE;
          // if(  !(  IR(  d0 )&SIGN_BITMASK ) && !(  IR(  d1 )&SIGN_BITMASK ) && !(  IR(  d2 )&SIGN_BITMASK ) ) return FALSE;
           }
           Mask+=Mask;
           p++;
           }
          /*
           for(  udword i=0;i<6;i++ )
           {
           float d0 = p[i].Distance(  mLeafVerts[0] );
           float d1 = p[i].Distance(  mLeafVerts[1] );
           float d2 = p[i].Distance(  mLeafVerts[2] );
           if(  d0>0.0f && d1>0.0f && d2>0.0f ) return false;
           }
          */
           return TRUE;
          }

./components/ogre/ogreopcode/include/Opcode/OPC_RayAABBOverlap.h

          // Opcode 1.1: ray-AABB overlap tests based on Woo's code
          // Opcode 1.2: ray-AABB overlap tests based on the separating axis theorem
          // Opcode 1.3.2: configuration. Apply or do not apply the model's scale??
          //
          // The point of intersection is not computed anymore. The distance to impact is not needed anymore
          // since we now have two different queries for segments or rays.
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes a segment-AABB overlap test using the separating axis theorem. Segment is cached within the class.
           * \param center [in] AABB center
           * \param extents [in] AABB extents
           * \return true on overlap
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          /// What we do here is just a simple hack over the method declaration in order do keep the
          /// intersection code easier to maintain. This code will be moved to RayCollider macros sooner or later
          
          #if defined(  OPC_RAYCOLLIDER_SCALE_BEFORE_OVERLAP )
           inline_ BOOL RayCollider::SegmentAABBOverlap(  const Point& center_,   const Point& extents_ )
           {
           // Applies model's local scale
           const IceMaths::Point center = center_ * mLocalScale;
           const IceMaths::Point extents = extents_* mLocalScale;
          
          #else
          inline_ BOOL RayCollider::SegmentAABBOverlap(  const Point& center,   const Point& extents )
          {
          #endif
           // Stats
      32   mNbRayBVTests++;
          
           // Pierre's code: looks like an AABB-AABB test
           float Dx = mData2.x - center.x; if(  fabsf(  Dx ) > extents.x + mFDir.x ) return FALSE;
           float Dy = mData2.y - center.y; if(  fabsf(  Dy ) > extents.y + mFDir.y ) return FALSE;
           float Dz = mData2.z - center.z; if(  fabsf(  Dz ) > extents.z + mFDir.z ) return FALSE;
          
           //float f;
           register float f = mData.y * Dz - mData.z * Dy; if(  fabsf(  f ) > extents.y*mFDir.z + extents.z*mFDir.y ) return FALSE;
           f = mData.z * Dx - mData.x * Dz; if(  fabsf(  f ) > extents.x*mFDir.z + extents.z*mFDir.x ) return FALSE;
           f = mData.x * Dy - mData.y * Dx; if(  fabsf(  f ) > extents.x*mFDir.y + extents.y*mFDir.x ) return FALSE;
          
           return TRUE;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes a ray-AABB overlap test using the separating axis theorem. Ray is cached within the class.
           * \param center [in] AABB center
           * \param extents [in] AABB extents
           * \return true on overlap
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          #if defined(  OPC_RAYCOLLIDER_SCALE_BEFORE_OVERLAP )
           inline_ BOOL RayCollider::RayAABBOverlap(  const Point& center_,   const Point& extents_ )
           {
           const Point center = center_*mLocalScale;
           const Point extents = extents_*mLocalScale;
          #else
           inline_ BOOL RayCollider::RayAABBOverlap(  const Point& center,   const Point& extents )
           {
          #endif
          
           // Stats
           mNbRayBVTests++;
          
          // PIERRE'S CODE:
          // float Dx = mOrigin.x - center.x; if(  fabsf(  Dx ) > extents.x && Dx*mDir.x>=0.0f ) return FALSE;
          // float Dy = mOrigin.y - center.y; if(  fabsf(  Dy ) > extents.y && Dy*mDir.y>=0.0f ) return FALSE;
          // float Dz = mOrigin.z - center.z; if(  fabsf(  Dz ) > extents.z && Dz*mDir.z>=0.0f ) return FALSE;
          
           float Dx = mOrigin.x - center.x; if(  GREATER(  Dx,   extents.x ) && Dx*mDir.x>=0.0f ) return FALSE;
           float Dy = mOrigin.y - center.y; if(  GREATER(  Dy,   extents.y ) && Dy*mDir.y>=0.0f ) return FALSE;
           float Dz = mOrigin.z - center.z; if(  GREATER(  Dz,   extents.z ) && Dz*mDir.z>=0.0f ) return FALSE;
          
          // float Dx = mOrigin.x - center.x; if(  GREATER(  Dx,   extents.x ) && (  (  SIR(  Dx )-1 )^SIR(  mDir.x ) )>=0.0f ) return FALSE;
          // float Dy = mOrigin.y - center.y; if(  GREATER(  Dy,   extents.y ) && (  (  SIR(  Dy )-1 )^SIR(  mDir.y ) )>=0.0f ) return FALSE;
          // float Dz = mOrigin.z - center.z; if(  GREATER(  Dz,   extents.z ) && (  (  SIR(  Dz )-1 )^SIR(  mDir.z ) )>=0.0f ) return FALSE;
          
           //float f;
           register float f = mDir.y * Dz - mDir.z * Dy; if(  fabsf(  f ) > extents.y*mFDir.z + extents.z*mFDir.y ) return FALSE;
           f = mDir.z * Dx - mDir.x * Dz; if(  fabsf(  f ) > extents.x*mFDir.z + extents.z*mFDir.x ) return FALSE;
           f = mDir.x * Dy - mDir.y * Dx; if(  fabsf(  f ) > extents.x*mFDir.y + extents.y*mFDir.x ) return FALSE;
          
           return TRUE;
          }

./components/ogre/ogreopcode/include/Opcode/OPC_RayCollider.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for a ray collider.
           * \file OPC_RayCollider.h
           * \author Pierre Terdiman
           * \date June,   2,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_RAYCOLLIDER_H__
          #define __OPC_RAYCOLLIDER_H__
          
      28   class CollisionFace
           {
           public:
           //! Constructor
      32   inline_ CollisionFace(   ) {}
           //! Destructor
      34   inline_ ~CollisionFace(   ) {}
          
      36   udword mFaceID; //!< Index of touched face
           float mDistance; //!< Distance from collider to hitpoint
           float mU,   mV; //!< Impact barycentric coordinates
           };
          
      41   class CollisionFaces : private IceCore::Container
           {
           public:
           //! Constructor
      45   CollisionFaces(   ) {}
           //! Destructor
      47   ~CollisionFaces(   ) {}
          
           inline_ udword GetNbFaces(   ) const { return GetNbEntries(   )>>2; }
      50   inline_ const CollisionFace* GetFaces(   ) const { return (  const CollisionFace* )GetEntries(   ); }
          
      52   inline_ void Reset(   ) { IceCore::Container::Reset(   ); }
          
      54   inline_ void AddFace(  const CollisionFace& face ) { Add(  face.mFaceID ).Add(  face.mDistance ).Add(  face.mU ).Add(  face.mV ); }
           };
          
          #ifdef OPC_RAYHIT_CALLBACK
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * User-callback,   called by OPCODE to record a hit.
           * \param hit [in] current hit
           * \param user_data [in] user-defined data from SetCallback(   )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           typedef void (  *HitCallback ) (  const CollisionFace& hit,   void* user_data );
          #endif
          
           class RayCollider : public Collider
           {
           public:
           // Constructor / Destructor
           RayCollider(   );
           virtual ~RayCollider(   );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Generic stabbing query for generic OPCODE models. After the call,   access the results:
           * - with GetContactStatus(   )
           * - in the user-provided destination array
           *
           * \param world_ray [in] stabbing ray in world space
           * \param model [in] Opcode model to collide with
           * \param world [in] model's world matrix,   or null
           * \param cache [in] a possibly cached face index,   or null
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           bool Collide(  const IceMaths::Ray& world_ray,   const Model& model,   const IceMaths::Matrix4x4* world=null,   udword* cache=null );
           //
           bool Collide(  const IceMaths::Ray& world_ray,   const AABBTree* tree,   IceCore::Container& box_indices );
           // Settings
          
          #ifndef OPC_RAYHIT_CALLBACK
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Settings: enable or disable "closest hit" mode.
           * \param flag [in] true to report closest hit only
           * \see SetCulling(  bool flag )
           * \see SetMaxDist(  float max_dist )
           * \see SetDestination(  StabbedFaces* sf )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void SetClosestHit(  bool flag ) { mClosestHit = flag; }
          #endif
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Settings: enable or disable backface culling.
           * \param flag [in] true to enable backface culling
           * \see SetClosestHit(  bool flag )
           * \see SetMaxDist(  float max_dist )
           * \see SetDestination(  StabbedFaces* sf )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void SetCulling(  bool flag ) { mCulling = flag; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Settings: sets the higher distance bound.
           * \param max_dist [in] higher distance bound. Default = maximal value,   for ray queries (  else segment )
           * \see SetClosestHit(  bool flag )
           * \see SetCulling(  bool flag )
           * \see SetDestination(  StabbedFaces* sf )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void SetMaxDist(  float max_dist=MAX_FLOAT ) { mMaxDist = max_dist; }
          
          #ifdef OPC_RAYHIT_CALLBACK
           inline_ void SetHitCallback(  HitCallback cb ) { mHitCallback = cb; }
           inline_ void SetUserData(  void* user_data ) { mUserData = user_data; }
          #else
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Settings: sets the destination array for stabbed faces.
           * \param cf [in] destination array,   filled during queries
           * \see SetClosestHit(  bool flag )
           * \see SetCulling(  bool flag )
           * \see SetMaxDist(  float max_dist )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void SetDestination(  CollisionFaces* cf ) { mStabbedFaces = cf; }
          #endif
           // Stats
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Stats: gets the number of Ray-BV overlap tests after a collision query.
           * \see GetNbRayPrimTests(   )
           * \see GetNbIntersections(   )
           * \return the number of Ray-BV tests performed during last query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ udword GetNbRayBVTests(   ) const { return mNbRayBVTests; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Stats: gets the number of Ray-Triangle overlap tests after a collision query.
           * \see GetNbRayBVTests(   )
           * \see GetNbIntersections(   )
           * \return the number of Ray-Triangle tests performed during last query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ udword GetNbRayPrimTests(   ) const { return mNbRayPrimTests; }
          
           // In-out test
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Stats: gets the number of intersection found after a collision query. Can be used for in/out tests.
           * \see GetNbRayBVTests(   )
           * \see GetNbRayPrimTests(   )
           * \return the number of valid intersections during last query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ udword GetNbIntersections(   ) const { return mNbIntersections; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Validates current settings. You should call this method after all the settings and callbacks have been defined for a collider.
           * \return null if everything is ok,   else a string describing the problem
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           override(  Collider ) const char* ValidateSettings(   );
          
           protected:
           // Ray in local space
           IceMaths::Point mOrigin; //!< Ray origin
           IceMaths::Point mDir; //!< Ray direction (  normalized )
           IceMaths::Point mFDir; //!< fabsf(  mDir )
           IceMaths::Point mData,   mData2;
           // Model scaling
           IceMaths::Point mLocalScale; //!< Model's local scale
           // Stabbed faces
           CollisionFace mStabbedFace; //!< Current stabbed face
          #ifdef OPC_RAYHIT_CALLBACK
           HitCallback mHitCallback; //!< Callback used to record a hit
           void* mUserData; //!< User-defined data
          #else
           CollisionFaces* mStabbedFaces; //!< List of stabbed faces
          #endif
           // Stats
           udword mNbRayBVTests; //!< Number of Ray-BV tests
           udword mNbRayPrimTests; //!< Number of Ray-Primitive tests
           // In-out test
           udword mNbIntersections; //!< Number of valid intersections
           // Dequantization coeffs
           IceMaths::Point mCenterCoeff;
           IceMaths::Point mExtentsCoeff;
           // Settings
           float mMaxDist; //!< Valid segment on the ray
          #ifndef OPC_RAYHIT_CALLBACK
           bool mClosestHit; //!< Report closest hit only
          #endif
           bool mCulling; //!< Stab culled faces or not
           // Internal methods
           void _SegmentStab(  const AABBCollisionNode* node );
           void _SegmentStab(  const AABBNoLeafNode* node );
           void _SegmentStab(  const AABBQuantizedNode* node );
           void _SegmentStab(  const AABBQuantizedNoLeafNode* node );
           void _SegmentStab(  const AABBTreeNode* node,   IceCore::Container& box_indices );
           void _RayStab(  const AABBCollisionNode* node );
           void _RayStab(  const AABBNoLeafNode* node );
           void _RayStab(  const AABBQuantizedNode* node );
           void _RayStab(  const AABBQuantizedNoLeafNode* node );
           void _RayStab(  const AABBTreeNode* node,   IceCore::Container& box_indices );
           // Overlap tests
           inline_ BOOL RayAABBOverlap(  const IceMaths::Point& center,   const IceMaths::Point& extents );
           inline_ BOOL SegmentAABBOverlap(  const IceMaths::Point& center,   const IceMaths::Point& extents );
           inline_ BOOL RayTriOverlap(  const IceMaths::Point& vert0,   const IceMaths::Point& vert1,   const IceMaths::Point& vert2 );
           // Init methods
           BOOL InitQuery(  const IceMaths::Ray& world_ray,   const IceMaths::Matrix4x4* world=null,   udword* face_id=null );
           };
          
          #endif // __OPC_RAYCOLLIDER_H__

./components/ogre/ogreopcode/include/Opcode/OPC_RayTriOverlap.h

          #define LOCAL_EPSILON 0.000001f
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes a ray-triangle intersection test.
           * Original code from Tomas Möller's "Fast Minimum Storage Ray-Triangle Intersection".
           * It's been optimized a bit with integer code,   and modified to return a non-intersection if distance from
           * ray origin to triangle is negative.
           *
           * \param vert0 [in] triangle vertex
           * \param vert1 [in] triangle vertex
           * \param vert2 [in] triangle vertex
           * \return true on overlap. mStabbedFace is filled with relevant info.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          // just check the method's declaration
          #if defined(  OPC_RAYCOLLIDER_SCALE_BEFORE_OVERLAP )
          
           inline_ BOOL RayCollider::RayTriOverlap(  const Point& vert0_,   const Point& vert1_,   const Point& vert2_ )
           {
           // Applies model's local scale
           const IceMaths::Point& vert0 = vert0_*mLocalScale;
           const IceMaths::Point& vert1 = vert1_*mLocalScale;
           const IceMaths::Point& vert2 = vert2_*mLocalScale;
          
          #else
          
           inline_ BOOL RayCollider::RayTriOverlap(  const Point& vert0,   const Point& vert1,   const Point& vert2 )
           {
          
          #endif
           // Stats
      34   mNbRayPrimTests++;
          
           // Find vectors for two edges sharing vert0
           Point edge1 = vert1 - vert0;
           Point edge2 = vert2 - vert0;
          
           // Begin calculating determinant - also used to calculate U parameter
           Point pvec = mDir^edge2;
          
           // If determinant is near zero,   ray lies in plane of triangle
           float det = edge1|pvec;
          
           if(  mCulling )
           {
           if(  det<LOCAL_EPSILON ) return FALSE;
           // From here,   det is > 0. So we can use integer cmp.
          
           // Calculate distance from vert0 to ray origin
           Point tvec = mOrigin - vert0;
          
           // Calculate U parameter and test bounds
           mStabbedFace.mU = tvec|pvec;
          // if(  IR(  u )&0x80000000 || u>det ) return FALSE;
           if(  IS_NEGATIVE_FLOAT(  mStabbedFace.mU ) || IR(  mStabbedFace.mU )>IR(  det ) ) return FALSE;
          
           // Prepare to test V parameter
           Point qvec = tvec^edge1;
          
           // Calculate V parameter and test bounds
           mStabbedFace.mV = mDir|qvec;
           if(  IS_NEGATIVE_FLOAT(  mStabbedFace.mV ) || mStabbedFace.mU+mStabbedFace.mV>det ) return FALSE;
          
           // Calculate t,   scale parameters,   ray intersects triangle
           mStabbedFace.mDistance = edge2|qvec;
           // Det > 0 so we can early exit here
           // Intersection point is valid if distance is positive (  else it can just be a face behind the orig point )
           if(  IS_NEGATIVE_FLOAT(  mStabbedFace.mDistance ) ) return FALSE;
           // Else go on
           float OneOverDet = 1.0f / det;
           mStabbedFace.mDistance *= OneOverDet;
           mStabbedFace.mU *= OneOverDet;
           mStabbedFace.mV *= OneOverDet;
           }
           else
           {
           // the non-culling branch
           if(  det>-LOCAL_EPSILON && det<LOCAL_EPSILON ) return FALSE;
           float OneOverDet = 1.0f / det;
          
           // Calculate distance from vert0 to ray origin
           Point tvec = mOrigin - vert0;
          
           // Calculate U parameter and test bounds
           mStabbedFace.mU = (  tvec|pvec ) * OneOverDet;
          // if(  IR(  u )&0x80000000 || u>1.0f ) return FALSE;
           if(  IS_NEGATIVE_FLOAT(  mStabbedFace.mU ) || IR(  mStabbedFace.mU )>IEEE_1_0 ) return FALSE;
          
           // prepare to test V parameter
           Point qvec = tvec^edge1;
          
           // Calculate V parameter and test bounds
           mStabbedFace.mV = (  mDir|qvec ) * OneOverDet;
           if(  IS_NEGATIVE_FLOAT(  mStabbedFace.mV ) || mStabbedFace.mU+mStabbedFace.mV>1.0f ) return FALSE;
          
           // Calculate t,   ray intersects triangle
           mStabbedFace.mDistance = (  edge2|qvec ) * OneOverDet;
           // Intersection point is valid if distance is positive (  else it can just be a face behind the orig point )
           if(  IS_NEGATIVE_FLOAT(  mStabbedFace.mDistance ) ) return FALSE;
           }
           return TRUE;
          }

./components/ogre/ogreopcode/include/Opcode/OPC_Settings.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and some minor things )
           * Copyright (  C ) 2004-2005 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for news,   more information and updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains compilation flags.
           * \file OPC_Settings.h
           * \author Pierre Terdiman
           * \date May,   12,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_SETTINGS_H__
          #define __OPC_SETTINGS_H__
          
           //! NEW!!! Use double-precision vertices. Remember that this is a "storage-only" option,   because
           // every test performed in OPCODE for collision is done against a triangle. This means a
           // double precision triangle is 'cast' into a single precision one before true collision
           // tests are performed,   trees built,   etc.
           // #define OPC_DOUBLE_PRECISION
          
           //! Use CPU comparisons (  comment that line to use standard FPU compares )
           #define OPC_CPU_COMPARE
          
           //! Use FCOMI / FCMOV on Pentium-Pro based processors (  comment that line to use plain C++ )
           #define OPC_USE_FCOMI
          
           //! Use epsilon value in tri-tri overlap test
           #define OPC_TRITRI_EPSILON_TEST
          
           //! Use tree-coherence or not [not implemented yet]
          // #define OPC_USE_TREE_COHERENCE
          
           //! Use callbacks or direct pointers. Using callbacks might be a bit slower (  but probably not much )
          // #define OPC_USE_CALLBACKS
          
           //! Support triangle and vertex strides or not. Using strides might be a bit slower (  but probably not much )
           //! HINT: Enable strides only if your vertices are NOT "tighly packed",   ie,   there are other info (  not only
           //! vertex positions but colors,   normals,   etc ) stored at each vertex. In this case,   vertex strides
           //! must be set to the 'sizeof' the 'struct' holding your vertex positions in an array - if you used
           //! OpenGL vertex arrays,   you should understand this fine.
           //! Thus,   if you always have an array of 'xzy' coordinates and an array for indices,   it could be better
           //! if you disable strides.
           //#define OPC_USE_STRIDE
          
           //! Discard negative pointer in vanilla trees
           #define OPC_NO_NEG_VANILLA_TREE
          
           //! Use a callback in the ray collider
           //#define OPC_RAYHIT_CALLBACK
          
           // NB: no compilation flag to enable/disable stats since they're actually needed in the box/box overlap test.
           // Such flag will be added in the 1.3.3 version and will make things faster. Just wait.
          
          #endif //__OPC_SETTINGS_H__

./components/ogre/ogreopcode/include/Opcode/OPC_SphereAABBOverlap.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Sphere-AABB overlap test,   based on Jim Arvo's code.
           * \param center_ [in] box center
           * \param extents_ [in] box extents
           * \return TRUE on overlap
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ BOOL SphereCollider::SphereAABBOverlap(  const IceMaths::Point& center_,   const IceMaths::Point& extents_ )
          {
           // Stats
      12   mNbVolumeBVTests++;
          
           // Applies the model's local scale
           const IceMaths::Point center = center_ *mLocalScale;
           const IceMaths::Point extents = extents_*mLocalScale;
          
           float d = 0.0f;
          
           //find the square of the distance
           //from the sphere to the box
          #ifdef OLDIES
           for(  udword i=0;i<3;i++ )
           {
           float tmp = mCenter[i] - center[i];
           float s = tmp + extents[i];
          
           if(  s<0.0f ) d += s*s;
           else
           {
           s = tmp - extents[i];
           if(  s>0.0f ) d += s*s;
           }
           }
          #endif
          
          //#ifdef NEW_TEST
          
          // float tmp = mCenter.x - center.x;
          // float s = tmp + extents.x;
          
           float tmp,  s;
          
           tmp = mCenter.x - center.x;
           s = tmp + extents.x;
          
           if(  s<0.0f )
           {
           d += s*s;
           if(  d>mRadius2 ) return FALSE;
           }
           else
           {
           s = tmp - extents.x;
           if(  s>0.0f )
           {
           d += s*s;
           if(  d>mRadius2 ) return FALSE;
           }
           }
          
           tmp = mCenter.y - center.y;
           s = tmp + extents.y;
          
           if(  s<0.0f )
           {
           d += s*s;
           if(  d>mRadius2 ) return FALSE;
           }
           else
           {
           s = tmp - extents.y;
           if(  s>0.0f )
           {
           d += s*s;
           if(  d>mRadius2 ) return FALSE;
           }
           }
          
           tmp = mCenter.z - center.z;
           s = tmp + extents.z;
          
           if(  s<0.0f )
           {
           d += s*s;
           if(  d>mRadius2 ) return FALSE;
           }
           else
           {
           s = tmp - extents.z;
           if(  s>0.0f )
           {
           d += s*s;
           if(  d>mRadius2 ) return FALSE;
           }
           }
          //#endif
          
          #ifdef OLDIES
          // Point Min = center - extents;
          // Point Max = center + extents;
          
           float d = 0.0f;
          
           //find the square of the distance
           //from the sphere to the box
           for(  udword i=0;i<3;i++ )
           {
          float Min = center[i] - extents[i];
          
          // if(  mCenter[i]<Min[i] )
           if(  mCenter[i]<Min )
           {
          // float s = mCenter[i] - Min[i];
           float s = mCenter[i] - Min;
           d += s*s;
           }
           else
           {
          float Max = center[i] + extents[i];
          
          // if(  mCenter[i]>Max[i] )
           if(  mCenter[i]>Max )
           {
           float s = mCenter[i] - Max;
           d += s*s;
           }
           }
           }
          #endif
           return d <= mRadius2;
          }

./components/ogre/ogreopcode/include/Opcode/OPC_SphereTriOverlap.h

       1  
          // This is collision detection. If you do another distance test for collision *response*,  
          // if might be useful to simply *skip* the test below completely,   and report a collision.
          // - if sphere-triangle overlap,   result is ok
          // - if they don't,   we'll discard them during collision response with a similar test anyway
          // Overall this approach should run faster.
          
          // Original code by David Eberly in Magic.
       9  BOOL SphereCollider::SphereTriOverlap(  const IceMaths::Point& vert0_,   const IceMaths::Point& vert1_,   const IceMaths::Point& vert2_ )
          {
           // Stats
           mNbVolumePrimTests++;
          
           // applies the model's local scale
           IceMaths::Point vert0 = vert0_*mLocalScale;
           IceMaths::Point vert1 = vert1_*mLocalScale;
           IceMaths::Point vert2 = vert2_*mLocalScale;
          
           // Early exit if one of the vertices is inside the sphere
           IceMaths::Point kDiff = vert2 - mCenter;
           float fC = kDiff.SquareMagnitude(   );
           if(  fC <= mRadius2 ) return TRUE;
          
           kDiff = vert1 - mCenter;
           fC = kDiff.SquareMagnitude(   );
           if(  fC <= mRadius2 ) return TRUE;
          
           kDiff = vert0 - mCenter;
           fC = kDiff.SquareMagnitude(   );
           if(  fC <= mRadius2 ) return TRUE;
          
           // Else do the full distance test
           IceMaths::Point TriEdge0 = vert1 - vert0;
           IceMaths::Point TriEdge1 = vert2 - vert0;
          
          //Point kDiff = vert0 - mCenter;
           float fA00 = TriEdge0.SquareMagnitude(   );
           float fA01 = TriEdge0 | TriEdge1;
           float fA11 = TriEdge1.SquareMagnitude(   );
           float fB0 = kDiff | TriEdge0;
           float fB1 = kDiff | TriEdge1;
          //float fC = kDiff.SquareMagnitude(   );
           float fDet = fabsf(  fA00*fA11 - fA01*fA01 );
           float u = fA01*fB1-fA11*fB0;
           float v = fA01*fB0-fA00*fB1;
           float SqrDist;
          
           if(  u + v <= fDet )
           {
           if(  u < 0.0f )
           {
           if(  v < 0.0f ) // region 4
           {
           if(  fB0 < 0.0f )
           {
          // v = 0.0f;
           if(  -fB0>=fA00 ) { /*u = 1.0f;*/ SqrDist = fA00+2.0f*fB0+fC; }
           else { u = -fB0/fA00; SqrDist = fB0*u+fC; }
           }
           else
           {
          // u = 0.0f;
           if(  fB1>=0.0f ) { /*v = 0.0f;*/ SqrDist = fC; }
           else if(  -fB1>=fA11 ) { /*v = 1.0f;*/ SqrDist = fA11+2.0f*fB1+fC; }
           else { v = -fB1/fA11; SqrDist = fB1*v+fC; }
           }
           }
           else // region 3
           {
          // u = 0.0f;
           if(  fB1>=0.0f ) { /*v = 0.0f;*/ SqrDist = fC; }
           else if(  -fB1>=fA11 ) { /*v = 1.0f;*/ SqrDist = fA11+2.0f*fB1+fC; }
           else { v = -fB1/fA11; SqrDist = fB1*v+fC; }
           }
           }
           else if(  v < 0.0f ) // region 5
           {
          // v = 0.0f;
           if(  fB0>=0.0f ) { /*u = 0.0f;*/ SqrDist = fC; }
           else if(  -fB0>=fA00 ) { /*u = 1.0f;*/ SqrDist = fA00+2.0f*fB0+fC; }
           else { u = -fB0/fA00; SqrDist = fB0*u+fC; }
           }
           else // region 0
           {
           // minimum at interior point
           if(  fDet==0.0f )
           {
          // u = 0.0f;
          // v = 0.0f;
           SqrDist = MAX_FLOAT;
           }
           else
           {
           float fInvDet = 1.0f/fDet;
           u *= fInvDet;
           v *= fInvDet;
           SqrDist = u*(  fA00*u+fA01*v+2.0f*fB0 ) + v*(  fA01*u+fA11*v+2.0f*fB1 )+fC;
           }
           }
           }
           else
           {
           float fTmp0,   fTmp1,   fNumer,   fDenom;
          
           if(  u < 0.0f ) // region 2
           {
           fTmp0 = fA01 + fB0;
           fTmp1 = fA11 + fB1;
           if(  fTmp1 > fTmp0 )
           {
           fNumer = fTmp1 - fTmp0;
           fDenom = fA00-2.0f*fA01+fA11;
           if(  fNumer >= fDenom )
           {
          // u = 1.0f;
          // v = 0.0f;
           SqrDist = fA00+2.0f*fB0+fC;
           }
           else
           {
           u = fNumer/fDenom;
           v = 1.0f - u;
           SqrDist = u*(  fA00*u+fA01*v+2.0f*fB0 ) + v*(  fA01*u+fA11*v+2.0f*fB1 )+fC;
           }
           }
           else
           {
          // u = 0.0f;
           if(  fTmp1 <= 0.0f ) { /*v = 1.0f;*/ SqrDist = fA11+2.0f*fB1+fC; }
           else if(  fB1 >= 0.0f ) { /*v = 0.0f;*/ SqrDist = fC; }
           else { v = -fB1/fA11; SqrDist = fB1*v+fC; }
           }
           }
           else if(  v < 0.0f ) // region 6
           {
           fTmp0 = fA01 + fB1;
           fTmp1 = fA00 + fB0;
           if(  fTmp1 > fTmp0 )
           {
           fNumer = fTmp1 - fTmp0;
           fDenom = fA00-2.0f*fA01+fA11;
           if(  fNumer >= fDenom )
           {
          // v = 1.0f;
          // u = 0.0f;
           SqrDist = fA11+2.0f*fB1+fC;
           }
           else
           {
           v = fNumer/fDenom;
           u = 1.0f - v;
           SqrDist = u*(  fA00*u+fA01*v+2.0f*fB0 ) + v*(  fA01*u+fA11*v+2.0f*fB1 )+fC;
           }
           }
           else
           {
          // v = 0.0f;
           if(  fTmp1 <= 0.0f ) { /*u = 1.0f;*/ SqrDist = fA00+2.0f*fB0+fC; }
           else if(  fB0 >= 0.0f ) { /*u = 0.0f;*/ SqrDist = fC; }
           else { u = -fB0/fA00; SqrDist = fB0*u+fC; }
           }
           }
           else // region 1
           {
           fNumer = fA11 + fB1 - fA01 - fB0;
           if(  fNumer <= 0.0f )
           {
          // u = 0.0f;
          // v = 1.0f;
           SqrDist = fA11+2.0f*fB1+fC;
           }
           else
           {
           fDenom = fA00-2.0f*fA01+fA11;
           if(  fNumer >= fDenom )
           {
          // u = 1.0f;
          // v = 0.0f;
           SqrDist = fA00+2.0f*fB0+fC;
           }
           else
           {
           u = fNumer/fDenom;
           v = 1.0f - u;
           SqrDist = u*(  fA00*u+fA01*v+2.0f*fB0 ) + v*(  fA01*u+fA11*v+2.0f*fB1 )+fC;
           }
           }
           }
           }
          
           return fabsf(  SqrDist ) < mRadius2;
          }

./components/ogre/ogreopcode/include/Opcode/OPC_SweepAndPrune.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains an implementation of the sweep-and-prune algorithm (  moved from Z-Collide )
           * \file OPC_SweepAndPrune.h
           * \author Pierre Terdiman
           * \date January,   29,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_SWEEPANDPRUNE_H__
          #define __OPC_SWEEPANDPRUNE_H__
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * User-callback,   called by OPCODE for each colliding pairs.
           * \param id0 [in] id of colliding object
           * \param id1 [in] id of colliding object
           * \param user_data [in] user-defined data
           * \return TRUE to continue enumeration
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           typedef BOOL (  *PairCallback ) (  udword id0,   udword id1,   void* user_data );
          
      34   class SAP_Element;
      35   class SAP_EndPoint;
      36   class SAP_Box;
          
      38   class SAP_PairData
           {
           public:
      41   SAP_PairData(   );
      42   ~SAP_PairData(   );
          
      44   bool Init(  udword nb_objects );
          
      46   void AddPair(  udword id1,   udword id2 );
      47   void RemovePair(  udword id1,   udword id2 );
          
      49   void DumpPairs(  Pairs& pairs ) const;
      50   void DumpPairs(  PairCallback callback,   void* user_data ) const;
           private:
      52   udword mNbElements; //!< Total number of elements in the pool
      53   udword mNbUsedElements; //!< Number of used elements
      54   SAP_Element* mElementPool; //!< Array of mNbElements elements
      55   SAP_Element* mFirstFree; //!< First free element in the pool
          
      57   udword mNbObjects; //!< Max number of objects we can handle
      58   SAP_Element** mArray; //!< Pointers to pool
           // Internal methods
      60   SAP_Element* GetFreeElem(  udword id,   SAP_Element* next,   udword* remap=null );
           inline_ void FreeElem(  SAP_Element* elem );
           void Release(   );
           };
          
      65   class SweepAndPrune
           {
           public:
      68   SweepAndPrune(   );
      69   ~SweepAndPrune(   );
          
      71   bool Init(  udword nb_objects,   const IceMaths::AABB** boxes );
      72   bool UpdateObject(  udword i,   const IceMaths::AABB& box );
          
      74   void GetPairs(  Pairs& pairs ) const;
      75   void GetPairs(  PairCallback callback,   void* user_data ) const;
           private:
      77   SAP_PairData mPairs;
          
      79   udword mNbObjects;
      80   SAP_Box* mBoxes;
      81   SAP_EndPoint* mList[3];
           // Internal methods
      83   bool CheckListsIntegrity(   );
           };
          
          #endif //__OPC_SWEEPANDPRUNE_H__

./components/ogre/ogreopcode/include/Opcode/OPC_TreeBuilders.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for tree builders.
           * \file OPC_TreeBuilders.h
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_TREEBUILDERS_H__
          #define __OPC_TREEBUILDERS_H__
          
           //! Tree splitting rules
           enum SplittingRules
           {
           // Primitive split
           SPLIT_LARGEST_AXIS = (  1<<0 ),   //!< Split along the largest axis
           SPLIT_SPLATTER_POINTS = (  1<<1 ),   //!< Splatter primitive centers (  QuickCD-style )
           SPLIT_BEST_AXIS = (  1<<2 ),   //!< Try largest axis,   then second,   then last
           SPLIT_BALANCED = (  1<<3 ),   //!< Try to keep a well-balanced tree
           SPLIT_FIFTY = (  1<<4 ),   //!< Arbitrary 50-50 split
           // Node split
           SPLIT_GEOM_CENTER = (  1<<5 ),   //!< Split at geometric center (  else split in the middle )
           //
           SPLIT_FORCE_DWORD = 0x7fffffff
           };
          
           //! Simple wrapper around build-related settings [Opcode 1.3]
           struct BuildSettings
           {
           inline_ BuildSettings(   ) : mLimit(  1 ),   mRules(  SPLIT_FORCE_DWORD ) {}
          
           udword mLimit; //!< Limit number of primitives / node. If limit is 1,   build a complete tree (  2*N-1 nodes )
           udword mRules; //!< Building/Splitting rules (  a combination of SplittingRules flags )
           };
          
      47   class AABBTreeBuilder
           {
           public:
           //! Constructor
      51   AABBTreeBuilder(   ) :
           mNbPrimitives(  0 ),  
           mNodeBase(  null ),  
           mCount(  0 ),  
           mNbInvalidSplits(  0 ) {}
           //! Destructor
      57   virtual ~AABBTreeBuilder(   ) {}
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes the AABB of a set of primitives.
           * \param primitives [in] list of indices of primitives
           * \param nb_prims [in] number of indices
           * \param global_box [out] global AABB enclosing the set of input primitives
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      68   virtual bool ComputeGlobalBox(  const udword* primitives,   udword nb_prims,   IceMaths::AABB& global_box ) const = 0;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes the splitting value along a given axis for a given primitive.
           * \param index [in] index of the primitive to split
           * \param axis [in] axis index (  0,  1,  2 )
           * \return splitting value
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      78   virtual float GetSplittingValue(  udword index,   udword axis ) const = 0;
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Computes the splitting value along a given axis for a given node.
           * \param primitives [in] list of indices of primitives
           * \param nb_prims [in] number of indices
           * \param global_box [in] global AABB enclosing the set of input primitives
           * \param axis [in] axis index (  0,  1,  2 )
           * \return splitting value
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      90   virtual float GetSplittingValue(  const udword* primitives,   udword nb_prims,   const IceMaths::AABB& global_box,   udword axis ) const
           {
           // Default split value = middle of the axis (  using only the box )
           return global_box.GetCenter(  axis );
           }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Validates node subdivision. This is called each time a node is considered for subdivision,   during tree building.
           * \param primitives [in] list of indices of primitives
           * \param nb_prims [in] number of indices
           * \param global_box [in] global AABB enclosing the set of input primitives
           * \return TRUE if the node should be subdivised
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     105   virtual BOOL ValidateSubdivision(  const udword* primitives,   udword nb_prims,   const IceMaths::AABB& global_box )
           {
           // Check the user-defined limit
           if(  nb_prims<=mSettings.mLimit ) return FALSE;
          
           return TRUE;
           }
          
           BuildSettings mSettings; //!< Splitting rules & split limit [Opcode 1.3]
     114   udword mNbPrimitives; //!< Total number of primitives.
           void* mNodeBase; //!< Address of node pool [Opcode 1.3]
           // Stats
           inline_ void SetCount(  udword nb ) { mCount=nb; }
     118   inline_ void IncreaseCount(  udword nb ) { mCount+=nb; }
     119   inline_ udword GetCount(   ) const { return mCount; }
     120   inline_ void SetNbInvalidSplits(  udword nb ) { mNbInvalidSplits=nb; }
     121   inline_ void IncreaseNbInvalidSplits(   ) { mNbInvalidSplits++; }
     122   inline_ udword GetNbInvalidSplits(   ) const { return mNbInvalidSplits; }
          
           private:
           udword mCount; //!< Stats: number of nodes created
           udword mNbInvalidSplits; //!< Stats: number of invalid splits
           };
          
           class AABBTreeOfVerticesBuilder : public AABBTreeBuilder
           {
           public:
           //! Constructor
           AABBTreeOfVerticesBuilder(   ) : mVertexArray(  null ) {}
           //! Destructor
           virtual ~AABBTreeOfVerticesBuilder(   ) {}
          
           override(  AABBTreeBuilder ) bool ComputeGlobalBox(  const udword* primitives,   udword nb_prims,   IceMaths::AABB& global_box ) const;
           override(  AABBTreeBuilder ) float GetSplittingValue(  udword index,   udword axis ) const;
           override(  AABBTreeBuilder ) float GetSplittingValue(  const udword* primitives,   udword nb_prims,   const IceMaths::AABB& global_box,   udword axis ) const;
          
           const IceMaths::Point* mVertexArray; //!< Shortcut to an app-controlled array of vertices.
           };
          
           class AABBTreeOfAABBsBuilder : public AABBTreeBuilder
           {
           public:
           //! Constructor
           AABBTreeOfAABBsBuilder(   ) : mAABBArray(  null ) {}
           //! Destructor
           virtual ~AABBTreeOfAABBsBuilder(   ) {}
          
           override(  AABBTreeBuilder ) bool ComputeGlobalBox(  const udword* primitives,   udword nb_prims,   IceMaths::AABB& global_box ) const;
           override(  AABBTreeBuilder ) float GetSplittingValue(  udword index,   udword axis ) const;
          
           const IceMaths::AABB* mAABBArray; //!< Shortcut to an app-controlled array of AABBs.
           };
          
           class AABBTreeOfTrianglesBuilder : public AABBTreeBuilder
           {
           public:
           //! Constructor
           AABBTreeOfTrianglesBuilder(   ) : mIMesh(  null ) {}
           //! Destructor
           virtual ~AABBTreeOfTrianglesBuilder(   ) {}
          
           override(  AABBTreeBuilder ) bool ComputeGlobalBox(  const udword* primitives,   udword nb_prims,   IceMaths::AABB& global_box ) const;
           override(  AABBTreeBuilder ) float GetSplittingValue(  udword index,   udword axis ) const;
           override(  AABBTreeBuilder ) float GetSplittingValue(  const udword* primitives,   udword nb_prims,   const IceMaths::AABB& global_box,   udword axis ) const;
          
           const MeshInterface* mIMesh; //!< Shortcut to an app-controlled mesh interface
           };
          
          #endif // __OPC_TREEBUILDERS_H__

./components/ogre/ogreopcode/include/Opcode/OPC_TreeCollider.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for a tree collider.
           * \file OPC_TreeCollider.h
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_TREECOLLIDER_H__
          #define __OPC_TREECOLLIDER_H__
          
           //! This structure holds cached information used by the algorithm.
           //! Two model pointers and two colliding primitives are cached. Model pointers are assigned
           //! to their respective meshes,   and the pair of colliding primitives is used for temporal
           //! coherence. That is,   in case temporal coherence is enabled,   those two primitives are
           //! tested for overlap before everything else. If they still collide,   we're done before
           //! even entering the recursive collision code.
           struct BVTCache : Pair
           {
           //! Constructor
           inline_ BVTCache(   )
           {
           ResetCache(   );
           ResetCountDown(   );
           }
          
           void ResetCache(   )
           {
           Model0 = null;
           Model1 = null;
           id0 = 0;
           id1 = 1;
          #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE !
           HullTest = true;
           SepVector.pid = 0;
           SepVector.qid = 0;
           SepVector.SV = Point(  1.0f,   0.0f,   0.0f );
          #endif // __MESHMERIZER_H__
           }
          
           void ResetCountDown(   )
           {
          #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE !
           CountDown = 50;
          #endif // __MESHMERIZER_H__
           }
          
           const Model* Model0; //!< Model for first object
           const Model* Model1; //!< Model for second object
          
          #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE !
           SVCache SepVector;
           udword CountDown;
           bool HullTest;
          #endif // __MESHMERIZER_H__
           };
          
      74   class AABBTreeCollider : public Collider
           {
           public:
           // Constructor / Destructor
      78   AABBTreeCollider(   );
      79   virtual ~AABBTreeCollider(   );
           // Generic collision query
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Generic collision query for generic OPCODE models. After the call,   access the results with:
           * - GetContactStatus(   )
           * - GetNbPairs(   )
           * - GetPairs(   )
           *
           * \param cache [in] collision cache for model pointers and a colliding pair of primitives
           * \param world0 [in] world matrix for first object,   or null
           * \param world1 [in] world matrix for second object,   or null
           * \return true if success
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      95   bool Collide(  BVTCache& cache,   const IceMaths::Matrix4x4* world0=null,   const IceMaths::Matrix4x4* world1=null );
          
           // Collision queries
      98   bool Collide(  const AABBCollisionTree* tree0,   const AABBCollisionTree* tree1,   const IceMaths::Matrix4x4* world0=null,   const IceMaths::Matrix4x4* world1=null,   Pair* cache=null );
      99   bool Collide(  const AABBNoLeafTree* tree0,   const AABBNoLeafTree* tree1,   const IceMaths::Matrix4x4* world0=null,   const IceMaths::Matrix4x4* world1=null,   Pair* cache=null );
     100   bool Collide(  const AABBQuantizedTree* tree0,   const AABBQuantizedTree* tree1,   const IceMaths::Matrix4x4* world0=null,   const IceMaths::Matrix4x4* world1=null,   Pair* cache=null );
     101   bool Collide(  const AABBQuantizedNoLeafTree* tree0,   const AABBQuantizedNoLeafTree* tree1,   const IceMaths::Matrix4x4* world0=null,   const IceMaths::Matrix4x4* world1=null,   Pair* cache=null );
           // Settings
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Settings: selects between full box-box tests or "SAT-lite" tests (  where Class III axes are discarded )
           * \param flag [in] true for full tests,   false for coarse tests
           * \see SetFullPrimBoxTest(  bool flag )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ void SetFullBoxBoxTest(  bool flag ) { mFullBoxBoxTest = flag; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Settings: selects between full triangle-box tests or "SAT-lite" tests (  where Class III axes are discarded )
           * \param flag [in] true for full tests,   false for coarse tests
           * \see SetFullBoxBoxTest(  bool flag )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     120   inline_ void SetFullPrimBoxTest(  bool flag ) { mFullPrimBoxTest = flag; }
          
           // Stats
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Stats: gets the number of BV-BV overlap tests after a collision query.
           * \see GetNbPrimPrimTests(   )
           * \see GetNbBVPrimTests(   )
           * \return the number of BV-BV tests performed during last query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     132   inline_ udword GetNbBVBVTests(   ) const { return mNbBVBVTests; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Stats: gets the number of Triangle-Triangle overlap tests after a collision query.
           * \see GetNbBVBVTests(   )
           * \see GetNbBVPrimTests(   )
           * \return the number of Triangle-Triangle tests performed during last query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     142   inline_ udword GetNbPrimPrimTests(   ) const { return mNbPrimPrimTests; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Stats: gets the number of BV-Triangle overlap tests after a collision query.
           * \see GetNbBVBVTests(   )
           * \see GetNbPrimPrimTests(   )
           * \return the number of BV-Triangle tests performed during last query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     152   inline_ udword GetNbBVPrimTests(   ) const { return mNbBVPrimTests; }
          
           // Data access
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the number of contacts after a collision query.
           * \see GetContactStatus(   )
           * \see GetPairs(   )
           * \return the number of contacts / colliding pairs.
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     164   inline_ udword GetNbPairs(   ) const { return mPairs.GetNbEntries(   )>>1; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the pairs of colliding triangles after a collision query.
           * \see GetContactStatus(   )
           * \see GetNbPairs(   )
           * \return the list of colliding pairs (  triangle indices )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     174   inline_ const Pair* GetPairs(   ) const { return (  const Pair* )mPairs.GetEntries(   ); }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Validates current settings. You should call this method after all the settings and callbacks have been defined for a collider.
           * \return null if everything is ok,   else a string describing the problem
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     182   override(  Collider ) const char* ValidateSettings(   );
          
           protected:
           // Colliding pairs
           IceCore::Container mPairs; //!< Pairs of colliding primitives
           // User mesh interfaces
           const MeshInterface* mIMesh0; //!< User-defined mesh interface for object0
           const MeshInterface* mIMesh1; //!< User-defined mesh interface for object1
           // Stats
           udword mNbBVBVTests; //!< Number of BV-BV tests
           udword mNbPrimPrimTests; //!< Number of Primitive-Primitive tests
           udword mNbBVPrimTests; //!< Number of BV-Primitive tests
           // Precomputed data
           IceMaths::Matrix3x3 mAR; //!< Absolute rotation matrix
           IceMaths::Matrix3x3 mR0to1; //!< Rotation from object0 to object1
           IceMaths::Matrix3x3 mR1to0; //!< Rotation from object1 to object0
           IceMaths::Point mT0to1; //!< Translation from object0 to object1
           IceMaths::Point mT1to0; //!< Translation from object1 to object0
           // Precomputed scale data
           IceMaths::Matrix3x3 mSR0to1; //!< Scale & rotation from object0 to object1 - before scale in object1
           IceMaths::Matrix3x3 mSR1to0; //!< Scale & rotation from object1 to object0 - before scale in object0
           IceMaths::Point mScale1; //!< Scale for object 1
           IceMaths::Point mScale0; //!< Scale for object 0
           // Dequantization coeffs
           IceMaths::Point mCenterCoeff0;
           IceMaths::Point mExtentsCoeff0;
           IceMaths::Point mCenterCoeff1;
           IceMaths::Point mExtentsCoeff1;
           // Leaf description
           IceMaths::Point mLeafVerts[3]; //!< Triangle vertices
           udword mLeafIndex; //!< Triangle index
           // Settings
           bool mFullBoxBoxTest; //!< Perform full BV-BV tests (  true ) or SAT-lite tests (  false )
           bool mFullPrimBoxTest; //!< Perform full Primitive-BV tests (  true ) or SAT-lite tests (  false )
           // Internal methods
          
           // Standard AABB trees
           void _Collide(  const AABBCollisionNode* b0,   const AABBCollisionNode* b1 );
           // Quantized AABB trees
           void _Collide(  const AABBQuantizedNode* b0,   const AABBQuantizedNode* b1,   const IceMaths::Point& a,   const IceMaths::Point& Pa,   const IceMaths::Point& b,   const IceMaths::Point& Pb );
           // No-leaf AABB trees
           void _CollideTriBox(  const AABBNoLeafNode* b );
           void _CollideBoxTri(  const AABBNoLeafNode* b );
           void _Collide(  const AABBNoLeafNode* a,   const AABBNoLeafNode* b );
           // Quantized no-leaf AABB trees
           void _CollideTriBox(  const AABBQuantizedNoLeafNode* b );
           void _CollideBoxTri(  const AABBQuantizedNoLeafNode* b );
           void _Collide(  const AABBQuantizedNoLeafNode* a,   const AABBQuantizedNoLeafNode* b );
           // Overlap tests
           void PrimTest(  udword id0,   udword id1 ); // OK
           inline_ void PrimTestTriIndex(  udword id1 ); // OK
           inline_ void PrimTestIndexTri(  udword id0 ); // OK
          
           inline_ BOOL BoxBoxOverlap(  const IceMaths::Point& ea,   const IceMaths::Point& ca,   const IceMaths::Point& eb,   const IceMaths::Point& cb ); // OK
           inline_ BOOL TriBoxOverlap(  const IceMaths::Point& center,   const IceMaths::Point& extents ); // OK
           inline_ BOOL TriTriOverlap(  const IceMaths::Point& V0,   const IceMaths::Point& V1,   const IceMaths::Point& V2,   const IceMaths::Point& U0,   const IceMaths::Point& U1,   const IceMaths::Point& U2 ); // OK
           // Init methods
           void InitQuery(  const IceMaths::Matrix4x4* world0=null,   const IceMaths::Matrix4x4* world1=null );
           bool CheckTemporalCoherence(  Pair* cache );
          
           inline_ BOOL Setup(  const MeshInterface* mi0,   const MeshInterface* mi1 )
           {
           mIMesh0 = mi0;
           mIMesh1 = mi1;
          
           if(  !mIMesh0 || !mIMesh1 ) return FALSE;
          
           return TRUE;
           }
           };
          
          #endif // __OPC_TREECOLLIDER_H__

./components/ogre/ogreopcode/include/Opcode/OPC_TriBoxOverlap.h

          
          //! This macro quickly finds the min & max values among 3 variables
          #define FINDMINMAX(  x0,   x1,   x2,   min,   max ) \
       4   min = max = x0; \
           if(  x1<min ) min=x1; \
           if(  x1>max ) max=x1; \
           if(  x2<min ) min=x2; \
           if(  x2>max ) max=x2;
          
          //! TO BE DOCUMENTED
          inline_ BOOL planeBoxOverlap(  const IceMaths::Point& normal,   const float d,   const IceMaths::Point& maxbox )
          {
           IceMaths::Point vmin,   vmax;
           for(  udword q=0;q<=2;q++ )
           {
           if(  normal[q]>0.0f ) { vmin[q]=-maxbox[q]; vmax[q]=maxbox[q]; }
           else { vmin[q]=maxbox[q]; vmax[q]=-maxbox[q]; }
           }
           if(  (  normal|vmin )+d>0.0f ) return FALSE;
           if(  (  normal|vmax )+d>=0.0f ) return TRUE;
          
           return FALSE;
          }
          
          //! TO BE DOCUMENTED
          #define AXISTEST_X01(  a,   b,   fa,   fb ) \
           min = a*v0.y - b*v0.z; \
           max = a*v2.y - b*v2.z; \
           if(  min>max ) {const float tmp=max; max=min; min=tmp; } \
           rad = fa * extents.y + fb * extents.z; \
           if(  min>rad || max<-rad ) return FALSE;
          
          //! TO BE DOCUMENTED
          #define AXISTEST_X2(  a,   b,   fa,   fb ) \
           min = a*v0.y - b*v0.z; \
           max = a*v1.y - b*v1.z; \
           if(  min>max ) {const float tmp=max; max=min; min=tmp; } \
           rad = fa * extents.y + fb * extents.z; \
           if(  min>rad || max<-rad ) return FALSE;
          
          //! TO BE DOCUMENTED
          #define AXISTEST_Y02(  a,   b,   fa,   fb ) \
           min = b*v0.z - a*v0.x; \
           max = b*v2.z - a*v2.x; \
           if(  min>max ) {const float tmp=max; max=min; min=tmp; } \
           rad = fa * extents.x + fb * extents.z; \
           if(  min>rad || max<-rad ) return FALSE;
          
          //! TO BE DOCUMENTED
          #define AXISTEST_Y1(  a,   b,   fa,   fb ) \
           min = b*v0.z - a*v0.x; \
           max = b*v1.z - a*v1.x; \
           if(  min>max ) {const float tmp=max; max=min; min=tmp; } \
           rad = fa * extents.x + fb * extents.z; \
           if(  min>rad || max<-rad ) return FALSE;
          
          //! TO BE DOCUMENTED
          #define AXISTEST_Z12(  a,   b,   fa,   fb ) \
           min = a*v1.x - b*v1.y; \
           max = a*v2.x - b*v2.y; \
           if(  min>max ) {const float tmp=max; max=min; min=tmp; } \
           rad = fa * extents.x + fb * extents.y; \
           if(  min>rad || max<-rad ) return FALSE;
          
          //! TO BE DOCUMENTED
          #define AXISTEST_Z0(  a,   b,   fa,   fb ) \
           min = a*v0.x - b*v0.y; \
           max = a*v1.x - b*v1.y; \
           if(  min>max ) {const float tmp=max; max=min; min=tmp; } \
           rad = fa * extents.x + fb * extents.y; \
           if(  min>rad || max<-rad ) return FALSE;
          
          // compute triangle edges
          // - edges lazy evaluated to take advantage of early exits
          // - fabs precomputed (  half less work,   possible since extents are always >0 )
          // - customized macros to take advantage of the null component
          // - axis vector discarded,   possibly saves useless movs
          #define IMPLEMENT_CLASS3_TESTS \
           float rad; \
           float min,   max; \
           \
           const float fey0 = fabsf(  e0.y ); \
           const float fez0 = fabsf(  e0.z ); \
           AXISTEST_X01(  e0.z,   e0.y,   fez0,   fey0 ); \
           const float fex0 = fabsf(  e0.x ); \
           AXISTEST_Y02(  e0.z,   e0.x,   fez0,   fex0 ); \
           AXISTEST_Z12(  e0.y,   e0.x,   fey0,   fex0 ); \
           \
           const float fey1 = fabsf(  e1.y ); \
           const float fez1 = fabsf(  e1.z ); \
           AXISTEST_X01(  e1.z,   e1.y,   fez1,   fey1 ); \
           const float fex1 = fabsf(  e1.x ); \
           AXISTEST_Y02(  e1.z,   e1.x,   fez1,   fex1 ); \
           AXISTEST_Z0(  e1.y,   e1.x,   fey1,   fex1 ); \
           \
           const IceMaths::Point e2 = mLeafVerts[0] - mLeafVerts[2]; \
           const float fey2 = fabsf(  e2.y ); \
           const float fez2 = fabsf(  e2.z ); \
           AXISTEST_X2(  e2.z,   e2.y,   fez2,   fey2 ); \
           const float fex2 = fabsf(  e2.x ); \
           AXISTEST_Y1(  e2.z,   e2.x,   fez2,   fex2 ); \
           AXISTEST_Z12(  e2.y,   e2.x,   fey2,   fex2 );
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Triangle-Box overlap test using the separating axis theorem.
           * This is the code from Tomas Möller,   a bit optimized:
           * - with some more lazy evaluation (  faster path on PC )
           * - with a tiny bit of assembly
           * - with "SAT-lite" applied if needed
           * - and perhaps with some more minor modifs...
           *
           * \param center [in] box center
           * \param extents [in] box extents
           * \return true if triangle & box overlap
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ BOOL AABBTreeCollider::TriBoxOverlap(  const IceMaths::Point& center,   const IceMaths::Point& extents )
          {
           // Stats
           mNbBVPrimTests++;
          
           // use separating axis theorem to test overlap between triangle and box
           // need to test for overlap in these directions:
           // 1 ) the {x,  y,  z}-directions (  actually,   since we use the AABB of the triangle
           // we do not even need to test these )
           // 2 ) normal of the triangle
           // 3 ) crossproduct(  edge from tri,   {x,  y,  z}-directin )
           // this gives 3x3=9 more tests
          
           // move everything so that the boxcenter is in (  0,  0,  0 )
           IceMaths::Point v0,   v1,   v2;
           v0.x = mLeafVerts[0].x - center.x;
           v1.x = mLeafVerts[1].x - center.x;
           v2.x = mLeafVerts[2].x - center.x;
          
           // First,   test overlap in the {x,  y,  z}-directions
          #ifdef OPC_USE_FCOMI
           // find min,   max of the triangle in x-direction,   and test for overlap in X
           if(  FCMin3(  v0.x,   v1.x,   v2.x )>extents.x ) return FALSE;
           if(  FCMax3(  v0.x,   v1.x,   v2.x )<-extents.x ) return FALSE;
          
           // same for Y
           v0.y = mLeafVerts[0].y - center.y;
           v1.y = mLeafVerts[1].y - center.y;
           v2.y = mLeafVerts[2].y - center.y;
          
           if(  FCMin3(  v0.y,   v1.y,   v2.y )>extents.y ) return FALSE;
           if(  FCMax3(  v0.y,   v1.y,   v2.y )<-extents.y ) return FALSE;
          
           // same for Z
           v0.z = mLeafVerts[0].z - center.z;
           v1.z = mLeafVerts[1].z - center.z;
           v2.z = mLeafVerts[2].z - center.z;
          
           if(  FCMin3(  v0.z,   v1.z,   v2.z )>extents.z ) return FALSE;
           if(  FCMax3(  v0.z,   v1.z,   v2.z )<-extents.z ) return FALSE;
          #else
           float min,  max;
           // Find min,   max of the triangle in x-direction,   and test for overlap in X
           FINDMINMAX(  v0.x,   v1.x,   v2.x,   min,   max );
           if(  min>extents.x || max<-extents.x ) return FALSE;
          
           // Same for Y
           v0.y = mLeafVerts[0].y - center.y;
           v1.y = mLeafVerts[1].y - center.y;
           v2.y = mLeafVerts[2].y - center.y;
          
           FINDMINMAX(  v0.y,   v1.y,   v2.y,   min,   max );
           if(  min>extents.y || max<-extents.y ) return FALSE;
          
           // Same for Z
           v0.z = mLeafVerts[0].z - center.z;
           v1.z = mLeafVerts[1].z - center.z;
           v2.z = mLeafVerts[2].z - center.z;
          
           FINDMINMAX(  v0.z,   v1.z,   v2.z,   min,   max );
           if(  min>extents.z || max<-extents.z ) return FALSE;
          #endif
           // 2 ) Test if the box intersects the plane of the triangle
           // compute plane equation of triangle: normal*x+d=0
           // ### could be precomputed since we use the same leaf triangle several times
           const IceMaths::Point e0 = v1 - v0;
           const IceMaths::Point e1 = v2 - v1;
           const IceMaths::Point normal = e0 ^ e1;
           const float d = -normal|v0;
           if(  !planeBoxOverlap(  normal,   d,   extents ) ) return FALSE;
          
           // 3 ) "Class III" tests
           if(  mFullPrimBoxTest )
           {
           IMPLEMENT_CLASS3_TESTS
           }
           return TRUE;
          }
          
          //! A dedicated version where the box is constant
          inline_ BOOL OBBCollider::TriBoxOverlap(   )
          {
           // Stats
           mNbVolumePrimTests++;
          
           // Hook
           const IceMaths::Point& extents = mBoxExtents;
           const IceMaths::Point& v0 = mLeafVerts[0];
           const IceMaths::Point& v1 = mLeafVerts[1];
           const IceMaths::Point& v2 = mLeafVerts[2];
          
           // use separating axis theorem to test overlap between triangle and box
           // need to test for overlap in these directions:
           // 1 ) the {x,  y,  z}-directions (  actually,   since we use the AABB of the triangle
           // we do not even need to test these )
           // 2 ) normal of the triangle
           // 3 ) crossproduct(  edge from tri,   {x,  y,  z}-directin )
           // this gives 3x3=9 more tests
          
           // Box center is already in (  0,  0,  0 )
          
           // First,   test overlap in the {x,  y,  z}-directions
          #ifdef OPC_USE_FCOMI
           // find min,   max of the triangle in x-direction,   and test for overlap in X
           if(  FCMin3(  v0.x,   v1.x,   v2.x )>mBoxExtents.x ) return FALSE;
           if(  FCMax3(  v0.x,   v1.x,   v2.x )<-mBoxExtents.x ) return FALSE;
          
           if(  FCMin3(  v0.y,   v1.y,   v2.y )>mBoxExtents.y ) return FALSE;
           if(  FCMax3(  v0.y,   v1.y,   v2.y )<-mBoxExtents.y ) return FALSE;
          
           if(  FCMin3(  v0.z,   v1.z,   v2.z )>mBoxExtents.z ) return FALSE;
           if(  FCMax3(  v0.z,   v1.z,   v2.z )<-mBoxExtents.z ) return FALSE;
          #else
           float min,  max;
           // Find min,   max of the triangle in x-direction,   and test for overlap in X
           FINDMINMAX(  v0.x,   v1.x,   v2.x,   min,   max );
           if(  min>mBoxExtents.x || max<-mBoxExtents.x ) return FALSE;
          
           FINDMINMAX(  v0.y,   v1.y,   v2.y,   min,   max );
           if(  min>mBoxExtents.y || max<-mBoxExtents.y ) return FALSE;
          
           FINDMINMAX(  v0.z,   v1.z,   v2.z,   min,   max );
           if(  min>mBoxExtents.z || max<-mBoxExtents.z ) return FALSE;
          #endif
           // 2 ) Test if the box intersects the plane of the triangle
           // compute plane equation of triangle: normal*x+d=0
           // ### could be precomputed since we use the same leaf triangle several times
           const IceMaths::Point e0 = v1 - v0;
           const IceMaths::Point e1 = v2 - v1;
           const IceMaths::Point normal = e0 ^ e1;
           const float d = -normal|v0;
           if(  !planeBoxOverlap(  normal,   d,   mBoxExtents ) ) return FALSE;
          
           // 3 ) "Class III" tests - here we always do full tests since the box is a primitive (  not a BV )
           {
           IMPLEMENT_CLASS3_TESTS
           }
           return TRUE;
          }
          
          //! ...and another one,   jeez
          inline_ BOOL AABBCollider::TriBoxOverlap(   )
          {
           // Stats
           mNbVolumePrimTests++;
          
           // Hook
           const IceMaths::Point& center = mBox.mCenter;
           const IceMaths::Point& extents = mBox.mExtents;
          
           // use separating axis theorem to test overlap between triangle and box
           // need to test for overlap in these directions:
           // 1 ) the {x,  y,  z}-directions (  actually,   since we use the AABB of the triangle
           // we do not even need to test these )
           // 2 ) normal of the triangle
           // 3 ) crossproduct(  edge from tri,   {x,  y,  z}-directin )
           // this gives 3x3=9 more tests
          
           // move everything so that the boxcenter is in (  0,  0,  0 )
           IceMaths::Point v0,   v1,   v2;
           v0.x = mLeafVerts[0].x - center.x;
           v1.x = mLeafVerts[1].x - center.x;
           v2.x = mLeafVerts[2].x - center.x;
          
           // First,   test overlap in the {x,  y,  z}-directions
          #ifdef OPC_USE_FCOMI
           // find min,   max of the triangle in x-direction,   and test for overlap in X
           if(  FCMin3(  v0.x,   v1.x,   v2.x )>extents.x ) return FALSE;
           if(  FCMax3(  v0.x,   v1.x,   v2.x )<-extents.x ) return FALSE;
          
           // same for Y
           v0.y = mLeafVerts[0].y - center.y;
           v1.y = mLeafVerts[1].y - center.y;
           v2.y = mLeafVerts[2].y - center.y;
          
           if(  FCMin3(  v0.y,   v1.y,   v2.y )>extents.y ) return FALSE;
           if(  FCMax3(  v0.y,   v1.y,   v2.y )<-extents.y ) return FALSE;
          
           // same for Z
           v0.z = mLeafVerts[0].z - center.z;
           v1.z = mLeafVerts[1].z - center.z;
           v2.z = mLeafVerts[2].z - center.z;
          
           if(  FCMin3(  v0.z,   v1.z,   v2.z )>extents.z ) return FALSE;
           if(  FCMax3(  v0.z,   v1.z,   v2.z )<-extents.z ) return FALSE;
          #else
           float min,  max;
           // Find min,   max of the triangle in x-direction,   and test for overlap in X
           FINDMINMAX(  v0.x,   v1.x,   v2.x,   min,   max );
           if(  min>extents.x || max<-extents.x ) return FALSE;
          
           // Same for Y
           v0.y = mLeafVerts[0].y - center.y;
           v1.y = mLeafVerts[1].y - center.y;
           v2.y = mLeafVerts[2].y - center.y;
          
           FINDMINMAX(  v0.y,   v1.y,   v2.y,   min,   max );
           if(  min>extents.y || max<-extents.y ) return FALSE;
          
           // Same for Z
           v0.z = mLeafVerts[0].z - center.z;
           v1.z = mLeafVerts[1].z - center.z;
           v2.z = mLeafVerts[2].z - center.z;
          
           FINDMINMAX(  v0.z,   v1.z,   v2.z,   min,   max );
           if(  min>extents.z || max<-extents.z ) return FALSE;
          #endif
           // 2 ) Test if the box intersects the plane of the triangle
           // compute plane equation of triangle: normal*x+d=0
           // ### could be precomputed since we use the same leaf triangle several times
           const IceMaths::Point e0 = v1 - v0;
           const IceMaths::Point e1 = v2 - v1;
           const IceMaths::Point normal = e0 ^ e1;
           const float d = -normal|v0;
           if(  !planeBoxOverlap(  normal,   d,   extents ) ) return FALSE;
          
           // 3 ) "Class III" tests - here we always do full tests since the box is a primitive (  not a BV )
           {
           IMPLEMENT_CLASS3_TESTS
           }
           return TRUE;
          }

./components/ogre/ogreopcode/include/Opcode/OPC_VolumeCollider.h

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains base volume collider class.
           * \file OPC_VolumeCollider.h
           * \author Pierre Terdiman
           * \date June,   2,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPC_VOLUMECOLLIDER_H__
          #define __OPC_VOLUMECOLLIDER_H__
          
           struct VolumeCache
           {
           VolumeCache(   ) : Model(  null ) {}
           ~VolumeCache(   ) {}
          
           IceCore::Container TouchedPrimitives; //!< Indices of touched primitives
           const BaseModel* Model; //!< Owner
           };
          
      32   class VolumeCollider : public Collider
           {
           public:
           // Constructor / Destructor
      36   VolumeCollider(   );
      37   virtual ~VolumeCollider(   ) = 0;
          
           // Collision report
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the number of touched primitives after a collision query.
           * \see GetContactStatus(   )
           * \see GetTouchedPrimitives(   )
           * \return the number of touched primitives
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           inline_ udword GetNbTouchedPrimitives(   ) const { return mTouchedPrimitives ? mTouchedPrimitives->GetNbEntries(   ) : 0; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Gets the list of touched primitives after a collision query.
           * \see GetContactStatus(   )
           * \see GetNbTouchedPrimitives(   )
           * \return the list of touched primitives (  primitive indices )
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      59   inline_ const udword* GetTouchedPrimitives(   ) const { return mTouchedPrimitives ? mTouchedPrimitives->GetEntries(   ) : null; }
          
           // Stats
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Stats: gets the number of Volume-BV overlap tests after a collision query.
           * \see GetNbVolumePrimTests(   )
           * \return the number of Volume-BV tests performed during last query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      70   inline_ udword GetNbVolumeBVTests(   ) const { return mNbVolumeBVTests; }
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Stats: gets the number of Volume-Triangle overlap tests after a collision query.
           * \see GetNbVolumeBVTests(   )
           * \return the number of Volume-Triangle tests performed during last query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      79   inline_ udword GetNbVolumePrimTests(   ) const { return mNbVolumePrimTests; }
          
           // Settings
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Validates current settings. You should call this method after all the settings / callbacks have been defined for a collider.
           * \return null if everything is ok,   else a string describing the problem
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      89   override(  Collider ) const char* ValidateSettings(   );
          
           protected:
           // Touched primitives
           IceCore::Container* mTouchedPrimitives; //!< List of touched primitives
           // Precompured scale cache
           IceMaths::Point mLocalScale; //!< Collision model's local scale (  stripped off from its matrix )
           // Dequantization coeffs
           IceMaths::Point mCenterCoeff;
           IceMaths::Point mExtentsCoeff;
           // Stats
           udword mNbVolumeBVTests; //!< Number of Volume-BV tests
           udword mNbVolumePrimTests; //!< Number of Volume-Primitive tests
           // Internal methods
           void _Dump(  const AABBCollisionNode* node );
           void _Dump(  const AABBNoLeafNode* node );
           void _Dump(  const AABBQuantizedNode* node );
           void _Dump(  const AABBQuantizedNoLeafNode* node );
          
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           /**
           * Initializes a query
           */
           ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           override(  Collider ) inline_ void InitQuery(   )
           {
           // Reset stats & contact status
           mNbVolumeBVTests = 0;
           mNbVolumePrimTests = 0;
           Collider::InitQuery(   );
           }
          
           inline_ BOOL IsCacheValid(  VolumeCache& cache )
           {
           // We're going to do a volume-vs-model query.
           if(  cache.Model!=mCurrentModel )
           {
           // Cached list was for another model so we can't keep it
           // Keep track of new owner and reset cache
           cache.Model = mCurrentModel;
           return FALSE;
           }
           else
           {
           // Same models,   no problem
           return TRUE;
           }
           }
           };
          
          #endif // __OPC_VOLUMECOLLIDER_H__

./components/ogre/ogreopcode/include/Opcode/Opcode.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Main file for Opcode.dll.
           * \file Opcode.h
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Include Guard
          #ifndef __OPCODE_H__
          #define __OPCODE_H__
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Things to help us compile on non-windows platforms
          
          #if defined(  __APPLE__ ) || defined(  __MACOSX__ )
          #if __APPLE_CC__ < 1495
          #define sqrtf sqrt
          #define sinf sin
          #define cosf cos
          #define acosf acos
          #define asinf sinf
          #endif
          #endif
          
          #ifndef _MSC_VER
          
          #ifndef __MINGW32__
          #define __int64 long long int
          #define __stdcall /* */
          #endif
          
          #endif
          
          // Turn deprecation warnings off when using VC8
          #if (  _MSC_VER >= 1400 )
          #pragma warning (  disable : 4996 )
          #ifndef _CRT_SECURE_NO_DEPRECATE
          #define _CRT_SECURE_NO_DEPRECATE 1
          #endif
          #ifndef _CRT_NONSTDC_NO_DEPRECATE
          #define _CRT_NONSTDC_NO_DEPRECATE 1
          #endif
          #endif //VC8
          
          /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          //// Compilation messages
          //#ifdef _MSC_VER
          // #if defined(  OPCODE_EXPORTS )
          // //#pragma message(  "Compiling OPCODE" )
          // #elif !defined(  OPCODE_EXPORTS )
          // //#pragma message(  "Using OPCODE" )
          // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // // Automatic linking
          // #ifndef BAN_OPCODE_AUTOLINK
          // #ifdef _DEBUG
          // #pragma comment(  lib,   "Opcode_d.lib" )
          // #else
          // #pragma comment(  lib,   "Opcode.lib" )
          // #endif
          // #endif
          // #endif
          //#endif
          //
          /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          //// Preprocessor
          //#ifdef _MSC_VER
          // #ifndef ICE_NO_DLL
          // #ifdef OPCODE_EXPORTS
          // #define __declspec(  dllexport )
          // #else
          // #define __declspec(  dllimport )
          // #endif
          // #else
          // #define OPCODE_API
          // #endif
          //#else
          // #define OPCODE_API
          //#endif
          
           #include "OPC_IceHook.h"
          
           namespace Opcode
           {
           // Bulk-of-the-work
           #include "OPC_Settings.h"
           #include "OPC_Common.h"
           #include "OPC_MeshInterface.h"
           // Builders
           #include "OPC_TreeBuilders.h"
           // Trees
           #include "OPC_AABBTree.h"
           #include "OPC_OptimizedTree.h"
           // Models
           #include "OPC_BaseModel.h"
           #include "OPC_Model.h"
           #include "OPC_HybridModel.h"
           // Colliders
           #include "OPC_Collider.h"
           #include "OPC_VolumeCollider.h"
           #include "OPC_TreeCollider.h"
           #include "OPC_RayCollider.h"
           #include "OPC_SphereCollider.h"
           #include "OPC_OBBCollider.h"
           #include "OPC_AABBCollider.h"
           #include "OPC_LSSCollider.h"
           #include "OPC_PlanesCollider.h"
           // Usages
           #include "OPC_Picking.h"
           // Sweep-and-prune
           #include "OPC_BoxPruning.h"
           #include "OPC_SweepAndPrune.h"
          
     124   FUNCTION bool InitOpcode(   );
     125   FUNCTION bool CloseOpcode(   );
           }
          
          #endif // __OPCODE_H__

./components/ogre/ogreopcode/include/Opcode/Stdafx.h

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          #if !defined(  AFX_STDAFX_H__EFB95044_1D31_11D5_8B0F_0050BAC83302__INCLUDED_ )
          #define AFX_STDAFX_H__EFB95044_1D31_11D5_8B0F_0050BAC83302__INCLUDED_
          
          #if _MSC_VER > 1000
          #pragma once
          #endif // _MSC_VER > 1000
          
          // Insert your headers here
          #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
          
          #include "Opcode/Opcode.h"
          
          //{{AFX_INSERT_LOCATION}}
          // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
          
          #endif // !defined(  AFX_STDAFX_H__EFB95044_1D31_11D5_8B0F_0050BAC83302__INCLUDED_ )

./components/ogre/ogreopcode/src/BP_Endpoint.cpp

       1  /*
          * SOLID - Software Library for Interference Detection
          * Copyright (  c ) 2001 Dtecta <gino@dtecta.com>
          *
          * All rights reserved.
          */
          
          #include <assert.h>
          #include <new>
          #include "BP_Endpoint.h"
          #include "BP_Proxy.h"
          #include "BP_Scene.h"
          
          namespace OgreOpcode
          {
           namespace Details
           {
          
      19   BP_Endpoint::BP_Endpoint(  Ogre::Real pos,   Type type,   BP_Proxy *proxy,  
      20   GEN_List& endpointList ) :
           m_pos(  pos ),   m_type(  type ),   m_proxy(  proxy )
           {
           GEN_Link *next = endpointList.getHead(   );
          
           while (  !next->isTail(   ) && (  *(  BP_Endpoint * )next < *this ) ) {
           next = next->getNext(   );
           }
           insertBefore(  next );
           }
          
      31   BP_Endpoint::~BP_Endpoint(   )
           {
           if (  m_proxy != 0 ) {
           remove(   );
           }
           }
          
      38   void encounters(  const BP_Endpoint& a,   const BP_Endpoint& b,  
           BP_Scene& scene,   T_Overlap overlap )
           {
           assert(  a.m_proxy != b.m_proxy );
          
           if (  (  a.m_type != b.m_type ) && overlap(  *a.m_proxy,   *b.m_proxy ) ) {
           if (  a.m_type == BP_Endpoint::MAXIMUM ) {
           scene.callBeginOverlap(  a.m_proxy->getObject(   ),  
           b.m_proxy->getObject(   ) );
           }
           else {
           scene.callEndOverlap(  a.m_proxy->getObject(   ),  
           b.m_proxy->getObject(   ) );
           }
           }
           }
          
      55   void BP_Endpoint::move(  Ogre::Real x,   BP_Scene& scene,   T_Overlap overlap )
           {
           int sign = MT_sign(  x - m_pos );
          
           m_pos = x;
          
           switch (  sign ) {
           case -1: {
           GEN_Link *prev = getPrev(   );
           if (  !prev->isHead(   ) && (  *this < *(  BP_Endpoint * )prev ) ) {
           remove(   );
           do {
           encounters(  *(  BP_Endpoint * )prev,   *this,   scene,   overlap );
           prev = prev->getPrev(   );
           }
           while (  !prev->isHead(   ) && (  *this < *(  BP_Endpoint * )prev ) );
           insertAfter(  prev );
           }
           break;
           }
           case 1: {
           GEN_Link *next = getNext(   );
           if (  !next->isTail(   ) && (  *(  BP_Endpoint * )next < *this ) ) {
           remove(   );
           do {
           encounters(  *this,   *(  BP_Endpoint * )next,   scene,   overlap );
           next = next->getNext(   );
           }
           while (  !next->isTail(   ) && (  *(  BP_Endpoint * )next < *this ) );
           insertBefore(  next );
           }
           break;
           }
           case 0:
           // nothing to do
           break;
           default:
           assert(  false );
           }
           }
          
           }
          }
          
          
          
          
          

./components/ogre/ogreopcode/src/BP_Proxy.cpp

       1  /*
          * SOLID - Software Library for Interference Detection
          * Copyright (  c ) 2001 Dtecta <gino@dtecta.com>
          *
          * All rights reserved.
          */
          
          #include <new>
          
          #include "BP_Proxy.h"
          #include "BP_Scene.h"
          
          namespace OgreOpcode
          {
           namespace Details
           {
          
      18   BP_Proxy::BP_Proxy(  void *object,   BP_Scene& scene,  
      19   const Ogre::Vector3& min,  
      20   const Ogre::Vector3& max ) :
           m_object(  object ),  
           m_scene(  scene )
           {
           int i;
           for (  i = 0; i < 3; ++i ) {
           new (  &m_min[i] ) BP_Endpoint(  min[i],   BP_Endpoint::MINIMUM,  
           this,   scene.getLists(   )[i] );
           new (  &m_max[i] ) BP_Endpoint(  max[i],   BP_Endpoint::MAXIMUM,  
           this,   scene.getLists(   )[i] );
           }
           }
          
      33   bool overlapXY(  const BP_Proxy& a,   const BP_Proxy& b )
           {
           return a.getMin(  0 ) <= b.getMax(  0 ) && b.getMin(  0 ) <= a.getMax(  0 ) &&
           a.getMin(  1 ) <= b.getMax(  1 ) && b.getMin(  1 ) <= a.getMax(  1 );
           }
          
      39   bool overlapXZ(  const BP_Proxy& a,   const BP_Proxy& b )
           {
           return a.getMin(  0 ) <= b.getMax(  0 ) && b.getMin(  0 ) <= a.getMax(  0 ) &&
           a.getMin(  2 ) <= b.getMax(  2 ) && b.getMin(  2 ) <= a.getMax(  2 );
           }
          
      45   bool overlapYZ(  const BP_Proxy& a,   const BP_Proxy& b )
           {
           return a.getMin(  1 ) <= b.getMax(  1 ) && b.getMin(  1 ) <= a.getMax(  1 ) &&
           a.getMin(  2 ) <= b.getMax(  2 ) && b.getMin(  2 ) <= a.getMax(  2 );
           }
          
      51   void BP_Proxy::setBBox(  const Ogre::Vector3& min,   const Ogre::Vector3& max )
           {
           static T_Overlap overlap[3] = { overlapYZ,   overlapXZ,   overlapXY };
          
           int i;
           for (  i = 0; i < 3; ++i ) {
           if (  min[i] > m_max[i].getPos(   ) ) {
           m_max[i].move(  max[i],   m_scene,   overlap[i] );
           m_min[i].move(  min[i],   m_scene,   overlap[i] );
           }
           else {
           m_min[i].move(  min[i],   m_scene,   overlap[i] );
           m_max[i].move(  max[i],   m_scene,   overlap[i] );
           }
           }
           }
          
           }
          }
          
          
          

./components/ogre/ogreopcode/src/BP_Scene.cpp

       1  /*
          * SOLID - Software Library for Interference Detection
          * Copyright (  c ) 2001 Dtecta <gino@dtecta.com>
          *
          * All rights reserved.
          */
          
          #include "BP_Scene.h"
          #include "BP_Proxy.h"
          
          #include <algorithm>
          
          namespace OgreOpcode
          {
           namespace Details
           {
          
      18   BP_Scene::~BP_Scene(   )
           {
           T_ProxyList::iterator i;
           for (  i = m_proxyList.begin(   ); !(  i == m_proxyList.end(   ) ); ++i ) {
           delete *i;
           }
           }
          
          
      27   BP_Proxy *BP_Scene::createProxy(  void *object,  
      28   const Ogre::Vector3& min,  
      29   const Ogre::Vector3& max )
           {
           BP_Proxy *proxy = new BP_Proxy(  object,   *this,   min,   max );
          
           T_ProxyList::iterator i;
           for (  i = m_proxyList.begin(   ); !(  i == m_proxyList.end(   ) ); ++i ) {
           if (  BP_overlap(  *proxy,   *(  *i ) ) ) {
           callBeginOverlap(  proxy->getObject(   ),   (  *i )->getObject(   ) );
           }
           }
          
           m_proxyList.push_back(  proxy );
          
           return proxy;
           }
          
      45   void BP_Scene::deleteProxy(  BP_Proxy *proxy )
           {
           T_ProxyList::iterator i =
           std::find(  m_proxyList.begin(   ),   m_proxyList.end(   ),   proxy );
          
           if (  i != m_proxyList.end(   ) ) {
           m_proxyList.erase(  i );
          
           T_ProxyList::iterator j;
           for (  j = m_proxyList.begin(   ); !(  j == m_proxyList.end(   ) ); ++j ) {
           if (  BP_overlap(  *proxy,   *(  *j ) ) ) {
           callEndOverlap(  proxy->getObject(   ),   (  *j )->getObject(   ) );
           }
           }
          
           delete proxy;
           }
           }
           }
          }

./components/ogre/ogreopcode/src/IOgreCollisionShape.cpp

          ///////////////////////////////////////////////////////////////////////////////
          /// @file IOgreCollisionShape.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeExports.h"
          #include "IOgreCollisionShape.h"
          #include "OgreCollisionReporter.h"
          #include "OgreCollisionManager.h"
          #include "OgreOpcodeMath.h"
          #include "OgreOpcodeUtils.h"
          
          using namespace Ogre;
          using namespace OgreOpcode::Details;
          namespace OgreOpcode
          {
           namespace Details
           {
           template<class NodeT>
      42   inline void GetOpcodeNodeCenter(  const NodeT &n,   Vector3 &ctr )
           {
           ctr.x = n.mAABB.mCenter.x;
           ctr.y = n.mAABB.mCenter.y;
           ctr.z = n.mAABB.mCenter.z;
           }
           template<class TreeT,   class NodeT>
      49   inline void GetOpcodeQuantizedNodeCenter(  const TreeT &tree,   const NodeT &n,   Vector3 &ctr )
           {
           ctr = Vector3(  float(  n.mAABB.mCenter[0] ),   float(  n.mAABB.mCenter[1] ),   float(  n.mAABB.mCenter[2] ) );
           ctr.x *= tree.mCenterCoeff.x;
           ctr.y *= tree.mCenterCoeff.y;
           ctr.z *= tree.mCenterCoeff.z;
           }
           template<class NodeT>
      57   inline void GetOpcodeNodeMinMaxBox(  const NodeT &n,   Vector3 &bmin,   Vector3 &bMax )
           {
           Vector3 center(  n.mAABB.mCenter.x,   n.mAABB.mCenter.y,   n.mAABB.mCenter.z );
           Vector3 extent(  n.mAABB.mExtents.x,   n.mAABB.mExtents.y,   n.mAABB.mExtents.z );
          
           bmin = center;
           bmin -= extent;
           bMax = center;
           bMax += extent;
           }
           template<class TreeT,   class NodeT>
      68   inline void GetOpcodeQuantizedNodeMinMaxBox(  const TreeT &tree,   const NodeT &n,   Vector3 &bmin,   Vector3 &bMax )
           {
           Vector3 center(  float(  n.mAABB.mCenter[0] ),   float(  n.mAABB.mCenter[1] ),   float(  n.mAABB.mCenter[2] ) );
           Vector3 extent(  float(  n.mAABB.mExtents[0] ),   float(  n.mAABB.mExtents[1] ),   float(  n.mAABB.mExtents[2] ) );
          
           extent.x *= tree.mExtentsCoeff.x;
           extent.y *= tree.mExtentsCoeff.y;
           extent.z *= tree.mExtentsCoeff.z;
          
           center.x *= tree.mCenterCoeff.x;
           center.y *= tree.mCenterCoeff.y;
           center.z *= tree.mCenterCoeff.z;
          
           bmin = center;
           bmin -= extent;
           bMax = center;
           bMax += extent;
           }
          
      87   inline void GetOpcodeRootCenter(  const Opcode::Model &mdl,   Vector3 &ctr )
           {
           if (  mdl.IsQuantized(   ) ) {
           if (  mdl.HasLeafNodes(   ) ) {
           const Opcode::AABBQuantizedTree& tree = *static_cast<const Opcode::AABBQuantizedTree*>(  mdl.GetTree(   ) );
           GetOpcodeQuantizedNodeCenter(  tree,   *tree.GetNodes(   ),   ctr );
           }
           else{
           const Opcode::AABBQuantizedNoLeafTree& tree = *static_cast<const Opcode::AABBQuantizedNoLeafTree*>(  mdl.GetTree(   ) );
           GetOpcodeQuantizedNodeCenter(  tree,   *tree.GetNodes(   ),   ctr );
           }
           }
           else{
           if (  mdl.HasLeafNodes(   ) ) {
           const Opcode::AABBCollisionNode& root = *static_cast<const Opcode::AABBCollisionTree*>(  mdl.GetTree(   ) )->GetNodes(   );
           GetOpcodeNodeCenter(  root,   ctr );
           }
           else{
           const Opcode::AABBNoLeafNode& root = *static_cast<const Opcode::AABBNoLeafTree*>(  mdl.GetTree(   ) )->GetNodes(   );
           GetOpcodeNodeCenter(  root,   ctr );
           }
           }
           }
     110   inline void GetOpcodeRootMinMaxBox(  const Opcode::Model &mdl,   Vector3 &bmin,   Vector3 &bMax )
           {
           if (  mdl.IsQuantized(   ) ) {
           if (  mdl.HasLeafNodes(   ) ) {
           const Opcode::AABBQuantizedTree& tree = *static_cast<const Opcode::AABBQuantizedTree*>(  mdl.GetTree(   ) );
           GetOpcodeQuantizedNodeMinMaxBox(  tree,   *tree.GetNodes(   ),   bmin,   bMax );
           }
           else{
           const Opcode::AABBQuantizedNoLeafTree& tree = *static_cast<const Opcode::AABBQuantizedNoLeafTree*>(  mdl.GetTree(   ) );
           GetOpcodeQuantizedNodeMinMaxBox(  tree,   *tree.GetNodes(   ),   bmin,   bMax );
           }
           }
           else{
           if (  mdl.HasLeafNodes(   ) ) {
           const Opcode::AABBCollisionNode& root = *static_cast<const Opcode::AABBCollisionTree*>(  mdl.GetTree(   ) )->GetNodes(   );
           GetOpcodeNodeMinMaxBox(  root,   bmin,   bMax );
           }
           else{
           const Opcode::AABBNoLeafNode& root = *static_cast<const Opcode::AABBNoLeafTree*>(  mdl.GetTree(   ) )->GetNodes(   );
           GetOpcodeNodeMinMaxBox(  root,   bmin,   bMax );
           }
           }
           }
           } // Details
           //------------------------------------------------------------------------
     135   Ogre::String& ICollisionShape::getName(   )
           {
           return mName;
           }
           //------------------------------------------------------------------------
     140   Vector3& ICollisionShape::getCenter(   )
           {
           // World space center
           const Matrix4 &m = getFullTransform(   );
           GetOpcodeRootCenter(  opcModel,   mCenter );
           mCenter = m * mCenter;
           return mCenter;
           }
           //------------------------------------------------------------------------
     149   Vector3& ICollisionShape::getLocalCenter(   )
           {
           // Object space center
           GetOpcodeRootCenter(  opcModel,   mLocalCenter );
           return mLocalCenter;
           }
           //------------------------------------------------------------------------
     156   void ICollisionShape::getMinMax(  Vector3& bMin,   Vector3& bMax ) const
           {
           // Compute the tightest world space box around the current opcode AABB tree
           const Matrix4 &m = getFullTransform(   );
           Vector3 lMin,  lMax;
           GetOpcodeRootMinMaxBox(  opcModel,   lMin,   lMax );
           bMax = bMin = m * lMin;
           Vector3 v;
           v=m*Vector3(  lMin.x,  lMin.y,  lMin.z ); bMin.makeFloor(  v ); bMax.makeCeil(  v );
           v=m*Vector3(  lMin.x,  lMin.y,  lMax.z ); bMin.makeFloor(  v ); bMax.makeCeil(  v );
           v=m*Vector3(  lMin.x,  lMax.y,  lMin.z ); bMin.makeFloor(  v ); bMax.makeCeil(  v );
           v=m*Vector3(  lMin.x,  lMax.y,  lMax.z ); bMin.makeFloor(  v ); bMax.makeCeil(  v );
           v=m*Vector3(  lMax.x,  lMin.y,  lMin.z ); bMin.makeFloor(  v ); bMax.makeCeil(  v );
           v=m*Vector3(  lMax.x,  lMin.y,  lMax.z ); bMin.makeFloor(  v ); bMax.makeCeil(  v );
           v=m*Vector3(  lMax.x,  lMax.y,  lMin.z ); bMin.makeFloor(  v ); bMax.makeCeil(  v );
           v=m*Vector3(  lMax.x,  lMax.y,  lMax.z ); bMin.makeFloor(  v ); bMax.makeCeil(  v );
           }
           //------------------------------------------------------------------------
     174   void ICollisionShape::getLocalMinMax(  Vector3& lMin,   Vector3& lMax ) const
           {
           // Get the local object space box around the current opcode AABB tree
           GetOpcodeRootMinMaxBox(  opcModel,   lMin,   lMax );
           }
           //------------------------------------------------------------------------
     180   void ICollisionShape::calculateSize(   )
           {
           // This just calcs the radius. The world AABB has to be computed on demand
           // because it depends on the current parent node transform.
           // But the radius is the radius no matter what.
           Vector3 lMin,  lMax;
           getMinMax(  lMin,  lMax );
           lMax-=lMin;
           mRadius = lMax.length(   )*0.5;
           }
          
           //void ICollisionShape::computeIceABB(   )
           //{
           // Vector3 vA,   vB;
           // getMinMax(  vA,  vB );
           // mIceABB->SetMinMax(  IceMaths::Point(  vA.x,   vA.y,   vA.z ),   IceMaths::Point(  vB.x,   vB.y,   vB.z ) );
           //}
          
           //------------------------------------------------------------------------
           //IceMaths::AABB* ICollisionShape::getIceABB(  void ) const
           //{
           // return mIceABB;
           //}
           //------------------------------------------------------------------------
     204   ICollisionShape::ICollisionShape(  const Ogre::String& name )
           : mInitialized(  false ),  
           mShapeIsStatic(  false ),  
           mHasCostumTransform(  false ),  
           mDoVisualizeAABBNodes(  false ),  
           mName(  name ),  
           mRadius(  0.0f ),  
     211   numVertices(  0 ),  
           numFaces(  0 ),  
           mVertexBuf(  0 ),  
           mFaceBuf(  0 ),  
           mFullTransform(  Matrix4::IDENTITY ),  
           mLocalTransform(  Matrix4::IDENTITY ),  
           mActiveDebugger(  0 ),  
           mRefitCounter(  0 ),  
           mNumFramesPerRefit(  0 ),  
           mParentNode(  0 )
           {
           //mIceABB = new IceMaths::AABB(   );
           //mIceABB->SetEmpty(   );
           // initialize pointers to global OPCODE objects
           opcTreeCache = &(  CollisionManager::getSingletonPtr(   )->opcTreeCache );
           opcFaceCache = &(  CollisionManager::getSingletonPtr(   )->opcFaceCache );
           mDebugObject = new ManualObject(  "__OgreOpcode__Debugger__" + mName );
           }
          
           //------------------------------------------------------------------------
     231   ICollisionShape::~ICollisionShape(   )
           {
           //delete mIceABB;
           //if(  mDebugObject->isAttached(   ) )
           // mDebugObject->getParentSceneNode(   )->detachObject(  mDebugObject->getName(   ) );
           delete mDebugObject;
           }
          
     239   void ICollisionShape::update(  Ogre::Real dt )
           {
           if(   mNumFramesPerRefit > 0  )
           {
           ++mRefitCounter;
           if(   mRefitCounter >= mNumFramesPerRefit  )
           {
           refit(   );
           mRefitCounter = 0;
           }
           }
           }
          
     252   int ICollisionShape::getRefitRate(   )
           {
           return mNumFramesPerRefit;
           }
          
     257   void ICollisionShape::setRefitRate(  unsigned int NumFramesPerRefit )
           {
           mNumFramesPerRefit = NumFramesPerRefit;
           }
          
     262   Matrix4 ICollisionShape::getFullTransform(  void ) const
           {
           if(  !mHasCostumTransform )
           {
           getParentSceneNode(   )->_update(  true,   true );
           getParentSceneNode(   )->getWorldTransforms(  &mFullTransform );
           }
           return mFullTransform;
           }
          
     272   Matrix4& ICollisionShape::getLocalTransform(  void ) const
           {
           if(  !mHasCostumTransform )
           {
           mLocalTransform = mFullTransform.inverse(   );
           }
           return mLocalTransform;
           }
          
           //------------------------------------------------------------------------
           /// set a costum transform.
           /// @param newTransform Matrix4 The matrix you want the shape to be transformed by.
     284   void ICollisionShape::setTransform(  const Matrix4 newTransform )
           {
           mLocalTransform = mFullTransform = newTransform;
           mHasCostumTransform = true;
           }
          
          
           //------------------------------------------------------------------------
           /// perform collision with other ICollisionShape.
           /// @param collType CollisionType Collision type.
           /// @param ownMatrix Matrix4 Own matrix.
           /// @param otherShape ICollisionShape Shape to test against.
           /// @param otherMatrix Matrix4 Other matrix.
           /// @param collPair CollisionPair Collision report.
           /// @return bool return true on collision.
     299   bool ICollisionShape::collide(  CollisionType collType,   Matrix4& ownMatrix,   ICollisionShape* otherShape,   Matrix4& otherMatrix,   CollisionPair& collPair )
           {
           assert(  otherShape );
           assert(  (  collType == COLLTYPE_EXACT ) || (  collType == COLLTYPE_CONTACT ) );
          
           ICollisionShape* opcodeOther = otherShape;
           Opcode::AABBTreeCollider& collider = CollisionManager::getSingletonPtr(   )->opcTreeCollider;
          
           if (  collType == COLLTYPE_EXACT )
           {
           collider.SetFirstContact(  false );
           }
           else
           {
           collider.SetFirstContact(  true );
           }
          
           // setup the bvt cache
           opcTreeCache->Model0 = &(  opcModel );
           opcTreeCache->Model1 = &(  opcodeOther->opcModel );
          
           // convert Matrix4's into Matrix4x4's
           IceMaths::Matrix4x4 m0,   m1;
          
           OgreOpcodeUtils::ogreToIceMatrix4(   ownMatrix,   m0 );
           OgreOpcodeUtils::ogreToIceMatrix4(   otherMatrix,   m1 );
          
           // validate settings: asserts that we can check collision
           // another option is to display some annoying error windows using: Ogre::String(  collider.ValidateSettings(   )  )
           assert(   collider.ValidateSettings(   ) == 0  );
          
           // perform collision test and checks errors
           if(   !collider.Collide(  *(  opcTreeCache ),   &m0,   &m1 )  )
           return false;
          
           collPair.numBVBVTests = collider.GetNbBVBVTests(   );
           collPair.numBVPrimTests = collider.GetNbBVPrimTests(   );
           collPair.numPrimPrimTests = collider.GetNbPrimPrimTests(   );
          
           bool collided = false;
          
           // get the number of collided triangle pairs
           int numPairs = collider.GetNbPairs(   );
           //LogManager::getSingleton(   ).logMessage(  "Collisionshape had " + StringConverter::toString(  numPairs ) + " collisions." );
          
           if (   collider.GetContactStatus(   ) && numPairs > 0  )
           {
           collided = true;
          
           // get the list of collided triangles
           const Pair* pairs = collider.GetPairs(   );
          
           // clamp number of collisions to a reasonable amount
           if (  numPairs > 10 ) numPairs = 10;
           int i;
           Vector3 vThis0,   vThis1,   vThis2;
           Vector3 vOther0,   vOther1,   vOther2;
           for (  i = 0; i < numPairs; i++ )
           {
           // get the current contact triangle coordinates
           getTriCoords(  pairs[i].id0,   vThis0,   vThis1,   vThis2 );
           opcodeOther->getTriCoords(  pairs[i].id1,   vOther0,   vOther1,   vOther2 );
          
           // they are now in object space - transform to world space
           vThis0 = ownMatrix * vThis0;
           vThis1 = ownMatrix * vThis1;
           vThis2 = ownMatrix * vThis2;
           vOther0 = otherMatrix * vOther0;
           vOther1 = otherMatrix * vOther1;
           vOther2 = otherMatrix * vOther2;
          
           // calculate midpoints and normals in world space
           Vector3 thisCenter = (  vThis0+vThis1+vThis2 )*0.33333333333333333333f;
           Vector3 thisNormal = (  vThis1-vThis0 ).crossProduct(  vThis2-vThis0 );
           thisNormal.normalise(   );
           Vector3 otherCenter = (  vOther0+vOther1+vOther2 )*0.33333333333333333333f;
           Vector3 otherNormal = (  vOther1-vOther0 ).crossProduct(  vOther2-vOther0 );
           otherNormal.normalise(   );
          
           // fill out CollisionPair's CollisionInfo
           CollisionInfo collInfo;
           collInfo.contact = otherCenter;
           collInfo.this_contact = thisCenter;
           collInfo.other_contact = otherCenter;
           collInfo.this_normal = thisNormal;
           collInfo.other_normal = otherNormal;
          
           // fill triangle vertex info (  world space )
           collInfo.this_tri_verts[0] = vThis0;
           collInfo.this_tri_verts[1] = vThis1;
           collInfo.this_tri_verts[2] = vThis2;
           collInfo.other_tri_verts[0] = vOther0;
           collInfo.other_tri_verts[1] = vOther1;
           collInfo.other_tri_verts[2] = vOther2;
          
           collPair.collInfos.push_back(  collInfo );
          
           if(  0 == i ) // if this is the first contact
           {
           collPair.contact = otherCenter;
           collPair.this_contact = thisCenter;
           collPair.other_contact = otherCenter;
           collPair.this_normal = thisNormal;
           collPair.other_normal = otherNormal;
           }
           }
           }
          
           return collided;
           }
          
           //------------------------------------------------------------------------
           /// Check contact of line with shape.
           /// The collType is interpreted as follows:
           /// - COLLTYPE_IGNORE: illegal (  makes no sense )
           /// - COLLTYPE_QUICK: occlusion check only
           /// - COLLTYPE_CONTACT: return closest contact
           /// - COLLTYPE_EXACT: return a sorted list of contacts
           /// @param collType see above
           /// @param ownMatrix position/orientation of this shape
           /// @param line line definition in world space
           /// @param collPair will be filled with result
           /// @return true if line intersects shape
     422   bool ICollisionShape::rayCheck(  CollisionType collType,  
     423   const Matrix4& ownMatrix,  
     424   const Ogre::Ray& line,  
     425   const Real dist,  
     426   CollisionPair& collPair,   bool rayCulling )
           {
           assert(  COLLTYPE_IGNORE != collType );
          
           // setup ray collider
           Opcode::RayCollider& collider = CollisionManager::getSingletonPtr(   )->opcRayCollider;
           collider.SetMaxDist(  dist );
           collider.SetCulling(  rayCulling );
           collider.SetClosestHit(  true );
           switch (  collType )
           {
           case COLLTYPE_QUICK:
           case COLLTYPE_CONTACT:
           collider.SetFirstContact(  false );
           break;
          
           case COLLTYPE_EXACT:
           collider.SetFirstContact(  false );
           break;
          
           default:
           break;
           }
          
           // convert Matrix4 to Opcode Matrix4x4
           IceMaths::Matrix4x4 opcMatrix;
           IceMaths::Matrix4x4 *ptrOpcMatrix = &opcMatrix;
           // if model is in world space already (  local to world matrix,   ownMatrix,   is identity ),   then pass 0
           if (  ownMatrix == Matrix4::IDENTITY ) {
           ptrOpcMatrix = 0;
           } else {
           OgreOpcodeUtils::ogreToIceMatrix4(   ownMatrix,   opcMatrix );
           }
          
           // build Opcode ray from line
           IceMaths::Ray ray;
           OgreOpcodeUtils::ogreToIceRay(   line,   ray  );
          
           // validate settings: asserts that we can check collision
           // another option is to display some annoying error windows using: Ogre::String(  collider.ValidateSettings(   )  )
           assert(   collider.ValidateSettings(   ) == 0  );
          
           // perform collision
           if(   !collider.Collide(  ray,   opcModel,   ptrOpcMatrix )  )
           return false;
          
           collPair.numBVBVTests = collider.GetNbRayBVTests(   );
           collPair.numBVPrimTests = collider.GetNbRayPrimTests(   );
           collPair.numPrimPrimTests = 0;
          
           // get collision result
           if (  collider.GetContactStatus(   ) )
           {
           // fill out contact point and collision normal of closest contact
           const Opcode::CollisionFace* collFaces = opcFaceCache->GetFaces(   );
           int numFaces = opcFaceCache->GetNbFaces(   );
           if (  numFaces > 0 )
           {
           // if in closest hit mode,   find the contact with the smallest distance
           int collFaceIndex = 0;
           //if (  COLLTYPE_CONTACT )
           if (  1==1 ) // FIXME
           {
           int i;
           for (  i = 0; i < numFaces; i++ )
           {
           if (  collFaces[i].mDistance < collFaces[collFaceIndex].mDistance )
           {
           collFaceIndex = i;
           }
           }
           }
           int triangleIndex = collFaces[collFaceIndex].mFaceID;
           float thedist = collFaces[collFaceIndex].mDistance;
          
           // build triangle from from faceIndex
           Vector3 v0,  v1,  v2;
           getTriCoords(  triangleIndex,   v0,   v1,   v2 );
          
           //const Matrix4 &myMatrix = getFullTransform(   );
          
           // Compute the centered normal
           //Vector3 vCenter = (  v0+v1+v2 )*0.33333333333333333333f;
           Vector3 vNormal = (  v1-v0 ).crossProduct(  v2-v0 );
           vNormal.normalise(   );
          
           // Compute collision contact from barycentric coordinates
           Real mU = collFaces[0].mU;
           Real mV = collFaces[0].mV;
           Real mW = 1.0f - mU - mV;
           Vector3 vCenter(  Vector3::ZERO );
           vCenter.x = (  v0.x * mW ) + (  v1.x * mU ) + (  v2.x * mV );
           vCenter.y = (  v0.y * mW ) + (  v1.y * mU ) + (  v2.y * mV );
           vCenter.z = (  v0.z * mW ) + (  v1.z * mU ) + (  v2.z * mV );
          
           collPair.contact = ownMatrix * vCenter;//line.getOrigin(   ) + (  line.getDirection(   ).normalisedCopy(   ) * thedist );//myMatrix * vContact;//
           collPair.distance = thedist;
           collPair.this_normal = vNormal;
           collPair.other_normal = line.getDirection(   ).normalisedCopy(   );//-collPair.this_normal;
           CollisionInfo collInfo;
           collInfo.contact = collPair.contact;
           collInfo.distance = collPair.distance;
           collInfo.this_normal = collPair.this_normal;
           collInfo.other_normal = collPair.other_normal;
           collPair.collInfos.push_back(  collInfo );
          
           return true;
           }
           else
           {
           //n_printf(  "nOpcodeShape::rayCheck(   ): contact but no faces!\n" );
           return false;
           }
           }
           return false;
           }
          
           //------------------------------------------------------------------------
           /// Check contact of a line swept sphere with shape.
           /// The collType is interpreted as follows:
           /// - COLLTYPE_IGNORE: illegal (  makes no sense )
           /// - COLLTYPE_QUICK: first contact check only
           /// - COLLTYPE_CONTACT: return closest contact
           /// - COLLTYPE_EXACT: return a sorted list of contacts
           /// Currently,   sphere checks always work in first contact mode (  COLLTYPE_QUICK ).
           /// @param collType see above
           /// @param ownMatrix position/orientation of this shape
           /// @param ball sphere definition in world space
           /// @param collPair will be filled with result
           /// @return true if line intersects shape
     556   bool ICollisionShape::sweptSphereCheck(  CollisionType collType,  
     557   const Matrix4& ownMatrix,  
     558   const Vector3& position,  
     559   const Vector3& movementVector,  
     560   const Real& radius,  
     561   CollisionPair& collPair )
           {
           assert(  COLLTYPE_IGNORE != collType );
          
           // setup sphere collider
           Opcode::LSSCollider& collider = CollisionManager::getSingletonPtr(   )->opcSweptSphereCollider;
           Opcode::LSSCache& cache = CollisionManager::getSingletonPtr(   )->opcSweptSphereCache;
          
           switch (  collType )
           {
           case COLLTYPE_QUICK:
           case COLLTYPE_CONTACT:
           collider.SetFirstContact(  true );
           break;
          
           case COLLTYPE_EXACT:
           collider.SetFirstContact(  false );
           break;
          
           default:
           break;
           }
          
           // convert Matrix4 to Opcode Matrix4x4
           IceMaths::Matrix4x4 opcMatrix;
           IceMaths::Matrix4x4 *ptrOpcMatrix = &opcMatrix;
           OgreOpcodeUtils::ogreToIceMatrix4(   ownMatrix,   opcMatrix );
          
           // build identity matrix because sphere is already in world space
           IceMaths::Matrix4x4 identity;
           IceMaths::Matrix4x4 *ptrIdentity = &identity;
           identity.Identity(   );
          
           // validate settings: asserts that we can check collision
           // another option is to display some annoying error windows using: String(  collider.ValidateSettings(   )  )
           assert(   collider.ValidateSettings(   ) == 0  );
          
           IceMaths::Point startPoint;
           IceMaths::Point endPoint;
           OgreOpcodeUtils::ogreToIceVector3(  position,   startPoint );
           OgreOpcodeUtils::ogreToIceVector3(  position + movementVector,   endPoint );
           IceMaths::Segment opcSegment(  startPoint,   endPoint );
           IceMaths::LSS opcLSS(  opcSegment,   radius );
          
           // perform collision
           if(   !collider.Collide(  cache,   opcLSS,   opcModel,   ptrIdentity,   ptrOpcMatrix )  )
           return false;
          
           collPair.distance = movementVector.length(   );
          
           collPair.numBVBVTests = collider.GetNbVolumeBVTests(   );
           collPair.numBVPrimTests = collider.GetNbVolumePrimTests(   );
           collPair.numPrimPrimTests = 0;
          
           // get collision result
           if (  collider.GetContactStatus(   ) )
           {
           // fill out contact point and collision normal of closest contact
           const udword* collFaces = collider.GetTouchedPrimitives(   );
           int numFaces = collider.GetNbTouchedPrimitives(   );
           //LogManager::getSingleton(   ).logMessage(  "sphereCheck returned " + StringConverter::toString(  numFaces ) + " numfaces" );
           if (  numFaces > 0 )
           {
           for(  int i = 0; i < numFaces; i++ )
           {
           //assert(  1 == numFaces );
          
           // build triangle from from faceIndex
           Vector3 v0,  v1,  v2;
           getTriCoords(  collFaces[i],   v0,   v1,   v2 );
          
           v0 = ownMatrix * v0; // transform to world space
           v1 = ownMatrix * v1;
           v2 = ownMatrix * v2;
          
          
          
           testTriangleIntersection(  position,   movementVector,   radius,   v0,   v1,   v2,   &collPair );
          
          
           }
          
           //if(   collPair.distance == movementVector.length(   ) )
           //return false;
           //else
           return true;
           }
           else
           {
           //n_printf(  "nOpcodeShape::sphereCheck(   ): contact but no faces!\n" );
           return false;
           }
           }
          
           // FIXME!
           return false;
           }
          
          ////////////////////////////////////////////////////////////////////////////////
          // This code adapted from code from Irrlicht (  http://www.irrlicht3d.org )
          
     662   inline bool ICollisionShape::getLowestRoot(  Ogre::Real a,   Ogre::Real b,   Ogre::Real c,   Ogre::Real maxR,   Ogre::Real* root )
           {
           // check if solution exists
           Ogre::Real determinant = b*b - 4.0f*a*c;
          
           // if determinant is negative,   no solution
           if (  determinant < 0.0f ) return false;
          
           // calculate two roots: (  if det==0 then x1==x2
           // but lets disregard that slight optimization )
          
           Ogre::Real sqrtD = (  Ogre::Real )sqrt(  determinant );
           Ogre::Real r1 = (  -b - sqrtD ) / (  2*a );
           Ogre::Real r2 = (  -b + sqrtD ) / (  2*a );
          
           // sort so x1 <= x2
           if (  r1 > r2 ) { Ogre::Real tmp=r2; r2=r1; r1=tmp; }
          
           // get lowest root
           if (  r1 > 0 && r1 < maxR )
           {
           *root = r1;
           return true;
           }
          
           // its possible that we want x2,   this can happen if x1 < 0
           if (  r2 > 0 && r2 < maxR )
           {
           *root = r2;
           return true;
           }
          
           return false;
           }
          
          /////////////////////////////
          
     699   void ICollisionShape::sphereEdgeCheck(  Ogre::Vector3 &velocity,  
     700   Ogre::Vector3 &edge,   Ogre::Vector3 &baseToVertex,  
     701   Ogre::Real &t,   bool &foundCollision,  
     702   Ogre::Vector3 &collisionPoint,   Ogre::Vector3 &pnt )
           {
           Ogre::Real newT,   a,  b,  c;
          
           Ogre::Real edgeSqaredLength = (  Ogre::Real )edge.squaredLength(   );
           Ogre::Real edgeDotVelocity = edge.dotProduct(  velocity );
           Ogre::Real edgeDotBaseToVertex = edge.dotProduct(  baseToVertex );
          
           // calculate parameters for equation
           Ogre::Real velocitySqaredLength = velocity.squaredLength(   );
          
           a = edgeSqaredLength* -velocitySqaredLength +
           edgeDotVelocity*edgeDotVelocity;
           b = edgeSqaredLength* (  2*velocity.dotProduct(  baseToVertex ) ) -
           2.0f*edgeDotVelocity*edgeDotBaseToVertex;
           c = (  Ogre::Real )(  edgeSqaredLength* (  1-baseToVertex.squaredLength(   ) ) +
           edgeDotBaseToVertex*edgeDotBaseToVertex );
          
           // does the swept sphere collide against ininite edge?
           if (  getLowestRoot(  a,  b,  c,  t,  &newT ) )
           {
           Ogre::Real f = (  edgeDotVelocity*newT - edgeDotBaseToVertex ) / edgeSqaredLength;
           if (  f >=0.0f && f <= 1.0f )
           {
           // intersection took place within segment
           t = newT;
           foundCollision = true;
           collisionPoint = pnt + (  edge*f );
           }
           }
           }
          
          ////////////////////////////////////
          
     736   bool ICollisionShape::testTriangleIntersection(  Ogre::Vector3 position,  
     737   Ogre::Vector3 movementVector,  
     738   Ogre::Real radius,  
     739   Ogre::Vector3 v0,   Ogre::Vector3 v1,   Ogre::Vector3 v2,  
     740   CollisionPair *cp )
           {
          
           if(  movementVector == Ogre::Vector3::ZERO )
           return false;
          
           Ogre::Real scale_fact = 1.0 / radius;
           v0 *= scale_fact;
           v1 *= scale_fact;
           v2 *= scale_fact;
          
           position *= scale_fact;
           movementVector *= scale_fact;
          
           triangle triangle(  v0,   v1,   v2 );
          
           Ogre::Plane trianglePlane = triangle.getplane(   );
          
           trianglePlane.normal.normalise(   );
          
           // only check front facing polygons
           if (  trianglePlane.getSide(  position ) == Ogre::Plane::POSITIVE_SIDE )
           {
           // get interval of plane intersection
          
           Ogre::Real t1,   t0;
           bool embeddedInPlane = false;
          
           // calculate signed distance from sphere position to triangle plane
           Ogre::Real signedDistToTrianglePlane = trianglePlane.getDistance(  position );
          
           Ogre::Real normalDotVelocity = trianglePlane.normal.dotProduct(  movementVector );
          
           if (  normalDotVelocity == 0.0f )
           {
           // sphere is traveling paralell to plane
          
           if (  fabs(  signedDistToTrianglePlane ) >= 1.0f )
           return false; // no collision possible
           else
           {
           // sphere is embedded in plane
           embeddedInPlane = true;
           t0 = 0.0;
           t1 = 1.0;
           }
           }
           else
           {
           // N.D is not 0. Calculate intersection interval
           t0 = (  -1.0-signedDistToTrianglePlane )/normalDotVelocity;
           t1 = (  1.0-signedDistToTrianglePlane )/normalDotVelocity;
          
           // Swap so t0 < t1
           if (  t0 > t1 ) { Ogre::Real tmp = t1; t1 = t0; t0 = tmp; }
          
           // check if at least one value is within the range
           if (  t0 > 1.0f || t1 < 0.0f )
           return false; // both t values are outside 1 and 0,   no collision possible
          
           // clamp to 0 and 1
           if (  t0 < 0.0 ) t0 = 0.0;
           if (  t1 < 0.0 ) t1 = 0.0;
           if (  t0 > 1.0 ) t0 = 1.0;
           if (  t1 > 1.0 ) t1 = 1.0;
           }
          
           // at this point we have t0 and t1,   if there is any intersection,   it
           // is between this interval
          
           Ogre::Vector3 collisionPoint = Vector3::ZERO;
           bool foundCollision = false;
           Ogre::Real t = 1.0f;
          
           // first check the easy case: Collision within the triangle;
           // if this happens,   it must be at t0 and this is when the sphere
           // rests on the front side of the triangle plane. This can only happen
           // if the sphere is not embedded in the triangle plane.
          
           if (  !embeddedInPlane )
           {
           Ogre::Vector3 planeIntersectionPoint =
           (  position - trianglePlane.normal )
           + (  movementVector * (  Ogre::Real )t0 );
          
          
           if (  triangle.isPointInsideFast(  planeIntersectionPoint ) )
           {
           foundCollision = true;
           t = (  Ogre::Real )t0;
           collisionPoint = planeIntersectionPoint;
           }
           }
          
           // if we havent found a collision already we will have to sweep
           // the sphere against points and edges of the triangle. Note: A
           // collision inside the triangle will always happen before a
           // vertex or edge collision.
          
           // DAVE: is checking against points really necessary if we are checking against edges?
           // Shouldn't the edges take care of that?
          
           if (  !foundCollision )
           {
           Ogre::Vector3 velocity = movementVector;
           Ogre::Vector3 base = position;
          
           Ogre::Real velocitySqaredLength = (  Ogre::Real )velocity.squaredLength(   );
           Ogre::Real a,  b,  c;
           Ogre::Real newT;
          
           // for each edge or vertex a quadratic equation has to be solved:
           // a*t^2 + b*t + c = 0. We calculate a,  b,   and c for each test.
          
           // check against points
           a = velocitySqaredLength;
          
           // FIXME: turn these 3 into 1 function
           // p1
           b = 2.0f * (  velocity.dotProduct(  base - triangle.point(  0 ) ) );
           c = (  Ogre::Real )(  (  triangle.point(  0 )-base ).squaredLength(   ) - 1.0 );
           if (  getLowestRoot(  a,  b,  c,  t,   &newT ) )
           {
           t = newT;
           foundCollision = true;
           collisionPoint = triangle.point(  0 );
           }
          
           // p2
           if (  !foundCollision )
           {
           b = 2.0f * (  velocity.dotProduct(  base - triangle.point(  1 ) ) );
           c = (  Ogre::Real )(  (  triangle.point(  1 )-base ).squaredLength(   ) - 1.0 );
           if (  getLowestRoot(  a,  b,  c,  t,   &newT ) )
           {
           t = newT;
           foundCollision = true;
           collisionPoint = triangle.point(  1 );
           }
           }
          
           // p3
           if (  !foundCollision )
           {
           b = 2.0f * (  velocity.dotProduct(  base - triangle.point(  2 ) ) );
           c = (  Ogre::Real )(  (  triangle.point(  2 )-base ).squaredLength(   ) - 1.0 );
           if (  getLowestRoot(  a,  b,  c,  t,   &newT ) )
           {
           t = newT;
           foundCollision = true;
           collisionPoint = triangle.point(  2 );
           }
           }
          
           // check against edges:
          
           Ogre::Vector3 edge;
           Ogre::Vector3 baseToVertex;
          
           edge = triangle.point(  1 ) - triangle.point(  0 );
           baseToVertex = triangle.point(  0 ) - position;
          
           Vector3 point = triangle.point(  0 );
           sphereEdgeCheck(  velocity,   edge,   baseToVertex,   t,   foundCollision,   collisionPoint,   point );
          
           edge = triangle.point(  2 ) - triangle.point(  1 );
           baseToVertex = triangle.point(  1 ) - position;
          
           point = triangle.point(  1 );
           sphereEdgeCheck(  velocity,   edge,   baseToVertex,   t,   foundCollision,   collisionPoint,   point );
          
           edge = triangle.point(  0 ) - triangle.point(  2 );
           baseToVertex = triangle.point(  2 ) - position;
          
           point = triangle.point(  2 );
           sphereEdgeCheck(  velocity,   edge,   baseToVertex,   t,   foundCollision,   collisionPoint,   point );
          
           }// end no collision found
          
          
           // set result:
           if (  foundCollision )
           {
           // Time to scale everything back..
          
           // distance to collision is t
           Ogre::Real distToCollision = (  Ogre::Real )(  t*movementVector.length(   ) * radius );
          
           // does this triangle qualify for closest hit?
           if (  distToCollision <= cp->distance )
           {
           cp->distance = distToCollision;
           cp->contact = collisionPoint * radius;
           cp->other_contact = cp->contact;
           cp->this_contact = (  position + (  movementVector*t ) )*radius;
          
           cp->other_normal = trianglePlane.normal;
           Ogre::Vector3 vec_to_col = cp->contact - cp->this_contact;
           cp->this_normal = vec_to_col.normalisedCopy(   );
           }
          
           return true;
           }// end found collision
           }// end if is front facing
          
           return false;
           }
          
          
          /////////////////////////////////////////////////////////////////////////////////////
          
          
          
          
           //------------------------------------------------------------------------
           /// Check contact of a sphere with shape.
           /// The collType is interpreted as follows:
           /// - COLLTYPE_IGNORE: illegal (  makes no sense )
           /// - COLLTYPE_QUICK: first contact check only
           /// - COLLTYPE_CONTACT: return closest contact
           /// - COLLTYPE_EXACT: return a sorted list of contacts
           /// Currently,   sphere checks always work in first constact mode (  COLLTYPE_QUICK ).
           /// @param collType see above
           /// @param ownMatrix position/orientation of this shape
           /// @param ball sphere definition in world space
           /// @param collPair will be filled with result
           /// @return true if line intersects shape
     967   bool ICollisionShape::sphereCheck(  CollisionType collType,  
     968   const Matrix4& ownMatrix,  
     969   const Sphere& ball,  
     970   CollisionPair& collPair )
           {
           assert(  COLLTYPE_IGNORE != collType );
          
           // setup sphere collider
           Opcode::SphereCollider& collider = CollisionManager::getSingletonPtr(   )->opcSphereCollider;
           Opcode::SphereCache& cache = CollisionManager::getSingletonPtr(   )->opcSphereCache;
          
           switch (  collType )
           {
           case COLLTYPE_QUICK:
           case COLLTYPE_CONTACT:
           collider.SetFirstContact(  true );
           break;
          
           case COLLTYPE_EXACT:
           collider.SetFirstContact(  false );
           break;
          
           default:
           break;
           }
          
           // convert Matrix4 to Opcode Matrix4x4
           IceMaths::Matrix4x4 opcMatrix;
           IceMaths::Matrix4x4 *ptrOpcMatrix = &opcMatrix;
           OgreOpcodeUtils::ogreToIceMatrix4(   ownMatrix,   opcMatrix );
          
           // build identity matrix because sphere is already in world space
           IceMaths::Matrix4x4 identity;
           IceMaths::Matrix4x4 *ptrIdentity = &identity;
           identity.Identity(   );
          
           IceMaths::Sphere opcSphere;
           OgreOpcodeUtils::ogreToIceSphere(  ball,   opcSphere );
          
           // validate settings: asserts that we can check collision
           // another option is to display some annoying error windows using: Ogre::String(  collider.ValidateSettings(   )  )
           assert(   collider.ValidateSettings(   ) == 0  );
          
           // perform collision
           if(   !collider.Collide(  cache,   opcSphere,   opcModel,   ptrIdentity,   ptrOpcMatrix )  )
           return false;
          
           collPair.numBVBVTests = collider.GetNbVolumeBVTests(   );
           collPair.numBVPrimTests = collider.GetNbVolumePrimTests(   );
           collPair.numPrimPrimTests = 0;
          
           // get collision result
           if (  collider.GetContactStatus(   ) )
           {
           // fill out contact point and collision normal of closest contact
           const udword* collFaces = collider.GetTouchedPrimitives(   );
           int numFaces = collider.GetNbTouchedPrimitives(   );
           //LogManager::getSingleton(   ).logMessage(  "sphereCheck returned " + StringConverter::toString(  numFaces ) + " numfaces" );
           if (  numFaces > 0 )
           {
           for(  int i = 0; i < numFaces; i++ )
           {
           //assert(  1 == numFaces );
          
           // build triangle from from faceIndex
           Vector3 v0,  v1,  v2;
           getTriCoords(  collFaces[i],   v0,   v1,   v2 );
          
           // Compute the centered normal
           Vector3 vCenter = (  v0+v1+v2 )*0.33333333333333333333f;
           Vector3 vNormal = (  v1-v0 ).crossProduct(  v2-v0 );
           vNormal.normalise(   );
           Vector3 thePoint = ownMatrix * vCenter;
           Plane thePlane(  vNormal,   thePoint );
           Real theDist = thePlane.getDistance(  ball.getCenter(   ) );
           // fill collide report
           if(  0 == i )
           {
           collPair.this_normal = vNormal;
           collPair.other_normal = -collPair.this_normal;
           collPair.contact = ownMatrix * vCenter;//ball.getCenter(   ) + collPair.this_normal * theDist;
           }
           CollisionInfo collInfo;
           collInfo.this_normal = vNormal;
           collInfo.other_normal = -collPair.this_normal;
           collInfo.contact = ownMatrix * vCenter;
           collPair.collInfos.push_back(  collInfo );
           }
           return true;
           }
           else
           {
           //n_printf(  "nOpcodeShape::sphereCheck(   ): contact but no faces!\n" );
           return false;
           }
           }
          
           // FIXME!
           return false;
           }
          
           //------------------------------------------------------------------------
           /// Render a AABBCollisionNode and recurse.
           /// @param [in,   out] node const Opcode::AABBCollisionNode * AABBCollisionNode to visualize.
    1071   void ICollisionShape::visualizeAABBCollisionNode(  const Opcode::AABBCollisionNode* node )
           {
           assert(  node );
          
           Vector3 center(  node->mAABB.mCenter.x,   node->mAABB.mCenter.y,   node->mAABB.mCenter.z );
           Vector3 extent(  node->mAABB.mExtents.x,   node->mAABB.mExtents.y,   node->mAABB.mExtents.z );
          
           Vector3 v00(  center.x - extent.x,   center.y - extent.y,   center.z - extent.z );
           Vector3 v01(  center.x - extent.x,   center.y - extent.y,   center.z + extent.z );
           Vector3 v02(  center.x + extent.x,   center.y - extent.y,   center.z + extent.z );
           Vector3 v03(  center.x + extent.x,   center.y - extent.y,   center.z - extent.z );
          
           Vector3 v10(  center.x - extent.x,   center.y + extent.y,   center.z - extent.z );
           Vector3 v11(  center.x - extent.x,   center.y + extent.y,   center.z + extent.z );
           Vector3 v12(  center.x + extent.x,   center.y + extent.y,   center.z + extent.z );
           Vector3 v13(  center.x + extent.x,   center.y + extent.y,   center.z - extent.z );
          
           const Matrix4 &m = getFullTransform(   );
           v00 = m * v00;
           v01 = m * v01;
           v02 = m * v02;
           v03 = m * v03;
           v10 = m * v10;
           v11 = m * v11;
           v12 = m * v12;
           v13 = m * v13;
          
           //// render ground rect
           mActiveDebugger->addAABBLine(  v00.x,   v00.y,   v00.z,   v01.x,   v01.y,   v01.z );
           mActiveDebugger->addAABBLine(  v01.x,   v01.y,   v01.z,   v02.x,   v02.y,   v02.z );
           mActiveDebugger->addAABBLine(  v02.x,   v02.y,   v02.z,   v03.x,   v03.y,   v03.z );
           mActiveDebugger->addAABBLine(  v03.x,   v03.y,   v03.z,   v00.x,   v00.y,   v00.z );
          
           //// render top rect
           mActiveDebugger->addAABBLine(  v10.x,   v10.y,   v10.z,   v11.x,   v11.y,   v11.z );
           mActiveDebugger->addAABBLine(  v11.x,   v11.y,   v11.z,   v12.x,   v12.y,   v12.z );
           mActiveDebugger->addAABBLine(  v12.x,   v12.y,   v12.z,   v13.x,   v13.y,   v13.z );
           mActiveDebugger->addAABBLine(  v13.x,   v13.y,   v13.z,   v10.x,   v10.y,   v10.z );
          
           //// render vertical lines
           mActiveDebugger->addAABBLine(  v00.x,   v00.y,   v00.z,   v10.x,   v10.y,   v10.z );
           mActiveDebugger->addAABBLine(  v01.x,   v01.y,   v01.z,   v11.x,   v11.y,   v11.z );
           mActiveDebugger->addAABBLine(  v02.x,   v02.y,   v02.z,   v12.x,   v12.y,   v12.z );
           mActiveDebugger->addAABBLine(  v03.x,   v03.y,   v03.z,   v13.x,   v13.y,   v13.z );
          
           if (  !node->IsLeaf(   ) )
           {
           const Opcode::AABBCollisionNode* neg = node->GetNeg(   );
           const Opcode::AABBCollisionNode* pos = node->GetPos(   );
           if (  neg )
           visualizeAABBCollisionNode(  neg );
           if (  pos )
           visualizeAABBCollisionNode(  pos );
           }
           }
          
           //------------------------------------------------------------------------
           /// Render a AABBCollisionNode and recurse.
           /// @param [in,   out] node const Opcode::AABBNoLeafNode * AABBNoLeafNode to visualize.
    1130   void ICollisionShape::visualizeAABBNoLeafNode(  const Opcode::AABBNoLeafNode* node )
           {
           assert(  node );
          
           Vector3 center(  node->mAABB.mCenter.x,   node->mAABB.mCenter.y,   node->mAABB.mCenter.z );
           Vector3 extent(  node->mAABB.mExtents.x,   node->mAABB.mExtents.y,   node->mAABB.mExtents.z );
          
           Vector3 v00(  center.x - extent.x,   center.y - extent.y,   center.z - extent.z );
           Vector3 v01(  center.x - extent.x,   center.y - extent.y,   center.z + extent.z );
           Vector3 v02(  center.x + extent.x,   center.y - extent.y,   center.z + extent.z );
           Vector3 v03(  center.x + extent.x,   center.y - extent.y,   center.z - extent.z );
          
           Vector3 v10(  center.x - extent.x,   center.y + extent.y,   center.z - extent.z );
           Vector3 v11(  center.x - extent.x,   center.y + extent.y,   center.z + extent.z );
           Vector3 v12(  center.x + extent.x,   center.y + extent.y,   center.z + extent.z );
           Vector3 v13(  center.x + extent.x,   center.y + extent.y,   center.z - extent.z );
          
           const Matrix4 &m = getFullTransform(   );
           v00 = m * v00;
           v01 = m * v01;
           v02 = m * v02;
           v03 = m * v03;
           v10 = m * v10;
           v11 = m * v11;
           v12 = m * v12;
           v13 = m * v13;
          
           //// render ground rect
           mActiveDebugger->addAABBLine(  v00.x,   v00.y,   v00.z,   v01.x,   v01.y,   v01.z );
           mActiveDebugger->addAABBLine(  v01.x,   v01.y,   v01.z,   v02.x,   v02.y,   v02.z );
           mActiveDebugger->addAABBLine(  v02.x,   v02.y,   v02.z,   v03.x,   v03.y,   v03.z );
           mActiveDebugger->addAABBLine(  v03.x,   v03.y,   v03.z,   v00.x,   v00.y,   v00.z );
          
           //// render top rect
           mActiveDebugger->addAABBLine(  v10.x,   v10.y,   v10.z,   v11.x,   v11.y,   v11.z );
           mActiveDebugger->addAABBLine(  v11.x,   v11.y,   v11.z,   v12.x,   v12.y,   v12.z );
           mActiveDebugger->addAABBLine(  v12.x,   v12.y,   v12.z,   v13.x,   v13.y,   v13.z );
           mActiveDebugger->addAABBLine(  v13.x,   v13.y,   v13.z,   v10.x,   v10.y,   v10.z );
          
           //// render vertical lines
           mActiveDebugger->addAABBLine(  v00.x,   v00.y,   v00.z,   v10.x,   v10.y,   v10.z );
           mActiveDebugger->addAABBLine(  v01.x,   v01.y,   v01.z,   v11.x,   v11.y,   v11.z );
           mActiveDebugger->addAABBLine(  v02.x,   v02.y,   v02.z,   v12.x,   v12.y,   v12.z );
           mActiveDebugger->addAABBLine(  v03.x,   v03.y,   v03.z,   v13.x,   v13.y,   v13.z );
          
           if (  !node->HasNegLeaf(   ) )
           {
           const Opcode::AABBNoLeafNode* neg = node->GetNeg(   );
           visualizeAABBNoLeafNode(  neg );
           }
           if (  !node->HasPosLeaf(   ) )
           {
           const Opcode::AABBNoLeafNode* pos = node->GetPos(   );
           visualizeAABBNoLeafNode(  pos );
           }
           }
          
           //------------------------------------------------------------------------
           /// Renders the collide model triangle soup.
    1189   void ICollisionShape::visualize(  Details::OgreOpcodeDebugger* activeDebugger )
           {
           if(  !mDebugObject->isAttached(   ) )
           mParentNode->attachObject(  mDebugObject );
          
           mDebugObject->begin(  "OgreOpcodeDebug/Shapes",   Ogre::RenderOperation::OT_LINE_LIST );
          
           mActiveDebugger = activeDebugger;
          
          
           assert(  mVertexBuf && mFaceBuf );
          
           // render the triangle soup
           size_t i;
           for (  i = 0; i < numFaces; i++ )
           {
           size_t* indexPtr = mFaceBuf + 3 * i;
           float* v0 = mVertexBuf + 3 * indexPtr[0];
           float* v1 = mVertexBuf + 3 * indexPtr[1];
           float* v2 = mVertexBuf + 3 * indexPtr[2];
          
           //const Matrix4 &m = getFullTransform(   );
          
           Vector3 vect0(  v0[0],  v0[1],  v0[2] );
           Vector3 vect1(  v1[0],  v1[1],  v1[2] );
           Vector3 vect2(  v2[0],  v2[1],  v2[2] );
           //vect0 = m * vect0;
           //vect1 = m * vect1;
           //vect2 = m * vect2;
          
           mDebugObject->position(  vect0.x,   vect0.y,   vect0.z );
           mDebugObject->position(  vect1.x,   vect1.y,   vect1.z );
           mDebugObject->position(  vect1.x,   vect1.y,   vect1.z );
           mDebugObject->position(  vect2.x,   vect2.y,   vect2.z );
           mDebugObject->position(  vect2.x,   vect2.y,   vect2.z );
           mDebugObject->position(  vect0.x,   vect0.y,   vect0.z );
           }
           mDebugObject->end(   );
           }
          
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
    1232   void ICollisionShape::visualizeAABBs(  Details::OgreOpcodeDebugger* activeDebugger )
           {
           mActiveDebugger = activeDebugger;
           // render the AABB tree
           if (  opcModel.HasLeafNodes(   ) )
           {
           const Opcode::AABBCollisionTree* tree = static_cast<const Opcode::AABBCollisionTree*>(  opcModel.GetTree(   ) );
           visualizeAABBCollisionNode(  tree->GetNodes(   ) );
           }
           else
           {
           const Opcode::AABBNoLeafTree* tree = static_cast<const Opcode::AABBNoLeafTree*>(  opcModel.GetTree(   ) );
           visualizeAABBNoLeafNode(  tree->GetNodes(   ) );
           }
           }
          
           //------------------------------------------------------------------------
    1249   void ICollisionShape::_prepareOpcodeCreateParams(  Opcode::OPCODECREATE& opcc )
           {
           opcc.mIMesh = &opcMeshAccess;
           //opcc.mSettings.mRules = Opcode::SPLIT_BEST_AXIS;//Opcode::SPLIT_SPLATTER_POINTS; // split by splattering primitive centers (  ??? )
           opcc.mSettings.mRules = Opcode::SPLIT_GEOM_CENTER | Opcode::SPLIT_SPLATTER_POINTS; // Recommended by Opcode manual
           opcc.mSettings.mLimit = 1; // build a complete tree,   1 primitive/node
           opcc.mNoLeaf = true; // false;
           opcc.mQuantized = false; // true;
           }
          
          }
          
          //------------------------------------------------------------------------

./components/ogre/ogreopcode/src/OgreBoxCollisionShape.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreBoxCollisionShape.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeExports.h"
          #include "OgreBoxCollisionShape.h"
          #include "OgreCollisionReporter.h"
          #include "OgreCollisionManager.h"
          #include "OgreOpcodeMath.h"
          #include "OgreOpcodeUtils.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           //------------------------------------------------------------------------
      39   BoxCollisionShape::BoxCollisionShape(  const Ogre::String& name )
           : ICollisionShape(  name )
           {
           }
          
           //------------------------------------------------------------------------
      45   BoxCollisionShape::~BoxCollisionShape(   )
           {
           delete[] mVertexBuf;
           delete[] mFaceBuf;
           }
          
           //------------------------------------------------------------------------
      52   void BoxCollisionShape::_prepareOpcodeCreateParams(  Opcode::OPCODECREATE& opcc )
           {
           opcc.mIMesh = &opcMeshAccess;
           //opcc.mSettings.mRules = Opcode::SPLIT_BEST_AXIS;//Opcode::SPLIT_SPLATTER_POINTS; // split by splattering primitive centers (  ??? )
           opcc.mSettings.mRules = Opcode::SPLIT_GEOM_CENTER | Opcode::SPLIT_SPLATTER_POINTS; // Recommended by Opcode manual
           opcc.mSettings.mLimit = 1; // build a complete tree,   1 primitive/node
           opcc.mNoLeaf = true; // false;
           opcc.mQuantized = false; // true;
           }
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @param [in,   out] ent Entity * <TODO: insert parameter description here>
           /// @return bool <TODO: insert return value description here>
      65   bool BoxCollisionShape::load(  SceneNode* scnNode,   int height,   int width,   int depth )
           {
           assert(  !mVertexBuf && !mFaceBuf );
          
           mParentNode = scnNode;
          
           // Set up the 8 corners of the cube
           float top = height;
           float bottom = -height;
           float front = -width;
           float back = width;
           float left = -depth;
           float right = depth;
          
           numVertices = 8;
           numFaces = 12;
           mVertexBuf = new float[numVertices*3];
           mFaceBuf = new size_t[numFaces*3];
          
           mVertexBuf[0] = left;
           mVertexBuf[1] = bottom;
           mVertexBuf[2] = front;
           mVertexBuf[3] = right;
           mVertexBuf[4] = bottom;
           mVertexBuf[5] = front;
           mVertexBuf[6] = left;
           mVertexBuf[7] = top;
           mVertexBuf[8] = front;
           mVertexBuf[9] = right;
           mVertexBuf[10] = top;
           mVertexBuf[11] = front;
           mVertexBuf[12] = left;
           mVertexBuf[13] = bottom;
           mVertexBuf[14] = back;
           mVertexBuf[15] = right;
           mVertexBuf[16] = bottom;
           mVertexBuf[17] = back;
           mVertexBuf[18] = left;
           mVertexBuf[19] = top;
           mVertexBuf[20] = back;
           mVertexBuf[21] = right;
           mVertexBuf[22] = top;
           mVertexBuf[23] = back;
          
           int leftbottomfront = 1;
           int rightbottomfront = 0;
           int lefttopfront = 3;
           int righttopfront = 2;
           int leftbottomback = 5;
           int rightbottomback = 4;
           int lefttopback = 7;
           int righttopback = 6;
           //int leftbottomfront = 0;
           //int rightbottomfront = 1;
           //int lefttopfront = 2;
           //int righttopfront = 3;
           //int leftbottomback = 4;
           //int rightbottomback = 5;
           //int lefttopback = 6;
           //int righttopback = 7;
          
           // Left faces
           mFaceBuf[0] = lefttopfront;
           mFaceBuf[1] = lefttopback;
           mFaceBuf[2] = leftbottomback;
           mFaceBuf[3] = leftbottomback;
           mFaceBuf[4] = leftbottomfront;
           mFaceBuf[5] = lefttopfront;
           // Front faces
           mFaceBuf[6] = lefttopfront;
           mFaceBuf[7] = leftbottomfront;
           mFaceBuf[8] = rightbottomfront;
           mFaceBuf[9] = rightbottomfront;
           mFaceBuf[10] = righttopfront;
           mFaceBuf[11] = lefttopfront;
           // Right faces
           mFaceBuf[12] = righttopback;
           mFaceBuf[13] = righttopfront;
           mFaceBuf[14] = rightbottomfront;
           mFaceBuf[15] = rightbottomfront;
           mFaceBuf[16] = rightbottomback;
           mFaceBuf[17] = righttopback;
           // Back faces
           mFaceBuf[18] = leftbottomback;
           mFaceBuf[19] = lefttopback;
           mFaceBuf[20] = righttopback;
           mFaceBuf[21] = righttopback;
           mFaceBuf[22] = rightbottomback;
           mFaceBuf[23] = leftbottomback;
           // Top faces
           mFaceBuf[24] = righttopfront;
           mFaceBuf[25] = righttopback;
           mFaceBuf[26] = lefttopback;
           mFaceBuf[27] = lefttopback;
           mFaceBuf[28] = lefttopfront;
           mFaceBuf[29] = righttopfront;
           // Bottom faces
           mFaceBuf[30] = leftbottomfront;
           mFaceBuf[31] = leftbottomback;
           mFaceBuf[32] = rightbottomback;
           mFaceBuf[33] = rightbottomback;
           mFaceBuf[34] = rightbottomfront;
           mFaceBuf[35] = leftbottomfront;
          
           //numVertices = 4;
           //numFaces = 2;
           //mVertexBuf = new float[numVertices*3];
           //mFaceBuf = new int[numFaces*3];
           //
           //mVertexBuf[0] = -size;
           //mVertexBuf[1] = 0;
           //mVertexBuf[2] = -size;
           //mVertexBuf[3] = -size;
           //mVertexBuf[4] = 0;
           //mVertexBuf[5] = size;
           //mVertexBuf[6] = size;
           //mVertexBuf[7] = 0;
           //mVertexBuf[8] = size;
           //mVertexBuf[9] = size;
           //mVertexBuf[10] = 0;
           //mVertexBuf[11] = -size;
          
           //mFaceBuf[0] = 0;
           //mFaceBuf[1] = 1;
           //mFaceBuf[2] = 2;
           //mFaceBuf[3] = 0;
           //mFaceBuf[4] = 2;
           //mFaceBuf[5] = 3;
          
           opcMeshAccess.SetNbTriangles(  numFaces );
           opcMeshAccess.SetNbVertices(  numVertices );
           opcMeshAccess.SetPointers(  (  IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           //opcMeshAccess.SetStrides(  sizeof(  int ) * 3,   sizeof(  float ) * 3 );
          
           assert(  mVertexBuf && mFaceBuf );
          
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
          
           calculateSize(   );
          
           mParentNode->getWorldTransforms(  &mFullTransform );
           //mFullTransform = mParentNode->_getFullTransform(   );
          
           return true;
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
           //bool BoxCollisionShape::rebuild(   )
           //{
           // opcMeshAccess.SetNbTriangles(  numFaces );
           // opcMeshAccess.SetNbVertices(  numVertices );
           // opcMeshAccess.SetPointers(  (  IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           // opcMeshAccess.SetStrides(  sizeof(  int ) * 3,   sizeof(  float ) * 3 );
          
           // return _rebuildFromCachedData(   );
          
           //}
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
           //bool BoxCollisionShape::_rebuildFromCachedData(   )
           //{
           // assert(  mVertexBuf && mFaceBuf );
          
           // Opcode::OPCODECREATE opcc;
           // _prepareOpcodeCreateParams(  opcc );
           // opcModel.Build(  opcc );
          
           // calculateSize(   );
          
           // if (  _debug_obj ) {
           // setDebug(  true );
           // }
          
           // return true;
           //}
          }
          
          //------------------------------------------------------------------------

./components/ogre/ogreopcode/src/OgreCapsule.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCapsule.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          
          #include "OgreCapsule.h"
          #include "OgreOrientedBox.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           namespace Details
           {
           //------------------------------------------------------------------------
      38   bool Capsule::contains(   const Vector3& point  ) const
           {
           Line line(   start,   end  );
          
           return line.squaredDistance(  point ) <= (  radius*radius );
           }
           //------------------------------------------------------------------------
      45   bool Capsule::intersects(   const Aabb& aabb  ) const
           {
           // TODO: optimize this code for the AABB case.
           OrientedBox obb(   aabb  );
           return intersects(   obb  );
           }
           //------------------------------------------------------------------------
      52   bool Capsule::intersects(   const sphere& s  ) const
           {
           Line line(   start,   end );
           Real sqrDist = line.squaredDistance(   s.p  );
           Real rsum = radius + s.r;
          
           return sqrDist <= (  rsum*rsum );
           }
           //------------------------------------------------------------------------
      61   bool Capsule::intersects(   const OrientedBox& obb  ) const
           {
           Line line(   start,   end  );
          
           return line.squaredDistance(  obb ) <= (  radius*radius );
           }
           //------------------------------------------------------------------------
      68   bool Capsule::intersects(   const Capsule& cap  ) const
           {
           Line me(   start,   end  );
           Line it(   cap.start,   cap.end  );
          
           Real sqrDist = me.squaredDistance(   it  );
           Real rsum = radius + cap.radius;
          
           return sqrDist <= (  rsum*rsum );;
           }
           //------------------------------------------------------------------------
           }
          }

./components/ogre/ogreopcode/src/OgreCollisionContext.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCollisionContext.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreCollisionContext.h"
          #include "OgreCollisionObject.h"
          #include "OgreOpcodeMath.h"
          #include "OgreCollisionManager.h"
          #include "BP_Scene.h"
          
          using namespace Ogre;
          using namespace OgreOpcode::Details;
          
          namespace OgreOpcode
          {
           namespace Details
           {
      41   inline bool intervalOverlap(  Real a0,   Real a1,   Real b0,   Real b1 )
           {
           // Only two ways for intervals to not overlap --
           // a's max less than b's min,   or a's min greater than b's max.
           // Otherwise they overlap.
           // return !(  a1<b0 || a0>b1 );
           // I just applied the De Morgan's law here in order to obtain short-circuit
           return (  a1>=b0 ) && (  a0<=b1 );
           }
           } // Details
          
           // release all owned collide objects
      53   CollisionContext::~CollisionContext(   )
           {
           // remove collision objects
           while (  !owned_list.empty(   ) )
           {
           destroyObject(  *(  owned_list.begin(   ) ) );
           }
           delete mVisualDebugger;
           delete mBroadPhase;
           }
          
           // Construct a new collide object.
      65   CollisionObject *CollisionContext::createObject(  const Ogre::String& name )
           {
           CollisionObject *co = new CollisionObject(  name );
           co->setId(  unique_id++ );
           co->setContext(  this );
           owned_list.push_back(  co );
           return co;
           }
          
      74   CollisionContext::CollisionContext(  const Ogre::String& name ) :
           unique_id(  0 ),  
           mName(  name ),  
           mRayCulling(  true ),  
           mIsSAPDirty(  true )
           {
           mVisualDebugger = new Details::OgreOpcodeDebugger(  mName,   CollisionManager::getSingletonPtr(   )->getSceneManager(   ) );
           mRecentContactList.clear(   );
           mBroadPhase = new BP_Scene(  &proxList,   &OgreOpcode::CollisionContext::addPair,   &OgreOpcode::CollisionContext::removePair );
           }
          
           // Kill an owned collide object.
      86   void CollisionContext::destroyObject(  CollisionObject *collObj )
           {
           if (  collObj != 0 )
           {
           if(  collObj->isAttached(   ) )
           {
           rw_attached_list_iterator itAttached = find(  attached_list.begin(   ),   attached_list.end(   ),   collObj );
           if (  itAttached != attached_list.end(   ) )
           {
           attached_list.erase(  itAttached );
           }
           }
          
           rw_owned_list_iterator itOwned = find(  owned_list.begin(   ),   owned_list.end(   ),   collObj );
           if (  itOwned != owned_list.end(   ) )
           {
           owned_list.erase(  itOwned );
           }
           collObj->setAttached(  false );
           collObj->remove_broadphase(   );
           collObj->setContext(  0 );
           delete collObj;
           }
           }
          
     111   void CollisionContext::addObject(  CollisionObject *collObj )
           {
           if(  collObj == 0 )
           OGRE_EXCEPT(  Exception::ERR_INTERNAL_ERROR,   "Trying to add a null object.",   "CollisionContext::addObject" );
          
           attached_list.push_back(  collObj );
           collObj->setAttached(  true );
           }
          
     120   void CollisionContext::removeObject(  CollisionObject *collObj )
           {
           if (  collObj != 0 )
           {
           collObj->setAttached(  false );
           collObj->remove_broadphase(   );
           rw_attached_list_iterator itAttached = find(  attached_list.begin(   ),   attached_list.end(   ),   collObj );
           if (  itAttached != attached_list.end(   ) )
           {
           attached_list.erase(  itAttached );
           }
           }
           }
          
           /// Call collide on each object in the context.
           /// After this,   each object's collision array holds all collisions
           /// this object was involved with.
     137   int CollisionContext::collide(  Real dt )
           {
           update(  dt );
          
          
          
           // first,   clear the collision counters in all collide objects
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
           (  *i )->clearCollisions(   );
           }
          
           // then,   run the broadphase
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
           (  *i )->do_broadphase(   );
           }
          
           // Loop through the Potentially Colliding Set and tell each CollisionObject to test against the other
           for (  ProxList::iterator prox_it = proxList.begin(   ); prox_it != proxList.end(   ); ++prox_it )
           {
           // If the shape is marked as being static,   do not add it to the PCS.
           if(  !(  *prox_it ).obj1->getShape(   )->isStatic(   ) )
           (  *prox_it ).obj1->addToCollideList(  (  *prox_it ).obj2 );
           if(  !(  *prox_it ).obj2->getShape(   )->isStatic(   ) )
           (  *prox_it ).obj2->addToCollideList(  (  *prox_it ).obj1 );
           }
          
           // check the collision status for each object
           collideReportHandler.beginFrame(   );
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
           //if (   (  *i )->needsUpdate(   )  )
           (  *i )->collide(   );
           }
           collideReportHandler.endFrame(   );
          
           int num_coll = collideReportHandler.getNumCollisions(   );
           return num_coll;
           }
          
           /// Get all collisions an object is involved in.
           /// Returns pointer to an internal collision array and
           /// the number of collisions.
     181   int CollisionContext::getCollisions(  CollisionObject *collObj,   CollisionPair **&cpPtr )
           {
           if (  collObj->getNumCollisions(   ) > 0 )
           {
           return collideReportHandler.getCollisions(  collObj,  cpPtr );
           } else
           {
           cpPtr = 0;
           return 0;
           }
           }
          
     193   CollisionObject* CollisionContext::getAttachedObject(  Ogre::String name )
           {
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
           if(   (  *i )->getName(   ) == name  )
           return (  *i );
           }
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,   "'" + name + "' is not attached! Does it even exsist?",   "CollisionContext::getAttachedObject" );
           }
          
          
           ///
     205   const std::list<CollisionObject*>& CollisionContext::getPotentialColliders(  const CollisionObject* collidee )
           {
           return collidee->collideList;
           }
          
           /// get reporter for for last collide(   ) call.
     211   const CollisionReporter& CollisionContext::getCollisionReport(   )
           {
           return collideReportHandler;
           }
          
           ///
     217   const int CollisionContext::getNumCollisions(   )
           {
           return collideReportHandler.getNumCollisions(   );
           }
          
           /// get reporter for for last Check...(   ) call.
     223   const CollisionReporter& CollisionContext::getCheckReport(   )
           {
           return checkReportHandler;
           }
          
           /// visualize all objects in the context.
     229   void CollisionContext::visualize(  bool doVisualize,   bool doRadii,   bool doContacts,   bool doBBs,   bool doShapes,   bool doAABBs )
           {
           // if the debugger is down,   just return
           if(  !mVisualDebugger ) return;
          
           mVisualDebugger->clearAll(   );
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
           (  *i )->getShape(   )->clearViz(   );
           }
          
           if(  doVisualize )
           {
           if (  !attached_list.empty(   ) )
           {
           if(  doRadii )
           {
           mVisualDebugger->beginRadii(   );
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
           (  *i )->visualizeRadii(   );
           }
           mVisualDebugger->endRadii(   );
           }
           if(  doContacts )
           {
           if(   collideReportHandler.getNumCollisions(   ) > 0 )
           {
           mVisualDebugger->beginContacts(   );
           mVisualDebugger->beginContactNormals(   );
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
           (  *i )->visualizeContacts(   );
           }
           mVisualDebugger->endContactNormals(   );
           mVisualDebugger->endContacts(   );
           }
          
           static int contactCount = 0;
           static bool bufferContacts = true;
          
           if(   checkReportHandler.getNumCollisions(   ) > 0 )
           {
           CollisionPair **pick_report;
           int num_picks = checkReportHandler.getAllCollisions(  pick_report );
           if(  num_picks > 0 )
           {
          
           for(  int i = 0; i < num_picks; i++ )
           {
           for (  int currColl = 0; currColl < static_cast<int>(  pick_report[i]->collInfos.size(   ) ); currColl++ )
           {
           if(  bufferContacts )
           contactCount++;
           CollisionInfo collInfo;
           collInfo.contact = pick_report[i]->collInfos[currColl].contact;
           collInfo.this_normal = pick_report[i]->collInfos[currColl].this_normal * 5;
           collInfo.other_normal = pick_report[i]->collInfos[currColl].other_normal * 5;
           mRecentContactList.push_back(  collInfo );
           if(  !bufferContacts )
           mRecentContactList.pop_front(   );
           }
           }
           }
          
           if(  contactCount > 10 )
           bufferContacts = false;
          
           }
          
           // render any collision contact points
           if (  mRecentContactList.size(   ) > 0 )
           {
           mVisualDebugger->beginContacts(   );
           mVisualDebugger->beginContactNormals(   );
          
           std::list<CollisionInfo>::iterator contactIter;
           for (  contactIter = mRecentContactList.begin(   ); contactIter != mRecentContactList.end(   ); ++contactIter )
           {
           Vector3 cnt = (  *contactIter ).contact;
           mVisualDebugger->addContactLine(  cnt.x-0.5f,  cnt.y,  cnt.z,   cnt.x+0.5f,  cnt.y,  cnt.z );
           mVisualDebugger->addContactLine(  cnt.x,  cnt.y-0.5f,  cnt.z,   cnt.x,  cnt.y+0.5f,  cnt.z );
           mVisualDebugger->addContactLine(  cnt.x,  cnt.y,  cnt.z-0.5f,   cnt.x,  cnt.y,  cnt.z+0.5f );
          
           Vector3 n = (  *contactIter ).this_normal * 5;
           mVisualDebugger->addContactNormalsLine(  cnt.x,  cnt.y,  cnt.z,   cnt.x+n.x,  cnt.y+n.y,  cnt.z+n.z );
           n = (  *contactIter ).other_normal * 5;
           mVisualDebugger->addContactNormalsLine(  cnt.x,  cnt.y,  cnt.z,   cnt.x+n.x,  cnt.y+n.y,  cnt.z+n.z );
          
           }
          
           mVisualDebugger->endContactNormals(   );
           mVisualDebugger->endContacts(   );
           }
          
           }
          
           if(  doBBs )
           {
           mVisualDebugger->beginBBs(   );
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
           (  *i )->visualizeBoundingBoxes(   );
           }
           mVisualDebugger->endBBs(   );
           }
           if(  doShapes )
           {
           //mVisualDebugger->beginShapes(   );
          
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
          // if(   (  *i )->hasCollisions(   ) || (  *i )->hasCheckCollisions(   )  )
           (  *i )->getShape(   )->visualize(  mVisualDebugger );
           }
           //mVisualDebugger->endShapes(   );
           }
           if(  doAABBs )
           {
           mVisualDebugger->beginAABBs(   );
          
           for (  attached_list_iterator i = attached_list.begin(   ); i != attached_list.end(   ); ++i )
           {
           if(   (  *i )->hasCollisions(   ) || (  *i )->hasCheckCollisions(   )  )
           (  *i )->getShape(   )->visualizeAABBs(  mVisualDebugger );
           }
           mVisualDebugger->endAABBs(   );
           }
           }
           }
           }
          
           /// Do an instant check of a moving sphere in the collision volume.
           /// Fills out the provided collide report array and
           /// returns number of detected collisions.
           /// @param p0 [in] starting position
           /// @param v0 [in] vector to ending position
           /// @param radius [in] radius
           /// @param collClass [in] collision class for collision type query
           /// @param cr_ptr [out] pointer to array of pointers to CollisionPair's
           /// @return number of detected contacts (  1 per collide object )
     370   int CollisionContext::sweptSphereCheck(  const Vector3& position,   const Vector3& movementVector,   Real radius,   CollisionClass collClass,   CollisionPair **& cpPtr,   String ignorename )
           {
           // create a bounding box from the start and end position
           Vector3 endPosition(  position + movementVector );
           Vector3 minv(  n_min(  position.x,   endPosition.x ) - radius,  
           n_min(  position.y,   endPosition.y ) - radius,  
           n_min(  position.z,   endPosition.z ) - radius );
           Vector3 maxv(  n_max(  position.x,   endPosition.x ) + radius,  
           n_max(  position.y,   endPosition.y ) + radius,  
           n_max(  position.z,   endPosition.z ) + radius );
          
           const int own_id = 0xffff;
          
           // initialize collision report handler
           checkReportHandler.beginFrame(   );
          
           // This simply goes through all attached objects,   and
           // checks them for overlap,   so ITS SLOW! Every object is
           // tested exactly once
           for (  attached_list_iterator other = attached_list.begin(   ); other != attached_list.end(   ); ++other )
           {
           // see if we have overlaps in all 3 dimensions
           if (  (  minv.x < (  *other )->maxv.x ) && (  maxv.x > (  *other )->minv.x ) &&
           (  minv.y < (  *other )->maxv.y ) && (  maxv.y > (  *other )->minv.y ) &&
           (  minv.z < (  *other )->maxv.z ) && (  maxv.z > (  *other )->minv.z ) )
           {
           // see if the candidate is in the ignore types set
           CollisionType ct = CollisionManager::getSingletonPtr(   )->queryCollType(  collClass,  (  *other )->getCollClass(   ) );
           if (  COLLTYPE_IGNORE == ct ) continue;
          
           checkReportHandler.mTotalObjObjTests++;
           if(  (  *other )->getName(   ) != ignorename )
           {
           if (  COLLTYPE_QUICK == ct )
           {
           // Trying to extract position information from provided matrices.
           Vector3 p1 = Vector3(  (  *other )->old_matrix[0][3],   (  *other )->old_matrix[1][3],   (  *other )->old_matrix[2][3] );
           Vector3 v1 = Vector3(  Vector3(  (  *other )->new_matrix[0][3],   (  *other )->new_matrix[1][3],   (  *other )->new_matrix[2][3] ) - p1 );
          
           // do the contact check between 2 moving spheres
           sphere s0(  position,  radius );
           sphere s1(  p1,  (  *other )->getRadius(   ) );
           float u0,  u1;
           checkReportHandler.mTotalBVBVTests++;
           if (  s0.intersect_sweep(  movementVector,  s1,  v1,  u0,  u1 ) )
           {
           if (  (  u0>=0.0f ) && (  u0<1.0f ) )
           {
           // we have contact!
          
           // compute the 2 midpoints at the time of collision
           Vector3 c0(  position + movementVector*u0 );
           Vector3 c1(  p1 + v1*u0 );
          
           // compute the collide normal
           Vector3 d(  c1-c0 );
           if (  d.length(   ) > TINY )
           {
           d.normalise(   );
           } else
           {
           d = Vector3(  0.0f,   1.0f,   0.0f );
           }
          
           // fill out a collide report and add to report handler
           CollisionPair cr;
           cr.this_object = (  *other );
           cr.other_object = (  *other );
           cr.tstamp = 0.0;
           CollisionInfo collInfo;
           collInfo.contact = (  d*radius ) + c0;
           collInfo.this_normal = d;
           collInfo.other_normal = -d;
           cr.collInfos.push_back(  collInfo );
           checkReportHandler.addCollision(  cr,  own_id,  (  *other )->id );
           }
           }
           }
           else // CONTACT and EXACT
           {
           // do sphere-shape collision check
           ICollisionShape* shape = (  *other )->getShape(   );
          
           if (  shape )
           {
           CollisionPair cp;
           cp.this_object = (  *other );
           cp.other_object = (  *other );
           bool ret = shape->sweptSphereCheck(  ct,   (  *other )->getTransform(   ),   position,   movementVector,   radius,   cp );
           checkReportHandler.mTotalBVBVTests += cp.numBVBVTests;
           checkReportHandler.mTotalBVPrimTests += cp.numBVPrimTests;
           if (  ret )
           {
           cp.this_object = (  *other );
           cp.other_object = (  *other );
           checkReportHandler.addCollision(  cp,   own_id,   (  *other )->id );
           }
           }
           }
           }
          
           }
           }
           checkReportHandler.endFrame(   );
           return checkReportHandler.getAllCollisions(  cpPtr );
           }
          
           /// Test a ray against the collide objects in the collide context.
           /// The collType will be interpreted as follows:
           /// - COLLTYPE_IGNORE: illegal (  makes no sense )
           /// - COLLTYPE_QUICK: occlusion check only
           /// - COLLTYPE_CONTACT: return closest contact only
           /// - COLLTYPE_EXACT: return all contacts (  unsorted )
           /// @param line [in] the ray to test in global space
           /// @param collType [in] the collision type
           /// @param collClass [in] optional coll class (  COLLCLASS_ALWAYS_* if no coll class filtering wanted )
           /// @param cpPtr [out] will be filled with pointer to collide report pointers
           /// @return number of detected contacts (  1 per collide object )
     488   int CollisionContext::rayCheck(  const Ogre::Ray line,   const Real dist,   CollisionType collType,   CollisionClass collClass,   CollisionPair**& cpPtr )
           {
           assert(  collType != COLLTYPE_IGNORE );
          
           // create a bounding box from the line
           bbox3 bbox;
           bbox.begin_grow(   );
           bbox.grow(  line.getOrigin(   ) );
           bbox.grow(  line.getPoint(  dist ) );
           const int ownId = 0xffff;
          
           // initialize collision report handler
           checkReportHandler.beginFrame(   );
          
           // go through all attached collide objects
           for (  attached_list_iterator co = attached_list.begin(   ); co != attached_list.end(   ); ++co )
           {
           Vector3 coMin = (  *co )->minv;
           Vector3 coMax = (  *co )->maxv;
           // see if we have overlaps in all 3 dimensions
           if (  intervalOverlap(  bbox.vmin.x,  bbox.vmax.x,  coMin.x,  coMax.x ) &&
           intervalOverlap(  bbox.vmin.y,  bbox.vmax.y,  coMin.y,  coMax.y ) &&
           intervalOverlap(  bbox.vmin.z,  bbox.vmax.z,  coMin.z,  coMax.z )  )
           {
           // see if the candidate is in the ignore types set
           CollisionType ct = CollisionManager::getSingletonPtr(   )->queryCollType(  collClass,   (  *co )->getCollClass(   ) );
           if (  COLLTYPE_IGNORE == ct )
           {
           continue;
           }
          
          
           // check collision
           ICollisionShape* shape = (  *co )->getShape(   );
           if (  shape )
           {
           checkReportHandler.mTotalObjObjTests++;
           CollisionPair cp;
           bool ret = shape->rayCheck(  collType,   (  *co )->getTransform(   ),   line,   dist,   cp,   mRayCulling );
           checkReportHandler.mTotalBVBVTests += cp.numBVBVTests;
           checkReportHandler.mTotalBVBVTests += cp.numBVPrimTests;
           if (  ret )
           {
           cp.this_object = (  *co );
           cp.other_object = (  *co );
           checkReportHandler.addCollision(  cp,   ownId,   (  *co )->id );
           if (  COLLTYPE_QUICK == collType )
           {
           // break out of loop
           break;
           }
           }
           }
           }
           }
           checkReportHandler.endFrame(   );
          
           //if (  COLLTYPE_CONTACT == collType ) // FIXME!
           //{
           // // get closest contact only
           // return checkReportHandler.getClosestCollision(  line.getOrigin(   ),   cpPtr );
           //}
           //else
           //{
           // get all contacts (  unsorted )
           return checkReportHandler.getAllCollisions(  cpPtr );
           //}
           }
          
           /// Test a sphere against the collide objects in the collide context.
           /// The collType will be interpreted as follows:
           /// - COLLTYPE_IGNORE: illegal (  makes no sense )
           /// - COLLTYPE_QUICK: return all contacts,   do sphere-sphere check
           /// - COLLTYPE_CONTACT: return closest contact only,   sphere-shape
           /// - COLLTYPE_EXACT: return all contacts (  unsorted ),   sphere-shape
           /// @param theSphere [in] the sphere to test in global space
           /// @param collType [in] the collision type
           /// @param collClass [in] optional coll class (  COLLCLASS_ALWAYS_* if no coll class filtering wanted )
           /// @param cpPtr [out] will be filled with pointer to collide report pointers
           /// @return number of detected contacts (  1 per collide object )
     568   int CollisionContext::sphereCheck(  const Sphere& theSphere,   CollisionType collType,   CollisionClass collClass,   CollisionPair**& cpPtr )
           {
           assert(  collType != COLLTYPE_IGNORE );
          
           sphere ball;
           ball.set(  theSphere.getCenter(   ),  theSphere.getRadius(   ) );
           // create a bounding box from the sphere
           Vector3 vmin(  ball.p.x - ball.r,   ball.p.y - ball.r,   ball.p.z - ball.r );
           Vector3 vmax(  ball.p.x + ball.r,   ball.p.y + ball.r,   ball.p.z + ball.r );
           bbox3 bbox(  vmin,   vmax );
           const int ownId = 0xffff;
          
           // initialize collision report handler
           checkReportHandler.beginFrame(   );
          
           // go through all attached collide objects
           sphere s0;
           for (  attached_list_iterator co = attached_list.begin(   ); co != attached_list.end(   ); ++co )
           {
           // see if we have overlaps in all 3 dimensions
           if (  (  bbox.vmin.x < (  *co )->maxv.x ) && (  bbox.vmax.x > (  *co )->minv.x ) &&
           (  bbox.vmin.y < (  *co )->maxv.y ) && (  bbox.vmax.y > (  *co )->minv.y ) &&
           (  bbox.vmin.z < (  *co )->maxv.z ) && (  bbox.vmax.z > (  *co )->minv.z ) )
           {
           // see if the candidate is in the ignore types set
           CollisionType ct = CollisionManager::getSingletonPtr(   )->queryCollType(  collClass,   (  *co )->getCollClass(   ) );
           if (  COLLTYPE_IGNORE == ct )
           {
           continue;
           }
          
           checkReportHandler.mTotalObjObjTests++;
           if (  COLLTYPE_QUICK == ct )
           {
           // do sphere-sphere collision check
           const Matrix4 coTrans = (  *co )->getTransform(   );
           //s0.set(  coTrans[0][3],   coTrans[1][3],   coTrans[2][3],   (  *co )->getRadius(   ) );
           s0.set(  (  *co )->getShape(   )->getCenter(   ),   (  *co )->getRadius(   ) );
           checkReportHandler.mTotalBVBVTests++;
           if (  ball.intersects(  s0 ) )
           {
           CollisionPair cp;
           cp.this_object = (  *co );
           cp.other_object = (  *co );
           checkReportHandler.addCollision(  cp,   ownId,   (  *co )->id );
           }
           }
           else
           {
           // do sphere-shape collision check
           ICollisionShape* shape = (  *co )->getShape(   );
           if (  shape )
           {
           CollisionPair cp;
           bool ret = shape->sphereCheck(  collType,   (  *co )->getTransform(   ),   theSphere,   cp );
           checkReportHandler.mTotalBVBVTests += cp.numBVBVTests;
           checkReportHandler.mTotalBVPrimTests += cp.numBVPrimTests;
           if (  ret )
           {
           cp.this_object = (  *co );
           cp.other_object = (  *co );
           checkReportHandler.addCollision(  cp,   ownId,   (  *co )->id );
           }
           }
           }
           }
           }
           checkReportHandler.endFrame(   );
          
           //if (  COLLTYPE_CONTACT == collType )
           //{
           // // get closest contact only
           // return checkReportHandler.getClosestCollision(  ball.p,   cpPtr );
           //}
           //else
           //{
           // get all contacts (  unsorted )
           return checkReportHandler.getAllCollisions(  cpPtr );
           //}
           }
          
          
     650   void CollisionContext::update(  Real dt )
           {
           for (  attached_list_iterator co = attached_list.begin(   ); co != attached_list.end(   ); ++co )
           {
           (  *co )->update(  dt );
           }
           }
          
           /// reset position and timestamp of all attached collide objects to 0.0.
           /// This is useful at the beginning of a level to prevent phantom collisions
           /// (  when objects are repositioned to their starting point in the level ).
     661   void CollisionContext::reset(   )
           {
           Matrix4 identity = Matrix4::IDENTITY;
           for (  attached_list_iterator co = attached_list.begin(   ); co != attached_list.end(   ); ++co )
           {
           // This must be done twice,   so that old timestamp also becomes 0
           (  *co )->update(  -1.0,   identity );
           (  *co )->update(  -1.0,   identity );
           }
          
           }
          }

./components/ogre/ogreopcode/src/OgreCollisionManager.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCollisionManager.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreCollisionManager.h"
          #include "OgreCollisionReporter.h"
          
          #include "OgreMeshCollisionShape.h"
          #include "OgreEntityCollisionShape.h"
          #include "OgrePtrCollisionShape.h"
          #include "OgreBoxCollisionShape.h"
          #include "OgreSphereMeshCollisionShape.h"
          #include "OgreTerrainCollisionShape.h"
          
          using namespace Ogre;
          using namespace OgreOpcode::Details;
          template<> OgreOpcode::CollisionManager* Ogre::Singleton<OgreOpcode::CollisionManager>::ms_Singleton = 0;
          
          namespace OgreOpcode
          {
          
      43   CollisionManager* CollisionManager::getSingletonPtr(  void )
           {
           return ms_Singleton;
           }
          
      48   CollisionManager& CollisionManager::getSingleton(  void )
           {
           assert(   ms_Singleton  ); return (   *ms_Singleton  );
           }
          
      53   CollisionManager::CollisionManager(  SceneManager* sMgr )
           {
           mSceneMgr = sMgr;
           unique_id = 0;
           default_context = 0;
          
           Opcode::InitOpcode(   );
           // setup the tree collider
           opcTreeCollider.SetFirstContact(  false ); // report all contacts
           opcTreeCollider.SetFullBoxBoxTest(  false ); // use coarse BV-BV tests
           opcTreeCollider.SetFullPrimBoxTest(  false ); // use coarse primitive-BV tests
           opcTreeCollider.SetTemporalCoherence(  false ); // don't use temporal coherence
          
           // setup the ray collider
           opcRayCollider.SetFirstContact(  false ); // report all contacts
           opcRayCollider.SetTemporalCoherence(  false ); // no temporal coherence
           opcRayCollider.SetClosestHit(  false ); // all hits
           opcRayCollider.SetCulling(  true ); // with backface culling
           opcRayCollider.SetMaxDist(  100000.0f ); // max dist 100 km
           opcRayCollider.SetDestination(  &(  opcFaceCache ) ); // detected hits go here
          
           // setup the sphere collider
           opcSphereCollider.SetFirstContact(  false ); // report all contacts
           opcSphereCollider.SetTemporalCoherence(  false ); // no temporal coherence
          
           // setup the planes collider
           opcPlanesCollider.SetFirstContact(  false ); // report all contacts
           opcPlanesCollider.SetTemporalCoherence(  false ); // no temporal coherence
          
           // setup the LSS collider
           opcSweptSphereCollider.SetFirstContact(  false );
           opcSweptSphereCollider.SetTemporalCoherence(  false ); // no temporal coherence
           }
          
      87   CollisionManager::~CollisionManager(   )
           {
           /// release collision type definitions
           collclass_list.clear(   );
           colltype_table.clear(   );
          
           /// release any shapes and contexts that may still be around...
           ContextList::iterator ctxIter;
           for (  ctxIter = context_list.begin(   ); ctxIter != context_list.end(   ); ++ctxIter )
           {
           if(  ctxIter->second )
           delete ctxIter->second;
           }
           context_list.clear(   );
           ShapeList::iterator shpIter;
           for (  shpIter = shape_list.begin(   ); shpIter != shape_list.end(   ); ++shpIter )
           {
           if(  shpIter->second )
           delete shpIter->second;
           }
           shape_list.clear(   );
          
           Opcode::CloseOpcode(   );
           }
          
     112   CollisionContext *CollisionManager::createContext(  const Ogre::String& contextName )
           {
           ContextIterator i = context_list.find(  contextName );
           if (  i != context_list.end(   ) )
           {
           // Warning! Context already exsists. Return the exsisting one.
           return i->second;
           }
           CollisionContext *cc = new CollisionContext(  contextName );
           context_list.insert(  ContextList::value_type(  contextName,  cc ) );
           return cc;
           }
          
           /// Create a new,   possibly shared shape object.
     126   ICollisionShape *CollisionManager::createShape(  const Ogre::String& id,   const ShapeType shpType )
           {
           // assert(  id );
          
           Ogre::String new_id = getResourceID(  id );
          
           ShapeIterator i = shape_list.find(  new_id );
           if (  i != shape_list.end(   ) )
           {
           // Warning! Shape already exsists. Return the exsisting one,   if the pointer is valid
           // otherwise: delete the new_id shape from the shape list.
           if(  i->second )
           {
           return i->second;
           } else
           {
           shape_list.erase(  i->first );
           }
           }
           if(  shpType == SHAPETYPE_ENTITY )
           {
           EntityCollisionShape* cs = new EntityCollisionShape(  new_id );
           shape_list.insert(  ShapeList::value_type(  new_id,  cs ) );
           return cs;
           }
           if(  shpType == SHAPETYPE_MESH )
           {
           MeshCollisionShape* cs = new MeshCollisionShape(  new_id );
           shape_list.insert(  ShapeList::value_type(  new_id,  cs ) );
           return cs;
           }
           if(  shpType == SHAPETYPE_PTR )
           {
           PtrCollisionShape* cs = new PtrCollisionShape(  new_id );
           shape_list.insert(  ShapeList::value_type(  new_id,  cs ) );
           return cs;
           }
           if(  shpType == SHAPETYPE_BOX )
           {
           BoxCollisionShape* cs = new BoxCollisionShape(  new_id );
           shape_list.insert(  ShapeList::value_type(  new_id,  cs ) );
           return cs;
           }
           if(  shpType == SHAPETYPE_SPHERE )
           {
           SphereMeshCollisionShape* cs = new SphereMeshCollisionShape(  new_id );
           shape_list.insert(  ShapeList::value_type(  new_id,  cs ) );
           return cs;
           }
           if(  shpType == SHAPETYPE_TERRAIN )
           {
           TerrainCollisionShape* cs = new TerrainCollisionShape(  new_id );
           shape_list.insert(  ShapeList::value_type(  new_id,  cs ) );
           return cs;
           }
          
           // hacky way of returning a default ..
           EntityCollisionShape* cs = new EntityCollisionShape(  new_id );
           shape_list.insert(  ShapeList::value_type(  new_id,  cs ) );
           return cs;
           }
          
     188   MeshCollisionShape* CollisionManager::createMeshCollisionShape(  const Ogre::String& name )
           {
           return static_cast<MeshCollisionShape*>(  createShape(  name,   SHAPETYPE_MESH ) );
           }
          
     193   EntityCollisionShape* CollisionManager::createEntityCollisionShape(  const Ogre::String& name )
           {
           return static_cast<EntityCollisionShape*>(  createShape(  name,   SHAPETYPE_ENTITY ) );
           }
          
     198   BoxCollisionShape* CollisionManager::createBoxCollisionShape(  const Ogre::String& name )
           {
           return static_cast<BoxCollisionShape*>(  createShape(  name,   SHAPETYPE_BOX ) );
           }
          
     203   SphereMeshCollisionShape* CollisionManager::createSphereMeshCollisionShape(  const Ogre::String& name )
           {
           return static_cast<SphereMeshCollisionShape*>(  createShape(  name,   SHAPETYPE_SPHERE ) );
           }
          
     208   PtrCollisionShape* CollisionManager::createPtrCollisionShape(  const Ogre::String& name )
           {
           return static_cast<PtrCollisionShape*>(  createShape(  name,   SHAPETYPE_PTR ) );
           }
          
     213   TerrainCollisionShape* CollisionManager::createTerrainCollisionShape(  const Ogre::String& name )
           {
           return static_cast<TerrainCollisionShape*>(  createShape(  name,   SHAPETYPE_TERRAIN ) );
           }
          
     218   void CollisionManager::attachContext(  CollisionContext *cc )
           {
           Ogre::String contextName = cc->getName(   );
           ContextIterator i = context_list.find(  contextName );
           if (  i != context_list.end(   ) )
           {
           // Warning! Context already exsists.
           // If the pointer is 0 : Return without touching anything.
           if(  i->second )
           return;
           // Just remove the context from the list
           context_list.erase(  i->first );
           }
           context_list.insert(  ContextList::value_type(  contextName,  cc ) );
           }
          
     234   void CollisionManager::detachContext(  CollisionContext *cc )
           {
           assert(  cc );
           ContextIterator i,   iend;
           iend = context_list.end(   );
           for (  i = context_list.begin(   ); i != iend; ++i )
           {
           if (  i->second == cc )
           {
           context_list.erase(  i->first );
           break;
           }
           }
           }
          
     249   void CollisionManager::destroyContext(  CollisionContext *cc )
           {
           assert(  cc );
           ContextIterator i,   iend;
           iend = context_list.end(   );
           for (  i = context_list.begin(   ); i != iend; ++i )
           {
           if (  i->second == cc )
           {
           context_list.erase(  i->first );
           delete cc;
           break;
           }
           }
           }
          
     265   void CollisionManager::attachShape(  ICollisionShape *cs )
           {
           Ogre::String new_id = getResourceID(  cs->getName(   ) );
          
           ShapeIterator i = shape_list.find(  new_id );
           if (  i != shape_list.end(   ) )
           {
           // Warning! Shape already exsists.
           // Return doing nothing,   if the pointer is valid
           // otherwise: delete the new_id shape from the shape list.
           if(  i->second )
           {
           return;
           } else
           {
           shape_list.erase(  i->first );
           }
           }
          
           shape_list.insert(  ShapeList::value_type(  new_id,  cs ) );
           }
          
     287   void CollisionManager::detachShape(  ICollisionShape *cs )
           {
           assert(  cs );
           ShapeIterator i,   iend;
           iend = shape_list.end(   );
           for (  i = shape_list.begin(   ); i != iend; ++i )
           {
           if (  i->second == cs )
           {
           shape_list.erase(  i->first );
           break;
           }
           }
           }
          
     302   void CollisionManager::destroyShape(  ICollisionShape *cs )
           {
           assert(  cs );
           ShapeIterator i,   iend;
           iend = shape_list.end(   );
           for (  i = shape_list.begin(   ); i != iend; ++i )
           {
           if (  i->second == cs )
           {
           shape_list.erase(  i->first );
           delete cs;
           break;
           }
           }
           }
          
     318   SceneManager *CollisionManager::getSceneManager(  void )
           {
           return mSceneMgr;
           }
          
     323   CollisionContext *CollisionManager::getContext(  const Ogre::String& name )
           {
           ContextIterator i = context_list.find(  name );
          
           if (  i == context_list.end(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,   "Error! CollisionContext '" + name + "' not found. Did you create it?",   "CollisionManager::getContext" );
           }
           return i->second;
           }
          
     334   CollisionContext *CollisionManager::getDefaultContext(  void )
           {
           if (  !default_context )
           {
           default_context = createContext(  "default" );
           }
           return default_context;
           }
          
           /// Get a resource id string from a path name,   or create a unique
           /// resource id string if no name is given.
     345   Ogre::String CollisionManager::getResourceID(  const Ogre::String& name )
           {
           char buf[512];
           if (  name == "" )
           sprintf(  buf,  "res%d",  (  int )unique_id++ );
           else
           {
           // cut name to 32 characters and convert illegal chars
           // to underscores
           char c;
           char *str;
           int len = strlen(  name.c_str(   ) )+1;
           int off = len - sizeof(  buf );
           if (  off < 0 ) off = 0;
           len -= off;
           strcpy(  buf,  &(  name[off] ) );
           str = buf;
           while (  (  c = *str ) )
           {
           if (  (  c=='.' )||(  c=='/' )||(  c=='\\' )||(  c==':' ) )
           *str='_';
           str++;
           }
           }
           return Ogre::String(  buf );
           }
          
     372   void CollisionManager::addCollClass(  const Ogre::String& cl_name )
           {
           CollClassIterator i = collclass_list.find(  cl_name );
           if (  i != collclass_list.end(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_DUPLICATE_ITEM,   "Error! CollisionClass '" + cl_name + "' already exsist. Check your code.",   "CollisionManager::addCollClass" );
           }
           collclass_list.insert(  CollClassList::value_type(  cl_name,  collclass_list.size(   )+1 ) );
           }
          
     382   Ogre::String CollisionManager::getCollisionTypeEnum(  CollisionType colltype )
           {
           switch(  colltype )
           {
           case COLLTYPE_IGNORE:
           return "COLLTYPE_IGNORE";
           break;
           case COLLTYPE_QUICK:
           return "COLLTYPE_QUICK";
           break;
           case COLLTYPE_CONTACT:
           return "COLLTYPE_CONTACT";
           break;
           case COLLTYPE_BBOX:
           return "COLLTYPE_BBOX";
           break;
           case COLLTYPE_EXACT:
           return "COLLTYPE_EXACT";
           break;
           default:
           return "COLLTYPE_UNKNOWN";
           break;
           }
           }
           /// Important: Collision types MUST be bidirectional,   if one object
           /// checks collision with another object,   the collision type must
           /// be identical as if the check would be in the other direction.
           /// Due to the implementation of the top-level-collision check,  
           /// one of the 2 checks may return false,   although a collision may
           /// take place!
     412   void CollisionManager::addCollType(  const Ogre::String& cl1,   const Ogre::String& cl2,   CollisionType collType )
           {
           // Retrieve the first collision class
           CollClassIterator i = collclass_list.find(  cl1 );
           if (  i == collclass_list.end(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,   "CollisionClass '" + cl1 + "' not found! Did you call CollisionManager::addCollClass? If you did,   check the names of your collisionclasses.",   "CollisionManager::addCollType" );
           }
           int cc1 = i->second;
          
           // Retrieve the second collision class
           i = collclass_list.find(  cl2 );
           if (  i == collclass_list.end(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,   "CollisionClass '" + cl2 + "' not found! Did you call CollisionManager::addCollClass? If you did,   check the names of your collisionclasses.",   "CollisionManager::addCollType" );
           }
           int cc2 = i->second;
          
           int key = 0;
           get_merged_id(  cc1,   cc2,   key );
          
           // This key shouldn't exsist,   but check anyway.
           CollTypeIterator h = colltype_table.find(  key );
           if (  h != colltype_table.end(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_DUPLICATE_ITEM,   "Error! CollisionType '" + cl1 + "->" + cl2 + "' already exsist. Check your code.",   "CollisionManager::addCollType" );
           }
           colltype_table.insert(  CollTypeList::value_type(  key,  collType ) );
           }
          
     442   CollisionClass CollisionManager::queryCollClass(  const Ogre::String& cc )
           {
           CollClassIterator i = collclass_list.find(  cc );
          
           if (  i == collclass_list.end(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,   "CollisionClass '" + cc + "' not found!",   "CollisionManager::queryCollClass" );
           }
          
           return i->second;
           }
          
     454   CollisionType CollisionManager::queryCollType(  CollisionClass cc1,   CollisionClass cc2 )
           {
          
           // check for CollClass override cases
           if (  (  cc1 == COLLTYPE_ALWAYS_IGNORE ) || (  cc2 == COLLTYPE_ALWAYS_IGNORE ) )
           {
           return COLLTYPE_IGNORE;
           }
           else if (  (  cc1 == COLLTYPE_ALWAYS_QUICK ) || (  cc2 == COLLTYPE_ALWAYS_QUICK ) )
           {
           return COLLTYPE_QUICK;
           }
           else if (  (  cc1 == COLLTYPE_ALWAYS_CONTACT ) || (  cc2 == COLLTYPE_ALWAYS_CONTACT ) )
           {
           return COLLTYPE_CONTACT;
           }
           else if (  (  cc1 == COLLTYPE_ALWAYS_EXACT ) || (  cc2 == COLLTYPE_ALWAYS_EXACT ) )
           {
           return COLLTYPE_EXACT;
           }
          
           int key = 0;
           get_merged_id(  cc1,   cc2,   key );
           CollTypeIterator i = colltype_table.find(  key );
           if (  i == colltype_table.end(   ) )
           {
           // Return a default,   in case the user don't want to define every possible collision type.
           return COLLTYPE_IGNORE;
           //OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,   "CollisionType '" + getCollisionTypeEnum(  colltype_table[key] ) + "' not found!",   "CollisionManager::queryCollType" );
           }
           return colltype_table[key];
           }
          
     487   CollisionType CollisionManager::queryCollType(  const Ogre::String& s_cc1,   const Ogre::String& s_cc2 )
           {
           CollClassIterator i = collclass_list.find(  s_cc1 );
           if (  i == collclass_list.end(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,   "CollisionClass '" + s_cc1 + "' not found!",   "CollisionManager::queryCollType" );
           }
           CollisionClass class1 = i->second;
           i = collclass_list.find(  s_cc2 );
           if (  i == collclass_list.end(   ) )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,   "CollisionClass '" + s_cc2 + "' not found!",   "CollisionManager::queryCollType" );
           }
           CollisionClass class2 = i->second;
          
           return queryCollType(  class1,  class2 );
           }
          
          };

./components/ogre/ogreopcode/src/OgreCollisionObject.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreCollisionObject.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeExports.h"
          #include "OgreCollisionObject.h"
          #include "OgreCollisionReporter.h"
          #include "OgreCollisionManager.h"
          #include "OgreOpcodeMath.h"
          #include "OgreOpcodeUtils.h"
          #include "BP_Scene.h"
          #include "BP_Proxy.h"
          
          using namespace Ogre;
          using namespace OgreOpcode::Details;
          
          namespace OgreOpcode
          {
      42   void CollisionObject::getSAPMinMax(  Vector3& sapMin,   Vector3& sapMax ) const
           {
           //sapMin = Vector3(  n_min(  old_minv.x,  minv.x ),  
           // n_min(  old_minv.y,  minv.y ),  
           // n_min(  old_minv.z,  minv.z ) );
           //sapMax = Vector3(  n_max(  old_maxv.x,  maxv.x ),  
           // n_max(  old_maxv.y,  maxv.y ),  
           // n_max(  old_maxv.z,  maxv.z ) );
           sapMin = minv;
           sapMax = maxv;
           }
          
      54   void CollisionObject::update(  Real t,   Matrix4& m )
           {
           assert(  is_attached );
          
           mForcedUpdate = true; ///FIXME Blah. Do we really need this?
          
           if(  mForcedUpdate )
           {
           mNeedsUpdating = true;
           }
           else
           {
           Vector3 p0(  old_matrix[0][3],   old_matrix[1][3],   old_matrix[2][3] );
           Vector3 v0(  new_matrix[0][3],   new_matrix[1][3],   new_matrix[2][3] );
           Vector3 moved = p0 - v0;
          
           bool hasMoved = (  moved != Vector3::ZERO );
          
           mNeedsUpdating = hasMoved;
           }
          
           //if(  mNeedsUpdating )
           //{
           // getShape(   )->computeIceABB(   );
           //}
          
           old_matrix = new_matrix;
           old_pos = new_pos;
           new_matrix = m;
          
           new_pos = getShape(   )->getParentSceneNode(   )->_getDerivedPosition(   );
           // Get center in world space.
           Vector3 lMin,  lMax;
           getShape(   )->getMinMax(  lMin,  lMax );
           lMax-=lMin;
           mRadius = lMax.length(   )*0.5;
          
           old_minv = minv;
           old_maxv = maxv;
           getShape(   )->getMinMax(  minv,  maxv );
          
           // if old_matrix etc are not yet valid,  
           // initialize with the current values,   to prevent "startup popping"
           bool oldValsInvalid = (  m_tdelta <= 0.0 );
           if (  oldValsInvalid )
           {
           old_matrix = new_matrix;
           old_pos = new_pos;
           old_minv = minv;
           old_maxv = maxv;
           }
           m_tdelta = t;
          
           }
          
     109   bool CollisionObject::contact(  CollisionObject *other,   // the other object
           CollisionType ct,  
     111   CollisionPair& cr )
           {
           // This object moved from p0 to p0+v0,   the other from p1 to p1+v1.
           Vector3 p0(  old_matrix[0][3],   old_matrix[1][3],   old_matrix[2][3] );
           Vector3 p1(  other->old_matrix[0][3],   other->old_matrix[1][3],   other->old_matrix[2][3] );
           Vector3 v0(  new_matrix[0][3],   new_matrix[1][3],   new_matrix[2][3] );
           //Vector3 p0 = old_pos;
           //Vector3 p1 = other->old_pos;
           //Vector3 v0 = new_pos;
           v0 -= p0;
           Vector3 v1(  Vector3(  other->new_matrix[0][3],   other->new_matrix[1][3],   other->new_matrix[2][3] ) - p1 );
           //Vector3 v1(  other->new_pos - p1 );
          
           bool has_contact = false;
           switch (  ct )
           {
           case COLLTYPE_QUICK:
           {
           // do a contact check between 'moving spheres'
           sphere s0(  p0,  mRadius );
           sphere s1(  p1,  other->mRadius );
           Real u0,  u1;
           if (  s0.intersect_sweep(  v0,  s1,  v1,  u0,  u1 ) )
           {
           // there may be a valid contact somewhere along the path
           if (  (  u0>=0.0f ) && (  u0<1.0f ) )
           {
           // compute the 2 midpoints at the time of collision
           Vector3 c0(  p0 + v0*u0 );
           Vector3 c1(  p1 + v1*u0 );
          
           // compute the collide normal
           Vector3 d(  c1-c0 );
           if (  d.length(   ) > TINY )
           {
           d.normalise(   );
           } else
           {
           d = Vector3(  0.0f,   1.0f,   0.0f );
           }
          
           // compute the contact point
           CollisionInfo collInfo;
           collInfo.contact = (  d*mRadius ) + c0;
          
           // compute the collide normals
           collInfo.this_normal = d;
           collInfo.other_normal = -d;
           cr.collInfos.push_back(  collInfo );
          
           // compute the timestamp where the collision happened
           cr.tstamp = m_tdelta*u0;
           has_contact = true;
           }
           }
           }
           break;
          
           case COLLTYPE_EXACT:
           case COLLTYPE_CONTACT:
           {
           // If distance traveled is more then 1/8 then each of the object's
           // radii,   then we do several tests along the line
           // of movements.
          
           // WVB:
           // This isn't likely to work particularly well for objects
           // with large rotational motion. For that it would be better
           // to blend the transformations along the path as well,  
           // and to also use amount of rotation in determining how many
           // steps are necessary. That would bring this another step closer
           // to being a true continuous collision detection system.
          
           Real rq0 = mRadius * 0.125f;
           Real rq1 = other->mRadius * 0.125f;
           Real v0_len = v0.length(   );
           Real v1_len = v1.length(   );
           int num = (  int ) n_max(  (  v0_len/rq0 ),   (  v1_len/rq1 ) );
           const int maxChecks = 16;
           if (  num == 0 )
           {
           num = 1;
           } else if (  num > maxChecks )
           {
           num = maxChecks;
           }
           Vector3 d0(  v0 / float(  num ) );
           Vector3 d1(  v1 / float(  num ) );
           Matrix4 self_matrix = old_matrix;
           Matrix4 other_matrix = other->old_matrix;
           int i;
          
           for (  i=0; i<num; i++ )
           {
           p0 += d0;
           p1 += d1;
           self_matrix[0][3] = p0.x;
           self_matrix[1][3] = p0.y;
           self_matrix[2][3] = p0.z;
           other_matrix[0][3] = p1.x;
           other_matrix[1][3] = p1.y;
           other_matrix[2][3] = p1.z;
           if (  mShape->collide(  ct,   self_matrix,   other->getShape(   ),   other_matrix,   cr ) )
           {
           // CONTACT!!!
           double dt = (  m_tdelta ) / num;
           cr.tstamp = dt*i;
           return true;
           }
           }
           }
           break;
          
           default:
           break;
           }
           return has_contact;
           }
          
     230   void CollisionObject::addToCollideList(  CollisionObject* collObj )
           {
           collideList.push_back(  collObj );
           }
          
     235   void CollisionObject::collide(  void )
           {
           assert(  is_attached );
           assert(  mContext );
          
           CollisionReporter *crh = &(  mContext->collideReportHandler );
          
           //LogManager::getSingleton(   ).logMessage(  getName(   ) + " is about to test collisions." );
          
           for (  collideListIterator i = collideList.begin(   ); i != collideList.end(   ); ++i )
           {
           // is the candidate in the ignore types set?
           CollisionObject *other = (  *i );
          
           //LogManager::getSingleton(   ).logMessage(  getName(   ) + " is testing against " + other->getName(   ) );
          
           // am I trying to collide with myself?
           if (   id == other->id  ) continue;
          
           // query the collision type defined for those two objects
           CollisionType ct = CollisionManager::getSingletonPtr(   )->queryCollType(  getCollClass(   ),  other->getCollClass(   ) );
          
           // ignore collision?
           if (  COLLTYPE_IGNORE == ct ) continue;
          
           // has this collision already been checked by the other object?
           if (  !crh->collisionTested(  id,  other->id ) )
           {
           // no,   we're first...
           crh->mTotalObjObjTests++;
           crh->addCollisionTest(  id,  other->id );
          
           // ask objects whether they collide...
           // FIXME: probably do velocity-based finer
           // grained control here ?!?!?!
           CollisionPair cr;
           bool ret = contact(  other,  ct,  cr );
           crh->mTotalBVBVTests += cr.numBVBVTests;
           crh->mTotalBVPrimTests += cr.numBVPrimTests;
           crh->mTotalPrimPrimTests += cr.numPrimPrimTests;
           if (  ret )
           {
           cr.this_object = this;
           cr.other_object = other;
           crh->addCollision(  cr,  id,  other->id );
           num_colls++;
           other->num_colls++;
           }
           }
           }
           collideList.clear(   );
           mNeedsUpdating = false;
           }
          
     289   void CollisionObject::visualizeRadii(   )
           {
           // render the objects radii
           int dim;
           Real dr = Ogre::Math::DegreesToRadians(  5.0f );
           Vector3 ctr = getShape(   )->getCenter(   );
           for (  dim=0; dim<3; dim++ )
           {
           Real r;
           for (  r=0.0f; r< Ogre::Math::DegreesToRadians(  360.0f ); r+=dr )
           {
           Real sin_r0 = (  Real ) sin(  r );
           Real cos_r0 = (  Real ) cos(  r );
           float sin_r1 = (  Real ) sin(  r+dr );
           Real cos_r1 = (  Real ) cos(  r+dr );
           Vector3 v0_x(  0.0f,   sin_r0*mRadius,   cos_r0*mRadius ); v0_x+=ctr;
           Vector3 v1_x(  0.0f,   sin_r1*mRadius,   cos_r1*mRadius ); v1_x+=ctr;
           Vector3 v0_y(  sin_r0*mRadius,   0.0f,   cos_r0*mRadius ); v0_y+=ctr;
           Vector3 v1_y(  sin_r1*mRadius,   0.0f,   cos_r1*mRadius ); v1_y+=ctr;
           Vector3 v0_z(  sin_r0*mRadius,   cos_r0*mRadius,   0.0f ); v0_z+=ctr;
           Vector3 v1_z(  sin_r1*mRadius,   cos_r1*mRadius,   0.0f ); v1_z+=ctr;
          
           getContext(   )->getVisualDebugger(   )->addRadiiLine(  v0_x.x,  v0_x.y,  v0_x.z,   v1_x.x,  v1_x.y,  v1_x.z );
           getContext(   )->getVisualDebugger(   )->addRadiiLine(  v0_y.x,  v0_y.y,  v0_y.z,   v1_y.x,  v1_y.y,  v1_y.z );
           getContext(   )->getVisualDebugger(   )->addRadiiLine(  v0_z.x,  v0_z.y,  v0_z.z,   v1_z.x,  v1_z.y,  v1_z.z );
           }
           }
           }
          
     318   void CollisionObject::visualizeContacts(   )
           {
           static int contactCount = 0;
           static bool bufferContacts = true;
          
           if (  num_colls > 0 )
           {
           // Retrieve collision contact information and store them in mRecentContactList.
          
           CollisionPair **pcr;
           int num = mContext->getCollisions(  this,  pcr );
           int i;
           for (  i = 0; i < num; i++ )
           {
           CollisionPair *cr = pcr[i];
           for (  int currColl = 0; currColl < static_cast<int>(  cr->collInfos.size(   ) ); currColl++ )
           {
           if(  bufferContacts )
           contactCount++;
          
           CollisionInfo collInfo;
           collInfo.contact = cr->collInfos[currColl].contact;
           collInfo.this_normal = cr->collInfos[currColl].this_normal * 5;
           collInfo.other_normal = cr->collInfos[currColl].other_normal * 5;
           mRecentContactList.push_back(  collInfo );
           if(  !bufferContacts )
           mRecentContactList.pop_front(   );
           }
           }
           }
          
           // render any collision contact points
           if (  mRecentContactList.size(   ) > 0 )
           {
           std::list<CollisionInfo>::iterator contactIter;
           for (  contactIter = mRecentContactList.begin(   ); contactIter != mRecentContactList.end(   ); ++contactIter )
           {
           Vector3 cnt = (  *contactIter ).contact;
           getContext(   )->getVisualDebugger(   )->addContactLine(  cnt.x-0.5f,  cnt.y,  cnt.z,   cnt.x+0.5f,  cnt.y,  cnt.z );
           getContext(   )->getVisualDebugger(   )->addContactLine(  cnt.x,  cnt.y-0.5f,  cnt.z,   cnt.x,  cnt.y+0.5f,  cnt.z );
           getContext(   )->getVisualDebugger(   )->addContactLine(  cnt.x,  cnt.y,  cnt.z-0.5f,   cnt.x,  cnt.y,  cnt.z+0.5f );
          
           Vector3 n = (  *contactIter ).this_normal * 5;
           getContext(   )->getVisualDebugger(   )->addContactNormalsLine(  cnt.x,  cnt.y,  cnt.z,   cnt.x+n.x,  cnt.y+n.y,  cnt.z+n.z );
           n = (  *contactIter ).other_normal * 5;
           getContext(   )->getVisualDebugger(   )->addContactNormalsLine(  cnt.x,  cnt.y,  cnt.z,   cnt.x+n.x,  cnt.y+n.y,  cnt.z+n.z );
           }
           }
          
           if(  contactCount > 10 )
           bufferContacts = false;
           }
          
     371   void CollisionObject::visualizeBoundingBoxes(   )
           {
           // render the objects bounding boxes (  stretched by their movement )
           Vector3 v0,   v1;
           getShape(   )->getMinMax(  v0,  v1 );
          
           getContext(   )->getVisualDebugger(   )->addBBLine(  v0.x,  v0.y,  v0.z,   v1.x,  v0.y,  v0.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v1.x,  v0.y,  v0.z,   v1.x,  v1.y,  v0.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v1.x,  v1.y,  v0.z,   v0.x,  v1.y,  v0.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v0.x,  v1.y,  v0.z,   v0.x,  v0.y,  v0.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v0.x,  v0.y,  v1.z,   v1.x,  v0.y,  v1.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v1.x,  v0.y,  v1.z,   v1.x,  v1.y,  v1.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v1.x,  v1.y,  v1.z,   v0.x,  v1.y,  v1.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v0.x,  v1.y,  v1.z,   v0.x,  v0.y,  v1.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v0.x,  v0.y,  v0.z,   v0.x,  v0.y,  v1.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v1.x,  v0.y,  v0.z,   v1.x,  v0.y,  v1.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v1.x,  v1.y,  v0.z,   v1.x,  v1.y,  v1.z );
           getContext(   )->getVisualDebugger(   )->addBBLine(  v0.x,  v1.y,  v0.z,   v0.x,  v1.y,  v1.z );
           }
          
     391   void CollisionObject::nodeUpdated(  const Node* node )
           {
           mNeedsUpdating = true;
           }
          
     396   void CollisionObject::do_broadphase(   )
           {
           if (  mProxy )
           {
           mProxy->setBBox(  minv,   maxv );
           }
           else
           {
           mProxy = mContext->getBroadPhase(   )->createProxy(  this,   minv,   maxv );
           }
           }
          
     408   void CollisionObject::remove_broadphase(   )
           {
           if(  mProxy )
           {
           mContext->getBroadPhase(   )->deleteProxy(  mProxy );
           mProxy = 0;
           }
           }
          }
          
          //------------------------------------------------------------------------

./components/ogre/ogreopcode/src/OgreEntityCollisionShape.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreEntityCollisionShape.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeExports.h"
          #include "OgreEntityCollisionShape.h"
          #include "OgreCollisionReporter.h"
          #include "OgreCollisionManager.h"
          #include "OgreOpcodeMath.h"
          #include "OgreOpcodeUtils.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           //------------------------------------------------------------------------
      39   EntityCollisionShape::EntityCollisionShape(  const Ogre::String& name )
           : ICollisionShape(  name ),  
           mDummyNode(  0 ),  
           mDummyCreated(  false )
           {
           }
          
           //------------------------------------------------------------------------
      47   EntityCollisionShape::~EntityCollisionShape(   )
           {
           if (  mEntity && mEntity->hasSkeleton(   ) )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mEntity->removeSoftwareSkinningRequest(  false );
          #else
           mEntity->removeSoftwareAnimationRequest(  false );
          #endif
           }
           delete[] mVertexBuf;
           delete[] mFaceBuf;
           // Note that unlike PtrCollisionShape which creates a node,   mParentNode is used
           // as a reference to the Entity's parent SceneNode. We are not responsible for cleanup
           mParentNode = NULL;
           }
          
           //------------------------------------------------------------------------
           ///////////////////////////////////////////////////////////////////////////////
           /// Counts how many indices (  faces ) and vertices an entity contains.
           /// @param[in] entity Entity to count its data.
           /// @param[out] index_count Number of indices.
           /// @param[out] vertex_count Number of vertices.
           /// @author Yavin from the Ogre4J team
           ///////////////////////////////////////////////////////////////////////////////
      72   void EntityCollisionShape::countIndicesAndVertices(  Entity * entity,   size_t & index_count,   size_t & vertex_count )
           {
          // Mesh * mesh = entity->getMesh(   ).getPointer(   );
          
          #ifdef BUILD_AGAINST_AZATHOTH
           bool hwSkinning = entity->isHardwareSkinningEnabled(   );
          #else
           bool hwSkinning = entity->isHardwareAnimationEnabled(   );
          #endif
          
           bool added_shared = false;
           index_count = 0;
           vertex_count = 0;
          
           // Calculate how many vertices and indices we're going to need
           for (   size_t i = 0; i < entity->getNumSubEntities(   ); ++i )
           {
           SubEntity* subEntity = entity->getSubEntity(  i );
           if (  subEntity->isVisible(   ) ) {
           SubMesh* submesh = subEntity->getSubMesh(   );
          
           // We only need to add the shared vertices once
           if(  submesh->useSharedVertices )
           {
           if(   !added_shared  )
           {
           vertex_count += submesh->parent->sharedVertexData->vertexCount;
           added_shared = true;
           }
           }
           else
           {
           vertex_count += submesh->vertexData->vertexCount;
           }
          
           // Add the indices
           index_count += submesh->indexData->indexCount;
           }
           }
           }
          
          
           //------------------------------------------------------------------------
           //////////////////////////////////////////////////////////////////////////
           /// Converts mesh vertex and face data into simple float arrays.
           /// If the buffer parameters are null then that data is not converted.
           /// @param[in] entity Entity to extract data from.
           /// @param[out] vertexBuf Target vertex data array (  can be null ).
           /// @param[in] size_t vertex_count Number of vertices.
           /// @param[out] faceData Target face data array (  can be null ).
           /// @param[int] index_count Number of indices.
           /// @author Yavin from the Ogre4J team
           //////////////////////////////////////////////////////////////////////////
     125   void EntityCollisionShape::convertMeshData(  Entity * entity,  
     126   float * vertexBuf,   size_t vertex_count,  
     127   size_t * faceBuf,   size_t index_count )
           {
           //---------------------------------------------------------------------
           // CONVERT MESH DATA
           //---------------------------------------------------------------------
          // MeshPtr mesh = entity->getMesh(   );
           bool added_shared = false;
           size_t current_offset = 0;
           size_t shared_offset = 0;
           size_t next_offset = 0;
           size_t index_offset = 0;
           int numOfSubs = 0;
          
           bool useSoftwareBlendingVertices = entity->hasSkeleton(   );
          
           if (  useSoftwareBlendingVertices )
           {
           entity->_updateAnimation(   );
           }
          
           // Run through the submeshes again,   adding the data into the arrays
           for (   size_t i = 0; i < entity->getNumSubEntities(   ); ++i )
           {
           SubEntity* subEntity = entity->getSubEntity(  i );
           if (  subEntity->isVisible(   ) ) {
           SubMesh* submesh = subEntity->getSubMesh(   );
           bool useSharedVertices = submesh->useSharedVertices;
          
           if (  vertexBuf )
           {
           //----------------------------------------------------------------
           // GET VERTEXDATA
           //----------------------------------------------------------------
           const VertexData * vertex_data;
           if(  useSoftwareBlendingVertices )
           #ifdef BUILD_AGAINST_AZATHOTH
           vertex_data = useSharedVertices ? entity->_getSharedBlendedVertexData(   ) : entity->getSubEntity(  i )->_getBlendedVertexData(   );
           #else
           vertex_data = useSharedVertices ? entity->_getSkelAnimVertexData(   ) : entity->getSubEntity(  i )->_getSkelAnimVertexData(   );
           #endif
           else
           vertex_data = useSharedVertices ? submesh->parent->sharedVertexData : submesh->vertexData;
          
           if(  (  !useSharedVertices )||(  useSharedVertices && !added_shared ) )
           {
           if(  useSharedVertices )
           {
           added_shared = true;
           shared_offset = current_offset;
           }
          
           const VertexElement* posElem =
           vertex_data->vertexDeclaration->findElementBySemantic(  Ogre::VES_POSITION );
          
           HardwareVertexBufferSharedPtr vbuf =
           vertex_data->vertexBufferBinding->getBuffer(  posElem->getSource(   ) );
          
           unsigned char* vertex =
           static_cast<unsigned char*>(  vbuf->lock(  HardwareBuffer::HBL_READ_ONLY ) );
          
           // There is _no_ baseVertexPointerToElement(   ) which takes an Ogre::Real or a double
           // as second argument. So make it float,   to avoid trouble when Ogre::Real is
           // comiled/typedefed as double:
           float* pReal;
          
           #ifdef BUILD_AGAINST_AZATHOTH
           if (  useSoftwareBlendingVertices )
           {
           // Blended bone data is computed in world space.
           // Opcode expects data in local coordinates.
           Matrix4 xform = entity->_getParentNodeFullTransform(   ).inverse(   );
          
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
           Vector3 v = Vector3(  pReal[0],  pReal[1],  pReal[2] );
           v = xform * v;
           size_t n = current_offset*3 + j*3;
           vertexBuf[n + 0] = v[0];
           vertexBuf[n + 1] = v[1];
           vertexBuf[n + 2] = v[2];
           }
           }
           else
           {
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
           size_t n = current_offset*3 + j*3;
           vertexBuf[n + 0] = pReal[0];
           vertexBuf[n + 1] = pReal[1];
           vertexBuf[n + 2] = pReal[2];
           }
           }
           #else
          
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
          
           size_t n = current_offset*3 + j*3;
          
           vertexBuf[n + 0] = pReal[0];
           vertexBuf[n + 1] = pReal[1];
           vertexBuf[n + 2] = pReal[2];
           }
           #endif
          
           vbuf->unlock(   );
           next_offset += vertex_data->vertexCount;
           }
           }
          
           if (  faceBuf )
           {
           //----------------------------------------------------------------
           // GET INDEXDATA
           //----------------------------------------------------------------
           IndexData* index_data = submesh->indexData;
           size_t numTris = index_data->indexCount / 3;
           HardwareIndexBufferSharedPtr ibuf = index_data->indexBuffer;
          
           bool use32bitindexes = (  ibuf->getType(   ) == HardwareIndexBuffer::IT_32BIT );
          
           uint32 *pLong = static_cast<uint32*>(  ibuf->lock(  HardwareBuffer::HBL_READ_ONLY ) );
           uint16* pShort = reinterpret_cast<uint16*>(  pLong );
          
          
           size_t offset = (  submesh->useSharedVertices )? shared_offset : current_offset;
          
           if (   use32bitindexes  )
           {
           for (   size_t k = 0; k < numTris*3; ++k )
           {
           faceBuf[index_offset++] = pLong[k] + static_cast<int>(  offset );
           }
           }
           else
           {
           for (   size_t k = 0; k < numTris*3; ++k )
           {
           faceBuf[index_offset++] = static_cast<int>(  pShort[k] ) + static_cast<int>(  offset );
           }
           }
          
           ibuf->unlock(   );
           }
          
           current_offset = next_offset;
           }
           }
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @param [in,   out] ent Entity * <TODO: insert parameter description here>
           /// @return bool <TODO: insert return value description here>
     284   bool EntityCollisionShape::load(  Entity* ent )
           {
           assert(  ent );
           assert(  !mVertexBuf && !mFaceBuf );
           mEntity = ent;
          
           if (  mEntity->hasSkeleton(   ) )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mEntity->addSoftwareSkinningRequest(  false );
          #else
           mEntity->addSoftwareAnimationRequest(  false );
          #endif
           }
          
           mParentNode = mEntity->getParentSceneNode(   );
           mFullTransform = mEntity->getParentSceneNode(   )->_getFullTransform(   );
           //mParentNode->getWorldTransforms(  &mFullTransform );
           return rebuild(   );
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     308   bool EntityCollisionShape::rebuild(   )
           {
           assert(  mEntity );
          
           // NOTE: Assuming presence or absence of skeleton hasn't changed!
          
           size_t vertex_count = 0;
           size_t index_count = 0;
           countIndicesAndVertices(  mEntity,   index_count,   vertex_count );
          
           // Re-Allocate space for the vertices and indices
           if (  mVertexBuf && numVertices != vertex_count ) {
           delete [] mVertexBuf;
           mVertexBuf = 0;
           }
           if (  mFaceBuf && numFaces != index_count/3 ) {
           delete [] mFaceBuf;
           mFaceBuf = 0;
           }
          
           if (  !mVertexBuf )
           mVertexBuf = new float[vertex_count * 3];
           if (  !mFaceBuf )
           mFaceBuf = new size_t[index_count];
          
           if (  index_count > 0 && vertex_count > 0 ) {
           convertMeshData(  mEntity,   mVertexBuf,   vertex_count,   mFaceBuf,   index_count  );
          
           numFaces = index_count / 3;
           numVertices = vertex_count;
          
           opcMeshAccess.SetNbTriangles(  numFaces );
           opcMeshAccess.SetNbVertices(  numVertices );
           opcMeshAccess.SetPointers(  (  IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           //opcMeshAccess.SetStrides(  sizeof(  int ) * 3,   sizeof(  float ) * 3 );
          
           return _rebuildFromCachedData(   );
           }
           return true;
          
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     353   bool EntityCollisionShape::refit(   )
           {
           // bail if we don't need to refit
           if (   mShapeIsStatic  )
           return true;
          
           assert(  mEntity && mVertexBuf );
          
          #ifdef _DEBUG
           size_t vertex_count = 0;
           size_t index_count = 0;
           countIndicesAndVertices(  mEntity,   index_count,   vertex_count );
           assert(  numVertices == vertex_count );
          #endif
          
           if (  numVertices > 0 ) {
           convertMeshData(  mEntity,   mVertexBuf,   numVertices );
          
           return _refitToCachedData(   );
           }
           return true;
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     379   bool EntityCollisionShape::_refitToCachedData(   )
           {
           assert(  mEntity && mVertexBuf );
          
           // rebuild tree
           if (  !opcModel.Refit(   ) )
           {
           LogManager::getSingleton(   ).logMessage(  
           "OgreOpcode::EntityCollisionShape::_refitToCachedData(   ): OPCODE Quick refit not possible with the given tree type." );
           // Backup plan -- rebuild full tree
           opcMeshAccess.SetPointers(  (  IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
           }
          
           calculateSize(   );
          
           //computeIceABB(   );
          
           return true;
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     405   bool EntityCollisionShape::_rebuildFromCachedData(   )
           {
           assert(  mEntity && mVertexBuf && mFaceBuf );
          
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
          
           calculateSize(   );
          
           //computeIceABB(   );
          
           return true;
           }
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
     421   void EntityCollisionShape::createDummyNode(   )
           {
           if(  !mDummyCreated )
           {
           mDummyNode = CollisionManager::getSingletonPtr(   )->getSceneManager(   )->getRootSceneNode(   )->createChildSceneNode(  getName(   ) );
           mDummyNode->attachObject(  mEntity );
           mDummyCreated = true;
           }
          
           }
          }
          
          //------------------------------------------------------------------------

./components/ogre/ogreopcode/src/OgreMeshCollisionShape.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreMeshCollisionShape.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeExports.h"
          #include "OgreMeshCollisionShape.h"
          #include "OgreCollisionReporter.h"
          #include "OgreCollisionManager.h"
          #include "OgreOpcodeMath.h"
          #include "OgreOpcodeUtils.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           //------------------------------------------------------------------------
      39   MeshCollisionShape::MeshCollisionShape(  const Ogre::String& name )
           : ICollisionShape(  name ),  
           mDummyNode(  0 ),  
           mDummyCreated(  false )
           {
           }
          
           //------------------------------------------------------------------------
      47   MeshCollisionShape::~MeshCollisionShape(   )
           {
           if (  mEntity && mEntity->hasSkeleton(   ) )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mEntity->removeSoftwareSkinningRequest(  false );
          #else
           mEntity->removeSoftwareAnimationRequest(  false );
          #endif
           }
           delete[] mVertexBuf;
           delete[] mFaceBuf;
           }
          
           //------------------------------------------------------------------------
           ///////////////////////////////////////////////////////////////////////////////
           /// Counts how many indices (  faces ) and vertices an entity contains.
           /// @param[in] entity Entity to count its data.
           /// @param[out] index_count Number of indices.
           /// @param[out] vertex_count Number of vertices.
           /// @author Yavin from the Ogre4J team
           ///////////////////////////////////////////////////////////////////////////////
      69   void MeshCollisionShape::countIndicesAndVertices(  Entity * entity,   size_t & index_count,   size_t & vertex_count )
           {
           Mesh * mesh = entity->getMesh(   ).getPointer(   );
          
          #ifdef BUILD_AGAINST_AZATHOTH
           bool hwSkinning = entity->isHardwareSkinningEnabled(   );
          #else
           bool hwSkinning = entity->isHardwareAnimationEnabled(   );
          #endif
          
           bool added_shared = false;
           index_count = 0;
           vertex_count = 0;
          
           // Calculate how many vertices and indices we're going to need
           for (   unsigned short i = 0; i < mesh->getNumSubMeshes(   ); ++i )
           {
           SubMesh* submesh = mesh->getSubMesh(   i  );
          
           // We only need to add the shared vertices once
           if(  submesh->useSharedVertices )
           {
           if(   !added_shared  )
           {
           vertex_count += mesh->sharedVertexData->vertexCount;
           added_shared = true;
           }
           }
           else
           {
           vertex_count += submesh->vertexData->vertexCount;
           }
          
           // Add the indices
           index_count += submesh->indexData->indexCount;
           }
           }
          
          
           //------------------------------------------------------------------------
           //////////////////////////////////////////////////////////////////////////
           /// Converts mesh vertex and face data into simple float arrays.
           /// If the buffer parameters are null then that data is not converted.
           /// @param[in] entity Entity to extract data from.
           /// @param[out] vertexBuf Target vertex data array (  can be null ).
           /// @param[in] size_t vertex_count Number of vertices.
           /// @param[out] faceData Target face data array (  can be null ).
           /// @param[int] index_count Number of indices.
           /// @author Yavin from the Ogre4J team
           //////////////////////////////////////////////////////////////////////////
     119   void MeshCollisionShape::convertMeshData(  Entity * entity,  
     120   float * vertexBuf,   size_t vertex_count,  
     121   size_t * faceBuf,   size_t index_count )
           {
           //---------------------------------------------------------------------
           // CONVERT MESH DATA
           //---------------------------------------------------------------------
           MeshPtr mesh = entity->getMesh(   );
           bool added_shared = false;
           size_t current_offset = 0;
           size_t shared_offset = 0;
           size_t next_offset = 0;
           size_t index_offset = 0;
           int numOfSubs = 0;
          
           bool useSoftwareBlendingVertices = entity->hasSkeleton(   );
          
           if (  useSoftwareBlendingVertices )
           {
           entity->_updateAnimation(   );
           }
          
           // Run through the submeshes again,   adding the data into the arrays
           for (   size_t i = 0; i < mesh->getNumSubMeshes(   ); ++i )
           {
           SubMesh* submesh = mesh->getSubMesh(  i );
           bool useSharedVertices = submesh->useSharedVertices;
          
           if (  vertexBuf )
           {
           //----------------------------------------------------------------
           // GET VERTEXDATA
           //----------------------------------------------------------------
           const VertexData * vertex_data;
           if(  useSoftwareBlendingVertices )
          #ifdef BUILD_AGAINST_AZATHOTH
           vertex_data = useSharedVertices ? entity->_getSharedBlendedVertexData(   ) : entity->getSubEntity(  i )->_getBlendedVertexData(   );
          #else
           vertex_data = useSharedVertices ? entity->_getSkelAnimVertexData(   ) : entity->getSubEntity(  i )->_getSkelAnimVertexData(   );
          #endif
           else
           vertex_data = useSharedVertices ? mesh->sharedVertexData : submesh->vertexData;
          
           if(  (  !useSharedVertices )||(  useSharedVertices && !added_shared ) )
           {
           if(  useSharedVertices )
           {
           added_shared = true;
           shared_offset = current_offset;
           }
          
           const VertexElement* posElem =
           vertex_data->vertexDeclaration->findElementBySemantic(  Ogre::VES_POSITION );
          
           HardwareVertexBufferSharedPtr vbuf =
           vertex_data->vertexBufferBinding->getBuffer(  posElem->getSource(   ) );
          
           unsigned char* vertex =
           static_cast<unsigned char*>(  vbuf->lock(  HardwareBuffer::HBL_READ_ONLY ) );
          
           // There is _no_ baseVertexPointerToElement(   ) which takes an Ogre::Real or a double
           // as second argument. So make it float,   to avoid trouble when Ogre::Real is
           // comiled/typedefed as double:
           float* pReal;
          
          #ifdef BUILD_AGAINST_AZATHOTH
           if (  useSoftwareBlendingVertices )
           {
           // Blended bone data is computed in world space.
           // Opcode expects data in local coordinates.
           Matrix4 xform = entity->_getParentNodeFullTransform(   ).inverse(   );
          
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
           Vector3 v = Vector3(  pReal[0],  pReal[1],  pReal[2] );
           v = xform * v;
           size_t n = current_offset*3 + j*3;
           vertexBuf[n + 0] = v[0];
           vertexBuf[n + 1] = v[1];
           vertexBuf[n + 2] = v[2];
           }
           }
           else
           {
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
           size_t n = current_offset*3 + j*3;
           vertexBuf[n + 0] = pReal[0];
           vertexBuf[n + 1] = pReal[1];
           vertexBuf[n + 2] = pReal[2];
           }
           }
          #else
          
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
          
           size_t n = current_offset*3 + j*3;
          
           vertexBuf[n + 0] = pReal[0];
           vertexBuf[n + 1] = pReal[1];
           vertexBuf[n + 2] = pReal[2];
           }
          #endif
          
           vbuf->unlock(   );
           next_offset += vertex_data->vertexCount;
           }
           }
          
           if (  faceBuf )
           {
           //----------------------------------------------------------------
           // GET INDEXDATA
           //----------------------------------------------------------------
           IndexData* index_data = submesh->indexData;
           size_t numTris = index_data->indexCount / 3;
           HardwareIndexBufferSharedPtr ibuf = index_data->indexBuffer;
          
           bool use32bitindexes = (  ibuf->getType(   ) == HardwareIndexBuffer::IT_32BIT );
          
           uint32 *pLong = static_cast<uint32*>(  ibuf->lock(  HardwareBuffer::HBL_READ_ONLY ) );
           uint16* pShort = reinterpret_cast<uint16*>(  pLong );
          
          
           size_t offset = (  submesh->useSharedVertices )? shared_offset : current_offset;
          
           if (   use32bitindexes  )
           {
           for (   size_t k = 0; k < numTris*3; ++k )
           {
           faceBuf[index_offset++] = pLong[k] + static_cast<int>(  offset );
           }
           }
           else
           {
           for (   size_t k = 0; k < numTris*3; ++k )
           {
           faceBuf[index_offset++] = static_cast<int>(  pShort[k] ) + static_cast<int>(  offset );
           }
           }
          
           ibuf->unlock(   );
           }
          
           current_offset = next_offset;
           }
           }
          
           //------------------------------------------------------------------------
           /// load collide geometry from mesh,   and build a collision tree
           /// @param meshName [in] name of mesh to load
           /// @param orientation [in] optional orientation
           /// @param position [in] optional position
           /// @return bool boolean value indicating success or failure
     277   bool MeshCollisionShape::load(  const Ogre::String& meshName,   const Quaternion& orientation,   const Vector3& position )
           {
           //MeshPtr mesh = MeshManager::getSingleton(   ).load(  meshName );
           //assert(  mesh );
           assert(  !mVertexBuf && !mFaceBuf );
           mEntity = CollisionManager::getSingletonPtr(   )->getSceneManager(   )->createEntity(  mName,   meshName );
           assert(  mEntity );
           createDummyNode(   );
           mDummyNode->setOrientation(  orientation );
           mDummyNode->setPosition(  position );
          
           if (  mEntity->hasSkeleton(   ) ) {
          #ifdef BUILD_AGAINST_AZATHOTH
           mEntity->addSoftwareSkinningRequest(  false );
          #else
           mEntity->addSoftwareAnimationRequest(  false );
          #endif
           }
          
           mParentNode = mDummyNode;
           //mFullTransform = mEntity->getParentSceneNode(   )->_getFullTransform(   );
           mParentNode->getWorldTransforms(  &mFullTransform );
           return rebuild(   );
           }
          
           //------------------------------------------------------------------------
           /// Reload the collision geometry from mesh,   rebuild collision tree from scratch.
           /// Potentially very slow. Only necessary if the mesh has drastically changed,  
           /// like topology changing deformations,   or a change in the number of tris.
           /// In most cases RefitToMesh(   ) is sufficient,   and much faster.
           /// Under usual circumstances there is no need to call this method.
           /// @return bool Whether the rebuild operation was successful or not
     309   bool MeshCollisionShape::rebuild(   )
           {
           assert(  mEntity );
          
           // NOTE: Assuming presence or absence of skeleton hasn't changed!
          
           size_t vertex_count = 0;
           size_t index_count = 0;
           countIndicesAndVertices(  mEntity,   index_count,   vertex_count );
          
           // Re-Allocate space for the vertices and indices
           if (  mVertexBuf && numVertices != vertex_count ) {
           delete [] mVertexBuf;
           mVertexBuf = 0;
           }
           if (  mFaceBuf && numFaces != index_count/3 ) {
           delete [] mFaceBuf;
           mFaceBuf = 0;
           }
          
           if (  !mVertexBuf )
           mVertexBuf = new float[vertex_count * 3];
           if (  !mFaceBuf )
           mFaceBuf = new size_t[index_count];
          
           convertMeshData(  mEntity,   mVertexBuf,   vertex_count,   mFaceBuf,   index_count  );
          
           numFaces = index_count / 3;
           numVertices = vertex_count;
          
           opcMeshAccess.SetNbTriangles(  numFaces );
           opcMeshAccess.SetNbVertices(  numVertices );
           opcMeshAccess.SetPointers(  (  IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           //opcMeshAccess.SetStrides(  sizeof(  int ) * 3,   sizeof(  float ) * 3 );
          
           return _rebuildFromCachedData(   );
          
           }
          
           //------------------------------------------------------------------------
           /// Retrieve current vertex data from mesh and refit collision tree.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           /// @return bool Whether the operation was successful or not.
     352   bool MeshCollisionShape::refit(   )
           {
           // bail if we don't need to refit
           if (   mShapeIsStatic  )
           return true;
          
           assert(  mEntity && mVertexBuf );
          
          #ifdef _DEBUG
           size_t vertex_count = 0;
           size_t index_count = 0;
           countIndicesAndVertices(  mEntity,   index_count,   vertex_count );
           assert(  numVertices == vertex_count );
          #endif
          
           convertMeshData(  mEntity,   mVertexBuf,   numVertices );
          
           return _refitToCachedData(   );
           }
          
          
           //------------------------------------------------------------------------
           /// Refits the collision tree to the currently cached vertex data.
           /// This is an O(  n ) operation in the number of vertices in the mesh.
           /// This is an advanced method. It assumes that the user is manually
           /// updating both the MeshCollisionShape's cached data and the actual mesh
           /// hardware buffers. Mostly useful for implementing something like
           /// deformable body physics.
           /// @return bool
     381   bool MeshCollisionShape::_refitToCachedData(   )
           {
           assert(  mEntity && mVertexBuf );
          
           // rebuild tree
           if (  !opcModel.Refit(   ) )
           {
           LogManager::getSingleton(   ).logMessage(  
           "OgreOpcode::MeshCollisionShape::_refitToCachedData(   ): OPCODE Quick refit not possible with the given tree type." );
           // Backup plan -- rebuild full tree
           opcMeshAccess.SetPointers(  (  IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
           }
          
           calculateSize(   );
          
           //computeIceABB(   );
          
           //createDummyNode(   );
          
           return true;
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     409   bool MeshCollisionShape::_rebuildFromCachedData(   )
           {
           assert(  mEntity && mVertexBuf && mFaceBuf );
          
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
          
           calculateSize(   );
          
           //computeIceABB(   );
          
           //createDummyNode(   );
          
           return true;
           }
           //------------------------------------------------------------------------
     426   void MeshCollisionShape::createDummyNode(   )
           {
           if(  !mDummyCreated )
           {
           mDummyNode = CollisionManager::getSingletonPtr(   )->getSceneManager(   )->getRootSceneNode(   )->createChildSceneNode(  getName(   ) );
           mDummyNode->attachObject(  mEntity );
           mDummyCreated = true;
           }
          
           }
          }
          
          //------------------------------------------------------------------------

./components/ogre/ogreopcode/src/OgreOpcodeCharacterController.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeCharacterController.cpp
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeCharacterController.h"
          
          namespace OgreOpcode
          {
      31   CharacterController::CharacterController(  Ogre::SceneNode* CharacterBaseNode,   Ogre::Real CharacterRadius,   Ogre::Real CharacterHeight,   Ogre::Vector3 Gravity,   Ogre::Degree SlopeThreshold,   Ogre::Real UnitsPerMeter ) :
           mBaseNode(  CharacterBaseNode ),  
           mRadius(  CharacterRadius ),  
           mHeight(  CharacterHeight ),  
           mGravity(  Gravity ),  
           mSlopeThreshold(  SlopeThreshold ),  
           mUnitsPerMeter(  UnitsPerMeter ),  
           mContactName(  "" )
           {
           mVeryCloseDistance = (  (  mUnitsPerMeter / 100 ) * 0.005 ) * 5; // 25 centimeters in Ogre 3d coordinates
           }
          
      43   CharacterController::~CharacterController(   )
           {
           }
          
      47   Ogre::Vector3 CharacterController::_collideAndSlide(  const Ogre::Vector3& vel )
           {
           CollisionPacket colData;
          
           // Information about the move being requested: (  in R3 )
           colData.R3Position = mBaseNode->_getDerivedPosition(   );
           colData.R3Velocity = vel;
          
           // convert simple sphere radius into ellipsoid radius
           // (  algorithm works with ellipsoids but for now ogreopcode works only with spheres )
           colData.eRadius = Ogre::Vector3(  mRadius,   mRadius,   mRadius );
          
           // calculate position and velocity in eSpace
           Ogre::Vector3 eSpacePosition = colData.R3Position / colData.eRadius;
           Ogre::Vector3 eSpaceVelocity = colData.R3Velocity / colData.eRadius;
          
           // Iterate until we have our final position.
           Ogre::Vector3 finalPosition = _collideWithWorld(  0,   eSpacePosition,   eSpaceVelocity,   colData,   false,   Ogre::Degree(  0 ) );
          
           // Add gravity pull:
           if (  mGravity != Ogre::Vector3::ZERO ) {
           // Set the new R3 position (  convert back from eSpace to R3 )
           colData.R3Position = finalPosition * colData.eRadius;
           colData.R3Velocity = mGravity;
           eSpacePosition = colData.R3Position / colData.eRadius;
           eSpaceVelocity = mGravity / colData.eRadius;
           finalPosition = _collideWithWorld(  0,   eSpacePosition,   eSpaceVelocity,   colData,   true,   mSlopeThreshold );
           }
          
           // Convert final result back to R3:
           return finalPosition * colData.eRadius;
           }
          
      80   Ogre::Vector3 CharacterController::_collideWithWorld(  int recursionDepth,   const Ogre::Vector3& pos,   const Ogre::Vector3& vel,   CollisionPacket& colData,   bool gravityStep,   const Ogre::Degree& slopeSlideThresold )
           {
           // do we need to worry?
           if (  recursionDepth > 5 )
           return pos;
          
           // Ok,   we need to worry:
           colData.velocity = vel;
           colData.normalizedVelocity = vel;
           colData.normalizedVelocity.normalise(   );
           colData.basePoint = pos;
           colData.foundCollision = false;
          
           // ----------------------------
           // OgreOpcode part begin
           _doOgreOpcodeCollision(  colData,   mVeryCloseDistance );
           // OgreOpcode part end
           // ----------------------------
          
           // If no collision we just move along the velocity
           if (  colData.foundCollision == false ) {
           return pos + vel;
           }
          
           // *** Collision occured ***
           // The original destination point
           Ogre::Vector3 destinationPoint = pos + vel;
           Ogre::Vector3 newBasePoint = pos;
          
           // only update if we are not already very close
           // and if so we only move very close to intersection..not
           // to the exact spot.
           if (  colData.nearestDistance >= mVeryCloseDistance ) {
           Ogre::Vector3 V = vel;
           V.normalise(   );
           V = V * (  colData.nearestDistance - mVeryCloseDistance );
           newBasePoint = colData.basePoint + V;
           // Adjust polygon intersection point (  so sliding
           // plane will be unaffected by the fact that we
           // move slightly less than collision tells us )
           V.normalise(   );
           colData.intersectionPoint -= mVeryCloseDistance * V;
           }
          
           // Determine the sliding plane
           Ogre::Vector3 slidePlaneOrigin = colData.intersectionPoint;
           Ogre::Vector3 slidePlaneNormal = newBasePoint - colData.intersectionPoint;
           slidePlaneNormal.normalise(   );
           Ogre::Plane slidingPlane(  slidePlaneNormal,   slidePlaneOrigin );
          
           Ogre::Vector3 newDestinationPoint = destinationPoint -
           slidingPlane.getDistance(  destinationPoint ) *
           slidePlaneNormal;
          
           // Generate the slide vector,   which will become our new
           // velocity vector for the next iteration
           Ogre::Vector3 newVelocityVector = newDestinationPoint - colData.intersectionPoint;
          
           // Recurse:
           // dont recurse if the new velocity is very small
           if (  newVelocityVector.length(   ) < mVeryCloseDistance ) {
           return newBasePoint;
           }
          
           // simulate "friction"
           if (  gravityStep ) {
           // apply gravity only if slope is steep enough
           const Ogre::Radian tolerance = Ogre::Radian(  slopeSlideThresold );
           Ogre::Vector3 gravity = vel;
           gravity.normalise(   );
           if (  slidePlaneNormal.directionEquals(  -gravity,   tolerance ) ) {
           return newBasePoint;
           }
           }
          
           return _collideWithWorld(  recursionDepth++,   newBasePoint,   newVelocityVector,   colData,   gravityStep,   slopeSlideThresold );
           }
          
     158   void CharacterController::_doOgreOpcodeCollision(  CollisionPacket& colData,   float sweepOffset )
           {
           Ogre::Vector3 pos_R3 = colData.basePoint * colData.eRadius;
           Ogre::Vector3 vel_R3 = colData.velocity * colData.eRadius;
          
           OgreOpcode::CollisionPair** reports;
          
           // TODO: sweptSphereCheck does not support ellipsoids,  
           // so we must use only one dimension!!!
           Ogre::Real radius = colData.eRadius.x;
          
           // Add a little offset to velocity so that we don't get too close.
           Ogre::Vector3 offset = vel_R3;
           offset.normalise(   );
           offset *= sweepOffset;
          
           OgreOpcode::Details::CollisionClass collClass = OgreOpcode::COLLTYPE_ALWAYS_EXACT;
          
           int count = OgreOpcode::CollisionManager::getSingletonPtr(   )->getDefaultContext(   )->
           sweptSphereCheck(  pos_R3,   vel_R3 + offset,   radius,   collClass,   reports );
          
           if (  count )
           {
           // search for closest distance collision
           int closest = 0;
           Ogre::Real d = reports[0]->distance;
           for (  int i = 1; i < count; i++ ) {
           if (  reports[i]->distance < d ) {
           d = reports[i]->distance;
           closest = i;
           }
           }
          
           colData.foundCollision = true;
           colData.nearestDistance = reports[closest]->distance;
           colData.intersectionPoint = reports[closest]->contact / colData.eRadius;
          
           mContactName = reports[closest]->other_object->getName(   );
           }
           }
          
     199   Ogre::SceneNode* CharacterController::getBaseNode(   )
           {
           return mBaseNode;
           }
          
     204   Ogre::Real CharacterController::getHeight(   )
           {
           return mHeight;
           }
          
     209   Ogre::Real CharacterController::getRadius(   )
           {
           return mRadius;
           }
          
     214   Ogre::Vector3 CharacterController::getGravity(   )
           {
           return mGravity;
           }
          
     219   Ogre::Degree CharacterController::getSlopeThreshold(   )
           {
           return mSlopeThreshold;
           }
          
     224   void CharacterController::move(  Ogre::Vector3 velocity )
           {
           mBaseNode->setPosition(  _collideAndSlide(  velocity ) );
           }
          
     229   void CharacterController::setHeight(  Ogre::Real Height )
           {
           mHeight = Height;
           }
          
     234   void CharacterController::setRadius(  Ogre::Real Radius )
           {
           mRadius = Radius;
           }
          
     239   void CharacterController::setGravity(  const Ogre::Vector3& Gravity )
           {
           mGravity = Gravity;
           }
          
     244   void CharacterController::setSlopeThreshold(  const Ogre::Degree& SlopeThreshold )
           {
           mSlopeThreshold = SlopeThreshold;
           }
          }

./components/ogre/ogreopcode/src/OgreOpcodeDebugObject.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeDebugObject.cpp
          /// @brief <TODO: insert file description here>
          /// @remarks Based directly on code from OgreNewt,   by Walaber.
          /// @author The OgreOpcode Team
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeDebugObject.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           namespace Details
           {
      34   OgreOpcodeDebugger::OgreOpcodeDebugger(  const Ogre::String& name,   SceneManager* sceneMgr )
           : mSceneMgr(  sceneMgr ),  
           mName(  name ),  
           mRadiiDebugNode(  0 ),  
           mContactsDebugNode(  0 ),  
           mContactNormalsDebugNode(  0 ),  
           mBBsDebugNode(  0 ),  
           mShapesDebugNode(  0 ),  
           mAABBsDebugNode(  0 ),  
           mRadiiDebugObject(  0 ),  
           mContactsDebugObject(  0 ),  
           mContactNormalsDebugObject(  0 ),  
           mBBsDebugObject(  0 ),  
           mShapesDebugObject(  0 ),  
           mAABBsDebugObject(  0 )
           {
           mRadiiDebugNode = mSceneMgr->getRootSceneNode(   )->createChildSceneNode(  "__OgreOpcode__RadiiDebugger__" + mName );
           mContactsDebugNode = mSceneMgr->getRootSceneNode(   )->createChildSceneNode(  "__OgreOpcode__ContactsDebugger__" + mName );
           mContactNormalsDebugNode = mSceneMgr->getRootSceneNode(   )->createChildSceneNode(  "__OgreOpcode__ContactNormalsDebugger__" + mName );
           mBBsDebugNode = mSceneMgr->getRootSceneNode(   )->createChildSceneNode(  "__OgreOpcode__BBsDebugger__" + mName );
           mShapesDebugNode = mSceneMgr->getRootSceneNode(   )->createChildSceneNode(  "__OgreOpcode__ShapesDebugger__" + mName );
           mAABBsDebugNode = mSceneMgr->getRootSceneNode(   )->createChildSceneNode(  "__OgreOpcode__AABBsDebugger__" + mName );
          
          #ifdef BUILD_AGAINST_AZATHOTH
           mRadiiDebugObject = new DebugLines(   );
           mContactsDebugObject = new DebugLines(   );
           mContactNormalsDebugObject = new DebugLines(   );
           mBBsDebugObject = new DebugLines(   );
           mShapesDebugObject = new DebugLines(   );
           mAABBsDebugObject = new DebugLines(   );
          #else
           mRadiiDebugObject = new ManualObject(  "__OgreOpcode__RadiiDebugger__" + mName );
           mContactsDebugObject = new ManualObject(  "__OgreOpcode__ContactsDebugger__" + mName );
           mContactNormalsDebugObject = new ManualObject(  "__OgreOpcode__ContactNormalsDebugger__" + mName );
           mBBsDebugObject = new ManualObject(  "__OgreOpcode__BBsDebugger__" + mName );
           mShapesDebugObject = new ManualObject(  "__OgreOpcode__ShapesDebugger__" + mName );
           mAABBsDebugObject = new ManualObject(  "__OgreOpcode__AABBsDebugger__" + mName );
          #endif
          
           }
          
      75   OgreOpcodeDebugger::~OgreOpcodeDebugger(   )
           {
           delete mRadiiDebugObject;
           delete mContactsDebugObject;
           delete mContactNormalsDebugObject;
           delete mBBsDebugObject;
           delete mShapesDebugObject;
           delete mAABBsDebugObject;
          
           mRadiiDebugNode->getParentSceneNode(   )->removeChild(  mRadiiDebugNode );
           mSceneMgr->destroySceneNode(  mRadiiDebugNode->getName(   ) );
           mRadiiDebugNode = 0;
           mContactsDebugNode->getParentSceneNode(   )->removeChild(  mContactsDebugNode );
           mSceneMgr->destroySceneNode(  mContactsDebugNode->getName(   ) );
           mContactsDebugNode = 0;
           mContactNormalsDebugNode->getParentSceneNode(   )->removeChild(  mContactNormalsDebugNode );
           mSceneMgr->destroySceneNode(  mContactNormalsDebugNode->getName(   ) );
           mContactNormalsDebugNode = 0;
           mBBsDebugNode->getParentSceneNode(   )->removeChild(  mBBsDebugNode );
           mSceneMgr->destroySceneNode(  mBBsDebugNode->getName(   ) );
           mBBsDebugNode = 0;
           mShapesDebugNode->getParentSceneNode(   )->removeChild(  mShapesDebugNode );
           mSceneMgr->destroySceneNode(  mShapesDebugNode->getName(   ) );
           mShapesDebugNode = 0;
           mAABBsDebugNode->getParentSceneNode(   )->removeChild(  mAABBsDebugNode );
           mSceneMgr->destroySceneNode(  mAABBsDebugNode->getName(   ) );
           mAABBsDebugNode = 0;
           }
          
     104   void OgreOpcodeDebugger::addRadiiLine(  Real lx1,   Real ly1,   Real lz1,   Real lx2,   Real ly2,   Real lz2 )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mRadiiDebugObject->addLine(  lx1,   ly1,   lz1,   lx2,   ly2,   lz2 );
          #else
           mRadiiDebugObject->position(  lx1,   ly1,   lz1 );
           mRadiiDebugObject->position(  lx2,   ly2,   lz2 );
          #endif
           }
          
     114   void OgreOpcodeDebugger::addContactLine(  Real lx1,   Real ly1,   Real lz1,   Real lx2,   Real ly2,   Real lz2 )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mContactsDebugObject->addLine(  lx1,   ly1,   lz1,   lx2,   ly2,   lz2 );
          #else
           mContactsDebugObject->position(  lx1,   ly1,   lz1 );
           mContactsDebugObject->position(  lx2,   ly2,   lz2 );
          #endif
           }
          
     124   void OgreOpcodeDebugger::addContactNormalsLine(  Real lx1,   Real ly1,   Real lz1,   Real lx2,   Real ly2,   Real lz2 )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mContactNormalsDebugObject->addLine(  lx1,   ly1,   lz1,   lx2,   ly2,   lz2 );
          #else
           mContactNormalsDebugObject->position(  lx1,   ly1,   lz1 );
           mContactNormalsDebugObject->position(  lx2,   ly2,   lz2 );
          #endif
           }
          
     134   void OgreOpcodeDebugger::addBBLine(  Real lx1,   Real ly1,   Real lz1,   Real lx2,   Real ly2,   Real lz2 )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mBBsDebugObject->addLine(  lx1,   ly1,   lz1,   lx2,   ly2,   lz2 );
          #else
           mBBsDebugObject->position(  lx1,   ly1,   lz1 );
           mBBsDebugObject->position(  lx2,   ly2,   lz2 );
          #endif
           }
          
     144   void OgreOpcodeDebugger::addShapeLine(  Real lx1,   Real ly1,   Real lz1,   Real lx2,   Real ly2,   Real lz2 )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mShapesDebugObject->addLine(  lx1,   ly1,   lz1,   lx2,   ly2,   lz2 );
          #else
           mShapesDebugObject->position(  lx1,   ly1,   lz1 );
           mShapesDebugObject->position(  lx2,   ly2,   lz2 );
          #endif
           }
          
     154   void OgreOpcodeDebugger::addAABBLine(  Real lx1,   Real ly1,   Real lz1,   Real lx2,   Real ly2,   Real lz2 )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mAABBsDebugObject->addLine(  lx1,   ly1,   lz1,   lx2,   ly2,   lz2 );
          #else
           mAABBsDebugObject->position(  lx1,   ly1,   lz1 );
           mAABBsDebugObject->position(  lx2,   ly2,   lz2 );
          #endif
           }
          
     164   void OgreOpcodeDebugger::clearRadii(   )
           {
           mRadiiDebugNode->detachAllObjects(   );
           mRadiiDebugObject->clear(   );
           }
          
     170   void OgreOpcodeDebugger::beginRadii(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mRadiiDebugObject->setMaterial(  "OgreOpcodeDebug/Radii" );
          #else
           mRadiiDebugObject->begin(  "OgreOpcodeDebug/Radii",   Ogre::RenderOperation::OT_LINE_LIST );
          #endif
           }
          
     179   void OgreOpcodeDebugger::endRadii(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mRadiiDebugObject->draw(   );
          #else
           mRadiiDebugObject->end(   );
          #endif
           mRadiiDebugNode->attachObject(  mRadiiDebugObject );
           }
          
     189   void OgreOpcodeDebugger::clearContacts(   )
           {
           mContactsDebugNode->detachAllObjects(   );
           mContactsDebugObject->clear(   );
           }
          
     195   void OgreOpcodeDebugger::beginContacts(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mContactsDebugObject->setMaterial(  "OgreOpcodeDebug/Contacts" );
          #else
           mContactsDebugObject->begin(  "OgreOpcodeDebug/Contacts",   Ogre::RenderOperation::OT_LINE_LIST );
          #endif
           }
          
     204   void OgreOpcodeDebugger::endContacts(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mContactsDebugObject->draw(   );
          #else
           mContactsDebugObject->end(   );
          #endif
           if(  mContactsDebugNode->numAttachedObjects(   ) < 1 )
           mContactsDebugNode->attachObject(  mContactsDebugObject );
           }
          
     215   void OgreOpcodeDebugger::clearContactNormals(   )
           {
           mContactNormalsDebugNode->detachAllObjects(   );
           mContactNormalsDebugObject->clear(   );
           }
          
     221   void OgreOpcodeDebugger::beginContactNormals(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mContactNormalsDebugObject->setMaterial(  "OgreOpcodeDebug/ContactNormals" );
          #else
           mContactNormalsDebugObject->begin(  "OgreOpcodeDebug/ContactNormals",   Ogre::RenderOperation::OT_LINE_LIST );
          #endif
           }
          
     230   void OgreOpcodeDebugger::endContactNormals(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mContactNormalsDebugObject->draw(   );
          #else
           mContactNormalsDebugObject->end(   );
          #endif
           if(  mContactNormalsDebugNode->numAttachedObjects(   ) < 1 )
           mContactNormalsDebugNode->attachObject(  mContactNormalsDebugObject );
           }
          
     241   void OgreOpcodeDebugger::clearBBs(   )
           {
           mBBsDebugNode->detachAllObjects(   );
           mBBsDebugObject->clear(   );
           }
          
     247   void OgreOpcodeDebugger::beginBBs(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mBBsDebugObject->setMaterial(  "OgreOpcodeDebug/BBs" );
          #else
           mBBsDebugObject->begin(  "OgreOpcodeDebug/BBs",   Ogre::RenderOperation::OT_LINE_LIST );
          #endif
           }
          
     256   void OgreOpcodeDebugger::endBBs(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mBBsDebugObject->draw(   );
          #else
           mBBsDebugObject->end(   );
          #endif
           mBBsDebugNode->attachObject(  mBBsDebugObject );
           }
          
     266   void OgreOpcodeDebugger::clearShapes(   )
           {
           mShapesDebugNode->detachAllObjects(   );
           mShapesDebugObject->clear(   );
           }
          
     272   void OgreOpcodeDebugger::beginShapes(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mShapesDebugObject->setMaterial(  "OgreOpcodeDebug/Shapes" );
          #else
           mShapesDebugObject->begin(  "OgreOpcodeDebug/Shapes",   Ogre::RenderOperation::OT_LINE_LIST );
          #endif
           }
          
     281   void OgreOpcodeDebugger::endShapes(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mShapesDebugObject->draw(   );
          #else
           mShapesDebugObject->end(   );
          #endif
           mShapesDebugNode->attachObject(  mShapesDebugObject );
           }
          
     291   void OgreOpcodeDebugger::clearAABBs(   )
           {
           mAABBsDebugNode->detachAllObjects(   );
           mAABBsDebugObject->clear(   );
           }
          
     297   void OgreOpcodeDebugger::beginAABBs(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mAABBsDebugObject->setMaterial(  "OgreOpcodeDebug/AABBs" );
          #else
           mAABBsDebugObject->begin(  "OgreOpcodeDebug/AABBs",   Ogre::RenderOperation::OT_LINE_LIST );
          #endif
           }
          
     306   void OgreOpcodeDebugger::endAABBs(   )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mAABBsDebugObject->draw(   );
          #else
           mAABBsDebugObject->end(   );
          #endif
           mAABBsDebugNode->attachObject(  mAABBsDebugObject );
           }
          
     316   void OgreOpcodeDebugger::clearAll(   )
           {
           clearRadii(   );
           clearContacts(   );
           clearContactNormals(   );
           clearShapes(   );
           clearBBs(   );
           clearAABBs(   );
           }
          
          #ifdef BUILD_AGAINST_AZATHOTH
     327   DebugLines::DebugLines(   )
           {
           mRenderOp.vertexData = new VertexData(   );
           _drawn = false;
           }
          
     333   void DebugLines::clear(   )
           {
           if(  _drawn )
           {
           _drawn = false;
           _points.clear(   );
           delete mRenderOp.vertexData;
          
           mRenderOp.vertexData = new VertexData(   );
           }
           }
          
     345   DebugLines::~DebugLines(  void )
           {
           clear(   );
          
           delete mRenderOp.vertexData;
           }
          
     352   void DebugLines::draw(   )
           {
           if(  _drawn ) return;
           else _drawn = true;
          
           // Initialization stuff
           mRenderOp.indexData = 0;
           mRenderOp.vertexData->vertexCount = _points.size(   );
           mRenderOp.vertexData->vertexStart = 0;
           mRenderOp.operationType = RenderOperation::OT_LINE_LIST;
           mRenderOp.useIndexes = false;
          
           VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
           VertexBufferBinding *bind = mRenderOp.vertexData->vertexBufferBinding;
          
           decl->addElement(  0,   0,   VET_FLOAT3,   VES_POSITION );
          
           HardwareVertexBufferSharedPtr vbuf =
           HardwareBufferManager::getSingleton(   ).createVertexBuffer(  
           decl->getVertexSize(  0 ),  
           mRenderOp.vertexData->vertexCount,  
           HardwareBuffer::HBU_STATIC_WRITE_ONLY );
          
           bind->setBinding(  0,   vbuf );
          
           // Drawing stuff
           size_t size = _points.size(   );
           Vector3 vaabMin = _points[0];
           Vector3 vaabMax = _points[0];
          
           Real *prPos = static_cast<Real*>(  vbuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          
           for(  size_t i = 0; i < size; i++ )
           {
           *prPos++ = _points[i].x;
           *prPos++ = _points[i].y;
           *prPos++ = _points[i].z;
          
           if(  _points[i].x < vaabMin.x )
           vaabMin.x = _points[i].x;
           if(  _points[i].y < vaabMin.y )
           vaabMin.y = _points[i].y;
           if(  _points[i].z < vaabMin.z )
           vaabMin.z = _points[i].z;
          
           if(  _points[i].x > vaabMax.x )
           vaabMax.x = _points[i].x;
           if(  _points[i].y > vaabMax.y )
           vaabMax.y = _points[i].y;
           if(  _points[i].z > vaabMax.z )
           vaabMax.z = _points[i].z;
           }
          
           vbuf->unlock(   );
          
           mBox.setExtents(  vaabMin,   vaabMax );
           }
          
     410   Real DebugLines::getSquaredViewDepth(  const Camera *cam ) const
           {
           Vector3 vMin,   vMax,   vMid,   vDist;
           vMin = mBox.getMinimum(   );
           vMax = mBox.getMaximum(   );
           vMid = (  (  vMin - vMax ) * 0.5 ) + vMin;
           vDist = cam->getDerivedPosition(   ) - vMid;
          
           return vDist.squaredLength(   );
           }
          
     421   Real DebugLines::getBoundingRadius(   ) const
           {
           return Math::Sqrt(  std::max(  mBox.getMaximum(   ).squaredLength(   ),   mBox.getMinimum(   ).squaredLength(   ) ) );
           }
          #endif
           } // namespace Details
          
          } // namespace OgreOpcode

./components/ogre/ogreopcode/src/OgreOpcodeLine.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeLine.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          
          #include "OgreOpcodeLine.h"
          #include "OgreOpcodeRay.h"
          #include "OgreCapsule.h"
          #include "OgreOrientedBox.h"
          #ifdef __MINGW32__
          #include <float.h>
          #endif
          
          //This includes the FLT_EPSILON symbol
          //#ifdef LINUX_FLOAT
          #include <float.h>
          //#endif
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           namespace Details
           {
           #if (  OGRE_DOUBLE_PRECISION == 1 )
           #define LINE_EPSILON DBL_EPSILON
           #else
           #define LINE_EPSILON FLT_EPSILON
           #endif
           //------------------------------------------------------------------------
           // Line class
           //------------------------------------------------------------------------
      55   Real Line::squaredDistance(   const Vector3& point,   Real *t  ) const
           {
           Vector3 dir = end - start;
           Vector3 kDiff = point - start;
           Real fT = kDiff | dir;
          
           if (   fT <= 0.0  )
           {
           fT = 0.0;
           }
           else
           {
           Real fSqrLen= dir.squaredLength(   );
           if (   fT >= fSqrLen  )
           {
           fT = 1.0;
           kDiff -= dir;
           }
           else
           {
           fT /= fSqrLen;
           kDiff -= fT*dir;
           }
           }
          
           if (   t  ) *t = fT;
          
           return kDiff.squaredLength(   );
           }
           // --------------------------------------------------------------------
      85   Real Line::distance(   const Vector3& point,   Real *t  ) const
           {
           return Math::Sqrt(   squaredDistance(  point,  t )  );
           }
           //------------------------------------------------------------------------
           // Follows from Magic-Software at http://www.magic-software.com
           //------------------------------------------------------------------------
      92   Real Line::squaredDistance(   const Line& line1,   Real* p0,   Real* p1  ) const
           {
           const Line& line0 = *this;
           Vector3 dir0 = line0.getDirection(   );
           Vector3 dir1 = line1.getDirection(   );
          
           Vector3 kDiff = line0.start - line1.start;
           Real fA00 = dir0.squaredLength(   );
           Real fA01 = -(  dir0|dir1 );
           Real fA11 = dir1.squaredLength(   );
           Real fB0 = kDiff | dir0;
           Real fC = kDiff.squaredLength(   );
           Real fDet = Math::Abs(  fA00*fA11-fA01*fA01 );
           Real fB1,   fS,   fT,   fSqrDist,   fTmp;
          
           if (   fDet >= LINE_EPSILON  )
           {
           // line segments are not parallel
           fB1 = -(  kDiff|dir1 );
           fS = fA01*fB1-fA11*fB0;
           fT = fA01*fB0-fA00*fB1;
          
           if (   fS >= 0.0  )
           {
           if (   fS <= fDet  )
           {
           if (   fT >= 0.0  )
           {
           if (   fT <= fDet  ) // region 0 (  interior )
           {
           // minimum at two interior points of 3D lines
           Real fInvDet = (  1.0 )/fDet;
           fS *= fInvDet;
           fT *= fInvDet;
           fSqrDist = fS*(  fA00*fS+fA01*fT+(  2.0 )*fB0 ) +
           fT*(  fA01*fS+fA11*fT+(  2.0 )*fB1 )+fC;
           }
           else // region 3 (  side )
           {
           fT = 1.0;
           fTmp = fA01+fB0;
           if (   fTmp >= 0.0  )
           {
           fS = 0.0;
           fSqrDist = fA11+(  2.0 )*fB1+fC;
           }
           else if (   -fTmp >= fA00  )
           {
           fS = 1.0;
           fSqrDist = fA00+fA11+fC+(  2.0 )*(  fB1+fTmp );
           }
           else
           {
           fS = -fTmp/fA00;
           fSqrDist = fTmp*fS+fA11+(  2.0 )*fB1+fC;
           }
           }
           }
           else // region 7 (  side )
           {
           fT = 0.0;
           if (   fB0 >= 0.0  )
           {
           fS = 0.0;
           fSqrDist = fC;
           }
           else if (   -fB0 >= fA00  )
           {
           fS = 1.0;
           fSqrDist = fA00+(  2.0 )*fB0+fC;
           }
           else
           {
           fS = -fB0/fA00;
           fSqrDist = fB0*fS+fC;
           }
           }
           }
           else
           {
           if (   fT >= 0.0  )
           {
           if (   fT <= fDet  ) // region 1 (  side )
           {
           fS = 1.0;
           fTmp = fA01+fB1;
           if (   fTmp >= 0.0  )
           {
           fT = 0.0;
           fSqrDist = fA00+(  2.0 )*fB0+fC;
           }
           else if (   -fTmp >= fA11  )
           {
           fT = 1.0;
           fSqrDist = fA00+fA11+fC+(  2.0 )*(  fB0+fTmp );
           }
           else
           {
           fT = -fTmp/fA11;
           fSqrDist = fTmp*fT+fA00+(  2.0 )*fB0+fC;
           }
           }
           else // region 2 (  corner )
           {
           fTmp = fA01+fB0;
           if (   -fTmp <= fA00  )
           {
           fT = 1.0;
           if (   fTmp >= 0.0  )
           {
           fS = 0.0;
           fSqrDist = fA11+(  2.0 )*fB1+fC;
           }
           else
           {
           fS = -fTmp/fA00;
           fSqrDist = fTmp*fS+fA11+(  2.0 )*fB1+fC;
           }
           }
           else
           {
           fS = 1.0;
           fTmp = fA01+fB1;
           if (   fTmp >= 0.0  )
           {
           fT = 0.0;
           fSqrDist = fA00+(  2.0 )*fB0+fC;
           }
           else if (   -fTmp >= fA11  )
           {
           fT = 1.0;
           fSqrDist = fA00+fA11+fC+
           (  2.0 )*(  fB0+fTmp );
           }
           else
           {
           fT = -fTmp/fA11;
           fSqrDist = fTmp*fT+fA00+(  2.0 )*fB0+fC;
           }
           }
           }
           }
           else // region 8 (  corner )
           {
           if (   -fB0 < fA00  )
           {
           fT = 0.0;
           if (   fB0 >= 0.0  )
           {
           fS = 0.0;
           fSqrDist = fC;
           }
           else
           {
           fS = -fB0/fA00;
           fSqrDist = fB0*fS+fC;
           }
           }
           else
           {
           fS = 1.0;
           fTmp = fA01+fB1;
           if (   fTmp >= 0.0  )
           {
           fT = 0.0;
           fSqrDist = fA00+(  2.0 )*fB0+fC;
           }
           else if (   -fTmp >= fA11  )
           {
           fT = 1.0;
           fSqrDist = fA00+fA11+fC+(  2.0 )*(  fB0+fTmp );
           }
           else
           {
           fT = -fTmp/fA11;
           fSqrDist = fTmp*fT+fA00+(  2.0 )*fB0+fC;
           }
           }
           }
           }
           }
           else
           {
           if (   fT >= 0.0  )
           {
           if (   fT <= fDet  ) // region 5 (  side )
           {
           fS = 0.0;
           if (   fB1 >= 0.0  )
           {
           fT = 0.0;
           fSqrDist = fC;
           }
           else if (   -fB1 >= fA11  )
           {
           fT = 1.0;
           fSqrDist = fA11+(  2.0 )*fB1+fC;
           }
           else
           {
           fT = -fB1/fA11;
           fSqrDist = fB1*fT+fC;
           }
           }
           else // region 4 (  corner )
           {
           fTmp = fA01+fB0;
           if (   fTmp < 0.0  )
           {
           fT = 1.0;
           if (   -fTmp >= fA00  )
           {
           fS = 1.0;
           fSqrDist = fA00+fA11+fC+(  2.0 )*(  fB1+fTmp );
           }
           else
           {
           fS = -fTmp/fA00;
           fSqrDist = fTmp*fS+fA11+(  2.0 )*fB1+fC;
           }
           }
           else
           {
           fS = 0.0;
           if (   fB1 >= 0.0  )
           {
           fT = 0.0;
           fSqrDist = fC;
           }
           else if (   -fB1 >= fA11  )
           {
           fT = 1.0;
           fSqrDist = fA11+(  2.0 )*fB1+fC;
           }
           else
           {
           fT = -fB1/fA11;
           fSqrDist = fB1*fT+fC;
           }
           }
           }
           }
           else // region 6 (  corner )
           {
           if (   fB0 < 0.0  )
           {
           fT = 0.0;
           if (   -fB0 >= fA00  )
           {
           fS = 1.0;
           fSqrDist = fA00+(  2.0 )*fB0+fC;
           }
           else
           {
           fS = -fB0/fA00;
           fSqrDist = fB0*fS+fC;
           }
           }
           else
           {
           fS = 0.0;
           if (   fB1 >= 0.0  )
           {
           fT = 0.0;
           fSqrDist = fC;
           }
           else if (   -fB1 >= fA11  )
           {
           fT = 1.0;
           fSqrDist = fA11+(  2.0 )*fB1+fC;
           }
           else
           {
           fT = -fB1/fA11;
           fSqrDist = fB1*fT+fC;
           }
           }
           }
           }
           }
           else
           {
           // line segments are parallel
           if (   fA01 > 0.0  )
           {
           // direction vectors form an obtuse angle
           if (   fB0 >= 0.0  )
           {
           fS = 0.0;
           fT = 0.0;
           fSqrDist = fC;
           }
           else if (   -fB0 <= fA00  )
           {
           fS = -fB0/fA00;
           fT = 0.0;
           fSqrDist = fB0*fS+fC;
           }
           else
           {
           fB1 = -(  kDiff|dir1 );
           fS = 1.0;
           fTmp = fA00+fB0;
           if (   -fTmp >= fA01  )
           {
           fT = 1.0;
           fSqrDist = fA00+fA11+fC+(  2.0 )*(  fA01+fB0+fB1 );
           }
           else
           {
           fT = -fTmp/fA01;
           fSqrDist = fA00+(  2.0 )*fB0+fC+fT*(  fA11*fT+
           (  2.0 )*(  fA01+fB1 ) );
           }
           }
           }
           else
           {
           // direction vectors form an acute angle
           if (   -fB0 >= fA00  )
           {
           fS = 1.0;
           fT = 0.0;
           fSqrDist = fA00+(  2.0 )*fB0+fC;
           }
           else if (   fB0 <= 0.0  )
           {
           fS = -fB0/fA00;
           fT = 0.0;
           fSqrDist = fB0*fS+fC;
           }
           else
           {
           fB1 = -(  kDiff | dir1 );
           fS = 0.0;
           if (   fB0 >= -fA01  )
           {
           fT = 1.0;
           fSqrDist = fA11+(  2.0 )*fB1+fC;
           }
           else
           {
           fT = -fB0/fA01;
           fSqrDist = fC+fT*(  (  2.0 )*fB1+fA11*fT );
           }
           }
           }
           }
          
           // put
           if (   p0  ) *p0 = fS;
           if (   p1  ) *p1 = fT;
          
           return Math::Abs(  fSqrDist );
           }
           // --------------------------------------------------------------------
     448   Real Line::distance(   const Line& line1,   Real* p0,   Real* p1  ) const
           {
           return Math::Sqrt(   squaredDistance(  line1,   p0,   p1 )  );
           }
           // --------------------------------------------------------------------
           // Follows code from Magic-Software at http://www.magic-software.com
           // --------------------------------------------------------------------
           // supporting routines
           //---------------------------------------------------------------------
     457   static void Face (  int i0,   int i1,   int i2,   Vector3& rkPnt,  
           const Vector3& rkDir,   const OBB& rkBox,  
           const Vector3& rkPmE,   Real* pfLParam,   Real& rfSqrDistance )
           {
           Vector3 kPpE;
           Real fLSqr,   fInv,   fTmp,   fParam,   fT,   fDelta;
          
           kPpE[i1] = rkPnt[i1] + rkBox.getExtents(   )[i1];
           kPpE[i2] = rkPnt[i2] + rkBox.getExtents(   )[i2];
           if (   rkDir[i0]*kPpE[i1] >= rkDir[i1]*rkPmE[i0]  )
           {
           if (   rkDir[i0]*kPpE[i2] >= rkDir[i2]*rkPmE[i0]  )
           {
           // v[i1] >= -e[i1],   v[i2] >= -e[i2] (  distance = 0 )
           if (   pfLParam  )
           {
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           fInv = 1.0/rkDir[i0];
           rkPnt[i1] -= rkDir[i1]*rkPmE[i0]*fInv;
           rkPnt[i2] -= rkDir[i2]*rkPmE[i0]*fInv;
           *pfLParam = -rkPmE[i0]*fInv;
           }
           }
           else
           {
           // v[i1] >= -e[i1],   v[i2] < -e[i2]
           fLSqr = rkDir[i0]*rkDir[i0] + rkDir[i2]*rkDir[i2];
           fTmp = fLSqr*kPpE[i1] - rkDir[i1]*(  rkDir[i0]*rkPmE[i0] +
           rkDir[i2]*kPpE[i2] );
           if (   fTmp <= 2.0*fLSqr*rkBox.getExtents(   )[i1]  )
           {
           fT = fTmp/fLSqr;
           fLSqr += rkDir[i1]*rkDir[i1];
           fTmp = kPpE[i1] - fT;
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*fTmp +
           rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + fTmp*fTmp +
           kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if (   pfLParam  )
           {
           *pfLParam = fParam;
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           rkPnt[i1] = fT - rkBox.getExtents(   )[i1];
           rkPnt[i2] = -rkBox.getExtents(   )[i2];
           }
           }
           else
           {
           fLSqr += rkDir[i1]*rkDir[i1];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*rkPmE[i1] +
           rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + rkPmE[i1]*rkPmE[i1] +
           kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if (   pfLParam  )
           {
           *pfLParam = fParam;
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           rkPnt[i1] = rkBox.getExtents(   )[i1];
           rkPnt[i2] = -rkBox.getExtents(   )[i2];
           }
           }
           }
           }
           else
           {
           if (   rkDir[i0]*kPpE[i2] >= rkDir[i2]*rkPmE[i0]  )
           {
           // v[i1] < -e[i1],   v[i2] >= -e[i2]
           fLSqr = rkDir[i0]*rkDir[i0] + rkDir[i1]*rkDir[i1];
           fTmp = fLSqr*kPpE[i2] - rkDir[i2]*(  rkDir[i0]*rkPmE[i0] +
           rkDir[i1]*kPpE[i1] );
           if (   fTmp <= (  2.0 )*fLSqr*rkBox.getExtents(   )[i2]  )
           {
           fT = fTmp/fLSqr;
           fLSqr += rkDir[i2]*rkDir[i2];
           fTmp = kPpE[i2] - fT;
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] +
           rkDir[i2]*fTmp;
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] +
           fTmp*fTmp + fDelta*fParam;
          
           if (   pfLParam  )
           {
           *pfLParam = fParam;
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           rkPnt[i1] = -rkBox.getExtents(   )[i1];
           rkPnt[i2] = fT - rkBox.getExtents(   )[i2];
           }
           }
           else
           {
           fLSqr += rkDir[i2]*rkDir[i2];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] +
           rkDir[i2]*rkPmE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] +
           rkPmE[i2]*rkPmE[i2] + fDelta*fParam;
          
           if (   pfLParam  )
           {
           *pfLParam = fParam;
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           rkPnt[i1] = -rkBox.getExtents(   )[i1];
           rkPnt[i2] = rkBox.getExtents(   )[i2];
           }
           }
           }
           else
           {
           // v[i1] < -e[i1],   v[i2] < -e[i2]
           fLSqr = rkDir[i0]*rkDir[i0]+rkDir[i2]*rkDir[i2];
           fTmp = fLSqr*kPpE[i1] - rkDir[i1]*(  rkDir[i0]*rkPmE[i0] +
           rkDir[i2]*kPpE[i2] );
           if (   fTmp >= 0.0  )
           {
           // v[i1]-edge is closest
           if (   fTmp <= 2.0*fLSqr*rkBox.getExtents(   )[i1]  )
           {
           fT = fTmp/fLSqr;
           fLSqr += rkDir[i1]*rkDir[i1];
           fTmp = kPpE[i1] - fT;
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*fTmp +
           rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + fTmp*fTmp +
           kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if (   pfLParam  )
           {
           *pfLParam = fParam;
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           rkPnt[i1] = fT - rkBox.getExtents(   )[i1];
           rkPnt[i2] = -rkBox.getExtents(   )[i2];
           }
           }
           else
           {
           fLSqr += rkDir[i1]*rkDir[i1];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*rkPmE[i1] +
           rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + rkPmE[i1]*rkPmE[i1]
           + kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if (   pfLParam  )
           {
           *pfLParam = fParam;
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           rkPnt[i1] = rkBox.getExtents(   )[i1];
           rkPnt[i2] = -rkBox.getExtents(   )[i2];
           }
           }
           return;
           }
          
           fLSqr = rkDir[i0]*rkDir[i0] + rkDir[i1]*rkDir[i1];
           fTmp = fLSqr*kPpE[i2] - rkDir[i2]*(  rkDir[i0]*rkPmE[i0] +
           rkDir[i1]*kPpE[i1] );
           if (   fTmp >= 0.0  )
           {
           // v[i2]-edge is closest
           if (   fTmp <= 2.0*fLSqr*rkBox.getExtents(   )[i2]  )
           {
           fT = fTmp/fLSqr;
           fLSqr += rkDir[i2]*rkDir[i2];
           fTmp = kPpE[i2] - fT;
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] +
           rkDir[i2]*fTmp;
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] +
           fTmp*fTmp + fDelta*fParam;
          
           if (   pfLParam  )
           {
           *pfLParam = fParam;
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           rkPnt[i1] = -rkBox.getExtents(   )[i1];
           rkPnt[i2] = fT - rkBox.getExtents(   )[i2];
           }
           }
           else
           {
           fLSqr += rkDir[i2]*rkDir[i2];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] +
           rkDir[i2]*rkPmE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] +
           rkPmE[i2]*rkPmE[i2] + fDelta*fParam;
          
           if (   pfLParam  )
           {
           *pfLParam = fParam;
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           rkPnt[i1] = -rkBox.getExtents(   )[i1];
           rkPnt[i2] = rkBox.getExtents(   )[i2];
           }
           }
           return;
           }
          
           // (  v[i1],  v[i2] )-corner is closest
           fLSqr += rkDir[i2]*rkDir[i2];
           fDelta = rkDir[i0]*rkPmE[i0] + rkDir[i1]*kPpE[i1] +
           rkDir[i2]*kPpE[i2];
           fParam = -fDelta/fLSqr;
           rfSqrDistance += rkPmE[i0]*rkPmE[i0] + kPpE[i1]*kPpE[i1] +
           kPpE[i2]*kPpE[i2] + fDelta*fParam;
          
           if (   pfLParam  )
           {
           *pfLParam = fParam;
           rkPnt[i0] = rkBox.getExtents(   )[i0];
           rkPnt[i1] = -rkBox.getExtents(   )[i1];
           rkPnt[i2] = -rkBox.getExtents(   )[i2];
           }
           }
           }
           }
           //----------------------------------------------------------------------------
     681   static void CaseNoZeros (  Vector3& rkPnt,   const Vector3& rkDir,  
           const OrientedBox& rkBox,   Real* pfLParam,   Real& rfSqrDistance )
           {
           Vector3 kPmE(  
           rkPnt.x - rkBox.getExtents(   )[0],  
           rkPnt.y - rkBox.getExtents(   )[1],  
           rkPnt.z - rkBox.getExtents(   )[2] );
          
           Real fProdDxPy = rkDir.x*kPmE.y;
           Real fProdDyPx = rkDir.y*kPmE.x;
           Real fProdDzPx,   fProdDxPz,   fProdDzPy,   fProdDyPz;
          
           if (   fProdDyPx >= fProdDxPy  )
           {
           fProdDzPx = rkDir.z*kPmE.x;
           fProdDxPz = rkDir.x*kPmE.z;
           if (   fProdDzPx >= fProdDxPz  )
           {
           // line intersects x = e0
           Face(  0,  1,  2,  rkPnt,  rkDir,  rkBox,  kPmE,  pfLParam,  rfSqrDistance );
           }
           else
           {
           // line intersects z = e2
           Face(  2,  0,  1,  rkPnt,  rkDir,  rkBox,  kPmE,  pfLParam,  rfSqrDistance );
           }
           }
           else
           {
           fProdDzPy = rkDir.z*kPmE.y;
           fProdDyPz = rkDir.y*kPmE.z;
           if (   fProdDzPy >= fProdDyPz  )
           {
           // line intersects y = e1
           Face(  1,  2,  0,  rkPnt,  rkDir,  rkBox,  kPmE,  pfLParam,  rfSqrDistance );
           }
           else
           {
           // line intersects z = e2
           Face(  2,  0,  1,  rkPnt,  rkDir,  rkBox,  kPmE,  pfLParam,  rfSqrDistance );
           }
           }
           }
           //----------------------------------------------------------------------------
     725   static void Case0 (  int i0,   int i1,   int i2,   Vector3& rkPnt,  
           const Vector3& rkDir,   const OrientedBox& rkBox,   Real* pfLParam,  
           Real& rfSqrDistance )
           {
           Real fPmE0 = rkPnt[i0] - rkBox.getExtents(   )[i0];
           Real fPmE1 = rkPnt[i1] - rkBox.getExtents(   )[i1];
           Real fProd0 = rkDir[i1]*fPmE0;
           Real fProd1 = rkDir[i0]*fPmE1;
           Real fDelta,   fInvLSqr,   fInv;
          
           if (   fProd0 >= fProd1  )
           {
           // line intersects P[i0] = e[i0]
           rkPnt[i0] = rkBox.getExtents(   )[i0];
          
           Real fPpE1 = rkPnt[i1] + rkBox.getExtents(   )[i1];
           fDelta = fProd0 - rkDir[i0]*fPpE1;
           if (   fDelta >= (  Real )0.0  )
           {
           fInvLSqr = (  (  Real )1.0 )/(  rkDir[i0]*rkDir[i0]+rkDir[i1]*rkDir[i1] );
           rfSqrDistance += fDelta*fDelta*fInvLSqr;
           if (   pfLParam  )
           {
           rkPnt[i1] = -rkBox.getExtents(   )[i1];
           *pfLParam = -(  rkDir[i0]*fPmE0+rkDir[i1]*fPpE1 )*fInvLSqr;
           }
           }
           else
           {
           if (   pfLParam  )
           {
           fInv = (  (  Real )1.0 )/rkDir[i0];
           rkPnt[i1] -= fProd0*fInv;
           *pfLParam = -fPmE0*fInv;
           }
           }
           }
           else
           {
           // line intersects P[i1] = e[i1]
           rkPnt[i1] = rkBox.getExtents(   )[i1];
          
           Real fPpE0 = rkPnt[i0] + rkBox.getExtents(   )[i0];
           fDelta = fProd1 - rkDir[i1]*fPpE0;
           if (   fDelta >= (  Real )0.0  )
           {
           fInvLSqr = (  (  Real )1.0 )/(  rkDir[i0]*rkDir[i0]+rkDir[i1]*rkDir[i1] );
           rfSqrDistance += fDelta*fDelta*fInvLSqr;
           if (   pfLParam  )
           {
           rkPnt[i0] = -rkBox.getExtents(   )[i0];
           *pfLParam = -(  rkDir[i0]*fPpE0+rkDir[i1]*fPmE1 )*fInvLSqr;
           }
           }
           else
           {
           if (   pfLParam  )
           {
           fInv = (  (  Real )1.0 )/rkDir[i1];
           rkPnt[i0] -= fProd1*fInv;
           *pfLParam = -fPmE1*fInv;
           }
           }
           }
          
           if (   rkPnt[i2] < -rkBox.getExtents(   )[i2]  )
           {
           fDelta = rkPnt[i2] + rkBox.getExtents(   )[i2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i2] = -rkBox.getExtents(   )[i2];
           }
           else if (   rkPnt[i2] > rkBox.getExtents(   )[i2]  )
           {
           fDelta = rkPnt[i2] - rkBox.getExtents(   )[i2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i2] = rkBox.getExtents(   )[i2];
           }
           }
           //----------------------------------------------------------------------------
     804   static void Case00 (  int i0,   int i1,   int i2,   Vector3& rkPnt,  
           const Vector3& rkDir,   const OrientedBox& rkBox,   Real* pfLParam,  
           Real& rfSqrDistance )
           {
           Real fDelta;
          
           if (   pfLParam  )
           *pfLParam = (  rkBox.getExtents(   )[i0] - rkPnt[i0] )/rkDir[i0];
          
           rkPnt[i0] = rkBox.getExtents(   )[i0];
          
           if (   rkPnt[i1] < -rkBox.getExtents(   )[i1]  )
           {
           fDelta = rkPnt[i1] + rkBox.getExtents(   )[i1];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i1] = -rkBox.getExtents(   )[i1];
           }
           else if (   rkPnt[i1] > rkBox.getExtents(   )[i1]  )
           {
           fDelta = rkPnt[i1] - rkBox.getExtents(   )[i1];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i1] = rkBox.getExtents(   )[i1];
           }
          
           if (   rkPnt[i2] < -rkBox.getExtents(   )[i2]  )
           {
           fDelta = rkPnt[i2] + rkBox.getExtents(   )[i2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i2] = -rkBox.getExtents(   )[i2];
           }
           else if (   rkPnt[i2] > rkBox.getExtents(   )[i2]  )
           {
           fDelta = rkPnt[i2] - rkBox.getExtents(   )[i2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt[i2] = rkBox.getExtents(   )[i2];
           }
           }
           //----------------------------------------------------------------------------
     842   static void Case000 (  Vector3& rkPnt,   const OrientedBox& rkBox,  
           Real& rfSqrDistance )
           {
           Real fDelta;
          
           if (   rkPnt.x < -rkBox.getExtents(   )[0]  )
           {
           fDelta = rkPnt.x + rkBox.getExtents(   )[0];
           rfSqrDistance += fDelta*fDelta;
           rkPnt.x = -rkBox.getExtents(   )[0];
           }
           else if (   rkPnt.x > rkBox.getExtents(   )[0]  )
           {
           fDelta = rkPnt.x - rkBox.getExtents(   )[0];
           rfSqrDistance += fDelta*fDelta;
           rkPnt.x = rkBox.getExtents(   )[0];
           }
          
           if (   rkPnt.y < -rkBox.getExtents(   )[1]  )
           {
           fDelta = rkPnt.y + rkBox.getExtents(   )[1];
           rfSqrDistance += fDelta*fDelta;
           rkPnt.y = -rkBox.getExtents(   )[1];
           }
           else if (   rkPnt.y > rkBox.getExtents(   )[1]  )
           {
           fDelta = rkPnt.y - rkBox.getExtents(   )[1];
           rfSqrDistance += fDelta*fDelta;
           rkPnt.y = rkBox.getExtents(   )[1];
           }
          
           if (   rkPnt.z < -rkBox.getExtents(   )[2]  )
           {
           fDelta = rkPnt.z + rkBox.getExtents(   )[2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt.z = -rkBox.getExtents(   )[2];
           }
           else if (   rkPnt.z > rkBox.getExtents(   )[2]  )
           {
           fDelta = rkPnt.z - rkBox.getExtents(   )[2];
           rfSqrDistance += fDelta*fDelta;
           rkPnt.z = rkBox.getExtents(   )[2];
           }
           }
           //---------------------------------------------------------------------
           // Distance between a point and a OBB
     888   Real sqrDistance (  const Vector3& rkPoint,   const OrientedBox& rkBox,  
           Real* pfBParam0,   Real* pfBParam1,   Real* pfBParam2 )
           {
           // compute coordinates of point in box coordinate system
           Vector3 kDiff = rkPoint - rkBox.getCenter(   );
           Vector3 rot[3] = { rkBox.getOrientation(   ).GetColumn(  0 ),  
           rkBox.getOrientation(   ).GetColumn(  1 ),  
           rkBox.getOrientation(   ).GetColumn(  2 ) };
          
           Vector3 kClosest(  kDiff | rot[0],  
           kDiff | rot[1],  
           kDiff | rot[2] );
          
           // project test point onto box
           Real fSqrDistance = (  Real )0.0;
           Real fDelta;
          
           if (   kClosest.x < -rkBox.getExtents(   )[0]  )
           {
           fDelta = kClosest.x + rkBox.getExtents(   )[0];
           fSqrDistance += fDelta*fDelta;
           kClosest.x = -rkBox.getExtents(   )[0];
           }
           else if (   kClosest.x > rkBox.getExtents(   )[0]  )
           {
           fDelta = kClosest.x - rkBox.getExtents(   )[0];
           fSqrDistance += fDelta*fDelta;
           kClosest.x = rkBox.getExtents(   )[0];
           }
          
           if (   kClosest.y < -rkBox.getExtents(   )[1]  )
           {
           fDelta = kClosest.y + rkBox.getExtents(   )[1];
           fSqrDistance += fDelta*fDelta;
           kClosest.y = -rkBox.getExtents(   )[1];
           }
           else if (   kClosest.y > rkBox.getExtents(   )[1]  )
           {
           fDelta = kClosest.y - rkBox.getExtents(   )[1];
           fSqrDistance += fDelta*fDelta;
           kClosest.y = rkBox.getExtents(   )[1];
           }
          
           if (   kClosest.z < -rkBox.getExtents(   )[2]  )
           {
           fDelta = kClosest.z + rkBox.getExtents(   )[2];
           fSqrDistance += fDelta*fDelta;
           kClosest.z = -rkBox.getExtents(   )[2];
           }
           else if (   kClosest.z > rkBox.getExtents(   )[2]  )
           {
           fDelta = kClosest.z - rkBox.getExtents(   )[2];
           fSqrDistance += fDelta*fDelta;
           kClosest.z = rkBox.getExtents(   )[2];
           }
          
           if (   pfBParam0  ) *pfBParam0 = kClosest.x;
           if (   pfBParam1  ) *pfBParam1 = kClosest.y;
           if (   pfBParam2  ) *pfBParam2 = kClosest.z;
          
           return fSqrDistance;
           }
           //---------------------------------------------------------------------
           // Distance from an infitine line and a OBB
     952   Real sqrDistance(   const Vector3& origin,   const Vector3& direction,  
           const OrientedBox& rkBox,   Real* pfLParam,   Real* pfBParam0,   Real* pfBParam1,   Real* pfBParam2 )
           {
           // compute coordinates of line in box coordinate system
           Vector3 kDiff = origin - rkBox.getCenter(   );
           Vector3 rot[3] = { rkBox.getOrientation(   ).GetColumn(  0 ),  
           rkBox.getOrientation(   ).GetColumn(  1 ),  
           rkBox.getOrientation(   ).GetColumn(  2 ) };
          
           Vector3 kPnt(   kDiff | rot[0],  
           kDiff | rot[1],  
           kDiff | rot[2]  );
           Vector3 kDir(   direction | rot[0],  
           direction | rot[1],  
           direction | rot[2]  );
          
           // Apply reflections so that direction vector has nonnegative components.
           bool bReflect[3];
           int i;
           for (  i = 0; i < 3; i++ )
           {
           if (   kDir[i] < (  Real )0.0  )
           {
           kPnt[i] = -kPnt[i];
           kDir[i] = -kDir[i];
           bReflect[i] = true;
           }
           else
           {
           bReflect[i] = false;
           }
           }
          
           Real fSqrDistance = (  Real )0.0;
           if (   kDir.x > (  Real )0.0  )
           {
           if (   kDir.y > (  Real )0.0  )
           {
           if (   kDir.z > (  Real )0.0  )
           {
           // (  +,  +,  + )
           CaseNoZeros(  kPnt,  kDir,  rkBox,  pfLParam,  fSqrDistance );
           }
           else
           {
           // (  +,  +,  0 )
           Case0(  0,  1,  2,  kPnt,  kDir,  rkBox,  pfLParam,  fSqrDistance );
           }
           }
           else
           {
           if (   kDir.z > (  Real )0.0  )
           {
           // (  +,  0,  + )
           Case0(  0,  2,  1,  kPnt,  kDir,  rkBox,  pfLParam,  fSqrDistance );
           }
           else
           {
           // (  +,  0,  0 )
           Case00(  0,  1,  2,  kPnt,  kDir,  rkBox,  pfLParam,  fSqrDistance );
           }
           }
           }
           else
           {
           if (   kDir.y > (  Real )0.0  )
           {
           if (   kDir.z > (  Real )0.0  )
           {
           // (  0,  +,  + )
           Case0(  1,  2,  0,  kPnt,  kDir,  rkBox,  pfLParam,  fSqrDistance );
           }
           else
           {
           // (  0,  +,  0 )
           Case00(  1,  0,  2,  kPnt,  kDir,  rkBox,  pfLParam,  fSqrDistance );
           }
           }
           else
           {
           if (   kDir.z > (  Real )0.0  )
           {
           // (  0,  0,  + )
           Case00(  2,  0,  1,  kPnt,  kDir,  rkBox,  pfLParam,  fSqrDistance );
           }
           else
           {
           // (  0,  0,  0 )
           Case000(  kPnt,  rkBox,  fSqrDistance );
           if (   pfLParam  )
           *pfLParam = (  Real )0.0;
           }
           }
           }
          
           // undo reflections
           for (  i = 0; i < 3; i++ )
           {
           if (   bReflect[i]  )
           kPnt[i] = -kPnt[i];
           }
          
           if (   pfBParam0  )
           *pfBParam0 = kPnt.x;
          
           if (   pfBParam1  )
           *pfBParam1 = kPnt.y;
          
           if (   pfBParam2  )
           *pfBParam2 = kPnt.z;
          
           return fSqrDistance;
           }
           // --------------------------------------------------------------------
           // Utility functions for picking
           // --------------------------------------------------------------------
    1068   bool Clip(   Real fDenom,   Real fNumer,   Real& rfT0,   Real& rfT1 )
           {
           // Return value is 'true' if line segment intersects the current test
           // plane. Otherwise 'false' is returned in which case the line segment
           // is entirely clipped.
          
           if (   fDenom > 0.0  )
           {
           if (   fNumer > fDenom*rfT1  )
           return false;
           if (   fNumer > fDenom*rfT0  )
           rfT0 = fNumer/fDenom;
           return true;
           }
           else if (   fDenom < 0.0  )
           {
           if (   fNumer > fDenom*rfT0  )
           return false;
           if (   fNumer > fDenom*rfT1  )
           rfT1 = fNumer/fDenom;
           return true;
           }
           else
           {
           return fNumer <= 0.0;
           }
           }
           // --------------------------------------------------------------------
    1096   bool FindIntersection(   const Vector3& rkOrigin,  
           const Vector3& rkDirection,  
           const Vector3& afExtent,  
           Real& rfT0,  
           Real& rfT1 )
           {
           Real fSaveT0 = rfT0,   fSaveT1 = rfT1;
          
           return Clip(  +rkDirection.x,  -rkOrigin.x-afExtent[0],  rfT0,  rfT1 ) &&
           Clip(  -rkDirection.x,  +rkOrigin.x-afExtent[0],  rfT0,  rfT1 ) &&
           Clip(  +rkDirection.y,  -rkOrigin.y-afExtent[1],  rfT0,  rfT1 ) &&
           Clip(  -rkDirection.y,  +rkOrigin.y-afExtent[1],  rfT0,  rfT1 ) &&
           Clip(  +rkDirection.z,  -rkOrigin.z-afExtent[2],  rfT0,  rfT1 ) &&
           Clip(  -rkDirection.z,  +rkOrigin.z-afExtent[2],  rfT0,  rfT1 ) &&
           (   rfT0 != fSaveT0 || rfT1 != fSaveT1  );
           }
           //---------------------------------------------------------------------
    1113   Real Line::squaredDistance(   const OrientedBox& rkBox  ) const
           {
           Vector3 direction = end - start;
          
           Real fLP,   fBP0,   fBP1,   fBP2;
           Real pfBParam0,  pfBParam1,  pfBParam2;
           Real fSqrDistance = sqrDistance(  start,   direction,   rkBox,  &fLP,  &fBP0,  &fBP1,  &fBP2 );
           if (   fLP >= (  Real )0.0  )
           {
           if (   fLP <= (  Real )1.0  )
           {
           //if (   pfLParam  ) *pfLParam = fLP;
           //if (   pfBParam0  ) *pfBParam0 = fBP0;
           //if (   pfBParam1  ) *pfBParam1 = fBP1;
           //if (   pfBParam2  ) *pfBParam2 = fBP2;
           return fSqrDistance;
           }
           else
           {
           // TODO implement distance between a point and a box
           fSqrDistance = sqrDistance(   end,   rkBox,   &pfBParam0,  &pfBParam1,  &pfBParam2 );
           //if (   pfLParam  ) *pfLParam = (  Real )1.0;
           return fSqrDistance;
           }
           }
           else
           {
           fSqrDistance = sqrDistance(  start,  rkBox,   &pfBParam0,  &pfBParam1,  &pfBParam2 );
           // if (   pfLParam  ) *pfLParam = (  Real )0.0;
           return fSqrDistance;
           }
          
           return 0.0;
           }
           // --------------------------------------------------------------------
    1148   Real Line::distance(   const OrientedBox& obb  ) const
           {
           return Math::Sqrt(   squaredDistance(  obb )  );
           }
           // --------------------------------------------------------------------
           // INTERSECTION TESTS
           // --------------------------------------------------------------------
    1155   bool Line::intersect(   const Aabb& aabb  ) const
           {
           OBB obb(  aabb );
           return intersect(  obb );
           }
           // --------------------------------------------------------------------
    1161   bool Line::intersect(   const OBB& rkBox  ) const
           {
           Vector3 dir = end - start;
           Real fAWdU[3],   fADdU[3],   fAWxDdU[3],   fRhs;
           Vector3 kSDir = 0.5*dir;
           Vector3 kSCen = start + kSDir;
           Vector3 rot[3] = { rkBox.getOrientation(   ).GetColumn(  0 ),  
           rkBox.getOrientation(   ).GetColumn(  1 ),  
           rkBox.getOrientation(   ).GetColumn(  2 ) };
          
           Vector3 kDiff = kSCen - rkBox.getCenter(   );
          
           fAWdU[0] = Math::Abs(  kSDir | rot[0] );
           fADdU[0] = Math::Abs(  kDiff | rot[0] );
           fRhs = rkBox.getExtents(   )[0] + fAWdU[0];
           if (   fADdU[0] > fRhs  )
           return false;
          
           fAWdU[1] = Math::Abs(  kSDir | rot[1] );
           fADdU[1] = Math::Abs(  kDiff | rot[1] );
           fRhs = rkBox.getExtents(   )[1] + fAWdU[1];
           if (   fADdU[1] > fRhs  )
           return false;
          
           fAWdU[2] = Math::Abs(  kSDir | rot[2] );
           fADdU[2] = Math::Abs(  kDiff | rot[2] );
           fRhs = rkBox.getExtents(   )[2] + fAWdU[2];
           if (   fADdU[2] > fRhs  )
           return false;
          
           Vector3 kWxD = kSDir ^ kDiff;
          
           fAWxDdU[0] = Math::Abs(  kWxD | rot[0] );
           fRhs = rkBox.getExtents(   )[1]*fAWdU[2] + rkBox.getExtents(   )[2]*fAWdU[1];
           if (   fAWxDdU[0] > fRhs  )
           return false;
          
           fAWxDdU[1] = Math::Abs(  kWxD | rot[1] );
           fRhs = rkBox.getExtents(   )[0]*fAWdU[2] + rkBox.getExtents(   )[2]*fAWdU[0];
           if (   fAWxDdU[1] > fRhs  )
           return false;
          
           fAWxDdU[2] = Math::Abs(  kWxD | rot[2] );
           fRhs = rkBox.getExtents(   )[0]*fAWdU[1] + rkBox.getExtents(   )[1]*fAWdU[0];
           if (   fAWxDdU[2] > fRhs  )
           return false;
          
           return true;
           }
           // --------------------------------------------------------------------
    1211   bool Line::intersect(   const Sphere& sphere  ) const
           {
           Real fSqrDist = squaredDistance(   sphere.getCenter(   )  );
           return fSqrDist <= sphere.getRadius(   )*sphere.getRadius(   );
           }
           // --------------------------------------------------------------------
    1217   bool Line::intersect(   const Capsule& capsule  ) const
           {
           Real fSqrDist = squaredDistance(   Line(  capsule.start,   capsule.end )  );
           return fSqrDist <= capsule.radius*capsule.radius;
           }
           // --------------------------------------------------------------------
    1223   bool Line::pick(   const Aabb& aabb,   Real& dist  ) const
           {
           OBB obb(  aabb );
           return pick(  obb,  dist );
           }
           // --------------------------------------------------------------------
    1229   bool Line::pick(   const OBB& obb,   Real& dist  ) const
           {
           // convert line to box coordinates
           Vector3 kDiff = start - obb.getCenter(   );
           Vector3 rot[3] = { obb.getOrientation(   ).GetColumn(  0 ),  
           obb.getOrientation(   ).GetColumn(  1 ),  
           obb.getOrientation(   ).GetColumn(  2 ) };
           Vector3 kOrigin(  
           kDiff | rot[0],  
           kDiff | rot[1],  
           kDiff | rot[2]
            );
          
           Vector3 direction = end - start;
           Vector3 kDirection(  
           direction | rot[0],  
           direction | rot[1],  
           direction | rot[2]
            );
          
           Real fT0 = Math::NEG_INFINITY,   fT1 = Math::POS_INFINITY;
           bool ret = FindIntersection(  kOrigin,  kDirection,  obb.getExtents(   ),  
           fT0,  fT1 );
          
           if (   ret  )
           {
           if (   fT0 != fT1  )
           dist = std::min(  fT0,  fT1 );
           else
           dist = fT0;
           }
          
           return ret;
           }
           // --------------------------------------------------------------------
    1264   bool Line::pick(   const Sphere& sphere,   Real& dist  ) const
           {
           // set up quadratic Q(  t ) = a*t^2 + 2*b*t + c
           Vector3 direction = end - start;
           Vector3 kDiff = start - sphere.getCenter(   );
           Real fA = direction.squaredLength(   );
           Real fB = kDiff | direction;
           Real fC = kDiff.squaredLength(   ) - sphere.getRadius(   )*sphere.getRadius(   );
          
           Real afT[2];
           Real fDiscr = fB*fB - fA*fC;
           if (   fDiscr < 0.0  )
           {
           return false;
           }
           else if (   fDiscr > 0.0  )
           {
           Real fRoot = Math::Sqrt(  fDiscr );
           Real fInvA = (  1.0 )/fA;
           afT[0] = (  -fB - fRoot )*fInvA;
           afT[1] = (  -fB + fRoot )*fInvA;
          
           dist = std::min(  afT[0],  afT[1] );
           return true;
           }
           else
           {
           dist = -fB/fA;
           return true;
           }
           }
           // --------------------------------------------------------------------
           // Ray3 implementation
           // --------------------------------------------------------------------
    1298   Real Ray3::squaredDistance(   const Vector3& point  ) const
           {
           Vector3 delta = point - origin;
           Real proj = direction | delta;
          
           if (   proj < 0.0  )
           proj = 0.0;
           else
           {
           proj /= direction.squaredLength(   );
           delta += -proj*direction;
           }
          
           return delta.squaredLength(   );
           }
           // --------------------------------------------------------------------
    1314   Real Ray3::distance(   const Vector3& point  ) const
           {
           return Math::Sqrt(   squaredDistance(  point )  );
           }
           // --------------------------------------------------------------------
    1319   Real Ray3::squaredDistance(   const Line& line  ) const
           {
           Vector3 lineDir = line.getDirection(   );
           Vector3 kDiff = line.start - origin;
           Real fA00 = lineDir.squaredLength(   );
           Real fA01 = -(  lineDir|direction  );
           Real fA11 = direction.squaredLength(   );
           Real fB0 = (  kDiff|lineDir  );
           Real fC = kDiff.squaredLength(   );
           Real fDet = Math::Abs(  fA00*fA11-fA01*fA01 );
           Real fB1,   fS,   fT,   fSqrDist;
          
           if (   fDet >= LINE_EPSILON  )
           {
           fB1 = -(  kDiff|direction );
           fT = fA01*fB0-fA00*fB1;
          
           if (   fT >= (  Real )0.0  )
           {
           // two interior points are closest,   one on line and one on ray
           Real fInvDet = (  (  Real )1.0 )/fDet;
           fS = (  fA01*fB1-fA11*fB0 )*fInvDet;
           fT *= fInvDet;
           fSqrDist = fS*(  fA00*fS+fA01*fT+(  (  Real )2.0 )*fB0 ) +
           fT*(  fA01*fS+fA11*fT+(  (  Real )2.0 )*fB1 )+fC;
           }
           else
           {
           // end point of ray and interior point of line are closest
           fS = -fB0/fA00;
           fT = (  Real )0.0;
           fSqrDist = fB0*fS+fC;
           }
           }
           else
           {
           // lines are parallel,   closest pair with one point at ray origin
           fS = -fB0/fA00;
           fT = (  Real )0.0;
           fSqrDist = fB0*fS+fC;
           }
          
           return Math::Abs(  fSqrDist );
           }
           // --------------------------------------------------------------------
    1364   Real Ray3::distance(   const Line& line  ) const
           {
           return Math::Sqrt(   squaredDistance(  line )  );
           }
           // --------------------------------------------------------------------
    1369   bool Ray3::intersect(   const Aabb& aabb  ) const
           {
           OBB obb(  aabb );
           return intersect(  obb );
           }
           // --------------------------------------------------------------------
    1375   bool Ray3::intersect(   const OBB& rkBox  ) const
           {
           Real fWdU[3],   fAWdU[3],   fDdU[3],   fADdU[3],   fAWxDdU[3],   fRhs;
          
           Vector3 rot[3] = { rkBox.getOrientation(   ).GetColumn(  0 ),  
           rkBox.getOrientation(   ).GetColumn(  1 ),  
           rkBox.getOrientation(   ).GetColumn(  2 ) };
           Vector3 kDiff = origin - rkBox.getCenter(   );
          
           fWdU[0] = direction | rot[0];
           fAWdU[0] = Math::Abs(   fWdU[0] );
           fDdU[0] = kDiff | rot[0];
           fADdU[0] = Math::Abs(   fDdU[0] );
           if (   fADdU[0] > rkBox.getExtents(   )[0] && fDdU[0]*fWdU[0] >= (  Real )0.0  )
           return false;
          
           fWdU[1] = direction | rot[1];
           fAWdU[1] = Math::Abs(   fWdU[1] );
           fDdU[1] = kDiff | rot[1];
           fADdU[1] = Math::Abs(   fDdU[1] );
           if (   fADdU[1] > rkBox.getExtents(   )[1] && fDdU[1]*fWdU[1] >= (  Real )0.0  )
           return false;
          
           fWdU[2] = direction | rot[2];
           fAWdU[2] = Math::Abs(   fWdU[2] );
           fDdU[2] = kDiff | rot[2];
           fADdU[2] = Math::Abs(   fDdU[2] );
           if (   fADdU[2] > rkBox.getExtents(   )[2] && fDdU[2]*fWdU[2] >= (  Real )0.0  )
           return false;
          
           Vector3 kWxD = direction ^ kDiff;
           fAWxDdU[0] = Math::Abs(   kWxD | rot[0]  );
           fRhs = rkBox.getExtents(   )[1]*fAWdU[2] + rkBox.getExtents(   )[2]*fAWdU[1];
           if (   fAWxDdU[0] > fRhs  )
           return false;
          
           fAWxDdU[1] = Math::Abs(   kWxD | rot[1]  );
           fRhs = rkBox.getExtents(   )[0]*fAWdU[2] + rkBox.getExtents(   )[2]*fAWdU[0];
           if (   fAWxDdU[1] > fRhs  )
           return false;
          
           fAWxDdU[2] = Math::Abs(   kWxD | rot[2]  );
           fRhs = rkBox.getExtents(   )[0]*fAWdU[1] + rkBox.getExtents(   )[1]*fAWdU[0];
           if (   fAWxDdU[2] > fRhs  )
           return false;
          
           return true;
           }
           // --------------------------------------------------------------------
    1424   bool Ray3::intersect(   const Sphere& sphere  ) const
           {
           Real squaredDist = squaredDistance(   sphere.getCenter(   )  );
           return squaredDist <= sphere.getRadius(   )*sphere.getRadius(   );
           }
           // --------------------------------------------------------------------
    1430   bool Ray3::intersect(   const Capsule& capsule  ) const
           {
           Real squaredDist = squaredDistance(   Line(  capsule.start,   capsule.end )  );
           return squaredDist <= capsule.radius*capsule.radius;
           }
           // --------------------------------------------------------------------
    1436   bool Ray3::pick(   const Aabb& aabb,   Real& dist  ) const
           {
           OBB obb(  aabb );
           return pick(  obb,   dist );
           }
           // --------------------------------------------------------------------
    1442   bool Ray3::pick(   const OBB& obb,   Real& dist  ) const
           {
           dist = 0.0f;
          
           // convert ray to box coordinates
           Vector3 kDiff = origin - obb.getCenter(   );
           Vector3 rot[3] = { obb.getOrientation(   ).GetColumn(  0 ),  
           obb.getOrientation(   ).GetColumn(  1 ),  
           obb.getOrientation(   ).GetColumn(  2 ) };
           Vector3 kOrigin(  
           kDiff | rot[0],  
           kDiff | rot[1],  
           kDiff | rot[2]
            );
          
           Vector3 kDirection(  
           direction | rot[0],  
           direction | rot[1],  
           direction | rot[2]
            );
          
           Real fT0 = 0.0,  
           fT1 = Math::POS_INFINITY;
          
           bool ret = FindIntersection(  kOrigin,  kDirection,  obb.getExtents(   ),   fT0,  fT1 );
          
           if (   ret  )
           {
           if (   fT0 > 0.0  )
           dist = std::min(  fT0,  fT1 );
           else // fT0 == 0
           dist = fT1;
           }
          
           return ret;
           }
           // --------------------------------------------------------------------
    1479   bool Ray3::pick(   const Sphere& sphere,   Real& dist  ) const
           {
           // set up quadratic Q(  t ) = a*t^2 + 2*b*t + c
           Vector3 kDiff = origin - sphere.getCenter(   );
           Real fA = direction.squaredLength(   );
           Real fB = kDiff | direction;
           Real fC = kDiff.squaredLength(   ) - sphere.getRadius(   )*sphere.getRadius(   );
          
           Real afT[2];
           Real fDiscr = fB*fB - fA*fC;
           dist = 0.0;
          
           // tests if the code won't return intersections
           if (   fDiscr < 0.0  )
           return false;
          
           if (   fDiscr > 0.0  )
           {
           Real fRoot = Math::Sqrt(  fDiscr );
           Real fInvA = (  1.0 )/fA;
           afT[0] = (  -fB - fRoot )*fInvA;
           afT[1] = (  -fB + fRoot )*fInvA;
          
           // aft[1]>=afT[0] >= 0.0
           if (   afT[0] >= 0.0  )
           {
           dist = std::min(  afT[0],  afT[1] );
           return true;
           }
           else if (   afT[1] >= 0.0  )
           {
           dist = afT[1];
           return true;
           }
           else
           return false;
           }
           else
           {
           afT[0] = -fB/fA;
           if (   afT[0] >= 0.0  )
           {
           dist = afT[0];
           return true;
           }
           else
           return false;
           }
           }
           // --------------------------------------------------------------------
           }
          }

./components/ogre/ogreopcode/src/OgreOpcodeMath.cpp

          ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeMath.cpp
          /// @brief Triangle Intersection routines
          ///
          /// @author The OgreOpcode Team
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          
          #include "OgreOpcodeMath.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           namespace Details
           {
          #define SMALL_EPSILON 0.000001f
          
          #define FABS(  x ) (  fabsf(  x ) ) /* implement as is fastest on your machine */
          
           /* if USE_EPSILON_TEST is true then we do a check:
           if |dv|<SMALL_EPSILON then dv=0.0;
           else no check is done (  which is less robust )
           */
          #define USE_EPSILON_TEST TRUE
          
           /* some macros */
          
           /* sort so that a<=b */
          #define SORT(  a,  b ) \
           if(  a>b ) \
           { \
           float c; \
           c=a; \
           a=b; \
           b=c; \
           }
      57  
           /* this edge to edge test is based on Franlin Antonio's gem:
      59   "Faster Line Segment Intersection",   in Graphics Gems III,  
           pp. 199-202 */
      61  #define EDGE_EDGE_TEST(  V0,  U0,  U1 ) \
           Bx=U0[i0]-U1[i0]; \
           By=U0[i1]-U1[i1]; \
           Cx=V0[i0]-U0[i0]; \
           Cy=V0[i1]-U0[i1]; \
      66   f=Ay*Bx-Ax*By; \
      67   d=By*Cx-Bx*Cy; \
      68   if(  (  f>0 && d>=0 && d<=f ) || (  f<0 && d<=0 && d>=f ) ) \
           { \
           e=Ax*Cy-Ay*Cx; \
           if(  f>0 ) \
           { \
           if(  e>=0 && e<=f ) return true; \
           } \
           else \
           { \
           if(  e<=0 && e>=f ) return true; \
           } \
           }
          
          #define EDGE_AGAINST_TRI_EDGES(  V0,  V1,  U0,  U1,  U2 ) \
           { \
           float Ax,  Ay,  Bx,  By,  Cx,  Cy,  e,  d,  f; \
           Ax=V1[i0]-V0[i0]; \
           Ay=V1[i1]-V0[i1]; \
           /* test edge U0,  U1 against V0,  V1 */ \
           EDGE_EDGE_TEST(  V0,  U0,  U1 ); \
           /* test edge U1,  U2 against V0,  V1 */ \
           EDGE_EDGE_TEST(  V0,  U1,  U2 ); \
           /* test edge U2,  U1 against V0,  V1 */ \
           EDGE_EDGE_TEST(  V0,  U2,  U0 ); \
           }
          
          #define POINT_IN_TRI(  V0,  U0,  U1,  U2 ) \
           { \
           float a,  b,  c,  d0,  d1,  d2; \
           /* is T1 completly inside T2? */ \
           /* check if V0 is inside tri(  U0,  U1,  U2 ) */ \
           a=U1[i1]-U0[i1]; \
           b=-(  U1[i0]-U0[i0] ); \
           c=-a*U0[i0]-b*U0[i1]; \
           d0=a*V0[i0]+b*V0[i1]+c; \
           \
           a=U2[i1]-U1[i1]; \
           b=-(  U2[i0]-U1[i0] ); \
           c=-a*U1[i0]-b*U1[i1]; \
           d1=a*V0[i0]+b*V0[i1]+c; \
           \
           a=U0[i1]-U2[i1]; \
           b=-(  U0[i0]-U2[i0] ); \
           c=-a*U2[i0]-b*U2[i1]; \
           d2=a*V0[i0]+b*V0[i1]+c; \
           if(  d0*d1>0.0 ) \
           { \
           if(  d0*d2>0.0 ) return true; \
           } \
           }
          
           static bool coplanar_tri_tri(  const Vector3& N,   const Vector3 tri1[3],  
           const Vector3 tri2[3] )
           {
           float A[3];
           short i0,  i1;
           /* first project onto an axis-aligned plane,   that maximizes the area */
           /* of the triangles,   compute indices: i0,  i1. */
           A[0]=fabs(  N[0] );
           A[1]=fabs(  N[1] );
           A[2]=fabs(  N[2] );
           if(  A[0]>A[1] )
           {
           if(  A[0]>A[2] )
           {
           i0=1; /* A[0] is greatest */
           i1=2;
           }
           else
           {
           i0=0; /* A[2] is greatest */
           i1=1;
           }
           }
           else /* A[0]<=A[1] */
           {
           if(  A[2]>A[1] )
           {
           i0=0; /* A[2] is greatest */
           i1=1;
           }
           else
           {
           i0=0; /* A[1] is greatest */
           i1=2;
           }
           }
          
           /* test all edges of triangle 1 against the edges of triangle 2 */
           EDGE_AGAINST_TRI_EDGES(  tri1[0],  tri1[1],  tri2[0],  tri2[1],  tri2[2] );
           EDGE_AGAINST_TRI_EDGES(  tri1[1],  tri1[2],  tri2[0],  tri2[1],  tri2[2] );
           EDGE_AGAINST_TRI_EDGES(  tri1[2],  tri1[0],  tri2[0],  tri2[1],  tri2[2] );
          
           /* finally,   test if tri1 is totally contained in tri2 or vice versa */
           POINT_IN_TRI(  tri1[0],  tri2[0],  tri2[1],  tri2[2] );
           POINT_IN_TRI(  tri2[0],  tri1[0],  tri1[1],  tri1[2] );
          
           return false;
           }
          
          #define NEWCOMPUTE_INTERVALS(  VV0,  VV1,  VV2,  D0,  D1,  D2,  D0D1,  D0D2,  A,  B,  C,  X0,  X1 ) \
           { \
           if(  D0D1>0.0f ) \
           { \
           /* here we know that D0D2<=0.0 */ \
           /* that is D0,   D1 are on the same side,   D2 on the other or on the plane */ \
           A=VV2; B=(  VV0-VV2 )*D2; C=(  VV1-VV2 )*D2; X0=D2-D0; X1=D2-D1; \
           } \
           else if(  D0D2>0.0f )\
           { \
           /* here we know that d0d1<=0.0 */ \
           A=VV1; B=(  VV0-VV1 )*D1; C=(  VV2-VV1 )*D1; X0=D1-D0; X1=D1-D2; \
           } \
           else if(  D1*D2>0.0f || D0!=0.0f ) \
           { \
           /* here we know that d0d1<=0.0 or that D0!=0.0 */ \
           A=VV0; B=(  VV1-VV0 )*D0; C=(  VV2-VV0 )*D0; X0=D0-D1; X1=D0-D2; \
           } \
           else if(  D1!=0.0f ) \
           { \
           A=VV1; B=(  VV0-VV1 )*D1; C=(  VV2-VV1 )*D1; X0=D1-D0; X1=D1-D2; \
           } \
           else if(  D2!=0.0f ) \
           { \
           A=VV2; B=(  VV0-VV2 )*D2; C=(  VV1-VV2 )*D2; X0=D2-D0; X1=D2-D1; \
           } \
           else \
           { \
           /* triangles are coplanar */ \
           return coplanar_tri_tri(  N1,  tri1,  tri2 ); \
           } \
           }
          
           /**
           * Tests if two triangles intersect (  without divisions )
           *
           * @param tri1 Vertices of triangle 1
           * @param tri2 Vertices of triangle 2
           * @return true if the triangles intersect,   otherwise false
           *
           */
          
           bool Intersect3::triangleTriangle(  const Vector3 tri1[3],  
           const Vector3 tri2[3] )
           {
           Vector3 E1,  E2;
           Vector3 N1,  N2;
           float d1,  d2;
           float du0,  du1,  du2,  dv0,  dv1,  dv2;
           Vector3 D;
           float isect1[2],   isect2[2];
           float du0du1,  du0du2,  dv0dv1,  dv0dv2;
           short index;
           float vp0,  vp1,  vp2;
           float up0,  up1,  up2;
           float bb,  cc,  max;
           float a,  b,  c,  x0,  x1;
           float d,  e,  f,  y0,  y1;
           float xx,  yy,  xxyy,  tmp;
          
           /* compute plane equation of triangle(  tri1 ) */
           E1 = tri1[1] - tri1[0];
           E2 = tri1[2] - tri1[0];
           N1 = E1.crossProduct(  E2 );
           d1=-(  N1.dotProduct(  tri1[0] ) );
           /* plane equation 1: N1.X+d1=0 */
          
           /* put tri2 into plane equation 1 to compute signed distances to the plane*/
           du0=(  N1.dotProduct(  tri2[0] ) )+d1;
           du1=(  N1.dotProduct(  tri2[1] ) )+d1;
           du2=(  N1.dotProduct(  tri2[2] ) )+d1;
          
           /* coplanarity robustness check */
          #if USE_EPSILON_TEST==TRUE
           if(  FABS(  du0 )<SMALL_EPSILON ) du0=0.0;
           if(  FABS(  du1 )<SMALL_EPSILON ) du1=0.0;
           if(  FABS(  du2 )<SMALL_EPSILON ) du2=0.0;
          #endif
           du0du1=du0*du1;
           du0du2=du0*du2;
          
           if(  du0du1>0.0f && du0du2>0.0f ) /* same sign on all of them + not equal 0 ? */
           return 0; /* no intersection occurs */
          
           /* compute plane of triangle (  tri2 ) */
           E1 = tri2[1] - tri2[0];
           E2 = tri2[2] - tri2[0];
           N2 = E1.crossProduct(  E2 );
           d2=-(  N2.dotProduct(  tri2[0] ) );
           /* plane equation 2: N2.X+d2=0 */
          
           /* put tri1 into plane equation 2 */
           dv0=(  N2.dotProduct(  tri1[0] ) )+d2;
           dv1=(  N2.dotProduct(  tri1[1] ) )+d2;
           dv2=(  N2.dotProduct(  tri1[2] ) )+d2;
          
          #if USE_EPSILON_TEST==TRUE
           if(  FABS(  dv0 )<SMALL_EPSILON ) dv0=0.0;
           if(  FABS(  dv1 )<SMALL_EPSILON ) dv1=0.0;
           if(  FABS(  dv2 )<SMALL_EPSILON ) dv2=0.0;
          #endif
          
           dv0dv1=dv0*dv1;
           dv0dv2=dv0*dv2;
          
           if(  dv0dv1>0.0f && dv0dv2>0.0f ) /* same sign on all of them + not equal 0 ? */
           return 0; /* no intersection occurs */
          
           /* compute direction of intersection line */
           D = N1.crossProduct(  N2 );
          
           /* compute and index to the largest component of D */
           max=(  float )FABS(  D[0] );
           index=0;
           bb=(  float )FABS(  D[1] );
           cc=(  float )FABS(  D[2] );
           if(  bb>max ) max=bb,  index=1;
           if(  cc>max ) max=cc,  index=2;
          
           /* this is the simplified projection onto L*/
           vp0=tri1[0][index];
           vp1=tri1[1][index];
           vp2=tri1[2][index];
          
           up0=tri2[0][index];
           up1=tri2[1][index];
           up2=tri2[2][index];
          
           /* compute interval for triangle 1 */
           NEWCOMPUTE_INTERVALS(  vp0,  vp1,  vp2,  dv0,  dv1,  dv2,  dv0dv1,  dv0dv2,  a,  b,  c,  x0,  x1 );
          
           /* compute interval for triangle 2 */
           NEWCOMPUTE_INTERVALS(  up0,  up1,  up2,  du0,  du1,  du2,  du0du1,  du0du2,  d,  e,  f,  y0,  y1 );
          
           xx=x0*x1;
           yy=y0*y1;
           xxyy=xx*yy;
          
           tmp=a*xxyy;
           isect1[0]=tmp+b*x1*yy;
           isect1[1]=tmp+c*x0*yy;
          
           tmp=d*xxyy;
           isect2[0]=tmp+e*xx*y1;
           isect2[1]=tmp+f*xx*y0;
          
           SORT(  isect1[0],  isect1[1] );
           SORT(  isect2[0],  isect2[1] );
          
           if(  isect1[1]<isect2[0] || isect2[1]<isect1[0] ) return false;
           return true;
           }
          
           /* sort so that a<=b */
          #define SORT2(  a,  b,  smallest ) \
           if(  a>b ) \
           { \
           float c; \
           c=a; \
           a=b; \
           b=c; \
           smallest=1; \
           } \
           else smallest=0;
          
          
           static inline void isect2(  const Vector3 tri[3],  float VV0,  float VV1,  float VV2,  
           float D0,  float D1,  float D2,  float *isect0,  float *isect1,  Vector3 isectline[2] )
           {
           float tmp=D0/(  D0-D1 );
           Vector3 diff;
           *isect0=VV0+(  VV1-VV0 )*tmp;
           diff = tri[1] - tri[0];
           diff = diff * tmp;
           isectline[0] = diff + tri[0];
           tmp=D0/(  D0-D2 );
           *isect1=VV0+(  VV2-VV0 )*tmp;
           diff = tri[2] - tri[0];
           diff = diff * tmp;
           isectline[1] = tri[0] + diff;
           }
          
          
           static inline bool compute_intervals_isectline(  const Vector3 tri[3],  
           float VV0,  float VV1,  float VV2,  float D0,  float D1,  float D2,  
           float D0D1,  float D0D2,  float *isect0,  float *isect1,  
           Vector3 isectline[2] )
           {
           if(  D0D1>0.0f )
           {
           /* here we know that D0D2<=0.0 */
           /* that is D0,   D1 are on the same side,   D2 on the other or on the plane */
           Vector3 newTri[3] = {tri[2],   tri[0],   tri[1]};
           isect2(  newTri,  VV2,  VV0,  VV1,  D2,  D0,  D1,  isect0,  isect1,  isectline );
           }
           else if(  D0D2>0.0f )
           {
           Vector3 newTri[3] = {tri[1],   tri[0],   tri[2]};
           /* here we know that d0d1<=0.0 */
           isect2(  newTri,  VV1,  VV0,  VV2,  D1,  D0,  D2,  isect0,  isect1,  isectline );
           }
           else if(  D1*D2>0.0f || D0!=0.0f )
           {
           Vector3 newTri[3] = {tri[0],   tri[1],   tri[2]};
           /* here we know that d0d1<=0.0 or that D0!=0.0 */
           isect2(  newTri,  VV0,  VV1,  VV2,  D0,  D1,  D2,  isect0,  isect1,  isectline );
           }
           else if(  D1!=0.0f )
           {
           Vector3 newTri[3] = {tri[1],   tri[0],   tri[2]};
           isect2(  newTri,  VV1,  VV0,  VV2,  D1,  D0,  D2,  isect0,  isect1,  isectline );
           }
           else if(  D2!=0.0f )
           {
           Vector3 newTri[3] = {tri[2],   tri[0],   tri[1]};
           isect2(  newTri,  VV2,  VV0,  VV1,  D2,  D0,  D1,  isect0,  isect1,  isectline );
           }
           else
           {
           /* triangles are coplanar */
           return 1;
           }
           return 0;
           }
          
          #define COMPUTE_INTERVALS_ISECTLINE(  VERT0,  VERT1,  VERT2,  VV0,  VV1,  VV2,  D0,  D1,  D2,  D0D1,  D0D2,  isect0,  isect1,  isectpoint0,  isectpoint1 ) \
           if(  D0D1>0.0f ) \
           { \
           /* here we know that D0D2<=0.0 */ \
           /* that is D0,   D1 are on the same side,   D2 on the other or on the plane */ \
           isect2(  VERT2,  VERT0,  VERT1,  VV2,  VV0,  VV1,  D2,  D0,  D1,  &isect0,  &isect1,  isectpoint0,  isectpoint1 ); \
           }
          #if 0
           else if(  D0D2>0.0f ) \
           { \
           /* here we know that d0d1<=0.0 */ \
           isect2(  VERT1,  VERT0,  VERT2,  VV1,  VV0,  VV2,  D1,  D0,  D2,  &isect0,  &isect1,  isectpoint0,  isectpoint1 ); \
           } \
           else if(  D1*D2>0.0f || D0!=0.0f ) \
           { \
           /* here we know that d0d1<=0.0 or that D0!=0.0 */ \
           isect2(  VERT0,  VERT1,  VERT2,  VV0,  VV1,  VV2,  D0,  D1,  D2,  &isect0,  &isect1,  isectpoint0,  isectpoint1 ); \
           } \
           else if(  D1!=0.0f ) \
           { \
           isect2(  VERT1,  VERT0,  VERT2,  VV1,  VV0,  VV2,  D1,  D0,  D2,  &isect0,  &isect1,  isectpoint0,  isectpoint1 ); \
           } \
           else if(  D2!=0.0f ) \
           { \
           isect2(  VERT2,  VERT0,  VERT1,  VV2,  VV0,  VV1,  D2,  D0,  D1,  &isect0,  &isect1,  isectpoint0,  isectpoint1 ); \
           } \
           else \
           { \
           /* triangles are coplanar */ \
           coplanar=1; \
           return coplanar_tri_tri(  N1,  V0,  V1,  V2,  U0,  U1,  U2 ); \
           }
          #endif
          
           /**
           * Tests if two triangles intersect and compute the line of intersection
           * (  if they are not coplanar ).
           *
           * @param tri1 Vertices of triangle 1
           * @param tri2 Vertices of triangle 2
           * @param[out] isectline The line segment where they intersect
           * @param[out] coplanar Returns whether the triangles are coplanar
           * @return true if the triangles intersect,   otherwise false
           *
           */
          
           bool Intersect3::triangleTriangle(  const Vector3 tri1[3],  
           const Vector3 tri2[3],  
           Segment3& isectline,   bool& coplanar )
           {
           Vector3 E1,  E2;
           Vector3 N1,  N2;
           float d1,  d2;
           float du0,  du1,  du2,  dv0,  dv1,  dv2;
           Vector3 D;
           float isect1[2] = {0,  0},   isect2[2] = {0,  0};
           Vector3 isectpointA[2];
           Vector3 isectpointB[2];
           float du0du1,  du0du2,  dv0dv1,  dv0dv2;
           short index;
           float vp0,  vp1,  vp2;
           float up0,  up1,  up2;
           float b,  c,  max;
           int smallest1,  smallest2;
          
           /* compute plane equation of triangle(  tri1 ) */
           E1 = tri1[1] - tri1[0];
           E2 = tri1[2] - tri1[0];
           N1 = E1.crossProduct(  E2 );
           d1 =-(  N1.dotProduct(  tri1[0] ) );
           /* plane equation 1: N1.X+d1=0 */
          
           /* put tri2 into plane equation 1 to compute signed distances to the plane*/
           du0=(  N1.dotProduct(  tri2[0] ) )+d1;
           du1=(  N1.dotProduct(  tri2[1] ) )+d1;
           du2=(  N1.dotProduct(  tri2[2] ) )+d1;
          
           /* coplanarity robustness check */
          #if USE_EPSILON_TEST==TRUE
           if(  fabs(  du0 )<SMALL_EPSILON ) du0=0.0;
           if(  fabs(  du1 )<SMALL_EPSILON ) du1=0.0;
           if(  fabs(  du2 )<SMALL_EPSILON ) du2=0.0;
          #endif
           du0du1=du0*du1;
           du0du2=du0*du2;
          
           if(  du0du1>0.0f && du0du2>0.0f ) /* same sign on all of them + not equal 0 ? */
           return 0; /* no intersection occurs */
          
           /* compute plane of triangle (  tri2 ) */
           E1 = tri2[1] - tri2[0];
           E2 = tri2[2] - tri2[0];
           N2 = E1.crossProduct(  E2 );
           d2=-(  N2.dotProduct(  tri2[0] ) );
           /* plane equation 2: N2.X+d2=0 */
          
           /* put tri1 into plane equation 2 */
           dv0=(  N2.dotProduct(  tri1[0] ) )+d2;
           dv1=(  N2.dotProduct(  tri1[1] ) )+d2;
           dv2=(  N2.dotProduct(  tri1[2] ) )+d2;
          
          #if USE_EPSILON_TEST==TRUE
           if(  fabs(  dv0 )<SMALL_EPSILON ) dv0=0.0;
           if(  fabs(  dv1 )<SMALL_EPSILON ) dv1=0.0;
           if(  fabs(  dv2 )<SMALL_EPSILON ) dv2=0.0;
          #endif
          
           dv0dv1=dv0*dv1;
           dv0dv2=dv0*dv2;
          
           if(  dv0dv1>0.0f && dv0dv2>0.0f ) /* same sign on all of them + not equal 0 ? */
           return 0; /* no intersection occurs */
          
           /* compute direction of intersection line */
           D = N1.crossProduct(  N2 );
          
           /* compute and index to the largest component of D */
           max=fabs(  D[0] );
           index=0;
           b=fabs(  D[1] );
           c=fabs(  D[2] );
           if(  b>max ) max=b,  index=1;
           if(  c>max ) max=c,  index=2;
          
           /* this is the simplified projection onto L*/
           vp0=tri1[0][index];
           vp1=tri1[1][index];
           vp2=tri1[2][index];
          
           up0=tri2[0][index];
           up1=tri2[1][index];
           up2=tri2[2][index];
          
           /* compute interval for triangle 1 */
           coplanar=compute_intervals_isectline(  tri1,  vp0,  vp1,  vp2,  dv0,  dv1,  dv2,  
           dv0dv1,  dv0dv2,  &isect1[0],  &isect1[1],  isectpointA );
           if(  coplanar ) return coplanar_tri_tri(  N1,   tri1,   tri2 );
          
          
           /* compute interval for triangle 2 */
           compute_intervals_isectline(  tri2,  up0,  up1,  up2,  du0,  du1,  du2,  
           du0du1,  du0du2,  &isect2[0],  &isect2[1],  isectpointB );
          
           SORT2(  isect1[0],  isect1[1],  smallest1 );
           SORT2(  isect2[0],  isect2[1],  smallest2 );
          
           if(  isect1[1]<isect2[0] || isect2[1]<isect1[0] ) return 0;
          
           /* at this point,   we know that the triangles intersect */
          
           if(  isect2[0]<isect1[0] )
           {
           if(  smallest1==0 ) { isectline.setStart(  isectpointA[0] ); }
           else { isectline.setStart(  isectpointA[1] ); }
          
           if(  isect2[1]<isect1[1] )
           {
           if(  smallest2==0 ) { isectline.setEnd(  isectpointB[1] ); }
           else { isectline.setEnd(  isectpointB[0] ); }
           }
           else
           {
           if(  smallest1==0 ) { isectline.setEnd(  isectpointA[1] ); }
           else { isectline.setEnd(  isectpointA[0] ); }
           }
           }
           else
           {
           if(  smallest2==0 ) { isectline.setStart(  isectpointB[0] ); }
           else { isectline.setStart(  isectpointB[1] ); }
          
           if(  isect2[1]>isect1[1] )
           {
           if(  smallest1==0 ) { isectline.setEnd(  isectpointA[1] ); }
           else { isectline.setEnd(  isectpointA[0] ); }
           }
           else
           {
           if(  smallest2==0 ) { isectline.setEnd(  isectpointB[1] ); }
           else { isectline.setEnd(  isectpointB[0] ); }
           }
           }
           return true;
           }
          
           bool powerOf2(  unsigned int i )
           {
           Ogre::String binary = decimalToBinary(  i );
           int counter = 0;
           for(   int index = 0; index < static_cast<int>(  binary.size(   ) ); ++index  )
           if(   binary[index] == '1'  ) ++counter;
          
           if(   counter > 1  ) return false;
           else return true;
           }
          
           Ogre::String decimalToBinary(  unsigned int i )
           {
           Ogre::String binary = "";
           Ogre::String temp = "";
          
           do{
           temp += (  i % 2 ) + '0';
           i = i / 2;
           }while(   i > 0  );
          
           for(   int counter = static_cast<int>(  temp.size(   ) ); counter > 0; --counter  )
           binary += temp[counter];
          
           return binary;
           }
          
           }
          }

./components/ogre/ogreopcode/src/OgreOpcodeRay.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOpcodeRay.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          
          #include "OgreOpcodeRay.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           namespace Details
           {
           //------------------------------------------------------------------------
           // This class is implemented together with Line in 'OgreOpcodeLine.cpp'
           // because they share internal,   supporting C functions.
           //------------------------------------------------------------------------
           }
          }

./components/ogre/ogreopcode/src/OgreOpcodeTerrainData.cpp

       1  #include "OgreOpcodeTerrainData.h"
          #include "OgreCollisionManager.h"
          
          namespace OgreOpcode
          {
       6   TerrainData::TerrainData(  const std::vector<float>& HeightmapData,   size_t Width,   size_t Depth,   Ogre::Vector3 Scale,   Ogre::Vector3 Offset ) :
           mWidth(  Width ),  
           mDepth(  Depth ),  
           mScale(  Scale ),  
           mOffset(  Offset )
           {
           mHeightmapData = &HeightmapData;
           mTileShapes.clear(   );
           }
          
      16   TerrainData::~TerrainData(   )
           {
           }
          
      20   std::vector<OgreOpcode::PtrCollisionShape*>* TerrainData::createTileShapes(  unsigned int numTilesX,   unsigned int numTilesZ )
           {
           if(  !mTileShapes.empty(   ) ) return NULL;
           // enforcing number of x and z tiles to be greater than zero,   and also a power of 2: 2,   4,   8,   16,   etc.
           if(   (  numTilesX <= 0 ) || !Details::powerOf2(  numTilesX )  ) return NULL;
           if(   (  numTilesZ <= 0 ) || !Details::powerOf2(  numTilesZ )  ) return NULL;
          
           // calculate the number of vertices for each tile,  
           // for both x direction (  in 3d space ) verts,   and z direction (  in 3d space ) verts
           unsigned int xTileSize = (  (  mWidth - 1 ) / numTilesX ) + 1;
           unsigned int zTileSize = (  (  mDepth - 1 ) / numTilesZ ) + 1;
          
           //Create indices - ever 3 indices represent a triangle. 6 indices represent a quad.
           size_t index_size = (  xTileSize - 1 ) * (  zTileSize -1 ) * 6;
           // create buffer to store computed indices
           size_t* indices = new size_t[index_size*3];
           for(   size_t x = 0; x < xTileSize - 1; x++ )
           {
           for(   size_t y=0; y < zTileSize - 1; y++ )
           {
           // Define/Store indices that are used to create triangles.
           // The indices are used along with the list of vertices to define triangles.
           // Indices 0,   1,   2,   for example,   would create a line from vert[0] -> vert[1],   vert[1] -> vert[2],   vert[2] -> vert[0].
           // The example triangle would look like a line. (  not your typical triangle )
           // xTileSize comes in because each horizontal strip of vertices consists of exactly xTileSize vertices.
           // In this way,   you can add a z element to the triangle. (  actually looks like a triangle in 3 dimensions )
          
           // The idea here is to go across each row and build up each quad. (  2 triangles )
           // Each quad is a square that gets split into two polygons.
           // Below is a diagram of one tile where pX represents a vertex.
           //
           // p0 --- p1
           // . / .
           // p2 --- p3
           //
           // An example of a counter-clockwise polygon would be: p0 -> p1 -> p2
           // An example of a clockwise polygon would be: p1 -> p3 -> p2
           // Note1: note that I said "An example".
           // **** You can use any order,   but the indexing needs to match your vert list!!! ****
           // Note2: depending on how you define your indices,   you can control how the quad looks! (  Important )
           // p0 --- p1
           // . \ .
           // p2 --- p3
          
           // triangle1: counter clockwise winding. p3 -> p1 -> p0
           indices[(  x+y*(  xTileSize-1 ) )*6] = (  x+1 )+(  y+1 ) * xTileSize;
           indices[(  x+y*(  xTileSize-1 ) )*6+1] = (  x+1 )+y * xTileSize;
           indices[(  x+y*(  xTileSize-1 ) )*6+2] = x+y * xTileSize;
          
           // triangle2: counter clockwise winding. p3 -> p0 -> p2
           indices[(  x+y*(  xTileSize-1 ) )*6+3] = (  x+1 )+(  y+1 ) * xTileSize;
           indices[(  x+y*(  xTileSize-1 ) )*6+4] = x+y * xTileSize;
           indices[(  x+y*(  xTileSize-1 ) )*6+5] = x+(  y+1 ) * xTileSize;
           }
           }
          
           int tileCounter = 0;
           // Loop through all tiles
           for (   unsigned int zIndex = 0; zIndex < numTilesZ; ++zIndex  )
           {
           for (   unsigned int xIndex = 0; xIndex < numTilesX; ++xIndex  )
           {
           int numVertsPerTile = xTileSize * zTileSize;
           float* OOData = new float[numVertsPerTile * 3];
           int OODataCounter = 0;
          
           int zStart = zIndex * (  zTileSize - 1 );
           int xStart = xIndex * (  xTileSize - 1 );
           for(   unsigned int col = zStart; col < (  zStart + zTileSize ); ++col )
           {
           for(   unsigned int row = xStart; row < (  xStart + xTileSize ); ++row )
           {
           Ogre::Vector3 v3(  
           mOffset.x + (  row * mScale.x ),  
           mOffset.y + (  at(  row,  col ) * mScale.y ),  
           mOffset.z + (  col * mScale.z )
            );
           OOData[OODataCounter + 0] = v3.x;
           OOData[OODataCounter + 1] = v3.y;
           OOData[OODataCounter + 2] = v3.z;
           OODataCounter += 3;
           }
           }
          
           OgreOpcode::PtrCollisionShape* tempTerrainShape;
           Ogre::String shapeName = "terrainShape" + Ogre::StringConverter::toString(  tileCounter++ );
           tempTerrainShape = CollisionManager::getSingletonPtr(   )->createPtrCollisionShape(  shapeName );
           tempTerrainShape->load(  numVertsPerTile*3,   index_size,   OOData,   indices );
           mTileShapes.push_back(  tempTerrainShape );
          
           delete[] OOData;
           }
           }
          
           delete[] indices;
           indices = NULL;
          
           return &mTileShapes;
           }
          
     120   size_t TerrainData::getDepth(   )
           {
           return mDepth;
           }
          
     125   Ogre::Vector3 TerrainData::getOffset(   )
           {
           return mOffset;
           }
          
     130   Ogre::Vector3 TerrainData::getScale(   )
           {
           return mScale;
           }
          
     135   size_t TerrainData::getWidth(   )
           {
           return mWidth;
           }
          }

./components/ogre/ogreopcode/src/OgreOrientedBox.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreOrientedBox.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          
          #include "OgreOrientedBox.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           namespace Details
           {
           //------------------------------------------------------------------------
      37   bool OrientedBox::intersects(   const Details::bbox3& box  ) const
           {
           // Optimize this: return intersects(   OrientedBox(  box )  );
          
           //translation,   in parent frame (  note: A = this,   B = obb )
           Vector3 v = box.getCenter(   ) - center;
           Vector3 boxExtents = box.getExtents(   );
          
           //translation,   in A's frame
           Vector3 T(   v.dotProduct(   rot.GetColumn(  0 ) ),  
           v.dotProduct(   rot.GetColumn(  1 ) ),  
           v.dotProduct(   rot.GetColumn(  2 ) )  );
          
           //B's basis with respect to A's local frame
           Real R[3][3];
           Real FR[3][3];
           Real ra,   rb,   t;
           long i,   k;
           //calculate rotation matrix from "obb" to "this" - palso recomputes the fabs matrix
           for(   i=0 ; i<3 ; i++  )
           {
           for(   k=0 ; k<3 ; k++  )
           {
           R[i][k] = rot.GetColumn(  k )[i];
           // fabs and shift borrowed from RAPID
           FR[i][k] = 1e-6f + Math::Abs(  R[i][k] );
           }
           }
          
           // Separating axis theorem: test of all 15 potential separating axes
           // These axes are always parallel to each OBB edges or its normal plane
           const Vector3 &a = extents,  
           &b = boxExtents;
          
           // First stage: each obb's axis!
           //A's basis vectors
           for(   i=0 ; i<3 ; i++  )
           {
           ra = a[i];
           rb = b.x*FR[i][0] + b.y*FR[i][1] + b.z*FR[i][2];
           t = Math::Abs(   T[i]  );
          
           if(   t > ra + rb  ) return false;
           }
          
           //B's basis vectors
           for(   k=0 ; k<3 ; k++  )
           {
           ra = a.x*FR[0][k] + a.y*FR[1][k] + a.z*FR[2][k];
           rb = b[k];
           t = Math::Abs(   T[0]*R[0][k] + T[1]*R[1][k] + T[2]*R[2][k]  );
          
           if(   t > ra + rb  ) return false;
           }
          
           // Second stage: 9 cross products
           //L = A0 x B0
           ra = a[1]*FR[2][0] + a[2]*FR[1][0];
           rb = b[1]*FR[0][2] + b[2]*FR[0][1];
           t = Math::Abs(   T[2]*R[1][0] - T[1]*R[2][0]  );
           if(   t > ra + rb  ) return false;
          
           //L = A0 x B1
           ra = a[1]*FR[2][1] + a[2]*FR[1][1];
           rb = b[0]*FR[0][2] + b[2]*FR[0][0];
           t = Math::Abs(   T[2]*R[1][1] - T[1]*R[2][1]  );
           if(   t > ra + rb  ) return false;
          
           //L = A0 x B2
           ra = a[1]*FR[2][2] + a[2]*FR[1][2];
           rb = b[0]*FR[0][1] + b[1]*FR[0][0];
           t = Math::Abs(   T[2]*R[1][2] - T[1]*R[2][2]  );
           if(   t > ra + rb  ) return false;
          
           //L = A1 x B0
           ra = a[0]*FR[2][0] + a[2]*FR[0][0];
           rb = b[1]*FR[1][2] + b[2]*FR[1][1];
           t = Math::Abs(   T[0]*R[2][0] - T[2]*R[0][0]  );
           if(   t > ra + rb  ) return false;
          
           //L = A1 x B1
           ra = a[0]*FR[2][1] + a[2]*FR[0][1];
           rb = b[0]*FR[1][2] + b[2]*FR[1][0];
           t = Math::Abs(   T[0]*R[2][1] - T[2]*R[0][1]  );
           if(   t > ra + rb  ) return false;
          
           //L = A1 x B2
           ra = a[0]*FR[2][2] + a[2]*FR[0][2];
           rb = b[0]*FR[1][1] + b[1]*FR[1][0];
           t = Math::Abs(   T[0]*R[2][2] - T[2]*R[0][2]  );
           if(   t > ra + rb  ) return false;
          
           //L = A2 x B0
           ra = a[0]*FR[1][0] + a[1]*FR[0][0];
           rb = b[1]*FR[2][2] + b[2]*FR[2][1];
           t = Math::Abs(   T[1]*R[0][0] - T[0]*R[1][0]  );
           if(   t > ra + rb  ) return false;
          
           //L = A2 x B1
           ra = a[0]*FR[1][1] + a[1]*FR[0][1];
           rb = b[0]*FR[2][2] + b[2]*FR[2][0];
           t = Math::Abs(   T[1]*R[0][1] - T[0]*R[1][1]  );
           if(   t > ra + rb  ) return false;
          
           //L = A2 x B2
           ra = a[0]*FR[1][2] + a[1]*FR[0][2];
           rb = b[0]*FR[2][1] + b[1]*FR[2][0];
           t = Math::Abs(   T[1]*R[0][2] - T[0]*R[1][2]  );
           if(   t > ra + rb  ) return false;
          
          
           // Phew! No separating axis found,   no overlap!
           return true;
           }
           //------------------------------------------------------------------------
     152   bool OrientedBox::intersects(   const OrientedBox& obb  ) const
           {
           //translation,   in parent frame (  note: A = this,   B = obb )
           Vector3 v = obb.center - center;
           //translation,   in A's frame
           Vector3 T(   v.dotProduct(   rot.GetColumn(  0 ) ),  
           v.dotProduct(   rot.GetColumn(  1 ) ),  
           v.dotProduct(   rot.GetColumn(  2 ) )  );
          
           //B's basis with respect to A's local frame
           Real R[3][3];
           Real FR[3][3];
           Real ra,   rb,   t;
           long i,   k;
           //calculate rotation matrix from "obb" to "this" - palso recomputes the fabs matrix
           for(   i=0 ; i<3 ; i++  )
           {
           for(   k=0 ; k<3 ; k++  )
           {
           R[i][k] = rot.GetColumn(  i ).dotProduct(  obb.rot.GetColumn(  k )  );
           // fabs and shift borrowed from RAPID
           FR[i][k] = 1e-6f + Math::Abs(  R[i][k] );
           }
           }
          
           // Separating axis theorem: test of all 15 potential separating axes
           // These axes are always parallel to each OBB edges or its normal plane
           const Vector3 &a = extents,  
           &b = obb.extents;
          
           // First stage: each obb's axis!
           //A's basis vectors
           for(   i=0 ; i<3 ; i++  )
           {
           ra = a[i];
           rb = b.x*FR[i][0] + b.y*FR[i][1] + b.z*FR[i][2];
           t = Math::Abs(   T[i]  );
          
           if(   t > ra + rb  ) return false;
           }
          
           //B's basis vectors
           for(   k=0 ; k<3 ; k++  )
           {
           ra = a.x*FR[0][k] + a.y*FR[1][k] + a.z*FR[2][k];
           rb = b[k];
           t = Math::Abs(   T[0]*R[0][k] + T[1]*R[1][k] + T[2]*R[2][k]  );
          
           if(   t > ra + rb  ) return false;
           }
          
           // Second stage: 9 cross products
           //L = A0 x B0
           ra = a[1]*FR[2][0] + a[2]*FR[1][0];
           rb = b[1]*FR[0][2] + b[2]*FR[0][1];
           t = Math::Abs(   T[2]*R[1][0] - T[1]*R[2][0]  );
           if(   t > ra + rb  ) return false;
          
           //L = A0 x B1
           ra = a[1]*FR[2][1] + a[2]*FR[1][1];
           rb = b[0]*FR[0][2] + b[2]*FR[0][0];
           t = Math::Abs(   T[2]*R[1][1] - T[1]*R[2][1]  );
           if(   t > ra + rb  ) return false;
          
           //L = A0 x B2
           ra = a[1]*FR[2][2] + a[2]*FR[1][2];
           rb = b[0]*FR[0][1] + b[1]*FR[0][0];
           t = Math::Abs(   T[2]*R[1][2] - T[1]*R[2][2]  );
           if(   t > ra + rb  ) return false;
          
           //L = A1 x B0
           ra = a[0]*FR[2][0] + a[2]*FR[0][0];
           rb = b[1]*FR[1][2] + b[2]*FR[1][1];
           t = Math::Abs(   T[0]*R[2][0] - T[2]*R[0][0]  );
           if(   t > ra + rb  ) return false;
          
           //L = A1 x B1
           ra = a[0]*FR[2][1] + a[2]*FR[0][1];
           rb = b[0]*FR[1][2] + b[2]*FR[1][0];
           t = Math::Abs(   T[0]*R[2][1] - T[2]*R[0][1]  );
           if(   t > ra + rb  ) return false;
          
           //L = A1 x B2
           ra = a[0]*FR[2][2] + a[2]*FR[0][2];
           rb = b[0]*FR[1][1] + b[1]*FR[1][0];
           t = Math::Abs(   T[0]*R[2][2] - T[2]*R[0][2]  );
           if(   t > ra + rb  ) return false;
          
           //L = A2 x B0
           ra = a[0]*FR[1][0] + a[1]*FR[0][0];
           rb = b[1]*FR[2][2] + b[2]*FR[2][1];
           t = Math::Abs(   T[1]*R[0][0] - T[0]*R[1][0]  );
           if(   t > ra + rb  ) return false;
          
           //L = A2 x B1
           ra = a[0]*FR[1][1] + a[1]*FR[0][1];
           rb = b[0]*FR[2][2] + b[2]*FR[2][0];
           t = Math::Abs(   T[1]*R[0][1] - T[0]*R[1][1]  );
           if(   t > ra + rb  ) return false;
          
           //L = A2 x B2
           ra = a[0]*FR[1][2] + a[1]*FR[0][2];
           rb = b[0]*FR[2][1] + b[1]*FR[2][0];
           t = Math::Abs(   T[1]*R[0][2] - T[0]*R[1][2]  );
           if(   t > ra + rb  ) return false;
          
          
           // Phew! No separating axis found,   no overlap!
           return true;
           }
           //------------------------------------------------------------------------
           }
          }

./components/ogre/ogreopcode/src/OgrePtrCollisionShape.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgrePtrCollisionShape.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeExports.h"
          #include "OgrePtrCollisionShape.h"
          #include "OgreCollisionReporter.h"
          #include "OgreCollisionManager.h"
          #include "OgreOpcodeMath.h"
          #include "OgreOpcodeUtils.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           //------------------------------------------------------------------------
      39   PtrCollisionShape::PtrCollisionShape(  const Ogre::String& name )
           : ICollisionShape(  name )
           {
           }
          
           //------------------------------------------------------------------------
      45   PtrCollisionShape::~PtrCollisionShape(   )
           {
           delete[] mVertexBuf;
           delete[] mFaceBuf;
           mVertexBuf = 0;
           mFaceBuf = 0;
          
           // the "load" function creates a node,   so we need to cleanup this node.
           if(  mParentNode != NULL ) CollisionManager::getSingleton(   ).getSceneManager(   )->getRootSceneNode(   )->removeAndDestroyChild(  mParentNode->getName(   ) );
           mParentNode = NULL;
           }
          
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @param [in,   out] ent Entity * <TODO: insert parameter description here>
           /// @return bool <TODO: insert return value description here>
      62   bool PtrCollisionShape::load(  size_t numVertex,   size_t numIndices,   float *vertices,   size_t *indices )
           {
           assert(  !mVertexBuf && !mFaceBuf );
           assert(  numVertex < MAX_UDWORD );
           assert(  numIndices < MAX_UDWORD );
          
           numVertices = numVertex;
           numFaces = numIndices/3;
          
           // Let's make a deep copy of the data
           mVertexBuf = new float[numVertex];
           mFaceBuf = new size_t[numIndices*3];
           for (  size_t i = 0; i < numVertex; i++ )
           {
           mVertexBuf[i] = vertices[i];
           }
           for (  size_t i = 0; i < numIndices; i++ )
           {
           mFaceBuf[i] = indices[i];
           }
          
           mParentNode = CollisionManager::getSingleton(   ).getSceneManager(   )->getRootSceneNode(   )->createChildSceneNode(  "ptrcollnode" + this->getName(   ) );
          
           return rebuild(   );
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
      91   bool PtrCollisionShape::rebuild(   )
           {
           //opcMeshAccess.SetInterfaceType(  Opcode::MESH_TRIANGLE );
           opcMeshAccess.SetNbTriangles(  numFaces );
           opcMeshAccess.SetNbVertices(  numVertices );
           opcMeshAccess.SetPointers(  (  const IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           //opcMeshAccess.SetStrides(  sizeof(  int ) * 3,   sizeof(  float ) * 3 );
          
           return _rebuildFromCachedData(   );
          
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     106   bool PtrCollisionShape::refit(   )
           {
           return true;
           }
          
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     115   bool PtrCollisionShape::_refitToCachedData(   )
           {
           assert(  mVertexBuf );
          
           // rebuild tree
           if (  !opcModel.Refit(   ) )
           {
           LogManager::getSingleton(   ).logMessage(  
           "OgreOpcode::PtrCollisionShape::_refitToCachedData(   ): OPCODE Quick refit not possible with the given tree type." );
           // Backup plan -- rebuild full tree
           opcMeshAccess.SetPointers(  (  IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
           }
          
           calculateSize(   );
          
           //computeIceABB(   );
          
           return true;
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     141   bool PtrCollisionShape::_rebuildFromCachedData(   )
           {
           assert(  mVertexBuf && mFaceBuf );
          
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
          
           calculateSize(   );
          
           //computeIceABB(   );
          
           return true;
           }
          }
          
          //------------------------------------------------------------------------

./components/ogre/ogreopcode/src/OgreSphereMeshCollisionShape.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreSphereMeshCollisionShape.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeExports.h"
          #include "OgreSphereMeshCollisionShape.h"
          #include "OgreCollisionReporter.h"
          #include "OgreCollisionManager.h"
          #include "OgreOpcodeMath.h"
          #include "OgreOpcodeUtils.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           //------------------------------------------------------------------------
      39   SphereMeshCollisionShape::SphereMeshCollisionShape(  const Ogre::String& name )
           : ICollisionShape(  name )
           {
           }
          
           //------------------------------------------------------------------------
      45   SphereMeshCollisionShape::~SphereMeshCollisionShape(   )
           {
           if (  mEntity && mEntity->hasSkeleton(   ) )
           {
          #ifdef BUILD_AGAINST_AZATHOTH
           mEntity->removeSoftwareSkinningRequest(  false );
          #else
           mEntity->removeSoftwareAnimationRequest(  false );
          #endif
           }
           delete[] mVertexBuf;
           delete[] mFaceBuf;
           }
          
           //------------------------------------------------------------------------
           ///////////////////////////////////////////////////////////////////////////////
           /// Counts how many indices (  faces ) and vertices an entity contains.
           /// @param[in] entity Entity to count its data.
           /// @param[out] index_count Number of indices.
           /// @param[out] vertex_count Number of vertices.
           /// @author Yavin from the Ogre4J team
           ///////////////////////////////////////////////////////////////////////////////
      67   void SphereMeshCollisionShape::countIndicesAndVertices(  Entity * entity,   size_t & index_count,   size_t & vertex_count )
           {
           Mesh * mesh = entity->getMesh(   ).getPointer(   );
          
          #ifdef BUILD_AGAINST_AZATHOTH
           bool hwSkinning = entity->isHardwareSkinningEnabled(   );
          #else
           bool hwSkinning = entity->isHardwareAnimationEnabled(   );
          #endif
           bool added_shared = false;
           index_count = 0;
           vertex_count = 0;
          
           // Calculate how many vertices and indices we're going to need
           for (   unsigned short i = 0; i < mesh->getNumSubMeshes(   ); ++i )
           {
           SubMesh* submesh = mesh->getSubMesh(   i  );
          
           // We only need to add the shared vertices once
           if(  submesh->useSharedVertices )
           {
           if(   !added_shared  )
           {
           vertex_count += mesh->sharedVertexData->vertexCount;
           added_shared = true;
           }
           }
           else
           {
           vertex_count += submesh->vertexData->vertexCount;
           }
          
           // Add the indices
           index_count += submesh->indexData->indexCount;
           }
           }
          
          
           //------------------------------------------------------------------------
           //////////////////////////////////////////////////////////////////////////
           /// Converts mesh vertex and face data into simple float arrays.
           /// If the buffer parameters are null then that data is not converted.
           /// @param[in] entity Entity to extract data from.
           /// @param[out] vertexBuf Target vertex data array (  can be null ).
           /// @param[in] size_t vertex_count Number of vertices.
           /// @param[out] faceData Target face data array (  can be null ).
           /// @param[int] index_count Number of indices.
           /// @author Yavin from the Ogre4J team
           //////////////////////////////////////////////////////////////////////////
     116   void SphereMeshCollisionShape::convertMeshData(  Entity * entity,  
     117   float * vertexBuf,   size_t vertex_count,  
     118   size_t * faceBuf,   size_t index_count )
           {
           //---------------------------------------------------------------------
           // CONVERT MESH DATA
           //---------------------------------------------------------------------
           MeshPtr mesh = entity->getMesh(   );
           bool added_shared = false;
           size_t current_offset = 0;
           size_t shared_offset = 0;
           size_t next_offset = 0;
           size_t index_offset = 0;
           int numOfSubs = 0;
          
           bool useSoftwareBlendingVertices = entity->hasSkeleton(   );
          
           if (  useSoftwareBlendingVertices )
           {
           entity->_updateAnimation(   );
           }
          
           // Run through the submeshes again,   adding the data into the arrays
           for (   size_t i = 0; i < mesh->getNumSubMeshes(   ); ++i )
           {
           SubMesh* submesh = mesh->getSubMesh(  i );
           bool useSharedVertices = submesh->useSharedVertices;
          
           if (  vertexBuf )
           {
           //----------------------------------------------------------------
           // GET VERTEXDATA
           //----------------------------------------------------------------
           const VertexData * vertex_data;
           if(  useSoftwareBlendingVertices )
          #ifdef BUILD_AGAINST_AZATHOTH
           vertex_data = useSharedVertices ? entity->_getSharedBlendedVertexData(   ) : entity->getSubEntity(  i )->_getBlendedVertexData(   );
          #else
           vertex_data = useSharedVertices ? entity->_getSkelAnimVertexData(   ) : entity->getSubEntity(  i )->_getSkelAnimVertexData(   );
          #endif
           else
           vertex_data = useSharedVertices ? mesh->sharedVertexData : submesh->vertexData;
          
           if(  (  !useSharedVertices )||(  useSharedVertices && !added_shared ) )
           {
           if(  useSharedVertices )
           {
           added_shared = true;
           shared_offset = current_offset;
           }
          
           const VertexElement* posElem =
           vertex_data->vertexDeclaration->findElementBySemantic(  Ogre::VES_POSITION );
          
           HardwareVertexBufferSharedPtr vbuf =
           vertex_data->vertexBufferBinding->getBuffer(  posElem->getSource(   ) );
          
           unsigned char* vertex =
           static_cast<unsigned char*>(  vbuf->lock(  HardwareBuffer::HBL_READ_ONLY ) );
          
           // There is _no_ baseVertexPointerToElement(   ) which takes an Ogre::Real or a double
           // as second argument. So make it float,   to avoid trouble when Ogre::Real is
           // comiled/typedefed as double:
           float* pReal;
          
          #ifdef BUILD_AGAINST_AZATHOTH
           if (  useSoftwareBlendingVertices )
           {
           // Blended bone data is computed in world space.
           // Opcode expects data in local coordinates.
           Matrix4 xform = entity->_getParentNodeFullTransform(   ).inverse(   );
          
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
           Vector3 v = Vector3(  pReal[0],  pReal[1],  pReal[2] );
           v = xform * v;
           size_t n = current_offset*3 + j*3;
           vertexBuf[n + 0] = v[0];
           vertexBuf[n + 1] = v[1];
           vertexBuf[n + 2] = v[2];
           }
           }
           else
           {
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
           size_t n = current_offset*3 + j*3;
           vertexBuf[n + 0] = pReal[0];
           vertexBuf[n + 1] = pReal[1];
           vertexBuf[n + 2] = pReal[2];
           }
           }
          #else
          
           for(   size_t j = 0; j < vertex_data->vertexCount; ++j,   vertex += vbuf->getVertexSize(   ) )
           {
           posElem->baseVertexPointerToElement(  vertex,   &pReal );
          
           size_t n = current_offset*3 + j*3;
          
           vertexBuf[n + 0] = pReal[0];
           vertexBuf[n + 1] = pReal[1];
           vertexBuf[n + 2] = pReal[2];
           }
          #endif
           vbuf->unlock(   );
           next_offset += vertex_data->vertexCount;
           }
           }
          
           if (  faceBuf )
           {
           //----------------------------------------------------------------
           // GET INDEXDATA
           //----------------------------------------------------------------
           IndexData* index_data = submesh->indexData;
           size_t numTris = index_data->indexCount / 3;
           HardwareIndexBufferSharedPtr ibuf = index_data->indexBuffer;
          
           bool use32bitindexes = (  ibuf->getType(   ) == HardwareIndexBuffer::IT_32BIT );
          
           uint32 *pLong = static_cast<uint32*>(  ibuf->lock(  HardwareBuffer::HBL_READ_ONLY ) );
           uint16* pShort = reinterpret_cast<uint16*>(  pLong );
          
          
           size_t offset = (  submesh->useSharedVertices )? shared_offset : current_offset;
          
           if (   use32bitindexes  )
           {
           for (   size_t k = 0; k < numTris*3; ++k )
           {
           faceBuf[index_offset++] = pLong[k] + static_cast<int>(  offset );
           }
           }
           else
           {
           for (   size_t k = 0; k < numTris*3; ++k )
           {
           faceBuf[index_offset++] = static_cast<int>(  pShort[k] ) + static_cast<int>(  offset );
           }
           }
          
           ibuf->unlock(   );
           }
          
           current_offset = next_offset;
           }
           }
          
     267  void SphereMeshCollisionShape::createSphere(  const std::string& strName,   const float r,   const int nRings,   const int nSegments )
          {
           MeshPtr pSphere = MeshManager::getSingleton(   ).createManual(  strName,   ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
           SubMesh *pSphereVertex = pSphere->createSubMesh(   );
          
           pSphere->sharedVertexData = new VertexData(   );
           VertexData* vertexData = pSphere->sharedVertexData;
          
           // define the vertex format
           VertexDeclaration* vertexDecl = vertexData->vertexDeclaration;
           size_t currOffset = 0;
           // positions
           vertexDecl->addElement(  0,   currOffset,   VET_FLOAT3,   VES_POSITION );
           currOffset += VertexElement::getTypeSize(  VET_FLOAT3 );
           // normals
           vertexDecl->addElement(  0,   currOffset,   VET_FLOAT3,   VES_NORMAL );
           currOffset += VertexElement::getTypeSize(  VET_FLOAT3 );
           // two dimensional texture coordinates
           vertexDecl->addElement(  0,   currOffset,   VET_FLOAT2,   VES_TEXTURE_COORDINATES,   0 );
           currOffset += VertexElement::getTypeSize(  VET_FLOAT2 );
          
           // allocate the vertex buffer
           vertexData->vertexCount = (  nRings + 1 ) * (  nSegments+1 );
           HardwareVertexBufferSharedPtr vBuf = HardwareBufferManager::getSingleton(   ).createVertexBuffer(  vertexDecl->getVertexSize(  0 ),   vertexData->vertexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
           VertexBufferBinding* binding = vertexData->vertexBufferBinding;
           binding->setBinding(  0,   vBuf );
           float* pVertex = static_cast<float*>(  vBuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          
           // allocate index buffer
           pSphereVertex->indexData->indexCount = 6 * nRings * (  nSegments + 1 );
           pSphereVertex->indexData->indexBuffer = HardwareBufferManager::getSingleton(   ).createIndexBuffer(  HardwareIndexBuffer::IT_16BIT,   pSphereVertex->indexData->indexCount,   HardwareBuffer::HBU_STATIC_WRITE_ONLY,   false );
           HardwareIndexBufferSharedPtr iBuf = pSphereVertex->indexData->indexBuffer;
           unsigned short* pIndices = static_cast<unsigned short*>(  iBuf->lock(  HardwareBuffer::HBL_DISCARD ) );
          
           float fDeltaRingAngle = (  PI / nRings );
           float fDeltaSegAngle = (  2 * PI / nSegments );
           unsigned short wVerticeIndex = 0 ;
          
           // Generate the group of rings for the sphere
           for(   int ring = 0; ring <= nRings; ring++  ) {
           float r0 = r * sinf (  ring * fDeltaRingAngle );
           float y0 = r * cosf (  ring * fDeltaRingAngle );
          
           // Generate the group of segments for the current ring
           for(  int seg = 0; seg <= nSegments; seg++ ) {
           float x0 = r0 * sinf(  seg * fDeltaSegAngle );
           float z0 = r0 * cosf(  seg * fDeltaSegAngle );
          
           // Add one vertex to the strip which makes up the sphere
           *pVertex++ = x0;
           *pVertex++ = y0;
           *pVertex++ = z0;
          
           Vector3 vNormal = Vector3(  x0,   y0,   z0 ).normalisedCopy(   );
           *pVertex++ = vNormal.x;
           *pVertex++ = vNormal.y;
           *pVertex++ = vNormal.z;
          
           *pVertex++ = (  float ) seg / (  float ) nSegments;
           *pVertex++ = (  float ) ring / (  float ) nRings;
          
           if (  ring != nRings ) {
           // each vertex (  except the last ) has six indices pointing to it
           *pIndices++ = wVerticeIndex + nSegments + 1;
           *pIndices++ = wVerticeIndex;
           *pIndices++ = wVerticeIndex + nSegments;
           *pIndices++ = wVerticeIndex + nSegments + 1;
           *pIndices++ = wVerticeIndex + 1;
           *pIndices++ = wVerticeIndex;
           wVerticeIndex ++;
           }
           }; // end for seg
           } // end for ring
          
           // Unlock
           vBuf->unlock(   );
           iBuf->unlock(   );
           // Generate face list
           pSphereVertex->useSharedVertices = true;
          
           // the original code was missing this line:
           pSphere->_setBounds(   AxisAlignedBox(   Vector3(  -r,   -r,   -r ),   Vector3(  r,   r,   r )  ),   false  );
           pSphere->_setBoundingSphereRadius(  r );
           // this line makes clear the mesh is loaded (  avoids memory leaks )
           pSphere->load(   );
           }
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @param [in,   out] ent Entity * <TODO: insert parameter description here>
           /// @return bool <TODO: insert return value description here>
     357   bool SphereMeshCollisionShape::load(  const Ogre::String& name,   SceneNode* scnNode,   const float r,   const int nRings,   const int nSegments )
           {
           assert(  !mVertexBuf && !mFaceBuf );
          
           createSphere(  name ,   r,   nRings,   nSegments );
          
           mEntity = CollisionManager::getSingletonPtr(   )->getSceneManager(   )->createEntity(  name,  name );
          
           if (  mEntity->hasSkeleton(   ) ) {
          #ifdef BUILD_AGAINST_AZATHOTH
           mEntity->addSoftwareSkinningRequest(  false );
          #else
           mEntity->addSoftwareAnimationRequest(  false );
          #endif
           }
          
           mParentNode = scnNode;
           mFullTransform = mParentNode->_getFullTransform(   );
           //mParentNode->getWorldTransforms(  &mFullTransform );
           return rebuild(   );
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     382   bool SphereMeshCollisionShape::rebuild(   )
           {
           assert(  mEntity );
          
           // NOTE: Assuming presence or absence of skeleton hasn't changed!
          
           size_t vertex_count = 0;
           size_t index_count = 0;
           countIndicesAndVertices(  mEntity,   index_count,   vertex_count );
          
           // Re-Allocate space for the vertices and indices
           if (  mVertexBuf && numVertices != vertex_count ) {
           delete [] mVertexBuf;
           mVertexBuf = 0;
           }
           if (  mFaceBuf && numFaces != index_count/3 ) {
           delete [] mFaceBuf;
           mFaceBuf = 0;
           }
          
           if (  !mVertexBuf )
           mVertexBuf = new float[vertex_count * 3];
           if (  !mFaceBuf )
           mFaceBuf = new size_t[index_count];
          
           convertMeshData(  mEntity,   mVertexBuf,   vertex_count,   mFaceBuf,   index_count  );
          
           numFaces = index_count / 3;
           numVertices = vertex_count;
          
           opcMeshAccess.SetNbTriangles(  numFaces );
           opcMeshAccess.SetNbVertices(  numVertices );
           opcMeshAccess.SetPointers(  (  IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           //opcMeshAccess.SetStrides(  sizeof(  int ) * 3,   sizeof(  float ) * 3 );
          
           return _rebuildFromCachedData(   );
          
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     424   bool SphereMeshCollisionShape::refit(   )
           {
           // bail if we don't need to refit
           if (   mShapeIsStatic  )
           return true;
          
           assert(  mEntity && mVertexBuf );
          
          #ifdef _DEBUG
           size_t vertex_count = 0;
           size_t index_count = 0;
           countIndicesAndVertices(  mEntity,   index_count,   vertex_count );
           assert(  numVertices == vertex_count );
          #endif
          
           convertMeshData(  mEntity,   mVertexBuf,   numVertices );
          
           return _refitToCachedData(   );
           }
          
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     448   bool SphereMeshCollisionShape::_refitToCachedData(   )
           {
           assert(  mEntity && mVertexBuf );
          
           // rebuild tree
           if (  !opcModel.Refit(   ) )
           {
           LogManager::getSingleton(   ).logMessage(  
           "OgreOpcode::SphereMeshCollisionShape::_refitToCachedData(   ): OPCODE Quick refit not possible with the given tree type." );
           // Backup plan -- rebuild full tree
           opcMeshAccess.SetPointers(  (  IceMaths::IndexedTriangle* )mFaceBuf,   (  IceMaths::Point* )mVertexBuf );
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
           }
          
           calculateSize(   );
          
           //computeIceABB(   );
          
           return true;
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     474   bool SphereMeshCollisionShape::_rebuildFromCachedData(   )
           {
           assert(  mEntity && mVertexBuf && mFaceBuf );
          
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
          
           calculateSize(   );
          
           //computeIceABB(   );
          
           return true;
           }
          }
          
          //------------------------------------------------------------------------

./components/ogre/ogreopcode/src/OgreTerrainCollisionShape.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreTerrainCollisionShape.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          #include "OgreOpcodeExports.h"
          #include "OgreTerrainCollisionShape.h"
          #include "OgreCollisionReporter.h"
          #include "OgreCollisionManager.h"
          #include "OgreOpcodeMath.h"
          #include "OgreOpcodeUtils.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           //------------------------------------------------------------------------
      39   TerrainCollisionShape::TerrainCollisionShape(  const Ogre::String& name )
           : ICollisionShape(  name ),  
           mVerticesPerRow(  0 )
           {
           }
          
           //------------------------------------------------------------------------
      46   TerrainCollisionShape::~TerrainCollisionShape(   )
           {
           // No,   we are not deleting mVertexBuf nor mFaceBuf here!
           // They are owned by the DotSceneOctree SceneManager.
           }
          
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @param [in,   out] ent Entity * <TODO: insert parameter description here>
           /// @return bool <TODO: insert return value description here>
      57   bool TerrainCollisionShape::load(  int numVertex,   float *vertices,   int verticesPerRow,   int rowCount )
           {
           assert(  !mVertexBuf && !mFaceBuf );
           // triangleCount = 2*(  verticesPerRow-1 )*(  rowCount-1 )
           mVerticesPerRow = verticesPerRow;
           numVertices = mVerticesPerRow;
           numFaces = 2*(  mVerticesPerRow-1 )*(  rowCount-1 );
           mVertexBuf = vertices;
           mFaceBuf = 0;
          
           mParentNode = CollisionManager::getSingleton(   ).getSceneManager(   )->getRootSceneNode(   )->createChildSceneNode(  "ptrcollnode" + this->getName(   ) );
          
           return rebuild(   );
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
      75   bool TerrainCollisionShape::rebuild(   )
           {
           opcMeshAccess.SetInterfaceType(  Opcode::MESH_TERRAIN );
           opcMeshAccess.SetNbTriangles(  numFaces );
           opcMeshAccess.SetNbVertices(  numVertices );
           opcMeshAccess.SetPointers(  0,   (  IceMaths::Point* )mVertexBuf );
           //opcMeshAccess.SetStrides(  sizeof(  int )*3,   sizeof(  float ) * 3 );
          
           return _rebuildFromCachedData(   );
          
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
      90   bool TerrainCollisionShape::refit(   )
           {
           return true;
           }
          
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
      99   bool TerrainCollisionShape::_refitToCachedData(   )
           {
           assert(  mVertexBuf );
          
           // rebuild tree
           if (  !opcModel.Refit(   ) )
           {
           LogManager::getSingleton(   ).logMessage(  
           "OgreOpcode::TerrainCollisionShape::_refitToCachedData(   ): OPCODE Quick refit not possible with the given tree type." );
           // Backup plan -- rebuild full tree
           opcMeshAccess.SetPointers(  0,   (  IceMaths::Point* )mVertexBuf );
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
           }
          
           calculateSize(   );
          
           return true;
           }
          
           //------------------------------------------------------------------------
           /// <TODO: insert function description here>
           /// @return bool <TODO: insert return value description here>
     123   bool TerrainCollisionShape::_rebuildFromCachedData(   )
           {
           //assert(  mVertexBuf && mFaceBuf );
          
           Opcode::OPCODECREATE opcc;
           _prepareOpcodeCreateParams(  opcc );
           opcModel.Build(  opcc );
          
           calculateSize(   );
          
           return true;
           }
          
           //------------------------------------------------------------------------
           /// Renders the collide model triangle soup.
     138   void TerrainCollisionShape::visualize(  Details::OgreOpcodeDebugger* activeDebugger )
           {
           mActiveDebugger = activeDebugger;
          
           assert(  mVertexBuf );
          
           // render the triangle soup
           int i,   k;
           k = 0;
           for (  i = 0; i < mVerticesPerRow*mVerticesPerRow*3; i += 9 )
           {
           float v0 = mVertexBuf[i+0];
           float v1 = mVertexBuf[i+1];
           float v2 = mVertexBuf[i+2];
           float v3 = mVertexBuf[i+3];
           float v4 = mVertexBuf[i+4];
           float v5 = mVertexBuf[i+5];
           float v6 = mVertexBuf[i+6];
           float v7 = mVertexBuf[i+7];
           float v8 = mVertexBuf[i+8];
          
           const Matrix4 &m = getFullTransform(   );
          
           Vector3 vect0(  v0,  v1,  v2 );
           Vector3 vect1(  v3,  v4,  v5 );
           Vector3 vect2(  v6,  v7,  v8 );
           vect0 = m * vect0;
           vect1 = m * vect1;
           vect2 = m * vect2;
          
           mActiveDebugger->addShapeLine(  vect0.x,   vect0.y,   vect0.z,   vect1.x,   vect1.y,   vect1.z );
           mActiveDebugger->addShapeLine(  vect1.x,   vect1.y,   vect1.z,   vect2.x,   vect2.y,   vect2.z );
           mActiveDebugger->addShapeLine(  vect2.x,   vect2.y,   vect2.z,   vect0.x,   vect0.y,   vect0.z );
           }
           }
          }
          
          //------------------------------------------------------------------------

./components/ogre/ogreopcode/src/OgreTriangle.cpp

       1  ///////////////////////////////////////////////////////////////////////////////
          /// @file OgreTriangle.cpp
          /// @brief <TODO: insert file description here>
          ///
          /// @author The OgreOpcode Team @date 28-05-2005
          ///
          ///////////////////////////////////////////////////////////////////////////////
          ///
          /// This file is part of OgreOpcode.
          ///
          /// A lot of the code is based on the Nebula Opcode Collision module,   see docs/Nebula_license.txt
          ///
          /// OgreOpcode is free software; you can redistribute it and/or
          /// modify it under the terms of the GNU General Public
          /// License as published by the Free Software Foundation; either
          /// version 2.1 of the License,   or (  at your option ) any later version.
          ///
          /// OgreOpcode is distributed in the hope that it will be useful,  
          /// but WITHOUT ANY WARRANTY; without even the implied warranty of
          /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
          /// General Public License for more details.
          ///
          /// You should have received a copy of the GNU General Public
          /// License along with OgreOpcode; if not,   write to the Free Software
          /// Foundation,   Inc.,   59 Temple Place,   Suite 330,   Boston,   MA 02111-1307 USA
          ///
          ///////////////////////////////////////////////////////////////////////////////
          
          #include "OgreOpcodeMath.h"
          #include "OgreTriangle.h"
          #include "OgreCapsule.h"
          
          using namespace Ogre;
          namespace OgreOpcode
          {
           namespace Details
           {
           //------------------------------------------------------------------------
      39   Real Triangle::squaredDistance(   const Vector3& point  ) const
           {
           // edge pre-computing
           Vector3 e0 = vertices[1] - vertices[0];
           Vector3 e1 = vertices[2] - vertices[1];
          
           Vector3 kDiff = e0 - point;
           Real fA00 = e0.squaredLength(   );
           Real fA01 = e0 | e1;
           Real fA11 = e1.squaredLength(   );
           Real fB0 = kDiff.dotProduct(  e0 );
           Real fB1 = kDiff.dotProduct(  e1 );
           Real fC = kDiff.squaredLength(   );
           Real fDet = Math::Abs(  fA00*fA11-fA01*fA01 );
           Real fS = fA01*fB1-fA11*fB0;
           Real fT = fA01*fB0-fA00*fB1;
           Real fSqrDist;
          
           if (   fS + fT <= fDet  )
           {
           if (   fS < (  Real )0.0  )
           {
           if (   fT < (  Real )0.0  ) // region 4
           {
           if (   fB0 < (  Real )0.0  )
           {
           fT = (  Real )0.0;
           if (   -fB0 >= fA00  )
           {
           fS = (  Real )1.0;
           fSqrDist = fA00+(  (  Real )2.0 )*fB0+fC;
           }
           else
           {
           fS = -fB0/fA00;
           fSqrDist = fB0*fS+fC;
           }
           }
           else
           {
           fS = (  Real )0.0;
           if (   fB1 >= (  Real )0.0  )
           {
           fT = (  Real )0.0;
           fSqrDist = fC;
           }
           else if (   -fB1 >= fA11  )
           {
           fT = (  Real )1.0;
           fSqrDist = fA11+(  (  Real )2.0 )*fB1+fC;
           }
           else
           {
           fT = -fB1/fA11;
           fSqrDist = fB1*fT+fC;
           }
           }
           }
           else // region 3
           {
           fS = (  Real )0.0;
           if (   fB1 >= (  Real )0.0  )
           {
           fT = (  Real )0.0;
           fSqrDist = fC;
           }
           else if (   -fB1 >= fA11  )
           {
           fT = (  Real )1.0;
           fSqrDist = fA11+(  (  Real )2.0 )*fB1+fC;
           }
           else
           {
           fT = -fB1/fA11;
           fSqrDist = fB1*fT+fC;
           }
           }
           }
           else if (   fT < (  Real )0.0  ) // region 5
           {
           fT = (  Real )0.0;
           if (   fB0 >= (  Real )0.0  )
           {
           fS = (  Real )0.0;
           fSqrDist = fC;
           }
           else if (   -fB0 >= fA00  )
           {
           fS = (  Real )1.0;
           fSqrDist = fA00+(  (  Real )2.0 )*fB0+fC;
           }
           else
           {
           fS = -fB0/fA00;
           fSqrDist = fB0*fS+fC;
           }
           }
           else // region 0
           {
           // minimum at interior point
           Real fInvDet = (  (  Real )1.0 )/fDet;
           fS *= fInvDet;
           fT *= fInvDet;
           fSqrDist = fS*(  fA00*fS+fA01*fT+(  (  Real )2.0 )*fB0 ) +
           fT*(  fA01*fS+fA11*fT+(  (  Real )2.0 )*fB1 )+fC;
           }
           }
           else
           {
           Real fTmp0,   fTmp1,   fNumer,   fDenom;
          
           if (   fS < (  Real )0.0  ) // region 2
           {
           fTmp0 = fA01 + fB0;
           fTmp1 = fA11 + fB1;
           if (   fTmp1 > fTmp0  )
           {
           fNumer = fTmp1 - fTmp0;
           fDenom = fA00-2.0f*fA01+fA11;
           if (   fNumer >= fDenom  )
           {
           fS = (  Real )1.0;
           fT = (  Real )0.0;
           fSqrDist = fA00+(  (  Real )2.0 )*fB0+fC;
           }
           else
           {
           fS = fNumer/fDenom;
           fT = (  Real )1.0 - fS;
           fSqrDist = fS*(  fA00*fS+fA01*fT+2.0f*fB0 ) +
           fT*(  fA01*fS+fA11*fT+(  (  Real )2.0 )*fB1 )+fC;
           }
           }
           else
           {
           fS = (  Real )0.0;
           if (   fTmp1 <= (  Real )0.0  )
           {
           fT = (  Real )1.0;
           fSqrDist = fA11+(  (  Real )2.0 )*fB1+fC;
           }
           else if (   fB1 >= (  Real )0.0  )
           {
           fT = (  Real )0.0;
           fSqrDist = fC;
           }
           else
           {
           fT = -fB1/fA11;
           fSqrDist = fB1*fT+fC;
           }
           }
           }
           else if (   fT < (  Real )0.0  ) // region 6
           {
           fTmp0 = fA01 + fB1;
           fTmp1 = fA00 + fB0;
           if (   fTmp1 > fTmp0  )
           {
           fNumer = fTmp1 - fTmp0;
           fDenom = fA00-(  (  Real )2.0 )*fA01+fA11;
           if (   fNumer >= fDenom  )
           {
           fT = (  Real )1.0;
           fS = (  Real )0.0;
           fSqrDist = fA11+(  (  Real )2.0 )*fB1+fC;
           }
           else
           {
           fT = fNumer/fDenom;
           fS = (  Real )1.0 - fT;
           fSqrDist = fS*(  fA00*fS+fA01*fT+(  (  Real )2.0 )*fB0 ) +
           fT*(  fA01*fS+fA11*fT+(  (  Real )2.0 )*fB1 )+fC;
           }
           }
           else
           {
           fT = (  Real )0.0;
           if (   fTmp1 <= (  Real )0.0  )
           {
           fS = (  Real )1.0;
           fSqrDist = fA00+(  (  Real )2.0 )*fB0+fC;
           }
           else if (   fB0 >= (  Real )0.0  )
           {
           fS = (  Real )0.0;
           fSqrDist = fC;
           }
           else
           {
           fS = -fB0/fA00;
           fSqrDist = fB0*fS+fC;
           }
           }
           }
           else // region 1
           {
           fNumer = fA11 + fB1 - fA01 - fB0;
           if (   fNumer <= (  Real )0.0  )
           {
           fS = (  Real )0.0;
           fT = (  Real )1.0;
           fSqrDist = fA11+(  (  Real )2.0 )*fB1+fC;
           }
           else
           {
           fDenom = fA00-2.0f*fA01+fA11;
           if (   fNumer >= fDenom  )
           {
           fS = (  Real )1.0;
           fT = (  Real )0.0;
           fSqrDist = fA00+(  (  Real )2.0 )*fB0+fC;
           }
           else
           {
           fS = fNumer/fDenom;
           fT = (  Real )1.0 - fS;
           fSqrDist = fS*(  fA00*fS+fA01*fT+(  (  Real )2.0 )*fB0 ) +
           fT*(  fA01*fS+fA11*fT+(  (  Real )2.0 )*fB1 )+fC;
           }
           }
           }
           }
          
           // Uncomment this if you want the minimal to get the closest point in the
           // triangle (  barycentric coordinates )
           //if (   pfSParam  ) outSParam = fS;
           //if (   pfTParam  ) outTParam = fT;
          
           return Math::Abs(  fSqrDist );
           }
           //------------------------------------------------------------------------
           }
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IceAABB.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains AABB-related code.
           * \file IceAABB.cpp
           * \author Pierre Terdiman
           * \date January,   29,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * AABB class.
           * \class AABB
           * \author Pierre Terdiman
           * \version 1.0
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the sum of two AABBs.
           * \param aabb [in] the other AABB
           * \return Self-Reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      32  AABB& AABB::Add(  const AABB& aabb )
          {
           // Compute new min & max values
           Point Min; GetMin(  Min );
           Point Tmp; aabb.GetMin(  Tmp );
           Min.Min(  Tmp );
          
           Point Max; GetMax(  Max );
           aabb.GetMax(  Tmp );
           Max.Max(  Tmp );
          
           // Update this
           SetMinMax(  Min,   Max );
           return *this;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Makes a cube from the AABB.
           * \param cube [out] the cube AABB
           * \return cube edge length
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      55  float AABB::MakeCube(  AABB& cube ) const
          {
           Point Ext; GetExtents(  Ext );
           float Max = Ext.Max(   );
          
           Point Cnt; GetCenter(  Cnt );
           cube.SetCenterExtents(  Cnt,   Point(  Max,   Max,   Max ) );
           return Max;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Makes a sphere from the AABB.
           * \param sphere [out] sphere containing the AABB
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      71  void AABB::MakeSphere(  Sphere& sphere ) const
          {
           GetExtents(  sphere.mCenter );
           sphere.mRadius = sphere.mCenter.Magnitude(   ) * 1.00001f; // To make sure sphere::Contains(  *this ) succeeds
           GetCenter(  sphere.mCenter );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks a box is inside another box.
           * \param box [in] the other AABB
           * \return true if current box is inside input box
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      85  bool AABB::IsInside(  const AABB& box ) const
          {
           if(  box.GetMin(  0 )>GetMin(  0 ) ) return false;
           if(  box.GetMin(  1 )>GetMin(  1 ) ) return false;
           if(  box.GetMin(  2 )>GetMin(  2 ) ) return false;
           if(  box.GetMax(  0 )<GetMax(  0 ) ) return false;
           if(  box.GetMax(  1 )<GetMax(  1 ) ) return false;
           if(  box.GetMax(  2 )<GetMax(  2 ) ) return false;
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the AABB planes.
           * \param planes [out] 6 planes surrounding the box
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     103  bool AABB::ComputePlanes(  Plane* planes ) const
          {
           // Checkings
           if(  !planes ) return false;
          
           Point Center,   Extents;
           GetCenter(  Center );
           GetExtents(  Extents );
          
           // Writes normals
           planes[0].n = Point(  1.0f,   0.0f,   0.0f );
           planes[1].n = Point(  -1.0f,   0.0f,   0.0f );
           planes[2].n = Point(  0.0f,   1.0f,   0.0f );
           planes[3].n = Point(  0.0f,   -1.0f,   0.0f );
           planes[4].n = Point(  0.0f,   0.0f,   1.0f );
           planes[5].n = Point(  0.0f,   0.0f,   -1.0f );
          
           // Compute a point on each plane
           Point p0 = Point(  Center.x+Extents.x,   Center.y,   Center.z );
           Point p1 = Point(  Center.x-Extents.x,   Center.y,   Center.z );
           Point p2 = Point(  Center.x,   Center.y+Extents.y,   Center.z );
           Point p3 = Point(  Center.x,   Center.y-Extents.y,   Center.z );
           Point p4 = Point(  Center.x,   Center.y,   Center.z+Extents.z );
           Point p5 = Point(  Center.x,   Center.y,   Center.z-Extents.z );
          
           // Compute d
           planes[0].d = -(  planes[0].n|p0 );
           planes[1].d = -(  planes[1].n|p1 );
           planes[2].d = -(  planes[2].n|p2 );
           planes[3].d = -(  planes[3].n|p3 );
           planes[4].d = -(  planes[4].n|p4 );
           planes[5].d = -(  planes[5].n|p5 );
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the aabb points.
           * \param pts [out] 8 box points
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     146  bool AABB::ComputePoints(  Point* pts ) const
          {
           // Checkings
           if(  !pts ) return false;
          
           // Get box corners
           Point min; GetMin(  min );
           Point max; GetMax(  max );
          
           // 7+------+6 0 = ---
           // /| /| 1 = +--
           // / | / | 2 = ++-
           // / 4+---/--+5 3 = -+-
           // 3+------+2 / y z 4 = --+
           // | / | / | / 5 = +-+
           // |/ |/ |/ 6 = +++
           // 0+------+1 *---x 7 = -++
          
           // Generate 8 corners of the bbox
           pts[0] = Point(  min.x,   min.y,   min.z );
           pts[1] = Point(  max.x,   min.y,   min.z );
           pts[2] = Point(  max.x,   max.y,   min.z );
           pts[3] = Point(  min.x,   max.y,   min.z );
           pts[4] = Point(  min.x,   min.y,   max.z );
           pts[5] = Point(  max.x,   min.y,   max.z );
           pts[6] = Point(  max.x,   max.y,   max.z );
           pts[7] = Point(  min.x,   max.y,   max.z );
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Gets vertex normals.
           * \param pts [out] 8 box points
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     184  const Point* AABB::GetVertexNormals(   ) const
          {
           static float VertexNormals[] =
           {
           -INVSQRT3,   -INVSQRT3,   -INVSQRT3,  
           INVSQRT3,   -INVSQRT3,   -INVSQRT3,  
           INVSQRT3,   INVSQRT3,   -INVSQRT3,  
           -INVSQRT3,   INVSQRT3,   -INVSQRT3,  
           -INVSQRT3,   -INVSQRT3,   INVSQRT3,  
           INVSQRT3,   -INVSQRT3,   INVSQRT3,  
           INVSQRT3,   INVSQRT3,   INVSQRT3,  
           -INVSQRT3,   INVSQRT3,   INVSQRT3
           };
           return (  const Point* )VertexNormals;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Returns edges.
           * \return 24 indices (  12 edges ) indexing the list returned by ComputePoints(   )
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     206  const udword* AABB::GetEdges(   ) const
          {
           static udword Indices[] = {
           0,   1,   1,   2,   2,   3,   3,   0,  
           7,   6,   6,   5,   5,   4,   4,   7,  
           1,   5,   6,   2,  
           3,   7,   4,   0
           };
           return Indices;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Returns edge normals.
           * \return edge normals in local space
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     223  const Point* AABB::GetEdgeNormals(   ) const
          {
           static float EdgeNormals[] =
           {
           0,   -INVSQRT2,   -INVSQRT2,   // 0-1
           INVSQRT2,   0,   -INVSQRT2,   // 1-2
           0,   INVSQRT2,   -INVSQRT2,   // 2-3
           -INVSQRT2,   0,   -INVSQRT2,   // 3-0
          
           0,   INVSQRT2,   INVSQRT2,   // 7-6
           INVSQRT2,   0,   INVSQRT2,   // 6-5
           0,   -INVSQRT2,   INVSQRT2,   // 5-4
           -INVSQRT2,   0,   INVSQRT2,   // 4-7
          
           INVSQRT2,   -INVSQRT2,   0,   // 1-5
           INVSQRT2,   INVSQRT2,   0,   // 6-2
           -INVSQRT2,   INVSQRT2,   0,   // 3-7
           -INVSQRT2,   -INVSQRT2,   0 // 4-0
           };
           return (  const Point* )EdgeNormals;
          }
          
          // ===========================================================================
          // (  C ) 1996-98 Vienna University of Technology
          // ===========================================================================
          // NAME: bboxarea
          // TYPE: c++ code
          // PROJECT: Bounding Box Area
          // CONTENT: Computes area of 2D projection of 3D oriented bounding box
          // VERSION: 1.0
          // ===========================================================================
          // AUTHORS: ds Dieter Schmalstieg
          // ep Erik Pojar
          // ===========================================================================
          // HISTORY:
          //
          // 19-sep-99 15:23:03 ds last modification
          // 01-dec-98 15:23:03 ep created
          // ===========================================================================
          
          //----------------------------------------------------------------------------
          // SAMPLE CODE STARTS HERE
          //----------------------------------------------------------------------------
          
          // NOTE: This sample program requires OPEN INVENTOR!
          
          //indexlist: this table stores the 64 possible cases of classification of
          //the eyepoint with respect to the 6 defining planes of the bbox (  2^6=64 )
          //only 26 (  3^3-1,   where 1 is "inside" cube ) of these cases are valid.
          //the first 6 numbers in each row are the indices of the bbox vertices that
          //form the outline of which we want to compute the area (  counterclockwise
          //ordering ),   the 7th entry means the number of vertices in the outline.
          //there are 6 cases with a single face and and a 4-vertex outline,   and
          //20 cases with 2 or 3 faces and a 6-vertex outline. a value of 0 indicates
          //an invalid case.
          
          
          // Original list was made of 7 items,   I added an 8th element:
          // - to padd on a cache line
          // - to repeat the first entry to avoid modulos
          //
          // I also replaced original ints with sbytes.
          
          static const sbyte gIndexList[64][8] =
          {
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   // 0 inside
           { 0,   4,   7,   3,   0,  -1,  -1,   4},   // 1 left
           { 1,   2,   6,   5,   1,  -1,  -1,   4},   // 2 right
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   // 3 -
           { 0,   1,   5,   4,   0,  -1,  -1,   4},   // 4 bottom
           { 0,   1,   5,   4,   7,   3,   0,   6},   // 5 bottom,   left
           { 0,   1,   2,   6,   5,   4,   0,   6},   // 6 bottom,   right
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   // 7 -
           { 2,   3,   7,   6,   2,  -1,  -1,   4},   // 8 top
           { 0,   4,   7,   6,   2,   3,   0,   6},   // 9 top,   left
           { 1,   2,   3,   7,   6,   5,   1,   6},   //10 top,   right
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //11 -
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //12 -
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //13 -
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //14 -
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //15 -
           { 0,   3,   2,   1,   0,  -1,  -1,   4},   //16 front
           { 0,   4,   7,   3,   2,   1,   0,   6},   //17 front,   left
           { 0,   3,   2,   6,   5,   1,   0,   6},   //18 front,   right
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //19 -
           { 0,   3,   2,   1,   5,   4,   0,   6},   //20 front,   bottom
           { 1,   5,   4,   7,   3,   2,   1,   6},   //21 front,   bottom,   left
           { 0,   3,   2,   6,   5,   4,   0,   6},   //22 front,   bottom,   right
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //23 -
           { 0,   3,   7,   6,   2,   1,   0,   6},   //24 front,   top
           { 0,   4,   7,   6,   2,   1,   0,   6},   //25 front,   top,   left
           { 0,   3,   7,   6,   5,   1,   0,   6},   //26 front,   top,   right
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //27 -
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //28 -
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //29 -
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //30 -
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //31 -
           { 4,   5,   6,   7,   4,  -1,  -1,   4},   //32 back
           { 0,   4,   5,   6,   7,   3,   0,   6},   //33 back,   left
           { 1,   2,   6,   7,   4,   5,   1,   6},   //34 back,   right
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //35 -
           { 0,   1,   5,   6,   7,   4,   0,   6},   //36 back,   bottom
           { 0,   1,   5,   6,   7,   3,   0,   6},   //37 back,   bottom,   left
           { 0,   1,   2,   6,   7,   4,   0,   6},   //38 back,   bottom,   right
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //39 -
           { 2,   3,   7,   4,   5,   6,   2,   6},   //40 back,   top
           { 0,   4,   5,   6,   2,   3,   0,   6},   //41 back,   top,   left
           { 1,   2,   3,   7,   4,   5,   1,   6},   //42 back,   top,   right
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //43 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //44 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //45 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //46 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //47 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //48 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //49 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //50 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //51 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //52 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //53 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //54 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //55 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //56 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //57 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //58 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //59 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //60 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //61 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0},   //62 invalid
           {-1,  -1,  -1,  -1,  -1,  -1,  -1,   0} //63 invalid
          };
          
     354  const sbyte* AABB::ComputeOutline(  const Point& local_eye,   sdword& num ) const
          {
           // Get box corners
           Point min; GetMin(  min );
           Point max; GetMax(  max );
          
           // Compute 6-bit code to classify eye with respect to the 6 defining planes of the bbox
           int pos = (  (  local_eye.x < min.x ) ? 1 : 0 ) // 1 = left
           + (  (  local_eye.x > max.x ) ? 2 : 0 ) // 2 = right
           + (  (  local_eye.y < min.y ) ? 4 : 0 ) // 4 = bottom
           + (  (  local_eye.y > max.y ) ? 8 : 0 ) // 8 = top
           + (  (  local_eye.z < min.z ) ? 16 : 0 ) // 16 = front
           + (  (  local_eye.z > max.z ) ? 32 : 0 ); // 32 = back
          
           // Look up number of vertices in outline
           num = (  sdword )gIndexList[pos][7];
           // Zero indicates invalid case
           if(  !num ) return null;
          
           return &gIndexList[pos][0];
          }
          
          // calculateBoxArea: computes the screen-projected 2D area of an oriented 3D bounding box
          
          //const Point& eye,   //eye point (  in bbox object coordinates )
          //const AABB& box,   //3d bbox
          //const Matrix4x4& mat,   //free transformation for bbox
          //float width,   float height,   int& num )
     382  float AABB::ComputeBoxArea(  const Point& eye,   const Matrix4x4& mat,   float width,   float height,   sdword& num ) const
          {
           const sbyte* Outline = ComputeOutline(  eye,   num );
           if(  !Outline ) return -1.0f;
          
           // Compute box vertices
           Point vertexBox[8],   dst[8];
           ComputePoints(  vertexBox );
          
           // Transform all outline corners into 2D screen space
           for(  sdword i=0;i<num;i++ )
           {
           HPoint Projected;
           vertexBox[Outline[i]].ProjectToScreen(  width,   height,   mat,   Projected );
           dst[i] = Projected;
           }
          
           float Sum = (  dst[num-1][0] - dst[0][0] ) * (  dst[num-1][1] + dst[0][1] );
          
           for(  int i=0; i<num-1; i++ )
           Sum += (  dst[i][0] - dst[i+1][0] ) * (  dst[i][1] + dst[i+1][1] );
          
           return Sum * 0.5f; //return computed value corrected by 0.5
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IceContainer.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a simple container class.
           * \file IceContainer.cpp
           * \author Pierre Terdiman
           * \date February,   5,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a list of 32-bits values.
           * Use this class when you need to store an unknown number of values. The list is automatically
           * resized and can contains 32-bits entities (  dwords or floats )
           *
           * \class Container
           * \author Pierre Terdiman
           * \version 1.0
           * \date 08.15.98
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceCore;
          
          // Static members
          #ifdef CONTAINER_STATS
          udword Container::mNbContainers = 0;
          udword Container::mUsedRam = 0;
          #endif
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor. No entries allocated there.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      40  Container::Container(   ) : mMaxNbEntries(  0 ),   mCurNbEntries(  0 ),   mEntries(  null ),   mGrowthFactor(  2.0f )
          {
          #ifdef CONTAINER_STATS
           mNbContainers++;
           mUsedRam+=sizeof(  Container );
          #endif
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor. Also allocates a given number of entries.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      53  Container::Container(  udword size,   float growth_factor ) : mMaxNbEntries(  0 ),   mCurNbEntries(  0 ),   mEntries(  null ),   mGrowthFactor(  growth_factor )
          {
          #ifdef CONTAINER_STATS
           mNbContainers++;
           mUsedRam+=sizeof(  Container );
          #endif
           SetSize(  size );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Copy constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      67  Container::Container(  const Container& object ) : mMaxNbEntries(  0 ),   mCurNbEntries(  0 ),   mEntries(  null ),   mGrowthFactor(  2.0f )
          {
          #ifdef CONTAINER_STATS
           mNbContainers++;
           mUsedRam+=sizeof(  Container );
          #endif
           *this = object;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor. Frees everything and leaves.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      81  Container::~Container(   )
          {
           Empty(   );
          #ifdef CONTAINER_STATS
           mNbContainers--;
           mUsedRam-=GetUsedRam(   );
          #endif
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Clears the container. All stored values are deleted,   and it frees used ram.
           * \see Reset(   )
           * \return Self-Reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      97  Container& Container::Empty(   )
          {
          #ifdef CONTAINER_STATS
           mUsedRam-=mMaxNbEntries*sizeof(  udword );
          #endif
           DELETEARRAY(  mEntries );
           mCurNbEntries = mMaxNbEntries = 0;
           return *this;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Resizes the container.
           * \param needed [in] assume the container can be added at least "needed" values
           * \return true if success.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     114  bool Container::Resize(  udword needed )
          {
          #ifdef CONTAINER_STATS
           // Subtract previous amount of bytes
           mUsedRam-=mMaxNbEntries*sizeof(  udword );
          #endif
          
           // Get more entries
           mMaxNbEntries = mMaxNbEntries ? udword(  float(  mMaxNbEntries )*mGrowthFactor ) : 2; // Default nb Entries = 2
           if(  mMaxNbEntries<mCurNbEntries + needed ) mMaxNbEntries = mCurNbEntries + needed;
          
           // Get some bytes for new entries
           udword* NewEntries = new udword[mMaxNbEntries];
           CHECKALLOC(  NewEntries );
          
          #ifdef CONTAINER_STATS
           // Add current amount of bytes
           mUsedRam+=mMaxNbEntries*sizeof(  udword );
          #endif
          
           // Copy old data if needed
           if(  mCurNbEntries ) CopyMemory(  NewEntries,   mEntries,   mCurNbEntries*sizeof(  udword ) );
          
           // Delete old data
           DELETEARRAY(  mEntries );
          
           // Assign new pointer
           mEntries = NewEntries;
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Sets the initial size of the container. If it already contains something,   it's discarded.
           * \param nb [in] Number of entries
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     153  bool Container::SetSize(  udword nb )
          {
           // Make sure it's empty
           Empty(   );
          
           // Checkings
           if(  !nb ) return false;
          
           // Initialize for nb entries
           mMaxNbEntries = nb;
          
           // Get some bytes for new entries
           mEntries = new udword[mMaxNbEntries];
           CHECKALLOC(  mEntries );
          
          #ifdef CONTAINER_STATS
           // Add current amount of bytes
           mUsedRam+=mMaxNbEntries*sizeof(  udword );
          #endif
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the container and get rid of unused bytes.
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     181  bool Container::Refit(   )
          {
          #ifdef CONTAINER_STATS
           // Subtract previous amount of bytes
           mUsedRam-=mMaxNbEntries*sizeof(  udword );
          #endif
          
           // Get just enough entries
           mMaxNbEntries = mCurNbEntries;
           if(  !mMaxNbEntries ) return false;
          
           // Get just enough bytes
           udword* NewEntries = new udword[mMaxNbEntries];
           CHECKALLOC(  NewEntries );
          
          #ifdef CONTAINER_STATS
           // Add current amount of bytes
           mUsedRam+=mMaxNbEntries*sizeof(  udword );
          #endif
          
           // Copy old data
           CopyMemory(  NewEntries,   mEntries,   mCurNbEntries*sizeof(  udword ) );
          
           // Delete old data
           DELETEARRAY(  mEntries );
          
           // Assign new pointer
           mEntries = NewEntries;
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks whether the container already contains a given value.
           * \param entry [in] the value to look for in the container
           * \param location [out] a possible pointer to store the entry location
           * \see Add(  udword entry )
           * \see Add(  float entry )
           * \see Empty(   )
           * \return true if the value has been found in the container,   else false.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     224  bool Container::Contains(  udword entry,   udword* location ) const
          {
           // Look for the entry
           for(  udword i=0;i<mCurNbEntries;i++ )
           {
           if(  mEntries[i]==entry )
           {
           if(  location ) *location = i;
           return true;
           }
           }
           return false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Deletes an entry. If the container contains such an entry,   it's removed.
           * \param entry [in] the value to delete.
           * \return true if the value has been found in the container,   else false.
           * \warning This method is arbitrary slow (  O(  n ) ) and should be used carefully. Insertion order is not preserved.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     246  bool Container::Delete(  udword entry )
          {
           // Look for the entry
           for(  udword i=0;i<mCurNbEntries;i++ )
           {
           if(  mEntries[i]==entry )
           {
           // Entry has been found at index i. The strategy is to copy the last current entry at index i,   and decrement the current number of entries.
           DeleteIndex(  i );
           return true;
           }
           }
           return false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Deletes an entry,   preserving the insertion order. If the container contains such an entry,   it's removed.
           * \param entry [in] the value to delete.
           * \return true if the value has been found in the container,   else false.
           * \warning This method is arbitrary slow (  O(  n ) ) and should be used carefully.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     269  bool Container::DeleteKeepingOrder(  udword entry )
          {
           // Look for the entry
           for(  udword i=0;i<mCurNbEntries;i++ )
           {
           if(  mEntries[i]==entry )
           {
           // Entry has been found at index i.
           // Shift entries to preserve order. You really should use a linked list instead.
           mCurNbEntries--;
           for(  udword j=i;j<mCurNbEntries;j++ )
           {
           mEntries[j] = mEntries[j+1];
           }
           return true;
           }
           }
           return false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Gets the next entry,   starting from input one.
           * \param entry [in/out] On input,   the entry to look for. On output,   the next entry
           * \param find_mode [in] wrap/clamp
           * \return Self-Reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     297  Container& Container::FindNext(  udword& entry,   FindMode find_mode )
          {
           udword Location;
           if(  Contains(  entry,   &Location ) )
           {
           Location++;
           if(  Location==mCurNbEntries ) Location = find_mode==FIND_WRAP ? 0 : mCurNbEntries-1;
           entry = mEntries[Location];
           }
           return *this;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Gets the previous entry,   starting from input one.
           * \param entry [in/out] On input,   the entry to look for. On output,   the previous entry
           * \param find_mode [in] wrap/clamp
           * \return Self-Reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     317  Container& Container::FindPrev(  udword& entry,   FindMode find_mode )
          {
           udword Location;
           if(  Contains(  entry,   &Location ) )
           {
           Location--;
           if(  Location==0xffffffff ) Location = find_mode==FIND_WRAP ? mCurNbEntries-1 : 0;
           entry = mEntries[Location];
           }
           return *this;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Gets the ram used by the container.
           * \return the ram used in bytes.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     335  udword Container::GetUsedRam(   ) const
          {
           return sizeof(  Container ) + mMaxNbEntries * sizeof(  udword );
          }
          
     340  void Container::operator=(  const Container& object )
          {
           SetSize(  object.GetNbEntries(   ) );
           CopyMemory(  mEntries,   object.GetEntries(   ),   mMaxNbEntries*sizeof(  udword ) );
           mCurNbEntries = mMaxNbEntries;
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IceHPoint.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for homogeneous points.
           * \file IceHPoint.cpp
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Homogeneous point.
           *
           * Use it:
           * - for clipping in homogeneous space (  standard way )
           * - to differentiate between points (  w=1 ) and vectors (  w=0 ).
           * - in some cases you can also use it instead of Point for padding reasons.
           *
           * \class HPoint
           * \author Pierre Terdiman
           * \version 1.0
           * \warning No cross-product in 4D.
           * \warning HPoint *= Matrix3x3 doesn't exist,   the matrix is first casted to a 4x4
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Point Mul = HPoint * Matrix3x3;
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      36  Point HPoint::operator*(  const Matrix3x3& mat ) const
          {
           return Point(  
           x * mat.m[0][0] + y * mat.m[1][0] + z * mat.m[2][0],  
           x * mat.m[0][1] + y * mat.m[1][1] + z * mat.m[2][1],  
           x * mat.m[0][2] + y * mat.m[1][2] + z * mat.m[2][2]  );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // HPoint Mul = HPoint * Matrix4x4;
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      47  HPoint HPoint::operator*(  const Matrix4x4& mat ) const
          {
           return HPoint(  
           x * mat.m[0][0] + y * mat.m[1][0] + z * mat.m[2][0] + w * mat.m[3][0],  
           x * mat.m[0][1] + y * mat.m[1][1] + z * mat.m[2][1] + w * mat.m[3][1],  
           x * mat.m[0][2] + y * mat.m[1][2] + z * mat.m[2][2] + w * mat.m[3][2],  
           x * mat.m[0][3] + y * mat.m[1][3] + z * mat.m[2][3] + w * mat.m[3][3] );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // HPoint *= Matrix4x4
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      59  HPoint& HPoint::operator*=(  const Matrix4x4& mat )
          {
           float xp = x * mat.m[0][0] + y * mat.m[1][0] + z * mat.m[2][0] + w * mat.m[3][0];
           float yp = x * mat.m[0][1] + y * mat.m[1][1] + z * mat.m[2][1] + w * mat.m[3][1];
           float zp = x * mat.m[0][2] + y * mat.m[1][2] + z * mat.m[2][2] + w * mat.m[3][2];
           float wp = x * mat.m[0][3] + y * mat.m[1][3] + z * mat.m[2][3] + w * mat.m[3][3];
          
           x = xp; y = yp; z = zp; w = wp;
          
           return *this;
          }
          

./components/ogre/ogreopcode/src/Opcode/Ice/IceIndexedTriangle.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a handy indexed triangle class.
           * \file IceIndexedTriangle.cpp
           * \author Pierre Terdiman
           * \date January,   17,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains an indexed triangle class.
           *
           * \class Triangle
           * \author Pierre Terdiman
           * \version 1.0
           * \date 08.15.98
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Flips the winding order.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      32  void IndexedTriangle::Flip(   )
          {
           Swap(  mVRef[1],   mVRef[2] );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle area.
           * \param verts [in] the list of indexed vertices
           * \return the area
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      44  float IndexedTriangle::Area(  const Point* verts ) const
          {
           if(  !verts ) return 0.0f;
           const Point& p0 = verts[0];
           const Point& p1 = verts[1];
           const Point& p2 = verts[2];
           return (  (  p0-p1 )^(  p0-p2 ) ).Magnitude(   ) * 0.5f;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle perimeter.
           * \param verts [in] the list of indexed vertices
           * \return the perimeter
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      60  float IndexedTriangle::Perimeter(  const Point* verts ) const
          {
           if(  !verts ) return 0.0f;
           const Point& p0 = verts[0];
           const Point& p1 = verts[1];
           const Point& p2 = verts[2];
           return p0.Distance(  p1 )
           + p0.Distance(  p2 )
           + p1.Distance(  p2 );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle compacity.
           * \param verts [in] the list of indexed vertices
           * \return the compacity
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      78  float IndexedTriangle::Compacity(  const Point* verts ) const
          {
           if(  !verts ) return 0.0f;
           float P = Perimeter(  verts );
           if(  P==0.0f ) return 0.0f;
           return (  4.0f*PI*Area(  verts )/(  P*P ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle normal.
           * \param verts [in] the list of indexed vertices
           * \param normal [out] the computed normal
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      93  void IndexedTriangle::Normal(  const Point* verts,   Point& normal ) const
          {
           if(  !verts ) return;
          
           const Point& p0 = verts[mVRef[0]];
           const Point& p1 = verts[mVRef[1]];
           const Point& p2 = verts[mVRef[2]];
           normal = (  (  p2-p1 )^(  p0-p1 ) ).Normalize(   );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle denormalized normal.
           * \param verts [in] the list of indexed vertices
           * \param normal [out] the computed normal
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     110  void IndexedTriangle::DenormalizedNormal(  const Point* verts,   Point& normal ) const
          {
           if(  !verts ) return;
          
           const Point& p0 = verts[mVRef[0]];
           const Point& p1 = verts[mVRef[1]];
           const Point& p2 = verts[mVRef[2]];
           normal = (  (  p2-p1 )^(  p0-p1 ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle center.
           * \param verts [in] the list of indexed vertices
           * \param center [out] the computed center
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     127  void IndexedTriangle::Center(  const Point* verts,   Point& center ) const
          {
           if(  !verts ) return;
          
           const Point& p0 = verts[mVRef[0]];
           const Point& p1 = verts[mVRef[1]];
           const Point& p2 = verts[mVRef[2]];
           center = (  p0+p1+p2 )*INV3;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the centered normal
           * \param verts [in] the list of indexed vertices
           * \param normal [out] the computed centered normal
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     144  void IndexedTriangle::CenteredNormal(  const Point* verts,   Point& normal ) const
          {
           if(  !verts ) return;
          
           const Point& p0 = verts[mVRef[0]];
           const Point& p1 = verts[mVRef[1]];
           const Point& p2 = verts[mVRef[2]];
           Point Center = (  p0+p1+p2 )*INV3;
           normal = Center + (  (  p2-p1 )^(  p0-p1 ) ).Normalize(   );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes a random point within the triangle.
           * \param verts [in] the list of indexed vertices
           * \param normal [out] the computed centered normal
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     162  void IndexedTriangle::RandomPoint(  const Point* verts,   Point& random ) const
          {
           if(  !verts ) return;
          
           // Random barycentric coords
           float Alpha = UnitRandomFloat(   );
           float Beta = UnitRandomFloat(   );
           float Gamma = UnitRandomFloat(   );
           float OneOverTotal = 1.0f / (  Alpha + Beta + Gamma );
           Alpha *= OneOverTotal;
           Beta *= OneOverTotal;
           Gamma *= OneOverTotal;
          
           const Point& p0 = verts[mVRef[0]];
           const Point& p1 = verts[mVRef[1]];
           const Point& p2 = verts[mVRef[2]];
           random = Alpha*p0 + Beta*p1 + Gamma*p2;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes backface culling.
           * \param verts [in] the list of indexed vertices
           * \param source [in] source point (  in local space ) from which culling must be computed
           * \return true if the triangle is visible from the source point
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     189  bool IndexedTriangle::IsVisible(  const Point* verts,   const Point& source ) const
          {
           // Checkings
           if(  !verts ) return false;
          
           const Point& p0 = verts[mVRef[0]];
           const Point& p1 = verts[mVRef[1]];
           const Point& p2 = verts[mVRef[2]];
          
           // Compute denormalized normal
           Point Normal = (  p2 - p1 )^(  p0 - p1 );
          
           // Backface culling
           return (  Normal | source ) >= 0.0f;
          
          // Same as:
          // Plane PL(  verts[mVRef[0]],   verts[mVRef[1]],   verts[mVRef[2]] );
          // return PL.Distance(  source ) > PL.d;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes backface culling.
           * \param verts [in] the list of indexed vertices
           * \param source [in] source point (  in local space ) from which culling must be computed
           * \return true if the triangle is visible from the source point
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     217  bool IndexedTriangle::BackfaceCulling(  const Point* verts,   const Point& source ) const
          {
           // Checkings
           if(  !verts ) return false;
          
           const Point& p0 = verts[mVRef[0]];
           const Point& p1 = verts[mVRef[1]];
           const Point& p2 = verts[mVRef[2]];
          
           // Compute base
          // Point Base = (  p0 + p1 + p2 )*INV3;
          
           // Compute denormalized normal
           Point Normal = (  p2 - p1 )^(  p0 - p1 );
          
           // Backface culling
          // return (  Normal | (  source - Base ) ) >= 0.0f;
           return (  Normal | (  source - p0 ) ) >= 0.0f;
          
          // Same as: (  but a bit faster )
          // Plane PL(  verts[mVRef[0]],   verts[mVRef[1]],   verts[mVRef[2]] );
          // return PL.Distance(  source )>0.0f;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the occlusion potential of the triangle.
           * \param verts [in] the list of indexed vertices
           * \param source [in] source point (  in local space ) from which occlusion potential must be computed
           * \return the occlusion potential
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     249  float IndexedTriangle::ComputeOcclusionPotential(  const Point* verts,   const Point& view ) const
          {
           if(  !verts ) return 0.0f;
           // Occlusion potential: -(  A * (  N|V ) / d^2 )
           // A = polygon area
           // N = polygon normal
           // V = view vector
           // d = distance viewpoint-center of polygon
          
           float A = Area(  verts );
           Point N; Normal(  verts,   N );
           Point C; Center(  verts,   C );
           float d = view.Distance(  C );
           return -(  A*(  N|view ) )/(  d*d );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Replaces a vertex reference with another one.
           * \param oldref [in] the vertex reference to replace
           * \param newref [in] the new vertex reference
           * \return true if success,   else false if the input vertex reference doesn't belong to the triangle
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     273  bool IndexedTriangle::ReplaceVertex(  udword oldref,   udword newref )
          {
           if(  mVRef[0]==oldref ) { mVRef[0] = newref; return true; }
           else if(  mVRef[1]==oldref ) { mVRef[1] = newref; return true; }
           else if(  mVRef[2]==oldref ) { mVRef[2] = newref; return true; }
           return false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks whether the triangle is degenerate or not. A degenerate triangle has two common vertex references. This is a zero-area triangle.
           * \return true if the triangle is degenerate
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     287  bool IndexedTriangle::IsDegenerate(   ) const
          {
           if(  mVRef[0]==mVRef[1] ) return true;
           if(  mVRef[1]==mVRef[2] ) return true;
           if(  mVRef[2]==mVRef[0] ) return true;
           return false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks whether the input vertex reference belongs to the triangle or not.
           * \param ref [in] the vertex reference to look for
           * \return true if the triangle contains the vertex reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     302  bool IndexedTriangle::HasVertex(  udword ref ) const
          {
           if(  mVRef[0]==ref ) return true;
           if(  mVRef[1]==ref ) return true;
           if(  mVRef[2]==ref ) return true;
           return false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks whether the input vertex reference belongs to the triangle or not.
           * \param ref [in] the vertex reference to look for
           * \param index [out] the corresponding index in the triangle
           * \return true if the triangle contains the vertex reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     318  bool IndexedTriangle::HasVertex(  udword ref,   udword* index ) const
          {
           if(  mVRef[0]==ref ) { *index = 0; return true; }
           if(  mVRef[1]==ref ) { *index = 1; return true; }
           if(  mVRef[2]==ref ) { *index = 2; return true; }
           return false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Finds an edge in a tri,   given two vertex references.
           * \param vref0 [in] the edge's first vertex reference
           * \param vref1 [in] the edge's second vertex reference
           * \return the edge number between 0 and 2,   or 0xff if input refs are wrong.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     334  ubyte IndexedTriangle::FindEdge(  udword vref0,   udword vref1 ) const
          {
           if(  mVRef[0]==vref0 && mVRef[1]==vref1 ) return 0;
           else if(  mVRef[0]==vref1 && mVRef[1]==vref0 ) return 0;
           else if(  mVRef[0]==vref0 && mVRef[2]==vref1 ) return 1;
           else if(  mVRef[0]==vref1 && mVRef[2]==vref0 ) return 1;
           else if(  mVRef[1]==vref0 && mVRef[2]==vref1 ) return 2;
           else if(  mVRef[1]==vref1 && mVRef[2]==vref0 ) return 2;
           return 0xff;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Gets the last reference given the first two.
           * \param vref0 [in] the first vertex reference
           * \param vref1 [in] the second vertex reference
           * \return the last reference,   or INVALID_ID if input refs are wrong.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     353  udword IndexedTriangle::OppositeVertex(  udword vref0,   udword vref1 ) const
          {
           if(  mVRef[0]==vref0 && mVRef[1]==vref1 ) return mVRef[2];
           else if(  mVRef[0]==vref1 && mVRef[1]==vref0 ) return mVRef[2];
           else if(  mVRef[0]==vref0 && mVRef[2]==vref1 ) return mVRef[1];
           else if(  mVRef[0]==vref1 && mVRef[2]==vref0 ) return mVRef[1];
           else if(  mVRef[1]==vref0 && mVRef[2]==vref1 ) return mVRef[0];
           else if(  mVRef[1]==vref1 && mVRef[2]==vref0 ) return mVRef[0];
           return INVALID_ID;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Gets the three sorted vertex references according to an edge number.
           * edgenb = 0 => edge 0-1,   returns references 0,   1,   2
           * edgenb = 1 => edge 0-2,   returns references 0,   2,   1
           * edgenb = 2 => edge 1-2,   returns references 1,   2,   0
           *
           * \param edgenb [in] the edge number,   0,   1 or 2
           * \param vref0 [out] the returned first vertex reference
           * \param vref1 [out] the returned second vertex reference
           * \param vref2 [out] the returned third vertex reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     377  void IndexedTriangle::GetVRefs(  ubyte edgenb,   udword& vref0,   udword& vref1,   udword& vref2 ) const
          {
           if(  edgenb==0 )
           {
           vref0 = mVRef[0];
           vref1 = mVRef[1];
           vref2 = mVRef[2];
           }
           else if(  edgenb==1 )
           {
           vref0 = mVRef[0];
           vref1 = mVRef[2];
           vref2 = mVRef[1];
           }
           else if(  edgenb==2 )
           {
           vref0 = mVRef[1];
           vref1 = mVRef[2];
           vref2 = mVRef[0];
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle's smallest edge length.
           * \param verts [in] the list of indexed vertices
           * \return the smallest edge length
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     406  float IndexedTriangle::MinEdgeLength(  const Point* verts ) const
          {
           if(  !verts ) return 0.0f;
          
           float Min = MAX_FLOAT;
           float Length01 = verts[0].Distance(  verts[1] );
           float Length02 = verts[0].Distance(  verts[2] );
           float Length12 = verts[1].Distance(  verts[2] );
           if(  Length01 < Min ) Min = Length01;
           if(  Length02 < Min ) Min = Length02;
           if(  Length12 < Min ) Min = Length12;
           return Min;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle's largest edge length.
           * \param verts [in] the list of indexed vertices
           * \return the largest edge length
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     427  float IndexedTriangle::MaxEdgeLength(  const Point* verts ) const
          {
           if(  !verts ) return 0.0f;
          
           float Max = MIN_FLOAT;
           float Length01 = verts[0].Distance(  verts[1] );
           float Length02 = verts[0].Distance(  verts[2] );
           float Length12 = verts[1].Distance(  verts[2] );
           if(  Length01 > Max ) Max = Length01;
           if(  Length02 > Max ) Max = Length02;
           if(  Length12 > Max ) Max = Length12;
           return Max;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes a point on the triangle according to the stabbing information.
           * \param verts [in] the list of indexed vertices
           * \param u,  v [in] point's barycentric coordinates
           * \param pt [out] point on triangle
           * \param nearvtx [out] index of nearest vertex
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     450  void IndexedTriangle::ComputePoint(  const Point* verts,   float u,   float v,   Point& pt,   udword* nearvtx ) const
          {
           // Checkings
           if(  !verts ) return;
          
           // Get face in local or global space
           const Point& p0 = verts[mVRef[0]];
           const Point& p1 = verts[mVRef[1]];
           const Point& p2 = verts[mVRef[2]];
          
           // Compute point coordinates
           pt = (  1.0f - u - v )*p0 + u*p1 + v*p2;
          
           // Compute nearest vertex if needed
           if(  nearvtx )
           {
           // Compute distance vector
           Point d(  p0.SquareDistance(  pt ),   // Distance^2 from vertex 0 to point on the face
           p1.SquareDistance(  pt ),   // Distance^2 from vertex 1 to point on the face
           p2.SquareDistance(  pt ) ); // Distance^2 from vertex 2 to point on the face
          
           // Get smallest distance
           *nearvtx = mVRef[d.SmallestAxis(   )];
           }
          }
          
           //**************************************
           // Angle between two vectors (  in radians )
           // we use this formula
           // uv = |u||v| cos(  u,  v )
           // u ^ v = w
           // |w| = |u||v| |sin(  u,  v )|
           //**************************************
     483   float Angle(  const Point& u,   const Point& v )
           {
           float NormU = u.Magnitude(   ); // |u|
           float NormV = v.Magnitude(   ); // |v|
           float Product = NormU*NormV; // |u||v|
           if(  Product==0.0f ) return 0.0f;
           float OneOverProduct = 1.0f / Product;
          
           // Cosinus
           float Cosinus = (  u|v ) * OneOverProduct;
          
           // Sinus
           Point w = u^v;
           float NormW = w.Magnitude(   );
          
           float AbsSinus = NormW * OneOverProduct;
          
           // Remove degeneracy
           if(  AbsSinus > 1.0f ) AbsSinus = 1.0f;
           if(  AbsSinus < -1.0f ) AbsSinus = -1.0f;
          
           if(  Cosinus>=0.0f ) return asinf(  AbsSinus );
           else return (  PI-asinf(  AbsSinus ) );
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the angle between two triangles.
           * \param tri [in] the other triangle
           * \param verts [in] the list of indexed vertices
           * \return the angle in radians
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     516  float IndexedTriangle::Angle(  const IndexedTriangle& tri,   const Point* verts ) const
          {
           // Checkings
           if(  !verts ) return 0.0f;
          
           // Compute face normals
           Point n0,   n1;
           Normal(  verts,   n0 );
           tri.Normal(  verts,   n1 );
          
           // Compute angle
           float dp = n0|n1;
           if(  dp>1.0f ) return 0.0f;
           if(  dp<-1.0f ) return PI;
           return acosf(  dp );
          
          // return ::Angle(  n0,  n1 );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks a triangle is the same as another one.
           * \param tri [in] the other triangle
           * \return true if same triangle
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     542  bool IndexedTriangle::Equal(  const IndexedTriangle& tri ) const
          {
           // Test all vertex references
           return (  HasVertex(  tri.mVRef[0] ) &&
           HasVertex(  tri.mVRef[1] ) &&
           HasVertex(  tri.mVRef[2] ) );
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IceMatrix3x3.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for 3x3 matrices.
           * \file IceMatrix3x3.cpp
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * 3x3 matrix.
           * DirectX-compliant,   ie row-column order,   ie m[Row][Col].
           * Same as:
           * m11 m12 m13 first row.
           * m21 m22 m23 second row.
           * m31 m32 m33 third row.
           * Stored in memory as m11 m12 m13 m21...
           *
           * Multiplication rules:
           *
           * [x'y'z'] = [xyz][M]
           *
           * x' = x*m11 + y*m21 + z*m31
           * y' = x*m12 + y*m22 + z*m32
           * z' = x*m13 + y*m23 + z*m33
           *
           * \class Matrix3x3
           * \author Pierre Terdiman
           * \version 1.0
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
          // Cast operator
      41  Matrix3x3::operator Matrix4x4(   ) const
          {
           return Matrix4x4(  
           m[0][0],   m[0][1],   m[0][2],   0.0f,  
           m[1][0],   m[1][1],   m[1][2],   0.0f,  
           m[2][0],   m[2][1],   m[2][2],   0.0f,  
           0.0f,   0.0f,   0.0f,   1.0f );
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IceMatrix4x4.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for 4x4 matrices.
           * \file IceMatrix4x4.cpp
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * 4x4 matrix.
           * DirectX-compliant,   ie row-column order,   ie m[Row][Col].
           * Same as:
           * m11 m12 m13 m14 first row.
           * m21 m22 m23 m24 second row.
           * m31 m32 m33 m34 third row.
           * m41 m42 m43 m44 fourth row.
           * Translation is (  m41,   m42,   m43 ),   (  m14,   m24,   m34,   m44 ) = (  0,   0,   0,   1 ).
           * Stored in memory as m11 m12 m13 m14 m21...
           *
           * Multiplication rules:
           *
           * [x'y'z'1] = [xyz1][M]
           *
           * x' = x*m11 + y*m21 + z*m31 + m41
           * y' = x*m12 + y*m22 + z*m32 + m42
           * z' = x*m13 + y*m23 + z*m33 + m43
           * 1' = 0 + 0 + 0 + m44
           *
           * \class Matrix4x4
           * \author Pierre Terdiman
           * \version 1.0
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Inverts a PR matrix. (  which only contains a rotation and a translation )
           * This is faster and less subject to FPU errors than the generic inversion code.
           *
           * \relates Matrix4x4
           * \fn InvertPRMatrix(  Matrix4x4& dest,   const Matrix4x4& src )
           * \param dest [out] destination matrix
           * \param src [in] source matrix
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      54  void IceMaths::InvertPRMatrix(  Matrix4x4& dest,   const Matrix4x4& src )
          {
           dest.m[0][0] = src.m[0][0];
           dest.m[1][0] = src.m[0][1];
           dest.m[2][0] = src.m[0][2];
           dest.m[3][0] = -(  src.m[3][0]*src.m[0][0] + src.m[3][1]*src.m[0][1] + src.m[3][2]*src.m[0][2] );
          
           dest.m[0][1] = src.m[1][0];
           dest.m[1][1] = src.m[1][1];
           dest.m[2][1] = src.m[1][2];
           dest.m[3][1] = -(  src.m[3][0]*src.m[1][0] + src.m[3][1]*src.m[1][1] + src.m[3][2]*src.m[1][2] );
          
           dest.m[0][2] = src.m[2][0];
           dest.m[1][2] = src.m[2][1];
           dest.m[2][2] = src.m[2][2];
           dest.m[3][2] = -(  src.m[3][0]*src.m[2][0] + src.m[3][1]*src.m[2][1] + src.m[3][2]*src.m[2][2] );
          
           dest.m[0][3] = 0.0f;
           dest.m[1][3] = 0.0f;
           dest.m[2][3] = 0.0f;
           dest.m[3][3] = 1.0f;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Inverts a PRS matrix. (  which only contains a scale,   a rotation and a translation,   in this order )
           * This is faster and less subject to FPU errors than the generic inversion code.
           *
           * \relates Matrix4x4
           * \fn InvertPRSMatrix(  Matrix4x4& dest,   const Matrix4x4& src )
           * \param dest [out] destination matrix
           * \param src [in] source matrix
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      88  void IceMaths::InvertPRSMatrix(  Matrix4x4& dest,   const Matrix4x4& src )
          {
           // first,   inverts the rotation part.
           float invS2 = 1.0f/(  src.m[0][0]*src.m[0][0] + src.m[0][1]*src.m[0][1] + src.m[0][2]*src.m[0][2] );
           dest.m[0][0] = invS2*src.m[0][0];
           dest.m[1][0] = invS2*src.m[0][1];
           dest.m[2][0] = invS2*src.m[0][2];
          
           invS2 = 1.0f/(  src.m[1][0]*src.m[1][0] + src.m[1][1]*src.m[1][1] + src.m[1][2]*src.m[1][2] );
           dest.m[0][1] = invS2*src.m[1][0];
           dest.m[1][1] = invS2*src.m[1][1];
           dest.m[2][1] = invS2*src.m[1][2];
          
           invS2 = 1.0f/(  src.m[2][0]*src.m[2][0] + src.m[2][1]*src.m[2][1] + src.m[2][2]*src.m[2][2] );
           dest.m[0][2] = invS2*src.m[2][0];
           dest.m[1][2] = invS2*src.m[2][1];
           dest.m[2][2] = invS2*src.m[2][2];
          
           // then,   inverts the translation part
           dest.m[3][0] = -(  dest[0][0]*src.m[3][0] + dest[1][0]*src.m[3][1] + dest[2][0]*src.m[3][2] );
           dest.m[3][1] = -(  dest[0][1]*src.m[3][0] + dest[1][1]*src.m[3][1] + dest[2][1]*src.m[3][2] );
           dest.m[3][2] = -(  dest[0][2]*src.m[3][0] + dest[1][2]*src.m[3][1] + dest[2][2]*src.m[3][2] );
          
          
           // fills last column
           dest.m[0][3] = dest.m[1][3] = dest.m[2][3] = 0.0;
           dest.m[3][3] = 1.0;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Normalizes a PRS matrix. (  which only contains a scale,   a rotation and a translation )
           * This is faster and less subject to FPU errors than the generic inversion code.
           *
           * \relates Matrix4x4
           * \fn NormalizePRSMatrix(  Matrix4x4& dest,   Point scale,   const Matrix4x4& src )
           * \param dest [out] destination matrix
           * \param scale [out] destination point for scale part
           * \param src [in] source matrix
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     129  void IceMaths::NormalizePRSMatrix(  Matrix4x4& dest,   Point& scale,   const Matrix4x4& src )
          {
           Point row;
           dest = src;
           for(   int i=0;i<3;i++ )
           {
           src.GetRow(  i,  row );
          
           // computes scales
          
           scale[i] = row.Magnitude(   );
          
           row /= scale[i];
          
           dest.SetRow(  i,  row );
           }
          }
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Compute the cofactor of the Matrix at a specified location
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     149  float Matrix4x4::CoFactor(  udword row,   udword col ) const
          {
           return (  (   m[(  row+1 )&3][(  col+1 )&3]*m[(  row+2 )&3][(  col+2 )&3]*m[(  row+3 )&3][(  col+3 )&3] +
           m[(  row+1 )&3][(  col+2 )&3]*m[(  row+2 )&3][(  col+3 )&3]*m[(  row+3 )&3][(  col+1 )&3] +
           m[(  row+1 )&3][(  col+3 )&3]*m[(  row+2 )&3][(  col+1 )&3]*m[(  row+3 )&3][(  col+2 )&3] )
           - (  m[(  row+3 )&3][(  col+1 )&3]*m[(  row+2 )&3][(  col+2 )&3]*m[(  row+1 )&3][(  col+3 )&3] +
           m[(  row+3 )&3][(  col+2 )&3]*m[(  row+2 )&3][(  col+3 )&3]*m[(  row+1 )&3][(  col+1 )&3] +
           m[(  row+3 )&3][(  col+3 )&3]*m[(  row+2 )&3][(  col+1 )&3]*m[(  row+1 )&3][(  col+2 )&3] ) ) * (  (  row + col ) & 1 ? -1.0f : +1.0f );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Compute the determinant of the Matrix
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     162  float Matrix4x4::Determinant(   ) const
          {
           return m[0][0] * CoFactor(  0,   0 ) +
           m[0][1] * CoFactor(  0,   1 ) +
           m[0][2] * CoFactor(  0,   2 ) +
           m[0][3] * CoFactor(  0,   3 );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Compute the inverse of the matrix
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     173  Matrix4x4& Matrix4x4::Invert(   )
          {
           float Det = Determinant(   );
           Matrix4x4 Temp;
          
           if(  fabsf(  Det ) < MATRIX4X4_EPSILON )
           return *this; // The matrix is not invertible! Singular case!
          
           float IDet = 1.0f / Det;
          
           Temp.m[0][0] = CoFactor(  0,  0 ) * IDet;
           Temp.m[1][0] = CoFactor(  0,  1 ) * IDet;
           Temp.m[2][0] = CoFactor(  0,  2 ) * IDet;
           Temp.m[3][0] = CoFactor(  0,  3 ) * IDet;
           Temp.m[0][1] = CoFactor(  1,  0 ) * IDet;
           Temp.m[1][1] = CoFactor(  1,  1 ) * IDet;
           Temp.m[2][1] = CoFactor(  1,  2 ) * IDet;
           Temp.m[3][1] = CoFactor(  1,  3 ) * IDet;
           Temp.m[0][2] = CoFactor(  2,  0 ) * IDet;
           Temp.m[1][2] = CoFactor(  2,  1 ) * IDet;
           Temp.m[2][2] = CoFactor(  2,  2 ) * IDet;
           Temp.m[3][2] = CoFactor(  2,  3 ) * IDet;
           Temp.m[0][3] = CoFactor(  3,  0 ) * IDet;
           Temp.m[1][3] = CoFactor(  3,  1 ) * IDet;
           Temp.m[2][3] = CoFactor(  3,  2 ) * IDet;
           Temp.m[3][3] = CoFactor(  3,  3 ) * IDet;
          
           *this = Temp;
          
           return *this;
          }
          

./components/ogre/ogreopcode/src/Opcode/Ice/IceOBB.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains OBB-related code.
           * \file IceOBB.cpp
           * \author Pierre Terdiman
           * \date January,   29,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * An Oriented Bounding Box (  OBB ).
           * \class OBB
           * \author Pierre Terdiman
           * \version 1.0
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Tests if a point is contained within the OBB.
           * \param p [in] the world point to test
           * \return true if inside the OBB
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      32  bool OBB::ContainsPoint(  const Point& p ) const
          {
           // Point in OBB test using lazy evaluation and early exits
          
           // Translate to box space
           Point RelPoint = p - mCenter;
          
           // Point * mRot maps from box space to world space
           // mRot * Point maps from world space to box space (  what we need here )
          
           float f = mRot.m[0][0] * RelPoint.x + mRot.m[0][1] * RelPoint.y + mRot.m[0][2] * RelPoint.z;
           if(  f >= mExtents.x || f <= -mExtents.x ) return false;
          
           f = mRot.m[1][0] * RelPoint.x + mRot.m[1][1] * RelPoint.y + mRot.m[1][2] * RelPoint.z;
           if(  f >= mExtents.y || f <= -mExtents.y ) return false;
          
           f = mRot.m[2][0] * RelPoint.x + mRot.m[2][1] * RelPoint.y + mRot.m[2][2] * RelPoint.z;
           if(  f >= mExtents.z || f <= -mExtents.z ) return false;
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds an OBB from an AABB and a world transform.
           * \param aabb [in] the aabb
           * \param mat [in] the world transform
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      60  void OBB::Create(  const AABB& aabb,   const Matrix4x4& mat )
          {
           // Note: must be coherent with Rotate(   )
          
           aabb.GetCenter(  mCenter );
           aabb.GetExtents(  mExtents );
           // Here we have the same as OBB::Rotate(  mat ) where the obb is (  mCenter,   mExtents,   Identity ).
          
           // So following what's done in Rotate:
           // - x-form the center
           mCenter *= mat;
           // - combine rotation with identity,   i.e. just use given matrix
           mRot = mat;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the obb planes.
           * \param planes [out] 6 box planes
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      82  bool OBB::ComputePlanes(  Plane* planes ) const
          {
           // Checkings
           if(  !planes ) return false;
          
           Point Axis0 = mRot[0];
           Point Axis1 = mRot[1];
           Point Axis2 = mRot[2];
          
           // Writes normals
           planes[0].n = Axis0;
           planes[1].n = -Axis0;
           planes[2].n = Axis1;
           planes[3].n = -Axis1;
           planes[4].n = Axis2;
           planes[5].n = -Axis2;
          
           // Compute a point on each plane
           Point p0 = mCenter + Axis0 * mExtents.x;
           Point p1 = mCenter - Axis0 * mExtents.x;
           Point p2 = mCenter + Axis1 * mExtents.y;
           Point p3 = mCenter - Axis1 * mExtents.y;
           Point p4 = mCenter + Axis2 * mExtents.z;
           Point p5 = mCenter - Axis2 * mExtents.z;
          
           // Compute d
           planes[0].d = -(  planes[0].n|p0 );
           planes[1].d = -(  planes[1].n|p1 );
           planes[2].d = -(  planes[2].n|p2 );
           planes[3].d = -(  planes[3].n|p3 );
           planes[4].d = -(  planes[4].n|p4 );
           planes[5].d = -(  planes[5].n|p5 );
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the obb points.
           * \param pts [out] 8 box points
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     125  bool OBB::ComputePoints(  Point* pts ) const
          {
           // Checkings
           if(  !pts ) return false;
          
           Point Axis0 = mRot[0];
           Point Axis1 = mRot[1];
           Point Axis2 = mRot[2];
          
           Axis0 *= mExtents.x;
           Axis1 *= mExtents.y;
           Axis2 *= mExtents.z;
          
           // 7+------+6 0 = ---
           // /| /| 1 = +--
           // / | / | 2 = ++-
           // / 4+---/--+5 3 = -+-
           // 3+------+2 / y z 4 = --+
           // | / | / | / 5 = +-+
           // |/ |/ |/ 6 = +++
           // 0+------+1 *---x 7 = -++
          
           pts[0] = mCenter - Axis0 - Axis1 - Axis2;
           pts[1] = mCenter + Axis0 - Axis1 - Axis2;
           pts[2] = mCenter + Axis0 + Axis1 - Axis2;
           pts[3] = mCenter - Axis0 + Axis1 - Axis2;
           pts[4] = mCenter - Axis0 - Axis1 + Axis2;
           pts[5] = mCenter + Axis0 - Axis1 + Axis2;
           pts[6] = mCenter + Axis0 + Axis1 + Axis2;
           pts[7] = mCenter - Axis0 + Axis1 + Axis2;
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes vertex normals.
           * \param pts [out] 8 box points
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     166  bool OBB::ComputeVertexNormals(  Point* pts ) const
          {
           static float VertexNormals[] =
           {
           -INVSQRT3,   -INVSQRT3,   -INVSQRT3,  
           INVSQRT3,   -INVSQRT3,   -INVSQRT3,  
           INVSQRT3,   INVSQRT3,   -INVSQRT3,  
           -INVSQRT3,   INVSQRT3,   -INVSQRT3,  
           -INVSQRT3,   -INVSQRT3,   INVSQRT3,  
           INVSQRT3,   -INVSQRT3,   INVSQRT3,  
           INVSQRT3,   INVSQRT3,   INVSQRT3,  
           -INVSQRT3,   INVSQRT3,   INVSQRT3
           };
          
           if(  !pts ) return false;
          
           const Point* VN = (  const Point* )VertexNormals;
           for(  udword i=0;i<8;i++ )
           {
           pts[i] = VN[i] * mRot;
           }
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Returns edges.
           * \return 24 indices (  12 edges ) indexing the list returned by ComputePoints(   )
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     197  const udword* OBB::GetEdges(   ) const
          {
           static udword Indices[] = {
           0,   1,   1,   2,   2,   3,   3,   0,  
           7,   6,   6,   5,   5,   4,   4,   7,  
           1,   5,   6,   2,  
           3,   7,   4,   0
           };
           return Indices;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Returns local edge normals.
           * \return edge normals in local space
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     214  const Point* OBB::GetLocalEdgeNormals(   ) const
          {
           static float EdgeNormals[] =
           {
           0,   -INVSQRT2,   -INVSQRT2,   // 0-1
           INVSQRT2,   0,   -INVSQRT2,   // 1-2
           0,   INVSQRT2,   -INVSQRT2,   // 2-3
           -INVSQRT2,   0,   -INVSQRT2,   // 3-0
          
           0,   INVSQRT2,   INVSQRT2,   // 7-6
           INVSQRT2,   0,   INVSQRT2,   // 6-5
           0,   -INVSQRT2,   INVSQRT2,   // 5-4
           -INVSQRT2,   0,   INVSQRT2,   // 4-7
          
           INVSQRT2,   -INVSQRT2,   0,   // 1-5
           INVSQRT2,   INVSQRT2,   0,   // 6-2
           -INVSQRT2,   INVSQRT2,   0,   // 3-7
           -INVSQRT2,   -INVSQRT2,   0 // 4-0
           };
           return (  const Point* )EdgeNormals;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Returns world edge normal
           * \param edge_index [in] 0 <= edge index < 12
           * \param world_normal [out] edge normal in world space
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     243  void OBB::ComputeWorldEdgeNormal(  udword edge_index,   Point& world_normal ) const
          {
           ASSERT(  edge_index<12 );
           world_normal = GetLocalEdgeNormals(   )[edge_index] * mRot;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes an LSS surrounding the OBB.
           * \param lss [out] the LSS
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     255  void OBB::ComputeLSS(  LSS& lss ) const
          {
           Point Axis0 = mRot[0];
           Point Axis1 = mRot[1];
           Point Axis2 = mRot[2];
          
           switch(  mExtents.LargestAxis(   ) )
           {
           case 0:
           lss.mRadius = (  mExtents.y + mExtents.z )*0.5f;
           lss.mP0 = mCenter + Axis0 * (  mExtents.x - lss.mRadius );
           lss.mP1 = mCenter - Axis0 * (  mExtents.x - lss.mRadius );
           break;
           case 1:
           lss.mRadius = (  mExtents.x + mExtents.z )*0.5f;
           lss.mP0 = mCenter + Axis1 * (  mExtents.y - lss.mRadius );
           lss.mP1 = mCenter - Axis1 * (  mExtents.y - lss.mRadius );
           break;
           case 2:
           lss.mRadius = (  mExtents.x + mExtents.y )*0.5f;
           lss.mP0 = mCenter + Axis2 * (  mExtents.z - lss.mRadius );
           lss.mP1 = mCenter - Axis2 * (  mExtents.z - lss.mRadius );
           break;
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks the OBB is inside another OBB.
           * \param box [in] the other OBB
           * \return TRUE if we're inside the other box
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     288  BOOL OBB::IsInside(  const OBB& box ) const
          {
           // Make a 4x4 from the box & inverse it
           Matrix4x4 M0Inv;
           {
           Matrix4x4 M0 = box.mRot;
           M0.SetTrans(  box.mCenter );
           InvertPRMatrix(  M0Inv,   M0 );
           }
          
           // With our inversed 4x4,   create box1 in space of box0
           OBB _1in0;
           Rotate(  M0Inv,   _1in0 );
          
           // This should cancel out box0's rotation,   i.e. it's now an AABB.
           // => Center(  0,  0,  0 ),   Rot(  identity )
          
           // The two boxes are in the same space so now we can compare them.
          
           // Create the AABB of (  box1 in space of box0 )
           const Matrix3x3& mtx = _1in0.mRot;
          
           float f = fabsf(  mtx.m[0][0] * mExtents.x ) + fabsf(  mtx.m[1][0] * mExtents.y ) + fabsf(  mtx.m[2][0] * mExtents.z ) - box.mExtents.x;
           if(  f > _1in0.mCenter.x ) return FALSE;
           if(  -f < _1in0.mCenter.x ) return FALSE;
          
           f = fabsf(  mtx.m[0][1] * mExtents.x ) + fabsf(  mtx.m[1][1] * mExtents.y ) + fabsf(  mtx.m[2][1] * mExtents.z ) - box.mExtents.y;
           if(  f > _1in0.mCenter.y ) return FALSE;
           if(  -f < _1in0.mCenter.y ) return FALSE;
          
           f = fabsf(  mtx.m[0][2] * mExtents.x ) + fabsf(  mtx.m[1][2] * mExtents.y ) + fabsf(  mtx.m[2][2] * mExtents.z ) - box.mExtents.z;
           if(  f > _1in0.mCenter.z ) return FALSE;
           if(  -f < _1in0.mCenter.z ) return FALSE;
          
           return TRUE;
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IcePlane.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for planes.
           * \file IcePlane.cpp
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Plane class.
           * \class Plane
           * \author Pierre Terdiman
           * \version 1.0
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the plane equation from 3 points.
           * \param p0 [in] first point
           * \param p1 [in] second point
           * \param p2 [in] third point
           * \return Self-reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      34  Plane& Plane::Set(  const Point& p0,   const Point& p1,   const Point& p2 )
          {
           Point Edge0 = p1 - p0;
           Point Edge1 = p2 - p0;
          
           n = Edge0 ^ Edge1;
           n.Normalize(   );
          
           d = -(  p0 | n );
          
           return *this;
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IcePoint.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for 3D vectors.
           * \file IcePoint.cpp
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * 3D point.
           *
           * The name is "Point" instead of "Vector" since a vector is N-dimensional,   whereas a point is an implicit "vector of dimension 3".
           * So the choice was between "Point" and "Vector3",   the first one looked better (  IMHO ).
           *
           * Some people,   then,   use a typedef to handle both points & vectors using the same class: typedef Point Vector3;
           * This is bad since it opens the door to a lot of confusion while reading the code. I know it may sounds weird but check this out:
           *
           * \code
           * Point P0,  P1 = some 3D points;
           * Point Delta = P1 - P0;
           * \endcode
           *
           * This compiles fine,   although you should have written:
           *
           * \code
           * Point P0,  P1 = some 3D points;
           * Vector3 Delta = P1 - P0;
           * \endcode
           *
           * Subtle things like this are not caught at compile-time,   and when you find one in the code,   you never know whether it's a mistake
           * from the author or something you don't get.
           *
           * One way to handle it at compile-time would be to use different classes for Point & Vector3,   only overloading operator "-" for vectors.
           * But then,   you get a lot of redundant code in thoses classes,   and basically it's really a lot of useless work.
           *
           * Another way would be to use homogeneous points: w=1 for points,   w=0 for vectors. That's why the HPoint class exists. Now,   to store
           * your model's vertices and in most cases,   you really want to use Points to save ram.
           *
           * \class Point
           * \author Pierre Terdiman
           * \version 1.0
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Creates a positive unit random vector.
           * \return Self-reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      59  Point& Point::PositiveUnitRandomVector(   )
          {
           x = UnitRandomFloat(   );
           y = UnitRandomFloat(   );
           z = UnitRandomFloat(   );
           Normalize(   );
           return *this;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Creates a unit random vector.
           * \return Self-reference
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      74  Point& Point::UnitRandomVector(   )
          {
           x = UnitRandomFloat(   ) - 0.5f;
           y = UnitRandomFloat(   ) - 0.5f;
           z = UnitRandomFloat(   ) - 0.5f;
           Normalize(   );
           return *this;
          }
          
          // Cast operator
          // WARNING: not inlined
      85  Point::operator HPoint(   ) const { return HPoint(  x,   y,   z,   0.0f ); }
          
      87  Point& Point::Refract(  const Point& eye,   const Point& n,   float refractindex,   Point& refracted )
          {
           // Point EyePt = eye position
           // Point p = current vertex
           // Point n = vertex normal
           // Point rv = refracted vector
           // Eye vector - doesn't need to be normalized
           Point Env;
           Env.x = eye.x - x;
           Env.y = eye.y - y;
           Env.z = eye.z - z;
          
           float NDotE = n|Env;
           float NDotN = n|n;
           NDotE /= refractindex;
          
           // Refracted vector
           refracted = n*NDotE - Env*NDotN;
          
           return *this;
          }
          
     109  Point& Point::ProjectToPlane(  const Plane& p )
          {
           *this-= (  p.d + (  *this|p.n ) )*p.n;
           return *this;
          }
          
     115  void Point::ProjectToScreen(  float halfrenderwidth,   float halfrenderheight,   const Matrix4x4& mat,   HPoint& projected ) const
          {
           projected = HPoint(  x,   y,   z,   1.0f ) * mat;
           projected.w = 1.0f / projected.w;
          
           projected.x*=projected.w;
           projected.y*=projected.w;
           projected.z*=projected.w;
          
           projected.x *= halfrenderwidth; projected.x += halfrenderwidth;
           projected.y *= -halfrenderheight; projected.y += halfrenderheight;
          }
          
     128  void Point::SetNotUsed(   )
          {
           // We use a particular integer pattern : 0xffffffff everywhere. This is a NAN.
           IR(  x ) = 0xffffffff;
           IR(  y ) = 0xffffffff;
           IR(  z ) = 0xffffffff;
          }
          
     136  BOOL Point::IsNotUsed(   ) const
          {
           if(  IR(  x )!=0xffffffff ) return FALSE;
           if(  IR(  y )!=0xffffffff ) return FALSE;
           if(  IR(  z )!=0xffffffff ) return FALSE;
           return TRUE;
          }
          
     144  Point& Point::Mult(  const Matrix3x3& mat,   const Point& a )
          {
           x = a.x * mat.m[0][0] + a.y * mat.m[0][1] + a.z * mat.m[0][2];
           y = a.x * mat.m[1][0] + a.y * mat.m[1][1] + a.z * mat.m[1][2];
           z = a.x * mat.m[2][0] + a.y * mat.m[2][1] + a.z * mat.m[2][2];
           return *this;
          }
          
     152  Point& Point::Mult2(  const Matrix3x3& mat1,   const Point& a1,   const Matrix3x3& mat2,   const Point& a2 )
          {
           x = a1.x * mat1.m[0][0] + a1.y * mat1.m[0][1] + a1.z * mat1.m[0][2] + a2.x * mat2.m[0][0] + a2.y * mat2.m[0][1] + a2.z * mat2.m[0][2];
           y = a1.x * mat1.m[1][0] + a1.y * mat1.m[1][1] + a1.z * mat1.m[1][2] + a2.x * mat2.m[1][0] + a2.y * mat2.m[1][1] + a2.z * mat2.m[1][2];
           z = a1.x * mat1.m[2][0] + a1.y * mat1.m[2][1] + a1.z * mat1.m[2][2] + a2.x * mat2.m[2][0] + a2.y * mat2.m[2][1] + a2.z * mat2.m[2][2];
           return *this;
          }
          
     160  Point& Point::Mac(  const Matrix3x3& mat,   const Point& a )
          {
           x += a.x * mat.m[0][0] + a.y * mat.m[0][1] + a.z * mat.m[0][2];
           y += a.x * mat.m[1][0] + a.y * mat.m[1][1] + a.z * mat.m[1][2];
           z += a.x * mat.m[2][0] + a.y * mat.m[2][1] + a.z * mat.m[2][2];
           return *this;
          }
          
     168  Point& Point::TransMult(  const Matrix3x3& mat,   const Point& a )
          {
           x = a.x * mat.m[0][0] + a.y * mat.m[1][0] + a.z * mat.m[2][0];
           y = a.x * mat.m[0][1] + a.y * mat.m[1][1] + a.z * mat.m[2][1];
           z = a.x * mat.m[0][2] + a.y * mat.m[1][2] + a.z * mat.m[2][2];
           return *this;
          }
          
     176  Point& Point::Transform(  const Point& r,   const Matrix3x3& rotpos,   const Point& linpos )
          {
           x = r.x * rotpos.m[0][0] + r.y * rotpos.m[0][1] + r.z * rotpos.m[0][2] + linpos.x;
           y = r.x * rotpos.m[1][0] + r.y * rotpos.m[1][1] + r.z * rotpos.m[1][2] + linpos.y;
           z = r.x * rotpos.m[2][0] + r.y * rotpos.m[2][1] + r.z * rotpos.m[2][2] + linpos.z;
           return *this;
          }
          
     184  Point& Point::InvTransform(  const Point& r,   const Matrix3x3& rotpos,   const Point& linpos )
          {
           float sx = r.x - linpos.x;
           float sy = r.y - linpos.y;
           float sz = r.z - linpos.z;
           x = sx * rotpos.m[0][0] + sy * rotpos.m[1][0] + sz * rotpos.m[2][0];
           y = sx * rotpos.m[0][1] + sy * rotpos.m[1][1] + sz * rotpos.m[2][1];
           z = sx * rotpos.m[0][2] + sy * rotpos.m[1][2] + sz * rotpos.m[2][2];
           return *this;
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IceRandom.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for random generators.
           * \file IceRandom.cpp
           * \author Pierre Terdiman
           * \date August,   9,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceCore;
          
      16  void IceCore:: SRand(  udword seed )
          {
           srand(  seed );
          }
          
      21  udword IceCore::Rand(   )
          {
           return rand(   );
          }
          
          
      27  static BasicRandom gRandomGenerator(  42 );
          
      29  udword IceCore::GetRandomIndex(  udword max_index )
          {
           // We don't use rand(   ) since it's limited to RAND_MAX
           udword Index = gRandomGenerator.Randomize(   );
           return Index % max_index;
          }
          

./components/ogre/ogreopcode/src/Opcode/Ice/IceRay.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for rays.
           * \file IceRay.cpp
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Ray class.
           * A ray is a half-line P(  t ) = mOrig + mDir * t,   with 0 <= t <= +infinity
           * \class Ray
           * \author Pierre Terdiman
           * \version 1.0
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          /*
           O = Origin = impact point
           i = normalized vector along the x axis
           j = normalized vector along the y axis = actually the normal vector in O
           D = Direction vector,   norm |D| = 1
           N = Projection of D on y axis,   norm |N| = normal reaction
           T = Projection of D on x axis,   norm |T| = tangential reaction
           R = Reflexion vector
          
           ^y
           |
           |
           |
           _ _ _| _ _ _
           * * *|
           \ | /
           \ |N / |
           R\ | /D
           \ | / |
           \ | /
           _________\|/______*_______>x
           O T
          
           Let define theta = angle between D and N. Then cos(  theta ) = |N| / |D| = |N| since D is normalized.
          
           j|D = |j|*|D|*cos(  theta ) => |N| = j|D
          
           Then we simply have:
          
           D = N + T
          
           To compute tangential reaction :
          
           T = D - N
          
           To compute reflexion vector :
          
           R = N - T = N - (  D-N ) = 2*N - D
          */
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
      66  float Ray::SquareDistance(  const Point& point,   float* t ) const
          {
           Point Diff = point - mOrig;
           float fT = Diff | mDir;
          
           if(  fT<=0.0f )
           {
           fT = 0.0f;
           }
           else
           {
           fT /= mDir.SquareMagnitude(   );
           Diff -= fT*mDir;
           }
          
           if(  t ) *t = fT;
          
           return Diff.SquareMagnitude(   );
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IceSegment.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for segments.
           * \file IceSegment.cpp
           * \author Pierre Terdiman
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Segment class.
           * A segment is defined by S(  t ) = mP0 * (  1 - t ) + mP1 * t,   with 0 <= t <= 1
           * Alternatively,   a segment is S(  t ) = Origin + t * Direction for 0 <= t <= 1.
           * Direction is not necessarily unit length. The end points are Origin = mP0 and Origin + Direction = mP1.
           *
           * \class Segment
           * \author Pierre Terdiman
           * \version 1.0
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
      29  float Segment::SquareDistance(  const Point& point,   float* t ) const
          {
           Point Diff = point - mP0;
           Point Dir = mP1 - mP0;
           float fT = Diff | Dir;
          
           if(  fT<=0.0f )
           {
           fT = 0.0f;
           }
           else
           {
           float SqrLen= Dir.SquareMagnitude(   );
           if(  fT>=SqrLen )
           {
           fT = 1.0f;
           Diff -= Dir;
           }
           else
           {
           fT /= SqrLen;
           Diff -= fT*Dir;
           }
           }
          
           if(  t ) *t = fT;
          
           return Diff.SquareMagnitude(   );
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IceTriangle.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a handy triangle class.
           * \file IceTriangle.cpp
           * \author Pierre Terdiman
           * \date January,   17,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceMaths;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a triangle class.
           *
           * \class Tri
           * \author Pierre Terdiman
           * \version 1.0
           * \date 08.15.98
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
      27  static sdword VPlaneSideEps(  const Point& v,   const Plane& plane,   float epsilon )
          {
           // Compute distance from current vertex to the plane
           float Dist = plane.Distance(  v );
           // Compute side:
           // 1 = the vertex is on the positive side of the plane
           // -1 = the vertex is on the negative side of the plane
           // 0 = the vertex is on the plane (  within epsilon )
           return Dist > epsilon ? 1 : Dist < -epsilon ? -1 : 0;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Flips the winding order.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      43  void Triangle::Flip(   )
          {
           Point Tmp = mVerts[1];
           mVerts[1] = mVerts[2];
           mVerts[2] = Tmp;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle area.
           * \return the area
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      56  float Triangle::Area(   ) const
          {
           const Point& p0 = mVerts[0];
           const Point& p1 = mVerts[1];
           const Point& p2 = mVerts[2];
           return (  (  p0 - p1 )^(  p0 - p2 ) ).Magnitude(   ) * 0.5f;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle perimeter.
           * \return the perimeter
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      70  float Triangle::Perimeter(   ) const
          {
           const Point& p0 = mVerts[0];
           const Point& p1 = mVerts[1];
           const Point& p2 = mVerts[2];
           return p0.Distance(  p1 )
           + p0.Distance(  p2 )
           + p1.Distance(  p2 );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle compacity.
           * \return the compacity
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      86  float Triangle::Compacity(   ) const
          {
           float P = Perimeter(   );
           if(  P==0.0f ) return 0.0f;
           return (  4.0f*PI*Area(   )/(  P*P ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle normal.
           * \param normal [out] the computed normal
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      99  void Triangle::Normal(  Point& normal ) const
          {
           const Point& p0 = mVerts[0];
           const Point& p1 = mVerts[1];
           const Point& p2 = mVerts[2];
           normal = (  (  p0 - p1 )^(  p0 - p2 ) ).Normalize(   );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle denormalized normal.
           * \param normal [out] the computed normal
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     113  void Triangle::DenormalizedNormal(  Point& normal ) const
          {
           const Point& p0 = mVerts[0];
           const Point& p1 = mVerts[1];
           const Point& p2 = mVerts[2];
           normal = (  (  p0 - p1 )^(  p0 - p2 ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle center.
           * \param center [out] the computed center
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     127  void Triangle::Center(  Point& center ) const
          {
           const Point& p0 = mVerts[0];
           const Point& p1 = mVerts[1];
           const Point& p2 = mVerts[2];
           center = (  p0 + p1 + p2 )*INV3;
          }
          
     135  PartVal Triangle::TestAgainstPlane(  const Plane& plane,   float epsilon ) const
          {
           bool Pos = false,   Neg = false;
          
           // Loop through all vertices
           for(  udword i=0;i<3;i++ )
           {
           // Compute side:
           sdword Side = VPlaneSideEps(  mVerts[i],   plane,   epsilon );
          
           if (  Side < 0 ) Neg = true;
           else if (  Side > 0 ) Pos = true;
           }
          
           if (  !Pos && !Neg ) return TRI_ON_PLANE;
           else if (  Pos && Neg ) return TRI_INTERSECT;
           else if (  Pos && !Neg ) return TRI_PLUS_SPACE;
           else if (  !Pos && Neg ) return TRI_MINUS_SPACE;
          
           // What?!
           return TRI_FORCEDWORD;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle moment.
           * \param m [out] the moment
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
          void Triangle::ComputeMoment(  Moment& m )
          {
           // Compute the area of the triangle
           m.mArea = Area(   );
          
           // Compute the centroid
           Center(  m.mCentroid );
          
           // Second-order components. Handle zero-area faces.
           Point& p = mVerts[0];
           Point& q = mVerts[1];
           Point& r = mVerts[2];
           if(  m.mArea==0.0f )
           {
           // This triangle has zero area. The second order components would be eliminated with the usual formula,   so,   for the
           // sake of robustness we use an alternative form. These are the centroid and second-order components of the triangle's vertices.
           m.mCovariance.m[0][0] = (  p.x*p.x + q.x*q.x + r.x*r.x );
           m.mCovariance.m[0][1] = (  p.x*p.y + q.x*q.y + r.x*r.y );
           m.mCovariance.m[0][2] = (  p.x*p.z + q.x*q.z + r.x*r.z );
           m.mCovariance.m[1][1] = (  p.y*p.y + q.y*q.y + r.y*r.y );
           m.mCovariance.m[1][2] = (  p.y*p.z + q.y*q.z + r.y*r.z );
           m.mCovariance.m[2][2] = (  p.z*p.z + q.z*q.z + r.z*r.z );
           m.mCovariance.m[2][1] = m.mCovariance.m[1][2];
           m.mCovariance.m[1][0] = m.mCovariance.m[0][1];
           m.mCovariance.m[2][0] = m.mCovariance.m[0][2];
           }
           else
           {
           const float OneOverTwelve = 1.0f / 12.0f;
           m.mCovariance.m[0][0] = m.mArea * (  9.0f * m.mCentroid.x*m.mCentroid.x + p.x*p.x + q.x*q.x + r.x*r.x ) * OneOverTwelve;
           m.mCovariance.m[0][1] = m.mArea * (  9.0f * m.mCentroid.x*m.mCentroid.y + p.x*p.y + q.x*q.y + r.x*r.y ) * OneOverTwelve;
           m.mCovariance.m[1][1] = m.mArea * (  9.0f * m.mCentroid.y*m.mCentroid.y + p.y*p.y + q.y*q.y + r.y*r.y ) * OneOverTwelve;
           m.mCovariance.m[0][2] = m.mArea * (  9.0f * m.mCentroid.x*m.mCentroid.z + p.x*p.z + q.x*q.z + r.x*r.z ) * OneOverTwelve;
           m.mCovariance.m[1][2] = m.mArea * (  9.0f * m.mCentroid.y*m.mCentroid.z + p.y*p.z + q.y*q.z + r.y*r.z ) * OneOverTwelve;
           m.mCovariance.m[2][2] = m.mArea * (  9.0f * m.mCentroid.z*m.mCentroid.z + p.z*p.z + q.z*q.z + r.z*r.z ) * OneOverTwelve;
           m.mCovariance.m[2][1] = m.mCovariance.m[1][2];
           m.mCovariance.m[1][0] = m.mCovariance.m[0][1];
           m.mCovariance.m[2][0] = m.mCovariance.m[0][2];
           }
          }
          */
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle's smallest edge length.
           * \return the smallest edge length
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     213  float Triangle::MinEdgeLength(   ) const
          {
           float Min = MAX_FLOAT;
           float Length01 = mVerts[0].Distance(  mVerts[1] );
           float Length02 = mVerts[0].Distance(  mVerts[2] );
           float Length12 = mVerts[1].Distance(  mVerts[2] );
           if(  Length01 < Min ) Min = Length01;
           if(  Length02 < Min ) Min = Length02;
           if(  Length12 < Min ) Min = Length12;
           return Min;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the triangle's largest edge length.
           * \return the largest edge length
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     231  float Triangle::MaxEdgeLength(   ) const
          {
           float Max = MIN_FLOAT;
           float Length01 = mVerts[0].Distance(  mVerts[1] );
           float Length02 = mVerts[0].Distance(  mVerts[2] );
           float Length12 = mVerts[1].Distance(  mVerts[2] );
           if(  Length01 > Max ) Max = Length01;
           if(  Length02 > Max ) Max = Length02;
           if(  Length12 > Max ) Max = Length12;
           return Max;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes a point on the triangle according to the stabbing information.
           * \param u,  v [in] point's barycentric coordinates
           * \param pt [out] point on triangle
           * \param nearvtx [out] index of nearest vertex
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     251  void Triangle::ComputePoint(  float u,   float v,   Point& pt,   udword* nearvtx ) const
          {
           // Compute point coordinates
           pt = (  1.0f - u - v )*mVerts[0] + u*mVerts[1] + v*mVerts[2];
          
           // Compute nearest vertex if needed
           if(  nearvtx )
           {
           // Compute distance vector
           Point d(  mVerts[0].SquareDistance(  pt ),   // Distance^2 from vertex 0 to point on the face
           mVerts[1].SquareDistance(  pt ),   // Distance^2 from vertex 1 to point on the face
           mVerts[2].SquareDistance(  pt ) ); // Distance^2 from vertex 2 to point on the face
          
           // Get smallest distance
           *nearvtx = d.SmallestAxis(   );
           }
          }
          
     269  void Triangle::Inflate(  float fat_coeff,   bool constant_border )
          {
           // Compute triangle center
           Point TriangleCenter;
           Center(  TriangleCenter );
          
           // Don't normalize?
           // Normalize => add a constant border,   regardless of triangle size
           // Don't => add more to big triangles
           for(  udword i=0;i<3;i++ )
           {
           Point v = mVerts[i] - TriangleCenter;
          
           if(  constant_border ) v.Normalize(   );
          
           mVerts[i] += v * fat_coeff;
           }
          }

./components/ogre/ogreopcode/src/Opcode/Ice/IceUtils.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains misc. useful macros & defines.
           * \file IceUtils.cpp
           * \author Pierre Terdiman (  collected from various sources )
           * \date April,   4,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace IceCore;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Returns the alignment of the input address.
           * \fn Alignment(   )
           * \param address [in] address to check
           * \return the best alignment (  e.g. 1 for odd addresses,   etc )
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      24  udword IceCore::Alignment(  udword address )
          {
           // Returns 0 for null addresses
           if(  !address ) return 0;
          
           // Test all bits
           udword Align = 1;
           for(  udword i=1;i<32;i++ )
           {
           // Returns as soon as the alignment is broken
           if(  address&Align ) return Align;
           Align<<=1;
           }
           // Here all bits are null,   except the highest one (  else the address would be null )
           return Align;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_AABBCollider.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for an AABB collider.
           * \file OPC_AABBCollider.cpp
           * \author Pierre Terdiman
           * \date January,   1st,   2002
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains an AABB-vs-tree collider.
           *
           * \class AABBCollider
           * \author Pierre Terdiman
           * \version 1.3
           * \date January,   1st,   2002
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          #include "Opcode/OPC_BoxBoxOverlap.h"
          #include "Opcode/OPC_TriBoxOverlap.h"
          
          #define SET_CONTACT(  prim_index,   flag ) \
           /* Set contact status */ \
      40   mFlags |= flag; \
      41   mTouchedPrimitives->Add(  prim_index );
          
          //! AABB-triangle test
          #define AABB_PRIM(  prim_index,   flag ) \
           /* Request vertices from the app */ \
      46   VertexPointers VP; mIMesh->GetTriangle(  VP,   prim_index );\
      47   mLeafVerts[0] = *VP.Vertex[0]; \
           mLeafVerts[1] = *VP.Vertex[1]; \
           mLeafVerts[2] = *VP.Vertex[2]; \
           /* Perform triangle-box overlap test */ \
           if(  TriBoxOverlap(   ) ) \
           { \
           SET_CONTACT(  prim_index,   flag ) \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          AABBCollider::AABBCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          AABBCollider::~AABBCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Generic collision query for generic OPCODE models. After the call,   access the results:
           * - with GetContactStatus(   )
           * - with GetNbTouchedPrimitives(   )
           * - with GetTouchedPrimitives(   )
           *
           * \param cache [in/out] a box cache
           * \param box [in] collision AABB in world space
           * \param model [in] Opcode model to collide with
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBCollider::Collide(  AABBCache& cache,   const CollisionAABB& box,   const Model& model )
          {
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   box ) ) return true;
          
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           }
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Initializes a collision query :
           * - reset stats & contact status
           * - check temporal coherence
           *
           * \param cache [in/out] a box cache
           * \param box [in] AABB in world space
           * \return TRUE if we can return immediately
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          BOOL AABBCollider::InitQuery(  AABBCache& cache,   const CollisionAABB& box )
          {
           // 1 ) Call the base method
           VolumeCollider::InitQuery(   );
          
           // 2 ) Keep track of the query box
           mBox = box;
          
           // 3 ) Setup destination pointer
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // 4 ) Special case: 1-triangle meshes [Opcode 1.3]
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           if(  !SkipPrimitiveTests(   ) )
           {
           // We simply perform the BV-Prim overlap test each time. We assume single triangle has index 0.
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the unique triangle and the box (  and set contact status if needed )
           AABB_PRIM(  udword(  0 ),   OPC_CONTACT )
          
           // Return immediately regardless of status
           return TRUE;
           }
           }
          
           // 5 ) Check temporal coherence :
           if(  TemporalCoherenceEnabled(   ) )
           {
           // Here we use temporal coherence
           // => check results from previous frame before performing the collision query
           if(  FirstContactEnabled(   ) )
           {
           // We're only interested in the first contact found => test the unique previously touched face
           if(  mTouchedPrimitives->GetNbEntries(   ) )
           {
           // Get index of previously touched face = the first entry in the array
           udword PreviouslyTouchedFace = mTouchedPrimitives->GetEntry(  0 );
          
           // Then reset the array:
           // - if the overlap test below is successful,   the index we'll get added back anyway
           // - if it isn't,   then the array should be reset anyway for the normal query
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the cached triangle and the box (  and set contact status if needed )
           AABB_PRIM(  PreviouslyTouchedFace,   OPC_TEMPORAL_CONTACT )
          
           // Return immediately if possible
           if(  GetContactStatus(   ) ) return TRUE;
           }
           // else no face has been touched during previous query
           // => we'll have to perform a normal query
           }
           else
           {
           // We're interested in all contacts =>test the new real box N(  ew ) against the previous fat box P(  revious ):
           if(  IsCacheValid(  cache ) && mBox.IsInside(  cache.FatBox ) )
           {
           // - if N is included in P,   return previous list
           // => we simply leave the list (  mTouchedFaces ) unchanged
          
           // Set contact status if needed
           if(  mTouchedPrimitives->GetNbEntries(   ) ) mFlags |= OPC_TEMPORAL_CONTACT;
          
           // In any case we don't need to do a query
           return TRUE;
           }
           else
           {
           // - else do the query using a fat N
          
           // Reset cache since we'll about to perform a real query
           mTouchedPrimitives->Reset(   );
          
           // Make a fat box so that coherence will work for subsequent frames
           mBox.mExtents *= cache.FatCoeff;
          
           // Update cache with query data (  signature for cached faces )
           cache.FatBox = mBox;
           }
           }
           }
           else
           {
           // Here we don't use temporal coherence => do a normal query
           mTouchedPrimitives->Reset(   );
           }
          
           // 5 ) Precompute min & max bounds if needed
           mMin = box.mCenter - box.mExtents;
           mMax = box.mCenter + box.mExtents;
          
           return FALSE;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Collision query for vanilla AABB trees.
           * \param cache [in/out] a box cache
           * \param box [in] collision AABB in world space
           * \param tree [in] AABB tree
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBCollider::Collide(  AABBCache& cache,   const CollisionAABB& box,   const AABBTree* tree )
          {
           // This is typically called for a scene tree,   full of -AABBs-,   not full of triangles.
           // So we don't really have "primitives" to deal with. Hence it doesn't work with
           // "FirstContact" + "TemporalCoherence".
           ASSERT(   !(  FirstContactEnabled(   ) && TemporalCoherenceEnabled(   ) )  );
          
           // Checkings
           if(  !tree ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   box ) ) return true;
          
           // Perform collision query
           _Collide(  tree );
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks the AABB completely contains the box. In which case we can end the query sooner.
           * \param bc [in] box center
           * \param be [in] box extents
           * \return true if the AABB contains the whole box
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ BOOL AABBCollider::AABBContainsBox(  const IceMaths::Point& bc,   const IceMaths::Point& be )
          {
           if(  mMin.x > bc.x - be.x ) return FALSE;
           if(  mMin.y > bc.y - be.y ) return FALSE;
           if(  mMin.z > bc.z - be.z ) return FALSE;
          
           if(  mMax.x < bc.x + be.x ) return FALSE;
           if(  mMax.y < bc.y + be.y ) return FALSE;
           if(  mMax.z < bc.z + be.z ) return FALSE;
          
           return TRUE;
          }
          
          #define TEST_BOX_IN_AABB(  center,   extents ) \
           if(  AABBContainsBox(  center,   extents ) ) \
           { \
           /* Set contact status */ \
           mFlags |= OPC_CONTACT; \
           _Dump(  node ); \
           return; \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBCollider::_Collide(  const AABBCollisionNode* node )
          {
           // Perform AABB-AABB overlap test
           if(  !AABBAABBOverlap(  node->mAABB.mExtents,   node->mAABB.mCenter ) ) return;
          
           TEST_BOX_IN_AABB(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->IsLeaf(   ) )
           {
           AABB_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBCollider::_CollideNoPrimitiveTest(  const AABBCollisionNode* node )
          {
           // Perform AABB-AABB overlap test
           if(  !AABBAABBOverlap(  node->mAABB.mExtents,   node->mAABB.mCenter ) ) return;
          
           TEST_BOX_IN_AABB(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBCollider::_Collide(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform AABB-AABB overlap test
           if(  !AABBAABBOverlap(  Extents,   Center ) ) return;
          
           TEST_BOX_IN_AABB(  Center,   Extents )
          
           if(  node->IsLeaf(   ) )
           {
           AABB_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform AABB-AABB overlap test
           if(  !AABBAABBOverlap(  Extents,   Center ) ) return;
          
           TEST_BOX_IN_AABB(  Center,   Extents )
          
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBCollider::_Collide(  const AABBNoLeafNode* node )
          {
           // Perform AABB-AABB overlap test
           if(  !AABBAABBOverlap(  node->mAABB.mExtents,   node->mAABB.mCenter ) ) return;
          
           TEST_BOX_IN_AABB(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->HasPosLeaf(   ) ) { AABB_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { AABB_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBCollider::_CollideNoPrimitiveTest(  const AABBNoLeafNode* node )
          {
           // Perform AABB-AABB overlap test
           if(  !AABBAABBOverlap(  node->mAABB.mExtents,   node->mAABB.mCenter ) ) return;
          
           TEST_BOX_IN_AABB(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBCollider::_Collide(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform AABB-AABB overlap test
           if(  !AABBAABBOverlap(  Extents,   Center ) ) return;
          
           TEST_BOX_IN_AABB(  Center,   Extents )
          
           if(  node->HasPosLeaf(   ) ) { AABB_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { AABB_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform AABB-AABB overlap test
           if(  !AABBAABBOverlap(  Extents,   Center ) ) return;
          
           TEST_BOX_IN_AABB(  Center,   Extents )
          
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for vanilla AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBCollider::_Collide(  const AABBTreeNode* node )
          {
           // Perform AABB-AABB overlap test
           IceMaths::Point Center,   Extents;
           node->GetAABB(   )->GetCenter(  Center );
           node->GetAABB(   )->GetExtents(  Extents );
           if(  !AABBAABBOverlap(  Center,   Extents ) ) return;
          
           if(  node->IsLeaf(   ) || AABBContainsBox(  Center,   Extents ) )
           {
           mFlags |= OPC_CONTACT;
           mTouchedPrimitives->Add(  node->GetPrimitives(   ),   node->GetNbPrimitives(   ) );
           }
           else
           {
           _Collide(  node->GetPos(   ) );
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridAABBCollider::HybridAABBCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridAABBCollider::~HybridAABBCollider(   )
          {
          }
          
          bool HybridAABBCollider::Collide(  AABBCache& cache,   const CollisionAABB& box,   const HybridModel& model )
          {
           // We don't want primitive tests here!
           mFlags |= OPC_NO_PRIMITIVE_TESTS;
          
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   box ) ) return true;
          
           // Special case for 1-leaf trees
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           // Here we're supposed to perform a normal query,   except our tree has a single node,   i.e. just a few triangles
           udword Nb = mIMesh->GetNbTriangles(   );
          
           // Loop through all triangles
           for(  udword i=0;i<Nb;i++ )
           {
           AABB_PRIM(  i,   OPC_CONTACT )
           }
           return true;
           }
          
           // Override destination array since we're only going to get leaf boxes here
           mTouchedBoxes.Reset(   );
           mTouchedPrimitives = &mTouchedBoxes;
          
           // Now,   do the actual query against leaf boxes
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           }
          
           // We only have a list of boxes so far
           if(  GetContactStatus(   ) )
           {
           // Reset contact status,   since it currently only reflects collisions with leaf boxes
           Collider::InitQuery(   );
          
           // Change dest container so that we can use built-in overlap tests and get collided primitives
           cache.TouchedPrimitives.Reset(   );
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // Read touched leaf boxes
           udword Nb = mTouchedBoxes.GetNbEntries(   );
           const udword* Touched = mTouchedBoxes.GetEntries(   );
          
           const LeafTriangles* LT = model.GetLeafTriangles(   );
           const udword* Indices = model.GetIndices(   );
          
           // Loop through touched leaves
           while(  Nb-- )
           {
           const LeafTriangles& CurrentLeaf = LT[*Touched++];
          
           // Each leaf box has a set of triangles
           udword NbTris = CurrentLeaf.GetNbTriangles(   );
           if(  Indices )
           {
           const udword* T = &Indices[CurrentLeaf.GetTriangleIndex(   )];
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = *T++;
           AABB_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           else
           {
           udword BaseIndex = CurrentLeaf.GetTriangleIndex(   );
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = BaseIndex++;
           AABB_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           }
           }
          
           return true;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_AABBTree.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for a versatile AABB tree.
           * \file OPC_AABBTree.cpp
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a generic AABB tree node.
           *
           * \class AABBTreeNode
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a generic AABB tree.
           * This is a vanilla AABB tree,   without any particular optimization. It contains anonymous references to
           * user-provided primitives,   which can theoretically be anything - triangles,   boxes,   etc. Each primitive
           * is surrounded by an AABB,   regardless of the primitive's nature. When the primitive is a triangle,   the
           * resulting tree can be converted into an optimized tree. If the primitive is a box,   the resulting tree
           * can be used for culling - VFC or occlusion -,   assuming you cull on a mesh-by-mesh basis (  modern way ).
           *
           * \class AABBTree
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      56  AABBTreeNode::AABBTreeNode(   ) :
           mPos (  null ),  
          #ifndef OPC_NO_NEG_VANILLA_TREE
           mNeg (  null ),  
          #endif
           mNbPrimitives (  0 ),  
           mNodePrimitives (  null )
          {
          #ifdef OPC_USE_TREE_COHERENCE
           mBitmask = 0;
          #endif
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      74  AABBTreeNode::~AABBTreeNode(   )
          {
           // Opcode 1.3:
           const AABBTreeNode* Pos = GetPos(   );
           const AABBTreeNode* Neg = GetNeg(   );
          #ifndef OPC_NO_NEG_VANILLA_TREE
           if(  !(  mPos&1 ) ) DELETESINGLE(  Pos );
           if(  !(  mNeg&1 ) ) DELETESINGLE(  Neg );
          #else
           if(  !(  mPos&1 ) ) DELETEARRAY(  Pos );
          #endif
           mNodePrimitives = null; // This was just a shortcut to the global list => no release
           mNbPrimitives = 0;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Splits the node along a given axis.
           * The list of indices is reorganized according to the split values.
           * \param axis [in] splitting axis index
           * \param builder [in] the tree builder
           * \return the number of primitives assigned to the first child
           * \warning this method reorganizes the internal list of primitives
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      99  udword AABBTreeNode::Split(  udword axis,   AABBTreeBuilder* builder )
          {
           // Get node split value
           float SplitValue = builder->GetSplittingValue(  mNodePrimitives,   mNbPrimitives,   mBV,   axis );
          
           udword NbPos = 0;
           // Loop through all node-related primitives. Their indices range from mNodePrimitives[0] to mNodePrimitives[mNbPrimitives-1].
           // Those indices map the global list in the tree builder.
           for(  udword i=0;i<mNbPrimitives;i++ )
           {
           // Get index in global list
           udword Index = mNodePrimitives[i];
          
           // Test against the splitting value. The primitive value is tested against the enclosing-box center.
           // [We only need an approximate partition of the enclosing box here.]
           float PrimitiveValue = builder->GetSplittingValue(  Index,   axis );
          
           // Reorganize the list of indices in this order: positive - negative.
           if(  PrimitiveValue > SplitValue )
           {
           // Swap entries
           udword Tmp = mNodePrimitives[i];
           mNodePrimitives[i] = mNodePrimitives[NbPos];
           mNodePrimitives[NbPos] = Tmp;
           // Count primitives assigned to positive space
           NbPos++;
           }
           }
           return NbPos;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Subdivides the node.
           *
           * N
           * / \
           * / \
           * N/2 N/2
           * / \ / \
           * N/4 N/4 N/4 N/4
           * (  etc )
           *
           * A well-balanced tree should have a O(  log n ) depth.
           * A degenerate tree would have a O(  n ) depth.
           * Note a perfectly-balanced tree is not well-suited to collision detection anyway.
           *
           * \param builder [in] the tree builder
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     150  bool AABBTreeNode::Subdivide(  AABBTreeBuilder* builder )
          {
           // Checkings
           if(  !builder ) return false;
          
           // Stop subdividing if we reach a leaf node. This is always performed here,  
           // else we could end in trouble if user overrides this.
           if(  mNbPrimitives==1 ) return true;
          
           // Let the user validate the subdivision
           if(  !builder->ValidateSubdivision(  mNodePrimitives,   mNbPrimitives,   mBV ) ) return true;
          
           bool ValidSplit = true; // Optimism...
           udword NbPos;
           if(  builder->mSettings.mRules & SPLIT_LARGEST_AXIS )
           {
           // Find the largest axis to split along
           IceMaths::Point Extents; mBV.GetExtents(  Extents ); // Box extents
           udword Axis = Extents.LargestAxis(   ); // Index of largest axis
          
           // Split along the axis
           NbPos = Split(  Axis,   builder );
          
           // Check split validity
           if(  !NbPos || NbPos==mNbPrimitives ) ValidSplit = false;
           }
           else if(  builder->mSettings.mRules & SPLIT_SPLATTER_POINTS )
           {
           // Compute the means
           IceMaths::Point Means(  0.0f,   0.0f,   0.0f );
           for(  udword i=0;i<mNbPrimitives;i++ )
           {
           udword Index = mNodePrimitives[i];
           Means.x+=builder->GetSplittingValue(  Index,   0 );
           Means.y+=builder->GetSplittingValue(  Index,   1 );
           Means.z+=builder->GetSplittingValue(  Index,   2 );
           }
           Means/=float(  mNbPrimitives );
          
           // Compute variances
           IceMaths::Point Vars(  0.0f,   0.0f,   0.0f );
           for(  udword i=0;i<mNbPrimitives;i++ )
           {
           udword Index = mNodePrimitives[i];
           float Cx = builder->GetSplittingValue(  Index,   0 );
           float Cy = builder->GetSplittingValue(  Index,   1 );
           float Cz = builder->GetSplittingValue(  Index,   2 );
           Vars.x += (  Cx - Means.x )*(  Cx - Means.x );
           Vars.y += (  Cy - Means.y )*(  Cy - Means.y );
           Vars.z += (  Cz - Means.z )*(  Cz - Means.z );
           }
           Vars/=float(  mNbPrimitives-1 );
          
           // Choose axis with greatest variance
           udword Axis = Vars.LargestAxis(   );
          
           // Split along the axis
           NbPos = Split(  Axis,   builder );
          
           // Check split validity
           if(  !NbPos || NbPos==mNbPrimitives ) ValidSplit = false;
           }
           else if(  builder->mSettings.mRules & SPLIT_BALANCED )
           {
           // Test 3 axis,   take the best
           float Results[3];
           NbPos = Split(  0,   builder ); Results[0] = float(  NbPos )/float(  mNbPrimitives );
           NbPos = Split(  1,   builder ); Results[1] = float(  NbPos )/float(  mNbPrimitives );
           NbPos = Split(  2,   builder ); Results[2] = float(  NbPos )/float(  mNbPrimitives );
           Results[0]-=0.5f; Results[0]*=Results[0];
           Results[1]-=0.5f; Results[1]*=Results[1];
           Results[2]-=0.5f; Results[2]*=Results[2];
           udword Min=0;
           if(  Results[1]<Results[Min] ) Min = 1;
           if(  Results[2]<Results[Min] ) Min = 2;
          
           // Split along the axis
           NbPos = Split(  Min,   builder );
          
           // Check split validity
           if(  !NbPos || NbPos==mNbPrimitives ) ValidSplit = false;
           }
           else if(  builder->mSettings.mRules & SPLIT_BEST_AXIS )
           {
           // Test largest,   then middle,   then smallest axis...
          
           // Sort axis
           IceMaths::Point Extents; mBV.GetExtents(  Extents ); // Box extents
           udword SortedAxis[] = { 0,   1,   2 };
           float* Keys = (  float* )&Extents.x;
           for(  udword j=0;j<3;j++ )
           {
           for(  udword i=0;i<2;i++ )
           {
           if(  Keys[SortedAxis[i]]<Keys[SortedAxis[i+1]] )
           {
           udword Tmp = SortedAxis[i];
           SortedAxis[i] = SortedAxis[i+1];
           SortedAxis[i+1] = Tmp;
           }
           }
           }
          
           // Find the largest axis to split along
           udword CurAxis = 0;
           ValidSplit = false;
           while(  !ValidSplit && CurAxis!=3 )
           {
           NbPos = Split(  SortedAxis[CurAxis],   builder );
           // Check the subdivision has been successful
           if(  !NbPos || NbPos==mNbPrimitives ) CurAxis++;
           else ValidSplit = true;
           }
           }
           else if(  builder->mSettings.mRules & SPLIT_FIFTY )
           {
           // Don't even bother splitting (  mainly a performance test )
           NbPos = mNbPrimitives>>1;
           }
           else return false; // Unknown splitting rules
          
           // Check the subdivision has been successful
           if(  !ValidSplit )
           {
           // Here,   all boxes lie in the same sub-space. Two strategies:
           // - if the tree *must* be complete,   make an arbitrary 50-50 split
           // - else stop subdividing
          // if(  builder->mSettings.mRules&SPLIT_COMPLETE )
           if(  builder->mSettings.mLimit==1 )
           {
           builder->IncreaseNbInvalidSplits(   );
           NbPos = mNbPrimitives>>1;
           }
           else return true;
           }
          
           // Now create children and assign their pointers.
           if(  builder->mNodeBase )
           {
           // We use a pre-allocated linear pool for complete trees [Opcode 1.3]
           AABBTreeNode* Pool = (  AABBTreeNode* )builder->mNodeBase;
           udword Count = builder->GetCount(   ) - 1; // Count begins to 1...
           // Set last bit to tell it shouldn't be freed ### pretty ugly,   find a better way. Maybe one bit in mNbPrimitives
           ASSERT(  !(  udword(  &Pool[Count+0] )&1 ) );
           ASSERT(  !(  udword(  &Pool[Count+1] )&1 ) );
           mPos = size_t(  &Pool[Count+0] )|1;
          #ifndef OPC_NO_NEG_VANILLA_TREE
           mNeg = size_t(  &Pool[Count+1] )|1;
          #endif
           }
           else
           {
           // Non-complete trees and/or Opcode 1.2 allocate nodes on-the-fly
          #ifndef OPC_NO_NEG_VANILLA_TREE
           mPos = (  size_t )new AABBTreeNode; CHECKALLOC(  mPos );
           mNeg = (  size_t )new AABBTreeNode; CHECKALLOC(  mNeg );
          #else
           AABBTreeNode* PosNeg = new AABBTreeNode[2];
           CHECKALLOC(  PosNeg );
           mPos = (  size_t )PosNeg;
          #endif
           }
          
           // Update stats
           builder->IncreaseCount(  2 );
          
           // Assign children
           AABBTreeNode* Pos = (  AABBTreeNode* )GetPos(   );
           AABBTreeNode* Neg = (  AABBTreeNode* )GetNeg(   );
           Pos->mNodePrimitives = &mNodePrimitives[0];
           Pos->mNbPrimitives = NbPos;
           Neg->mNodePrimitives = &mNodePrimitives[NbPos];
           Neg->mNbPrimitives = mNbPrimitives - NbPos;
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive hierarchy building in a top-down fashion.
           * \param builder [in] the tree builder
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     333  void AABBTreeNode::_BuildHierarchy(  AABBTreeBuilder* builder )
          {
           // 1 ) Compute the global box for current node. The box is stored in mBV.
           builder->ComputeGlobalBox(  mNodePrimitives,   mNbPrimitives,   mBV );
          
           // 2 ) Subdivide current node
           Subdivide(  builder );
          
           // 3 ) Recurse
           AABBTreeNode* Pos = (  AABBTreeNode* )GetPos(   );
           AABBTreeNode* Neg = (  AABBTreeNode* )GetNeg(   );
           if(  Pos ) Pos->_BuildHierarchy(  builder );
           if(  Neg ) Neg->_BuildHierarchy(  builder );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the tree (  top-down ).
           * \param builder [in] the tree builder
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     354  void AABBTreeNode::_Refit(  AABBTreeBuilder* builder )
          {
           // 1 ) Recompute the new global box for current node
           builder->ComputeGlobalBox(  mNodePrimitives,   mNbPrimitives,   mBV );
          
           // 2 ) Recurse
           AABBTreeNode* Pos = (  AABBTreeNode* )GetPos(   );
           AABBTreeNode* Neg = (  AABBTreeNode* )GetNeg(   );
           if(  Pos ) Pos->_Refit(  builder );
           if(  Neg ) Neg->_Refit(  builder );
          }
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     373  AABBTree::AABBTree(   ) : mIndices(  null ),   mTotalNbNodes(  0 ),   mPool(  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     382  AABBTree::~AABBTree(   )
          {
           Release(   );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Releases the tree.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     392  void AABBTree::Release(   )
          {
           DELETEARRAY(  mPool );
           DELETEARRAY(  mIndices );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds a generic AABB tree from a tree builder.
           * \param builder [in] the tree builder
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     405  bool AABBTree::Build(  AABBTreeBuilder* builder )
          {
           // Checkings
           if(  !builder || !builder->mNbPrimitives ) return false;
          
           // Release previous tree
           Release(   );
          
           // Init stats
           builder->SetCount(  1 );
           builder->SetNbInvalidSplits(  0 );
          
           // Initialize indices. This list will be modified during build.
           mIndices = new udword[builder->mNbPrimitives];
           CHECKALLOC(  mIndices );
           // Identity permutation
           for(  udword i=0;i<builder->mNbPrimitives;i++ ) mIndices[i] = i;
          
           // Setup initial node. Here we have a complete permutation of the app's primitives.
           mNodePrimitives = mIndices;
           mNbPrimitives = builder->mNbPrimitives;
          
           // Use a linear array for complete trees (  since we can predict the final number of nodes ) [Opcode 1.3]
          // if(  builder->mRules&SPLIT_COMPLETE )
           if(  builder->mSettings.mLimit==1 )
           {
           // Allocate a pool of nodes
           mPool = new AABBTreeNode[builder->mNbPrimitives*2 - 1];
          
           builder->mNodeBase = mPool; // ### ugly !
           }
          
           // Build the hierarchy
           _BuildHierarchy(  builder );
          
           // Get back total number of nodes
           mTotalNbNodes = builder->GetCount(   );
          
           // For complete trees,   check the correct number of nodes has been created [Opcode 1.3]
           if(  mPool ) ASSERT(  mTotalNbNodes==builder->mNbPrimitives*2 - 1 );
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the depth of the tree.
           * A well-balanced tree should have a log(  n ) depth. A degenerate tree O(  n ) depth.
           * \return depth of the tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     456  udword AABBTree::ComputeDepth(   ) const
          {
           return Walk(  null,   null ); // Use the walking code without callback
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Walks the tree,   calling the user back for each node.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     466  udword AABBTree::Walk(  WalkingCallback callback,   void* user_data ) const
          {
           // Call it without callback to compute max depth
           udword MaxDepth = 0;
           udword CurrentDepth = 0;
          
           struct Local
           {
           static void _Walk(  const AABBTreeNode* current_node,   udword& max_depth,   udword& current_depth,   WalkingCallback callback,   void* user_data )
           {
           // Checkings
           if(  !current_node ) return;
           // Entering a new node => increase depth
           current_depth++;
           // Keep track of max depth
           if(  current_depth>max_depth ) max_depth = current_depth;
          
           // Callback
           if(  callback && !(  callback )(  current_node,   current_depth,   user_data ) ) return;
          
           // Recurse
           if(  current_node->GetPos(   ) ) { _Walk(  current_node->GetPos(   ),   max_depth,   current_depth,   callback,   user_data ); current_depth--; }
           if(  current_node->GetNeg(   ) ) { _Walk(  current_node->GetNeg(   ),   max_depth,   current_depth,   callback,   user_data ); current_depth--; }
           }
           };
           Local::_Walk(  this,   MaxDepth,   CurrentDepth,   callback,   user_data );
           return MaxDepth;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the tree in a top-down way.
           * \param builder [in] the tree builder
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     501  bool AABBTree::Refit(  AABBTreeBuilder* builder )
          {
           if(  !builder ) return false;
           _Refit(  builder );
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the tree in a bottom-up way.
           * \param builder [in] the tree builder
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     514  bool AABBTree::Refit2(  AABBTreeBuilder* builder )
          {
           // Checkings
           if(  !builder ) return false;
          
           ASSERT(  mPool );
          
           // Bottom-up update
           IceMaths::Point Min,  Max;
           IceMaths::Point Min_,  Max_;
           udword Index = mTotalNbNodes;
           while(  Index-- )
           {
           AABBTreeNode& Current = mPool[Index];
          
           if(  Current.IsLeaf(   ) )
           {
           builder->ComputeGlobalBox(  Current.GetPrimitives(   ),   Current.GetNbPrimitives(   ),   *(  IceMaths::AABB* )Current.GetAABB(   ) );
           }
           else
           {
           Current.GetPos(   )->GetAABB(   )->GetMin(  Min );
           Current.GetPos(   )->GetAABB(   )->GetMax(  Max );
          
           Current.GetNeg(   )->GetAABB(   )->GetMin(  Min_ );
           Current.GetNeg(   )->GetAABB(   )->GetMax(  Max_ );
          
           Min.Min(  Min_ );
           Max.Max(  Max_ );
          
           (  (  IceMaths::AABB* )Current.GetAABB(   ) )->SetMinMax(  Min,   Max );
           }
           }
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the number of bytes used by the tree.
           * \return number of bytes used
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     556  udword AABBTree::GetUsedBytes(   ) const
          {
           udword TotalSize = mTotalNbNodes*GetNodeSize(   );
           if(  mIndices ) TotalSize+=mNbPrimitives*sizeof(  udword );
           return TotalSize;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks the tree is a complete tree or not.
           * A complete tree is made of 2*N-1 nodes,   where N is the number of primitives in the tree.
           * \return true for complete trees
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     570  bool AABBTree::IsComplete(   ) const
          {
           return (  GetNbNodes(   )==GetNbPrimitives(   )*2-1 );
          }

./components/ogre/ogreopcode/src/Opcode/OPC_BaseModel.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains base model interface.
           * \file OPC_BaseModel.cpp
           * \author Pierre Terdiman
           * \date May,   18,   2003
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * The base class for collision models.
           *
           * \class BaseModel
           * \author Pierre Terdiman
           * \version 1.3
           * \date May,   18,   2003
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          OPCODECREATE::OPCODECREATE(   )
          {
           mIMesh = null;
           mSettings.mRules = SPLIT_SPLATTER_POINTS | SPLIT_GEOM_CENTER;
           mSettings.mLimit = 1; // Mandatory for complete trees
           mNoLeaf = true;
           mQuantized = true;
          #ifdef __MESHMERIZER_H__
           mCollisionHull = false;
          #endif // __MESHMERIZER_H__
           mKeepOriginal = false;
           mCanRemap = false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      59  BaseModel::BaseModel(   ) : mIMesh(  null ),   mModelCode(  0 ),   mSource(  null ),   mTree(  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      68  BaseModel::~BaseModel(   )
          {
           ReleaseBase(   );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Releases everything.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      78  void BaseModel::ReleaseBase(   )
          {
           DELETESINGLE(  mSource );
           DELETESINGLE(  mTree );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Creates an optimized tree according to user-settings,   and setups mModelCode.
           * \param no_leaf [in] true for "no leaf" tree
           * \param quantized [in] true for quantized tree
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      92  bool BaseModel::CreateTree(  bool no_leaf,   bool quantized )
          {
           DELETESINGLE(  mTree );
          
           // Setup model code
           if(  no_leaf ) mModelCode |= OPC_NO_LEAF;
           else mModelCode &= ~OPC_NO_LEAF;
          
           if(  quantized ) mModelCode |= OPC_QUANTIZED;
           else mModelCode &= ~OPC_QUANTIZED;
          
           // Create the correct class
           if(  mModelCode & OPC_NO_LEAF )
           {
           if(  mModelCode & OPC_QUANTIZED ) mTree = new AABBQuantizedNoLeafTree;
           else mTree = new AABBNoLeafTree;
           }
           else
           {
           if(  mModelCode & OPC_QUANTIZED ) mTree = new AABBQuantizedTree;
           else mTree = new AABBCollisionTree;
           }
           CHECKALLOC(  mTree );
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the collision model. This can be used to handle dynamic meshes. Usage is:
           * 1. modify your mesh vertices (  keep the topology constant! )
           * 2. refit the tree (  call this method )
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     127  bool BaseModel::Refit(   )
          {
           // Refit the optimized tree
           return mTree->Refit(  mIMesh );
          
          // Old code kept for reference : refit the source tree then rebuild !
          // if(  !mSource ) return false;
          // // Ouch...
          // mSource->Refit(  &mTB );
          // // Ouch...
          // return mTree->Build(  mSource );
          }

./components/ogre/ogreopcode/src/Opcode/OPC_BoxPruning.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for box pruning.
           * \file IceBoxPruning.cpp
           * \author Pierre Terdiman
           * \date January,   29,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          /*
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           You could use a complex sweep-and-prune as implemented in I-Collide.
           You could use a complex hashing scheme as implemented in V-Clip or recently in ODE it seems.
           You could use a "Recursive Dimensional Clustering" algorithm as implemented in GPG2.
          
           Or you could use this.
           Faster ? I don't know. Probably not. It would be a shame. But who knows ?
           Easier ? Definitely. Enjoy the sheer simplicity.
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          */
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
      37   inline_ void FindRunningIndex(  udword& index,   float* array,   udword* sorted,   int last,   float max )
           {
           int First=index;
           while(  First<=last )
           {
           index = (  First+last )>>1;
          
           if(  max>array[sorted[index]] ) First = index+1;
           else last = index-1;
           }
           }
          // ### could be log(  n ) !
          // and maybe use cmp integers
          
          // InsertionSort has better coherence,   RadixSort is better for one-shot queries.
          #define PRUNING_SORTER RadixSort
          //#define PRUNING_SORTER InsertionSort
          
          // Static for coherence
          static PRUNING_SORTER* gCompletePruningSorter = null;
          static PRUNING_SORTER* gBipartitePruningSorter0 = null;
          static PRUNING_SORTER* gBipartitePruningSorter1 = null;
          inline_ PRUNING_SORTER* GetCompletePruningSorter(   )
          {
           if(  !gCompletePruningSorter ) gCompletePruningSorter = new PRUNING_SORTER;
           return gCompletePruningSorter;
          }
          inline_ PRUNING_SORTER* GetBipartitePruningSorter0(   )
          {
           if(  !gBipartitePruningSorter0 ) gBipartitePruningSorter0 = new PRUNING_SORTER;
           return gBipartitePruningSorter0;
          }
          inline_ PRUNING_SORTER* GetBipartitePruningSorter1(   )
          {
           if(  !gBipartitePruningSorter1 ) gBipartitePruningSorter1 = new PRUNING_SORTER;
           return gBipartitePruningSorter1;
          }
          void ReleasePruningSorters(   )
          {
           DELETESINGLE(  gBipartitePruningSorter1 );
           DELETESINGLE(  gBipartitePruningSorter0 );
           DELETESINGLE(  gCompletePruningSorter );
          }
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Bipartite box pruning. Returns a list of overlapping pairs of boxes,   each box of the pair belongs to a different set.
           * \param nb0 [in] number of boxes in the first set
           * \param array0 [in] array of boxes for the first set
           * \param nb1 [in] number of boxes in the second set
           * \param array1 [in] array of boxes for the second set
           * \param pairs [out] array of overlapping pairs
           * \param axes [in] projection order (  0,  2,  1 is often best )
           * \return true if success.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool Opcode::BipartiteBoxPruning(  udword nb0,   const IceMaths::AABB** array0,   udword nb1,   const IceMaths::AABB** array1,   Pairs& pairs,   const IceMaths::Axes& axes )
          {
           // Checkings
           if(  !nb0 || !array0 || !nb1 || !array1 ) return false;
          
           // Catch axes
           udword Axis0 = axes.mAxis0;
           udword Axis1 = axes.mAxis1;
           udword Axis2 = axes.mAxis2;
          
           // Allocate some temporary data
           float* MinPosList0 = new float[nb0];
           float* MinPosList1 = new float[nb1];
          
           // 1 ) Build main lists using the primary axis
           for(  udword i=0;i<nb0;i++ ) MinPosList0[i] = array0[i]->GetMin(  Axis0 );
           for(  udword i=0;i<nb1;i++ ) MinPosList1[i] = array1[i]->GetMin(  Axis0 );
          
           // 2 ) Sort the lists
           PRUNING_SORTER* RS0 = GetBipartitePruningSorter0(   );
           PRUNING_SORTER* RS1 = GetBipartitePruningSorter1(   );
           const udword* Sorted0 = RS0->Sort(  MinPosList0,   nb0 ).GetRanks(   );
           const udword* Sorted1 = RS1->Sort(  MinPosList1,   nb1 ).GetRanks(   );
          
           // 3 ) Prune the lists
           udword Index0,   Index1;
          
           const udword* const LastSorted0 = &Sorted0[nb0];
           const udword* const LastSorted1 = &Sorted1[nb1];
           const udword* RunningAddress0 = Sorted0;
           const udword* RunningAddress1 = Sorted1;
          
           while(  RunningAddress1<LastSorted1 && Sorted0<LastSorted0 )
           {
           Index0 = *Sorted0++;
          
           while(  RunningAddress1<LastSorted1 && MinPosList1[*RunningAddress1]<MinPosList0[Index0] ) RunningAddress1++;
          
           const udword* RunningAddress2_1 = RunningAddress1;
          
           while(  RunningAddress2_1<LastSorted1 && MinPosList1[Index1 = *RunningAddress2_1++]<=array0[Index0]->GetMax(  Axis0 ) )
           {
           if(  array0[Index0]->Intersect(  *array1[Index1],   Axis1 ) )
           {
           if(  array0[Index0]->Intersect(  *array1[Index1],   Axis2 ) )
           {
           pairs.AddPair(  Index0,   Index1 );
           }
           }
           }
           }
          
           ////
          
           while(  RunningAddress0<LastSorted0 && Sorted1<LastSorted1 )
           {
           Index0 = *Sorted1++;
          
           while(  RunningAddress0<LastSorted0 && MinPosList0[*RunningAddress0]<=MinPosList1[Index0] ) RunningAddress0++;
          
           const udword* RunningAddress2_0 = RunningAddress0;
          
           while(  RunningAddress2_0<LastSorted0 && MinPosList0[Index1 = *RunningAddress2_0++]<=array1[Index0]->GetMax(  Axis0 ) )
           {
           if(  array0[Index1]->Intersect(  *array1[Index0],   Axis1 ) )
           {
           if(  array0[Index1]->Intersect(  *array1[Index0],   Axis2 ) )
           {
           pairs.AddPair(  Index1,   Index0 );
           }
           }
          
           }
           }
          
           DELETEARRAY(  MinPosList1 );
           DELETEARRAY(  MinPosList0 );
          
           return true;
          }
          
          #define ORIGINAL_VERSION
          //#define JOAKIM
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Complete box pruning. Returns a list of overlapping pairs of boxes,   each box of the pair belongs to the same set.
           * \param nb [in] number of boxes
           * \param array [in] array of boxes
           * \param pairs [out] array of overlapping pairs
           * \param axes [in] projection order (  0,  2,  1 is often best )
           * \return true if success.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool Opcode::CompleteBoxPruning(  udword nb,   const IceMaths::AABB** array,   Pairs& pairs,   const IceMaths::Axes& axes )
          {
           // Checkings
           if(  !nb || !array ) return false;
          
           // Catch axes
           udword Axis0 = axes.mAxis0;
           udword Axis1 = axes.mAxis1;
           udword Axis2 = axes.mAxis2;
          
          #ifdef ORIGINAL_VERSION
           // Allocate some temporary data
          // float* PosList = new float[nb];
           float* PosList = new float[nb+1];
          
           // 1 ) Build main list using the primary axis
           for(  udword i=0;i<nb;i++ ) PosList[i] = array[i]->GetMin(  Axis0 );
          PosList[nb++] = MAX_FLOAT;
          
           // 2 ) Sort the list
           PRUNING_SORTER* RS = GetCompletePruningSorter(   );
           const udword* Sorted = RS->Sort(  PosList,   nb ).GetRanks(   );
          
           // 3 ) Prune the list
           const udword* const LastSorted = &Sorted[nb];
           const udword* RunningAddress = Sorted;
           udword Index0,   Index1;
           while(  RunningAddress<LastSorted && Sorted<LastSorted )
           {
           Index0 = *Sorted++;
          
          // while(  RunningAddress<LastSorted && PosList[*RunningAddress++]<PosList[Index0] );
           while(  PosList[*RunningAddress++]<PosList[Index0] );
          
           if(  RunningAddress<LastSorted )
           {
           const udword* RunningAddress2 = RunningAddress;
          
          // while(  RunningAddress2<LastSorted && PosList[Index1 = *RunningAddress2++]<=array[Index0]->GetMax(  Axis0 ) )
           while(  PosList[Index1 = *RunningAddress2++]<=array[Index0]->GetMax(  Axis0 ) )
           {
          // if(  Index0!=Index1 )
          // {
           if(  array[Index0]->Intersect(  *array[Index1],   Axis1 ) )
           {
           if(  array[Index0]->Intersect(  *array[Index1],   Axis2 ) )
           {
           pairs.AddPair(  Index0,   Index1 );
           }
           }
          // }
           }
           }
           }
          
           DELETEARRAY(  PosList );
          #endif
          
          #ifdef JOAKIM
           // Allocate some temporary data
          // float* PosList = new float[nb];
           float* MinList = new float[nb+1];
          
           // 1 ) Build main list using the primary axis
           for(  udword i=0;i<nb;i++ ) MinList[i] = array[i]->GetMin(  Axis0 );
           MinList[nb] = MAX_FLOAT;
          
           // 2 ) Sort the list
           PRUNING_SORTER* RS = GetCompletePruningSorter(   );
           udword* Sorted = RS->Sort(  MinList,   nb+1 ).GetRanks(   );
          
           // 3 ) Prune the list
          // const udword* const LastSorted = &Sorted[nb];
          // const udword* const LastSorted = &Sorted[nb-1];
           const udword* RunningAddress = Sorted;
           udword Index0,   Index1;
          
          // while(  RunningAddress<LastSorted && Sorted<LastSorted )
          // while(  RunningAddress<LastSorted )
           while(  RunningAddress<&Sorted[nb] )
          // while(  Sorted<LastSorted )
           {
          // Index0 = *Sorted++;
           Index0 = *RunningAddress++;
          
          // while(  RunningAddress<LastSorted && PosList[*RunningAddress++]<PosList[Index0] );
          // while(  PosList[*RunningAddress++]<PosList[Index0] );
          //RunningAddress = Sorted;
          // if(  RunningAddress<LastSorted )
           {
           const udword* RunningAddress2 = RunningAddress;
          
          // while(  RunningAddress2<LastSorted && PosList[Index1 = *RunningAddress2++]<=array[Index0]->GetMax(  Axis0 ) )
          
          // float CurrentMin = array[Index0]->GetMin(  Axis0 );
           float CurrentMax = array[Index0]->GetMax(  Axis0 );
          
           while(  MinList[Index1 = *RunningAddress2] <= CurrentMax )
          // while(  PosList[Index1 = *RunningAddress] <= CurrentMax )
           {
          // if(  Index0!=Index1 )
          // {
           if(  array[Index0]->Intersect(  *array[Index1],   Axis1 ) )
           {
           if(  array[Index0]->Intersect(  *array[Index1],   Axis2 ) )
           {
           pairs.AddPair(  Index0,   Index1 );
           }
           }
          // }
          
           RunningAddress2++;
          // RunningAddress++;
           }
           }
           }
          
           DELETEARRAY(  MinList );
          #endif
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Brute-force versions are kept:
          // - to check the optimized versions return the correct list of intersections
          // - to check the speed of the optimized code against the brute-force one
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Brute-force bipartite box pruning. Returns a list of overlapping pairs of boxes,   each box of the pair belongs to a different set.
           * \param nb0 [in] number of boxes in the first set
           * \param array0 [in] array of boxes for the first set
           * \param nb1 [in] number of boxes in the second set
           * \param array1 [in] array of boxes for the second set
           * \param pairs [out] array of overlapping pairs
           * \return true if success.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool Opcode::BruteForceBipartiteBoxTest(  udword nb0,   const IceMaths::AABB** array0,   udword nb1,   const IceMaths::AABB** array1,   Pairs& pairs )
          {
           // Checkings
           if(  !nb0 || !array0 || !nb1 || !array1 ) return false;
          
           // Brute-force nb0*nb1 overlap tests
           for(  udword i=0;i<nb0;i++ )
           {
           for(  udword j=0;j<nb1;j++ )
           {
           if(  array0[i]->Intersect(  *array1[j] ) ) pairs.AddPair(  i,   j );
           }
           }
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Complete box pruning. Returns a list of overlapping pairs of boxes,   each box of the pair belongs to the same set.
           * \param nb [in] number of boxes
           * \param array [in] array of boxes
           * \param pairs [out] array of overlapping pairs
           * \return true if success.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool Opcode::BruteForceCompleteBoxTest(  udword nb,   const IceMaths::AABB** array,   Pairs& pairs )
          {
           // Checkings
           if(  !nb || !array ) return false;
          
           // Brute-force n(  n-1 )/2 overlap tests
           for(  udword i=0;i<nb;i++ )
           {
           for(  udword j=i+1;j<nb;j++ )
           {
           if(  array[i]->Intersect(  *array[j] ) ) pairs.AddPair(  i,   j );
           }
           }
           return true;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_Collider.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains base collider class.
           * \file OPC_Collider.cpp
           * \author Pierre Terdiman
           * \date June,   2,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains the abstract class for colliders.
           *
           * \class Collider
           * \author Pierre Terdiman
           * \version 1.3
           * \date June,   2,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      40  Collider::Collider(   ) :
           mFlags (  0 ),  
           mCurrentModel (  null ),  
           mIMesh (  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      52  Collider::~Collider(   )
          {
          }

./components/ogre/ogreopcode/src/Opcode/OPC_Common.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains common classes & defs used in OPCODE.
           * \file OPC_Common.cpp
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * An AABB dedicated to collision detection.
           * We don't use the generic AABB class included in ICE,   since it can be a Min/Max or a Center/Extents one (  depends
           * on compilation flags ). Since the Center/Extents model is more efficient in collision detection,   it was worth
           * using an extra special class.
           *
           * \class CollisionAABB
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * A quantized AABB.
           * Center/Extent model,   using 16-bits integers.
           *
           * \class QuantizedAABB
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;

./components/ogre/ogreopcode/src/Opcode/OPC_HybridModel.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for hybrid models.
           * \file OPC_HybridModel.cpp
           * \author Pierre Terdiman
           * \date May,   18,   2003
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * An hybrid collision model.
           *
           * The problem :
           *
           * Opcode really shines for mesh-mesh collision,   especially when meshes are deeply overlapping
           * (  it typically outperforms RAPID in those cases ).
           *
           * Unfortunately this is not the typical scenario in games.
           *
           * For close-proximity cases,   especially for volume-mesh queries,   it's relatively easy to run faster
           * than Opcode,   that suffers from a relatively high setup time.
           *
           * In particular,   Opcode's "vanilla" trees in those cases -can- run faster. They can also use -less-
           * memory than the optimized ones,   when you let the system stop at ~10 triangles / leaf for example
           * (  i.e. when you don't use "complete" trees ). However,   those trees tend to fragment memory quite a
           * lot,   increasing cache misses : since they're not "complete",   we can't predict the final number of
           * nodes and we have to allocate nodes on-the-fly. For the same reasons we can't use Opcode's "optimized"
           * trees here,   since they rely on a known layout to perform the "optimization".
           *
           * Hybrid trees :
           *
           * Hybrid trees try to combine best of both worlds :
           *
           * - they use a maximum limit of 16 triangles/leaf. "16" is used so that we'll be able to save the
           * number of triangles using 4 bits only.
           *
           * - they're still "complete" trees thanks to a two-passes building phase. First we create a "vanilla"
           * AABB-tree with Opcode,   limited to 16 triangles/leaf. Then we create a *second* vanilla tree,   this
           * time using the leaves of the first one. The trick is : this second tree is now "complete"... so we
           * can further transform it into an Opcode's optimized tree.
           *
           * - then we run the collision queries on that standard Opcode tree. The only difference is that leaf
           * nodes contain indices to leaf nodes of another tree. Also,   we have to skip all primitive tests in
           * Opcode optimized trees,   since our leaves don't contain triangles anymore.
           *
           * - finally,   for each collided leaf,   we simply loop through 16 triangles max,   and collide them with
           * the bounding volume used in the query (  we only support volume-vs-mesh queries here,   not mesh-vs-mesh )
           *
           * All of that is wrapped in this "hybrid model" that contains the minimal data required for this to work.
           * It's a mix between old "vanilla" trees,   and old "optimized" trees.
           *
           * Extra advantages:
           *
           * - If we use them for dynamic models,   we're left with a very small number of leaf nodes to refit. It
           * might be a bit faster since we have less nodes to write back.
           *
           * - In rigid body simulation,   using temporal coherence and sleeping objects greatly reduce the actual
           * influence of one tree over another (  i.e. the speed difference is often invisible ). So memory is really
           * the key element to consider,   and in this regard hybrid trees are just better.
           *
           * Information to take home:
           * - they use less ram
           * - they're not slower (  they're faster or slower depending on cases,   overall there's no significant
           * difference *as long as objects don't interpenetrate too much* - in which case Opcode's optimized trees
           * are still notably faster )
           *
           * \class HybridModel
           * \author Pierre Terdiman
           * \version 1.3
           * \date May,   18,   2003
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      94  HybridModel::HybridModel(   ) :
           mNbLeaves (  0 ),  
           mNbPrimitives (  0 ),  
           mTriangles (  null ),  
           mIndices (  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     107  HybridModel::~HybridModel(   )
          {
           Release(   );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Releases everything.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     117  void HybridModel::Release(   )
          {
           ReleaseBase(   );
           DELETEARRAY(  mIndices );
           DELETEARRAY(  mTriangles );
           mNbLeaves = 0;
           mNbPrimitives = 0;
          }
          
           struct Internal
           {
           Internal(   )
           {
           mNbLeaves = 0;
           mLeaves = null;
           mTriangles = null;
           mBase = null;
           }
           ~Internal(   )
           {
           DELETEARRAY(  mLeaves );
           }
          
           udword mNbLeaves;
           IceMaths::AABB* mLeaves;
           LeafTriangles* mTriangles;
           const udword* mBase;
           };
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds a collision model.
           * \param create [in] model creation structure
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     153  bool HybridModel::Build(  const OPCODECREATE& create )
          {
           // 1 ) Checkings
           if(  !create.mIMesh || !create.mIMesh->IsValid(   ) ) return false;
          
           // Look for degenerate faces.
           udword NbDegenerate = create.mIMesh->CheckTopology(   );
           if(  NbDegenerate ) OpcodeLog(  "OPCODE WARNING: found %d degenerate faces in model! Collision might report wrong results!\n",   NbDegenerate );
           // We continue nonetheless....
          
           Release(   ); // Make sure previous tree has been discarded
          
           // 1-1 ) Setup mesh interface automatically
           SetMeshInterface(  create.mIMesh );
          
           bool Status = false;
           AABBTree* LeafTree = null;
           Internal Data;
          
           // 2 ) Build a generic AABB Tree.
           mSource = new AABBTree;
           CHECKALLOC(  mSource );
          
           // 2-1 ) Setup a builder. Our primitives here are triangles from input mesh,  
           // so we use an AABBTreeOfTrianglesBuilder.....
           {
           AABBTreeOfTrianglesBuilder TB;
           TB.mIMesh = create.mIMesh;
           TB.mNbPrimitives = create.mIMesh->GetNbTriangles(   );
           TB.mSettings = create.mSettings;
           TB.mSettings.mLimit = 16; // ### Hardcoded,   but maybe we could let the user choose 8 / 16 / 32 ...
           if(  !mSource->Build(  &TB ) ) goto FreeAndExit;
           }
          
           // 2-2 ) Here's the trick : create *another* AABB tree using the leaves of the first one (  which are boxes,   this time )
           struct Local
           {
           // A callback to count leaf nodes
           static bool CountLeaves(  const AABBTreeNode* current,   udword depth,   void* user_data )
           {
           if(  current->IsLeaf(   ) )
           {
           Internal* Data = (  Internal* )user_data;
           Data->mNbLeaves++;
           }
           return true;
           }
          
           // A callback to setup leaf nodes in our internal structures
           static bool SetupLeafData(  const AABBTreeNode* current,   udword depth,   void* user_data )
           {
           if(  current->IsLeaf(   ) )
           {
           Internal* Data = (  Internal* )user_data;
          
           // Get current leaf's box
           Data->mLeaves[Data->mNbLeaves] = *current->GetAABB(   );
          
           // Setup leaf data
           udword Index = (  size_t(  current->GetPrimitives(   ) ) - size_t(  Data->mBase ) )/sizeof(  size_t );
           Data->mTriangles[Data->mNbLeaves].SetData(  current->GetNbPrimitives(   ),   Index );
          
           Data->mNbLeaves++;
           }
           return true;
           }
           };
          
           // Walk the tree & count number of leaves
           Data.mNbLeaves = 0;
           mSource->Walk(  Local::CountLeaves,   &Data );
           mNbLeaves = Data.mNbLeaves; // Keep track of it
          
           // Special case for 1-leaf meshes
           if(  mNbLeaves==1 )
           {
           mModelCode |= OPC_SINGLE_NODE;
           Status = true;
           goto FreeAndExit;
           }
          
           // Allocate our structures
           Data.mLeaves = new IceMaths::AABB[Data.mNbLeaves]; CHECKALLOC(  Data.mLeaves );
           mTriangles = new LeafTriangles[Data.mNbLeaves]; CHECKALLOC(  mTriangles );
          
           // Walk the tree again & setup leaf data
           Data.mTriangles = mTriangles;
           Data.mBase = mSource->GetIndices(   );
           Data.mNbLeaves = 0; // Reset for incoming walk
           mSource->Walk(  Local::SetupLeafData,   &Data );
          
           // Handle source indices
           {
           bool MustKeepIndices = true;
           if(  create.mCanRemap )
           {
           // We try to get rid of source indices (  saving more ram! ) by reorganizing triangle arrays...
           // Remap can fail when we use callbacks => keep track of indices in that case (  it still
           // works,   only using more memory )
           if(  create.mIMesh->RemapClient(  mSource->GetNbPrimitives(   ),   mSource->GetIndices(   ) ) )
           {
           MustKeepIndices = false;
           }
           }
          
           if(  MustKeepIndices )
           {
           // Keep track of source indices (  from vanilla tree )
           mNbPrimitives = mSource->GetNbPrimitives(   );
           mIndices = new udword[mNbPrimitives];
           CopyMemory(  mIndices,   mSource->GetIndices(   ),   mNbPrimitives*sizeof(  udword ) );
           }
           }
          
           // Now,   create our optimized tree using previous leaf nodes
           LeafTree = new AABBTree;
           CHECKALLOC(  LeafTree );
           {
           AABBTreeOfAABBsBuilder TB; // Now using boxes !
           TB.mSettings = create.mSettings;
           TB.mSettings.mLimit = 1; // We now want a complete tree so that we can "optimize" it
           TB.mNbPrimitives = Data.mNbLeaves;
           TB.mAABBArray = Data.mLeaves;
           if(  !LeafTree->Build(  &TB ) ) goto FreeAndExit;
           }
          
           // 3 ) Create an optimized tree according to user-settings
           if(  !CreateTree(  create.mNoLeaf,   create.mQuantized ) ) goto FreeAndExit;
          
           // 3-2 ) Create optimized tree
           if(  !mTree->Build(  LeafTree ) ) goto FreeAndExit;
          
           // Finally ok...
           Status = true;
          
          FreeAndExit: // Allow me this one...
           DELETESINGLE(  LeafTree );
          
           // 3-3 ) Delete generic tree if needed
           if(  !create.mKeepOriginal ) DELETESINGLE(  mSource );
          
           return Status;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Gets the number of bytes used by the tree.
           * \return amount of bytes used
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     303  udword HybridModel::GetUsedBytes(   ) const
          {
           udword UsedBytes = 0;
           if(  mTree ) UsedBytes += mTree->GetUsedBytes(   );
           if(  mIndices ) UsedBytes += mNbPrimitives * sizeof(  udword ); // mIndices
           if(  mTriangles ) UsedBytes += mNbLeaves * sizeof(  LeafTriangles ); // mTriangles
           return UsedBytes;
          }
          
     312  inline_ void ComputeMinMax(  IceMaths::Point& min,   IceMaths::Point& max,   const VertexPointers& vp )
          {
           // Compute triangle's AABB = a leaf box
          #ifdef OPC_USE_FCOMI // a 15% speedup on my machine,   not much
           min.x = FCMin3(  vp.Vertex[0]->x,   vp.Vertex[1]->x,   vp.Vertex[2]->x );
           max.x = FCMax3(  vp.Vertex[0]->x,   vp.Vertex[1]->x,   vp.Vertex[2]->x );
          
           min.y = FCMin3(  vp.Vertex[0]->y,   vp.Vertex[1]->y,   vp.Vertex[2]->y );
           max.y = FCMax3(  vp.Vertex[0]->y,   vp.Vertex[1]->y,   vp.Vertex[2]->y );
          
           min.z = FCMin3(  vp.Vertex[0]->z,   vp.Vertex[1]->z,   vp.Vertex[2]->z );
           max.z = FCMax3(  vp.Vertex[0]->z,   vp.Vertex[1]->z,   vp.Vertex[2]->z );
          #else
           min = *vp.Vertex[0];
           max = *vp.Vertex[0];
           min.Min(  *vp.Vertex[1] );
           max.Max(  *vp.Vertex[1] );
           min.Min(  *vp.Vertex[2] );
           max.Max(  *vp.Vertex[2] );
          #endif
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the collision model. This can be used to handle dynamic meshes. Usage is:
           * 1. modify your mesh vertices (  keep the topology constant! )
           * 2. refit the tree (  call this method )
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     342  bool HybridModel::Refit(   )
          {
           if(  !mIMesh ) return false;
           if(  !mTree ) return false;
          
           if(  IsQuantized(   ) ) return false;
           if(  HasLeafNodes(   ) ) return false;
          
           const LeafTriangles* LT = GetLeafTriangles(   );
           const udword* Indices = GetIndices(   );
          
           // Bottom-up update
           VertexPointers VP;
           IceMaths::Point Min,  Max;
           IceMaths::Point Min_,  Max_;
           udword Index = mTree->GetNbNodes(   );
           AABBNoLeafNode* Nodes = (  AABBNoLeafNode* )(  (  AABBNoLeafTree* )mTree )->GetNodes(   );
           while(  Index-- )
           {
           AABBNoLeafNode& Current = Nodes[Index];
          
           if(  Current.HasPosLeaf(   ) )
           {
           const LeafTriangles& CurrentLeaf = LT[Current.GetPosPrimitive(   )];
          
           Min.SetPlusInfinity(   );
           Max.SetMinusInfinity(   );
          
           IceMaths::Point TmpMin,   TmpMax;
          
           // Each leaf box has a set of triangles
           udword NbTris = CurrentLeaf.GetNbTriangles(   );
           if(  Indices )
           {
           const udword* T = &Indices[CurrentLeaf.GetTriangleIndex(   )];
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           mIMesh->GetTriangle(  VP,   *T++ );
           ComputeMinMax(  TmpMin,   TmpMax,   VP );
           Min.Min(  TmpMin );
           Max.Max(  TmpMax );
           }
           }
           else
           {
           udword BaseIndex = CurrentLeaf.GetTriangleIndex(   );
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           mIMesh->GetTriangle(  VP,   BaseIndex++ );
           ComputeMinMax(  TmpMin,   TmpMax,   VP );
           Min.Min(  TmpMin );
           Max.Max(  TmpMax );
           }
           }
           }
           else
           {
           const CollisionAABB& CurrentBox = Current.GetPos(   )->mAABB;
           CurrentBox.GetMin(  Min );
           CurrentBox.GetMax(  Max );
           }
          
           if(  Current.HasNegLeaf(   ) )
           {
           const LeafTriangles& CurrentLeaf = LT[Current.GetNegPrimitive(   )];
          
           Min_.SetPlusInfinity(   );
           Max_.SetMinusInfinity(   );
          
           IceMaths::Point TmpMin,   TmpMax;
          
           // Each leaf box has a set of triangles
           udword NbTris = CurrentLeaf.GetNbTriangles(   );
           if(  Indices )
           {
           const udword* T = &Indices[CurrentLeaf.GetTriangleIndex(   )];
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           mIMesh->GetTriangle(  VP,   *T++ );
           ComputeMinMax(  TmpMin,   TmpMax,   VP );
           Min_.Min(  TmpMin );
           Max_.Max(  TmpMax );
           }
           }
           else
           {
           udword BaseIndex = CurrentLeaf.GetTriangleIndex(   );
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           mIMesh->GetTriangle(  VP,   BaseIndex++ );
           ComputeMinMax(  TmpMin,   TmpMax,   VP );
           Min_.Min(  TmpMin );
           Max_.Max(  TmpMax );
           }
           }
           }
           else
           {
           const CollisionAABB& CurrentBox = Current.GetNeg(   )->mAABB;
           CurrentBox.GetMin(  Min_ );
           CurrentBox.GetMax(  Max_ );
           }
          #ifdef OPC_USE_FCOMI
           Min.x = FCMin2(  Min.x,   Min_.x );
           Max.x = FCMax2(  Max.x,   Max_.x );
           Min.y = FCMin2(  Min.y,   Min_.y );
           Max.y = FCMax2(  Max.y,   Max_.y );
           Min.z = FCMin2(  Min.z,   Min_.z );
           Max.z = FCMax2(  Max.z,   Max_.z );
          #else
           Min.Min(  Min_ );
           Max.Max(  Max_ );
          #endif
           Current.mAABB.SetMinMax(  Min,   Max );
           }
           return true;
          }
          

./components/ogre/ogreopcode/src/Opcode/OPC_LSSCollider.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for an LSS collider.
           * \file OPC_LSSCollider.cpp
           * \author Pierre Terdiman
           * \date December,   28,   2002
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a lss-vs-tree collider.
           *
           * \class LSSCollider
           * \author Pierre Terdiman
           * \version 1.3
           * \date December,   28,   2002
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          #include "Opcode/OPC_LSSAABBOverlap.h"
          #include "Opcode/OPC_LSSTriOverlap.h"
          
          #define SET_CONTACT(  prim_index,   flag ) \
           /* Set contact status */ \
      45   mFlags |= flag; \
      46   mTouchedPrimitives->Add(  prim_index );
          
          //! LSS-triangle overlap test
          #define LSS_PRIM(  prim_index,   flag ) \
           /* Request vertices from the app */ \
      51   VertexPointers VP; mIMesh->GetTriangle(  VP,   prim_index ); \
           \
           /* Perform LSS-tri overlap test */ \
      54   if(  LSSTriOverlap(  *VP.Vertex[0],   *VP.Vertex[1],   *VP.Vertex[2] ) ) \
           { \
           SET_CONTACT(  prim_index,   flag ) \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      64  LSSCollider::LSSCollider(   )
          {
          // mCenter.Zero(   );
          // mRadius2 = 0.0f;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      75  LSSCollider::~LSSCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Generic collision query for generic OPCODE models. After the call,   access the results:
           * - with GetContactStatus(   )
           * - with GetNbTouchedPrimitives(   )
           * - with GetTouchedPrimitives(   )
           *
           * \param cache [in/out] an lss cache
           * \param lss [in] collision lss in local space
           * \param model [in] Opcode model to collide with
           * \param worldl [in] lss world matrix,   or null
           * \param worldm [in] model's world matrix,   or null
           * \return true if success
           * \warning SCALE NOT SUPPORTED IN LSS WORLD MATRIX. The LSS matrix must contain rotation & translation parts only.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      95  bool LSSCollider::Collide(  LSSCache& cache,   const IceMaths::LSS& lss,   const Model& model,   const IceMaths::Matrix4x4* worldl,   const IceMaths::Matrix4x4* worldm )
          {
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   lss,   worldl,   worldm ) ) return true;
          
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           }
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Initializes a collision query :
           * - reset stats & contact status
           * - setup matrices
           * - check temporal coherence
           *
           * \param cache [in/out] an lss cache
           * \param lss [in] lss in local space
           * \param worldl [in] lss world matrix,   or null
           * \param worldm [in] model's world matrix,   or null
           * \return TRUE if we can return immediately
           * \warning SCALE NOT SUPPORTED IN LSS WORLD MATRIX. The matrix must contain rotation & translation parts only.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     168  BOOL LSSCollider::InitQuery(  LSSCache& cache,   const IceMaths::LSS& lss,   const IceMaths::Matrix4x4* worldl,   const IceMaths::Matrix4x4* worldm )
          {
           // 1 ) Call the base method
           VolumeCollider::InitQuery(   );
          
           // 2 ) Compute LSS in model space:
           // - Precompute R^2
           mRadius2 = lss.mRadius * lss.mRadius;
           // - Compute segment
           mSeg.mP0 = lss.mP0;
           mSeg.mP1 = lss.mP1;
           // -> to world space
           if(  worldl )
           {
           mSeg.mP0 *= *worldl;
           mSeg.mP1 *= *worldl;
           }
           // -> to model space
           if(  worldm )
           {
           // Matrix normalization & scaling stripping
           IceMaths::Matrix4x4 normWorldm;
           IceMaths::NormalizePRSMatrix(   normWorldm,   mLocalScale,   *worldm  );
          
           // Invert model matrix
           IceMaths::Matrix4x4 InvWorldM;
           IceMaths::InvertPRMatrix(  InvWorldM,   normWorldm );
          
           mSeg.mP0 *= InvWorldM;
           mSeg.mP1 *= InvWorldM;
           }else
           {
           mLocalScale.Set(  1.0,  1.0,  1.0 );
           }
          
           // 3 ) Setup destination pointer
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // 4 ) Special case: 1-triangle meshes [Opcode 1.3]
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           if(  !SkipPrimitiveTests(   ) )
           {
           // We simply perform the BV-Prim overlap test each time. We assume single triangle has index 0.
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the unique triangle and the LSS (  and set contact status if needed )
           LSS_PRIM(  udword(  0 ),   OPC_CONTACT )
          
           // Return immediately regardless of status
           return TRUE;
           }
           }
          
           // 5 ) Check temporal coherence :
           if(  TemporalCoherenceEnabled(   ) )
           {
           // Here we use temporal coherence
           // => check results from previous frame before performing the collision query
           if(  FirstContactEnabled(   ) )
           {
           // We're only interested in the first contact found => test the unique previously touched face
           if(  mTouchedPrimitives->GetNbEntries(   ) )
           {
           // Get index of previously touched face = the first entry in the array
           udword PreviouslyTouchedFace = mTouchedPrimitives->GetEntry(  0 );
          
           // Then reset the array:
           // - if the overlap test below is successful,   the index we'll get added back anyway
           // - if it isn't,   then the array should be reset anyway for the normal query
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the cached triangle and the LSS (  and set contact status if needed )
           LSS_PRIM(  PreviouslyTouchedFace,   OPC_TEMPORAL_CONTACT )
          
           // Return immediately if possible
           if(  GetContactStatus(   ) ) return TRUE;
           }
           // else no face has been touched during previous query
           // => we'll have to perform a normal query
           }
           else
           {
           // We're interested in all contacts =>test the new real LSS N(  ew ) against the previous fat LSS P(  revious ):
          
           // ### rewrite this
          
           IceMaths::LSS Test(  mSeg,   lss.mRadius ); // in model space
           IceMaths::LSS Previous(  cache.Previous,   sqrtf(  cache.Previous.mRadius ) );
          
          // if(  cache.Previous.Contains(  Test ) )
           if(  IsCacheValid(  cache ) && Previous.Contains(  Test ) )
           {
           // - if N is included in P,   return previous list
           // => we simply leave the list (  mTouchedFaces ) unchanged
          
           // Set contact status if needed
           if(  mTouchedPrimitives->GetNbEntries(   ) ) mFlags |= OPC_TEMPORAL_CONTACT;
          
           // In any case we don't need to do a query
           return TRUE;
           }
           else
           {
           // - else do the query using a fat N
          
           // Reset cache since we'll about to perform a real query
           mTouchedPrimitives->Reset(   );
          
           // Make a fat sphere so that coherence will work for subsequent frames
           mRadius2 *= cache.FatCoeff;
          // mRadius2 = (  lss.mRadius * cache.FatCoeff )*(  lss.mRadius * cache.FatCoeff );
          
          
           // Update cache with query data (  signature for cached faces )
           cache.Previous.mP0 = mSeg.mP0;
           cache.Previous.mP1 = mSeg.mP1;
           cache.Previous.mRadius = mRadius2;
           }
           }
           }
           else
           {
           // Here we don't use temporal coherence => do a normal query
           mTouchedPrimitives->Reset(   );
           }
          
           return FALSE;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Collision query for vanilla AABB trees.
           * \param cache [in/out] an lss cache
           * \param lss [in] collision lss in world space
           * \param tree [in] AABB tree
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     307  bool LSSCollider::Collide(  LSSCache& cache,   const IceMaths::LSS& lss,   const AABBTree* tree )
          {
           // This is typically called for a scene tree,   full of -AABBs-,   not full of triangles.
           // So we don't really have "primitives" to deal with. Hence it doesn't work with
           // "FirstContact" + "TemporalCoherence".
           ASSERT(   !(  FirstContactEnabled(   ) && TemporalCoherenceEnabled(   ) )  );
          
           // Checkings
           if(  !tree ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   lss ) ) return true;
          
           // Perform collision query
           _Collide(  tree );
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks the LSS completely contains the box. In which case we can end the query sooner.
           * \param bc [in] box center
           * \param be [in] box extents
           * \return true if the LSS contains the whole box
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ BOOL LSSCollider::LSSContainsBox(  const IceMaths::Point& bc,   const IceMaths::Point& be )
          {
           // Not implemented
           return FALSE;
          }
          
          #define TEST_BOX_IN_LSS(  center,   extents ) \
           if(  LSSContainsBox(  center,   extents ) ) \
           { \
           /* Set contact status */ \
           mFlags |= OPC_CONTACT; \
           _Dump(  node ); \
           return; \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void LSSCollider::_Collide(  const AABBCollisionNode* node )
          {
           // Perform LSS-AABB overlap test
           if(  !LSSAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           TEST_BOX_IN_LSS(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->IsLeaf(   ) )
           {
           LSS_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void LSSCollider::_CollideNoPrimitiveTest(  const AABBCollisionNode* node )
          {
           // Perform LSS-AABB overlap test
           if(  !LSSAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           TEST_BOX_IN_LSS(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void LSSCollider::_Collide(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform LSS-AABB overlap test
           if(  !LSSAABBOverlap(  Center,   Extents ) ) return;
          
           TEST_BOX_IN_LSS(  Center,   Extents )
          
           if(  node->IsLeaf(   ) )
           {
           LSS_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void LSSCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform LSS-AABB overlap test
           if(  !LSSAABBOverlap(  Center,   Extents ) ) return;
          
           TEST_BOX_IN_LSS(  Center,   Extents )
          
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void LSSCollider::_Collide(  const AABBNoLeafNode* node )
          {
           // Perform LSS-AABB overlap test
           if(  !LSSAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           TEST_BOX_IN_LSS(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->HasPosLeaf(   ) ) { LSS_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { LSS_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void LSSCollider::_CollideNoPrimitiveTest(  const AABBNoLeafNode* node )
          {
           // Perform LSS-AABB overlap test
           if(  !LSSAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           TEST_BOX_IN_LSS(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void LSSCollider::_Collide(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform LSS-AABB overlap test
           if(  !LSSAABBOverlap(  Center,   Extents ) ) return;
          
           TEST_BOX_IN_LSS(  Center,   Extents )
          
           if(  node->HasPosLeaf(   ) ) { LSS_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { LSS_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void LSSCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform LSS-AABB overlap test
           if(  !LSSAABBOverlap(  Center,   Extents ) ) return;
          
           TEST_BOX_IN_LSS(  Center,   Extents )
          
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for vanilla AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void LSSCollider::_Collide(  const AABBTreeNode* node )
          {
           // Perform LSS-AABB overlap test
           IceMaths::Point Center,   Extents;
           node->GetAABB(   )->GetCenter(  Center );
           node->GetAABB(   )->GetExtents(  Extents );
           if(  !LSSAABBOverlap(  Center,   Extents ) ) return;
          
           if(  node->IsLeaf(   ) || LSSContainsBox(  Center,   Extents ) )
           {
           mFlags |= OPC_CONTACT;
           mTouchedPrimitives->Add(  node->GetPrimitives(   ),   node->GetNbPrimitives(   ) );
           }
           else
           {
           _Collide(  node->GetPos(   ) );
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          
          
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridLSSCollider::HybridLSSCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridLSSCollider::~HybridLSSCollider(   )
          {
          }
          
          bool HybridLSSCollider::Collide(  LSSCache& cache,   const IceMaths::LSS& lss,   const HybridModel& model,   const IceMaths::Matrix4x4* worldl,   const IceMaths::Matrix4x4* worldm )
          {
           // We don't want primitive tests here!
           mFlags |= OPC_NO_PRIMITIVE_TESTS;
          
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   lss,   worldl,   worldm ) ) return true;
          
           // Special case for 1-leaf trees
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           // Here we're supposed to perform a normal query,   except our tree has a single node,   i.e. just a few triangles
           udword Nb = mIMesh->GetNbTriangles(   );
          
           // Loop through all triangles
           for(  udword i=0;i<Nb;i++ )
           {
           LSS_PRIM(  i,   OPC_CONTACT )
           }
           return true;
           }
          
           // Override destination array since we're only going to get leaf boxes here
           mTouchedBoxes.Reset(   );
           mTouchedPrimitives = &mTouchedBoxes;
          
           // Now,   do the actual query against leaf boxes
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           }
          
           // We only have a list of boxes so far
           if(  GetContactStatus(   ) )
           {
           // Reset contact status,   since it currently only reflects collisions with leaf boxes
           Collider::InitQuery(   );
          
           // Change dest container so that we can use built-in overlap tests and get collided primitives
           cache.TouchedPrimitives.Reset(   );
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // Read touched leaf boxes
           udword Nb = mTouchedBoxes.GetNbEntries(   );
           const udword* Touched = mTouchedBoxes.GetEntries(   );
          
           const LeafTriangles* LT = model.GetLeafTriangles(   );
           const udword* Indices = model.GetIndices(   );
          
           // Loop through touched leaves
           while(  Nb-- )
           {
           const LeafTriangles& CurrentLeaf = LT[*Touched++];
          
           // Each leaf box has a set of triangles
           udword NbTris = CurrentLeaf.GetNbTriangles(   );
           if(  Indices )
           {
           const udword* T = &Indices[CurrentLeaf.GetTriangleIndex(   )];
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = *T++;
           LSS_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           else
           {
           udword BaseIndex = CurrentLeaf.GetTriangleIndex(   );
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = BaseIndex++;
           LSS_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           }
           }
          
           return true;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_MeshInterface.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a mesh interface.
           * \file OPC_MeshInterface.cpp
           * \author Pierre Terdiman
           * \date November,   27,   2002
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * This structure holds 3 vertex-pointers. It's mainly used by collision callbacks so that the app doesn't have
           * to return 3 vertices to OPCODE (  36 bytes ) but only 3 pointers (  12 bytes ). It seems better but I never profiled
           * the alternative.
           *
           * \class VertexPointers
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * This class is an interface between us and user-defined meshes. Meshes can be defined in a lot of ways,   and here we
           * try to support most of them.
           *
           * Basically you have two options:
           * - callbacks,   if OPC_USE_CALLBACKS is defined in OPC_Settings.h.
           * - else pointers.
           *
           * If using pointers,   you can also use strides or not. Strides are used when OPC_USE_STRIDE is defined.
           *
           *
           * CALLBACKS:
           *
           * Using callbacks is the most generic way to feed OPCODE with your meshes. Indeed,   you just have to give
           * access to three vertices at the end of the day. It's up to you to fetch them from your database,   using
           * whatever method you want. Hence your meshes can lie in system memory or AGP,   be indexed or not,   use 16
           * or 32-bits indices,   you can decompress them on-the-fly if needed,   etc. On the other hand,   a callback is
           * called each time OPCODE needs access to a particular triangle,   so there might be a slight overhead.
           *
           * To make things clear: geometry & topology are NOT stored in the collision system,  
           * in order to save some ram. So,   when the system needs them to perform accurate intersection
           * tests,   you're requested to provide the triangle-vertices corresponding to a given face index.
           *
           * Ex:
           *
           * \code
           * static void ColCallback(  udword triangle_index,   VertexPointers& triangle,   udword user_data )
           * {
           * // Get back Mesh0 or Mesh1 (  you also can use 2 different callbacks )
           * Mesh* MyMesh = (  Mesh* )user_data;
           * // Get correct triangle in the app-controlled database
           * const Triangle* Tri = MyMesh->GetTriangle(  triangle_index );
           * // Setup pointers to vertices for the collision system
           * triangle.Vertex[0] = MyMesh->GetVertex(  Tri->mVRef[0] );
           * triangle.Vertex[1] = MyMesh->GetVertex(  Tri->mVRef[1] );
           * triangle.Vertex[2] = MyMesh->GetVertex(  Tri->mVRef[2] );
           * }
           *
           * // Setup callbacks
           * MeshInterface0->SetCallback(  ColCallback,   udword(  Mesh0 ) );
           * MeshInterface1->SetCallback(  ColCallback,   udword(  Mesh1 ) );
           * \endcode
           *
           * Of course,   you should make this callback as fast as possible. And you're also not supposed
           * to modify the geometry *after* the collision trees have been built. The alternative was to
           * store the geometry & topology in the collision system as well (  as in RAPID ) but we have found
           * this approach to waste a lot of ram in many cases.
           *
           *
           * POINTERS:
           *
           * If you're internally using the following canonical structures:
           * - a vertex made of three 32-bits floating point values
           * - a triangle made of three 32-bits integer vertex references
           * ...then you may want to use pointers instead of callbacks. This is the same,   except OPCODE will directly
           * use provided pointers to access the topology and geometry,   without using a callback. It might be faster,  
           * but probably not as safe. Pointers have been introduced in OPCODE 1.2.
           *
           * Ex:
           *
           * \code
           * // Setup pointers
           * MeshInterface0->SetPointers(  Mesh0->GetFaces(   ),   Mesh0->GetVerts(   ) );
           * MeshInterface1->SetPointers(  Mesh1->GetFaces(   ),   Mesh1->GetVerts(   ) );
           * \endcode
           *
           *
           * STRIDES:
           *
           * If your vertices are D3D-like entities interleaving a position,   a normal and/or texture coordinates
           * (  i.e. if your vertices are FVFs ),   you might want to use a vertex stride to skip extra data OPCODE
           * doesn't need. Using a stride shouldn't be notably slower than not using it,   but it might increase
           * cache misses. Please also note that you *shouldn't* read from AGP or video-memory buffers !
           *
           *
           * In any case,   compilation flags are here to select callbacks/pointers/strides at compile time,   so
           * choose what's best for your application. All of this has been wrapped into this MeshInterface.
           *
           * \class MeshInterface
           * \author Pierre Terdiman
           * \version 1.3
           * \date November,   27,   2002
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          IceMaths::Point MeshInterface::VertexCache[3];
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     135  MeshInterface::MeshInterface(   ) :
          #ifdef OPC_USE_CALLBACKS
           mUserData (  null ),  
           mObjCallback (  null ),  
          #else
           mTris (  null ),  
           mVerts (  null ),  
           #ifdef OPC_USE_STRIDE
           mTriStride (  sizeof(  IceMaths::IndexedTriangle ) ),  
           mVertexStride (  sizeof(  IceMaths::Point ) ),  
           #endif
          #endif
           mNbTris (  0 ),  
           mNbVerts (  0 ),  
           mMIType (  MESH_TRIANGLE )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     158  MeshInterface::~MeshInterface(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks the mesh interface is valid,   i.e. things have been setup correctly.
           * \return true if valid
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     168  bool MeshInterface::IsValid(   ) const
          {
           if(  !mNbTris || !mNbVerts ) return false;
          #ifdef OPC_USE_CALLBACKS
           if(  !mObjCallback ) return false;
          #else
           //if(  !mTris || !mVerts ) return false;
           // TODO: Perform a more complete check for every type of mesh interface: triangles,   terrain,   etc.
           // (  By now,   just checking vertices - it would be nice if this method returns an error message! )
           if(  !mVerts )
           {
           //DEBUG: "There is no vertices in the model"
           return false;
           }
          #endif
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks the mesh itself is valid.
           * Currently we only look for degenerate faces.
           * \return number of degenerate faces
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     193  udword MeshInterface::CheckTopology(   ) const
          {
           // Check topology. If the model contains degenerate faces,   collision report can be wrong in some cases.
           // e.g. it happens with the standard MAX teapot. So clean your meshes first... If you don't have a mesh cleaner
           // you can try this: www.codercorner.com/Consolidation.zip
          
           udword NbDegenerate = 0;
          
           VertexPointers VP;
          
           // Using callbacks,   we don't have access to vertex indices. Nevertheless we still can check for
           // redundant vertex pointers,   which cover all possibilities (  callbacks/pointers/strides ).
           for(  udword i=0;i<mNbTris;i++ )
           {
           GetTriangle(  VP,   i );
          
           if(   (  VP.Vertex[0]==VP.Vertex[1] )
           || (  VP.Vertex[1]==VP.Vertex[2] )
           || (  VP.Vertex[2]==VP.Vertex[0] ) ) NbDegenerate++;
           }
          
           return NbDegenerate;
          }
          
          #ifdef OPC_USE_CALLBACKS
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Callback control: setups object callback. Must provide triangle-vertices for a given triangle index.
           * \param callback [in] user-defined callback
           * \param user_data [in] user-defined data
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     226  bool MeshInterface::SetCallback(  RequestCallback callback,   void* user_data )
          {
           if(  !callback ) return SetIceError(  "MeshInterface::SetCallback: callback pointer is null" );
          
           mObjCallback = callback;
           mUserData = user_data;
           return true;
          }
          #else
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Pointers control: setups object pointers. Must provide access to faces and vertices for a given object.
           * \param tris [in] pointer to triangles
           * \param verts [in] pointer to vertices
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     243  bool MeshInterface::SetPointers(  const IceMaths::IndexedTriangle* tris,   const IceMaths::Point* verts )
          {
           //if(  !tris || !verts ) return SetIceError(  "MeshInterface::SetPointers: pointer is null",   null );
          
           // TODO: Perform a more complete check for every type of mesh interface: triangles,   terrain,   etc.
           // (  By now,   just checking vertices - it would be nice if this method returns an error message! )
           if(  !verts ) return SetIceError(  "MeshInterface::SetPointers: pointer is null",   null );
          
           mTris = tris;
           mVerts = verts;
           return true;
          }
          #ifdef OPC_USE_STRIDE
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Strides control
           * \param tri_stride [in] size of a triangle in bytes. The first sizeof(  IndexedTriangle ) bytes are used to get vertex indices.
           * \param vertex_stride [in] size of a vertex in bytes. The first sizeof(  Point ) bytes are used to get vertex position.
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     264  bool MeshInterface::SetStrides(  udword tri_stride,   udword vertex_stride )
          {
           if(  tri_stride<sizeof(  IceMaths::IndexedTriangle ) ) return SetIceError(  "MeshInterface::SetStrides: invalid triangle stride",   null );
           if(  vertex_stride<sizeof(  IceMaths::Point ) ) return SetIceError(  "MeshInterface::SetStrides: invalid vertex stride",   null );
          
           mTriStride = tri_stride;
           mVertexStride = vertex_stride;
           return true;
          }
          #endif
          #endif
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Remaps client's mesh according to a permutation.
           * \param nb_indices [in] number of indices in the permutation (  will be checked against number of triangles )
           * \param permutation [in] list of triangle indices
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     284  bool MeshInterface::RemapClient(  udword nb_indices,   const udword* permutation ) const
          {
           // Checkings
           if(  !nb_indices || !permutation ) return false;
           if(  nb_indices!=mNbTris ) return false;
          
          #ifdef OPC_USE_CALLBACKS
           // We can't really do that using callbacks
           return false;
          #else
           if(   mTris  )
           {
           IceMaths::IndexedTriangle* Tmp = new IceMaths::IndexedTriangle[mNbTris];
           CHECKALLOC(  Tmp );
          
           #ifdef OPC_USE_STRIDE
           udword Stride = mTriStride;
           #else
           udword Stride = sizeof(  IceMaths::IndexedTriangle );
           #endif
          
           for(  udword i=0;i<mNbTris;i++ )
           {
           const IceMaths::IndexedTriangle* T = (  const IceMaths::IndexedTriangle* )(  (  (  ubyte* )mTris ) + i * Stride );
           Tmp[i] = *T;
           }
          
           for(  udword i=0;i<mNbTris;i++ )
           {
           IceMaths::IndexedTriangle* T = (  IceMaths::IndexedTriangle* )(  (  (  ubyte* )mTris ) + i * Stride );
           *T = Tmp[permutation[i]];
           }
          
           DELETEARRAY(  Tmp );
           }
          #endif
           return true;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_Model.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for OPCODE models.
           * \file OPC_Model.cpp
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * The main collision wrapper,   for all trees. Supported trees are:
           * - Normal trees (  2*N-1 nodes,   full size )
           * - No-leaf trees (  N-1 nodes,   full size )
           * - Quantized trees (  2*N-1 nodes,   half size )
           * - Quantized no-leaf trees (  N-1 nodes,   half size )
           *
           * Usage:
           *
           * 1 ) Create a static mesh interface using callbacks or pointers. (  see OPC_MeshInterface.cpp ).
           * Keep it around in your app,   since a pointer to this interface is saved internally and
           * used until you release the collision structures.
           *
           * 2 ) Build a Model using a creation structure:
           *
           * \code
           * Model Sample;
           *
           * OPCODECREATE OPCC;
           * OPCC.IMesh = ...;
           * OPCC.Rules = ...;
           * OPCC.NoLeaf = ...;
           * OPCC.Quantized = ...;
           * OPCC.KeepOriginal = ...;
           * bool Status = Sample.Build(  OPCC );
           * \endcode
           *
           * 3 ) Create a tree collider and set it up:
           *
           * \code
           * AABBTreeCollider TC;
           * TC.SetFirstContact(  ... );
           * TC.SetFullBoxBoxTest(  ... );
           * TC.SetFullPrimBoxTest(  ... );
           * TC.SetTemporalCoherence(  ... );
           * \endcode
           *
           * 4 ) Perform a collision query
           *
           * \code
           * // Setup cache
           * static BVTCache ColCache;
           * ColCache.Model0 = &Model0;
           * ColCache.Model1 = &Model1;
           *
           * // Collision query
           * bool IsOk = TC.Collide(  ColCache,   World0,   World1 );
           *
           * // Get collision status => if true,   objects overlap
           * BOOL Status = TC.GetContactStatus(   );
           *
           * // Number of colliding pairs and list of pairs
           * udword NbPairs = TC.GetNbPairs(   );
           * const Pair* p = TC.GetPairs(   )
           * \endcode
           *
           * 5 ) Stats
           *
           * \code
           * Model0.GetUsedBytes(   ) = number of bytes used for this collision tree
           * TC.GetNbBVBVTests(   ) = number of BV-BV overlap tests performed during last query
           * TC.GetNbPrimPrimTests(   ) = number of Triangle-Triangle overlap tests performed during last query
           * TC.GetNbBVPrimTests(   ) = number of Triangle-BV overlap tests performed during last query
           * \endcode
           *
           * \class Model
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     102  Model::Model(   )
          {
          #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE !
           mHull = null;
          #endif // __MESHMERIZER_H__
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     114  Model::~Model(   )
          {
           Release(   );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Releases the model.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     124  void Model::Release(   )
          {
           ReleaseBase(   );
          #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE !
           DELETESINGLE(  mHull );
          #endif // __MESHMERIZER_H__
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds a collision model.
           * \param create [in] model creation structure
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     139  bool Model::Build(  const OPCODECREATE& create )
          {
           // 1 ) Checkings
           if(  !create.mIMesh || !create.mIMesh->IsValid(   ) ) return false;
          
           // For this model,   we only support complete trees
           if(  create.mSettings.mLimit!=1 ) return SetIceError(  "OPCODE WARNING: supports complete trees only! Use mLimit = 1.\n",   null );
          
           // Look for degenerate faces.
           udword NbDegenerate = create.mIMesh->CheckTopology(   );
           if(  NbDegenerate ) OpcodeLog(  "OPCODE WARNING: found %d degenerate faces in model! Collision might report wrong results!\n",   NbDegenerate );
           // We continue nonetheless....
          
           Release(   ); // Make sure previous tree has been discarded [Opcode 1.3,   thanks Adam]
          
           // 1-1 ) Setup mesh interface automatically [Opcode 1.3]
           SetMeshInterface(  create.mIMesh );
          
           // Special case for 1-triangle meshes [Opcode 1.3]
           udword NbTris = create.mIMesh->GetNbTriangles(   );
           if(  NbTris==1 )
           {
           // We don't need to actually create a tree here,   since we'll only have a single triangle to deal with anyway.
           // It's a waste to use a "model" for this but at least it will work.
           mModelCode |= OPC_SINGLE_NODE;
           return true;
           }
          
           // 2 ) Build a generic AABB Tree.
           mSource = new AABBTree;
           CHECKALLOC(  mSource );
          
           // 2-1 ) Setup a builder. Our primitives here are triangles from input mesh,  
           // so we use an AABBTreeOfTrianglesBuilder.....
           {
           AABBTreeOfTrianglesBuilder TB;
           TB.mIMesh = create.mIMesh;
           TB.mSettings = create.mSettings;
           TB.mNbPrimitives = NbTris;
           if(  !mSource->Build(  &TB ) ) return false;
           }
          
           // 3 ) Create an optimized tree according to user-settings
           if(  !CreateTree(  create.mNoLeaf,   create.mQuantized ) ) return false;
          
           // 3-2 ) Create optimized tree
           if(  !mTree->Build(  mSource ) ) return false;
          
           // 3-3 ) Delete generic tree if needed
           if(  !create.mKeepOriginal ) DELETESINGLE(  mSource );
          
          #ifdef __MESHMERIZER_H__
           // 4 ) Convex hull
           if(  create.mCollisionHull )
           {
           // Create hull
           mHull = new CollisionHull;
           CHECKALLOC(  mHull );
          
           CONVEXHULLCREATE CHC;
           // ### doesn't work with strides
           CHC.NbVerts = create.mIMesh->GetNbVertices(   );
           CHC.Vertices = create.mIMesh->GetVerts(   );
           CHC.UnifyNormals = true;
           CHC.ReduceVertices = true;
           CHC.WordFaces = false;
           mHull->Compute(  CHC );
           }
          #endif // __MESHMERIZER_H__
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Gets the number of bytes used by the tree.
           * \return amount of bytes used
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     218  udword Model::GetUsedBytes(   ) const
          {
           if(  !mTree ) return 0;
           return mTree->GetUsedBytes(   );
          }

./components/ogre/ogreopcode/src/Opcode/OPC_OBBCollider.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for an OBB collider.
           * \file OPC_OBBCollider.cpp
           * \author Pierre Terdiman
           * \date January,   1st,   2002
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains an OBB-vs-tree collider.
           *
           * \class OBBCollider
           * \author Pierre Terdiman
           * \version 1.3
           * \date January,   1st,   2002
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          using namespace IceMaths;
          
          #include "Opcode/OPC_BoxBoxOverlap.h"
          #include "Opcode/OPC_TriBoxOverlap.h"
          
          #define SET_CONTACT(  prim_index,   flag ) \
           /* Set contact status */ \
      41   mFlags |= flag; \
      42   mTouchedPrimitives->Add(  prim_index );
          
          //! OBB-triangle test
          #define OBB_PRIM(  prim_index,   flag ) \
           /* Request vertices from the app */ \
      47   VertexPointers VP; mIMesh->GetTriangle(  VP,   prim_index ); \
           /* Transform them in a common space with scales */ \
      49   TransformPoint(  mLeafVerts[0],   *VP.Vertex[0],   mSRModelToBox,   mTModelToBox ); \
      50   TransformPoint(  mLeafVerts[1],   *VP.Vertex[1],   mSRModelToBox,   mTModelToBox ); \
      51   TransformPoint(  mLeafVerts[2],   *VP.Vertex[2],   mSRModelToBox,   mTModelToBox ); \
           /* Perform triangle-box overlap test */ \
           if(  TriBoxOverlap(   ) ) \
           { \
           SET_CONTACT(  prim_index,   flag ) \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          OBBCollider::OBBCollider(   ) : mFullBoxBoxTest(  true )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          OBBCollider::~OBBCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Validates current settings. You should call this method after all the settings and callbacks have been defined.
           * \return null if everything is ok,   else a string describing the problem
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          const char* OBBCollider::ValidateSettings(   )
          {
           if(  TemporalCoherenceEnabled(   ) && !FirstContactEnabled(   ) ) return "Temporal coherence only works with ""First contact"" mode!";
          
           return VolumeCollider::ValidateSettings(   );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Generic collision query for generic OPCODE models. After the call,   access the results:
           * - with GetContactStatus(   )
           * - with GetNbTouchedPrimitives(   )
           * - with GetTouchedPrimitives(   )
           *
           * \param cache [in/out] a box cache
           * \param box [in] collision OBB in local space
           * \param model [in] Opcode model to collide with
           * \param worldb [in] OBB's world matrix,   or null
           * \param worldm [in] model's world matrix,   or null
           * \return true if success
           * \warning SCALE NOT SUPPORTED IN THE BOX WORLD MATRIX. The matrix must contain rotation & translation parts only.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool OBBCollider::Collide(  OBBCache& cache,   const IceMaths::OBB& box,   const Model& model,   const IceMaths::Matrix4x4* worldb,   const IceMaths::Matrix4x4* worldm )
          {
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   box,   worldb,   worldm ) ) return true;
          
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           }
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Initializes a collision query :
           * - reset stats & contact status
           * - setup matrices
           * - check temporal coherence
           *
           * \param cache [in/out] a box cache
           * \param box [in] obb in local space
           * \param worldb [in] obb's world matrix,   or null
           * \param worldm [in] model's world matrix,   or null
           * \return TRUE if we can return immediately
           * \warning SCALE NOT SUPPORTED IN OBB WORLD MATRIX. The matrix must contain rotation & translation parts only.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          BOOL OBBCollider::InitQuery(  OBBCache& cache,   const IceMaths::OBB& box,   const IceMaths::Matrix4x4* worldb,   const IceMaths::Matrix4x4* worldm )
          {
           // 1 ) Call the base method
           VolumeCollider::InitQuery(   );
          
           // 2 ) Compute obb in world space
           mBoxExtents = box.mExtents;
          
           IceMaths::Matrix4x4 WorldB;
          
           if(  worldb )
           {
           // normalizes world matrix and gets scale
           Point obbScale;
           Matrix4x4 normWorldB;
           NormalizePRSMatrix(   normWorldB,   obbScale,   *worldb  );
          
           WorldB = Matrix4x4(   box.mRot * Matrix3x3(  normWorldB )  );
          
           // note that scale is pre-applied to center and extents
           WorldB.SetTrans(  (  box.mCenter*obbScale ) * normWorldB );
           mBoxExtents *= obbScale;
           }
           else
           {
           WorldB = box.mRot;
           WorldB.SetTrans(  box.mCenter );
           }
          
           // Setup matrices
           IceMaths::Matrix4x4 InvWorldB;
           InvertPRMatrix(  InvWorldB,   WorldB );
          
           if(  worldm )
           {
           // Matrix normalization & scaling stripping
           IceMaths::Matrix4x4 normWorldM;
           NormalizePRSMatrix(   normWorldM,   mLocalScale,   *worldm  );
          
           // uses the PR part of the world matrix
           IceMaths::Matrix4x4 InvWorldM;
           InvertPRMatrix(  InvWorldM,   normWorldM );
          
           IceMaths::Matrix4x4 WorldBtoM = WorldB * InvWorldM;
           IceMaths::Matrix4x4 WorldMtoB = normWorldM * InvWorldB;
           mSRModelToBox = *worldm * InvWorldB; // for scales
          
           mRModelToBox = WorldMtoB; WorldMtoB.GetTrans(  mTModelToBox );
           mRBoxToModel = WorldBtoM; WorldBtoM.GetTrans(  mTBoxToModel );
           }
           else
           {
           mLocalScale.Set(  1.0,  1.0,  1.0 );
           mSRModelToBox = mRModelToBox = InvWorldB; InvWorldB.GetTrans(  mTModelToBox );
           mRBoxToModel = WorldB; WorldB.GetTrans(  mTBoxToModel );
           }
          
           // 3 ) Setup destination pointer
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // 4 ) Special case: 1-triangle meshes [Opcode 1.3]
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           if(  !SkipPrimitiveTests(   ) )
           {
           // We simply perform the BV-Prim overlap test each time. We assume single triangle has index 0.
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the unique triangle and the box (  and set contact status if needed )
           OBB_PRIM(  udword(  0 ),   OPC_CONTACT )
          
           // Return immediately regardless of status
           return TRUE;
           }
           }
          
           // 5 ) Check temporal coherence:
           if(  TemporalCoherenceEnabled(   ) )
           {
           // Here we use temporal coherence
           // => check results from previous frame before performing the collision query
           if(  FirstContactEnabled(   ) )
           {
           // We're only interested in the first contact found => test the unique previously touched face
           if(  mTouchedPrimitives->GetNbEntries(   ) )
           {
           // Get index of previously touched face = the first entry in the array
           udword PreviouslyTouchedFace = mTouchedPrimitives->GetEntry(  0 );
          
           // Then reset the array:
           // - if the overlap test below is successful,   the index we'll get added back anyway
           // - if it isn't,   then the array should be reset anyway for the normal query
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the cached triangle and the box (  and set contact status if needed )
           OBB_PRIM(  PreviouslyTouchedFace,   OPC_TEMPORAL_CONTACT )
          
           // Return immediately if possible
           if(  GetContactStatus(   ) ) return TRUE;
           }
           // else no face has been touched during previous query
           // => we'll have to perform a normal query
           }
           else
           {
           // ### rewrite this
           IceMaths::OBB TestBox(  mTBoxToModel,   mBoxExtents,   mRBoxToModel );
          
           // We're interested in all contacts =>test the new real box N(  ew ) against the previous fat box P(  revious ):
           if(  IsCacheValid(  cache ) && TestBox.IsInside(  cache.FatBox ) )
           {
           // - if N is included in P,   return previous list
           // => we simply leave the list (  mTouchedFaces ) unchanged
          
           // Set contact status if needed
           if(  mTouchedPrimitives->GetNbEntries(   ) ) mFlags |= OPC_TEMPORAL_CONTACT;
          
           // In any case we don't need to do a query
           return TRUE;
           }
           else
           {
           // - else do the query using a fat N
          
           // Reset cache since we'll about to perform a real query
           mTouchedPrimitives->Reset(   );
          
           // Make a fat box so that coherence will work for subsequent frames
           TestBox.mExtents *= cache.FatCoeff;
           mBoxExtents *= cache.FatCoeff;
          
           // Update cache with query data (  signature for cached faces )
           cache.FatBox = TestBox;
           }
           }
           }
           else
           {
           // Here we don't use temporal coherence => do a normal query
           mTouchedPrimitives->Reset(   );
           }
          
           // Now we can precompute box-box data
          
           // Precompute absolute box-to-model rotation matrix
           for(  udword i=0;i<3;i++ )
           {
           for(  udword j=0;j<3;j++ )
           {
           // Epsilon value prevents floating-point inaccuracies (  strategy borrowed from RAPID )
           mAR.m[i][j] = 1e-6f + fabsf(  mRBoxToModel.m[i][j] );
           }
           }
          
           // Precompute bounds for box-in-box test
           mB0 = mBoxExtents - mTModelToBox;
           mB1 = - mBoxExtents - mTModelToBox;
          
           // Precompute box-box data - Courtesy of Erwin de Vries
           mBBx1 = mBoxExtents.x*mAR.m[0][0] + mBoxExtents.y*mAR.m[1][0] + mBoxExtents.z*mAR.m[2][0];
           mBBy1 = mBoxExtents.x*mAR.m[0][1] + mBoxExtents.y*mAR.m[1][1] + mBoxExtents.z*mAR.m[2][1];
           mBBz1 = mBoxExtents.x*mAR.m[0][2] + mBoxExtents.y*mAR.m[1][2] + mBoxExtents.z*mAR.m[2][2];
          
           mBB_1 = mBoxExtents.y*mAR.m[2][0] + mBoxExtents.z*mAR.m[1][0];
           mBB_2 = mBoxExtents.x*mAR.m[2][0] + mBoxExtents.z*mAR.m[0][0];
           mBB_3 = mBoxExtents.x*mAR.m[1][0] + mBoxExtents.y*mAR.m[0][0];
           mBB_4 = mBoxExtents.y*mAR.m[2][1] + mBoxExtents.z*mAR.m[1][1];
           mBB_5 = mBoxExtents.x*mAR.m[2][1] + mBoxExtents.z*mAR.m[0][1];
           mBB_6 = mBoxExtents.x*mAR.m[1][1] + mBoxExtents.y*mAR.m[0][1];
           mBB_7 = mBoxExtents.y*mAR.m[2][2] + mBoxExtents.z*mAR.m[1][2];
           mBB_8 = mBoxExtents.x*mAR.m[2][2] + mBoxExtents.z*mAR.m[0][2];
           mBB_9 = mBoxExtents.x*mAR.m[1][2] + mBoxExtents.y*mAR.m[0][2];
          
           return FALSE;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks the OBB completely contains the box. In which case we can end the query sooner.
           * \param bc [in] box center
           * \param be [in] box extents
           * \return true if the OBB contains the whole box
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ BOOL OBBCollider::OBBContainsBox(  const IceMaths::Point& bc_,   const IceMaths::Point& be_ )
          {
           // Applies the model's local scale
           const IceMaths::Point bc = bc_ * mLocalScale;
           const IceMaths::Point be = be_ * mLocalScale;
          
           // I assume if all 8 box vertices are inside the OBB,   so does the whole box.
           // Sounds ok but maybe there's a better way?
          /*
          #define TEST_PT(  a,  b,  c ) \
           p.x=a; p.y=b; p.z=c; p+=bc; \
           f = p.x * mRModelToBox.m[0][0] + p.y * mRModelToBox.m[1][0] + p.z * mRModelToBox.m[2][0]; if(  f>mB0.x || f<mB1.x ) return FALSE;\
           f = p.x * mRModelToBox.m[0][1] + p.y * mRModelToBox.m[1][1] + p.z * mRModelToBox.m[2][1]; if(  f>mB0.y || f<mB1.y ) return FALSE;\
           f = p.x * mRModelToBox.m[0][2] + p.y * mRModelToBox.m[1][2] + p.z * mRModelToBox.m[2][2]; if(  f>mB0.z || f<mB1.z ) return FALSE;
          
           Point p;
           float f;
          
           TEST_PT(  be.x,   be.y,   be.z )
           TEST_PT(  -be.x,   be.y,   be.z )
           TEST_PT(  be.x,   -be.y,   be.z )
           TEST_PT(  -be.x,   -be.y,   be.z )
           TEST_PT(  be.x,   be.y,   -be.z )
           TEST_PT(  -be.x,   be.y,   -be.z )
           TEST_PT(  be.x,   -be.y,   -be.z )
           TEST_PT(  -be.x,   -be.y,   -be.z )
          
           return TRUE;
          */
          
           // Yes there is:
           // - compute model-box's AABB in OBB space
           // - test AABB-in-AABB
           float NCx = bc.x * mRModelToBox.m[0][0] + bc.y * mRModelToBox.m[1][0] + bc.z * mRModelToBox.m[2][0];
           float NEx = fabsf(  mRModelToBox.m[0][0] * be.x ) + fabsf(  mRModelToBox.m[1][0] * be.y ) + fabsf(  mRModelToBox.m[2][0] * be.z );
          
           if(  mB0.x < NCx+NEx ) return FALSE;
           if(  mB1.x > NCx-NEx ) return FALSE;
          
           float NCy = bc.x * mRModelToBox.m[0][1] + bc.y * mRModelToBox.m[1][1] + bc.z * mRModelToBox.m[2][1];
           float NEy = fabsf(  mRModelToBox.m[0][1] * be.x ) + fabsf(  mRModelToBox.m[1][1] * be.y ) + fabsf(  mRModelToBox.m[2][1] * be.z );
          
           if(  mB0.y < NCy+NEy ) return FALSE;
           if(  mB1.y > NCy-NEy ) return FALSE;
          
           float NCz = bc.x * mRModelToBox.m[0][2] + bc.y * mRModelToBox.m[1][2] + bc.z * mRModelToBox.m[2][2];
           float NEz = fabsf(  mRModelToBox.m[0][2] * be.x ) + fabsf(  mRModelToBox.m[1][2] * be.y ) + fabsf(  mRModelToBox.m[2][2] * be.z );
          
           if(  mB0.z < NCz+NEz ) return FALSE;
           if(  mB1.z > NCz-NEz ) return FALSE;
          
           return TRUE;
          }
          
          #define TEST_BOX_IN_OBB(  center,   extents ) \
           if(  OBBContainsBox(  center,   extents ) ) \
           { \
           /* Set contact status */ \
           mFlags |= OPC_CONTACT; \
           _Dump(  node ); \
           return; \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void OBBCollider::_Collide(  const AABBCollisionNode* node )
          {
           // Perform OBB-AABB overlap test
           if(  !BoxBoxOverlap(  node->mAABB.mExtents,   node->mAABB.mCenter ) ) return;
          
           TEST_BOX_IN_OBB(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->IsLeaf(   ) )
           {
           OBB_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void OBBCollider::_CollideNoPrimitiveTest(  const AABBCollisionNode* node )
          {
           // Perform OBB-AABB overlap test
           if(  !BoxBoxOverlap(  node->mAABB.mExtents,   node->mAABB.mCenter ) ) return;
          
           TEST_BOX_IN_OBB(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void OBBCollider::_Collide(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform OBB-AABB overlap test
           if(  !BoxBoxOverlap(  Extents,   Center ) ) return;
          
           TEST_BOX_IN_OBB(  Center,   Extents )
          
           if(  node->IsLeaf(   ) )
           {
           OBB_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void OBBCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform OBB-AABB overlap test
           if(  !BoxBoxOverlap(  Extents,   Center ) ) return;
          
           TEST_BOX_IN_OBB(  Center,   Extents )
          
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void OBBCollider::_Collide(  const AABBNoLeafNode* node )
          {
           // Perform OBB-AABB overlap test
           if(  !BoxBoxOverlap(  node->mAABB.mExtents,   node->mAABB.mCenter ) ) return;
          
           TEST_BOX_IN_OBB(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->HasPosLeaf(   ) ) { OBB_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { OBB_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void OBBCollider::_CollideNoPrimitiveTest(  const AABBNoLeafNode* node )
          {
           // Perform OBB-AABB overlap test
           if(  !BoxBoxOverlap(  node->mAABB.mExtents,   node->mAABB.mCenter ) ) return;
          
           TEST_BOX_IN_OBB(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void OBBCollider::_Collide(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform OBB-AABB overlap test
           if(  !BoxBoxOverlap(  Extents,   Center ) ) return;
          
           TEST_BOX_IN_OBB(  Center,   Extents )
          
           if(  node->HasPosLeaf(   ) ) { OBB_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { OBB_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void OBBCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform OBB-AABB overlap test
           if(  !BoxBoxOverlap(  Extents,   Center ) ) return;
          
           TEST_BOX_IN_OBB(  Center,   Extents )
          
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ) );
          }
          
          
          
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridOBBCollider::HybridOBBCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridOBBCollider::~HybridOBBCollider(   )
          {
          }
          
          bool HybridOBBCollider::Collide(  OBBCache& cache,   const IceMaths::OBB& box,   const HybridModel& model,   const IceMaths::Matrix4x4* worldb,   const IceMaths::Matrix4x4* worldm )
          {
           // We don't want primitive tests here!
           mFlags |= OPC_NO_PRIMITIVE_TESTS;
          
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   box,   worldb,   worldm ) ) return true;
          
           // Special case for 1-leaf trees
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           // Here we're supposed to perform a normal query,   except our tree has a single node,   i.e. just a few triangles
           udword Nb = mIMesh->GetNbTriangles(   );
          
           // Loop through all triangles
           for(  udword i=0;i<Nb;i++ )
           {
           OBB_PRIM(  i,   OPC_CONTACT )
           }
           return true;
           }
          
           // Override destination array since we're only going to get leaf boxes here
           mTouchedBoxes.Reset(   );
           mTouchedPrimitives = &mTouchedBoxes;
          
           // Now,   do the actual query against leaf boxes
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           }
          
           // We only have a list of boxes so far
           if(  GetContactStatus(   ) )
           {
           // Reset contact status,   since it currently only reflects collisions with leaf boxes
           Collider::InitQuery(   );
          
           // Change dest container so that we can use built-in overlap tests and get collided primitives
           cache.TouchedPrimitives.Reset(   );
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // Read touched leaf boxes
           udword Nb = mTouchedBoxes.GetNbEntries(   );
           const udword* Touched = mTouchedBoxes.GetEntries(   );
          
           const LeafTriangles* LT = model.GetLeafTriangles(   );
           const udword* Indices = model.GetIndices(   );
          
           // Loop through touched leaves
           while(  Nb-- )
           {
           const LeafTriangles& CurrentLeaf = LT[*Touched++];
          
           // Each leaf box has a set of triangles
           udword NbTris = CurrentLeaf.GetNbTriangles(   );
           if(  Indices )
           {
           const udword* T = &Indices[CurrentLeaf.GetTriangleIndex(   )];
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = *T++;
           OBB_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           else
           {
           udword BaseIndex = CurrentLeaf.GetTriangleIndex(   );
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = BaseIndex++;
           OBB_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           }
           }
          
           return true;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_OptimizedTree.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for optimized trees. Implements 4 trees:
           * - normal
           * - no leaf
           * - quantized
           * - no leaf / quantized
           *
           * \file OPC_OptimizedTree.cpp
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * A standard AABB tree.
           *
           * \class AABBCollisionTree
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * A no-leaf AABB tree.
           *
           * \class AABBNoLeafTree
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * A quantized AABB tree.
           *
           * \class AABBQuantizedTree
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * A quantized no-leaf AABB tree.
           *
           * \class AABBQuantizedNoLeafTree
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          //! Compilation flag:
          //! - true to fix quantized boxes (  i.e. make sure they enclose the original ones )
          //! - false to see the effects of quantization errors (  faster,   but wrong results in some cases )
          static bool gFixQuantized = true;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds an implicit tree from a standard one. An implicit tree is a complete tree (  2*N-1 nodes ) whose negative
           * box pointers and primitive pointers have been made implicit,   hence packing 3 pointers in one.
           *
           * Layout for implicit trees:
           * Node:
           * - box
           * - data (  32-bits value )
           *
           * if data's LSB = 1 => remaining bits are a primitive pointer
           * else remaining bits are a P-node pointer,   and N = P + 1
           *
           * \relates AABBCollisionNode
           * \fn _BuildCollisionTree(  AABBCollisionNode* linear,   const udword box_id,   udword& current_id,   const AABBTreeNode* current_node )
           * \param linear [in] base address of destination nodes
           * \param box_id [in] index of destination node
           * \param current_id [in] current running index
           * \param current_node [in] current node from input tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      99  static void _BuildCollisionTree(  AABBCollisionNode* linear,   const udword box_id,   udword& current_id,   const AABBTreeNode* current_node )
          {
           // Current node from input tree is "current_node". Must be flattened into "linear[boxid]".
          
           // Store the AABB
           current_node->GetAABB(   )->GetCenter(  linear[box_id].mAABB.mCenter );
           current_node->GetAABB(   )->GetExtents(  linear[box_id].mAABB.mExtents );
           // Store remaining info
           if(  current_node->IsLeaf(   ) )
           {
           // The input tree must be complete => i.e. one primitive/leaf
           ASSERT(  current_node->GetNbPrimitives(   )==1 );
           // Get the primitive index from the input tree
           udword PrimitiveIndex = current_node->GetPrimitives(   )[0];
           // Setup box data as the primitive index,   marked as leaf
           linear[box_id].mData = (  PrimitiveIndex<<1 )|1;
           }
           else
           {
           // To make the negative one implicit,   we must store P and N in successive order
           udword PosID = current_id++; // Get a new id for positive child
           udword NegID = current_id++; // Get a new id for negative child
           // Setup box data as the forthcoming new P pointer
           linear[box_id].mData = (  size_t )&linear[PosID];
           // Make sure it's not marked as leaf
           ASSERT(  !(  linear[box_id].mData&1 ) );
           // Recurse with new IDs
           _BuildCollisionTree(  linear,   PosID,   current_id,   current_node->GetPos(   ) );
           _BuildCollisionTree(  linear,   NegID,   current_id,   current_node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds a "no-leaf" tree from a standard one. This is a tree whose leaf nodes have been removed.
           *
           * Layout for no-leaf trees:
           *
           * Node:
           * - box
           * - P pointer => a node (  LSB=0 ) or a primitive (  LSB=1 )
           * - N pointer => a node (  LSB=0 ) or a primitive (  LSB=1 )
           *
           * \relates AABBNoLeafNode
           * \fn _BuildNoLeafTree(  AABBNoLeafNode* linear,   const udword box_id,   udword& current_id,   const AABBTreeNode* current_node )
           * \param linear [in] base address of destination nodes
           * \param box_id [in] index of destination node
           * \param current_id [in] current running index
           * \param current_node [in] current node from input tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     150  static void _BuildNoLeafTree(  AABBNoLeafNode* linear,   const udword box_id,   udword& current_id,   const AABBTreeNode* current_node )
          {
           const AABBTreeNode* P = current_node->GetPos(   );
           const AABBTreeNode* N = current_node->GetNeg(   );
           // Leaf nodes here?!
           ASSERT(  P );
           ASSERT(  N );
           // Internal node => keep the box
           current_node->GetAABB(   )->GetCenter(  linear[box_id].mAABB.mCenter );
           current_node->GetAABB(   )->GetExtents(  linear[box_id].mAABB.mExtents );
          
           if(  P->IsLeaf(   ) )
           {
           // The input tree must be complete => i.e. one primitive/leaf
           ASSERT(  P->GetNbPrimitives(   )==1 );
           // Get the primitive index from the input tree
           udword PrimitiveIndex = P->GetPrimitives(   )[0];
           // Setup prev box data as the primitive index,   marked as leaf
           linear[box_id].mPosData = (  PrimitiveIndex<<1 )|1;
           }
           else
           {
           // Get a new id for positive child
           udword PosID = current_id++;
           // Setup box data
           linear[box_id].mPosData = (  size_t )&linear[PosID];
           // Make sure it's not marked as leaf
           ASSERT(  !(  linear[box_id].mPosData&1 ) );
           // Recurse
           _BuildNoLeafTree(  linear,   PosID,   current_id,   P );
           }
          
           if(  N->IsLeaf(   ) )
           {
           // The input tree must be complete => i.e. one primitive/leaf
           ASSERT(  N->GetNbPrimitives(   )==1 );
           // Get the primitive index from the input tree
           udword PrimitiveIndex = N->GetPrimitives(   )[0];
           // Setup prev box data as the primitive index,   marked as leaf
           linear[box_id].mNegData = (  PrimitiveIndex<<1 )|1;
           }
           else
           {
           // Get a new id for negative child
           udword NegID = current_id++;
           // Setup box data
           linear[box_id].mNegData = (  size_t )&linear[NegID];
           // Make sure it's not marked as leaf
           ASSERT(  !(  linear[box_id].mNegData&1 ) );
           // Recurse
           _BuildNoLeafTree(  linear,   NegID,   current_id,   N );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     209  AABBCollisionTree::AABBCollisionTree(   ) : mNodes(  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     218  AABBCollisionTree::~AABBCollisionTree(   )
          {
           DELETEARRAY(  mNodes );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds the collision tree from a generic AABB tree.
           * \param tree [in] generic AABB tree
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     230  bool AABBCollisionTree::Build(  AABBTree* tree )
          {
           // Checkings
           if(  !tree ) return false;
           // Check the input tree is complete
           udword NbTriangles = tree->GetNbPrimitives(   );
           udword NbNodes = tree->GetNbNodes(   );
           if(  NbNodes!=NbTriangles*2-1 ) return false;
          
           // Get nodes
           if(  mNbNodes!=NbNodes ) // Same number of nodes => keep moving
           {
           mNbNodes = NbNodes;
           DELETEARRAY(  mNodes );
           mNodes = new AABBCollisionNode[mNbNodes];
           CHECKALLOC(  mNodes );
           }
          
           // Build the tree
           udword CurID = 1;
           _BuildCollisionTree(  mNodes,   0,   CurID,   tree );
           ASSERT(  CurID==mNbNodes );
          
           return true;
          }
          
     256  inline_ void ComputeMinMax(  IceMaths::Point& min,   IceMaths::Point& max,   const VertexPointers& vp )
          {
           // Compute triangle's AABB = a leaf box
          #ifdef OPC_USE_FCOMI // a 15% speedup on my machine,   not much
           min.x = FCMin3(  vp.Vertex[0]->x,   vp.Vertex[1]->x,   vp.Vertex[2]->x );
           max.x = FCMax3(  vp.Vertex[0]->x,   vp.Vertex[1]->x,   vp.Vertex[2]->x );
          
           min.y = FCMin3(  vp.Vertex[0]->y,   vp.Vertex[1]->y,   vp.Vertex[2]->y );
           max.y = FCMax3(  vp.Vertex[0]->y,   vp.Vertex[1]->y,   vp.Vertex[2]->y );
          
           min.z = FCMin3(  vp.Vertex[0]->z,   vp.Vertex[1]->z,   vp.Vertex[2]->z );
           max.z = FCMax3(  vp.Vertex[0]->z,   vp.Vertex[1]->z,   vp.Vertex[2]->z );
          #else
           min = *vp.Vertex[0];
           max = *vp.Vertex[0];
           min.Min(  *vp.Vertex[1] );
           max.Max(  *vp.Vertex[1] );
           min.Min(  *vp.Vertex[2] );
           max.Max(  *vp.Vertex[2] );
          #endif
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the collision tree after vertices have been modified.
           *
           * \remarks
           * OPCODE 1.3 does not provide support for refitting 'normal' collision trees
           * because they are much slower to update than no-leaf trees. This feature was
           * added in OPCODE 1.3.2 because we may want to compute between deformable models
           * using 'normal' AABB trees. The main problem here is that normal trees have twice
           * as nodes to refit than no-leaf trees.
           * The performance tests I've conduced in my engine points that normal trees are
           * roughly 2 times slower to refit than no-leaf trees. I recommend thge use of 'normal'
           * trees only when you absolutely need triangle-triangle intersections to be performed,  
           * because no-leaf trees typically outperforms normal trees in just everything. Send me
           * any questions,   comments or suggestions you have by mail {gilvanmaia@gmail.com}.
           *
           * \param mesh_interface [in] mesh interface for current model
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     298  bool AABBCollisionTree::Refit(  const MeshInterface* mesh_interface )
          {
           // (  Commented because we support it now! )
           // ASSERT(  !"Not implemented since AABBCollisionTrees have twice as more nodes to refit as AABBNoLeafTrees!" );
          
           // Checkings
           if(  !mesh_interface ) return false;
          
           // Bottom-up update
           VertexPointers VP;
           IceMaths::Point Min,  Max;
           IceMaths::Point Min_,  Max_;
           udword Index = mNbNodes;
           while(  Index-- )
           {
           AABBCollisionNode& Current = mNodes[Index];
          
           if(   Current.IsLeaf(   )  )
           {
           mesh_interface->GetTriangle(  VP,   Current.GetPrimitive(   )  );
           ComputeMinMax(  Min,   Max,   VP );
           }else
           {
           if(   Current.GetPos(   )  )
           {
           const CollisionAABB& CurrentBox = Current.GetPos(   )->mAABB;
           CurrentBox.GetMin(  Min );
           CurrentBox.GetMax(  Max );
           }
          
           if(   Current.GetNeg(   )  )
           {
           const CollisionAABB& CurrentBox = Current.GetNeg(   )->mAABB;
           CurrentBox.GetMin(  Min_ );
           CurrentBox.GetMax(  Max_ );
           }
           }
          
          #ifdef OPC_USE_FCOMI
           Min.x = FCMin2(  Min.x,   Min_.x );
           Max.x = FCMax2(  Max.x,   Max_.x );
           Min.y = FCMin2(  Min.y,   Min_.y );
           Max.y = FCMax2(  Max.y,   Max_.y );
           Min.z = FCMin2(  Min.z,   Min_.z );
           Max.z = FCMax2(  Max.z,   Max_.z );
          #else
           Min.Min(  Min_ );
           Max.Max(  Max_ );
          #endif
           Current.mAABB.SetMinMax(  Min,   Max );
           }
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Walks the tree and call the user back for each node.
           * \param callback [in] walking callback
           * \param user_data [in] callback's user data
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     360  bool AABBCollisionTree::Walk(  GenericWalkingCallback callback,   void* user_data ) const
          {
           if(  !callback ) return false;
          
           struct Local
           {
           static void _Walk(  const AABBCollisionNode* current_node,   GenericWalkingCallback callback,   void* user_data )
           {
           if(  !current_node || !(  callback )(  current_node,   user_data ) ) return;
          
           if(  !current_node->IsLeaf(   ) )
           {
           _Walk(  current_node->GetPos(   ),   callback,   user_data );
           _Walk(  current_node->GetNeg(   ),   callback,   user_data );
           }
           }
           };
           Local::_Walk(  mNodes,   callback,   user_data );
           return true;
          }
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     387  AABBNoLeafTree::AABBNoLeafTree(   ) : mNodes(  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     396  AABBNoLeafTree::~AABBNoLeafTree(   )
          {
           DELETEARRAY(  mNodes );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds the collision tree from a generic AABB tree.
           * \param tree [in] generic AABB tree
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     408  bool AABBNoLeafTree::Build(  AABBTree* tree )
          {
           // Checkings
           if(  !tree ) return false;
           // Check the input tree is complete
           udword NbTriangles = tree->GetNbPrimitives(   );
           udword NbNodes = tree->GetNbNodes(   );
           if(  NbNodes!=NbTriangles*2-1 ) return false;
          
           // Get nodes
           if(  mNbNodes!=NbTriangles-1 ) // Same number of nodes => keep moving
           {
           mNbNodes = NbTriangles-1;
           DELETEARRAY(  mNodes );
           mNodes = new AABBNoLeafNode[mNbNodes];
           CHECKALLOC(  mNodes );
           }
          
           // Build the tree
           udword CurID = 1;
           _BuildNoLeafTree(  mNodes,   0,   CurID,   tree );
           ASSERT(  CurID==mNbNodes );
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the collision tree after vertices have been modified.
           * \param mesh_interface [in] mesh interface for current model
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     441  bool AABBNoLeafTree::Refit(  const MeshInterface* mesh_interface )
          {
           // Checkings
           if(  !mesh_interface ) return false;
          
           // Bottom-up update
           VertexPointers VP;
           IceMaths::Point Min,  Max;
           IceMaths::Point Min_,  Max_;
           udword Index = mNbNodes;
           while(  Index-- )
           {
           AABBNoLeafNode& Current = mNodes[Index];
          
           if(  Current.HasPosLeaf(   ) )
           {
           mesh_interface->GetTriangle(  VP,   Current.GetPosPrimitive(   ) );
           ComputeMinMax(  Min,   Max,   VP );
           }
           else
           {
           const CollisionAABB& CurrentBox = Current.GetPos(   )->mAABB;
           CurrentBox.GetMin(  Min );
           CurrentBox.GetMax(  Max );
           }
          
           if(  Current.HasNegLeaf(   ) )
           {
           mesh_interface->GetTriangle(  VP,   Current.GetNegPrimitive(   ) );
           ComputeMinMax(  Min_,   Max_,   VP );
           }
           else
           {
           const CollisionAABB& CurrentBox = Current.GetNeg(   )->mAABB;
           CurrentBox.GetMin(  Min_ );
           CurrentBox.GetMax(  Max_ );
           }
          #ifdef OPC_USE_FCOMI
           Min.x = FCMin2(  Min.x,   Min_.x );
           Max.x = FCMax2(  Max.x,   Max_.x );
           Min.y = FCMin2(  Min.y,   Min_.y );
           Max.y = FCMax2(  Max.y,   Max_.y );
           Min.z = FCMin2(  Min.z,   Min_.z );
           Max.z = FCMax2(  Max.z,   Max_.z );
          #else
           Min.Min(  Min_ );
           Max.Max(  Max_ );
          #endif
           Current.mAABB.SetMinMax(  Min,   Max );
           }
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Walks the tree and call the user back for each node.
           * \param callback [in] walking callback
           * \param user_data [in] callback's user data
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     502  bool AABBNoLeafTree::Walk(  GenericWalkingCallback callback,   void* user_data ) const
          {
           if(  !callback ) return false;
          
           struct Local
           {
           static void _Walk(  const AABBNoLeafNode* current_node,   GenericWalkingCallback callback,   void* user_data )
           {
           if(  !current_node || !(  callback )(  current_node,   user_data ) ) return;
          
           if(  !current_node->HasPosLeaf(   ) ) _Walk(  current_node->GetPos(   ),   callback,   user_data );
           if(  !current_node->HasNegLeaf(   ) ) _Walk(  current_node->GetNeg(   ),   callback,   user_data );
           }
           };
           Local::_Walk(  mNodes,   callback,   user_data );
           return true;
          }
          
          // Quantization notes:
          // - We could use the highest bits of mData to store some more quantized bits. Dequantization code
          // would be slightly more complex,   but number of overlap tests would be reduced (  and anyhow those
          // bits are currently wasted ). Of course it's not possible if we move to 16 bits mData.
          // - Something like "16 bits floats" could be tested,   to bypass the int-to-float conversion.
          // - A dedicated BV-BV test could be used,   dequantizing while testing for overlap. (  i.e. it's some
          // lazy-dequantization which may save some work in case of early exits ). At the very least some
          // muls could be saved by precomputing several more matrices. But maybe not worth the pain.
          // - Do we need to dequantize anyway? Not doing the extents-related muls only implies the box has
          // been scaled,   for example.
          // - The deeper we move into the hierarchy,   the smaller the extents should be. May not need a fixed
          // number of quantization bits. Even better,   could probably be best delta-encoded.
          
          
          // Find max values. Some people asked why I wasn't simply using the first node. Well,   I can't.
          // I'm not looking for (  min,   max ) values like in a standard AABB,   I'm looking for the extremal
          // centers/extents in order to quantize them. The first node would only give a single center and
          // a single extents. While extents would be the biggest,   the center wouldn't.
          #define FIND_MAX_VALUES \
           /* Get max values */ \
     540   IceMaths::Point CMax(  MIN_FLOAT,   MIN_FLOAT,   MIN_FLOAT ); \
     541   IceMaths::Point EMax(  MIN_FLOAT,   MIN_FLOAT,   MIN_FLOAT ); \
           for(  udword i=0;i<mNbNodes;i++ ) \
           { \
           if(  fabsf(  Nodes[i].mAABB.mCenter.x )>CMax.x ) CMax.x = fabsf(  Nodes[i].mAABB.mCenter.x ); \
           if(  fabsf(  Nodes[i].mAABB.mCenter.y )>CMax.y ) CMax.y = fabsf(  Nodes[i].mAABB.mCenter.y ); \
           if(  fabsf(  Nodes[i].mAABB.mCenter.z )>CMax.z ) CMax.z = fabsf(  Nodes[i].mAABB.mCenter.z ); \
           if(  fabsf(  Nodes[i].mAABB.mExtents.x )>EMax.x ) EMax.x = fabsf(  Nodes[i].mAABB.mExtents.x ); \
           if(  fabsf(  Nodes[i].mAABB.mExtents.y )>EMax.y ) EMax.y = fabsf(  Nodes[i].mAABB.mExtents.y ); \
           if(  fabsf(  Nodes[i].mAABB.mExtents.z )>EMax.z ) EMax.z = fabsf(  Nodes[i].mAABB.mExtents.z ); \
           }
          
          #define INIT_QUANTIZATION \
           udword nbc=15; /* Keep one bit for sign */ \
           udword nbe=15; /* Keep one bit for fix */ \
           if(  !gFixQuantized ) nbe++; \
           \
           /* Compute quantization coeffs */ \
           IceMaths::Point CQuantCoeff,   EQuantCoeff; \
           CQuantCoeff.x = CMax.x!=0.0f ? float(  (  1<<nbc )-1 )/CMax.x : 0.0f; \
           CQuantCoeff.y = CMax.y!=0.0f ? float(  (  1<<nbc )-1 )/CMax.y : 0.0f; \
           CQuantCoeff.z = CMax.z!=0.0f ? float(  (  1<<nbc )-1 )/CMax.z : 0.0f; \
           EQuantCoeff.x = EMax.x!=0.0f ? float(  (  1<<nbe )-1 )/EMax.x : 0.0f; \
           EQuantCoeff.y = EMax.y!=0.0f ? float(  (  1<<nbe )-1 )/EMax.y : 0.0f; \
           EQuantCoeff.z = EMax.z!=0.0f ? float(  (  1<<nbe )-1 )/EMax.z : 0.0f; \
           /* Compute and save dequantization coeffs */ \
           mCenterCoeff.x = CQuantCoeff.x!=0.0f ? 1.0f / CQuantCoeff.x : 0.0f; \
           mCenterCoeff.y = CQuantCoeff.y!=0.0f ? 1.0f / CQuantCoeff.y : 0.0f; \
           mCenterCoeff.z = CQuantCoeff.z!=0.0f ? 1.0f / CQuantCoeff.z : 0.0f; \
           mExtentsCoeff.x = EQuantCoeff.x!=0.0f ? 1.0f / EQuantCoeff.x : 0.0f; \
           mExtentsCoeff.y = EQuantCoeff.y!=0.0f ? 1.0f / EQuantCoeff.y : 0.0f; \
           mExtentsCoeff.z = EQuantCoeff.z!=0.0f ? 1.0f / EQuantCoeff.z : 0.0f; \
          
          #define PERFORM_QUANTIZATION \
           /* Quantize */ \
           mNodes[i].mAABB.mCenter[0] = sword(  Nodes[i].mAABB.mCenter.x * CQuantCoeff.x ); \
           mNodes[i].mAABB.mCenter[1] = sword(  Nodes[i].mAABB.mCenter.y * CQuantCoeff.y ); \
           mNodes[i].mAABB.mCenter[2] = sword(  Nodes[i].mAABB.mCenter.z * CQuantCoeff.z ); \
           mNodes[i].mAABB.mExtents[0] = uword(  Nodes[i].mAABB.mExtents.x * EQuantCoeff.x ); \
           mNodes[i].mAABB.mExtents[1] = uword(  Nodes[i].mAABB.mExtents.y * EQuantCoeff.y ); \
           mNodes[i].mAABB.mExtents[2] = uword(  Nodes[i].mAABB.mExtents.z * EQuantCoeff.z ); \
           /* Fix quantized boxes */ \
           if(  gFixQuantized ) \
           { \
           /* Make sure the quantized box is still valid */ \
           IceMaths::Point Max = Nodes[i].mAABB.mCenter + Nodes[i].mAABB.mExtents; \
           IceMaths::Point Min = Nodes[i].mAABB.mCenter - Nodes[i].mAABB.mExtents; \
           /* For each axis */ \
           for(  udword j=0;j<3;j++ ) \
           { /* Dequantize the box center */ \
           float qc = float(  mNodes[i].mAABB.mCenter[j] ) * mCenterCoeff[j]; \
           bool FixMe=true; \
           do \
           { /* Dequantize the box extent */ \
           float qe = float(  mNodes[i].mAABB.mExtents[j] ) * mExtentsCoeff[j]; \
           /* Compare real & dequantized values */ \
           if(  qc+qe<Max[j] || qc-qe>Min[j] ) mNodes[i].mAABB.mExtents[j]++; \
           else FixMe=false; \
           /* Prevent wrapping */ \
           if(  !mNodes[i].mAABB.mExtents[j] ) \
           { \
           mNodes[i].mAABB.mExtents[j]=0xffff; \
           FixMe=false; \
           } \
           }while(  FixMe ); \
           } \
           }
          
          #define REMAP_DATA(  member ) \
           /* Fix data */ \
           Data = Nodes[i].member; \
           if(  !(  Data&1 ) ) \
           { \
           /* Compute box number */ \
           udword Nb = (  Data - size_t(  Nodes ) )/Nodes[i].GetNodeSize(   ); \
           Data = (  size_t ) &mNodes[Nb] ; \
           } \
           /* ...remapped */ \
           mNodes[i].member = Data;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          AABBQuantizedTree::AABBQuantizedTree(   ) : mNodes(  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          AABBQuantizedTree::~AABBQuantizedTree(   )
          {
           DELETEARRAY(  mNodes );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds the collision tree from a generic AABB tree.
           * \param tree [in] generic AABB tree
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBQuantizedTree::Build(  AABBTree* tree )
          {
           // Checkings
           if(  !tree ) return false;
           // Check the input tree is complete
           udword NbTriangles = tree->GetNbPrimitives(   );
           udword NbNodes = tree->GetNbNodes(   );
           if(  NbNodes!=NbTriangles*2-1 ) return false;
          
           // Get nodes
           mNbNodes = NbNodes;
           DELETEARRAY(  mNodes );
           AABBCollisionNode* Nodes = new AABBCollisionNode[mNbNodes];
           CHECKALLOC(  Nodes );
          
           // Build the tree
           udword CurID = 1;
           _BuildCollisionTree(  Nodes,   0,   CurID,   tree );
          
           // Quantize
           {
           mNodes = new AABBQuantizedNode[mNbNodes];
           CHECKALLOC(  mNodes );
          
           // Get max values
           FIND_MAX_VALUES
          
           // Quantization
           INIT_QUANTIZATION
          
           // Quantize
           size_t Data;
           for(  udword i=0;i<mNbNodes;i++ )
           {
           PERFORM_QUANTIZATION
           REMAP_DATA(  mData )
           }
          
           DELETEARRAY(  Nodes );
           }
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the collision tree after vertices have been modified.
           * \param mesh_interface [in] mesh interface for current model
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBQuantizedTree::Refit(  const MeshInterface* mesh_interface )
          {
           ASSERT(  !"Not implemented since requantizing is painful !" );
           return false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Walks the tree and call the user back for each node.
           * \param callback [in] walking callback
           * \param user_data [in] callback's user data
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBQuantizedTree::Walk(  GenericWalkingCallback callback,   void* user_data ) const
          {
           if(  !callback ) return false;
          
           struct Local
           {
           static void _Walk(  const AABBQuantizedNode* current_node,   GenericWalkingCallback callback,   void* user_data )
           {
           if(  !current_node || !(  callback )(  current_node,   user_data ) ) return;
          
           if(  !current_node->IsLeaf(   ) )
           {
           _Walk(  current_node->GetPos(   ),   callback,   user_data );
           _Walk(  current_node->GetNeg(   ),   callback,   user_data );
           }
           }
           };
           Local::_Walk(  mNodes,   callback,   user_data );
           return true;
          }
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          AABBQuantizedNoLeafTree::AABBQuantizedNoLeafTree(   ) : mNodes(  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          AABBQuantizedNoLeafTree::~AABBQuantizedNoLeafTree(   )
          {
           DELETEARRAY(  mNodes );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Builds the collision tree from a generic AABB tree.
           * \param tree [in] generic AABB tree
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBQuantizedNoLeafTree::Build(  AABBTree* tree )
          {
           // Checkings
           if(  !tree ) return false;
           // Check the input tree is complete
           udword NbTriangles = tree->GetNbPrimitives(   );
           udword NbNodes = tree->GetNbNodes(   );
           if(  NbNodes!=NbTriangles*2-1 ) return false;
          
           // Get nodes
           mNbNodes = NbTriangles-1;
           DELETEARRAY(  mNodes );
           AABBNoLeafNode* Nodes = new AABBNoLeafNode[mNbNodes];
           CHECKALLOC(  Nodes );
          
           // Build the tree
           udword CurID = 1;
           _BuildNoLeafTree(  Nodes,   0,   CurID,   tree );
           ASSERT(  CurID==mNbNodes );
          
           // Quantize
           {
           mNodes = new AABBQuantizedNoLeafNode[mNbNodes];
           CHECKALLOC(  mNodes );
          
           // Get max values
           FIND_MAX_VALUES
          
           // Quantization
           INIT_QUANTIZATION
          
           // Quantize
           size_t Data;
           for(  udword i=0;i<mNbNodes;i++ )
           {
           PERFORM_QUANTIZATION
           REMAP_DATA(  mPosData )
           REMAP_DATA(  mNegData )
           }
          
           DELETEARRAY(  Nodes );
           }
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Refits the collision tree after vertices have been modified.
           * \param mesh_interface [in] mesh interface for current model
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBQuantizedNoLeafTree::Refit(  const MeshInterface* mesh_interface )
          {
           ASSERT(  !"Not implemented since requantizing is painful !" );
           return false;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Walks the tree and call the user back for each node.
           * \param callback [in] walking callback
           * \param user_data [in] callback's user data
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBQuantizedNoLeafTree::Walk(  GenericWalkingCallback callback,   void* user_data ) const
          {
           if(  !callback ) return false;
          
           struct Local
           {
           static void _Walk(  const AABBQuantizedNoLeafNode* current_node,   GenericWalkingCallback callback,   void* user_data )
           {
           if(  !current_node || !(  callback )(  current_node,   user_data ) ) return;
          
           if(  !current_node->HasPosLeaf(   ) ) _Walk(  current_node->GetPos(   ),   callback,   user_data );
           if(  !current_node->HasNegLeaf(   ) ) _Walk(  current_node->GetNeg(   ),   callback,   user_data );
           }
           };
           Local::_Walk(  mNodes,   callback,   user_data );
           return true;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_Picking.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code to perform "picking".
           * \file OPC_Picking.cpp
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          #ifdef OPC_RAYHIT_CALLBACK
          
          /*
           Possible RayCollider usages:
           - boolean query (  shadow feeler )
           - closest hit
           - all hits
           - number of intersection (  boolean )
          
          */
          
      35  bool Opcode::SetupAllHits(  RayCollider& collider,   CollisionFaces& contacts )
          {
           struct Local
           {
           static void AllContacts(  const CollisionFace& hit,   void* user_data )
           {
           CollisionFaces* CF = (  CollisionFaces* )user_data;
           CF->AddFace(  hit );
           }
           };
          
           collider.SetFirstContact(  false );
           collider.SetHitCallback(  Local::AllContacts );
           collider.SetUserData(  &contacts );
           return true;
          }
          
      52  bool Opcode::SetupClosestHit(  RayCollider& collider,   CollisionFace& closest_contact )
          {
           struct Local
           {
           static void ClosestContact(  const CollisionFace& hit,   void* user_data )
           {
           CollisionFace* CF = (  CollisionFace* )user_data;
           if(  hit.mDistance<CF->mDistance ) *CF = hit;
           }
           };
          
           collider.SetFirstContact(  false );
           collider.SetHitCallback(  Local::ClosestContact );
           collider.SetUserData(  &closest_contact );
           closest_contact.mDistance = MAX_FLOAT;
           return true;
          }
          
      70  bool Opcode::SetupShadowFeeler(  RayCollider& collider )
          {
           collider.SetFirstContact(  true );
           collider.SetHitCallback(  null );
           return true;
          }
          
      77  bool Opcode::SetupInOutTest(  RayCollider& collider )
          {
           collider.SetFirstContact(  false );
           collider.SetHitCallback(  null );
           // Results with collider.GetNbIntersections(   )
           return true;
          }
          
      85  bool Opcode::Picking(  
      86  CollisionFace& picked_face,  
      87  const Ray& world_ray,   const Model& model,   const Matrix4x4* world,  
      88  float min_dist,   float max_dist,   const Point& view_point,   CullModeCallback callback,   void* user_data )
          {
           struct Local
           {
           struct CullData
           {
           CollisionFace* Closest;
           float MinLimit;
           CullModeCallback Callback;
           void* UserData;
           Point ViewPoint;
           const MeshInterface* IMesh;
           };
          
           // Called for each stabbed face
           static void RenderCullingCallback(  const CollisionFace& hit,   void* user_data )
           {
           CullData* Data = (  CullData* )user_data;
          
           // Discard face if we already have a closer hit
           if(  hit.mDistance>=Data->Closest->mDistance ) return;
          
           // Discard face if hit point is smaller than min limit. This mainly happens when the face is in front
           // of the near clip plane (  or straddles it ). If we keep the face nonetheless,   the user can select an
           // object that he may not even be able to see,   which is very annoying.
           if(  hit.mDistance<=Data->MinLimit ) return;
          
           // This is the index of currently stabbed triangle.
           udword StabbedFaceIndex = hit.mFaceID;
          
           // We may keep it or not,   depending on backface culling
           bool KeepIt = true;
          
           // Catch *render* cull mode for this face
           CullMode CM = (  Data->Callback )(  StabbedFaceIndex,   Data->UserData );
          
           if(  CM!=CULLMODE_NONE ) // Don't even compute culling for double-sided triangles
           {
           // Compute backface culling for current face
          
           VertexPointers VP;
           Data->IMesh->GetTriangle(  VP,   StabbedFaceIndex );
           if(  VP.BackfaceCulling(  Data->ViewPoint ) )
           {
           if(  CM==CULLMODE_CW ) KeepIt = false;
           }
           else
           {
           if(  CM==CULLMODE_CCW ) KeepIt = false;
           }
           }
          
           if(  KeepIt ) *Data->Closest = hit;
           }
           };
          
           RayCollider RC;
           RC.SetMaxDist(  max_dist );
           RC.SetTemporalCoherence(  false );
           RC.SetCulling(  false ); // We need all faces since some of them can be double-sided
           RC.SetFirstContact(  false );
           RC.SetHitCallback(  Local::RenderCullingCallback );
          
           picked_face.mFaceID = INVALID_ID;
           picked_face.mDistance = MAX_FLOAT;
           picked_face.mU = 0.0f;
           picked_face.mV = 0.0f;
          
           Local::CullData Data;
           Data.Closest = &picked_face;
           Data.MinLimit = min_dist;
           Data.Callback = callback;
           Data.UserData = user_data;
           Data.ViewPoint = view_point;
           Data.IMesh = model.GetMeshInterface(   );
          
           if(  world )
           {
           // Get matrices
           Matrix4x4 InvWorld;
           InvertPRMatrix(  InvWorld,   *world );
          
           // Compute camera position in mesh space
           Data.ViewPoint *= InvWorld;
           }
          
           RC.SetUserData(  &Data );
           if(  RC.Collide(  world_ray,   model,   world ) )
           {
           return picked_face.mFaceID!=INVALID_ID;
           }
           return false;
          }
          
          #endif

./components/ogre/ogreopcode/src/Opcode/OPC_PlanesCollider.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for a planes collider.
           * \file OPC_PlanesCollider.cpp
           * \author Pierre Terdiman
           * \date January,   1st,   2002
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a Planes-vs-tree collider.
           *
           * \class PlanesCollider
           * \author Pierre Terdiman
           * \version 1.3
           * \date January,   1st,   2002
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          using namespace IceMaths;
          
          #include "Opcode/OPC_PlanesAABBOverlap.h"
          #include "Opcode/OPC_PlanesTriOverlap.h"
          
          #define SET_CONTACT(  prim_index,   flag ) \
           /* Set contact status */ \
      46   mFlags |= flag; \
      47   mTouchedPrimitives->Add(  prim_index );
          
          //! Planes-triangle test
          #define PLANES_PRIM(  prim_index,   flag ) \
           /* Request vertices from the app */ \
           mIMesh->GetTriangle(  mVP,   prim_index ); \
           /* Perform triangle-box overlap test */ \
           if(  PlanesTriOverlap(  clip_mask ) ) \
           { \
           SET_CONTACT(  prim_index,   flag ) \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          PlanesCollider::PlanesCollider(   ) :
           mPlanes (  null ),  
           mNbPlanes (  0 )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          PlanesCollider::~PlanesCollider(   )
          {
           DELETEARRAY(  mPlanes );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Validates current settings. You should call this method after all the settings and callbacks have been defined.
           * \return null if everything is ok,   else a string describing the problem
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          const char* PlanesCollider::ValidateSettings(   )
          {
           if(  TemporalCoherenceEnabled(   ) && !FirstContactEnabled(   ) ) return "Temporal coherence only works with ""First contact"" mode!";
          
           return VolumeCollider::ValidateSettings(   );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Generic collision query for generic OPCODE models. After the call,   access the results:
           * - with GetContactStatus(   )
           * - with GetNbTouchedPrimitives(   )
           * - with GetTouchedPrimitives(   )
           *
           * \param cache [in/out] a planes cache
           * \param planes [in] list of planes in world space
           * \param nb_planes [in] number of planes
           * \param model [in] Opcode model to collide with
           * \param worldm [in] model's world matrix,   or null
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool PlanesCollider::Collide(  PlanesCache& cache,   const IceMaths::Plane* planes,   udword nb_planes,   const Model& model,   const IceMaths::Matrix4x4* worldm )
          {
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   planes,   nb_planes,   worldm ) ) return true;
          
           udword PlaneMask = (  1<<nb_planes )-1;
          
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ),   PlaneMask );
           else _Collide(  Tree->GetNodes(   ),   PlaneMask );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ),   PlaneMask );
           else _Collide(  Tree->GetNodes(   ),   PlaneMask );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ),   PlaneMask );
           else _Collide(  Tree->GetNodes(   ),   PlaneMask );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ),   PlaneMask );
           else _Collide(  Tree->GetNodes(   ),   PlaneMask );
           }
           }
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Initializes a collision query :
           * - reset stats & contact status
           * - compute planes in model space
           * - check temporal coherence
           *
           * \param cache [in/out] a planes cache
           * \param planes [in] list of planes
           * \param nb_planes [in] number of planes
           * \param worldm [in] model's world matrix,   or null
           * \return TRUE if we can return immediately
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          BOOL PlanesCollider::InitQuery(  PlanesCache& cache,   const IceMaths::Plane* planes,   udword nb_planes,   const IceMaths::Matrix4x4* worldm )
          {
           // 1 ) Call the base method
           VolumeCollider::InitQuery(   );
          
           // 2 ) Compute planes in model space
           if(  nb_planes>mNbPlanes )
           {
           DELETEARRAY(  mPlanes );
           mPlanes = new IceMaths::Plane[nb_planes];
           }
           mNbPlanes = nb_planes;
          
           if(  worldm )
           {
           // Matrix normalization & scaling stripping
           IceMaths::Matrix4x4 normWorldm;
           NormalizePRSMatrix(   normWorldm,   mLocalScale,   *worldm  );
          
           IceMaths::Matrix4x4 InvWorldM;
           InvertPRMatrix(  InvWorldM,   normWorldm );
          
          // for(  udword i=0;i<nb_planes;i++ ) mPlanes[i] = planes[i] * InvWorldM;
           for(  udword i=0;i<nb_planes;i++ ) TransformPlane(  mPlanes[i],   planes[i],   InvWorldM );
           }
           else
           {
           mLocalScale.Set(  1.0,  1.0,  1.0 );
           CopyMemory(  mPlanes,   planes,   nb_planes*sizeof(  IceMaths::Plane ) );
           }
          
           // 3 ) Setup destination pointer
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // 4 ) Special case: 1-triangle meshes [Opcode 1.3]
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           if(  !SkipPrimitiveTests(   ) )
           {
           // We simply perform the BV-Prim overlap test each time. We assume single triangle has index 0.
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the unique triangle and the planes (  and set contact status if needed )
           udword clip_mask = (  1<<mNbPlanes )-1;
           PLANES_PRIM(  udword(  0 ),   OPC_CONTACT )
          
           // Return immediately regardless of status
           return TRUE;
           }
           }
          
           // 4 ) Check temporal coherence:
           if(  TemporalCoherenceEnabled(   ) )
           {
           // Here we use temporal coherence
           // => check results from previous frame before performing the collision query
           if(  FirstContactEnabled(   ) )
           {
           // We're only interested in the first contact found => test the unique previously touched face
           if(  mTouchedPrimitives->GetNbEntries(   ) )
           {
           // Get index of previously touched face = the first entry in the array
           udword PreviouslyTouchedFace = mTouchedPrimitives->GetEntry(  0 );
          
           // Then reset the array:
           // - if the overlap test below is successful,   the index we'll get added back anyway
           // - if it isn't,   then the array should be reset anyway for the normal query
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the cached triangle and the planes (  and set contact status if needed )
           udword clip_mask = (  1<<mNbPlanes )-1;
           PLANES_PRIM(  PreviouslyTouchedFace,   OPC_TEMPORAL_CONTACT )
          
           // Return immediately if possible
           if(  GetContactStatus(   ) ) return TRUE;
           }
           // else no face has been touched during previous query
           // => we'll have to perform a normal query
           }
           else mTouchedPrimitives->Reset(   );
           }
           else
           {
           // Here we don't use temporal coherence => do a normal query
           mTouchedPrimitives->Reset(   );
           }
          
           return FALSE;
          }
          
          #define TEST_CLIP_MASK \
           /* If the box is completely included,   so are its children. We don't need to do extra tests,   we */ \
           /* can immediately output a list of visible children. Those ones won't need to be clipped. */ \
           if(  !OutClipMask ) \
           { \
           /* Set contact status */ \
           mFlags |= OPC_CONTACT; \
           _Dump(  node ); \
           return; \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void PlanesCollider::_Collide(  const AABBCollisionNode* node,   udword clip_mask )
          {
           // Test the box against the planes. If the box is completely culled,   so are its children,   hence we exit.
           udword OutClipMask;
           if(  !PlanesAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents,   OutClipMask,   clip_mask ) ) return;
          
           TEST_CLIP_MASK
          
           // Else the box straddles one or several planes,   so we need to recurse down the tree.
           if(  node->IsLeaf(   ) )
           {
           PLANES_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ),   OutClipMask );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ),   OutClipMask );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void PlanesCollider::_CollideNoPrimitiveTest(  const AABBCollisionNode* node,   udword clip_mask )
          {
           // Test the box against the planes. If the box is completely culled,   so are its children,   hence we exit.
           udword OutClipMask;
           if(  !PlanesAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents,   OutClipMask,   clip_mask ) ) return;
          
           TEST_CLIP_MASK
          
           // Else the box straddles one or several planes,   so we need to recurse down the tree.
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ),   OutClipMask );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ),   OutClipMask );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void PlanesCollider::_Collide(  const AABBQuantizedNode* node,   udword clip_mask )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Test the box against the planes. If the box is completely culled,   so are its children,   hence we exit.
           udword OutClipMask;
           if(  !PlanesAABBOverlap(  Center,   Extents,   OutClipMask,   clip_mask ) ) return;
          
           TEST_CLIP_MASK
          
           // Else the box straddles one or several planes,   so we need to recurse down the tree.
           if(  node->IsLeaf(   ) )
           {
           PLANES_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ),   OutClipMask );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ),   OutClipMask );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void PlanesCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNode* node,   udword clip_mask )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Test the box against the planes. If the box is completely culled,   so are its children,   hence we exit.
           udword OutClipMask;
           if(  !PlanesAABBOverlap(  Center,   Extents,   OutClipMask,   clip_mask ) ) return;
          
           TEST_CLIP_MASK
          
           // Else the box straddles one or several planes,   so we need to recurse down the tree.
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ),   OutClipMask );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ),   OutClipMask );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void PlanesCollider::_Collide(  const AABBNoLeafNode* node,   udword clip_mask )
          {
           // Test the box against the planes. If the box is completely culled,   so are its children,   hence we exit.
           udword OutClipMask;
           if(  !PlanesAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents,   OutClipMask,   clip_mask ) ) return;
          
           TEST_CLIP_MASK
          
           // Else the box straddles one or several planes,   so we need to recurse down the tree.
           if(  node->HasPosLeaf(   ) ) { PLANES_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ),   OutClipMask );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { PLANES_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ),   OutClipMask );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void PlanesCollider::_CollideNoPrimitiveTest(  const AABBNoLeafNode* node,   udword clip_mask )
          {
           // Test the box against the planes. If the box is completely culled,   so are its children,   hence we exit.
           udword OutClipMask;
           if(  !PlanesAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents,   OutClipMask,   clip_mask ) ) return;
          
           TEST_CLIP_MASK
          
           // Else the box straddles one or several planes,   so we need to recurse down the tree.
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ),   OutClipMask );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ),   OutClipMask );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void PlanesCollider::_Collide(  const AABBQuantizedNoLeafNode* node,   udword clip_mask )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Test the box against the planes. If the box is completely culled,   so are its children,   hence we exit.
           udword OutClipMask;
           if(  !PlanesAABBOverlap(  Center,   Extents,   OutClipMask,   clip_mask ) ) return;
          
           TEST_CLIP_MASK
          
           // Else the box straddles one or several planes,   so we need to recurse down the tree.
           if(  node->HasPosLeaf(   ) ) { PLANES_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ),   OutClipMask );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { PLANES_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ),   OutClipMask );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void PlanesCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNoLeafNode* node,   udword clip_mask )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Test the box against the planes. If the box is completely culled,   so are its children,   hence we exit.
           udword OutClipMask;
           if(  !PlanesAABBOverlap(  Center,   Extents,   OutClipMask,   clip_mask ) ) return;
          
           TEST_CLIP_MASK
          
           // Else the box straddles one or several planes,   so we need to recurse down the tree.
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ),   OutClipMask );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ),   OutClipMask );
          }
          
          
          
          
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridPlanesCollider::HybridPlanesCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridPlanesCollider::~HybridPlanesCollider(   )
          {
          }
          
          bool HybridPlanesCollider::Collide(  PlanesCache& cache,   const IceMaths::Plane* planes,   udword nb_planes,   const HybridModel& model,   const IceMaths::Matrix4x4* worldm )
          {
           // We don't want primitive tests here!
           mFlags |= OPC_NO_PRIMITIVE_TESTS;
          
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   planes,   nb_planes,   worldm ) ) return true;
          
           // Special case for 1-leaf trees
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           // Here we're supposed to perform a normal query,   except our tree has a single node,   i.e. just a few triangles
           udword Nb = mIMesh->GetNbTriangles(   );
          
           // Loop through all triangles
           udword clip_mask = (  1<<mNbPlanes )-1;
           for(  udword i=0;i<Nb;i++ )
           {
           PLANES_PRIM(  i,   OPC_CONTACT )
           }
           return true;
           }
          
           // Override destination array since we're only going to get leaf boxes here
           mTouchedBoxes.Reset(   );
           mTouchedPrimitives = &mTouchedBoxes;
          
           udword PlaneMask = (  1<<nb_planes )-1;
          
           // Now,   do the actual query against leaf boxes
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ),   PlaneMask );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ),   PlaneMask );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ),   PlaneMask );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ),   PlaneMask );
           }
           }
          
           // We only have a list of boxes so far
           if(  GetContactStatus(   ) )
           {
           // Reset contact status,   since it currently only reflects collisions with leaf boxes
           Collider::InitQuery(   );
          
           // Change dest container so that we can use built-in overlap tests and get collided primitives
           cache.TouchedPrimitives.Reset(   );
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // Read touched leaf boxes
           udword Nb = mTouchedBoxes.GetNbEntries(   );
           const udword* Touched = mTouchedBoxes.GetEntries(   );
          
           const LeafTriangles* LT = model.GetLeafTriangles(   );
           const udword* Indices = model.GetIndices(   );
          
           // Loop through touched leaves
           udword clip_mask = (  1<<mNbPlanes )-1;
           while(  Nb-- )
           {
           const LeafTriangles& CurrentLeaf = LT[*Touched++];
          
           // Each leaf box has a set of triangles
           udword NbTris = CurrentLeaf.GetNbTriangles(   );
           if(  Indices )
           {
           const udword* T = &Indices[CurrentLeaf.GetTriangleIndex(   )];
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = *T++;
           PLANES_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           else
           {
           udword BaseIndex = CurrentLeaf.GetTriangleIndex(   );
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = BaseIndex++;
           PLANES_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           }
           }
          
           return true;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_RayCollider.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for a ray collider.
           * \file OPC_RayCollider.cpp
           * \author Pierre Terdiman
           * \date June,   2,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a ray-vs-tree collider.
           * This class performs a stabbing query on an AABB tree,   i.e. does a ray-mesh collision.
           *
           * HIGHER DISTANCE BOUND:
           *
           * If P0 and P1 are two 3D points,   let's define:
           * - d = distance between P0 and P1
           * - Origin = P0
           * - Direction = (  P1 - P0 ) / d = normalized direction vector
           * - A parameter t such as a point P on the line (  P0,  P1 ) is P = Origin + t * Direction
           * - t = 0 --> P = P0
           * - t = d --> P = P1
           *
           * Then we can define a general "ray" as:
           *
           * struct Ray
           * {
           * Point Origin;
           * Point Direction;
           * };
           *
           * But it actually maps three different things:
           * - a segment,   when 0 <= t <= d
           * - a half-line,   when 0 <= t < +infinity,   or -infinity < t <= d
           * - a line,   when -infinity < t < +infinity
           *
           * In Opcode,   we support segment queries,   which yield half-line queries by setting d = +infinity.
           * We don't support line-queries. If you need them,   shift the origin along the ray by an appropriate margin.
           *
           * In short,   the lower bound is always 0,   and you can setup the higher bound "d" with RayCollider::SetMaxDist(   ).
           *
           * Query |segment |half-line |line
           * --------|-------------------|---------------|----------------
           * Usages |-shadow feelers |-raytracing |-
           * |-sweep tests |-in/out tests |
           *
           * FIRST CONTACT:
           *
           * - You can setup "first contact" mode or "all contacts" mode with RayCollider::SetFirstContact(   ).
           * - In "first contact" mode we return as soon as the ray hits one face. If can be useful e.g. for shadow feelers,   where
           * you want to know whether the path to the light is free or not (  a boolean answer is enough ).
           * - In "all contacts" mode we return all faces hit by the ray.
           *
           * TEMPORAL COHERENCE:
           *
           * - You can enable or disable temporal coherence with RayCollider::SetTemporalCoherence(   ).
           * - It currently only works in "first contact" mode.
           * - If temporal coherence is enabled,   the previously hit triangle is cached during the first query. Then,   next queries
           * start by colliding the ray against the cached triangle. If they still collide,   we return immediately.
           *
           * CLOSEST HIT:
           *
           * - You can enable or disable "closest hit" with RayCollider::SetClosestHit(   ).
           * - It currently only works in "all contacts" mode.
           * - If closest hit is enabled,   faces are sorted by distance on-the-fly and the closest one only is reported.
           *
           * BACKFACE CULLING:
           *
           * - You can enable or disable backface culling with RayCollider::SetCulling(   ).
           * - If culling is enabled,   ray will not hit back faces (  only front faces ).
           *
           *
           *
           * \class RayCollider
           * \author Pierre Terdiman
           * \version 1.3
           * \date June,   2,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * This class describes a face hit by a ray or segment.
           * This is a particular class dedicated to stabbing queries.
           *
           * \class CollisionFace
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * This class is a dedicated collection of CollisionFace.
           *
           * \class CollisionFaces
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          using namespace IceMaths;
          
          // When this macro is set,   the overlap tests considers an scaling on AABBs/tris.
          // This means that the ray/line is not entirely in the model's local space when collision
          // tests take places.
          // #define OPC_RAYCOLLIDER_SCALE_BEFORE_OVERLAP
          
          #include "Opcode/OPC_RayAABBOverlap.h"
          #include "Opcode/OPC_RayTriOverlap.h"
          
          #define SET_CONTACT(  prim_index,   flag ) \
     134   mNbIntersections++; \
           /* Set contact status */ \
     136   mFlags |= flag; \
           /* In any case the contact has been found and recorded in mStabbedFace */ \
           mStabbedFace.mFaceID = prim_index;
          
          #ifdef OPC_RAYHIT_CALLBACK
          
           #define HANDLE_CONTACT(  prim_index,   flag ) \
           SET_CONTACT(  prim_index,   flag ) \
           \
           if(  mHitCallback ) (  mHitCallback )(  mStabbedFace,   mUserData );
          
           #define UPDATE_CACHE \
           if(  cache && GetContactStatus(   ) ) \
           { \
           *cache = mStabbedFace.mFaceID; \
           }
          #else
          
           #define HANDLE_CONTACT(  prim_index,   flag ) \
           SET_CONTACT(  prim_index,   flag ) \
           \
           /* Now we can also record it in mStabbedFaces if available */ \
           if(  mStabbedFaces ) \
           { \
           /* If we want all faces or if that's the first one we hit */ \
           if(  !mClosestHit || !mStabbedFaces->GetNbFaces(   ) ) \
           { \
           mStabbedFaces->AddFace(  mStabbedFace ); \
           } \
           else \
           { \
           /* We only keep closest hit */ \
           CollisionFace* Current = const_cast<CollisionFace*>(  mStabbedFaces->GetFaces(   ) ); \
           if(  Current && mStabbedFace.mDistance<Current->mDistance ) \
           { \
           *Current = mStabbedFace; \
           } \
           } \
           }
          
           #define UPDATE_CACHE \
           if(  cache && GetContactStatus(   ) && mStabbedFaces ) \
           { \
           const CollisionFace* Current = mStabbedFaces->GetFaces(   ); \
           if(  Current ) *cache = Current->mFaceID; \
           else *cache = INVALID_ID; \
           }
          #endif
          
          #define SEGMENT_PRIM(  prim_index,   flag ) \
           /* Request vertices from the app */ \
           VertexPointers VP; mIMesh->GetTriangle(  VP,   prim_index ); \
           \
           /* Perform ray-tri overlap test and return */ \
           if(  RayTriOverlap(  *VP.Vertex[0],   *VP.Vertex[1],   *VP.Vertex[2] ) ) \
           { \
           /* Intersection point is valid if dist < segment's length */ \
           /* We know dist>0 so we can use integers */ \
           if(  IR(  mStabbedFace.mDistance )<IR(  mMaxDist ) ) \
           { \
           HANDLE_CONTACT(  prim_index,   flag ) \
           } \
           }
          
          #define RAY_PRIM(  prim_index,   flag ) \
           /* Request vertices from the app */ \
           VertexPointers VP; mIMesh->GetTriangle(  VP,   prim_index ); \
           \
           /* Perform ray-tri overlap test and return */ \
           if(  RayTriOverlap(  *VP.Vertex[0],   *VP.Vertex[1],   *VP.Vertex[2] ) ) \
           { \
           HANDLE_CONTACT(  prim_index,   flag ) \
           }
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          RayCollider::RayCollider(   ) :
           mNbRayBVTests (  0 ),  
           mNbRayPrimTests (  0 ),  
           mNbIntersections (  0 ),  
           mCulling (  true ),  
          #ifdef OPC_RAYHIT_CALLBACK
           mHitCallback (  null ),  
           mUserData (  0 ),  
          #else
           mClosestHit (  false ),  
           mStabbedFaces (  null ),  
          #endif
           mMaxDist (  MAX_FLOAT )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          RayCollider::~RayCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Validates current settings. You should call this method after all the settings and callbacks have been defined.
           * \return null if everything is ok,   else a string describing the problem
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          const char* RayCollider::ValidateSettings(   )
          {
           if(  mMaxDist<0.0f ) return "Higher distance bound must be positive!";
           if(  TemporalCoherenceEnabled(   ) && !FirstContactEnabled(   ) ) return "Temporal coherence only works with ""First contact"" mode!";
          #ifndef OPC_RAYHIT_CALLBACK
           if(  mClosestHit && FirstContactEnabled(   ) ) return "Closest hit doesn't work with ""First contact"" mode!";
           if(  TemporalCoherenceEnabled(   ) && mClosestHit ) return "Temporal coherence can't guarantee to report closest hit!";
          #endif
           if(  SkipPrimitiveTests(   ) ) return "SkipPrimitiveTests not possible for RayCollider ! (  not implemented )";
           return null;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Generic stabbing query for generic OPCODE models. After the call,   access the results:
           * - with GetContactStatus(   )
           * - in the user-provided destination array
           *
           * \param world_ray [in] stabbing ray in world space
           * \param model [in] Opcode model to collide with
           * \param world [in] model's world matrix,   or null
           * \param cache [in] a possibly cached face index,   or null
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool RayCollider::Collide(  const IceMaths::Ray& world_ray,   const Model& model,   const IceMaths::Matrix4x4* world,   udword* cache )
          {
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           float maxDistanceBkp = mMaxDist;
           Point originBkp = mOrigin;
           Point dirBkp = mDir;
          
           if(  InitQuery(  world_ray,   world,   cache ) )
           {
           mMaxDist = maxDistanceBkp;
           mDir = dirBkp;
           mOrigin = originBkp;
           return true;
           }
          
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform stabbing query
           if(  IR(  mMaxDist )!=IEEE_MAX_FLOAT ) _SegmentStab(  Tree->GetNodes(   ) );
           else _RayStab(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform stabbing query
           if(  IR(  mMaxDist )!=IEEE_MAX_FLOAT ) _SegmentStab(  Tree->GetNodes(   ) );
           else _RayStab(  Tree->GetNodes(   ) );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform stabbing query
           if(  IR(  mMaxDist )!=IEEE_MAX_FLOAT ) _SegmentStab(  Tree->GetNodes(   ) );
           else _RayStab(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform stabbing query
           if(  IR(  mMaxDist )!=IEEE_MAX_FLOAT ) _SegmentStab(  Tree->GetNodes(   ) );
           else _RayStab(  Tree->GetNodes(   ) );
           }
           }
          
           // reverts max distance,   etc
           mMaxDist = maxDistanceBkp;
           mDir = dirBkp;
           mOrigin = originBkp;
          
           // Update cache if needed
           UPDATE_CACHE
           return true;
          }
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Initializes a stabbing query :
           * - reset stats & contact status
           * - compute ray in local space
           * - check temporal coherence
           *
           * \param world_ray [in] stabbing ray in world space
           * \param world [in] object's world matrix,   or null
           * \param face_id [in] index of previously stabbed triangle
           * \return TRUE if we can return immediately
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          BOOL RayCollider::InitQuery(  const IceMaths::Ray& world_ray,   const IceMaths::Matrix4x4* world,   udword* face_id )
          {
           // Reset stats & contact status
           Collider::InitQuery(   );
          
           mNbRayBVTests = 0;
           mNbRayPrimTests = 0;
           mNbIntersections = 0;
          
          #ifndef OPC_RAYHIT_CALLBACK
           if(  mStabbedFaces ) mStabbedFaces->Reset(   );
          #endif
          
           // Compute ray in local space
           // The (  Origin/Dir ) form is needed for the ray-triangle test anyway (  even for segment tests )
           if(  world )
           {
          #ifdef OPC_RAYCOLLIDER_SCALE_BEFORE_OVERLAP
           // Matrix normalization & scaling stripping
           Matrix4x4 normWorldm;
           NormalizePRSMatrix(   normWorldm,   mLocalScale,   *world  );
          
           // Invert model matrix
           Matrix3x3 InvWorld = normWorldm;
           mDir = InvWorld * world_ray.mDir;
          
           Matrix4x4 World;
           InvertPRMatrix(  World,   normWorldm );
           mOrigin = world_ray.mOrig * World;
          #else
           // Now we are a much better code to get the ray in local space.
           // Some notes about this new code:
           // - faster,   because we don't need to compute square roots anymore;
           // - faster yet,   because the number of divisions is even smaller now;
           // - the intersection tests are robust enough to handle rays with non-unit direction vectors;
           // - matrices are less subject to FPU errors,   because I don't like square root;
           // (  it seems to introduce errors,   because it cuts number precision by a half when
           // stripping the matrix scale off )
           // - the code is shorter and easier to maintain; :P
           #pragma message(  " >> Using new code for ray collision" )
          
           // first,   invert the world matrix and transform the ray's origin
           Matrix4x4 World;
           InvertPRSMatrix(  World,   *world );
           mOrigin = world_ray.mOrig * World;
          
           // second,   transform the ray's direction
           Matrix3x3 InvWorld = World;
           mDir = world_ray.mDir * InvWorld;
          #endif
           }
           else
           {
           mLocalScale.Set(  1.0f,  1.0f,  1.0f );
           mDir = world_ray.mDir;
           mOrigin = world_ray.mOrig;
           }
          
           // 4 ) Special case: 1-triangle meshes [Opcode 1.3]
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           // We simply perform the BV-Prim overlap test each time. We assume single triangle has index 0.
           if(  !SkipPrimitiveTests(   ) )
           {
           // Perform overlap test between the unique triangle and the ray (  and set contact status if needed )
           SEGMENT_PRIM(  udword(  0 ),   OPC_CONTACT )
          
           // Return immediately regardless of status
           return TRUE;
           }
           }
          
           // Check temporal coherence :
          
           // Test previously colliding primitives first
           if(  TemporalCoherenceEnabled(   ) && FirstContactEnabled(   ) && face_id && *face_id!=INVALID_ID )
           {
          #ifdef OLD_CODE
          #ifndef OPC_RAYHIT_CALLBACK
           if(  !mClosestHit )
          #endif
           {
           // Request vertices from the app
           VertexPointers VP;
           mIMesh->GetTriangle(  VP,   *face_id );
           // Perform ray-cached tri overlap test
           if(  RayTriOverlap(  *VP.Vertex[0],   *VP.Vertex[1],   *VP.Vertex[2] ) )
           {
           // Intersection point is valid if:
           // - distance is positive (  else it can just be a face behind the orig point )
           // - distance is smaller than a given max distance (  useful for shadow feelers )
          // if(  mStabbedFace.mDistance>0.0f && mStabbedFace.mDistance<mMaxDist )
           if(  IR(  mStabbedFace.mDistance )<IR(  mMaxDist ) ) // The other test is already performed in RayTriOverlap
           {
           // Set contact status
           mFlags |= OPC_TEMPORAL_CONTACT;
          
           mStabbedFace.mFaceID = *face_id;
          
          #ifndef OPC_RAYHIT_CALLBACK
           if(  mStabbedFaces ) mStabbedFaces->AddFace(  mStabbedFace );
          #endif
           return TRUE;
           }
           }
           }
          #else
           // New code
           // We handle both Segment/ray queries with the same segment code,   and a possible infinite limit
           SEGMENT_PRIM(  *face_id,   OPC_TEMPORAL_CONTACT )
          
           // Return immediately if possible
           if(  GetContactStatus(   ) ) return TRUE;
          #endif
           }
          
           // Precompute data (  moved after temporal coherence since only needed for ray-AABB )
           if(  IR(  mMaxDist )!=IEEE_MAX_FLOAT )
           {
           // For Segment-AABB overlap
           mData = 0.5f * mDir * mMaxDist;
           mData2 = mOrigin + mData;
          
           // Precompute mFDir;
           mFDir.x = fabsf(  mData.x );
           mFDir.y = fabsf(  mData.y );
           mFDir.z = fabsf(  mData.z );
           }
           else
           {
           // For Ray-AABB overlap
          // udword x = SIR(  mDir.x )-1;
          // udword y = SIR(  mDir.y )-1;
          // udword z = SIR(  mDir.z )-1;
          // mData.x = FR(  x );
          // mData.y = FR(  y );
          // mData.z = FR(  z );
          
           // Precompute mFDir;
           mFDir.x = fabsf(  mDir.x );
           mFDir.y = fabsf(  mDir.y );
           mFDir.z = fabsf(  mDir.z );
           }
          
           return FALSE;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Stabbing query for vanilla AABB trees.
           * \param world_ray [in] stabbing ray in world space
           * \param tree [in] AABB tree
           * \param box_indices [out] indices of stabbed boxes
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool RayCollider::Collide(  const IceMaths::Ray& world_ray,   const AABBTree* tree,   Container& box_indices )
          {
           // ### bad design here
          
           // This is typically called for a scene tree,   full of -AABBs-,   not full of triangles.
           // So we don't really have "primitives" to deal with. Hence it doesn't work with
           // "FirstContact" + "TemporalCoherence".
           ASSERT(   !(  FirstContactEnabled(   ) && TemporalCoherenceEnabled(   ) )  );
          
           // Checkings
           if(  !tree ) return false;
          
           // Init collision query
           // Basically this is only called to initialize precomputed data
           if(  InitQuery(  world_ray ) ) return true;
          
           // Perform stabbing query
           if(  IR(  mMaxDist )!=IEEE_MAX_FLOAT ) _SegmentStab(  tree,   box_indices );
           else _RayStab(  tree,   box_indices );
          
           return true;
          }
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for normal AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_SegmentStab(  const AABBCollisionNode* node )
          {
           // Perform Segment-AABB overlap test
           if(  !SegmentAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           if(  node->IsLeaf(   ) )
           {
           SEGMENT_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _SegmentStab(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _SegmentStab(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for quantized AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_SegmentStab(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform Segment-AABB overlap test
           if(  !SegmentAABBOverlap(  Center,   Extents ) ) return;
          
           if(  node->IsLeaf(   ) )
           {
           SEGMENT_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _SegmentStab(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _SegmentStab(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_SegmentStab(  const AABBNoLeafNode* node )
          {
           // Perform Segment-AABB overlap test
           if(  !SegmentAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           if(  node->HasPosLeaf(   ) )
           {
           SEGMENT_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT )
           }
           else _SegmentStab(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) )
           {
           SEGMENT_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT )
           }
           else _SegmentStab(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for quantized no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_SegmentStab(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform Segment-AABB overlap test
           if(  !SegmentAABBOverlap(  Center,   Extents ) ) return;
          
           if(  node->HasPosLeaf(   ) )
           {
           SEGMENT_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT )
           }
           else _SegmentStab(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) )
           {
           SEGMENT_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT )
           }
           else _SegmentStab(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for vanilla AABB trees.
           * \param node [in] current collision node
           * \param box_indices [out] indices of stabbed boxes
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_SegmentStab(  const AABBTreeNode* node,   Container& box_indices )
          {
           // Test the box against the segment
           IceMaths::Point Center,   Extents;
           node->GetAABB(   )->GetCenter(  Center );
           node->GetAABB(   )->GetExtents(  Extents );
           if(  !SegmentAABBOverlap(  Center,   Extents ) ) return;
          
           if(  node->IsLeaf(   ) )
           {
           box_indices.Add(  node->GetPrimitives(   ),   node->GetNbPrimitives(   ) );
           }
           else
           {
           _SegmentStab(  node->GetPos(   ),   box_indices );
           _SegmentStab(  node->GetNeg(   ),   box_indices );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for normal AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_RayStab(  const AABBCollisionNode* node )
          {
           // Perform Ray-AABB overlap test
           if(  !RayAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           if(  node->IsLeaf(   ) )
           {
           RAY_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _RayStab(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _RayStab(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for quantized AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_RayStab(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform Ray-AABB overlap test
           if(  !RayAABBOverlap(  Center,   Extents ) ) return;
          
           if(  node->IsLeaf(   ) )
           {
           RAY_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _RayStab(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _RayStab(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_RayStab(  const AABBNoLeafNode* node )
          {
           // Perform Ray-AABB overlap test
           if(  !RayAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           if(  node->HasPosLeaf(   ) )
           {
           RAY_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT )
           }
           else _RayStab(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) )
           {
           RAY_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT )
           }
           else _RayStab(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for quantized no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_RayStab(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform Ray-AABB overlap test
           if(  !RayAABBOverlap(  Center,   Extents ) ) return;
          
           if(  node->HasPosLeaf(   ) )
           {
           RAY_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT )
           }
           else _RayStab(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) )
           {
           RAY_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT )
           }
           else _RayStab(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive stabbing query for vanilla AABB trees.
           * \param node [in] current collision node
           * \param box_indices [out] indices of stabbed boxes
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void RayCollider::_RayStab(  const AABBTreeNode* node,   Container& box_indices )
          {
           // Test the box against the ray
           IceMaths::Point Center,   Extents;
           node->GetAABB(   )->GetCenter(  Center );
           node->GetAABB(   )->GetExtents(  Extents );
           if(  !RayAABBOverlap(  Center,   Extents ) ) return;
          
           if(  node->IsLeaf(   ) )
           {
           mFlags |= OPC_CONTACT;
           box_indices.Add(  node->GetPrimitives(   ),   node->GetNbPrimitives(   ) );
           }
           else
           {
           _RayStab(  node->GetPos(   ),   box_indices );
           _RayStab(  node->GetNeg(   ),   box_indices );
           }
          }

./components/ogre/ogreopcode/src/Opcode/OPC_SphereCollider.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for a sphere collider.
           * \file OPC_SphereCollider.cpp
           * \author Pierre Terdiman
           * \date June,   2,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains a sphere-vs-tree collider.
           * This class performs a collision test between a sphere and an AABB tree. You can use this to do a standard player vs world collision,  
           * in a Nettle/Telemachos way. It doesn't suffer from all reported bugs in those two classic codes - the "new" one by Paul Nettle is a
           * debuggued version I think. Collision response can be driven by reported collision data - it works extremely well for me. In sake of
           * efficiency,   all meshes (  that is,   all AABB trees ) should of course also be kept in an extra hierarchical structure (  octree,   whatever ).
           *
           * \class SphereCollider
           * \author Pierre Terdiman
           * \version 1.3
           * \date June,   2,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          using namespace IceMaths;
          
          #include "Opcode/OPC_SphereAABBOverlap.h"
          #include "Opcode/OPC_SphereTriOverlap.h"
          
          
          
          #define SET_CONTACT(  prim_index,   flag ) \
           /* Set contact status */ \
      47   mFlags |= flag; \
      48   mTouchedPrimitives->Add(  prim_index );
          
          //! Sphere-triangle overlap test
          #define SPHERE_PRIM(  prim_index,   flag ) \
           /* Request vertices from the app */ \
      53   VertexPointers VP; mIMesh->GetTriangle(  VP,   prim_index ); \
           \
           /* Perform sphere-tri overlap test */ \
      56   if(  SphereTriOverlap(  *VP.Vertex[0],   *VP.Vertex[1],   *VP.Vertex[2] ) ) \
           { \
           SET_CONTACT(  prim_index,   flag ) \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      66  SphereCollider::SphereCollider(   )
          {
           mCenter.Zero(   );
           mRadius2 = 0.0f;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      77  SphereCollider::~SphereCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Generic collision query for generic OPCODE models. After the call,   access the results:
           * - with GetContactStatus(   )
           * - with GetNbTouchedPrimitives(   )
           * - with GetTouchedPrimitives(   )
           *
           * \param cache [in/out] a sphere cache
           * \param sphere [in] collision sphere in local space
           * \param model [in] Opcode model to collide with
           * \param worlds [in] sphere's world matrix,   or null
           * \param worldm [in] model's world matrix,   or null
           * \return true if success
           * \warning SCALE NOT SUPPORTED IN SPHERE WORLD MATRIX. The matrix must contain rotation & translation parts only.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      97  bool SphereCollider::Collide(  SphereCache& cache,   const IceMaths::Sphere& sphere,   const Model& model,   const IceMaths::Matrix4x4* worlds,   const IceMaths::Matrix4x4* worldm )
          {
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   sphere,   worlds,   worldm ) ) return true;
          
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query
           if(  SkipPrimitiveTests(   ) ) _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           else _Collide(  Tree->GetNodes(   ) );
           }
           }
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Initializes a collision query :
           * - reset stats & contact status
           * - setup matrices
           * - check temporal coherence
           *
           * \param cache [in/out] a sphere cache
           * \param sphere [in] sphere in local space
           * \param worlds [in] sphere's world matrix,   or null
           * \param worldm [in] model's world matrix,   or null
           * \return TRUE if we can return immediately
           * \warning SCALE NOT SUPPORTED IN SPHERE WORLD MATRIX. The matrix must contain rotation & translation parts only.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     169  BOOL SphereCollider::InitQuery(  SphereCache& cache,   const IceMaths::Sphere& sphere,   const IceMaths::Matrix4x4* worlds,   const IceMaths::Matrix4x4* worldm )
          {
           // 1 ) Call the base method
           VolumeCollider::InitQuery(   );
          
           // 2 ) Compute sphere in model space:
           // - Precompute R^2
           mRadius2 = sphere.mRadius * sphere.mRadius;
           // - Compute center position
           mCenter = sphere.mCenter;
           // -> to world space
           if(  worlds ) mCenter *= *worlds;
           // -> to model space
           if(  worldm )
           {
           // Matrix normalization & scaling stripping
           IceMaths::Matrix4x4 normWorldm;
           NormalizePRSMatrix(   normWorldm,   mLocalScale,   *worldm  );
          
           // Invert model matrix
           IceMaths::Matrix4x4 InvWorldM;
           InvertPRMatrix(  InvWorldM,   normWorldm ); // OLD: //InvertPRMatrix(  InvWorldM,   *worldm );
          
           mCenter *= InvWorldM;
           }else
           {
           mLocalScale.Set(  1.0,  1.0,  1.0 );
           }
          
           // 3 ) Setup destination pointer
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // 4 ) Special case: 1-triangle meshes [Opcode 1.3]
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           if(  !SkipPrimitiveTests(   ) )
           {
           // We simply perform the BV-Prim overlap test each time. We assume single triangle has index 0.
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the unique triangle and the sphere (  and set contact status if needed )
           SPHERE_PRIM(  udword(  0 ),   OPC_CONTACT )
          
           // Return immediately regardless of status
           return TRUE;
           }
           }
          
           // 5 ) Check temporal coherence :
           if(  TemporalCoherenceEnabled(   ) )
           {
           // Here we use temporal coherence
           // => check results from previous frame before performing the collision query
           if(  FirstContactEnabled(   ) )
           {
           // We're only interested in the first contact found => test the unique previously touched face
           if(  mTouchedPrimitives->GetNbEntries(   ) )
           {
           // Get index of previously touched face = the first entry in the array
           udword PreviouslyTouchedFace = mTouchedPrimitives->GetEntry(  0 );
          
           // Then reset the array:
           // - if the overlap test below is successful,   the index we'll get added back anyway
           // - if it isn't,   then the array should be reset anyway for the normal query
           mTouchedPrimitives->Reset(   );
          
           // Perform overlap test between the cached triangle and the sphere (  and set contact status if needed )
           SPHERE_PRIM(  PreviouslyTouchedFace,   OPC_TEMPORAL_CONTACT )
          
           // Return immediately if possible
           if(  GetContactStatus(   ) ) return TRUE;
           }
           // else no face has been touched during previous query
           // => we'll have to perform a normal query
           }
           else
           {
           // We're interested in all contacts =>test the new real sphere N(  ew ) against the previous fat sphere P(  revious ):
           float r = sqrtf(  cache.FatRadius2 ) - sphere.mRadius;
           if(  IsCacheValid(  cache ) && cache.Center.SquareDistance(  mCenter ) < r*r )
           {
           // - if N is included in P,   return previous list
           // => we simply leave the list (  mTouchedFaces ) unchanged
          
           // Set contact status if needed
           if(  mTouchedPrimitives->GetNbEntries(   ) ) mFlags |= OPC_TEMPORAL_CONTACT;
          
           // In any case we don't need to do a query
           return TRUE;
           }
           else
           {
           // - else do the query using a fat N
          
           // Reset cache since we'll about to perform a real query
           mTouchedPrimitives->Reset(   );
          
           // Make a fat sphere so that coherence will work for subsequent frames
           mRadius2 *= cache.FatCoeff;
          // mRadius2 = (  sphere.mRadius * cache.FatCoeff )*(  sphere.mRadius * cache.FatCoeff );
          
           // Update cache with query data (  signature for cached faces )
           cache.Center = mCenter;
           cache.FatRadius2 = mRadius2;
           }
           }
           }
           else
           {
           // Here we don't use temporal coherence => do a normal query
           mTouchedPrimitives->Reset(   );
           }
          
           return FALSE;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Collision query for vanilla AABB trees.
           * \param cache [in/out] a sphere cache
           * \param sphere [in] collision sphere in world space
           * \param tree [in] AABB tree
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     294  bool SphereCollider::Collide(  SphereCache& cache,   const IceMaths::Sphere& sphere,   const AABBTree* tree )
          {
           // This is typically called for a scene tree,   full of -AABBs-,   not full of triangles.
           // So we don't really have "primitives" to deal with. Hence it doesn't work with
           // "FirstContact" + "TemporalCoherence".
           ASSERT(   !(  FirstContactEnabled(   ) && TemporalCoherenceEnabled(   ) )  );
          
           // Checkings
           if(  !tree ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   sphere ) ) return true;
          
           // Perform collision query
           _Collide(  tree );
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Checks the sphere completely contains the box. In which case we can end the query sooner.
           * \param bc_ [in] box center
           * \param be_ [in] box extents
           * \return true if the sphere contains the whole box
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ BOOL SphereCollider::SphereContainsBox(  const IceMaths::Point& bc_,   const IceMaths::Point& be_ )
          {
           // I assume if all 8 box vertices are inside the sphere,   so does the whole box.
           // Sounds ok but maybe there's a better way?
           IceMaths::Point p;
          
           // scaling freak
           IceMaths::Point bc = bc_*mLocalScale;
           IceMaths::Point be = be_*mLocalScale;
          
     331   p.x=bc.x+be.x; p.y=bc.y+be.y; p.z=bc.z+be.z; if(  mCenter.SquareDistance(  p )>=mRadius2 ) return FALSE;
           p.x=bc.x-be.x; if(  mCenter.SquareDistance(  p )>=mRadius2 ) return FALSE;
           p.x=bc.x+be.x; p.y=bc.y-be.y; if(  mCenter.SquareDistance(  p )>=mRadius2 ) return FALSE;
           p.x=bc.x-be.x; if(  mCenter.SquareDistance(  p )>=mRadius2 ) return FALSE;
           p.x=bc.x+be.x; p.y=bc.y+be.y; p.z=bc.z-be.z; if(  mCenter.SquareDistance(  p )>=mRadius2 ) return FALSE;
           p.x=bc.x-be.x; if(  mCenter.SquareDistance(  p )>=mRadius2 ) return FALSE;
           p.x=bc.x+be.x; p.y=bc.y-be.y; if(  mCenter.SquareDistance(  p )>=mRadius2 ) return FALSE;
           p.x=bc.x-be.x; if(  mCenter.SquareDistance(  p )>=mRadius2 ) return FALSE;
          
           return TRUE;
          }
          
          #define TEST_BOX_IN_SPHERE(  center,   extents ) \
           if(  SphereContainsBox(  center,   extents ) ) \
           { \
           /* Set contact status */ \
           mFlags |= OPC_CONTACT; \
           _Dump(  node ); \
           return; \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void SphereCollider::_Collide(  const AABBCollisionNode* node )
          {
           // Perform Sphere-AABB overlap test
           if(  !SphereAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           TEST_BOX_IN_SPHERE(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->IsLeaf(   ) )
           {
           SPHERE_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void SphereCollider::_CollideNoPrimitiveTest(  const AABBCollisionNode* node )
          {
           // Perform Sphere-AABB overlap test
           if(  !SphereAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           TEST_BOX_IN_SPHERE(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void SphereCollider::_Collide(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform Sphere-AABB overlap test
           if(  !SphereAABBOverlap(  Center,   Extents ) ) return;
          
           TEST_BOX_IN_SPHERE(  Center,   Extents )
          
           if(  node->IsLeaf(   ) )
           {
           SPHERE_PRIM(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void SphereCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform Sphere-AABB overlap test
           if(  !SphereAABBOverlap(  Center,   Extents ) ) return;
          
           TEST_BOX_IN_SPHERE(  Center,   Extents )
          
           if(  node->IsLeaf(   ) )
           {
           SET_CONTACT(  node->GetPrimitive(   ),   OPC_CONTACT )
           }
           else
           {
           _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           _CollideNoPrimitiveTest(  node->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void SphereCollider::_Collide(  const AABBNoLeafNode* node )
          {
           // Perform Sphere-AABB overlap test
           if(  !SphereAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           TEST_BOX_IN_SPHERE(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->HasPosLeaf(   ) ) { SPHERE_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SPHERE_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void SphereCollider::_CollideNoPrimitiveTest(  const AABBNoLeafNode* node )
          {
           // Perform Sphere-AABB overlap test
           if(  !SphereAABBOverlap(  node->mAABB.mCenter,   node->mAABB.mExtents ) ) return;
          
           TEST_BOX_IN_SPHERE(  node->mAABB.mCenter,   node->mAABB.mExtents )
          
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void SphereCollider::_Collide(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform Sphere-AABB overlap test
           if(  !SphereAABBOverlap(  Center,   Extents ) ) return;
          
           TEST_BOX_IN_SPHERE(  Center,   Extents )
          
           if(  node->HasPosLeaf(   ) ) { SPHERE_PRIM(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SPHERE_PRIM(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _Collide(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees,   without primitive tests.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void SphereCollider::_CollideNoPrimitiveTest(  const AABBQuantizedNoLeafNode* node )
          {
           // Dequantize box
           const QuantizedAABB& Box = node->mAABB;
           const IceMaths::Point Center(  float(  Box.mCenter[0] ) * mCenterCoeff.x,   float(  Box.mCenter[1] ) * mCenterCoeff.y,   float(  Box.mCenter[2] ) * mCenterCoeff.z );
           const IceMaths::Point Extents(  float(  Box.mExtents[0] ) * mExtentsCoeff.x,   float(  Box.mExtents[1] ) * mExtentsCoeff.y,   float(  Box.mExtents[2] ) * mExtentsCoeff.z );
          
           // Perform Sphere-AABB overlap test
           if(  !SphereAABBOverlap(  Center,   Extents ) ) return;
          
           TEST_BOX_IN_SPHERE(  Center,   Extents )
          
           if(  node->HasPosLeaf(   ) ) { SET_CONTACT(  node->GetPosPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  node->HasNegLeaf(   ) ) { SET_CONTACT(  node->GetNegPrimitive(   ),   OPC_CONTACT ) }
           else _CollideNoPrimitiveTest(  node->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for vanilla AABB trees.
           * \param node [in] current collision node
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void SphereCollider::_Collide(  const AABBTreeNode* node )
          {
           // Perform Sphere-AABB overlap test
           IceMaths::Point Center,   Extents;
           node->GetAABB(   )->GetCenter(  Center );
           node->GetAABB(   )->GetExtents(  Extents );
           if(  !SphereAABBOverlap(  Center,   Extents ) ) return;
          
           if(  node->IsLeaf(   ) || SphereContainsBox(  Center,   Extents ) )
           {
           mFlags |= OPC_CONTACT;
           mTouchedPrimitives->Add(  node->GetPrimitives(   ),   node->GetNbPrimitives(   ) );
           }
           else
           {
           _Collide(  node->GetPos(   ) );
           _Collide(  node->GetNeg(   ) );
           }
          }
          
          
          
          
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridSphereCollider::HybridSphereCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          HybridSphereCollider::~HybridSphereCollider(   )
          {
          }
          
          bool HybridSphereCollider::Collide(  SphereCache& cache,   const IceMaths::Sphere& sphere,   const HybridModel& model,   const IceMaths::Matrix4x4* worlds,   const IceMaths::Matrix4x4* worldm )
          {
           // We don't want primitive tests here!
           mFlags |= OPC_NO_PRIMITIVE_TESTS;
          
           // Checkings
           if(  !Setup(  &model ) ) return false;
          
           // Init collision query
           if(  InitQuery(  cache,   sphere,   worlds,   worldm ) ) return true;
          
           // Special case for 1-leaf trees
           if(  mCurrentModel && mCurrentModel->HasSingleNode(   ) )
           {
           // Here we're supposed to perform a normal query,   except our tree has a single node,   i.e. just a few triangles
           udword Nb = mIMesh->GetNbTriangles(   );
          
           // Loop through all triangles
           for(  udword i=0;i<Nb;i++ )
           {
           SPHERE_PRIM(  i,   OPC_CONTACT )
           }
           return true;
           }
          
           // Override destination array since we're only going to get leaf boxes here
           mTouchedBoxes.Reset(   );
           mTouchedPrimitives = &mTouchedBoxes;
          
           // Now,   do the actual query against leaf boxes
           if(  !model.HasLeafNodes(   ) )
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* Tree = (  const AABBQuantizedNoLeafTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBNoLeafTree* Tree = (  const AABBNoLeafTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           }
           else
           {
           if(  model.IsQuantized(   ) )
           {
           const AABBQuantizedTree* Tree = (  const AABBQuantizedTree* )model.GetTree(   );
          
           // Setup dequantization coeffs
           mCenterCoeff = Tree->mCenterCoeff;
           mExtentsCoeff = Tree->mExtentsCoeff;
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           else
           {
           const AABBCollisionTree* Tree = (  const AABBCollisionTree* )model.GetTree(   );
          
           // Perform collision query - we don't want primitive tests here!
           _CollideNoPrimitiveTest(  Tree->GetNodes(   ) );
           }
           }
          
           // We only have a list of boxes so far
           if(  GetContactStatus(   ) )
           {
           // Reset contact status,   since it currently only reflects collisions with leaf boxes
           Collider::InitQuery(   );
          
           // Change dest container so that we can use built-in overlap tests and get collided primitives
           cache.TouchedPrimitives.Reset(   );
           mTouchedPrimitives = &cache.TouchedPrimitives;
          
           // Read touched leaf boxes
           udword Nb = mTouchedBoxes.GetNbEntries(   );
           const udword* Touched = mTouchedBoxes.GetEntries(   );
          
           const LeafTriangles* LT = model.GetLeafTriangles(   );
           const udword* Indices = model.GetIndices(   );
          
           // Loop through touched leaves
           while(  Nb-- )
           {
           const LeafTriangles& CurrentLeaf = LT[*Touched++];
          
           // Each leaf box has a set of triangles
           udword NbTris = CurrentLeaf.GetNbTriangles(   );
           if(  Indices )
           {
           const udword* T = &Indices[CurrentLeaf.GetTriangleIndex(   )];
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = *T++;
           SPHERE_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           else
           {
           udword BaseIndex = CurrentLeaf.GetTriangleIndex(   );
          
           // Loop through triangles and test each of them
           while(  NbTris-- )
           {
           udword TriangleIndex = BaseIndex++;
           SPHERE_PRIM(  TriangleIndex,   OPC_CONTACT )
           }
           }
           }
           }
          
           return true;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_SweepAndPrune.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains an implementation of the sweep-and-prune algorithm (  moved from Z-Collide )
           * \file OPC_SweepAndPrune.cpp
           * \author Pierre Terdiman
           * \date January,   29,   2000
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
      24  inline_ void Sort(  udword& id0,   udword& id1 )
          {
           if(  id0>id1 ) Swap(  id0,   id1 );
          }
          
      29   class Opcode::SAP_Element
           {
           public:
      32   inline_ SAP_Element(   ) {}
      33   inline_ SAP_Element(  udword id,   SAP_Element* next ) : mID(  id ),   mNext(  next ) {}
      34   inline_ ~SAP_Element(   ) {}
          
      36   udword mID;
           SAP_Element* mNext;
           };
          
      40   class Opcode::SAP_Box
           {
           public:
      43   SAP_EndPoint* Min[3];
      44   SAP_EndPoint* Max[3];
           };
          
      47   class Opcode::SAP_EndPoint
           {
           public:
           float Value; // Min or Max value
           SAP_EndPoint* Previous; // Previous EndPoint whose Value is smaller than ours (  or null )
           SAP_EndPoint* Next; // Next EndPoint whose Value is greater than ours (  or null )
      53   udword Data; // Parent box ID *2 | MinMax flag
          
      55   inline_ void SetData(  udword box_id,   BOOL is_max ) { Data = (  box_id<<1 )|is_max; }
           inline_ BOOL IsMax(   ) const { return Data & 1; }
           inline_ udword GetBoxID(   ) const { return Data>>1; }
          
           inline_ void InsertAfter(  SAP_EndPoint* element )
           {
           if(  this!=element && this!=element->Next )
           {
           // Remove
           if(  Previous ) Previous->Next = Next;
           if(  Next ) Next->Previous = Previous;
          
           // Insert
           Next = element->Next;
           if(  Next ) Next->Previous = this;
          
           element->Next = this;
           Previous = element;
           }
           }
          
           inline_ void InsertBefore(  SAP_EndPoint* element )
           {
           if(  this!=element && this!=element->Previous )
           {
           // Remove
           if(  Previous ) Previous->Next = Next;
           if(  Next ) Next->Previous = Previous;
          
           // Insert
           Previous = element->Previous;
           element->Previous = this;
          
           Next = element;
           if(  Previous ) Previous->Next = this;
           }
           }
           };
          
          
          
          
          
          
          
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          SAP_PairData::SAP_PairData(   ) :
           mNbElements (  0 ),  
           mNbUsedElements (  0 ),  
           mElementPool (  null ),  
           mFirstFree (  null ),  
           mNbObjects (  0 ),  
           mArray (  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          SAP_PairData::~SAP_PairData(   )
          {
           Release(   );
          }
          
          void SAP_PairData::Release(   )
          {
           mNbElements = 0;
           mNbUsedElements = 0;
           mNbObjects = 0;
           DELETEARRAY(  mElementPool );
           DELETEARRAY(  mArray );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Initializes.
           * \param nb_objects [in]
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool SAP_PairData::Init(  udword nb_objects )
          {
           // Make sure everything has been released
           Release(   );
           if(  !nb_objects ) return false;
          
           mArray = new SAP_Element*[nb_objects];
           CHECKALLOC(  mArray );
           ZeroMemory(  mArray,   nb_objects*sizeof(  SAP_Element* ) );
           mNbObjects = nb_objects;
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Remaps a pointer when pool gets resized.
           * \param element [in/out] remapped element
           * \param delta [in] offset in bytes
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ void Remap(  SAP_Element*& element,   udword delta )
          {
           if(  element ) element = (  SAP_Element* )(  element + delta );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Gets a free element in the pool.
           * \param id [in] element id
           * \param next [in] next element
           * \param remap [out] possible remapping offset
           * \return the new element
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          SAP_Element* SAP_PairData::GetFreeElem(  udword id,   SAP_Element* next,   udword* remap )
          {
           if(  remap ) *remap = 0;
          
           SAP_Element* FreeElem;
           if(  mFirstFree )
           {
           // Recycle
           FreeElem = mFirstFree;
           mFirstFree = mFirstFree->mNext; // First free = next free (  or null )
           }
           else
           {
           if(  mNbUsedElements==mNbElements )
           {
           // Resize
           mNbElements = mNbElements ? (  mNbElements<<1 ) : 2;
          
           SAP_Element* NewElems = new SAP_Element[mNbElements];
          
           if(  mNbUsedElements ) CopyMemory(  NewElems,   mElementPool,   mNbUsedElements*sizeof(  SAP_Element ) );
          
           // Remap everything
           {
           size_t Delta = size_t(  NewElems ) - size_t(  mElementPool );
          
           for(  udword i=0;i<mNbUsedElements;i++ ) Remap(  NewElems[i].mNext,   Delta );
           for(  udword i=0;i<mNbObjects;i++ ) Remap(  mArray[i],   Delta );
          
           Remap(  mFirstFree,   Delta );
           Remap(  next,   Delta );
          
           if(  remap ) *remap = Delta;
           }
          
           DELETEARRAY(  mElementPool );
           mElementPool = NewElems;
           }
          
           FreeElem = &mElementPool[mNbUsedElements++];
           }
          
           FreeElem->mID = id;
           FreeElem->mNext = next;
          
           return FreeElem;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Frees an element of the pool.
           * \param elem [in] element to free/recycle
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ void SAP_PairData::FreeElem(  SAP_Element* elem )
          {
           elem->mNext = mFirstFree; // Next free
           mFirstFree = elem;
          }
          
          // Add a pair to the set.
          void SAP_PairData::AddPair(  udword id1,   udword id2 )
          {
           // Order the ids
           Sort(  id1,   id2 );
          
           ASSERT(  id1<mNbObjects );
           if(  id1>=mNbObjects ) return;
          
           // Select the right list from "mArray".
           SAP_Element* Current = mArray[id1];
          
           if(  !Current )
           {
           // Empty slot => create new element
           mArray[id1] = GetFreeElem(  id2,   null );
           }
           else if(  Current->mID>id2 )
           {
           // The list is not empty but all elements are greater than id2 => insert id2 in the front.
           mArray[id1] = GetFreeElem(  id2,   mArray[id1] );
           }
           else
           {
           // Else find the correct location in the sorted list (  ascending order ) and insert id2 there.
           while(  Current->mNext )
           {
           if(  Current->mNext->mID > id2 ) break;
          
           Current = Current->mNext;
           }
          
           if(  Current->mID==id2 ) return; // The pair already exists
          
          // Current->mNext = GetFreeElem(  id2,   Current->mNext );
           udword Delta;
           SAP_Element* E = GetFreeElem(  id2,   Current->mNext,   &Delta );
           if(  Delta ) Remap(  Current,   Delta );
           Current->mNext = E;
           }
          }
          
          // Delete a pair from the set.
          void SAP_PairData::RemovePair(  udword id1,   udword id2 )
          {
           // Order the ids.
           Sort(  id1,   id2 );
          
           // Exit if the pair doesn't exist in the set
           if(  id1>=mNbObjects ) return;
          
           // Otherwise,   select the correct list.
           SAP_Element* Current = mArray[id1];
          
           // If this list is empty,   the pair doesn't exist.
           if(  !Current ) return;
          
           // Otherwise,   if id2 is the first element,   delete it.
           if(  Current->mID==id2 )
           {
           mArray[id1] = Current->mNext;
           FreeElem(  Current );
           }
           else
           {
           // If id2 is not the first element,   start traversing the sorted list.
           while(  Current->mNext )
           {
           // If we have moved too far away without hitting id2,   then the pair doesn't exist
           if(  Current->mNext->mID > id2 ) return;
          
           // Otherwise,   delete id2.
           if(  Current->mNext->mID == id2 )
           {
           SAP_Element* Temp = Current->mNext;
           Current->mNext = Temp->mNext;
           FreeElem(  Temp );
           return;
           }
           Current = Current->mNext;
           }
           }
          }
          
          void SAP_PairData::DumpPairs(  Pairs& pairs ) const
          {
           // ### Ugly and slow
           for(  udword i=0;i<mNbObjects;i++ )
           {
           SAP_Element* Current = mArray[i];
           while(  Current )
           {
           ASSERT(  Current->mID<mNbObjects );
          
           pairs.AddPair(  i,   Current->mID );
           Current = Current->mNext;
           }
           }
          }
          
          void SAP_PairData::DumpPairs(  PairCallback callback,   void* user_data ) const
          {
           if(  !callback ) return;
          
           // ### Ugly and slow
           for(  udword i=0;i<mNbObjects;i++ )
           {
           SAP_Element* Current = mArray[i];
           while(  Current )
           {
           ASSERT(  Current->mID<mNbObjects );
          
           if(  !(  callback )(  i,   Current->mID,   user_data ) ) return;
           Current = Current->mNext;
           }
           }
          }
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          SweepAndPrune::SweepAndPrune(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          SweepAndPrune::~SweepAndPrune(   )
          {
          }
          
          void SweepAndPrune::GetPairs(  Pairs& pairs ) const
          {
           mPairs.DumpPairs(  pairs );
          }
          
          void SweepAndPrune::GetPairs(  PairCallback callback,   void* user_data ) const
          {
           mPairs.DumpPairs(  callback,   user_data );
          }
          
          bool SweepAndPrune::Init(  udword nb_objects,   const IceMaths::AABB** boxes )
          {
           // 1 ) Create sorted lists
           mNbObjects = nb_objects;
          
           mBoxes = new SAP_Box[nb_objects];
          // for(  udword i=0;i<nb_objects;i++ ) mBoxes[i].Box = *boxes[i];
          
           float* Data = new float[nb_objects*2];
          
           for(  udword Axis=0;Axis<3;Axis++ )
           {
           mList[Axis] = new SAP_EndPoint[nb_objects*2];
          
           for(  udword i=0;i<nb_objects;i++ )
           {
           Data[i*2+0] = boxes[i]->GetMin(  Axis );
           Data[i*2+1] = boxes[i]->GetMax(  Axis );
           }
           RadixSort RS;
           const udword* Sorted = RS.Sort(  Data,   nb_objects*2 ).GetRanks(   );
          
           SAP_EndPoint* PreviousEndPoint = null;
          
           for(  udword i=0;i<nb_objects*2;i++ )
           {
           udword SortedIndex = *Sorted++;
           float SortedCoord = Data[SortedIndex];
           udword BoxIndex = SortedIndex>>1;
          
           ASSERT(  BoxIndex<nb_objects );
          
           SAP_EndPoint* CurrentEndPoint = &mList[Axis][SortedIndex];
           CurrentEndPoint->Value = SortedCoord;
          // CurrentEndPoint->IsMax = SortedIndex&1; // ### could be implicit ?
          // CurrentEndPoint->ID = BoxIndex; // ### could be implicit ?
           CurrentEndPoint->SetData(  BoxIndex,   SortedIndex&1 ); // ### could be implicit ?
           CurrentEndPoint->Previous = PreviousEndPoint;
           CurrentEndPoint->Next = null;
           if(  PreviousEndPoint ) PreviousEndPoint->Next = CurrentEndPoint;
          
           if(  CurrentEndPoint->IsMax(   ) ) mBoxes[BoxIndex].Max[Axis] = CurrentEndPoint;
           else mBoxes[BoxIndex].Min[Axis] = CurrentEndPoint;
          
           PreviousEndPoint = CurrentEndPoint;
           }
           }
          
           DELETEARRAY(  Data );
          
           CheckListsIntegrity(   );
          
           // 2 ) Quickly find starting pairs
          
           mPairs.Init(  nb_objects );
          
           {
           Pairs P;
           CompleteBoxPruning(  nb_objects,   boxes,   P,   IceMaths::Axes(  IceMaths::AXES_XZY ) );
           for(  udword i=0;i<P.GetNbPairs(   );i++ )
           {
           const Pair* PP = P.GetPair(  i );
          
           udword id0 = PP->id0;
           udword id1 = PP->id1;
          
           if(  id0!=id1 && boxes[id0]->Intersect(  *boxes[id1] ) )
           {
           mPairs.AddPair(  id0,   id1 );
           }
           else ASSERT(  0 );
           }
           }
          
           return true;
          }
          
          bool SweepAndPrune::CheckListsIntegrity(   )
          {
           for(  udword Axis=0;Axis<3;Axis++ )
           {
           // Find list head
           SAP_EndPoint* Current = mList[Axis];
           while(  Current->Previous ) Current = Current->Previous;
          
           udword Nb = 0;
          
           SAP_EndPoint* Previous = null;
           while(  Current )
           {
           Nb++;
          
           if(  Previous )
           {
           ASSERT(  Previous->Value <= Current->Value );
           if(  Previous->Value > Current->Value ) return false;
           }
          
           ASSERT(  Current->Previous==Previous );
           if(  Current->Previous!=Previous ) return false;
          
           Previous = Current;
           Current = Current->Next;
           }
          
           ASSERT(  Nb==mNbObjects*2 );
           }
           return true;
          }
          
          inline_ BOOL Intersect(  const IceMaths::AABB& a,   const SAP_Box& b )
          {
           if(  b.Max[0]->Value < a.GetMin(  0 ) || a.GetMax(  0 ) < b.Min[0]->Value
           || b.Max[1]->Value < a.GetMin(  1 ) || a.GetMax(  1 ) < b.Min[1]->Value
           || b.Max[2]->Value < a.GetMin(  2 ) || a.GetMax(  2 ) < b.Min[2]->Value ) return FALSE;
          
           return TRUE;
          }
          
          
          
          bool SweepAndPrune::UpdateObject(  udword i,   const IceMaths::AABB& box )
          {
           for(  udword Axis=0;Axis<3;Axis++ )
           {
          // udword Base = (  udword )&mList[Axis][0];
          
           // Update min
           {
           SAP_EndPoint* const CurrentMin = mBoxes[i].Min[Axis];
           ASSERT(  !CurrentMin->IsMax(   ) );
          
           const float Limit = box.GetMin(  Axis );
           if(  Limit == CurrentMin->Value )
           {
           }
           else if(  Limit < CurrentMin->Value )
           {
           CurrentMin->Value = Limit;
          
           // Min is moving left:
           SAP_EndPoint* NewPos = CurrentMin;
           ASSERT(  NewPos );
          
           SAP_EndPoint* tmp;
           while(  (  tmp = NewPos->Previous ) && tmp->Value > Limit )
           {
           NewPos = tmp;
          
           if(  NewPos->IsMax(   ) )
           {
           // Our min passed a max => start overlap
           //udword SortedIndex = (  udword(  CurrentMin ) - Base )/sizeof(  NS_EndPoint );
           const udword id0 = CurrentMin->GetBoxID(   );
           const udword id1 = NewPos->GetBoxID(   );
          
           if(  id0!=id1 && Intersect(  box,   mBoxes[id1] ) ) mPairs.AddPair(  id0,   id1 );
           }
           }
          
           CurrentMin->InsertBefore(  NewPos );
           }
           else// if(  Limit > CurrentMin->Value )
           {
           CurrentMin->Value = Limit;
          
           // Min is moving right:
           SAP_EndPoint* NewPos = CurrentMin;
           ASSERT(  NewPos );
          
           SAP_EndPoint* tmp;
           while(  (  tmp = NewPos->Next ) && tmp->Value < Limit )
           {
           NewPos = tmp;
          
           if(  NewPos->IsMax(   ) )
           {
           // Our min passed a max => stop overlap
           const udword id0 = CurrentMin->GetBoxID(   );
           const udword id1 = NewPos->GetBoxID(   );
          
           if(  id0!=id1 ) mPairs.RemovePair(  id0,   id1 );
           }
           }
          
           CurrentMin->InsertAfter(  NewPos );
           }
           }
          
           // Update max
           {
           SAP_EndPoint* const CurrentMax = mBoxes[i].Max[Axis];
           ASSERT(  CurrentMax->IsMax(   ) );
          
           const float Limit = box.GetMax(  Axis );
           if(  Limit == CurrentMax->Value )
           {
           }
           else if(  Limit > CurrentMax->Value )
           {
           CurrentMax->Value = Limit;
          
           // Max is moving right:
           SAP_EndPoint* NewPos = CurrentMax;
           ASSERT(  NewPos );
          
           SAP_EndPoint* tmp;
           while(  (  tmp = NewPos->Next ) && tmp->Value < Limit )
           {
           NewPos = tmp;
          
           if(  !NewPos->IsMax(   ) )
           {
           // Our max passed a min => start overlap
           const udword id0 = CurrentMax->GetBoxID(   );
           const udword id1 = NewPos->GetBoxID(   );
          
           if(  id0!=id1 && Intersect(  box,   mBoxes[id1] ) ) mPairs.AddPair(  id0,   id1 );
           }
           }
          
           CurrentMax->InsertAfter(  NewPos );
           }
           else// if(  Limit < CurrentMax->Value )
           {
           CurrentMax->Value = Limit;
          
           // Max is moving left:
           SAP_EndPoint* NewPos = CurrentMax;
           ASSERT(  NewPos );
          
           SAP_EndPoint* tmp;
           while(  (  tmp = NewPos->Previous ) && tmp->Value > Limit )
           {
           NewPos = tmp;
          
           if(  !NewPos->IsMax(   ) )
           {
           // Our max passed a min => stop overlap
           const udword id0 = CurrentMax->GetBoxID(   );
           const udword id1 = NewPos->GetBoxID(   );
          
           if(  id0!=id1 ) mPairs.RemovePair(  id0,   id1 );
           }
           }
          
           CurrentMax->InsertBefore(  NewPos );
           }
           }
           }
          
           return true;
          }

./components/ogre/ogreopcode/src/Opcode/OPC_TreeBuilders.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for tree builders.
           * \file OPC_TreeBuilders.cpp
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * A builder for AABB-trees of vertices.
           *
           * \class AABBTreeOfVerticesBuilder
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * A builder for AABB-trees of AABBs.
           *
           * \class AABBTreeOfAABBsBuilder
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * A builder for AABB-trees of triangles.
           *
           * \class AABBTreeOfTrianglesBuilder
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the AABB of a set of primitives.
           * \param primitives [in] list of indices of primitives
           * \param nb_prims [in] number of indices
           * \param global_box [out] global AABB enclosing the set of input primitives
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      66  bool AABBTreeOfAABBsBuilder::ComputeGlobalBox(  const udword* primitives,   udword nb_prims,   IceMaths::AABB& global_box ) const
          {
           // Checkings
           if(  !primitives || !nb_prims ) return false;
          
           // Initialize global box
           global_box = mAABBArray[primitives[0]];
          
           // Loop through boxes
           for(  udword i=1;i<nb_prims;i++ )
           {
           // Update global box
           global_box.Add(  mAABBArray[primitives[i]] );
           }
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the splitting value along a given axis for a given primitive.
           * \param index [in] index of the primitive to split
           * \param axis [in] axis index (  0,  1,  2 )
           * \return splitting value
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      91  float AABBTreeOfAABBsBuilder::GetSplittingValue(  udword index,   udword axis ) const
          {
           // For an AABB,   the splitting value is the middle of the given axis,  
           // i.e. the corresponding component of the center point
           return mAABBArray[index].GetCenter(  axis );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the AABB of a set of primitives.
           * \param primitives [in] list of indices of primitives
           * \param nb_prims [in] number of indices
           * \param global_box [out] global AABB enclosing the set of input primitives
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     107  bool AABBTreeOfTrianglesBuilder::ComputeGlobalBox(  const udword* primitives,   udword nb_prims,   IceMaths::AABB& global_box ) const
          {
           // Checkings
           if(  !primitives || !nb_prims ) return false;
          
           // Initialize global box
           IceMaths::Point Min(  MAX_FLOAT,   MAX_FLOAT,   MAX_FLOAT );
           IceMaths::Point Max(  MIN_FLOAT,   MIN_FLOAT,   MIN_FLOAT );
          
           // Loop through triangles
           VertexPointers VP;
           while(  nb_prims-- )
           {
           // Get current triangle-vertices
           mIMesh->GetTriangle(  VP,   *primitives++ );
           // Update global box
           Min.Min(  *VP.Vertex[0] ).Min(  *VP.Vertex[1] ).Min(  *VP.Vertex[2] );
           Max.Max(  *VP.Vertex[0] ).Max(  *VP.Vertex[1] ).Max(  *VP.Vertex[2] );
           }
           global_box.SetMinMax(  Min,   Max );
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the splitting value along a given axis for a given primitive.
           * \param index [in] index of the primitive to split
           * \param axis [in] axis index (  0,  1,  2 )
           * \return splitting value
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     138  float AABBTreeOfTrianglesBuilder::GetSplittingValue(  udword index,   udword axis ) const
          {
          /* // Compute center of triangle
           Point Center;
           mTriList[index].Center(  mVerts,   Center );
           // Return value
           return Center[axis];*/
          
           // Compute correct component from center of triangle
          // return (  mVerts[mTriList[index].mVRef[0]][axis]
          // +mVerts[mTriList[index].mVRef[1]][axis]
          // +mVerts[mTriList[index].mVRef[2]][axis] )*INV3;
          
           VertexPointers VP;
           mIMesh->GetTriangle(  VP,   index );
          
           // Compute correct component from center of triangle
           return (  (  *VP.Vertex[0] )[axis]
           +(  *VP.Vertex[1] )[axis]
           +(  *VP.Vertex[2] )[axis] )*INV3;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the splitting value along a given axis for a given node.
           * \param primitives [in] list of indices of primitives
           * \param nb_prims [in] number of indices
           * \param global_box [in] global AABB enclosing the set of input primitives
           * \param axis [in] axis index (  0,  1,  2 )
           * \return splitting value
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     170  float AABBTreeOfTrianglesBuilder::GetSplittingValue(  const udword* primitives,   udword nb_prims,   const IceMaths::AABB& global_box,   udword axis ) const
          {
           if(  mSettings.mRules&SPLIT_GEOM_CENTER )
           {
           // Loop through triangles
           float SplitValue = 0.0f;
           VertexPointers VP;
           for(  udword i=0;i<nb_prims;i++ )
           {
           // Get current triangle-vertices
           mIMesh->GetTriangle(  VP,   primitives[i] );
           // Update split value
           SplitValue += (  *VP.Vertex[0] )[axis];
           SplitValue += (  *VP.Vertex[1] )[axis];
           SplitValue += (  *VP.Vertex[2] )[axis];
           }
           return SplitValue / float(  nb_prims*3 );
           }
           else return AABBTreeBuilder::GetSplittingValue(  primitives,   nb_prims,   global_box,   axis );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the AABB of a set of primitives.
           * \param primitives [in] list of indices of primitives
           * \param nb_prims [in] number of indices
           * \param global_box [out] global AABB enclosing the set of input primitives
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     200  bool AABBTreeOfVerticesBuilder::ComputeGlobalBox(  const udword* primitives,   udword nb_prims,   IceMaths::AABB& global_box ) const
          {
           // Checkings
           if(  !primitives || !nb_prims ) return false;
          
           // Initialize global box
           global_box.SetEmpty(   );
          
           // Loop through vertices
           for(  udword i=0;i<nb_prims;i++ )
           {
           // Update global box
           global_box.Extend(  mVertexArray[primitives[i]] );
           }
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the splitting value along a given axis for a given primitive.
           * \param index [in] index of the primitive to split
           * \param axis [in] axis index (  0,  1,  2 )
           * \return splitting value
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     225  float AABBTreeOfVerticesBuilder::GetSplittingValue(  udword index,   udword axis ) const
          {
           // For a vertex,   the splitting value is simply the vertex coordinate.
           return mVertexArray[index][axis];
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Computes the splitting value along a given axis for a given node.
           * \param primitives [in] list of indices of primitives
           * \param nb_prims [in] number of indices
           * \param global_box [in] global AABB enclosing the set of input primitives
           * \param axis [in] axis index (  0,  1,  2 )
           * \return splitting value
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     241  float AABBTreeOfVerticesBuilder::GetSplittingValue(  const udword* primitives,   udword nb_prims,   const IceMaths::AABB& global_box,   udword axis ) const
          {
           if(  mSettings.mRules&SPLIT_GEOM_CENTER )
           {
           // Loop through vertices
           float SplitValue = 0.0f;
           for(  udword i=0;i<nb_prims;i++ )
           {
           // Update split value
           SplitValue += mVertexArray[primitives[i]][axis];
           }
           return SplitValue / float(  nb_prims );
           }
           else return AABBTreeBuilder::GetSplittingValue(  primitives,   nb_prims,   global_box,   axis );
          }

./components/ogre/ogreopcode/src/Opcode/OPC_TreeCollider.cpp

          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           *
           * OPCODE modifications for scaled model support (  and other things )
           * Copyright (  C ) 2004 Gilvan Maia (  gilvan 'at' vdl.ufc.br )
           * Check http://www.vdl.ufc.br/gilvan/coll/opcode/index.htm for updates.
           *
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains code for a tree collider.
           * \file OPC_TreeCollider.cpp
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains an AABB tree collider.
           * This class performs a collision test between two AABB trees.
           * This class had changed a bit since jan/2005 in order to support scaled models.
           *
           * \class AABBTreeCollider
           * \author Pierre Terdiman
           * \version 1.3
           * \date March,   20,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          using namespace IceMaths;
          
          #include "Opcode/OPC_BoxBoxOverlap.h"
          #include "Opcode/OPC_TriBoxOverlap.h"
          
          // The tri-tri overlap
          #include "Opcode/OPC_TriTriOverlap.h" // Standard OPCODE's tri-tri overlap routine (  by Pierre )
          // #include "OPC_TriTriOverlapGilvan.h" // An optional tri-tri overlap routine based on SAT - Separating Axis Theorem (  by Gilvan )
          
          
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      57  AABBTreeCollider::AABBTreeCollider(   ) :
           mNbBVBVTests (  0 ),  
           mNbPrimPrimTests (  0 ),  
           mNbBVPrimTests (  0 ),  
           mScale0 (  1.0,  1.0,  1.0 ),  
           mScale1 (  1.0,  1.0,  1.0 ),  
           mFullBoxBoxTest (  true ),  
           mFullPrimBoxTest (  true ),  
           mIMesh0 (  null ),  
           mIMesh1 (  null )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      75  AABBTreeCollider::~AABBTreeCollider(   )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Validates current settings. You should call this method after all the settings and callbacks have been defined.
           * \return null if everything is ok,   else a string describing the problem
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      85  const char* AABBTreeCollider::ValidateSettings(   )
          {
           if(  TemporalCoherenceEnabled(   ) && !FirstContactEnabled(   ) ) return "Temporal coherence only works with ""First contact"" mode!";
           return null;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Generic collision query for generic OPCODE models. After the call,   access the results with:
           * - GetContactStatus(   )
           * - GetNbPairs(   )
           * - GetPairs(   )
           *
           * \param cache [in] collision cache for model pointers and a colliding pair of primitives
           * \param world0 [in] world matrix for first object
           * \param world1 [in] world matrix for second object
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     104  bool AABBTreeCollider::Collide(  BVTCache& cache,   const IceMaths::Matrix4x4* world0,   const IceMaths::Matrix4x4* world1 )
          {
           // Checkings: olny works for corresponding models(  leaf style and quantization  )
           if(  !cache.Model0 || !cache.Model1 ) return false;
           if(  cache.Model0->HasLeafNodes(   )!=cache.Model1->HasLeafNodes(   ) ) return false;
           if(  cache.Model0->IsQuantized(   )!=cache.Model1->IsQuantized(   ) ) return false;
          
           /*
          
           Rules:
           - perform hull test
           - when hulls collide,   disable hull test
           - if meshes overlap,   reset countdown
           - if countdown reaches 0,   enable hull test
          
           */
          
          #ifdef __MESHMERIZER_H__
           // Handle hulls
           if(  cache.HullTest )
           {
           if(  cache.Model0->GetHull(   ) && cache.Model1->GetHull(   ) )
           {
           struct Local
           {
           static IceMaths::Point* SVCallback(  const IceMaths::Point& sv,   udword& previndex,   udword user_data )
           {
           CollisionHull* Hull = (  CollisionHull* )user_data;
           previndex = Hull->ComputeSupportingVertex(  sv,   previndex );
           return (  IceMaths::Point* )&Hull->GetVerts(   )[previndex];
           }
           };
          
           bool Collide;
          
           if(  0 )
           {
           static GJKEngine GJK;
           static bool GJKInitDone=false;
           if(  !GJKInitDone )
           {
           GJK.Enable(  GJK_BACKUP_PROCEDURE );
           GJK.Enable(  GJK_DEGENERATE );
           GJK.Enable(  GJK_HILLCLIMBING );
           GJKInitDone = true;
           }
           GJK.SetCallbackObj0(  Local::SVCallback );
           GJK.SetCallbackObj1(  Local::SVCallback );
           GJK.SetUserData0(  udword(  cache.Model0->GetHull(   ) ) );
           GJK.SetUserData1(  udword(  cache.Model1->GetHull(   ) ) );
           Collide = GJK.Collide(  *world0,   *world1,   &cache.SepVector );
           }
           else
           {
           static SVEngine SVE;
           SVE.SetCallbackObj0(  Local::SVCallback );
           SVE.SetCallbackObj1(  Local::SVCallback );
           SVE.SetUserData0(  udword(  cache.Model0->GetHull(   ) ) );
           SVE.SetUserData1(  udword(  cache.Model1->GetHull(   ) ) );
           Collide = SVE.Collide(  *world0,   *world1,   &cache.SepVector );
           }
          
           if(  !Collide )
           {
           // Reset stats & contact status
           mFlags &= ~OPC_CONTACT;
           mNbBVBVTests = 0;
           mNbPrimPrimTests = 0;
           mNbBVPrimTests = 0;
           mPairs.Reset(   );
           return true;
           }
           }
           }
          
           // Here,   hulls collide
           cache.HullTest = false;
          #endif // __MESHMERIZER_H__
          
           // Checkings: was this modified by someone? Why?
           // mFlags &= ~OPC_CONTACT;
           if(  !Setup(  cache.Model0->GetMeshInterface(   ),   cache.Model1->GetMeshInterface(   ) ) ) return false;
          
           // Simple double-dispatch
           bool Status;
           if(  !cache.Model0->HasLeafNodes(   ) )
           {
           if(  cache.Model0->IsQuantized(   ) )
           {
           const AABBQuantizedNoLeafTree* T0 = (  const AABBQuantizedNoLeafTree* )cache.Model0->GetTree(   );
           const AABBQuantizedNoLeafTree* T1 = (  const AABBQuantizedNoLeafTree* )cache.Model1->GetTree(   );
           Status = Collide(  T0,   T1,   world0,   world1,   &cache );
           }
           else
           {
           const AABBNoLeafTree* T0 = (  const AABBNoLeafTree* )cache.Model0->GetTree(   );
           const AABBNoLeafTree* T1 = (  const AABBNoLeafTree* )cache.Model1->GetTree(   );
           Status = Collide(  T0,   T1,   world0,   world1,   &cache );
           }
           }
           else
           {
           if(  cache.Model0->IsQuantized(   ) )
           {
           const AABBQuantizedTree* T0 = (  const AABBQuantizedTree* )cache.Model0->GetTree(   );
           const AABBQuantizedTree* T1 = (  const AABBQuantizedTree* )cache.Model1->GetTree(   );
           Status = Collide(  T0,   T1,   world0,   world1,   &cache );
           }
           else
           {
           const AABBCollisionTree* T0 = (  const AABBCollisionTree* )cache.Model0->GetTree(   );
           const AABBCollisionTree* T1 = (  const AABBCollisionTree* )cache.Model1->GetTree(   );
           Status = Collide(  T0,   T1,   world0,   world1,   &cache );
           }
           }
          
          #ifdef __MESHMERIZER_H__
           if(  Status )
           {
           // Reset counter as long as overlap occurs
           if(  GetContactStatus(   ) ) cache.ResetCountDown(   );
          
           // Enable hull test again when counter reaches zero
           cache.CountDown--;
           if(  !cache.CountDown )
           {
           cache.ResetCountDown(   );
           cache.HullTest = true;
           }
           }
          #endif
           return Status;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Initializes a collision query :
           * - reset stats & contact status
           * - setup matrices
           *
           * \param world0 [in] world matrix for first object
           * \param world1 [in] world matrix for second object
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     248  void AABBTreeCollider::InitQuery(  const IceMaths::Matrix4x4* world0,   const IceMaths::Matrix4x4* world1 )
          {
           // Reset stats & contact status
           Collider::InitQuery(   );
           mNbBVBVTests = 0;
           mNbPrimPrimTests = 0;
           mNbBVPrimTests = 0;
           mPairs.Reset(   );
          
           // Setup matrices
           IceMaths::Matrix4x4 InvWorld0,   InvWorld1;
           IceMaths::Matrix4x4 WorldM0,   WorldM1; // normalized (  rotation & translation parts )
          
           if(  world0 )
           {
           NormalizePRSMatrix(   WorldM0,   mScale0,  *world0 );
          
           InvertPRMatrix(  InvWorld0,   WorldM0 );
           }
           else
           {
           mScale0.Set(  1.0,  1.0,  1.0 );
           InvWorld0.Identity(   );
           }
          
           if(  world1 )
           {
           NormalizePRSMatrix(   WorldM1,   mScale1,  *world1 );
          
           InvertPRMatrix(  InvWorld1,   WorldM1 );
           }
           else
           {
           mScale1.Set(  1.0,  1.0,  1.0 );
           InvWorld1.Identity(   );
           }
          
           IceMaths::Matrix4x4 World0to1 = world0 ? (  WorldM0 * InvWorld1 ) : InvWorld1;
           IceMaths::Matrix4x4 World1to0 = world1 ? (  WorldM1 * InvWorld0 ) : InvWorld0;
           // scale & rotation only
           mSR0to1 = world0 ? (  *world0 * InvWorld1 ) : InvWorld1;
           mSR1to0 = world1 ? (  *world1 * InvWorld0 ) : InvWorld0;
           // rotation & translation only
           mR0to1 = World0to1; World0to1.GetTrans(  mT0to1 );
           mR1to0 = World1to0; World1to0.GetTrans(  mT1to0 );
          
           // Precompute absolute 1-to-0 rotation matrix
           for(  udword i=0;i<3;i++ )
           {
           for(  udword j=0;j<3;j++ )
           {
           // Epsilon value prevents floating-point inaccuracies (  strategy borrowed from RAPID )
           mAR.m[i][j] = 1e-6f + fabsf(  mR1to0.m[i][j] );
           }
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Takes advantage of temporal coherence.
           * \param cache [in] cache for a pair of previously colliding primitives
           * \return true if we can return immediately
           * \warning only works for "First Contact" mode
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     313  bool AABBTreeCollider::CheckTemporalCoherence(  Pair* cache )
          {
           // Checkings
           if(  !cache ) return false;
          
           // Test previously colliding primitives first
           if(  TemporalCoherenceEnabled(   ) && FirstContactEnabled(   ) )
           {
           PrimTest(  cache->id0,   cache->id1 );
           if(  GetContactStatus(   ) ) return true;
           }
           return false;
          }
          
          #define UPDATE_CACHE \
           if(  cache && GetContactStatus(   ) ) \
           { \
           cache->id0 = mPairs.GetEntry(  0 ); \
           cache->id1 = mPairs.GetEntry(  1 ); \
           }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Collision query for normal AABB trees.
           * \param tree0 [in] AABB tree from first object
           * \param tree1 [in] AABB tree from second object
           * \param world0 [in] world matrix for first object
           * \param world1 [in] world matrix for second object
           * \param cache [in/out] cache for a pair of previously colliding primitives
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBTreeCollider::Collide(  const AABBCollisionTree* tree0,   const AABBCollisionTree* tree1,   const IceMaths::Matrix4x4* world0,   const IceMaths::Matrix4x4* world1,   Pair* cache )
          {
           // Init collision query
           InitQuery(  world0,   world1 );
          
           // Check previous state
           if(  CheckTemporalCoherence(  cache ) ) return true;
          
           // Perform collision query
           _Collide(  tree0->GetNodes(   ),   tree1->GetNodes(   ) );
          
           UPDATE_CACHE
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Collision query for no-leaf AABB trees.
           * \param tree0 [in] AABB tree from first object
           * \param tree1 [in] AABB tree from second object
           * \param world0 [in] world matrix for first object
           * \param world1 [in] world matrix for second object
           * \param cache [in/out] cache for a pair of previously colliding primitives
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBTreeCollider::Collide(  const AABBNoLeafTree* tree0,   const AABBNoLeafTree* tree1,   const IceMaths::Matrix4x4* world0,   const IceMaths::Matrix4x4* world1,   Pair* cache )
          {
           // Init collision query
           InitQuery(  world0,   world1 );
          
           // Check previous state
           if(  CheckTemporalCoherence(  cache ) ) return true;
          
           // Perform collision query
           _Collide(  tree0->GetNodes(   ),   tree1->GetNodes(   ) );
          
           UPDATE_CACHE
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Collision query for quantized AABB trees.
           * \param tree0 [in] AABB tree from first object
           * \param tree1 [in] AABB tree from second object
           * \param world0 [in] world matrix for first object
           * \param world1 [in] world matrix for second object
           * \param cache [in/out] cache for a pair of previously colliding primitives
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBTreeCollider::Collide(  const AABBQuantizedTree* tree0,   const AABBQuantizedTree* tree1,   const IceMaths::Matrix4x4* world0,   const IceMaths::Matrix4x4* world1,   Pair* cache )
          {
           // Init collision query
           InitQuery(  world0,   world1 );
          
           // Check previous state
           if(  CheckTemporalCoherence(  cache ) ) return true;
          
           // Setup dequantization coeffs
           mCenterCoeff0 = tree0->mCenterCoeff;
           mExtentsCoeff0 = tree0->mExtentsCoeff;
           mCenterCoeff1 = tree1->mCenterCoeff;
           mExtentsCoeff1 = tree1->mExtentsCoeff;
          
           // Dequantize box A
           const AABBQuantizedNode* N0 = tree0->GetNodes(   );
           const IceMaths::Point a(  float(  N0->mAABB.mExtents[0] ) * mExtentsCoeff0.x,   float(  N0->mAABB.mExtents[1] ) * mExtentsCoeff0.y,   float(  N0->mAABB.mExtents[2] ) * mExtentsCoeff0.z );
           const IceMaths::Point Pa(  float(  N0->mAABB.mCenter[0] ) * mCenterCoeff0.x,   float(  N0->mAABB.mCenter[1] ) * mCenterCoeff0.y,   float(  N0->mAABB.mCenter[2] ) * mCenterCoeff0.z );
           // Dequantize box B
           const AABBQuantizedNode* N1 = tree1->GetNodes(   );
           const IceMaths::Point b(  float(  N1->mAABB.mExtents[0] ) * mExtentsCoeff1.x,   float(  N1->mAABB.mExtents[1] ) * mExtentsCoeff1.y,   float(  N1->mAABB.mExtents[2] ) * mExtentsCoeff1.z );
           const IceMaths::Point Pb(  float(  N1->mAABB.mCenter[0] ) * mCenterCoeff1.x,   float(  N1->mAABB.mCenter[1] ) * mCenterCoeff1.y,   float(  N1->mAABB.mCenter[2] ) * mCenterCoeff1.z );
          
           // Perform collision query
           _Collide(  N0,   N1,   a,   Pa,   b,   Pb );
          
           UPDATE_CACHE
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Collision query for quantized no-leaf AABB trees.
           * \param tree0 [in] AABB tree from first object
           * \param tree1 [in] AABB tree from second object
           * \param world0 [in] world matrix for first object
           * \param world1 [in] world matrix for second object
           * \param cache [in/out] cache for a pair of previously colliding primitives
           * \return true if success
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          bool AABBTreeCollider::Collide(  const AABBQuantizedNoLeafTree* tree0,   const AABBQuantizedNoLeafTree* tree1,   const IceMaths::Matrix4x4* world0,   const IceMaths::Matrix4x4* world1,   Pair* cache )
          {
           // Init collision query
           InitQuery(  world0,   world1 );
          
           // Check previous state
           if(  CheckTemporalCoherence(  cache ) ) return true;
          
           // Setup dequantization coeffs
           mCenterCoeff0 = tree0->mCenterCoeff;
           mExtentsCoeff0 = tree0->mExtentsCoeff;
           mCenterCoeff1 = tree1->mCenterCoeff;
           mExtentsCoeff1 = tree1->mExtentsCoeff;
          
           // Perform collision query
           _Collide(  tree0->GetNodes(   ),   tree1->GetNodes(   ) );
          
           UPDATE_CACHE
          
           return true;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Standard trees
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          // The normal AABB tree can use 2 different descent rules (  with different performances )
          //#define ORIGINAL_CODE //!< UNC-like descent rules
          #define ALTERNATIVE_CODE //!< Alternative descent rules
          
          #ifdef ORIGINAL_CODE
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees.
           * \param b0 [in] collision node from first tree
           * \param b1 [in] collision node from second tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::_Collide(  const AABBCollisionNode* b0,   const AABBCollisionNode* b1 )
          {
           // Perform BV-BV overlap test
           if(  !BoxBoxOverlap(  b0->mAABB.mExtents,   b0->mAABB.mCenter,   b1->mAABB.mExtents,   b1->mAABB.mCenter ) ) return;
          
           if(  b0->IsLeaf(   ) && b1->IsLeaf(   ) ) { PrimTest(  b0->GetPrimitive(   ),   b1->GetPrimitive(   ) ); return; }
          
           if(  b1->IsLeaf(   ) || (  !b0->IsLeaf(   ) && (  b0->GetSize(   ) > b1->GetSize(   ) ) ) )
           {
           _Collide(  b0->GetNeg(   ),   b1 );
           if(  ContactFound(   ) ) return;
           _Collide(  b0->GetPos(   ),   b1 );
           }
           else
           {
           _Collide(  b0,   b1->GetNeg(   ) );
           if(  ContactFound(   ) ) return;
           _Collide(  b0,   b1->GetPos(   ) );
           }
          }
          #endif
          
          #ifdef ALTERNATIVE_CODE
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for normal AABB trees.
           * \param b0 [in] collision node from first tree
           * \param b1 [in] collision node from second tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::_Collide(  const AABBCollisionNode* b0,   const AABBCollisionNode* b1 )
          {
           // Perform BV-BV overlap test
           if(  !BoxBoxOverlap(  b0->mAABB.mExtents,   b0->mAABB.mCenter,   b1->mAABB.mExtents,   b1->mAABB.mCenter ) )
           {
           return;
           }
          
           if(  b0->IsLeaf(   ) )
           {
           if(  b1->IsLeaf(   ) )
           {
           PrimTest(  b0->GetPrimitive(   ),   b1->GetPrimitive(   ) );
           }
           else
           {
           _Collide(  b0,   b1->GetNeg(   ) );
           if(  ContactFound(   ) ) return;
           _Collide(  b0,   b1->GetPos(   ) );
           }
           }
           else if(  b1->IsLeaf(   ) )
           {
           _Collide(  b0->GetNeg(   ),   b1 );
           if(  ContactFound(   ) ) return;
           _Collide(  b0->GetPos(   ),   b1 );
           }
           else
           {
           _Collide(  b0->GetNeg(   ),   b1->GetNeg(   ) );
           if(  ContactFound(   ) ) return;
           _Collide(  b0->GetNeg(   ),   b1->GetPos(   ) );
           if(  ContactFound(   ) ) return;
           _Collide(  b0->GetPos(   ),   b1->GetNeg(   ) );
           if(  ContactFound(   ) ) return;
           _Collide(  b0->GetPos(   ),   b1->GetPos(   ) );
           }
          }
          #endif
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // No-leaf trees
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Leaf-leaf test for two primitive indices.
           * \param id0 [in] index from first leaf-triangle
           * \param id1 [in] index from second leaf-triangle
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::PrimTest(  udword id0,   udword id1 )
          {
           // Request vertices from the app
           VertexPointers VP0;
           VertexPointers VP1;
           mIMesh0->GetTriangle(  VP0,   id0 );
           mIMesh1->GetTriangle(  VP1,   id1 );
          
           // Transform from space 1 to space 0 (  applies scale 1 to u0u1u2 )
           IceMaths::Point u0,  u1,  u2;
           TransformPoint(  u0,   *VP1.Vertex[0],   mSR1to0,   mT1to0 );
           TransformPoint(  u1,   *VP1.Vertex[1],   mSR1to0,   mT1to0 );
           TransformPoint(  u2,   *VP1.Vertex[2],   mSR1to0,   mT1to0 );
          
           // Perform triangle-triangle overlap test (  includes scale 0 to v0v1v2 )
           if(  TriTriOverlap(  (  *VP0.Vertex[0] )*mScale0,   (  *VP0.Vertex[1] )*mScale0,   (  *VP0.Vertex[2] )*mScale0,   u0,   u1,   u2 ) )
           {
           // Keep track of colliding pairs
           mPairs.Add(  id0 ).Add(  id1 );
           // Set contact status
           mFlags |= OPC_CONTACT;
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Leaf-leaf test for a previously fetched triangle from tree A (  in B's space ) and a new leaf from B.
           * \param id1 [in] leaf-triangle index from tree B
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ void AABBTreeCollider::PrimTestTriIndex(  udword id1 )
          {
           // Request vertices from the app
           VertexPointers VP;
           mIMesh1->GetTriangle(  VP,   id1 );
          
           // Perform triangle-triangle overlap test (  uses mScale1 )
           if(  TriTriOverlap(  mLeafVerts[0],   mLeafVerts[1],   mLeafVerts[2],   *VP.Vertex[0]*mScale1,   *VP.Vertex[1]*mScale1,   *VP.Vertex[2]*mScale1 ) )
           {
           // Keep track of colliding pairs
           mPairs.Add(  mLeafIndex ).Add(  id1 );
           // Set contact status
           mFlags |= OPC_CONTACT;
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Leaf-leaf test for a previously fetched triangle from tree B (  in A's space ) and a new leaf from A.
           * \param id0 [in] leaf-triangle index from tree A
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          inline_ void AABBTreeCollider::PrimTestIndexTri(  udword id0 )
          {
           // Request vertices from the app
           VertexPointers VP;
           mIMesh0->GetTriangle(  VP,   id0 );
          
           // Perform triangle-triangle overlap test (  uses mScale0 )
           if(  TriTriOverlap(  mLeafVerts[0],   mLeafVerts[1],   mLeafVerts[2],   *VP.Vertex[0]*mScale0,   *VP.Vertex[1]*mScale0,   *VP.Vertex[2]*mScale0 ) )
           {
           // Keep track of colliding pairs
           mPairs.Add(  id0 ).Add(  mLeafIndex );
           // Set contact status
           mFlags |= OPC_CONTACT;
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision of a leaf node from A and a branch from B.
           * \param b [in] collision node from second tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::_CollideTriBox(  const AABBNoLeafNode* b )
          {
           // Perform triangle-box overlap test (  applies mScale1 on the box first! )
           if(  !TriBoxOverlap(  b->mAABB.mCenter*mScale1,   b->mAABB.mExtents*mScale1 ) ) return;
          
           // Keep same triangle,   deal with first child
           if(  b->HasPosLeaf(   ) ) PrimTestTriIndex(  b->GetPosPrimitive(   ) );
           else _CollideTriBox(  b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           // Keep same triangle,   deal with second child
           if(  b->HasNegLeaf(   ) ) PrimTestTriIndex(  b->GetNegPrimitive(   ) );
           else _CollideTriBox(  b->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision of a leaf node from B and a branch from A.
           * \param b [in] collision node from first tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::_CollideBoxTri(  const AABBNoLeafNode* b )
          {
           // Perform triangle-box overlap test (  applies mScale0 on the box first! )
           if(  !TriBoxOverlap(  b->mAABB.mCenter*mScale0,   b->mAABB.mExtents*mScale0 ) ) return;
          
           // Keep same triangle,   deal with first child
           if(  b->HasPosLeaf(   ) ) PrimTestIndexTri(  b->GetPosPrimitive(   ) );
           else _CollideBoxTri(  b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           // Keep same triangle,   deal with second child
           if(  b->HasNegLeaf(   ) ) PrimTestIndexTri(  b->GetNegPrimitive(   ) );
           else _CollideBoxTri(  b->GetNeg(   ) );
          }
          
          //! Request triangle vertices from the app and transform them
          #define FETCH_LEAF(  prim_index,   imesh,   rot,   trans ) \
           mLeafIndex = prim_index; \
           /* Request vertices from the app */ \
           VertexPointers VP; imesh->GetTriangle(  VP,   prim_index ); \
           /* Transform them in a common space */ \
           TransformPoint(  mLeafVerts[0],   *VP.Vertex[0],   rot,   trans ); \
           TransformPoint(  mLeafVerts[1],   *VP.Vertex[1],   rot,   trans ); \
           TransformPoint(  mLeafVerts[2],   *VP.Vertex[2],   rot,   trans );
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for no-leaf AABB trees.
           * \param a [in] collision node from first tree
           * \param b [in] collision node from second tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::_Collide(  const AABBNoLeafNode* a,   const AABBNoLeafNode* b )
          {
           // Perform BV-BV overlap test (  uses  )
           if(  !BoxBoxOverlap(  a->mAABB.mExtents,   a->mAABB.mCenter,   b->mAABB.mExtents,   b->mAABB.mCenter ) ) return;
          
           // Catch leaf status
           BOOL BHasPosLeaf = b->HasPosLeaf(   );
           BOOL BHasNegLeaf = b->HasNegLeaf(   );
          
           if(  a->HasPosLeaf(   ) )
           {
           FETCH_LEAF(  a->GetPosPrimitive(   ),   mIMesh0,   mSR0to1,   mT0to1 )
          
           if(  BHasPosLeaf ) PrimTestTriIndex(  b->GetPosPrimitive(   ) );
           else _CollideTriBox(  b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  BHasNegLeaf ) PrimTestTriIndex(  b->GetNegPrimitive(   ) );
           else _CollideTriBox(  b->GetNeg(   ) );
           }
           else
           {
           if(  BHasPosLeaf )
           {
           FETCH_LEAF(  b->GetPosPrimitive(   ),   mIMesh1,   mSR1to0,   mT1to0 )
          
           _CollideBoxTri(  a->GetPos(   ) );
           }
           else _Collide(  a->GetPos(   ),   b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  BHasNegLeaf )
           {
           FETCH_LEAF(  b->GetNegPrimitive(   ),   mIMesh1,   mSR1to0,   mT1to0 )
          
           _CollideBoxTri(  a->GetPos(   ) );
           }
           else _Collide(  a->GetPos(   ),   b->GetNeg(   ) );
           }
          
           if(  ContactFound(   ) ) return;
          
           if(  a->HasNegLeaf(   ) )
           {
           FETCH_LEAF(  a->GetNegPrimitive(   ),   mIMesh0,   mSR0to1,   mT0to1 )
          
           if(  BHasPosLeaf ) PrimTestTriIndex(  b->GetPosPrimitive(   ) );
           else _CollideTriBox(  b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  BHasNegLeaf ) PrimTestTriIndex(  b->GetNegPrimitive(   ) );
           else _CollideTriBox(  b->GetNeg(   ) );
           }
           else
           {
           if(  BHasPosLeaf )
           {
           // ### That leaf has possibly already been fetched
           FETCH_LEAF(  b->GetPosPrimitive(   ),   mIMesh1,   mSR1to0,   mT1to0 )
          
           _CollideBoxTri(  a->GetNeg(   ) );
           }
           else _Collide(  a->GetNeg(   ),   b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  BHasNegLeaf )
           {
           // ### That leaf has possibly already been fetched
           FETCH_LEAF(  b->GetNegPrimitive(   ),   mIMesh1,   mSR1to0,   mT1to0 )
          
           _CollideBoxTri(  a->GetNeg(   ) );
           }
           else _Collide(  a->GetNeg(   ),   b->GetNeg(   ) );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Quantized trees
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized AABB trees.
           * \param b0 [in] collision node from first tree
           * \param b1 [in] collision node from second tree
           * \param a [in] extent from box A
           * \param Pa [in] center from box A
           * \param b [in] extent from box B
           * \param Pb [in] center from box B
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::_Collide(  const AABBQuantizedNode* b0,   const AABBQuantizedNode* b1,   const IceMaths::Point& a,   const IceMaths::Point& Pa,   const IceMaths::Point& b,   const IceMaths::Point& Pb )
          {
           // Perform BV-BV overlap test
           if(  !BoxBoxOverlap(  a,   Pa,   b,   Pb ) ) return;
          
           if(  b0->IsLeaf(   ) && b1->IsLeaf(   ) ) { PrimTest(  b0->GetPrimitive(   ),   b1->GetPrimitive(   ) ); return; }
          
           if(  b1->IsLeaf(   ) || (  !b0->IsLeaf(   ) && (  b0->GetSize(   ) > b1->GetSize(   ) ) ) )
           {
           // Dequantize box
           const QuantizedAABB* Box = &b0->GetNeg(   )->mAABB;
           const IceMaths::Point negPa(  float(  Box->mCenter[0] ) * mCenterCoeff0.x,   float(  Box->mCenter[1] ) * mCenterCoeff0.y,   float(  Box->mCenter[2] ) * mCenterCoeff0.z );
           const IceMaths::Point nega(  float(  Box->mExtents[0] ) * mExtentsCoeff0.x,   float(  Box->mExtents[1] ) * mExtentsCoeff0.y,   float(  Box->mExtents[2] ) * mExtentsCoeff0.z );
           _Collide(  b0->GetNeg(   ),   b1,   nega,   negPa,   b,   Pb );
          
           if(  ContactFound(   ) ) return;
          
           // Dequantize box
           Box = &b0->GetPos(   )->mAABB;
           const IceMaths::Point posPa(  float(  Box->mCenter[0] ) * mCenterCoeff0.x,   float(  Box->mCenter[1] ) * mCenterCoeff0.y,   float(  Box->mCenter[2] ) * mCenterCoeff0.z );
           const IceMaths::Point posa(  float(  Box->mExtents[0] ) * mExtentsCoeff0.x,   float(  Box->mExtents[1] ) * mExtentsCoeff0.y,   float(  Box->mExtents[2] ) * mExtentsCoeff0.z );
           _Collide(  b0->GetPos(   ),   b1,   posa,   posPa,   b,   Pb );
           }
           else
           {
           // Dequantize box
           const QuantizedAABB* Box = &b1->GetNeg(   )->mAABB;
           const IceMaths::Point negPb(  float(  Box->mCenter[0] ) * mCenterCoeff1.x,   float(  Box->mCenter[1] ) * mCenterCoeff1.y,   float(  Box->mCenter[2] ) * mCenterCoeff1.z );
           const IceMaths::Point negb(  float(  Box->mExtents[0] ) * mExtentsCoeff1.x,   float(  Box->mExtents[1] ) * mExtentsCoeff1.y,   float(  Box->mExtents[2] ) * mExtentsCoeff1.z );
           _Collide(  b0,   b1->GetNeg(   ),   a,   Pa,   negb,   negPb );
          
           if(  ContactFound(   ) ) return;
          
           // Dequantize box
           Box = &b1->GetPos(   )->mAABB;
           const IceMaths::Point posPb(  float(  Box->mCenter[0] ) * mCenterCoeff1.x,   float(  Box->mCenter[1] ) * mCenterCoeff1.y,   float(  Box->mCenter[2] ) * mCenterCoeff1.z );
           const IceMaths::Point posb(  float(  Box->mExtents[0] ) * mExtentsCoeff1.x,   float(  Box->mExtents[1] ) * mExtentsCoeff1.y,   float(  Box->mExtents[2] ) * mExtentsCoeff1.z );
           _Collide(  b0,   b1->GetPos(   ),   a,   Pa,   posb,   posPb );
           }
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Quantized no-leaf trees
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision of a leaf node from A and a quantized branch from B.
           * \param leaf [in] leaf triangle from first tree
           * \param b [in] collision node from second tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::_CollideTriBox(  const AABBQuantizedNoLeafNode* b )
          {
           // Dequantize box
           const QuantizedAABB* bb = &b->mAABB;
           const IceMaths::Point Pb(  float(  bb->mCenter[0] ) * mCenterCoeff1.x,   float(  bb->mCenter[1] ) * mCenterCoeff1.y,   float(  bb->mCenter[2] ) * mCenterCoeff1.z );
           const IceMaths::Point eb(  float(  bb->mExtents[0] ) * mExtentsCoeff1.x,   float(  bb->mExtents[1] ) * mExtentsCoeff1.y,   float(  bb->mExtents[2] ) * mExtentsCoeff1.z );
          
           // Perform triangle-box overlap test (  box comes from B,   so apply mScale1 to it )
           if(  !TriBoxOverlap(  Pb*mScale1,   eb*mScale1 ) ) return;
          
           if(  b->HasPosLeaf(   ) ) PrimTestTriIndex(  b->GetPosPrimitive(   ) );
           else _CollideTriBox(  b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  b->HasNegLeaf(   ) ) PrimTestTriIndex(  b->GetNegPrimitive(   ) );
           else _CollideTriBox(  b->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision of a leaf node from B and a quantized branch from A.
           * \param b [in] collision node from first tree
           * \param leaf [in] leaf triangle from second tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::_CollideBoxTri(  const AABBQuantizedNoLeafNode* b )
          {
           // Dequantize box
           const QuantizedAABB* bb = &b->mAABB;
           const IceMaths::Point Pa(  float(  bb->mCenter[0] ) * mCenterCoeff0.x,   float(  bb->mCenter[1] ) * mCenterCoeff0.y,   float(  bb->mCenter[2] ) * mCenterCoeff0.z );
           const IceMaths::Point ea(  float(  bb->mExtents[0] ) * mExtentsCoeff0.x,   float(  bb->mExtents[1] ) * mExtentsCoeff0.y,   float(  bb->mExtents[2] ) * mExtentsCoeff0.z );
          
           // Perform triangle-box overlap test (  box comes from A,   so apply mScale0 to it )
           if(  !TriBoxOverlap(  Pa*mScale0,   ea*mScale0 ) ) return;
          
           if(  b->HasPosLeaf(   ) ) PrimTestIndexTri(  b->GetPosPrimitive(   ) );
           else _CollideBoxTri(  b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  b->HasNegLeaf(   ) ) PrimTestIndexTri(  b->GetNegPrimitive(   ) );
           else _CollideBoxTri(  b->GetNeg(   ) );
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Recursive collision query for quantized no-leaf AABB trees.
           * \param a [in] collision node from first tree
           * \param b [in] collision node from second tree
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          void AABBTreeCollider::_Collide(  const AABBQuantizedNoLeafNode* a,   const AABBQuantizedNoLeafNode* b )
          {
           // Dequantize box A
           const QuantizedAABB* ab = &a->mAABB;
           const IceMaths::Point Pa(  float(  ab->mCenter[0] ) * mCenterCoeff0.x,   float(  ab->mCenter[1] ) * mCenterCoeff0.y,   float(  ab->mCenter[2] ) * mCenterCoeff0.z );
           const IceMaths::Point ea(  float(  ab->mExtents[0] ) * mExtentsCoeff0.x,   float(  ab->mExtents[1] ) * mExtentsCoeff0.y,   float(  ab->mExtents[2] ) * mExtentsCoeff0.z );
           // Dequantize box B
           const QuantizedAABB* bb = &b->mAABB;
           const IceMaths::Point Pb(  float(  bb->mCenter[0] ) * mCenterCoeff1.x,   float(  bb->mCenter[1] ) * mCenterCoeff1.y,   float(  bb->mCenter[2] ) * mCenterCoeff1.z );
           const IceMaths::Point eb(  float(  bb->mExtents[0] ) * mExtentsCoeff1.x,   float(  bb->mExtents[1] ) * mExtentsCoeff1.y,   float(  bb->mExtents[2] ) * mExtentsCoeff1.z );
          
           // Perform BV-BV overlap test (  don't use scales )
           if(  !BoxBoxOverlap(  ea,   Pa,   eb,   Pb ) ) return;
          
           // Catch leaf status
           BOOL BHasPosLeaf = b->HasPosLeaf(   );
           BOOL BHasNegLeaf = b->HasNegLeaf(   );
          
           if(  a->HasPosLeaf(   ) )
           {
           FETCH_LEAF(  a->GetPosPrimitive(   ),   mIMesh0,   mSR0to1,   mT0to1 )
          
           if(  BHasPosLeaf ) PrimTestTriIndex(  b->GetPosPrimitive(   ) );
           else _CollideTriBox(  b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  BHasNegLeaf ) PrimTestTriIndex(  b->GetNegPrimitive(   ) );
           else _CollideTriBox(  b->GetNeg(   ) );
           }
           else
           {
           if(  BHasPosLeaf )
           {
           FETCH_LEAF(  b->GetPosPrimitive(   ),   mIMesh1,   mSR1to0,   mT1to0 )
          
           _CollideBoxTri(  a->GetPos(   ) );
           }
           else _Collide(  a->GetPos(   ),   b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  BHasNegLeaf )
           {
           FETCH_LEAF(  b->GetNegPrimitive(   ),   mIMesh1,   mSR1to0,   mT1to0 )
          
           _CollideBoxTri(  a->GetPos(   ) );
           }
           else _Collide(  a->GetPos(   ),   b->GetNeg(   ) );
           }
          
           if(  ContactFound(   ) ) return;
          
           if(  a->HasNegLeaf(   ) )
           {
           FETCH_LEAF(  a->GetNegPrimitive(   ),   mIMesh0,   mSR0to1,   mT0to1 )
          
           if(  BHasPosLeaf ) PrimTestTriIndex(  b->GetPosPrimitive(   ) );
           else _CollideTriBox(  b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  BHasNegLeaf ) PrimTestTriIndex(  b->GetNegPrimitive(   ) );
           else _CollideTriBox(  b->GetNeg(   ) );
           }
           else
           {
           if(  BHasPosLeaf )
           {
           // ### That leaf has possibly already been fetched
           FETCH_LEAF(  b->GetPosPrimitive(   ),   mIMesh1,   mSR1to0,   mT1to0 )
          
           _CollideBoxTri(  a->GetNeg(   ) );
           }
           else _Collide(  a->GetNeg(   ),   b->GetPos(   ) );
          
           if(  ContactFound(   ) ) return;
          
           if(  BHasNegLeaf )
           {
           // ### That leaf has possibly already been fetched
           FETCH_LEAF(  b->GetNegPrimitive(   ),   mIMesh1,   mSR1to0,   mT1to0 )
          
           _CollideBoxTri(  a->GetNeg(   ) );
           }
           else _Collide(  a->GetNeg(   ),   b->GetNeg(   ) );
           }
          }

./components/ogre/ogreopcode/src/Opcode/OPC_VolumeCollider.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains base volume collider class.
           * \file OPC_VolumeCollider.cpp
           * \author Pierre Terdiman
           * \date June,   2,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Contains the abstract class for volume colliders.
           *
           * \class VolumeCollider
           * \author Pierre Terdiman
           * \version 1.3
           * \date June,   2,   2001
          */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          
          using namespace Opcode;
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Constructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      40  VolumeCollider::VolumeCollider(   ) :
           mTouchedPrimitives (  null ),  
           mLocalScale (  1.0,  1.0,  1.0 ),  
           mNbVolumeBVTests (  0 ),  
           mNbVolumePrimTests (  0 )
          {
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Destructor.
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      53  VolumeCollider::~VolumeCollider(   )
          {
           mTouchedPrimitives = null;
          }
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Validates current settings. You should call this method after all the settings / callbacks have been defined for a collider.
           * \return null if everything is ok,   else a string describing the problem
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      64  const char* VolumeCollider::ValidateSettings(   )
          {
           return null;
          }
          
          // Pretty dumb way to dump - to do better - one day...
          
          #define IMPLEMENT_NOLEAFDUMP(  type ) \
      72  void VolumeCollider::_Dump(  const type* node ) \
          { \
           if(  node->HasPosLeaf(   ) ) mTouchedPrimitives->Add(  node->GetPosPrimitive(   ) ); \
           else _Dump(  node->GetPos(   ) ); \
           \
           if(  ContactFound(   ) ) return; \
           \
           if(  node->HasNegLeaf(   ) ) mTouchedPrimitives->Add(  node->GetNegPrimitive(   ) ); \
           else _Dump(  node->GetNeg(   ) ); \
          }
          
          #define IMPLEMENT_LEAFDUMP(  type ) \
      84  void VolumeCollider::_Dump(  const type* node ) \
          { \
           if(  node->IsLeaf(   ) ) \
           { \
           mTouchedPrimitives->Add(  node->GetPrimitive(   ) ); \
           } \
           else \
           { \
           _Dump(  node->GetPos(   ) ); \
           \
           if(  ContactFound(   ) ) return; \
           \
           _Dump(  node->GetNeg(   ) ); \
           } \
          }
          
     100  IMPLEMENT_NOLEAFDUMP(  AABBNoLeafNode )
          IMPLEMENT_NOLEAFDUMP(  AABBQuantizedNoLeafNode )
          
          IMPLEMENT_LEAFDUMP(  AABBCollisionNode )
          IMPLEMENT_LEAFDUMP(  AABBQuantizedNode )

./components/ogre/ogreopcode/src/Opcode/Opcode.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /**
           * Main file for Opcode.dll.
           * \file Opcode.cpp
           * \author Pierre Terdiman
           * \date March,   20,   2001
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          /*
           Finding a good name is difficult!
           Here's the draft for this lib.... Spooky,   uh?
          
           VOID? Very Optimized Interference Detection
           ZOID? Zappy's Optimized Interference Detection
           CID? Custom/Clever Interference Detection
           AID / ACID! Accurate Interference Detection
           QUID? Quick Interference Detection
           RIDE? Realtime Interference DEtection
           WIDE? Wicked Interference DEtection (  .... )
           GUID!
           KID ! k-dop interference detection : )
           OPCODE! OPtimized COllision DEtection
          */
          
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Precompiled Header
          #include "Opcode/Stdafx.h"
          #include <fstream>
          #include <iostream>
          //std::ofstream gFile;
          
          #include <cstdarg>
          
      43  void Opcode_Log (  const char* msg,   ... )
          {
           //va_list args;
           //va_start (  args,   msg );
           // char mesg[256];
           //sprintf(  mesg,   msg,   args );
           //gFile << mesg;
           //gFile.flush(   );
           //va_end (  args );
          }
          
      54  bool Opcode_Err (  const char* msg,   ... )
          {
           //va_list args;
           //va_start (  args,   msg );
           //// Although it's called "..._Err",   Opcode also reports less-than-fatal
           //// messages through it
           //
           // char mesg[256];
           //sprintf(  mesg,   msg,   args );
           //gFile << mesg;
           //gFile.flush(   );
           //va_end (  args );
           return false;
          }
          
      69  bool Opcode::InitOpcode(   )
          {
           //gFile.open(  "opcode.log" );
           OpcodeLog(  "// Initializing OPCODE\n\n" );
           //LogAPIInfo(   );
           return true;
          }
          
      77  void ReleasePruningSorters(   );
      78  bool Opcode::CloseOpcode(   )
          {
           OpcodeLog(  "// Closing OPCODE\n\n" );
          
           ReleasePruningSorters(   );
          
           return true;
          }
          
          #ifdef ICE_MAIN
          
      89  void ModuleAttach(  HINSTANCE hinstance )
          {
          }
          
      93  void ModuleDetach(   )
          {
          }
          
          #endif

./components/ogre/ogreopcode/src/Opcode/StdAfx.cpp

       1  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          /*
           * OPCODE - Optimized Collision Detection
           * Copyright (  C ) 2001 Pierre Terdiman
           * Homepage: http://www.codercorner.com/Opcode.htm
           */
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          
          //#define ICE_MAIN
          #include "Opcode/Stdafx.h"

./components/ogre/scripting/LuaHelper.cpp

       1  //
          // C++ Implementation: LuaHelper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "LuaHelper.h"
          
          namespace EmberOgre {
          
          namespace Scripting {
          
      33  int LuaHelper::luaErrorHandler(  lua_State *L ) {
          #ifdef LUA51
           ///see if we have the debug library loaded
           lua_getfield(  L,   LUA_GLOBALSINDEX,   "debug" );
           if (  !lua_istable(  L,   -1 ) ) {
           lua_pop(  L,   1 );
           return 1;
           }
           ///if so,   call the traceback method
           lua_getfield(  L,   -1,   "traceback" );
           if (  !lua_isfunction(  L,   -1 ) ) {
           lua_pop(  L,   2 );
           return 1;
           }
           lua_pushvalue(  L,   1 );
           lua_pushinteger(  L,   2 );
           lua_call(  L,   2,   1 );
          #endif
           return 1;
          }
          
          
          }
          
          }

./components/ogre/scripting/LuaHelper.h

       1  //
          // C++ Interface: LuaHelper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2008
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_SCRIPTINGLUAHELPER_H
          #define EMBEROGRE_SCRIPTINGLUAHELPER_H
          
          // include Lua libs
          extern "C" {
          #include "lua.h"
          }
          
          namespace EmberOgre {
          
          namespace Scripting {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      38  class LuaHelper{
          public:
      40   static int luaErrorHandler(  lua_State *L );
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/scripting/LuaScriptingProvider.cpp

       1  //
          // C++ Implementation: LuaScriptingProvider
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "../EmberOgrePrerequisites.h"
          #include "LuaScriptingProvider.h"
          
          #include "bindings/lua/helpers/LuaConnector.h"
          
          #include <CEGUIExceptions.h>
          
          #include "framework/Exception.h"
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          
          // include Lua libs and tolua++
          extern "C" {
          #include "lua.h"
          #include "lualib.h"
          #include "lauxlib.h"
          }
          //#include <lua.hpp>
          #include <tolua++.h>
          #include "LuaHelper.h"
          
      44  TOLUA_API int tolua_Ogre_open (  lua_State* tolua_S );
      45  TOLUA_API int tolua_Eris_open (  lua_State* tolua_S );
      46  TOLUA_API int tolua_EmberServices_open (  lua_State* tolua_S );
      47  TOLUA_API int tolua_EmberOgre_open (  lua_State* tolua_S );
      48  TOLUA_API int tolua_Helpers_open (  lua_State* tolua_S );
      49  TOLUA_API int tolua_Framework_open (  lua_State* tolua_S );
      50  TOLUA_API int tolua_Application_open (  lua_State* tolua_S );
      51  TOLUA_API int tolua_atlas_adapters_open (  lua_State* tolua_S );
      52  TOLUA_API int tolua_Atlas_open (  lua_State* tolua_S );
          
          namespace EmberOgre {
          
      56  LuaScriptingProvider::LuaScriptingProvider(   )
          : mService(  0 )
          {
           initialize(   );
          }
          
          
      63  LuaScriptingProvider::~LuaScriptingProvider(   )
          {
           lua_close(  mLuaState );
          }
          
          // void LuaScriptingProvider::start(   )
          // {
          // initialize(   );
          // }
          
      73  void LuaScriptingProvider::stop(   )
          {
           try {
           ///we want to clear up the lua environment without destroying it (  lua_close destroys it )
           std::string shutdownScript(  "for key,  value in pairs(  _G ) do if key ~= \"_G\" and key ~= \"pairs\" then _G[key] = nil end end" );
           executeScript(  shutdownScript );
           forceGC(   );
           } catch (  ... ) {
           S_LOG_WARNING(  "Error when stopping lua." );
           }
          }
          
      85  void LuaScriptingProvider::initialize(   )
          {
           createState(   );
           tolua_Framework_open(  mLuaState );
           tolua_EmberOgre_open(  mLuaState );
           tolua_Eris_open(  mLuaState );
           tolua_EmberServices_open(  mLuaState );
           tolua_Helpers_open (  mLuaState );
           tolua_Ogre_open(  mLuaState );
           tolua_Application_open(  mLuaState );
           tolua_atlas_adapters_open(  mLuaState );
           tolua_Atlas_open(  mLuaState );
           LuaConnector::setState(  mLuaState );
          }
          
     100  void LuaScriptingProvider::createState(   )
          {
           bool loadDebugLib = true;
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "lua",   "debug" ) ) {
           loadDebugLib = static_cast<bool>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "lua",   "debug" ) );
           }
           if (  loadDebugLib ) {
           S_LOG_VERBOSE(  "Loading lua debug library." );
           }
          
          
          #ifdef LUA51
           static const luaL_Reg lualibs[] = {
           {"",   luaopen_base},  
           {LUA_LOADLIBNAME,   luaopen_package},  
           {LUA_TABLIBNAME,   luaopen_table},  
           {LUA_IOLIBNAME,   luaopen_io},  
           {LUA_STRLIBNAME,   luaopen_string},  
           {LUA_MATHLIBNAME,   luaopen_math},  
           {NULL,   NULL}
           };
           static const luaL_Reg lualibsDebug[] = {
           {"",   luaopen_base},  
           {LUA_LOADLIBNAME,   luaopen_package},  
           {LUA_TABLIBNAME,   luaopen_table},  
           {LUA_IOLIBNAME,   luaopen_io},  
           {LUA_STRLIBNAME,   luaopen_string},  
           {LUA_MATHLIBNAME,   luaopen_math},  
           {LUA_DBLIBNAME,   luaopen_debug},  
           {NULL,   NULL}
           };
          #endif /* LUA51 */
          
           mLuaState = lua_open(   );
          
           // init all standard libraries
          #ifdef LUA51
           const luaL_Reg *lib = loadDebugLib ? lualibsDebug : lualibs;
           for (  ; lib->func; lib++ )
           {
           lua_pushcfunction(  mLuaState,   lib->func );
           lua_pushstring(  mLuaState,   lib->name );
           lua_call(  mLuaState,   1,   0 );
           }
          #else /* LUA51 */
           luaopen_base(  mLuaState );
           luaopen_io(  mLuaState );
           luaopen_string(  mLuaState );
           luaopen_table(  mLuaState );
           luaopen_math(  mLuaState );
           if (  loadDebugLib ) {
           luaopen_debug(  mLuaState );
           }
          #endif /* LUA51 */
          
          }
          
     157  lua_State* LuaScriptingProvider::getLuaState(   )
          {
           return mLuaState;
          }
          
          
          
     164  void LuaScriptingProvider::loadScript(  Ember::ResourceWrapper& resWrapper )
          {
           try {
          
           // load code into lua
           int top = lua_gettop(  mLuaState );
           int loaderr = luaL_loadbuffer(  mLuaState,   resWrapper.getDataPtr(   ),   resWrapper.getSize(   ),   resWrapper.getName(   ).c_str(   ) );
          
           if (  loaderr )
           {
           std::string errMsg(  lua_tostring(  mLuaState,  -1 ) );
           lua_settop(  mLuaState,  top );
           throw Ember::Exception(  "Unable to load Lua script file: '"+resWrapper.getName(   )+"'\n\n"+errMsg+"\n" );
           }
          
           ///push our error handling method before calling the code
           int error_index = lua_gettop(  mLuaState );
           #if LUA51
           lua_pushcfunction(  mLuaState,   ::EmberOgre::Scripting::LuaHelper::luaErrorHandler );
           #else
           lua_pushliteral(  mLuaState,   "_TRACEBACK" );
           lua_rawget(  mLuaState,   LUA_GLOBALSINDEX ); /* get traceback function */
           #endif
           lua_insert(  mLuaState,   error_index );/* put it under chunk and args */
          
          
           // call it
           if (  lua_pcall(  mLuaState,  0,  0,  error_index ) )
           {
           std::string errMsg(  lua_tostring(  mLuaState,  -1 ) );
           lua_settop(  mLuaState,  top );
           throw Ember::Exception(  "Unable to execute Lua script file: '"+resWrapper.getName(   )+"'\n\n"+errMsg+"\n" );
           }
          
           lua_settop(  mLuaState,  top ); // just in case :P
          
          
          // getScriptModule(   ).executeScriptFile(  scriptName );
           } catch (  const CEGUI::Exception& ex ) {
           throw Ember::Exception(  ex.getMessage(   ).c_str(   ) );
           } catch(   const CEGUI::String& str  )
           {
           throw Ember::Exception(  str.c_str(   ) );
           } catch (  const Ember::Exception& ex ) {
           throw ex;
           } catch (  ... ) {
           throw Ember::Exception(  "Unknown error." );
           }
          /* } catch (  const Ogre::Exception& ex ) {
           throw Ember::Exception(  "Error when loading script " + scriptName + ". Message: " + ex.get );
           }*/
          }
          
     217  void LuaScriptingProvider::executeScript(  const std::string& scriptCode )
          {
           try {
           int top = lua_gettop(  mLuaState );
          
          
           int loaderr = luaL_loadbuffer(  mLuaState,   scriptCode.c_str(   ),   scriptCode.length(   ),   scriptCode.c_str(   ) );
          
           if (  loaderr )
           {
           std::string errMsg(  lua_tostring(  mLuaState,  -1 ) );
           lua_settop(  mLuaState,  top );
           throw Ember::Exception(  "Unable to load Lua script: '" + scriptCode + "'\n\n"+errMsg+"\n" );
           }
          
           ///push our error handling method before calling the code
           int error_index = lua_gettop(  mLuaState );
           lua_pushcfunction(  mLuaState,   ::EmberOgre::Scripting::LuaHelper::luaErrorHandler );
           lua_insert(  mLuaState,   error_index );
          
           /// load code into lua and call it
           int error = lua_pcall(  mLuaState,  0,  0,  error_index );
          
           // handle errors
           if (  error )
           {
           std::string errMsg(  lua_tostring(  mLuaState,  -1 ) );
           lua_settop(  mLuaState,  top );
           throw Ember::Exception(  "Unable to execute Lua script string: '"+scriptCode+"'\n\n"+errMsg+"\n" );
           }
          // getScriptModule(   ).executeString(  scriptCode );
           } catch (  const CEGUI::Exception& ex ) {
           throw Ember::Exception(  ex.getMessage(   ).c_str(   ) );
           } catch(   const CEGUI::String& str  )
           {
           throw Ember::Exception(  str.c_str(   ) );
           } catch (  const Ember::Exception& ex ) {
           throw ex;
           } catch (  ... ) {
           throw Ember::Exception(  "Unknown error." );
           }
          
          }
          
     261  bool LuaScriptingProvider::willLoadScript(  const std::string& scriptName )
          {
           if (  Ogre::StringUtil::endsWith(  scriptName,   ".lua" ) ) {
           return true;
           }
           return false;
          }
          
     269  const std::string& LuaScriptingProvider::getName(   ) const
          {
           static std::string name = "LuaScriptingProvider";
           return name;
          }
          
     275  void LuaScriptingProvider::_registerWithService(  Ember::ScriptingService* service )
          {
           mService = service;
          }
          
     280  void LuaScriptingProvider::forceGC(   )
          {
          #ifdef LUA51
           lua_gc(  mLuaState,   LUA_GCCOLLECT,   0 );
          #else
           lua_setgcthreshold(  mLuaState,  0 );
          #endif
          }
          
          
          
          
          // int32_t LuaScriptInterface::callFunction(  uint32_t nParams )
          // {
          // int32_t result = LUA_NO_ERROR;
          //
          // int size0 = lua_gettop(  m_luaState );
          //
          // int error_index = lua_gettop(  m_luaState ) - nParams;
          // lua_pushcfunction(  m_luaState,   luaErrorHandler );
          // lua_insert(  m_luaState,   error_index );
          //
          // if(  lua_pcall(  m_luaState,   nParams,   1,   error_index ) != 0 ){
          // LuaScriptInterface::reportError(  NULL,   std::string(  LuaScriptInterface::popString(  m_luaState ) ) );
          // result = LUA_ERROR;
          // } else {
          // result = (  int32_t )LuaScriptInterface::popNumber(  m_luaState );
          // }
          // lua_remove(  m_luaState,   error_index );
          //
          // if(  (  lua_gettop(  m_luaState ) + (  int )nParams + 1 ) != size0 ){
          // LuaScriptInterface::reportError(  NULL,   "Stack size changed!" );
          // }
          //
          // return result;
          // }
          
          
          
          // CEGUI::ScriptModule& LuaScriptingProvider::getScriptModule(   )
          // {
          // return mLuaScriptModule;
          // }
          
          }

./components/ogre/scripting/LuaScriptingProvider.h

       1  //
          // C++ Interface: LuaScriptingProvider
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRELUASCRIPTINGPROVIDER_H
          #define EMBEROGRELUASCRIPTINGPROVIDER_H
          
          #include "framework/IScriptingProvider.h"
          
          #include <CEGUIScriptModule.h>
          #include <CEGUILua.h>
          
          struct lua_State;
          
          namespace Ember
          {
      35   class ScriptingService;
          }
          
          namespace EmberOgre {
          
          /**
          @author Erik Hjortsberg
          */
      43  class LuaScriptingProvider : public Ember::IScriptingProvider
          {
          public:
      46   LuaScriptingProvider(   );
          
      48   virtual ~LuaScriptingProvider(   );
          
           /**
           * Loads the script.
           * @param scriptName
           */
      54   virtual void loadScript(  Ember::ResourceWrapper& resWrapper );
          
           /**
           * Executes the supplied string directly into the scripting environment.
           * @param scriptCode
           */
      60   virtual void executeScript(  const std::string& scriptCode );
          
           /**
           * Returns true if the provider will load the supplied script name. This is in most cases decided from the filename suffix.
           * @param scriptName
           * @return
           */
      67   virtual bool willLoadScript(  const std::string& scriptName );
          
           /**
           * Gets the unique name of the scripting provider.
           * @return
           */
      73   virtual const std::string& getName(   ) const;
          
           /**
           * Register with a service to allow for callbacks etc.
           * @param service
           */
      79   virtual void _registerWithService(  Ember::ScriptingService* service );
          
           /**
           * Forces a full garbage collection.
           */
      84   virtual void forceGC(   );
          
          // virtual void start(   );
      87   virtual void stop(   );
          
          
           /**
           * Returns the scripting module
           * @return
           */
          // CEGUI::ScriptModule& getScriptModule(   );
          
      96   lua_State* getLuaState(   );
          
          
          private:
          
     101   void initialize(   );
     102   void createState(   );
          // std::auto_ptr<CEGUI::LuaScriptModule> mLuaScriptModule;
     104   Ember::ScriptingService* mService;
           lua_State* mLuaState;
          
          };
          
          }
          
          #endif

./components/ogre/scripting/bindings/lua/helpers/LuaConnector.cpp

       1  //
          // C++ Implementation: LuaConnectors
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "LuaConnector.h"
          #include "LuaConnectorHelper.h"
          
          #include "framework/Exception.h"
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/scripting/ScriptingService.h"
          
          #include "components/ogre/MousePicker.h"
          #include "components/ogre/EntityWorldPickListener.h"
          #include "components/ogre/scripting/LuaHelper.h"
          
          #include <Eris/Task.h>
          
          #include <CEGUIExceptions.h>
          
          #include <Eris/ServerInfo.h>
          
          namespace EmberOgre {
          
          namespace LuaConnectors {
          
      45  ConnectorBase::ConnectorBase(   )
          : mLuaFunctionIndex(  LUA_NOREF )
          {
          }
          
          
      51  ConnectorBase::ConnectorBase(  const LuaTypeStore& luaTypeNames )
          : mLuaTypeNames(  luaTypeNames ),   mLuaFunctionIndex(  LUA_NOREF )
          {
          }
          
      56  ConnectorBase::~ConnectorBase(   )
          {
           mConnection.disconnect(   );
          }
          
      61  void ConnectorBase::disconnect(   )
          {
           mConnection.disconnect(   );
          }
          
          
      67  void ConnectorBase::connect(  const std::string & luaMethod )
          {
           mLuaMethod = luaMethod;
          }
          
      72  void ConnectorBase::connect(  int luaMethod )
          {
           mLuaFunctionIndex = luaMethod;
          }
          
          
      78  void ConnectorBase::pushNamedFunction(  lua_State* state )
          {
           LuaConnectorHelper::pushNamedFunction(  state,   mLuaMethod );
          }
          
          //template<> void ConnectorBase::callLuaMethod(  std::string t0,   std::string t1,   Empty t2,   Empty t3 );
      84  template <typename Treturn,   typename T0,   typename T1,   typename T2,   typename T3> Treturn ConnectorBase::callLuaMethod(  T0 t0,   T1 t1,   T2 t2,   T3 t3 )
          {
           int numberOfArguments = static_cast<int>(  mLuaTypeNames.size(   ) );
           lua_State* state = EmberOgre::LuaConnector::getState(   );
           int top = lua_gettop(  state );
           try {
          
           if (  mLuaFunctionIndex == LUA_NOREF || Ember::EmberServices::getSingleton(   ).getScriptingService(   )->getAlwaysLookup(   ) ) {
           pushNamedFunction(  state );
           mLuaFunctionIndex = luaL_ref(  state,   LUA_REGISTRYINDEX );
           }
          
           ///get the lua function
           lua_rawgeti(  state,   LUA_REGISTRYINDEX,   mLuaFunctionIndex );
          
          // lua_getglobal(  state,   mLuaMethod.c_str(   ) );
          
           // is it a function
          
           LuaTypeStore::const_iterator I = mLuaTypeNames.begin(   );
           if (  I != mLuaTypeNames.end(   ) )
           EmberOgre::LuaConnector::pushValue(  t0,   (  *I++ ) );
           if (  I != mLuaTypeNames.end(   ) )
           EmberOgre::LuaConnector::pushValue(  t1,   (  *I++ ) );
           if (  I != mLuaTypeNames.end(   ) )
           EmberOgre::LuaConnector::pushValue(  t2,   (  *I++ ) );
           if (  I != mLuaTypeNames.end(   ) )
           EmberOgre::LuaConnector::pushValue(  t3,   (  *I++ ) );
          
           ///push our error handling method before calling the code
           int error_index = lua_gettop(  state ) - numberOfArguments;
           #if LUA51
           lua_pushcfunction(  state,   ::EmberOgre::Scripting::LuaHelper::luaErrorHandler );
           #else
           lua_pushliteral(  state,   "_TRACEBACK" );
           lua_rawget(  state,   LUA_GLOBALSINDEX ); /* get traceback function */
           #endif
           lua_insert(  state,   error_index );/* put it under chunk and args */
          
           /// call it
           int error = lua_pcall(  state,  numberOfArguments,  LUA_MULTRET,  error_index );
          
           /// handle errors
           if (   error  )
           {
           const std::string& msg = lua_tostring(  state,  -1 );
           lua_settop(  state,   top  );
          // lua_pop(  state,  numberOfArguments );
           throw Ember::Exception(  msg );
           }
          
          // Treturn& returnValue(  0 );
           //return (  Treturn )returnValueFromLua(  state );
           //return returnValue;
          
           }
           catch(  const Ember::Exception& ex  )
           {
           lua_settop(  state,   top  );
           S_LOG_FAILURE(  "(  LuaScriptModule ) Unable to execute scripted event handler: " << mLuaMethod << "\n" << ex.getError(   ) );
           }
           catch(   const CEGUI::String& str  )
           {
           lua_settop(  state,   top  );
           S_LOG_FAILURE(  "(  LuaScriptModule ) Unable to execute scripted event handler: "<<mLuaMethod<<"\n"<<str.c_str(   ) );
           }
           catch(   const CEGUI::Exception& ex  )
           {
           lua_settop(  state,   top  );
           S_LOG_FAILURE(  "(  LuaScriptModule ) Unable to execute scripted event handler: "<<mLuaMethod<<"\n"<<ex.getMessage(   ).c_str(   ) );
           }
           catch(  const std::exception& ex  )
           {
           lua_settop(  state,   top  );
           S_LOG_FAILURE(  "(  LuaScriptModule ) Unable to execute scripted event handler: " << mLuaMethod << "\n" << ex.what(   ) );
           } catch (  ... )
           {
           lua_settop(  state,   top  );
           S_LOG_FAILURE(  "Unspecified error when executing: " << mLuaMethod  );
           }
          /* void* test(  0 );
           return (  Treturn )*test;*/
          }
          
          template<typename Treturn>
     169  Treturn ConnectorBase::returnValueFromLua(  lua_State* state )
          {
           return static_cast<Treturn>(  lua_touserdata(  state,  -1 ) );
          }
          
          // void ConnectorBase::returnValueFromLua(  lua_State* state,   bool& returnValueHolder )
          // {
          // returnValueHolder = lua_toboolean(  state,  -1 );
          // }
          //
          // void returnValueFromLua(  lua_State* state )
          // {
          // }
          
          template <typename Treturn>
     184  ConnectorZero<Treturn>::ConnectorZero(  sigc::signal<Treturn>& signal ) : ConnectorBase(   ),   mSignal(  signal )
          {
           mConnection = mSignal.connect(  sigc::mem_fun(  *this,   &ConnectorZero<Treturn>::signal_recieve ) );
          }
          
          template <typename Treturn,   typename T0>
     190  ConnectorOne<Treturn,   T0>::ConnectorOne(  sigc::signal<Treturn,   T0>& signal,   const LuaTypeStore& luaTypeNames ) : ConnectorBase(  luaTypeNames ),   mSignal(  signal )
          {
           mConnection = mSignal.connect(  sigc::mem_fun(  *this,   &ConnectorOne<Treturn,   T0>::signal_recieve ) );
          }
          
          // template <typename Treturn,   typename T0>
          // ConnectorOne<Treturn,   T0>::ConnectorOne(  SigC::Signal1<Treturn,   T0>& signal,   const LuaTypeStore& luaTypeNames ) :
          // ConnectorBase(  luaTypeNames ),   mSignal_old(  signal )
          // {
          // mConnection = mSignal_old.connect(  sigc::mem_fun(  *this,   &ConnectorOne<Treturn,   T0>::signal_recieve ) );
          // }
          
          template <typename Treturn,   typename T0,   typename T1>
     203  ConnectorTwo<Treturn,   T0,   T1>::ConnectorTwo(  sigc::signal<Treturn,   T0,   T1>& signal,   const LuaTypeStore& luaTypeNames ) : ConnectorBase(  luaTypeNames ),   mSignal(  signal )
          {
           mConnection = mSignal.connect(  sigc::mem_fun(  *this,   &ConnectorTwo<Treturn,   T0,   T1>::signal_recieve ) );
          }
          
          template <typename Treturn,   typename T0,   typename T1,   typename T2>
     209  ConnectorThree<Treturn,   T0,   T1,   T2>::ConnectorThree(  sigc::signal<Treturn,   T0,   T1,   T2>& signal,   const LuaTypeStore& luaTypeNames ) : ConnectorBase(  luaTypeNames ),   mSignal(  signal )
          {
           mConnection = mSignal.connect(  sigc::mem_fun(  *this,   &ConnectorThree<Treturn,   T0,   T1,   T2>::signal_recieve ) );
          }
          
          template <typename Treturn,   typename T0,   typename T1,   typename T2,   typename T3>
     215  ConnectorFour<Treturn,   T0,   T1,   T2,   T3>::ConnectorFour(  sigc::signal<Treturn,   T0,   T1,   T2,   T3>& signal,   const LuaTypeStore& luaTypeNames ) : ConnectorBase(  luaTypeNames ),   mSignal(  signal )
          {
           mConnection = mSignal.connect(  sigc::mem_fun(  *this,   &ConnectorFour<Treturn,   T0,   T1,   T2,   T3>::signal_recieve ) );
          }
          
          
          template <typename Treturn>
     222  Treturn ConnectorZero<Treturn>::signal_recieve(   )
          {
           return callLuaMethod<Treturn,   Empty,   Empty,   Empty,   Empty>(  Empty(   ),   Empty(   ),   Empty(   ),   Empty(   ) );
          }
          
          template <typename Treturn,   typename T0>
     228  Treturn ConnectorOne<Treturn,   T0>::signal_recieve(  T0 t0 )
          {
           return callLuaMethod<Treturn,   T0,   Empty,   Empty,   Empty>(  t0,   Empty(   ),   Empty(   ),   Empty(   ) );
          }
          
          template <typename Treturn,   typename T0,   typename T1>
     234  Treturn ConnectorTwo<Treturn,   T0,   T1>::signal_recieve(  T0 t0,   T1 t1 )
          {
           return callLuaMethod<Treturn,   T0,   T1,   Empty,   Empty>(  t0,   t1,   Empty(   ),   Empty(   ) );
          }
          
          template <typename Treturn,   typename T0,   typename T1,   typename T2>
     240  Treturn ConnectorThree<Treturn,   T0,   T1,   T2>::signal_recieve(  T0 t0,   T1 t1,   T2 t2 )
          {
           return callLuaMethod<Treturn,   T0,   T1,   T2,   Empty>(  t0,   t1,   t2,   Empty(   ) );
          }
          
          template <typename Treturn,   typename T0,   typename T1,   typename T2,   typename T3>
     246  Treturn ConnectorFour<Treturn,   T0,   T1,   T2,   T3>::signal_recieve(  T0 t0,   T1 t1,   T2 t2,   T3 t3 )
          {
           return callLuaMethod<Treturn,   T0,   T1,   T2,   T3>(  t0,   t1,   t2,   t3 );
          }
          
          
          };
          
          template <typename T>
     255  void LuaConnector::pushValue(  T theValue,   const std::string& luaTypename )
          {
          // tolua_pushusertype(  EmberOgre::LuaConnector::getState(   ),  (  void* )&theValue,   luaTypename.c_str(   ) );
           tolua_pushusertype(  EmberOgre::LuaConnector::getState(   ),  (  void* )theValue,   luaTypename.c_str(   ) );
          }
          
     261  void LuaConnector::pushValue(  const Eris::ServerInfo& theValue,   const std::string& luaTypename )
          {
           tolua_pushusertype(  EmberOgre::LuaConnector::getState(   ),  (  void* )&theValue,   luaTypename.c_str(   ) );
          }
          
     266  void LuaConnector::pushValue(  const std::string& theValue,   const std::string& luaTypename )
          {
           tolua_pushstring(  EmberOgre::LuaConnector::getState(   ),  theValue.c_str(   ) );
          }
          
     271  void LuaConnector::pushValue(  LuaConnectors::Empty theValue,   const std::string& luaTypename )
          {
          }
          
     275  void LuaConnector::pushValue(  const float& theValue,   const std::string& luaTypename )
          {
           tolua_pushnumber(  EmberOgre::LuaConnector::getState(   ),  theValue );
          }
          
     280  void LuaConnector::pushValue(  const long& theValue,   const std::string& luaTypename )
          {
           tolua_pushnumber(  EmberOgre::LuaConnector::getState(   ),  theValue );
          }
          
     285  void LuaConnector::pushValue(  const unsigned long& theValue,   const std::string& luaTypename )
          {
           tolua_pushnumber(  EmberOgre::LuaConnector::getState(   ),  theValue );
          }
          
     290  void LuaConnector::pushValue(  const unsigned int& theValue,   const std::string& luaTypename )
          {
           tolua_pushnumber(  EmberOgre::LuaConnector::getState(   ),  theValue );
          }
          
          
     296  void LuaConnector::pushValue(  const int& theValue,   const std::string& luaTypename )
          {
           tolua_pushnumber(  EmberOgre::LuaConnector::getState(   ),  theValue );
          }
          
     301  void LuaConnector::pushValue(  const EntityPickResult& theValue,   const std::string& luaTypename )
          {
           tolua_pushusertype(  EmberOgre::LuaConnector::getState(   ),  (  void* )&theValue,   luaTypename.c_str(   ) );
          }
          
     306  void LuaConnector::pushValue(  const MousePickerArgs& theValue,   const std::string& luaTypename )
          {
           tolua_pushusertype(  EmberOgre::LuaConnector::getState(   ),  (  void* )&theValue,   luaTypename.c_str(   ) );
          }
          
     311  void LuaConnector::pushValue(  const Input::MouseButton& theValue,   const std::string& luaTypename )
          {
           tolua_pushnumber(  EmberOgre::LuaConnector::getState(   ),   theValue );
          }
     315  void LuaConnector::pushValue(  const Input::InputMode& theValue,   const std::string& luaTypename )
          {
           tolua_pushnumber(  EmberOgre::LuaConnector::getState(   ),   theValue );
          }
          
     320  void LuaConnector::pushValue(  const std::set<std::string>& theValue,   const std::string& luaTypename )
          {
           tolua_pushusertype(  EmberOgre::LuaConnector::getState(   ),  (  void* )&theValue,   luaTypename.c_str(   ) );
          }
          
     325  void LuaConnector::pushValue(  const Atlas::Message::Element& theValue,   const std::string& luaTypename )
          {
           tolua_pushusertype(  EmberOgre::LuaConnector::getState(   ),  (  void* )&theValue,   luaTypename.c_str(   ) );
          }
          
          
     331  LuaConnector::~LuaConnector(   )
          {
           delete mConnector;
          }
          
          lua_State* LuaConnector::sState = 0;
          
     338  void LuaConnector::setState(  lua_State* state )
          {
           sState = state;
          }
          
     343  lua_State* LuaConnector::getState(   )
          {
           return sState;
          }
          
     348  LuaConnector* LuaConnector::connect(  const std::string& luaMethod )
          {
           mConnector->connect(  luaMethod );
           return this;
          }
          
     354  LuaConnector* LuaConnector::connect(  int luaMethod )
          {
           ///we need to get the correct lua function
           int luaType = lua_type(  sState,  -1 );
           if (  luaType == LUA_TFUNCTION )
           {
           int index = luaL_ref(  sState,   LUA_REGISTRYINDEX );
           mConnector->connect(  index );
           } else {
           S_LOG_WARNING(  "No valid lua function sent as argument to LuaConnector::connect" );
           }
          
           return this;
          }
          
     369  void LuaConnector::disconnect(   )
          {
           mConnector->disconnect(   );
          }
          
          
          
          
          
          
          
     380  LuaConnector::LuaConnector(  sigc::signal<void>& signal )
          {
           mConnector = new LuaConnectors::ConnectorZero<void>(  signal );
          }
          
     385  LuaConnector::LuaConnector(  sigc::signal<void,   const std::string&,   EmberEntity*> & signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "string" );
           luaTypes.push_back(  "EmberOgre::EmberEntity" );
           mConnector = new LuaConnectors::ConnectorTwo<void,   const std::string&,   EmberEntity*>(  signal,   luaTypes );
          }
          
     393  LuaConnector::LuaConnector(  sigc::signal<void,   Eris::Connection*>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "Eris::Connection" );
           mConnector = new LuaConnectors::ConnectorOne<void,   Eris::Connection*>(  signal,   luaTypes );
          }
          
     400  LuaConnector::LuaConnector(  sigc::signal<void,   const Eris::ServerInfo&>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "Eris::ServerInfo" );
           mConnector = new LuaConnectors::ConnectorOne<void,   const Eris::ServerInfo&>(  signal,   luaTypes );
          }
          
     407  LuaConnector::LuaConnector(  sigc::signal<void,   float>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "float" );
           mConnector = new LuaConnectors::ConnectorOne<void,   float>(  signal,   luaTypes );
          }
          
     414  LuaConnector::LuaConnector(  sigc::signal<void,   const EntityPickResult&,   const MousePickerArgs&>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::EntityPickResult" );
           luaTypes.push_back(  "EmberOgre::MousePickerArgs" );
           mConnector = new LuaConnectors::ConnectorTwo<void,   const EntityPickResult&,   const MousePickerArgs&>(  signal,   luaTypes );
          }
          
     422  LuaConnector::LuaConnector(  sigc::signal<void,   const MousePickerArgs&>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::MousePickerArgs" );
           mConnector = new LuaConnectors::ConnectorOne<void,   const MousePickerArgs&>(  signal,   luaTypes );
          }
          
     429  LuaConnector::LuaConnector(  sigc::signal<void,   Input::MouseButton,   Input::InputMode>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::Input::MouseButton" );
           luaTypes.push_back(  "EmberOgre::Input::InputMode" );
           mConnector = new LuaConnectors::ConnectorTwo<void,   Input::MouseButton,   Input::InputMode>(  signal,   luaTypes );
          }
          
     437  LuaConnector::LuaConnector(  sigc::signal<void,   EmberEntityFactory*>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::EmberEntityFactory" );
           mConnector = new LuaConnectors::ConnectorOne<void,   EmberEntityFactory*>(  signal,   luaTypes );
          }
     443  LuaConnector::LuaConnector(  sigc::signal<void,   AvatarEmberEntity*>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::AvatarEmberEntity" );
           mConnector = new LuaConnectors::ConnectorOne<void,   AvatarEmberEntity*>(  signal,   luaTypes );
          }
     449  LuaConnector::LuaConnector(  sigc::signal<void,   Jesus*>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::Jesus" );
           mConnector = new LuaConnectors::ConnectorOne<void,   Jesus*>(  signal,   luaTypes );
          }
     455  LuaConnector::LuaConnector(  sigc::signal<void,   EmberEntity*>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::EmberEntity" );
           mConnector = new LuaConnectors::ConnectorOne<void,   EmberEntity*>(  signal,   luaTypes );
          }
          
     462  LuaConnector::LuaConnector(  sigc::signal<void,   const std::string&>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "string" );
           mConnector = new LuaConnectors::ConnectorOne<void,   const std::string&>(  signal,   luaTypes );
          }
          
     469  LuaConnector::LuaConnector(  sigc::signal<bool,   const std::string&>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "string" );
           mConnector = new LuaConnectors::ConnectorOne<bool,   const std::string&>(  signal,   luaTypes );
          }
          
     476  LuaConnector::LuaConnector(  sigc::signal<void,   const std::string&,   const std::string&>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "string" );
           luaTypes.push_back(  "string" );
           mConnector = new LuaConnectors::ConnectorTwo<void,   const std::string&,   const std::string&>(  signal,   luaTypes );
          }
          
     484  LuaConnector::LuaConnector(  sigc::signal<void,   Terrain::BasePointUserObject*>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::Terrain::BasePointUserObject" );
           mConnector = new LuaConnectors::ConnectorOne<void,   Terrain::BasePointUserObject*>(  signal,   luaTypes );
          }
          
     491  LuaConnector::LuaConnector(  sigc::signal<void,   Terrain::TerrainEditAction*>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::Terrain::TerrainEditAction" );
           mConnector = new LuaConnectors::ConnectorOne<void,   Terrain::TerrainEditAction*>(  signal,   luaTypes );
          }
          
     498  LuaConnector::LuaConnector(  sigc::signal<void,   Eris::Task*>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "Eris::Task" );
           mConnector = new LuaConnectors::ConnectorOne<void,   Eris::Task*>(  signal,   luaTypes );
          }
          
     505  LuaConnector::LuaConnector(  sigc::signal<void,   const std::set<std::string>&>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "std::set<std::string>" );
           mConnector = new LuaConnectors::ConnectorOne<void,   const std::set<std::string>&>(  signal,   luaTypes );
          }
          
     512  LuaConnector::LuaConnector(  sigc::signal<void,   EmberOgre::Gui::EntityIcon*>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "EmberOgre::Gui::EntityIcon" );
           mConnector = new LuaConnectors::ConnectorOne<void,   EmberOgre::Gui::EntityIcon*>(  signal,   luaTypes );
          }
          
     519  LuaConnector::LuaConnector(  sigc::signal<void,   const Atlas::Message::Element&>& signal )
          {
           LuaTypeStore luaTypes;
           luaTypes.push_back(  "Atlas::Message::Element" );
           mConnector = new LuaConnectors::ConnectorOne<void,   const Atlas::Message::Element&>(  signal,   luaTypes );
          }
          
          };

./components/ogre/scripting/bindings/lua/helpers/LuaConnector.h

          //
          // C++ Interface: LuaConnectors
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy ofthe GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRELUACONNECTORS_H
          #define EMBEROGRELUACONNECTORS_H
          
          #include <tolua++.h>
          #include <sigc++/signal.h>
          #include <sigc++/trackable.h>
          #include <sigc++/connection.h>
          #include <string>
          #include <vector>
          
          #include "components/ogre/input/Input.h"
          
          namespace Atlas {
          namespace Message {
      37  class Element;
          }
          }
          
      41  namespace Eris {
          
          class Connection;
          class Account;
          class View;
          class ServerInfo;
          class Task;
          }
          
          namespace EmberOgre {
          
      52  class EmberEntity;
          struct EntityPickResult;
          struct MousePickerArgs;
      55  class EmberEntityFactory;
      56  class AvatarEmberEntity;
      57  class Jesus;
          namespace Terrain {
      59  class BasePointUserObject;
      60  class TerrainEditAction;
          }
          
          typedef std::vector<std::string> LuaTypeStore;
          
          namespace Gui {
      66  class EntityIcon;
          }
          //template<> void ConnectorBase::callLuaMethod(  std::string t0,   std::string t1,   Empty t2,   Empty t3 );
          
          namespace LuaConnectors {
          
          
      73   class Empty
           {
           public:
      76   Empty(   ) {}
           };
          
      79   class ConnectorBase
      80   : public sigc::trackable
           {
           public:
      83   ConnectorBase(   );
      84   ConnectorBase(  const LuaTypeStore& luaTypeNames );
      85   virtual ~ConnectorBase(   );
          
           /**
           * Connects to a specified lua method.
           * @param luaMethod The fully qualified name of the method.
           */
      91   void connect(  const std::string & luaMethod );
          
           /**
           * Connects to a specified lua method.
           * @param luaMethod The lua method
           */
      97   void connect(  int luaMethod );
          
          
           /**
           Disconnects from the signal.
           */
     103   void disconnect(   );
          
     105   template <typename Treturn,   typename T0,   typename T1,   typename T2,   typename T3> Treturn callLuaMethod(  T0 t0,   T1 t1,   T2 t2,   T3 t3 );
          
           protected:
          
           /**
           The lua method to call.
           */
           std::string mLuaMethod;
          
           /**
           A vector of the lua type names of the arguments,   in order called.
           */
           std::vector<std::string> mLuaTypeNames;
          
           /**
           pushes the lua method onto the stack
           */
     122   void pushNamedFunction(  lua_State* state );
          
           /**
           After the lua method has been bound,   we don't need to do any more lookups and can instead just use the function index,   which is stored in this variable.
           */
           int mLuaFunctionIndex;
          
           /**
           The connection.
           */
           sigc::connection mConnection;
          
     134   template<typename Treturn> Treturn returnValueFromLua(  lua_State* state );
          /* void returnValueFromLua(  lua_State* state,   bool& returnValueHolder );
           void returnValueFromLua(  lua_State* state );*/
          
           };
          
          template <typename Treturn>
     141   class ConnectorZero : public ConnectorBase
           {
           public:
     144   ConnectorZero(  sigc::signal<Treturn>& signal );
          // ConnectorZero(  SigC::Signal0<Treturn>& signal );
          
           private:
     148   sigc::signal<Treturn> mSignal;
          // SigC::Signal0<Treturn> mSignal_old;
     150   Treturn signal_recieve(   );
           };
          
          
          template <typename Treturn,   typename T0>
     155   class ConnectorOne : public ConnectorBase
           {
           public:
     158   ConnectorOne(  sigc::signal<Treturn,   T0>& signal,   const LuaTypeStore& luaTypeNames );
          // ConnectorOne(  SigC::Signal1<Treturn,   T0>& signal,   const LuaTypeStore& luaTypeNames );
          
           private:
     162   sigc::signal<Treturn,   T0> mSignal;
          // SigC::Signal1<Treturn,   T0> mSignal_old;
     164   Treturn signal_recieve(  T0 t0 );
          
           };
          
          template <typename Treturn,   typename T0,   typename T1>
     169   class ConnectorTwo : public ConnectorBase
           {
           public:
     172   ConnectorTwo(  sigc::signal<Treturn,   T0,   T1>& signal,   const LuaTypeStore& luaTypeNames );
          
           private:
     175   sigc::signal<Treturn,   T0,   T1> mSignal;
     176   Treturn signal_recieve(  T0 t0,   T1 t1 );
          
           };
          
          template <typename Treturn,   typename T0,   typename T1,   typename T2>
     181   class ConnectorThree : public ConnectorBase
           {
           public:
     184   ConnectorThree(  sigc::signal<Treturn,   T0,   T1,   T2>& signal,   const LuaTypeStore& luaTypeNames );
          
          
           private:
     188   sigc::signal<Treturn,   T0,   T1,   T2> mSignal;
     189   Treturn signal_recieve(  T0 t0,   T1 t1,   T2 t2 );
          
           };
          
          template <typename Treturn,   typename T0,   typename T1,   typename T2,   typename T3>
     194   class ConnectorFour : public ConnectorBase
           {
           public:
     197   ConnectorFour(  sigc::signal<Treturn,   T0,   T1,   T2,   T3>& signal,   const LuaTypeStore& luaTypeNames );
          
          
           private:
     201   sigc::signal<Treturn,   T0,   T1,   T2,   T3> mSignal;
     202   Treturn signal_recieve(  T0 t0,   T1 t1,   T2 t2,   T3 t3 );
          
           };
          }
          
          
          /**
          @author Erik Hjortsberg
          
          Class used for connecting sigc signals to lua. Acts as an adapter for the signals,   recieving them from the c++ environment and sending them to the lua environment.
          
          To use them in lua,   use code like this:
          <code>
           --connect the lua method "lua_foo" to the event "EventFoo" of the object "emitter" and keeps a reference to the adapter in the variable "fooConnector"
           local emitter = EmberOgre.Emitter:new(   )
           fooConnector = EmberOgre.LuaConnector:new_local(  emitter.EventFoo ):connect(  "lua_foo" )
          
           function lua_foo(   )
           --do something here
           end
          
          </code>
          
          */
          class LuaConnector{
          public:
           static void setState(  lua_State* state );
           static lua_State* getState(   );
           static lua_State* sState;
           template <typename T> static void pushValue(  T theValue,   const std::string& luaTypename );
           static void pushValue(  const std::string& theValue,   const std::string& luaTypename );
           static void pushValue(  const float& theValue,   const std::string& luaTypename );
           static void pushValue(  const int& theValue,   const std::string& luaTypename );
           static void pushValue(  const unsigned int& theValue,   const std::string& luaTypename );
           static void pushValue(  const long& theValue,   const std::string& luaTypename );
           static void pushValue(  const unsigned long& theValue,   const std::string& luaTypename );
          
           static void pushValue(  const Eris::ServerInfo& theValue,   const std::string& luaTypename );
           static void pushValue(  const EntityPickResult& theValue,   const std::string& luaTypename );
           static void pushValue(  const MousePickerArgs& theValue,   const std::string& luaTypename );
           static void pushValue(  LuaConnectors::Empty theValue,   const std::string& luaTypename );
           static void pushValue(  const Input::MouseButton& theValue,   const std::string& luaTypename );
           static void pushValue(  const Input::InputMode& theValue,   const std::string& luaTypename );
           static void pushValue(  const std::set<std::string>& theValue,   const std::string& luaTypename );
           static void pushValue(  const Atlas::Message::Element& theValue,   const std::string& luaTypename );
          
          
           LuaConnector(  sigc::signal<void>& signal );
           LuaConnector(  sigc::signal<void,   const std::string&,   EmberEntity*>& signal );
           LuaConnector(  sigc::signal<void,   Eris::Connection*>& signal );
           LuaConnector(  sigc::signal<void,   const Eris::ServerInfo&>& signal );
           LuaConnector(  sigc::signal<void,   float>& signal );
           LuaConnector(  sigc::signal<void,   const EntityPickResult&,   const MousePickerArgs&>& signal );
           LuaConnector(  sigc::signal<void,   const MousePickerArgs&>& signal );
           LuaConnector(  sigc::signal<void,   Input::MouseButton,   Input::InputMode>& signal );
           LuaConnector(  sigc::signal<void,   EmberEntityFactory*>& signal );
           LuaConnector(  sigc::signal<void,   AvatarEmberEntity*>& signal );
           LuaConnector(  sigc::signal<void,   Jesus*>& signal );
           LuaConnector(  sigc::signal<void,   EmberEntity*>& signal );
           LuaConnector(  sigc::signal<void,   const std::string&>& signal );
           LuaConnector(  sigc::signal<bool,   const std::string&>& signal );
           LuaConnector(  sigc::signal<void,   const std::string&,   const std::string&>& signal );
           LuaConnector(  sigc::signal<void,   Terrain::BasePointUserObject*>& signal );
           LuaConnector(  sigc::signal<void,   Terrain::TerrainEditAction*>& signal );
           LuaConnector(  sigc::signal<void,   Eris::Task*>& signal );
           LuaConnector(  sigc::signal<void,   const std::set<std::string>&>& signal );
           LuaConnector(  sigc::signal<void,   EmberOgre::Gui::EntityIcon*>& signal );
           LuaConnector(  sigc::signal<void,   const Atlas::Message::Element&>& signal );
          
           ~LuaConnector(   );
          
           /**
           * Connects to the named lua method.
           * @param luaMethod The fully qualified name of the method.
           * @return
           */
           LuaConnector* connect(  const std::string& luaMethod );
          
           /**
           * Connects to the lua method.
           * @param luaMethod The lua method.
           * @return
           */
           LuaConnector* connect(  int luaMethod );
          
           /**
           Disconnects from the signal.
           */
           void disconnect(   );
          
          private:
           LuaConnectors::ConnectorBase* mConnector;
          };
          
          }
          
          #endif

./components/ogre/scripting/bindings/lua/helpers/LuaConnectorHelper.cpp

       1  //
          // C++ Implementation: LuaConnectorHelper
          /***************************************************************************
           * Copyright (  C ) 2004 - 2006 Paul D Turner & The CEGUI Development Team
           * Copyright (  C ) 2207 Erik Hjortsberg <erik.hjortsberg@iteam.se>
           *
           * Permission is hereby granted,   free of charge,   to any person obtaining
           * a copy of this software and associated documentation files (  the
           * "Software" ),   to deal in the Software without restriction,   including
           * without limitation the rights to use,   copy,   modify,   merge,   publish,  
           * distribute,   sublicense,   and/or sell copies of the Software,   and to
           * permit persons to whom the Software is furnished to do so,   subject to
           * the following conditions:
           *
           * The above copyright notice and this permission notice shall be
           * included in all copies or substantial portions of the Software.
           *
           * THE SOFTWARE IS PROVIDED "AS IS",   WITHOUT WARRANTY OF ANY KIND,  
           * EXPRESS OR IMPLIED,   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
           * MERCHANTABILITY,   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
           * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM,   DAMAGES OR
           * OTHER LIABILITY,   WHETHER IN AN ACTION OF CONTRACT,   TORT OR OTHERWISE,  
           * ARISING FROM,   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
           * OTHER DEALINGS IN THE SOFTWARE.
           ***************************************************************************/
          
          #include "LuaConnectorHelper.h"
          #include "framework/Exception.h"
          #include <sstream>
          
          namespace EmberOgre {
          
          namespace LuaConnectors {
          
          // LuaConnectorHelper::LuaConnectorHelper(   )
          // {
          // }
          //
          //
          // LuaConnectorHelper::~LuaConnectorHelper(   )
          // {
          // }
          
          /*************************************************************************
           Pushes a named function on the stack
           This whole method is pilfered from the CEGUI project. (  CEGUILuaFunctor.cpp )
          *************************************************************************/
      48  void LuaConnectorHelper::pushNamedFunction(  lua_State* state,   const std::string luaMethod )
          {
          // int top = lua_gettop(  state );
          
           // do we have any dots in the handler name? if so we grab the function as a table field
           std::string::size_type i = luaMethod.find_first_of(  '.' );
           if (  i!=std::string::npos )
           {
           // split the rest of the string up in parts seperated by '.'
           // TODO: count the dots and size the vector accordingly from the beginning.
           std::vector<std::string> parts;
           std::string::size_type start = 0;
           do
           {
           parts.push_back(  luaMethod.substr(  start,  i-start ) );
           start = i+1;
           i = luaMethod.find_first_of(  '.',  start );
           } while(  i!=std::string::npos );
          
           // add last part
           parts.push_back(  luaMethod.substr(  start ) );
          
           // first part is the global
           lua_getglobal(  state,   parts[0].c_str(   ) );
           if (  !lua_istable(  state,  -1 ) )
           {
          // lua_settop(  state,  top );
           throw Ember::Exception(  "Unable to get the Lua event handler: '"+luaMethod+"' as first part is not a table" );
           }
          
           // if there is more than two parts,   we have more tables to go through
           std::vector<std::string>::size_type visz = parts.size(   );
           if (  visz-- > 2 ) // avoid subtracting one later on
           {
           // go through all the remaining parts to (  hopefully ) have a valid Lua function in the end
           std::vector<std::string>::size_type vi = 1;
           while (  vi<visz )
           {
           // push key,   and get the next table
           lua_pushstring(  state,  parts[vi].c_str(   ) );
           lua_gettable(  state,  -2 );
           if (  !lua_istable(  state,  -1 ) )
           {
          // lua_settop(  L,  top );
           std::stringstream ss;
           ss <<(  vi+1 );
           throw Ember::Exception(  "Unable to get the Lua event handler: '"+luaMethod+"' as part #"+ss.str(   )+" (  "+parts[vi]+" ) is not a table" );
           }
           // get rid of the last table and move on
           lua_remove(  state,  -2 );
           vi++;
           }
           }
          
           // now we are ready to get the function to call ... phew : )
           lua_pushstring(  state,  parts[visz].c_str(   ) );
           lua_gettable(  state,  -2 );
           lua_remove(  state,  -2 ); // get rid of the table
           }
           // just a regular global function
           else
           {
           lua_getglobal(  state,   luaMethod.c_str(   ) );
           }
          
           // is it a function
           if (   !lua_isfunction(  state,  -1 )  )
           {
           throw Ember::Exception(   "\"" + luaMethod + "\" does not represent a Lua function"  );
           }
          }
          
          }
          
          }

./components/ogre/scripting/bindings/lua/helpers/LuaConnectorHelper.h

       1  //
          // C++ Interface: LuaConnectorHelper
          /***************************************************************************
           * Copyright (  C ) 2004 - 2006 Paul D Turner & The CEGUI Development Team
           * Copyright (  C ) 2207 Erik Hjortsberg <erik.hjortsberg@iteam.se>
           *
           * Permission is hereby granted,   free of charge,   to any person obtaining
           * a copy of this software and associated documentation files (  the
           * "Software" ),   to deal in the Software without restriction,   including
           * without limitation the rights to use,   copy,   modify,   merge,   publish,  
           * distribute,   sublicense,   and/or sell copies of the Software,   and to
           * permit persons to whom the Software is furnished to do so,   subject to
           * the following conditions:
           *
           * The above copyright notice and this permission notice shall be
           * included in all copies or substantial portions of the Software.
           *
           * THE SOFTWARE IS PROVIDED "AS IS",   WITHOUT WARRANTY OF ANY KIND,  
           * EXPRESS OR IMPLIED,   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
           * MERCHANTABILITY,   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
           * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM,   DAMAGES OR
           * OTHER LIABILITY,   WHETHER IN AN ACTION OF CONTRACT,   TORT OR OTHERWISE,  
           * ARISING FROM,   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
           * OTHER DEALINGS IN THE SOFTWARE.
           ***************************************************************************/
          #ifndef EMBEROGRE_LUACONNECTORSLUACONNECTORHELPER_H
          #define EMBEROGRE_LUACONNECTORSLUACONNECTORHELPER_H
          
          #include <tolua++.h>
          #include <string>
          #include <vector>
          
          namespace EmberOgre {
          
          namespace LuaConnectors {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      40  class LuaConnectorHelper{
          public:
          // LuaConnectorHelper(   );
          //
          // ~LuaConnectorHelper(   );
          
           /**
           pushes the lua method onto the stack
           */
      49   static void pushNamedFunction(  lua_State* state,   const std::string luaMethod );
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/scripting/bindings/lua/helpers/LuaConsoleObject.cpp

          //
          // C++ Implementation: LuaConsoleObject
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "LuaConsoleObject.h"
          #include "framework/ConsoleBackend.h"
          #include "LuaConnector.h"
          
          namespace EmberOgre {
          
      29  LuaConsoleObject::LuaConsoleObject(  const std::string& command,   const std::string& luaMethod,   const std::string& description ):
          mCommand(  command ),   mLuaMethod(  luaMethod ),   mCommandWrapper(  command,   this,   description )
          {
           LuaTypeStore typenames;
      33   typenames.push_back(  "string" );
      34   typenames.push_back(  "string" );
           mConnector = new LuaConnectors::ConnectorBase(  typenames );
           mConnector->connect(  luaMethod );
          }
          
          
          LuaConsoleObject::~LuaConsoleObject(   )
          {
           delete mConnector;
          }
          
          void LuaConsoleObject::runCommand(  const std::string &command,   const std::string &args )
          {
           mConnector->callLuaMethod<void,   const std::string &,   const std::string &,   EmberOgre::LuaConnectors::Empty,   EmberOgre::LuaConnectors::Empty>(  command,   args,   EmberOgre::LuaConnectors::Empty(   ),   EmberOgre::LuaConnectors::Empty(   ) );
          }
          
          }

./components/ogre/scripting/bindings/lua/helpers/LuaConsoleObject.h

       1  //
          // C++ Interface: LuaConsoleObject
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRELUACONSOLEOBJECT_H
          #define EMBEROGRELUACONSOLEOBJECT_H
          #include "framework/ConsoleObject.h"
          
          namespace EmberOgre {
          
          namespace LuaConnectors
          {
      31   class ConnectorBase;
          // template<> void ConnectorBase::callLuaMethod(  const std::string& t0,   const std::string& t1,   LuaConnectors::Empty t2,   LuaConnectors::Empty t3 );
          }
          
          
          /**
          @author Erik Hjortsberg
          */
      39  class LuaConsoleObject : public Ember::ConsoleObject
          {
          public:
          
      43   LuaConsoleObject(  const std::string& command,   const std::string& luaMethod,   const std::string& description = "" );
          
      45   ~LuaConsoleObject(   );
          
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
      53   virtual void runCommand(  const std::string &command,   const std::string &args );
          private:
      55   std::string mCommand;
      56   std::string mLuaMethod;
      57   EmberOgre::LuaConnectors::ConnectorBase* mConnector;
      58   const Ember::ConsoleCommandWrapper mCommandWrapper;
          };
          
          }
          
          #endif

./components/ogre/scripting/bindings/lua/helpers/OgreUtils.cpp

       1  //
          // C++ Implementation: OgreUtils
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OgreUtils.h"
          
          namespace EmberOgre {
          
          /**
           * Returns the name of the submesh at the specified index.
           * @param mesh
           * @param subMeshIndex
           * @return
           */
      33  const std::string& OgreUtils::getSubMeshName(  Ogre::Mesh* mesh,   unsigned int subMeshIndex )
          {
           if (  mesh ) {
           for(  Ogre::Mesh::SubMeshNameMap::const_iterator I = mesh->getSubMeshNameMap(   ).begin(   ); I != mesh->getSubMeshNameMap(   ).end(   ); ++I ) {
           if (  subMeshIndex == I->second ) {
           return I->first;
           }
           }
           }
           static const std::string noneFound(  "" );
           return noneFound;
          }
          
          
          }

./components/ogre/scripting/bindings/lua/helpers/OgreUtils.h

       1  //
          // C++ Interface: OgreUtils
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREOGREUTILS_H
          #define EMBEROGREOGREUTILS_H
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      32  class OgreUtils{
          public:
          
      35   static const std::string& getSubMeshName(  Ogre::Mesh* mesh,   unsigned int subMeshIndex );
          
          };
          
          }
          
          #endif

./components/ogre/scripting/bindings/lua/helpers/lua_Helpers.cpp

       1  /*
          ** Lua binding: Helpers
          ** Generated automatically by tolua++-1.0.92 on Sat Jan 19 22:17:31 2008.
          */
          
          #ifndef __cplusplus
          #include "stdlib.h"
          #endif
          #include "string.h"
          
          #include "tolua++.h"
          
          /* Exported function */
      14  TOLUA_API int tolua_Helpers_open (  lua_State* tolua_S );
          
          #include "required.h"
          
          /* function to release collected object via destructor */
          #ifdef __cplusplus
          
      21  static int tolua_collect_EmberOgre__LuaConnector (  lua_State* tolua_S )
          {
           EmberOgre::LuaConnector* self = (  EmberOgre::LuaConnector* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      28  static int tolua_collect_EmberOgre__LuaConsoleObject (  lua_State* tolua_S )
          {
           EmberOgre::LuaConsoleObject* self = (  EmberOgre::LuaConsoleObject* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          #endif
          
          
          /* function to register type */
      38  static void tolua_reg_types (  lua_State* tolua_S )
          {
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::EmberEntityFactory*>" );
           tolua_usertype(  tolua_S,  "EmberOgre::LuaConnector" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const EmberOgre::MousePickerArgs&>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const Eris::ServerInfo&>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Jesus*>" );
           tolua_usertype(  tolua_S,  "EmberOgre::LuaConsoleObject" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::string&,  const std::string&>" );
           tolua_usertype(  tolua_S,  "Ogre::Mesh" );
           tolua_usertype(  tolua_S,  "EmberOgre::OgreUtils" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const Atlas::Message::Element&>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::EmberEntity*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::set<std::string>&>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::AvatarEmberEntity*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::string&>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Eris::Task*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<bool,  const std::string&>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  float>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Eris::Connection*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Terrain::TerrainEditAction*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>" );
          }
          
          /* method: connect of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_connect00
      69  static int tolua_Helpers_EmberOgre_LuaConnector_connect00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::LuaConnector* self = (  EmberOgre::LuaConnector* ) tolua_tousertype(  tolua_S,  1,  0 );
           lua_Object luaMethod = (  (  lua_Object ) tolua_tovalue(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'connect'",  NULL );
          #endif
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) self->connect(  luaMethod );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'connect'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: connect of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_connect01
     102  static int tolua_Helpers_EmberOgre_LuaConnector_connect01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::LuaConnector* self = (  EmberOgre::LuaConnector* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string luaMethod = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'connect'",  NULL );
          #endif
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) self->connect(  luaMethod );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           tolua_pushcppstring(  tolua_S,  (  const char* )luaMethod );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_connect00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: disconnect of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_disconnect00
     132  static int tolua_Helpers_EmberOgre_LuaConnector_disconnect00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::LuaConnector* self = (  EmberOgre::LuaConnector* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'disconnect'",  NULL );
          #endif
           {
           self->disconnect(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'disconnect'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new00
     163  static int tolua_Helpers_EmberOgre_LuaConnector_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           sigc::signal<void>* signal = (  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new00_local
     193  static int tolua_Helpers_EmberOgre_LuaConnector_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           sigc::signal<void>* signal = (  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new01
     223  static int tolua_Helpers_EmberOgre_LuaConnector_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>* signal = (  (  sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new01_local
     248  static int tolua_Helpers_EmberOgre_LuaConnector_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>* signal = (  (  sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new02
     273  static int tolua_Helpers_EmberOgre_LuaConnector_new02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Connection*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  Eris::Connection*>* signal = (  (  sigc::signal<void,  Eris::Connection*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new02_local
     298  static int tolua_Helpers_EmberOgre_LuaConnector_new02_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Connection*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  Eris::Connection*>* signal = (  (  sigc::signal<void,  Eris::Connection*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new01_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new03
     323  static int tolua_Helpers_EmberOgre_LuaConnector_new03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Eris::ServerInfo&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const Eris::ServerInfo&>* signal = (  (  sigc::signal<void,  const Eris::ServerInfo&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new03_local
     348  static int tolua_Helpers_EmberOgre_LuaConnector_new03_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Eris::ServerInfo&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const Eris::ServerInfo&>* signal = (  (  sigc::signal<void,  const Eris::ServerInfo&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new02_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new04
     373  static int tolua_Helpers_EmberOgre_LuaConnector_new04(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  float>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  float>* signal = (  (  sigc::signal<void,  float>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new03(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new04_local
     398  static int tolua_Helpers_EmberOgre_LuaConnector_new04_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  float>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  float>* signal = (  (  sigc::signal<void,  float>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new03_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new05
     423  static int tolua_Helpers_EmberOgre_LuaConnector_new05(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>* signal = (  (  sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new04(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new05_local
     448  static int tolua_Helpers_EmberOgre_LuaConnector_new05_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>* signal = (  (  sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new04_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new06
     473  static int tolua_Helpers_EmberOgre_LuaConnector_new06(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const EmberOgre::MousePickerArgs&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const EmberOgre::MousePickerArgs&>* signal = (  (  sigc::signal<void,  const EmberOgre::MousePickerArgs&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new05(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new06_local
     498  static int tolua_Helpers_EmberOgre_LuaConnector_new06_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const EmberOgre::MousePickerArgs&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const EmberOgre::MousePickerArgs&>* signal = (  (  sigc::signal<void,  const EmberOgre::MousePickerArgs&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new05_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new07
     523  static int tolua_Helpers_EmberOgre_LuaConnector_new07(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>* signal = (  (  sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new06(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new07_local
     548  static int tolua_Helpers_EmberOgre_LuaConnector_new07_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>* signal = (  (  sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new06_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new08
     573  static int tolua_Helpers_EmberOgre_LuaConnector_new08(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::EmberEntityFactory*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::EmberEntityFactory*>* signal = (  (  sigc::signal<void,  EmberOgre::EmberEntityFactory*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new07(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new08_local
     598  static int tolua_Helpers_EmberOgre_LuaConnector_new08_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::EmberEntityFactory*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::EmberEntityFactory*>* signal = (  (  sigc::signal<void,  EmberOgre::EmberEntityFactory*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new07_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new09
     623  static int tolua_Helpers_EmberOgre_LuaConnector_new09(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::AvatarEmberEntity*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::AvatarEmberEntity*>* signal = (  (  sigc::signal<void,  EmberOgre::AvatarEmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new08(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new09_local
     648  static int tolua_Helpers_EmberOgre_LuaConnector_new09_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::AvatarEmberEntity*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::AvatarEmberEntity*>* signal = (  (  sigc::signal<void,  EmberOgre::AvatarEmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new08_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new10
     673  static int tolua_Helpers_EmberOgre_LuaConnector_new10(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Jesus*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Jesus*>* signal = (  (  sigc::signal<void,  EmberOgre::Jesus*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new09(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new10_local
     698  static int tolua_Helpers_EmberOgre_LuaConnector_new10_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Jesus*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Jesus*>* signal = (  (  sigc::signal<void,  EmberOgre::Jesus*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new09_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new11
     723  static int tolua_Helpers_EmberOgre_LuaConnector_new11(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::EmberEntity*>* signal = (  (  sigc::signal<void,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new10(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new11_local
     748  static int tolua_Helpers_EmberOgre_LuaConnector_new11_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::EmberEntity*>* signal = (  (  sigc::signal<void,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new10_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new12
     773  static int tolua_Helpers_EmberOgre_LuaConnector_new12(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const std::string&>* signal = (  (  sigc::signal<void,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new11(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new12_local
     798  static int tolua_Helpers_EmberOgre_LuaConnector_new12_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const std::string&>* signal = (  (  sigc::signal<void,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new11_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new13
     823  static int tolua_Helpers_EmberOgre_LuaConnector_new13(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<bool,  const std::string&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<bool,  const std::string&>* signal = (  (  sigc::signal<bool,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new12(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new13_local
     848  static int tolua_Helpers_EmberOgre_LuaConnector_new13_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<bool,  const std::string&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<bool,  const std::string&>* signal = (  (  sigc::signal<bool,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new12_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new14
     873  static int tolua_Helpers_EmberOgre_LuaConnector_new14(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&,  const std::string&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const std::string&,  const std::string&>* signal = (  (  sigc::signal<void,  const std::string&,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new13(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new14_local
     898  static int tolua_Helpers_EmberOgre_LuaConnector_new14_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&,  const std::string&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const std::string&,  const std::string&>* signal = (  (  sigc::signal<void,  const std::string&,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new13_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new15
     923  static int tolua_Helpers_EmberOgre_LuaConnector_new15(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>* signal = (  (  sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new14(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new15_local
     948  static int tolua_Helpers_EmberOgre_LuaConnector_new15_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>* signal = (  (  sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new14_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new16
     973  static int tolua_Helpers_EmberOgre_LuaConnector_new16(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Terrain::TerrainEditAction*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Terrain::TerrainEditAction*>* signal = (  (  sigc::signal<void,  EmberOgre::Terrain::TerrainEditAction*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new15(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new16_local
     998  static int tolua_Helpers_EmberOgre_LuaConnector_new16_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Terrain::TerrainEditAction*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Terrain::TerrainEditAction*>* signal = (  (  sigc::signal<void,  EmberOgre::Terrain::TerrainEditAction*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new15_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new17
    1023  static int tolua_Helpers_EmberOgre_LuaConnector_new17(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  Eris::Task*>* signal = (  (  sigc::signal<void,  Eris::Task*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new16(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new17_local
    1048  static int tolua_Helpers_EmberOgre_LuaConnector_new17_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  Eris::Task*>* signal = (  (  sigc::signal<void,  Eris::Task*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new16_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new18
    1073  static int tolua_Helpers_EmberOgre_LuaConnector_new18(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::set<std::string>&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const std::set<std::string>&>* signal = (  (  sigc::signal<void,  const std::set<std::string>&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new17(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new18_local
    1098  static int tolua_Helpers_EmberOgre_LuaConnector_new18_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::set<std::string>&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const std::set<std::string>&>* signal = (  (  sigc::signal<void,  const std::set<std::string>&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new17_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new19
    1123  static int tolua_Helpers_EmberOgre_LuaConnector_new19(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* signal = (  (  sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new18(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new19_local
    1148  static int tolua_Helpers_EmberOgre_LuaConnector_new19_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* signal = (  (  sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new18_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new20
    1173  static int tolua_Helpers_EmberOgre_LuaConnector_new20(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Atlas::Message::Element&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const Atlas::Message::Element&>* signal = (  (  sigc::signal<void,  const Atlas::Message::Element&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new19(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConnector */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConnector_new20_local
    1198  static int tolua_Helpers_EmberOgre_LuaConnector_new20_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConnector",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Atlas::Message::Element&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           sigc::signal<void,  const Atlas::Message::Element&>* signal = (  (  sigc::signal<void,  const Atlas::Message::Element&>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::LuaConnector* tolua_ret = (  EmberOgre::LuaConnector* ) new EmberOgre::LuaConnector(  *signal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConnector" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConnector_new19_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConsoleObject */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConsoleObject_new00
    1223  static int tolua_Helpers_EmberOgre_LuaConsoleObject_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConsoleObject",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string command = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string luaMethod = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           {
           EmberOgre::LuaConsoleObject* tolua_ret = (  EmberOgre::LuaConsoleObject* ) new EmberOgre::LuaConsoleObject(  command,  luaMethod );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConsoleObject" );
           tolua_pushcppstring(  tolua_S,  (  const char* )command );
           tolua_pushcppstring(  tolua_S,  (  const char* )luaMethod );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConsoleObject */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConsoleObject_new00_local
    1257  static int tolua_Helpers_EmberOgre_LuaConsoleObject_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConsoleObject",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string command = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string luaMethod = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           {
           EmberOgre::LuaConsoleObject* tolua_ret = (  EmberOgre::LuaConsoleObject* ) new EmberOgre::LuaConsoleObject(  command,  luaMethod );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConsoleObject" );
           tolua_pushcppstring(  tolua_S,  (  const char* )command );
           tolua_pushcppstring(  tolua_S,  (  const char* )luaMethod );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LuaConsoleObject */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConsoleObject_new01
    1291  static int tolua_Helpers_EmberOgre_LuaConsoleObject_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConsoleObject",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const std::string command = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string luaMethod = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const std::string description = (  (  const std::string ) tolua_tocppstring(  tolua_S,  4,  0 ) );
           {
           EmberOgre::LuaConsoleObject* tolua_ret = (  EmberOgre::LuaConsoleObject* ) new EmberOgre::LuaConsoleObject(  command,  luaMethod,  description );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LuaConsoleObject" );
           tolua_pushcppstring(  tolua_S,  (  const char* )command );
           tolua_pushcppstring(  tolua_S,  (  const char* )luaMethod );
           tolua_pushcppstring(  tolua_S,  (  const char* )description );
           }
           }
           return 4;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConsoleObject_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LuaConsoleObject */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConsoleObject_new01_local
    1323  static int tolua_Helpers_EmberOgre_LuaConsoleObject_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LuaConsoleObject",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const std::string command = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string luaMethod = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const std::string description = (  (  const std::string ) tolua_tocppstring(  tolua_S,  4,  0 ) );
           {
           EmberOgre::LuaConsoleObject* tolua_ret = (  EmberOgre::LuaConsoleObject* ) new EmberOgre::LuaConsoleObject(  command,  luaMethod,  description );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LuaConsoleObject" );
           tolua_pushcppstring(  tolua_S,  (  const char* )command );
           tolua_pushcppstring(  tolua_S,  (  const char* )luaMethod );
           tolua_pushcppstring(  tolua_S,  (  const char* )description );
           }
           }
           return 4;
          tolua_lerror:
           return tolua_Helpers_EmberOgre_LuaConsoleObject_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::LuaConsoleObject */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_LuaConsoleObject_delete00
    1355  static int tolua_Helpers_EmberOgre_LuaConsoleObject_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::LuaConsoleObject",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::LuaConsoleObject* self = (  EmberOgre::LuaConsoleObject* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubMeshName of class EmberOgre::OgreUtils */
          #ifndef TOLUA_DISABLE_tolua_Helpers_EmberOgre_OgreUtils_getSubMeshName00
    1384  static int tolua_Helpers_EmberOgre_OgreUtils_getSubMeshName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::OgreUtils",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Mesh",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Mesh* mesh = (  (  Ogre::Mesh* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           unsigned int subMeshIndex = (  (  unsigned int ) tolua_tonumber(  tolua_S,  3,  0 ) );
           {
           const std::string tolua_ret = (  const std::string ) EmberOgre::OgreUtils::getSubMeshName(  mesh,  subMeshIndex );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSubMeshName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* Open function */
    1415  TOLUA_API int tolua_Helpers_open (  lua_State* tolua_S )
          {
           tolua_open(  tolua_S );
           tolua_reg_types(  tolua_S );
           tolua_module(  tolua_S,  NULL,  0 );
           tolua_beginmodule(  tolua_S,  NULL );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "LuaConnector",  "EmberOgre::LuaConnector",  "",  tolua_collect_EmberOgre__LuaConnector );
           #else
           tolua_cclass(  tolua_S,  "LuaConnector",  "EmberOgre::LuaConnector",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "LuaConnector" );
           tolua_function(  tolua_S,  "connect",  tolua_Helpers_EmberOgre_LuaConnector_connect00 );
           tolua_function(  tolua_S,  "connect",  tolua_Helpers_EmberOgre_LuaConnector_connect01 );
           tolua_function(  tolua_S,  "disconnect",  tolua_Helpers_EmberOgre_LuaConnector_disconnect00 );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new00_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new01_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new02 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new02_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new02_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new03 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new03_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new03_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new04 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new04_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new04_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new05 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new05_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new05_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new06 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new06_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new06_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new07 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new07_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new07_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new08 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new08_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new08_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new09 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new09_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new09_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new10 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new10_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new10_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new11 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new11_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new11_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new12 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new12_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new12_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new13 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new13_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new13_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new14 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new14_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new14_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new15 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new15_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new15_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new16 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new16_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new16_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new17 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new17_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new17_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new18 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new18_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new18_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new19 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new19_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new19_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConnector_new20 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConnector_new20_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConnector_new20_local );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "LuaConsoleObject",  "EmberOgre::LuaConsoleObject",  "",  tolua_collect_EmberOgre__LuaConsoleObject );
           #else
           tolua_cclass(  tolua_S,  "LuaConsoleObject",  "EmberOgre::LuaConsoleObject",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "LuaConsoleObject" );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConsoleObject_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConsoleObject_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConsoleObject_new00_local );
           tolua_function(  tolua_S,  "new",  tolua_Helpers_EmberOgre_LuaConsoleObject_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_Helpers_EmberOgre_LuaConsoleObject_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_Helpers_EmberOgre_LuaConsoleObject_new01_local );
           tolua_function(  tolua_S,  "delete",  tolua_Helpers_EmberOgre_LuaConsoleObject_delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "OgreUtils",  "EmberOgre::OgreUtils",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "OgreUtils" );
           tolua_function(  tolua_S,  "getSubMeshName",  tolua_Helpers_EmberOgre_OgreUtils_getSubMeshName00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           return 1;
          }
          
          
          #if defined(  LUA_VERSION_NUM ) && LUA_VERSION_NUM >= 501
    1527   TOLUA_API int luaopen_Helpers (  lua_State* tolua_S ) {
           return tolua_Helpers_open(  tolua_S );
          };
          #endif
          

./components/ogre/scripting/bindings/lua/helpers/required.h

       1  // #include <SDL.h>
          //
          // #include <sigc++/sigc++.h>
          //
          // // #include <Eris/View.h>
          //
          // #include "components/ogre/AvatarController.h"
          // #include "components/ogre/Avatar.h"
          // #include "components/ogre/AvatarCamera.h"
          // #include "components/ogre/EmberOgre.h"
          //
          // #include "components/ogre/EmberEntityFactory.h"
          //
          // #include "components/ogre/EmberEntity.h"
          // #include "components/ogre/EmberPhysicalEntity.h"
          // #include "components/ogre/PersonEmberEntity.h"
          // #include "components/ogre/AvatarEmberEntity.h"
          // #include "components/ogre/WorldEmberEntity.h"
          //
          // #include "components/ogre/MousePicker.h"
          //
          // #include "components/ogre/MotionManager.h"
          // #include "components/ogre/GUIManager.h"
          // #include "components/ogre/TerrainGenerator.h"
          //
          // #include "components/ogre/model/Model.h"
          //
          // #include "components/ogre/widgets/Widget.h"
          //
          // #include "components/ogre/input/Input.h"
          //
          // #include "components/ogre/jesus/Jesus.h"
          
          #include "LuaConnector.h"
          #include "LuaConsoleObject.h"
          #include "OgreUtils.h"
          //#include "LuaConnector.h"
          
          // Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->EventChangedConfigItem.connect(  sigc::mem_fun(  *this,   &AvatarCamera::ConfigService_EventChangedConfigItem ) );

./components/ogre/scripting/bindings/lua/lua_EmberOgre.cpp

       1  /*
          ** Lua binding: EmberOgre
          ** Generated automatically by tolua++-1.0.92 on Thu Jan 24 21:43:18 2008.
          */
          
          #ifndef __cplusplus
          #include "stdlib.h"
          #endif
          #include "string.h"
          
          #include "tolua++.h"
          
          /* Exported function */
      14  TOLUA_API int tolua_EmberOgre_open (  lua_State* tolua_S );
          
          #include "required.h"
          #include "components/ogre/carpenter/Carpenter.h"
          #include "components/ogre/widgets/AssetsManager.h"
          
          /* function to release collected object via destructor */
          #ifdef __cplusplus
          
      23  static int tolua_collect_EmberOgre__Model__ModelDefnPtr (  lua_State* tolua_S )
          {
           EmberOgre::Model::ModelDefnPtr* self = (  EmberOgre::Model::ModelDefnPtr* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      30  static int tolua_collect_EmberOgre__Jesus (  lua_State* tolua_S )
          {
           EmberOgre::Jesus* self = (  EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      37  static int tolua_collect_std__set_std__string_ (  lua_State* tolua_S )
          {
           std::set<std::string>* self = (  std::set<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      44  static int tolua_collect_EmberOgre__AttachPointNode (  lua_State* tolua_S )
          {
           EmberOgre::AttachPointNode* self = (  EmberOgre::AttachPointNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      51  static int tolua_collect_Carpenter__AttachPair (  lua_State* tolua_S )
          {
           Carpenter::AttachPair* self = (  Carpenter::AttachPair* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      58  static int tolua_collect_std__vector_EmberOgre__Model__PartDefinition__ (  lua_State* tolua_S )
          {
           std::vector<EmberOgre::Model::PartDefinition*>* self = (  std::vector<EmberOgre::Model::PartDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      65  static int tolua_collect_EmberOgre__Gui__Icons__IconManager (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Icons::IconManager* self = (  EmberOgre::Gui::Icons::IconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      72  static int tolua_collect_std__vector_const_Carpenter__AttachPoint__ (  lua_State* tolua_S )
          {
           std::vector<const Carpenter::AttachPoint*>* self = (  std::vector<const Carpenter::AttachPoint*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      79  static int tolua_collect_std__vector_EmberOgre__ModelBlock__ (  lua_State* tolua_S )
          {
           std::vector<EmberOgre::ModelBlock*>* self = (  std::vector<EmberOgre::ModelBlock*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      86  static int tolua_collect_std__vector_std__string_ (  lua_State* tolua_S )
          {
           std::vector<std::string>* self = (  std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      93  static int tolua_collect_EmberOgre__Gui__EntityEditor (  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityEditor* self = (  EmberOgre::Gui::EntityEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     100  static int tolua_collect_EmberOgre__LightWibbler (  lua_State* tolua_S )
          {
           EmberOgre::LightWibbler* self = (  EmberOgre::LightWibbler* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     107  static int tolua_collect_EmberOgre__OgreInfo (  lua_State* tolua_S )
          {
           EmberOgre::OgreInfo* self = (  EmberOgre::OgreInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     114  static int tolua_collect_Ogre__MapIterator_Ogre__ResourceManager__ResourceHandleMap_ (  lua_State* tolua_S )
          {
           Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* self = (  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     121  static int tolua_collect_EmberOgre__AttributeObserver (  lua_State* tolua_S )
          {
           EmberOgre::AttributeObserver* self = (  EmberOgre::AttributeObserver* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     128  static int tolua_collect_EmberOgre__Gui__QuaternionAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::QuaternionAdapter* self = (  EmberOgre::Gui::QuaternionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     135  static int tolua_collect_EmberOgre__Model__Model (  lua_State* tolua_S )
          {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     142  static int tolua_collect_Carpenter__BuildingBlockSpecDefinition (  lua_State* tolua_S )
          {
           Carpenter::BuildingBlockSpecDefinition* self = (  Carpenter::BuildingBlockSpecDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     149  static int tolua_collect_EmberOgre__Gui__ConsoleAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::ConsoleAdapter* self = (  EmberOgre::Gui::ConsoleAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     156  static int tolua_collect_WFMath__Quaternion (  lua_State* tolua_S )
          {
           WFMath::Quaternion* self = (  WFMath::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     163  static int tolua_collect_std__vector_EmberOgre__Model__SubEntityDefinition__ (  lua_State* tolua_S )
          {
           std::vector<EmberOgre::Model::SubEntityDefinition*>* self = (  std::vector<EmberOgre::Model::SubEntityDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     170  static int tolua_collect_EmberOgre__Gui__Vector3Adapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Vector3Adapter* self = (  EmberOgre::Gui::Vector3Adapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     177  static int tolua_collect_WFMath__Point_3_ (  lua_State* tolua_S )
          {
           WFMath::Point<3>* self = (  WFMath::Point<3>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     184  static int tolua_collect_Ogre__Real (  lua_State* tolua_S )
          {
           Ogre::Real* self = (  Ogre::Real* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     191  static int tolua_collect_std__vector_EmberOgre__AttachPointNode__ (  lua_State* tolua_S )
          {
           std::vector<EmberOgre::AttachPointNode*>* self = (  std::vector<EmberOgre::AttachPointNode*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     198  static int tolua_collect_EmberOgre__Gui__IconBase (  lua_State* tolua_S )
          {
           EmberOgre::Gui::IconBase* self = (  EmberOgre::Gui::IconBase* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     205  static int tolua_collect_EmberOgre__Construction (  lua_State* tolua_S )
          {
           EmberOgre::Construction* self = (  EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     212  static int tolua_collect_std__vector_EmberOgre__Model__SubModelDefinition__ (  lua_State* tolua_S )
          {
           std::vector<EmberOgre::Model::SubModelDefinition*>* self = (  std::vector<EmberOgre::Model::SubModelDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     219  static int tolua_collect_Ogre__Quaternion (  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     226  static int tolua_collect_EmberOgre__Gui__StackableContainer (  lua_State* tolua_S )
          {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     233  static int tolua_collect_EmberOgre__Gui__ModelRenderer (  lua_State* tolua_S )
          {
           EmberOgre::Gui::ModelRenderer* self = (  EmberOgre::Gui::ModelRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     240  static int tolua_collect_EmberOgre__Gui__OgreEntityRenderer (  lua_State* tolua_S )
          {
           EmberOgre::Gui::OgreEntityRenderer* self = (  EmberOgre::Gui::OgreEntityRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     247  static int tolua_collect_WFMath__Vector_3_ (  lua_State* tolua_S )
          {
           WFMath::Vector<3>* self = (  WFMath::Vector<3>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     254  static int tolua_collect_EmberOgre__Terrain__TerrainArea (  lua_State* tolua_S )
          {
           EmberOgre::Terrain::TerrainArea* self = (  EmberOgre::Terrain::TerrainArea* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     261  static int tolua_collect_EmberOgre__Gui__IconBar (  lua_State* tolua_S )
          {
           EmberOgre::Gui::IconBar* self = (  EmberOgre::Gui::IconBar* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     268  static int tolua_collect_EmberOgre__AvatarControllerMovement (  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     275  static int tolua_collect_Ogre__ColourValue (  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     282  static int tolua_collect_std__vector_Eris__Task__ (  lua_State* tolua_S )
          {
           std::vector<Eris::Task*>* self = (  std::vector<Eris::Task*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     289  static int tolua_collect_EmberOgre__Gui__AssetsManager (  lua_State* tolua_S )
          {
           EmberOgre::Gui::AssetsManager* self = (  EmberOgre::Gui::AssetsManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     296  static int tolua_collect_EmberOgre__TerrainPosition (  lua_State* tolua_S )
          {
           EmberOgre::TerrainPosition* self = (  EmberOgre::TerrainPosition* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     303  static int tolua_collect_Carpenter__BuildingBlockSpec (  lua_State* tolua_S )
          {
           Carpenter::BuildingBlockSpec* self = (  Carpenter::BuildingBlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     310  static int tolua_collect_Ogre__Vector3 (  lua_State* tolua_S )
          {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     317  static int tolua_collect_EmberOgre__ModelBlock (  lua_State* tolua_S )
          {
           EmberOgre::ModelBlock* self = (  EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     324  static int tolua_collect_Carpenter__AttachPoint (  lua_State* tolua_S )
          {
           Carpenter::AttachPoint* self = (  Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     331  static int tolua_collect_EmberOgre__Gui__ListHolder (  lua_State* tolua_S )
          {
           EmberOgre::Gui::ListHolder* self = (  EmberOgre::Gui::ListHolder* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     338  static int tolua_collect_Carpenter__Carpenter (  lua_State* tolua_S )
          {
           Carpenter::Carpenter* self = (  Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     345  static int tolua_collect_Atlas__Message__Element (  lua_State* tolua_S )
          {
           Atlas::Message::Element* self = (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     352  static int tolua_collect_EmberOgre__Terrain__TerrainEditor (  lua_State* tolua_S )
          {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          #endif
          
          
          /* function to register type */
     362  static void tolua_reg_types (  lua_State* tolua_S )
          {
           tolua_usertype(  tolua_S,  "std::vector<EmberOgre::Model::SubModelDefinition*>" );
           tolua_usertype(  tolua_S,  "std::set<std::string>" );
           tolua_usertype(  tolua_S,  "EmberOgre::AttachPointNode" );
           tolua_usertype(  tolua_S,  "std::map<const std::string,  Carpenter::BlockSpec>" );
           tolua_usertype(  tolua_S,  "Ogre::Billboard" );
           tolua_usertype(  tolua_S,  "Eris::TypeInfo" );
           tolua_usertype(  tolua_S,  "Ogre::SceneManager" );
           tolua_usertype(  tolua_S,  "Ogre::ControllerValue<Ogre::Real>" );
           tolua_usertype(  tolua_S,  "Ogre::Degree" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>" );
           tolua_usertype(  tolua_S,  "std::vector<EmberOgre::Model::ActionDefinition*>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::EntityEditor" );
           tolua_usertype(  tolua_S,  "EmberOgre::LightWibbler" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::GUIManager&>" );
           tolua_usertype(  tolua_S,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>" );
           tolua_usertype(  tolua_S,  "EmberOgre::MovableObjectRenderer" );
           tolua_usertype(  tolua_S,  "EmberOgre::Terrain::BasePointUserObject" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::Action" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::EmberEntity*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const EmberOgre::Terrain::TerrainEditAction*>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::EntityIconSlot" );
           tolua_usertype(  tolua_S,  "EmberOgre::TerrainPosition" );
           tolua_usertype(  tolua_S,  "EmberOgre::ModelBlock" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::AvatarMovementMode::Mode>" );
           tolua_usertype(  tolua_S,  "Atlas::Message::Element" );
           tolua_usertype(  tolua_S,  "std::vector<EmberOgre::Terrain::TerrainEditBasePointMovement>" );
           tolua_usertype(  tolua_S,  "WFMath::Point<3>" );
           tolua_usertype(  tolua_S,  "WFMath::AxisBox<3>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::IconBar" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>" );
           tolua_usertype(  tolua_S,  "Ogre::AxisAlignedBox" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::EntityIconManager" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Icons::IconManager" );
           tolua_usertype(  tolua_S,  "std::vector<const Carpenter::AttachPoint*>" );
           tolua_usertype(  tolua_S,  "std::vector<EmberOgre::ModelBlock*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  float>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::AvatarEmberEntity*>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Environment::ISun" );
           tolua_usertype(  tolua_S,  "SDLKey" );
           tolua_usertype(  tolua_S,  "Carpenter::BuildingBlock" );
           tolua_usertype(  tolua_S,  "Carpenter::BuildingBlockBindingDefinition" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::ModelDefinition" );
           tolua_usertype(  tolua_S,  "std::map<const std::string,  Carpenter::BuildingBlockSpec>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Environment::IFog" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::AttachPointDefinition" );
           tolua_usertype(  tolua_S,  "EmberOgre::EmberPhysicalEntity" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Avatar" );
           tolua_usertype(  tolua_S,  "CEGUI::Window" );
           tolua_usertype(  tolua_S,  "EmberOgre::AvatarMovementMode" );
           tolua_usertype(  tolua_S,  "Eris::Entity" );
           tolua_usertype(  tolua_S,  "std::vector<Eris::Task*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::string&>" );
           tolua_usertype(  tolua_S,  "EmberOgre::EmberEntityFactory" );
           tolua_usertype(  tolua_S,  "Ogre::Entity" );
           tolua_usertype(  tolua_S,  "Ogre::Vector3" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::EntityIconDragDropTarget" );
           tolua_usertype(  tolua_S,  "Carpenter::Carpenter" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const Ogre::ColourValue&>" );
           tolua_usertype(  tolua_S,  "CEGUI::Image" );
           tolua_usertype(  tolua_S,  "Carpenter::BlockSpec" );
           tolua_usertype(  tolua_S,  "WFMath::Vector<3>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Icons::Icon" );
           tolua_usertype(  tolua_S,  "CEGUI::Editbox" );
           tolua_usertype(  tolua_S,  "const" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::PartDefinition" );
           tolua_usertype(  tolua_S,  "std::vector<std::string>" );
           tolua_usertype(  tolua_S,  "EmberOgre::AvatarCamera" );
           tolua_usertype(  tolua_S,  "EmberOgre::MouseMotion" );
           tolua_usertype(  tolua_S,  "EmberOgre::AvatarController" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::Model" );
           tolua_usertype(  tolua_S,  "EmberOgre::MousePickerArgs" );
           tolua_usertype(  tolua_S,  "std::map<const std::string,  Carpenter::BluePrint>" );
           tolua_usertype(  tolua_S,  "Ogre::AnimationState" );
           tolua_usertype(  tolua_S,  "std::vector<EmberOgre::Model::SubEntityDefinition*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Ogre::Camera*>" );
           tolua_usertype(  tolua_S,  "std::vector<EmberOgre::Model::AttachPointDefinition>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Environment::ISky" );
           tolua_usertype(  tolua_S,  "Ogre::Resource" );
           tolua_usertype(  tolua_S,  "Carpenter::AttachPair" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Terrain::TerrainGenerator&>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::MotionManager&>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::OgreEntityRenderer" );
           tolua_usertype(  tolua_S,  "std::map<std::string,  EmberOgre::Model::ViewDefinition*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const EmberOgre::MouseMotion&,  EmberOgre::Input::InputMode>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::EmberEntityFactory*>" );
           tolua_usertype(  tolua_S,  "Ogre::RenderWindow" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::ConsoleAdapter" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::SubEntityDefinition" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const Atlas::Message::Element&>" );
           tolua_usertype(  tolua_S,  "std::vector<EmberOgre::Model::PartDefinition*>" );
           tolua_usertype(  tolua_S,  "EmberOgre::OgreInfo" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::QuaternionAdapter" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Widget" );
           tolua_usertype(  tolua_S,  "EmberOgre::Terrain::TerrainEditAction" );
           tolua_usertype(  tolua_S,  "EmberOgre::AttributeObserver" );
           tolua_usertype(  tolua_S,  "EmberOgre::Terrain::TerrainArea" );
           tolua_usertype(  tolua_S,  "Ogre;;ResourceManager" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::ModelDefinitionManager" );
           tolua_usertype(  tolua_S,  "EmberOgre::Terrain::TerrainEditor" );
           tolua_usertype(  tolua_S,  "Mercator::Area" );
           tolua_usertype(  tolua_S,  "EmberOgre::EmberEntity" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>" );
           tolua_usertype(  tolua_S,  "EmberOgre::EntityWorldPickListener" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::SubModelDefinition" );
           tolua_usertype(  tolua_S,  "EmberOgre::GUIManager" );
           tolua_usertype(  tolua_S,  "EmberOgre::ModelMapping" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::ListHolder" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::ModelRenderer" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Jesus*>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::MovableObjectRenderer" );
           tolua_usertype(  tolua_S,  "WFMath::Quaternion" );
           tolua_usertype(  tolua_S,  "Carpenter::BuildingBlockSpec" );
           tolua_usertype(  tolua_S,  "Ogre::Vector2" );
           tolua_usertype(  tolua_S,  "EmberOgre::EntityPickResult" );
           tolua_usertype(  tolua_S,  "CEGUI::PushButton" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::AssetsManager" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Vector3Adapter" );
           tolua_usertype(  tolua_S,  "EmberOgre::Construction" );
           tolua_usertype(  tolua_S,  "EmberOgre::AvatarEmberEntity" );
           tolua_usertype(  tolua_S,  "Carpenter::BluePrint" );
           tolua_usertype(  tolua_S,  "std::vector<EmberOgre::AttachPointNode*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::AvatarController&>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>" );
           tolua_usertype(  tolua_S,  "CEGUI::Listbox" );
           tolua_usertype(  tolua_S,  "Ogre::BillboardSet" );
           tolua_usertype(  tolua_S,  "Mercator::BasePoint" );
           tolua_usertype(  tolua_S,  "Carpenter::BuildingBlockDefinition" );
           tolua_usertype(  tolua_S,  "CEGUI::ListboxTextItem" );
           tolua_usertype(  tolua_S,  "std::map<std::string,  Carpenter::BluePrint*>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Jesus" );
           tolua_usertype(  tolua_S,  "EmberOgre::EmberOgre" );
           tolua_usertype(  tolua_S,  "CEGUI::ListboxItem" );
           tolua_usertype(  tolua_S,  "Carpenter::BuildingBlockSpecDefinition" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  EmberOgre::Input::InputMode>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::ViewDefinition" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::ActionDefinition" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const SDL_keysym&,  EmberOgre::Input::InputMode>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::IconBase" );
           tolua_usertype(  tolua_S,  "Ogre::Real" );
           tolua_usertype(  tolua_S,  "EmberOgre::Input" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::EntityIcon" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::ModelDefnPtr" );
           tolua_usertype(  tolua_S,  "EmberOgre::MotionManager::MotionManagerInfo" );
           tolua_usertype(  tolua_S,  "Ogre::Quaternion" );
           tolua_usertype(  tolua_S,  "EmberOgre::EntityMoveManager" );
           tolua_usertype(  tolua_S,  "EmberOgre::AvatarControllerMovement" );
           tolua_usertype(  tolua_S,  "Carpenter::BuildingBlockBinding" );
           tolua_usertype(  tolua_S,  "Eris::Task" );
           tolua_usertype(  tolua_S,  "sigc::signal<void>" );
           tolua_usertype(  tolua_S,  "Ogre::Camera" );
           tolua_usertype(  tolua_S,  "EmberOgre::Environment::IWater" );
           tolua_usertype(  tolua_S,  "Ogre::ColourValue" );
           tolua_usertype(  tolua_S,  "EmberOgre::Model::SubModel" );
           tolua_usertype(  tolua_S,  "EmberOgre::Environment::Environment" );
           tolua_usertype(  tolua_S,  "CEGUI::DragContainer" );
           tolua_usertype(  tolua_S,  "EmberOgre::MotionManager" );
           tolua_usertype(  tolua_S,  "EmberOgre::WorldEmberEntity" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::StackableContainer" );
           tolua_usertype(  tolua_S,  "Carpenter::AttachPoint" );
           tolua_usertype(  tolua_S,  "EmberOgre::AvatarMovementState" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::ColouredListItem" );
           tolua_usertype(  tolua_S,  "EmberOgre::Terrain::TerrainEditBasePointMovement" );
           tolua_usertype(  tolua_S,  "Ogre::SceneNode" );
          }
          
          /* method: getAttachPoint of class Carpenter::AttachPair */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPair_getAttachPoint00
     533  static int tolua_EmberOgre_Carpenter_AttachPair_getAttachPoint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPair",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPair* self = (  const Carpenter::AttachPair* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttachPoint'",  NULL );
          #endif
           {
           const Carpenter::AttachPoint* tolua_ret = (  const Carpenter::AttachPoint* ) self->getAttachPoint(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const Carpenter::AttachPoint" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttachPoint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Carpenter::AttachPair */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPair_new00
     568  static int tolua_EmberOgre_Carpenter_AttachPair_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::AttachPair",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string type = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           Carpenter::AttachPoint point1 = *(  (  Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           Carpenter::AttachPoint point2 = *(  (  Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           Carpenter::AttachPair* tolua_ret = (  Carpenter::AttachPair* ) new Carpenter::AttachPair(  name,  type,  point1,  point2 );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::AttachPair" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           tolua_pushcppstring(  tolua_S,  (  const char* )type );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Carpenter::AttachPair */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPair_new00_local
     606  static int tolua_EmberOgre_Carpenter_AttachPair_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::AttachPair",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string type = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           Carpenter::AttachPoint point1 = *(  (  Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           Carpenter::AttachPoint point2 = *(  (  Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           Carpenter::AttachPair* tolua_ret = (  Carpenter::AttachPair* ) new Carpenter::AttachPair(  name,  type,  point1,  point2 );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Carpenter::AttachPair" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           tolua_pushcppstring(  tolua_S,  (  const char* )type );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPoint1 of class Carpenter::AttachPair */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPair_getPoint100
     644  static int tolua_EmberOgre_Carpenter_AttachPair_getPoint100(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPair",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPair* self = (  const Carpenter::AttachPair* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPoint1'",  NULL );
          #endif
           {
           const Carpenter::AttachPoint& tolua_ret = (  const Carpenter::AttachPoint& ) self->getPoint1(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Carpenter::AttachPoint" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPoint1'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPoint2 of class Carpenter::AttachPair */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPair_getPoint200
     676  static int tolua_EmberOgre_Carpenter_AttachPair_getPoint200(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPair",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPair* self = (  const Carpenter::AttachPair* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPoint2'",  NULL );
          #endif
           {
           const Carpenter::AttachPoint& tolua_ret = (  const Carpenter::AttachPoint& ) self->getPoint2(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Carpenter::AttachPoint" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPoint2'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class Carpenter::AttachPair */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPair_getName00
     708  static int tolua_EmberOgre_Carpenter_AttachPair_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPair",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPair* self = (  const Carpenter::AttachPair* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getType of class Carpenter::AttachPair */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPair_getType00
     740  static int tolua_EmberOgre_Carpenter_AttachPair_getType00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPair",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPair* self = (  const Carpenter::AttachPair* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getType'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getType(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getType'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Carpenter::AttachPoint */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPoint_new00
     772  static int tolua_EmberOgre_Carpenter_AttachPoint_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "WFMath::Point<3>",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "WFMath::Vector<3>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string mName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           WFMath::Point<3> position = *(  (  WFMath::Point<3>* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           WFMath::Vector<3> normal = *(  (  WFMath::Vector<3>* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           Carpenter::AttachPoint* tolua_ret = (  Carpenter::AttachPoint* ) new Carpenter::AttachPoint(  mName,  position,  normal );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::AttachPoint" );
           tolua_pushcppstring(  tolua_S,  (  const char* )mName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Carpenter::AttachPoint */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPoint_new00_local
     807  static int tolua_EmberOgre_Carpenter_AttachPoint_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "WFMath::Point<3>",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "WFMath::Vector<3>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string mName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           WFMath::Point<3> position = *(  (  WFMath::Point<3>* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           WFMath::Vector<3> normal = *(  (  WFMath::Vector<3>* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           Carpenter::AttachPoint* tolua_ret = (  Carpenter::AttachPoint* ) new Carpenter::AttachPoint(  mName,  position,  normal );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Carpenter::AttachPoint" );
           tolua_pushcppstring(  tolua_S,  (  const char* )mName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class Carpenter::AttachPoint */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPoint_getName00
     842  static int tolua_EmberOgre_Carpenter_AttachPoint_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPoint* self = (  const Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNormal of class Carpenter::AttachPoint */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPoint_getNormal00
     874  static int tolua_EmberOgre_Carpenter_AttachPoint_getNormal00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPoint* self = (  const Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNormal'",  NULL );
          #endif
           {
           const WFMath::Vector<3>& tolua_ret = (  const WFMath::Vector<3>& ) self->getNormal(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const WFMath::Vector<3>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNormal'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPosition of class Carpenter::AttachPoint */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPoint_getPosition00
     906  static int tolua_EmberOgre_Carpenter_AttachPoint_getPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPoint* self = (  const Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPosition'",  NULL );
          #endif
           {
           const WFMath::Point<3>& tolua_ret = (  const WFMath::Point<3>& ) self->getPosition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const WFMath::Point<3>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttachPair of class Carpenter::AttachPoint */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPoint_getAttachPair00
     938  static int tolua_EmberOgre_Carpenter_AttachPoint_getAttachPair00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPoint* self = (  const Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttachPair'",  NULL );
          #endif
           {
           const Carpenter::AttachPair* tolua_ret = (  const Carpenter::AttachPair* ) self->getAttachPair(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const Carpenter::AttachPair" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttachPair'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSibling of class Carpenter::AttachPoint */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_AttachPoint_getSibling00
     970  static int tolua_EmberOgre_Carpenter_AttachPoint_getSibling00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::AttachPoint* self = (  const Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSibling'",  NULL );
          #endif
           {
           const Carpenter::AttachPoint* tolua_ret = (  const Carpenter::AttachPoint* ) self->getSibling(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const Carpenter::AttachPoint" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSibling'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class Carpenter::BlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BlockSpec_getName00
    1002  static int tolua_EmberOgre_Carpenter_BlockSpec_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::BlockSpec",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::BlockSpec* self = (  const Carpenter::BlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBoundingBox of class Carpenter::BlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BlockSpec_getBoundingBox00
    1034  static int tolua_EmberOgre_Carpenter_BlockSpec_getBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::BlockSpec",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::BlockSpec* self = (  const Carpenter::BlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBoundingBox'",  NULL );
          #endif
           {
           const WFMath::AxisBox<3>& tolua_ret = (  const WFMath::AxisBox<3>& ) self->getBoundingBox(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const WFMath::AxisBox<3>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttachPair of class Carpenter::BlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BlockSpec_getAttachPair00
    1066  static int tolua_EmberOgre_Carpenter_BlockSpec_getAttachPair00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::BlockSpec",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::BlockSpec* self = (  const Carpenter::BlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttachPair'",  NULL );
          #endif
           {
           const Carpenter::AttachPair* tolua_ret = (  const Carpenter::AttachPair* ) self->getAttachPair(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const Carpenter::AttachPair" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttachPair'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addAttachPair of class Carpenter::BlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BlockSpec_addAttachPair00
    1101  static int tolua_EmberOgre_Carpenter_BlockSpec_addAttachPair00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Carpenter::BlockSpec",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Carpenter::AttachPair",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::BlockSpec* self = (  Carpenter::BlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
           Carpenter::AttachPair* pair = (  (  Carpenter::AttachPair* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addAttachPair'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->addAttachPair(  pair );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addAttachPair'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setBoundingBox of class Carpenter::BlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BlockSpec_setBoundingBox00
    1135  static int tolua_EmberOgre_Carpenter_BlockSpec_setBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Carpenter::BlockSpec",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "WFMath::AxisBox<3>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::BlockSpec* self = (  Carpenter::BlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
           WFMath::AxisBox<3> bbox = *(  (  WFMath::AxisBox<3>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setBoundingBox'",  NULL );
          #endif
           {
           self->setBoundingBox(  bbox );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAllPoints of class Carpenter::BlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BlockSpec_getAllPoints00
    1168  static int tolua_EmberOgre_Carpenter_BlockSpec_getAllPoints00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::BlockSpec",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::BlockSpec* self = (  const Carpenter::BlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAllPoints'",  NULL );
          #endif
           {
           const std::vector<const Carpenter::AttachPoint*> tolua_ret = (  const std::vector<const Carpenter::AttachPoint*> ) self->getAllPoints(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::vector<const Carpenter::AttachPoint*>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "const std::vector<const Carpenter::AttachPoint*>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  const std::vector<const Carpenter::AttachPoint*> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "const std::vector<const Carpenter::AttachPoint*>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAllPoints'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Carpenter::BuildingBlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BuildingBlockSpec_new00
    1208  static int tolua_EmberOgre_Carpenter_BuildingBlockSpec_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::BuildingBlockSpec",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Carpenter::BuildingBlockSpec* tolua_ret = (  Carpenter::BuildingBlockSpec* ) new Carpenter::BuildingBlockSpec(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::BuildingBlockSpec" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Carpenter::BuildingBlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BuildingBlockSpec_new00_local
    1236  static int tolua_EmberOgre_Carpenter_BuildingBlockSpec_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::BuildingBlockSpec",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Carpenter::BuildingBlockSpec* tolua_ret = (  Carpenter::BuildingBlockSpec* ) new Carpenter::BuildingBlockSpec(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Carpenter::BuildingBlockSpec" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDefinition of class Carpenter::BuildingBlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BuildingBlockSpec_getDefinition00
    1264  static int tolua_EmberOgre_Carpenter_BuildingBlockSpec_getDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::BuildingBlockSpec",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::BuildingBlockSpec* self = (  const Carpenter::BuildingBlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDefinition'",  NULL );
          #endif
           {
           const Carpenter::BuildingBlockSpecDefinition& tolua_ret = (  const Carpenter::BuildingBlockSpecDefinition& ) self->getDefinition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Carpenter::BuildingBlockSpecDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBlockSpec of class Carpenter::BuildingBlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BuildingBlockSpec_getBlockSpec00
    1296  static int tolua_EmberOgre_Carpenter_BuildingBlockSpec_getBlockSpec00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::BuildingBlockSpec",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::BuildingBlockSpec* self = (  const Carpenter::BuildingBlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBlockSpec'",  NULL );
          #endif
           {
           const Carpenter::BlockSpec* tolua_ret = (  const Carpenter::BlockSpec* ) self->getBlockSpec(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const Carpenter::BlockSpec" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBlockSpec'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class Carpenter::BuildingBlockSpec */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BuildingBlockSpec_getName00
    1328  static int tolua_EmberOgre_Carpenter_BuildingBlockSpec_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::BuildingBlockSpec",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::BuildingBlockSpec* self = (  const Carpenter::BuildingBlockSpec* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Carpenter::BuildingBlockSpecDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BuildingBlockSpecDefinition_new00
    1360  static int tolua_EmberOgre_Carpenter_BuildingBlockSpecDefinition_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::BuildingBlockSpecDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Carpenter::BuildingBlockSpecDefinition* tolua_ret = (  Carpenter::BuildingBlockSpecDefinition* ) new Carpenter::BuildingBlockSpecDefinition(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::BuildingBlockSpecDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Carpenter::BuildingBlockSpecDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_BuildingBlockSpecDefinition_new00_local
    1388  static int tolua_EmberOgre_Carpenter_BuildingBlockSpecDefinition_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::BuildingBlockSpecDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Carpenter::BuildingBlockSpecDefinition* tolua_ret = (  Carpenter::BuildingBlockSpecDefinition* ) new Carpenter::BuildingBlockSpecDefinition(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Carpenter::BuildingBlockSpecDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: mName of class Carpenter::BuildingBlockSpecDefinition */
          #ifndef TOLUA_DISABLE_tolua_get_Carpenter__BuildingBlockSpecDefinition_mName
    1416  static int tolua_get_Carpenter__BuildingBlockSpecDefinition_mName(  lua_State* tolua_S )
          {
           Carpenter::BuildingBlockSpecDefinition* self = (  Carpenter::BuildingBlockSpecDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'mName'",  NULL );
          #endif
           tolua_pushcppstring(  tolua_S,  (  const char* )self->mName );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: mName of class Carpenter::BuildingBlockSpecDefinition */
          #ifndef TOLUA_DISABLE_tolua_set_Carpenter__BuildingBlockSpecDefinition_mName
    1429  static int tolua_set_Carpenter__BuildingBlockSpecDefinition_mName(  lua_State* tolua_S )
          {
           Carpenter::BuildingBlockSpecDefinition* self = (  Carpenter::BuildingBlockSpecDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'mName'",  NULL );
           if (  !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->mName = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: mBlockSpecName of class Carpenter::BuildingBlockSpecDefinition */
          #ifndef TOLUA_DISABLE_tolua_get_Carpenter__BuildingBlockSpecDefinition_mBlockSpecName
    1446  static int tolua_get_Carpenter__BuildingBlockSpecDefinition_mBlockSpecName(  lua_State* tolua_S )
          {
           Carpenter::BuildingBlockSpecDefinition* self = (  Carpenter::BuildingBlockSpecDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'mBlockSpecName'",  NULL );
          #endif
           tolua_pushcppstring(  tolua_S,  (  const char* )self->mBlockSpecName );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: mBlockSpecName of class Carpenter::BuildingBlockSpecDefinition */
          #ifndef TOLUA_DISABLE_tolua_set_Carpenter__BuildingBlockSpecDefinition_mBlockSpecName
    1459  static int tolua_set_Carpenter__BuildingBlockSpecDefinition_mBlockSpecName(  lua_State* tolua_S )
          {
           Carpenter::BuildingBlockSpecDefinition* self = (  Carpenter::BuildingBlockSpecDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'mBlockSpecName'",  NULL );
           if (  !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->mBlockSpecName = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_new00
    1476  static int tolua_EmberOgre_Carpenter_Carpenter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Carpenter::Carpenter* tolua_ret = (  Carpenter::Carpenter* ) new Carpenter::Carpenter(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::Carpenter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_new00_local
    1504  static int tolua_EmberOgre_Carpenter_Carpenter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Carpenter::Carpenter* tolua_ret = (  Carpenter::Carpenter* ) new Carpenter::Carpenter(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Carpenter::Carpenter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_delete00
    1532  static int tolua_EmberOgre_Carpenter_Carpenter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::Carpenter* self = (  Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createBlueprint of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_createBlueprint00
    1561  static int tolua_EmberOgre_Carpenter_Carpenter_createBlueprint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::Carpenter* self = (  Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  1,  0 );
           std::string name = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createBlueprint'",  NULL );
          #endif
           {
           Carpenter::BluePrint* tolua_ret = (  Carpenter::BluePrint* ) self->createBlueprint(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::BluePrint" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createBlueprint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBuildingBlockSpec of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_getBuildingBlockSpec00
    1595  static int tolua_EmberOgre_Carpenter_Carpenter_getBuildingBlockSpec00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::Carpenter* self = (  Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBuildingBlockSpec'",  NULL );
          #endif
           {
           Carpenter::BuildingBlockSpec* tolua_ret = (  Carpenter::BuildingBlockSpec* ) self->getBuildingBlockSpec(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::BuildingBlockSpec" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBuildingBlockSpec'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createBlockSpec of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_createBlockSpec00
    1630  static int tolua_EmberOgre_Carpenter_Carpenter_createBlockSpec00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::Carpenter* self = (  Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  1,  0 );
           std::string name = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createBlockSpec'",  NULL );
          #endif
           {
           Carpenter::BlockSpec* tolua_ret = (  Carpenter::BlockSpec* ) self->createBlockSpec(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::BlockSpec" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createBlockSpec'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createBuildingBlockSpec of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_createBuildingBlockSpec00
    1664  static int tolua_EmberOgre_Carpenter_Carpenter_createBuildingBlockSpec00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Carpenter::BuildingBlockSpecDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::Carpenter* self = (  Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  1,  0 );
           Carpenter::BuildingBlockSpecDefinition definition = *(  (  Carpenter::BuildingBlockSpecDefinition* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createBuildingBlockSpec'",  NULL );
          #endif
           {
           Carpenter::BuildingBlockSpec* tolua_ret = (  Carpenter::BuildingBlockSpec* ) self->createBuildingBlockSpec(  definition );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::BuildingBlockSpec" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createBuildingBlockSpec'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBlockSpecs of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_getBlockSpecs00
    1698  static int tolua_EmberOgre_Carpenter_Carpenter_getBlockSpecs00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::Carpenter* self = (  const Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBlockSpecs'",  NULL );
          #endif
           {
           const std::map<const std::string,  Carpenter::BlockSpec>* tolua_ret = (  const std::map<const std::string,  Carpenter::BlockSpec>* ) self->getBlockSpecs(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const std::map<const std::string,  Carpenter::BlockSpec>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBlockSpecs'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBuildingBlockSpecs of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_getBuildingBlockSpecs00
    1730  static int tolua_EmberOgre_Carpenter_Carpenter_getBuildingBlockSpecs00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::Carpenter* self = (  const Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBuildingBlockSpecs'",  NULL );
          #endif
           {
           const std::map<const std::string,  Carpenter::BuildingBlockSpec>* tolua_ret = (  const std::map<const std::string,  Carpenter::BuildingBlockSpec>* ) self->getBuildingBlockSpecs(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const std::map<const std::string,  Carpenter::BuildingBlockSpec>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBuildingBlockSpecs'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBluePrints of class Carpenter::Carpenter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_Carpenter_Carpenter_getBluePrints00
    1762  static int tolua_EmberOgre_Carpenter_Carpenter_getBluePrints00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Carpenter::Carpenter* self = (  const Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBluePrints'",  NULL );
          #endif
           {
           const std::map<const std::string,  Carpenter::BluePrint>* tolua_ret = (  const std::map<const std::string,  Carpenter::BluePrint>* ) self->getBluePrints(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const std::map<const std::string,  Carpenter::BluePrint>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBluePrints'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: pitch of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_pitch00
    1794  static int tolua_EmberOgre_EmberOgre_AvatarCamera_pitch00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Degree degrees = *(  (  Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'pitch'",  NULL );
          #endif
           {
           self->pitch(  degrees );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'pitch'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: yaw of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_yaw00
    1827  static int tolua_EmberOgre_EmberOgre_AvatarCamera_yaw00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Degree degrees = *(  (  Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'yaw'",  NULL );
          #endif
           {
           self->yaw(  degrees );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'yaw'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPitch of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_getPitch00
    1860  static int tolua_EmberOgre_EmberOgre_AvatarCamera_getPitch00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::AvatarCamera* self = (  const EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPitch'",  NULL );
          #endif
           {
           const Ogre::Degree& tolua_ret = (  const Ogre::Degree& ) self->getPitch(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Degree" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPitch'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getYaw of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_getYaw00
    1892  static int tolua_EmberOgre_EmberOgre_AvatarCamera_getYaw00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::AvatarCamera* self = (  const EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getYaw'",  NULL );
          #endif
           {
           const Ogre::Degree& tolua_ret = (  const Ogre::Degree& ) self->getYaw(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Degree" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getYaw'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCamera of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_getCamera00
    1924  static int tolua_EmberOgre_EmberOgre_AvatarCamera_getCamera00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCamera'",  NULL );
          #endif
           {
           Ogre::Camera* tolua_ret = (  Ogre::Camera* ) self->getCamera(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Camera" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCamera'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCamera of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_getCamera01
    1956  static int tolua_EmberOgre_EmberOgre_AvatarCamera_getCamera01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const EmberOgre::AvatarCamera* self = (  const EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCamera'",  NULL );
          #endif
           {
           Ogre::Camera* tolua_ret = (  Ogre::Camera* ) self->getCamera(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Camera" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_AvatarCamera_getCamera00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getOrientation of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_getOrientation00
    1983  static int tolua_EmberOgre_EmberOgre_AvatarCamera_getOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::AvatarCamera* self = (  const EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool onlyHorizontal = (  (  bool ) tolua_toboolean(  tolua_S,  2,  true ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getOrientation'",  NULL );
          #endif
           {
           const Ogre::Quaternion& tolua_ret = (  const Ogre::Quaternion& ) self->getOrientation(  onlyHorizontal );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPosition of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_getPosition00
    2017  static int tolua_EmberOgre_EmberOgre_AvatarCamera_getPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::AvatarCamera* self = (  const EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPosition'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getPosition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMode of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_setMode00
    2049  static int tolua_EmberOgre_EmberOgre_AvatarCamera_setMode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::AvatarCamera::Mode mode = (  (  EmberOgre::AvatarCamera::Mode ) (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMode'",  NULL );
          #endif
           {
           self->setMode(  mode );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAvatarNode of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_setAvatarNode00
    2082  static int tolua_EmberOgre_EmberOgre_AvatarCamera_setAvatarNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::SceneNode* sceneNode = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAvatarNode'",  NULL );
          #endif
           {
           self->setAvatarNode(  sceneNode );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAvatarNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: MovedCamera of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarCamera_MovedCamera
    2115  static int tolua_get_EmberOgre__AvatarCamera_MovedCamera(  lua_State* tolua_S )
          {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'MovedCamera'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->MovedCamera,  "sigc::signal<void,  Ogre::Camera*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: MovedCamera of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarCamera_MovedCamera
    2128  static int tolua_set_EmberOgre__AvatarCamera_MovedCamera(  lua_State* tolua_S )
          {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'MovedCamera'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Ogre::Camera*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->MovedCamera = *(  (  sigc::signal<void,  Ogre::Camera*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventChangedCameraDistance of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarCamera_EventChangedCameraDistance
    2145  static int tolua_get_EmberOgre__AvatarCamera_EventChangedCameraDistance(  lua_State* tolua_S )
          {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventChangedCameraDistance'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventChangedCameraDistance,  "sigc::signal<void,  float>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventChangedCameraDistance of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarCamera_EventChangedCameraDistance
    2158  static int tolua_set_EmberOgre__AvatarCamera_EventChangedCameraDistance(  lua_State* tolua_S )
          {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventChangedCameraDistance'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  float>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventChangedCameraDistance = *(  (  sigc::signal<void,  float>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: pickInWorld of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_pickInWorld00
    2175  static int tolua_EmberOgre_EmberOgre_AvatarCamera_pickInWorld00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const EmberOgre::MousePickerArgs",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           float mouseX = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float mouseY = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           const EmberOgre::MousePickerArgs* args = (  (  const EmberOgre::MousePickerArgs* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'pickInWorld'",  NULL );
          #endif
           {
           self->pickInWorld(  mouseX,  mouseY,  *args );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'pickInWorld'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: worldToScreen of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_worldToScreen00
    2212  static int tolua_EmberOgre_EmberOgre_AvatarCamera_worldToScreen00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* worldPos = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Vector3* screenPos = (  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'worldToScreen'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->worldToScreen(  *worldPos,  *screenPos );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'worldToScreen'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: attach of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_attach00
    2248  static int tolua_EmberOgre_EmberOgre_AvatarCamera_attach00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::SceneNode* toNode = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'attach'",  NULL );
          #endif
           {
           self->attach(  toNode );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'attach'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setCameraDistance of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_setCameraDistance00
    2281  static int tolua_EmberOgre_EmberOgre_AvatarCamera_setCameraDistance00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           float distance = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setCameraDistance'",  NULL );
          #endif
           {
           self->setCameraDistance(  distance );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setCameraDistance'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: enableCompositor of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_enableCompositor00
    2314  static int tolua_EmberOgre_EmberOgre_AvatarCamera_enableCompositor00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string compositorName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           bool enable = (  (  bool ) tolua_toboolean(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'enableCompositor'",  NULL );
          #endif
           {
           self->enableCompositor(  compositorName,  enable );
           tolua_pushcppstring(  tolua_S,  (  const char* )compositorName );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'enableCompositor'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: toggleRenderMode of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_toggleRenderMode00
    2350  static int tolua_EmberOgre_EmberOgre_AvatarCamera_toggleRenderMode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'toggleRenderMode'",  NULL );
          #endif
           {
           self->toggleRenderMode(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'toggleRenderMode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: takeScreenshot of class EmberOgre::AvatarCamera */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarCamera_takeScreenshot00
    2381  static int tolua_EmberOgre_EmberOgre_AvatarCamera_takeScreenshot00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarCamera",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarCamera* self = (  EmberOgre::AvatarCamera* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'takeScreenshot'",  NULL );
          #endif
           {
           self->takeScreenshot(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'takeScreenshot'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarControllerMovement_new00
    2412  static int tolua_EmberOgre_EmberOgre_AvatarControllerMovement_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::AvatarControllerMovement",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::AvatarControllerMovement* tolua_ret = (  EmberOgre::AvatarControllerMovement* ) new EmberOgre::AvatarControllerMovement(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::AvatarControllerMovement" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarControllerMovement_new00_local
    2440  static int tolua_EmberOgre_EmberOgre_AvatarControllerMovement_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::AvatarControllerMovement",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::AvatarControllerMovement* tolua_ret = (  EmberOgre::AvatarControllerMovement* ) new EmberOgre::AvatarControllerMovement(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::AvatarControllerMovement" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: rotationDegHoriz of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarControllerMovement_rotationDegHoriz
    2468  static int tolua_get_EmberOgre__AvatarControllerMovement_rotationDegHoriz(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'rotationDegHoriz'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->rotationDegHoriz );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: rotationDegHoriz of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarControllerMovement_rotationDegHoriz
    2481  static int tolua_set_EmberOgre__AvatarControllerMovement_rotationDegHoriz(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'rotationDegHoriz'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->rotationDegHoriz = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: rotationDegVert of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarControllerMovement_rotationDegVert
    2498  static int tolua_get_EmberOgre__AvatarControllerMovement_rotationDegVert(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'rotationDegVert'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->rotationDegVert );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: rotationDegVert of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarControllerMovement_rotationDegVert
    2511  static int tolua_set_EmberOgre__AvatarControllerMovement_rotationDegVert(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'rotationDegVert'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->rotationDegVert = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: timeSlice of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarControllerMovement_timeSlice
    2528  static int tolua_get_EmberOgre__AvatarControllerMovement_timeSlice(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'timeSlice'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->timeSlice,  "Ogre::Real" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: timeSlice of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarControllerMovement_timeSlice
    2541  static int tolua_set_EmberOgre__AvatarControllerMovement_timeSlice(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'timeSlice'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Real",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->timeSlice = *(  (  Ogre::Real* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: movementDirection of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarControllerMovement_movementDirection
    2558  static int tolua_get_EmberOgre__AvatarControllerMovement_movementDirection(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'movementDirection'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->movementDirection,  "Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: movementDirection of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarControllerMovement_movementDirection
    2571  static int tolua_set_EmberOgre__AvatarControllerMovement_movementDirection(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'movementDirection'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Vector3",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->movementDirection = *(  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: mode of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarControllerMovement_mode
    2588  static int tolua_get_EmberOgre__AvatarControllerMovement_mode(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'mode'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->mode );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: mode of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarControllerMovement_mode
    2601  static int tolua_set_EmberOgre__AvatarControllerMovement_mode(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'mode'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->mode = (  (  EmberOgre::AvatarMovementMode::Mode ) (  int ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: isMoving of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarControllerMovement_isMoving
    2618  static int tolua_get_EmberOgre__AvatarControllerMovement_isMoving(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'isMoving'",  NULL );
          #endif
           tolua_pushboolean(  tolua_S,  (  bool )self->isMoving );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: isMoving of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarControllerMovement_isMoving
    2631  static int tolua_set_EmberOgre__AvatarControllerMovement_isMoving(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'isMoving'",  NULL );
           if (  !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->isMoving = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: cameraOrientation of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarControllerMovement_cameraOrientation
    2648  static int tolua_get_EmberOgre__AvatarControllerMovement_cameraOrientation(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'cameraOrientation'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->cameraOrientation,  "Ogre::Quaternion" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: cameraOrientation of class EmberOgre::AvatarControllerMovement */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarControllerMovement_cameraOrientation
    2661  static int tolua_set_EmberOgre__AvatarControllerMovement_cameraOrientation(  lua_State* tolua_S )
          {
           EmberOgre::AvatarControllerMovement* self = (  EmberOgre::AvatarControllerMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'cameraOrientation'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Quaternion",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->cameraOrientation = *(  (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventMovementModeChanged of class EmberOgre::AvatarController */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarController_EventMovementModeChanged
    2678  static int tolua_get_EmberOgre__AvatarController_EventMovementModeChanged(  lua_State* tolua_S )
          {
           EmberOgre::AvatarController* self = (  EmberOgre::AvatarController* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMovementModeChanged'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventMovementModeChanged,  "sigc::signal<void,  EmberOgre::AvatarMovementMode::Mode>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventMovementModeChanged of class EmberOgre::AvatarController */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarController_EventMovementModeChanged
    2691  static int tolua_set_EmberOgre__AvatarController_EventMovementModeChanged(  lua_State* tolua_S )
          {
           EmberOgre::AvatarController* self = (  EmberOgre::AvatarController* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMovementModeChanged'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::AvatarMovementMode::Mode>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventMovementModeChanged = *(  (  sigc::signal<void,  EmberOgre::AvatarMovementMode::Mode>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAvatarCamera of class EmberOgre::AvatarController */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarController_getAvatarCamera00
    2708  static int tolua_EmberOgre_EmberOgre_AvatarController_getAvatarCamera00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::AvatarController",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::AvatarController* self = (  const EmberOgre::AvatarController* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAvatarCamera'",  NULL );
          #endif
           {
           EmberOgre::AvatarCamera* tolua_ret = (  EmberOgre::AvatarCamera* ) self->getAvatarCamera(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::AvatarCamera" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAvatarCamera'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: detachCamera of class EmberOgre::AvatarController */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarController_detachCamera00
    2740  static int tolua_EmberOgre_EmberOgre_AvatarController_detachCamera00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarController",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarController* self = (  EmberOgre::AvatarController* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'detachCamera'",  NULL );
          #endif
           {
           self->detachCamera(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'detachCamera'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: attachCamera of class EmberOgre::AvatarController */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarController_attachCamera00
    2771  static int tolua_EmberOgre_EmberOgre_AvatarController_attachCamera00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarController",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarController* self = (  EmberOgre::AvatarController* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'attachCamera'",  NULL );
          #endif
           {
           self->attachCamera(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'attachCamera'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCurrentMovement of class EmberOgre::AvatarController */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarController_getCurrentMovement00
    2802  static int tolua_EmberOgre_EmberOgre_AvatarController_getCurrentMovement00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::AvatarController",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::AvatarController* self = (  const EmberOgre::AvatarController* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCurrentMovement'",  NULL );
          #endif
           {
           const EmberOgre::AvatarControllerMovement& tolua_ret = (  const EmberOgre::AvatarControllerMovement& ) self->getCurrentMovement(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const EmberOgre::AvatarControllerMovement" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCurrentMovement'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: moveToPoint of class EmberOgre::AvatarController */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarController_moveToPoint00
    2834  static int tolua_EmberOgre_EmberOgre_AvatarController_moveToPoint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarController",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarController* self = (  EmberOgre::AvatarController* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* point = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'moveToPoint'",  NULL );
          #endif
           {
           self->moveToPoint(  *point );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'moveToPoint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: teleportTo of class EmberOgre::AvatarController */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarController_teleportTo00
    2867  static int tolua_EmberOgre_EmberOgre_AvatarController_teleportTo00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarController",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarController* self = (  EmberOgre::AvatarController* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* point = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           EmberOgre::EmberEntity* locationEntity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'teleportTo'",  NULL );
          #endif
           {
           self->teleportTo(  *point,  locationEntity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'teleportTo'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: isMoving of class EmberOgre::AvatarMovementState */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarMovementState_isMoving
    2902  static int tolua_get_EmberOgre__AvatarMovementState_isMoving(  lua_State* tolua_S )
          {
           EmberOgre::AvatarMovementState* self = (  EmberOgre::AvatarMovementState* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'isMoving'",  NULL );
          #endif
           tolua_pushboolean(  tolua_S,  (  bool )self->isMoving );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: isMoving of class EmberOgre::AvatarMovementState */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarMovementState_isMoving
    2915  static int tolua_set_EmberOgre__AvatarMovementState_isMoving(  lua_State* tolua_S )
          {
           EmberOgre::AvatarMovementState* self = (  EmberOgre::AvatarMovementState* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'isMoving'",  NULL );
           if (  !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->isMoving = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: isRunning of class EmberOgre::AvatarMovementState */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarMovementState_isRunning
    2932  static int tolua_get_EmberOgre__AvatarMovementState_isRunning(  lua_State* tolua_S )
          {
           EmberOgre::AvatarMovementState* self = (  EmberOgre::AvatarMovementState* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'isRunning'",  NULL );
          #endif
           tolua_pushboolean(  tolua_S,  (  bool )self->isRunning );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: isRunning of class EmberOgre::AvatarMovementState */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarMovementState_isRunning
    2945  static int tolua_set_EmberOgre__AvatarMovementState_isRunning(  lua_State* tolua_S )
          {
           EmberOgre::AvatarMovementState* self = (  EmberOgre::AvatarMovementState* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'isRunning'",  NULL );
           if (  !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->isRunning = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: velocity of class EmberOgre::AvatarMovementState */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarMovementState_velocity
    2962  static int tolua_get_EmberOgre__AvatarMovementState_velocity(  lua_State* tolua_S )
          {
           EmberOgre::AvatarMovementState* self = (  EmberOgre::AvatarMovementState* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'velocity'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->velocity,  "Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: velocity of class EmberOgre::AvatarMovementState */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarMovementState_velocity
    2975  static int tolua_set_EmberOgre__AvatarMovementState_velocity(  lua_State* tolua_S )
          {
           EmberOgre::AvatarMovementState* self = (  EmberOgre::AvatarMovementState* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'velocity'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Vector3",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->velocity = *(  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: orientation of class EmberOgre::AvatarMovementState */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AvatarMovementState_orientation
    2992  static int tolua_get_EmberOgre__AvatarMovementState_orientation(  lua_State* tolua_S )
          {
           EmberOgre::AvatarMovementState* self = (  EmberOgre::AvatarMovementState* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'orientation'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->orientation,  "Ogre::Quaternion" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: orientation of class EmberOgre::AvatarMovementState */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AvatarMovementState_orientation
    3005  static int tolua_set_EmberOgre__AvatarMovementState_orientation(  lua_State* tolua_S )
          {
           EmberOgre::AvatarMovementState* self = (  EmberOgre::AvatarMovementState* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'orientation'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Quaternion",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->orientation = *(  (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAvatarCamera of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Avatar_getAvatarCamera00
    3022  static int tolua_EmberOgre_EmberOgre_Avatar_getAvatarCamera00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Avatar",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Avatar* self = (  const EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAvatarCamera'",  NULL );
          #endif
           {
           EmberOgre::AvatarCamera* tolua_ret = (  EmberOgre::AvatarCamera* ) self->getAvatarCamera(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::AvatarCamera" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAvatarCamera'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAvatarSceneNode of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Avatar_getAvatarSceneNode00
    3054  static int tolua_EmberOgre_EmberOgre_Avatar_getAvatarSceneNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Avatar",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Avatar* self = (  const EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAvatarSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->getAvatarSceneNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAvatarSceneNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAvatarController of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Avatar_setAvatarController00
    3086  static int tolua_EmberOgre_EmberOgre_Avatar_setAvatarController00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Avatar",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::AvatarController",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Avatar* self = (  EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::AvatarController* avatarController = (  (  EmberOgre::AvatarController* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAvatarController'",  NULL );
          #endif
           {
           self->setAvatarController(  avatarController );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAvatarController'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAvatarEmberEntity of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Avatar_getAvatarEmberEntity00
    3119  static int tolua_EmberOgre_EmberOgre_Avatar_getAvatarEmberEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Avatar",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Avatar* self = (  EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAvatarEmberEntity'",  NULL );
          #endif
           {
           EmberOgre::AvatarEmberEntity* tolua_ret = (  EmberOgre::AvatarEmberEntity* ) self->getAvatarEmberEntity(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::AvatarEmberEntity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAvatarEmberEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMinIntervalOfRotationChanges of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Avatar_setMinIntervalOfRotationChanges00
    3151  static int tolua_EmberOgre_EmberOgre_Avatar_setMinIntervalOfRotationChanges00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Avatar",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Real",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Avatar* self = (  EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Real milliseconds = *(  (  Ogre::Real* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMinIntervalOfRotationChanges'",  NULL );
          #endif
           {
           self->setMinIntervalOfRotationChanges(  milliseconds );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMinIntervalOfRotationChanges'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventAddedEntityToInventory of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Avatar_EventAddedEntityToInventory
    3184  static int tolua_get_EmberOgre__Avatar_EventAddedEntityToInventory(  lua_State* tolua_S )
          {
           EmberOgre::Avatar* self = (  EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventAddedEntityToInventory'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventAddedEntityToInventory,  "sigc::signal<void,  EmberOgre::EmberEntity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventAddedEntityToInventory of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Avatar_EventAddedEntityToInventory
    3197  static int tolua_set_EmberOgre__Avatar_EventAddedEntityToInventory(  lua_State* tolua_S )
          {
           EmberOgre::Avatar* self = (  EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventAddedEntityToInventory'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventAddedEntityToInventory = *(  (  sigc::signal<void,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventRemovedEntityFromInventory of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Avatar_EventRemovedEntityFromInventory
    3214  static int tolua_get_EmberOgre__Avatar_EventRemovedEntityFromInventory(  lua_State* tolua_S )
          {
           EmberOgre::Avatar* self = (  EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventRemovedEntityFromInventory'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventRemovedEntityFromInventory,  "sigc::signal<void,  EmberOgre::EmberEntity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventRemovedEntityFromInventory of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Avatar_EventRemovedEntityFromInventory
    3227  static int tolua_set_EmberOgre__Avatar_EventRemovedEntityFromInventory(  lua_State* tolua_S )
          {
           EmberOgre::Avatar* self = (  EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventRemovedEntityFromInventory'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventRemovedEntityFromInventory = *(  (  sigc::signal<void,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isAdmin of class EmberOgre::Avatar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Avatar_isAdmin00
    3244  static int tolua_EmberOgre_EmberOgre_Avatar_isAdmin00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Avatar",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Avatar* self = (  const EmberOgre::Avatar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isAdmin'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isAdmin(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isAdmin'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWorld of class EmberOgre::EmberEntityFactory */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntityFactory_getWorld00
    3276  static int tolua_EmberOgre_EmberOgre_EmberEntityFactory_getWorld00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntityFactory",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntityFactory* self = (  const EmberOgre::EmberEntityFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWorld'",  NULL );
          #endif
           {
           EmberOgre::WorldEmberEntity* tolua_ret = (  EmberOgre::WorldEmberEntity* ) self->getWorld(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::WorldEmberEntity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWorld'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: dumpAttributesOfEntity of class EmberOgre::EmberEntityFactory */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntityFactory_dumpAttributesOfEntity00
    3308  static int tolua_EmberOgre_EmberOgre_EmberEntityFactory_dumpAttributesOfEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntityFactory",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntityFactory* self = (  const EmberOgre::EmberEntityFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string entityId = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'dumpAttributesOfEntity'",  NULL );
          #endif
           {
           self->dumpAttributesOfEntity(  entityId );
           tolua_pushcppstring(  tolua_S,  (  const char* )entityId );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'dumpAttributesOfEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSceneNode of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_getSceneNode00
    3342  static int tolua_EmberOgre_EmberOgre_EmberEntity_getSceneNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->getSceneNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSceneNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasSuggestedResponses of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_hasSuggestedResponses00
    3374  static int tolua_EmberOgre_EmberOgre_EmberEntity_hasSuggestedResponses00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasSuggestedResponses'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasSuggestedResponses(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasSuggestedResponses'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSuggestedResponses of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_getSuggestedResponses00
    3406  static int tolua_EmberOgre_EmberOgre_EmberEntity_getSuggestedResponses00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSuggestedResponses'",  NULL );
          #endif
           {
           const std::vector<std::string>& tolua_ret = (  const std::vector<std::string>& ) self->getSuggestedResponses(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const std::vector<std::string>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSuggestedResponses'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setVisible of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_setVisible00
    3438  static int tolua_EmberOgre_EmberOgre_EmberEntity_setVisible00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberEntity* self = (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool visible = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setVisible'",  NULL );
          #endif
           {
           self->setVisible(  visible );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setVisible'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEmberLocation of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_getEmberLocation00
    3471  static int tolua_EmberOgre_EmberOgre_EmberEntity_getEmberLocation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEmberLocation'",  NULL );
          #endif
           {
           EmberOgre::EmberEntity* tolua_ret = (  EmberOgre::EmberEntity* ) self->getEmberLocation(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::EmberEntity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEmberLocation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isInitialized of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_isInitialized00
    3503  static int tolua_EmberOgre_EmberOgre_EmberEntity_isInitialized00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isInitialized'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isInitialized(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isInitialized'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMovementMode of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_getMovementMode00
    3535  static int tolua_EmberOgre_EmberOgre_EmberEntity_getMovementMode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMovementMode'",  NULL );
          #endif
           {
           EmberOgre::EmberEntity::MovementMode tolua_ret = (  EmberOgre::EmberEntity::MovementMode ) self->getMovementMode(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMovementMode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showOgreBoundingBox of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_showOgreBoundingBox00
    3567  static int tolua_EmberOgre_EmberOgre_EmberEntity_showOgreBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberEntity* self = (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool show = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showOgreBoundingBox'",  NULL );
          #endif
           {
           self->showOgreBoundingBox(  show );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showOgreBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showErisBoundingBox of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_showErisBoundingBox00
    3600  static int tolua_EmberOgre_EmberOgre_EmberEntity_showErisBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberEntity* self = (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool show = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showErisBoundingBox'",  NULL );
          #endif
           {
           self->showErisBoundingBox(  show );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showErisBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getShowOgreBoundingBox of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_getShowOgreBoundingBox00
    3633  static int tolua_EmberOgre_EmberOgre_EmberEntity_getShowOgreBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getShowOgreBoundingBox'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getShowOgreBoundingBox(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getShowOgreBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getShowErisBoundingBox of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_getShowErisBoundingBox00
    3665  static int tolua_EmberOgre_EmberOgre_EmberEntity_getShowErisBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getShowErisBoundingBox'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getShowErisBoundingBox(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getShowErisBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWorldBoundingBox of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_getWorldBoundingBox00
    3697  static int tolua_EmberOgre_EmberOgre_EmberEntity_getWorldBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool derive = (  (  bool ) tolua_toboolean(  tolua_S,  2,  true ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWorldBoundingBox'",  NULL );
          #endif
           {
           const Ogre::AxisAlignedBox& tolua_ret = (  const Ogre::AxisAlignedBox& ) self->getWorldBoundingBox(  derive );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWorldBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDefaultUseOperators of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_getDefaultUseOperators00
    3731  static int tolua_EmberOgre_EmberOgre_EmberEntity_getDefaultUseOperators00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberEntity* self = (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDefaultUseOperators'",  NULL );
          #endif
           {
           std::vector<std::string> tolua_ret = (  std::vector<std::string> ) self->getDefaultUseOperators(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::vector<std::string>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<std::string>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::vector<std::string> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<std::string>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDefaultUseOperators'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setVisualize of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_setVisualize00
    3771  static int tolua_EmberOgre_EmberOgre_EmberEntity_setVisualize00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberEntity* self = (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string visualization = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           bool visualize = (  (  bool ) tolua_toboolean(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setVisualize'",  NULL );
          #endif
           {
           self->setVisualize(  visualization,  visualize );
           tolua_pushcppstring(  tolua_S,  (  const char* )visualization );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setVisualize'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getVisualize of class EmberOgre::EmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberEntity_getVisualize00
    3807  static int tolua_EmberOgre_EmberOgre_EmberEntity_getVisualize00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberEntity* self = (  const EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string visualization = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getVisualize'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getVisualize(  visualization );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )visualization );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getVisualize'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ACTION_STAND of class EmberOgre::EmberPhysicalEntity */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_STAND
    3842  static int tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_STAND(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&EmberOgre::EmberPhysicalEntity::ACTION_STAND,  "const const" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ACTION_RUN of class EmberOgre::EmberPhysicalEntity */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_RUN
    3851  static int tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_RUN(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&EmberOgre::EmberPhysicalEntity::ACTION_RUN,  "const const" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ACTION_WALK of class EmberOgre::EmberPhysicalEntity */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_WALK
    3860  static int tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_WALK(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&EmberOgre::EmberPhysicalEntity::ACTION_WALK,  "const const" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ACTION_SWIM of class EmberOgre::EmberPhysicalEntity */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_SWIM
    3869  static int tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_SWIM(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&EmberOgre::EmberPhysicalEntity::ACTION_SWIM,  "const const" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ACTION_FLOAT of class EmberOgre::EmberPhysicalEntity */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_FLOAT
    3878  static int tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_FLOAT(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&EmberOgre::EmberPhysicalEntity::ACTION_FLOAT,  "const const" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getModel of class EmberOgre::EmberPhysicalEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getModel00
    3887  static int tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getModel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberPhysicalEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberPhysicalEntity* self = (  const EmberOgre::EmberPhysicalEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getModel'",  NULL );
          #endif
           {
           EmberOgre::Model::Model* tolua_ret = (  EmberOgre::Model::Model* ) self->getModel(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::Model" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getModel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getScaleNode of class EmberOgre::EmberPhysicalEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getScaleNode00
    3919  static int tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getScaleNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberPhysicalEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberPhysicalEntity* self = (  const EmberOgre::EmberPhysicalEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getScaleNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->getScaleNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getScaleNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntityAttachedToPoint of class EmberOgre::EmberPhysicalEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getEntityAttachedToPoint00
    3951  static int tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getEntityAttachedToPoint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EmberPhysicalEntity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberPhysicalEntity* self = (  EmberOgre::EmberPhysicalEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string attachPoint = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntityAttachedToPoint'",  NULL );
          #endif
           {
           EmberOgre::EmberEntity* tolua_ret = (  EmberOgre::EmberEntity* ) self->getEntityAttachedToPoint(  attachPoint );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::EmberEntity" );
           tolua_pushcppstring(  tolua_S,  (  const char* )attachPoint );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntityAttachedToPoint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWorldBoundingBox of class EmberOgre::EmberPhysicalEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getWorldBoundingBox00
    3986  static int tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getWorldBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberPhysicalEntity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberPhysicalEntity* self = (  const EmberOgre::EmberPhysicalEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool derive = (  (  bool ) tolua_toboolean(  tolua_S,  2,  true ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWorldBoundingBox'",  NULL );
          #endif
           {
           const Ogre::AxisAlignedBox& tolua_ret = (  const Ogre::AxisAlignedBox& ) self->getWorldBoundingBox(  derive );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWorldBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAvatar of class EmberOgre::AvatarEmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarEmberEntity_getAvatar00
    4020  static int tolua_EmberOgre_EmberOgre_AvatarEmberEntity_getAvatar00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarEmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarEmberEntity* self = (  EmberOgre::AvatarEmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAvatar'",  NULL );
          #endif
           {
           EmberOgre::Avatar* tolua_ret = (  EmberOgre::Avatar* ) self->getAvatar(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Avatar" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAvatar'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAvatarSceneNode of class EmberOgre::AvatarEmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AvatarEmberEntity_getAvatarSceneNode00
    4052  static int tolua_EmberOgre_EmberOgre_AvatarEmberEntity_getAvatarSceneNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AvatarEmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AvatarEmberEntity* self = (  EmberOgre::AvatarEmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAvatarSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->getAvatarSceneNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAvatarSceneNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEnvironment of class EmberOgre::WorldEmberEntity */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_WorldEmberEntity_getEnvironment00
    4084  static int tolua_EmberOgre_EmberOgre_WorldEmberEntity_getEnvironment00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::WorldEmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::WorldEmberEntity* self = (  EmberOgre::WorldEmberEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEnvironment'",  NULL );
          #endif
           {
           EmberOgre::Environment::Environment* tolua_ret = (  EmberOgre::Environment::Environment* ) self->getEnvironment(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Environment::Environment" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEnvironment'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAmbientLight of class EmberOgre::Environment::ISun */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_ISun_setAmbientLight00
    4116  static int tolua_EmberOgre_EmberOgre_Environment_ISun_setAmbientLight00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Environment::ISun",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Environment::ISun* self = (  EmberOgre::Environment::ISun* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::ColourValue* colour = (  (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAmbientLight'",  NULL );
          #endif
           {
           self->setAmbientLight(  *colour );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAmbientLight'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDensity of class EmberOgre::Environment::IFog */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_IFog_setDensity00
    4149  static int tolua_EmberOgre_EmberOgre_Environment_IFog_setDensity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Environment::IFog",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Environment::IFog* self = (  EmberOgre::Environment::IFog* ) tolua_tousertype(  tolua_S,  1,  0 );
           float density = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDensity'",  NULL );
          #endif
           {
           self->setDensity(  density );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setDensity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDensity of class EmberOgre::Environment::IFog */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_IFog_getDensity00
    4182  static int tolua_EmberOgre_EmberOgre_Environment_IFog_getDensity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Environment::IFog",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Environment::IFog* self = (  const EmberOgre::Environment::IFog* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDensity'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getDensity(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDensity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSun of class EmberOgre::Environment::Environment */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_Environment_getSun00
    4214  static int tolua_EmberOgre_EmberOgre_Environment_Environment_getSun00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Environment::Environment",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Environment::Environment* self = (  EmberOgre::Environment::Environment* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSun'",  NULL );
          #endif
           {
           EmberOgre::Environment::ISun* tolua_ret = (  EmberOgre::Environment::ISun* ) self->getSun(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Environment::ISun" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSun'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSky of class EmberOgre::Environment::Environment */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_Environment_getSky00
    4246  static int tolua_EmberOgre_EmberOgre_Environment_Environment_getSky00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Environment::Environment",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Environment::Environment* self = (  EmberOgre::Environment::Environment* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSky'",  NULL );
          #endif
           {
           EmberOgre::Environment::ISky* tolua_ret = (  EmberOgre::Environment::ISky* ) self->getSky(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Environment::ISky" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSky'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getFog of class EmberOgre::Environment::Environment */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_Environment_getFog00
    4278  static int tolua_EmberOgre_EmberOgre_Environment_Environment_getFog00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Environment::Environment",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Environment::Environment* self = (  EmberOgre::Environment::Environment* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getFog'",  NULL );
          #endif
           {
           EmberOgre::Environment::IFog* tolua_ret = (  EmberOgre::Environment::IFog* ) self->getFog(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Environment::IFog" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getFog'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWater of class EmberOgre::Environment::Environment */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_Environment_getWater00
    4310  static int tolua_EmberOgre_EmberOgre_Environment_Environment_getWater00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Environment::Environment",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Environment::Environment* self = (  EmberOgre::Environment::Environment* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWater'",  NULL );
          #endif
           {
           EmberOgre::Environment::IWater* tolua_ret = (  EmberOgre::Environment::IWater* ) self->getWater(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Environment::IWater" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWater'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setTime of class EmberOgre::Environment::Environment */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_Environment_setTime00
    4342  static int tolua_EmberOgre_EmberOgre_Environment_Environment_setTime00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Environment::Environment",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Environment::Environment* self = (  EmberOgre::Environment::Environment* ) tolua_tousertype(  tolua_S,  1,  0 );
           int hour = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           int minute = (  (  int ) tolua_tonumber(  tolua_S,  3,  0 ) );
           int second = (  (  int ) tolua_tonumber(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setTime'",  NULL );
          #endif
           {
           self->setTime(  hour,  minute,  second );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setTime'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setTime of class EmberOgre::Environment::Environment */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_Environment_setTime01
    4379  static int tolua_EmberOgre_EmberOgre_Environment_Environment_setTime01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Environment::Environment",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::Environment::Environment* self = (  EmberOgre::Environment::Environment* ) tolua_tousertype(  tolua_S,  1,  0 );
           int seconds = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setTime'",  NULL );
          #endif
           {
           self->setTime(  seconds );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Environment_Environment_setTime00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAmbientLight of class EmberOgre::Environment::Environment */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Environment_Environment_setAmbientLight00
    4407  static int tolua_EmberOgre_EmberOgre_Environment_Environment_setAmbientLight00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Environment::Environment",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Environment::Environment* self = (  EmberOgre::Environment::Environment* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::ColourValue* colour = (  (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAmbientLight'",  NULL );
          #endif
           {
           self->setAmbientLight(  *colour );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAmbientLight'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventUpdatedAmbientLight of class EmberOgre::Environment::Environment */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Environment__Environment_EventUpdatedAmbientLight
    4440  static int tolua_get_EmberOgre__Environment__Environment_EventUpdatedAmbientLight(  lua_State* tolua_S )
          {
           EmberOgre::Environment::Environment* self = (  EmberOgre::Environment::Environment* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventUpdatedAmbientLight'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventUpdatedAmbientLight,  "sigc::signal<void,  const Ogre::ColourValue&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventUpdatedAmbientLight of class EmberOgre::Environment::Environment */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Environment__Environment_EventUpdatedAmbientLight
    4453  static int tolua_set_EmberOgre__Environment__Environment_EventUpdatedAmbientLight(  lua_State* tolua_S )
          {
           EmberOgre::Environment::Environment* self = (  EmberOgre::Environment::Environment* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventUpdatedAmbientLight'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Ogre::ColourValue&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventUpdatedAmbientLight = *(  (  sigc::signal<void,  const Ogre::ColourValue&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_getSingleton00
    4470  static int tolua_EmberOgre_EmberOgre_GUIManager_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::GUIManager& tolua_ret = (  EmberOgre::GUIManager& ) EmberOgre::GUIManager::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::GUIManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: AppendIGChatLine of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__GUIManager_AppendIGChatLine
    4498  static int tolua_get_EmberOgre__GUIManager_AppendIGChatLine(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AppendIGChatLine'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->AppendIGChatLine,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: AppendIGChatLine of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__GUIManager_AppendIGChatLine
    4511  static int tolua_set_EmberOgre__GUIManager_AppendIGChatLine(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AppendIGChatLine'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->AppendIGChatLine = *(  (  sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: AppendOOGChatLine of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__GUIManager_AppendOOGChatLine
    4528  static int tolua_get_EmberOgre__GUIManager_AppendOOGChatLine(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AppendOOGChatLine'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->AppendOOGChatLine,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: AppendOOGChatLine of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__GUIManager_AppendOOGChatLine
    4541  static int tolua_set_EmberOgre__GUIManager_AppendOOGChatLine(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AppendOOGChatLine'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->AppendOOGChatLine = *(  (  sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: AppendAvatarImaginary of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__GUIManager_AppendAvatarImaginary
    4558  static int tolua_get_EmberOgre__GUIManager_AppendAvatarImaginary(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AppendAvatarImaginary'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->AppendAvatarImaginary,  "sigc::signal<void,  const std::string&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: AppendAvatarImaginary of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__GUIManager_AppendAvatarImaginary
    4571  static int tolua_set_EmberOgre__GUIManager_AppendAvatarImaginary(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AppendAvatarImaginary'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->AppendAvatarImaginary = *(  (  sigc::signal<void,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventEntityAction of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__GUIManager_EventEntityAction
    4588  static int tolua_get_EmberOgre__GUIManager_EventEntityAction(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventEntityAction'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventEntityAction,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventEntityAction of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__GUIManager_EventEntityAction
    4601  static int tolua_set_EmberOgre__GUIManager_EventEntityAction(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventEntityAction'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventEntityAction = *(  (  sigc::signal<void,  const std::string&,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventFrameStarted of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__GUIManager_EventFrameStarted
    4618  static int tolua_get_EmberOgre__GUIManager_EventFrameStarted(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventFrameStarted'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventFrameStarted,  "sigc::signal<void,  float>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventFrameStarted of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__GUIManager_EventFrameStarted
    4631  static int tolua_set_EmberOgre__GUIManager_EventFrameStarted(  lua_State* tolua_S )
          {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventFrameStarted'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  float>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventFrameStarted = *(  (  sigc::signal<void,  float>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeWidget of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_removeWidget00
    4648  static int tolua_EmberOgre_EmberOgre_GUIManager_removeWidget00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::Widget* widget = (  (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeWidget'",  NULL );
          #endif
           {
           self->removeWidget(  widget );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeWidget'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addWidget of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_addWidget00
    4681  static int tolua_EmberOgre_EmberOgre_GUIManager_addWidget00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::Widget* widget = (  (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addWidget'",  NULL );
          #endif
           {
           self->addWidget(  widget );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addWidget'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: EmitEntityAction of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_EmitEntityAction00
    4714  static int tolua_EmberOgre_EmberOgre_GUIManager_EmitEntityAction00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string action = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           EmberOgre::EmberEntity* entity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'EmitEntityAction'",  NULL );
          #endif
           {
           self->EmitEntityAction(  action,  entity );
           tolua_pushcppstring(  tolua_S,  (  const char* )action );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'EmitEntityAction'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMainSheet of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_getMainSheet00
    4750  static int tolua_EmberOgre_EmberOgre_GUIManager_getMainSheet00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMainSheet'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->getMainSheet(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMainSheet'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDebugText of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_setDebugText00
    4782  static int tolua_EmberOgre_EmberOgre_GUIManager_setDebugText00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string text = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDebugText'",  NULL );
          #endif
           {
           self->setDebugText(  text );
           tolua_pushcppstring(  tolua_S,  (  const char* )text );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setDebugText'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isInGUIMode of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_isInGUIMode00
    4816  static int tolua_EmberOgre_EmberOgre_GUIManager_isInGUIMode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::GUIManager* self = (  const EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isInGUIMode'",  NULL );
          #endif
           {
           const bool tolua_ret = (  const bool ) self->isInGUIMode(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isInGUIMode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isInMovementKeysMode of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_isInMovementKeysMode00
    4848  static int tolua_EmberOgre_EmberOgre_GUIManager_isInMovementKeysMode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::GUIManager* self = (  const EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isInMovementKeysMode'",  NULL );
          #endif
           {
           const bool tolua_ret = (  const bool ) self->isInMovementKeysMode(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isInMovementKeysMode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getInput of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_getInput00
    4880  static int tolua_EmberOgre_EmberOgre_GUIManager_getInput00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::GUIManager* self = (  const EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getInput'",  NULL );
          #endif
           {
           EmberOgre::Input& tolua_ret = (  EmberOgre::Input& ) self->getInput(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::Input" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInput'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createWindow of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_createWindow00
    4912  static int tolua_EmberOgre_EmberOgre_GUIManager_createWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string windowType = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createWindow'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->createWindow(  windowType );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           tolua_pushcppstring(  tolua_S,  (  const char* )windowType );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createWindow of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_createWindow01
    4947  static int tolua_EmberOgre_EmberOgre_GUIManager_createWindow01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string windowType = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string windowName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createWindow'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->createWindow(  windowType,  windowName );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           tolua_pushcppstring(  tolua_S,  (  const char* )windowType );
           tolua_pushcppstring(  tolua_S,  (  const char* )windowName );
           }
           }
           return 3;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_GUIManager_createWindow00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createWidget of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_createWidget00
    4980  static int tolua_EmberOgre_EmberOgre_GUIManager_createWidget00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createWidget'",  NULL );
          #endif
           {
           EmberOgre::Gui::Widget* tolua_ret = (  EmberOgre::Gui::Widget* ) self->createWidget(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Widget" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createWidget'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createWidget of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_createWidget01
    5012  static int tolua_EmberOgre_EmberOgre_GUIManager_createWidget01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createWidget'",  NULL );
          #endif
           {
           EmberOgre::Gui::Widget* tolua_ret = (  EmberOgre::Gui::Widget* ) self->createWidget(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Widget" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_GUIManager_createWidget00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDefaultScheme of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_getDefaultScheme00
    5042  static int tolua_EmberOgre_EmberOgre_GUIManager_getDefaultScheme00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::GUIManager* self = (  const EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDefaultScheme'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getDefaultScheme(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDefaultScheme'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntityPickListener of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_getEntityPickListener00
    5074  static int tolua_EmberOgre_EmberOgre_GUIManager_getEntityPickListener00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::GUIManager* self = (  const EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntityPickListener'",  NULL );
          #endif
           {
           EmberOgre::EntityWorldPickListener* tolua_ret = (  EmberOgre::EntityWorldPickListener* ) self->getEntityPickListener(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::EntityWorldPickListener" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntityPickListener'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getIconManager of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_getIconManager00
    5106  static int tolua_EmberOgre_EmberOgre_GUIManager_getIconManager00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getIconManager'",  NULL );
          #endif
           {
           EmberOgre::Gui::Icons::IconManager* tolua_ret = (  EmberOgre::Gui::Icons::IconManager* ) self->getIconManager(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Icons::IconManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getIconManager'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntityIconManager of class EmberOgre::GUIManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_GUIManager_getEntityIconManager00
    5138  static int tolua_EmberOgre_EmberOgre_GUIManager_getEntityIconManager00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::GUIManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::GUIManager* self = (  EmberOgre::GUIManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntityIconManager'",  NULL );
          #endif
           {
           EmberOgre::Gui::EntityIconManager* tolua_ret = (  EmberOgre::Gui::EntityIconManager* ) self->getEntityIconManager(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::EntityIconManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntityIconManager'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Terrain::TerrainArea */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_new00
    5170  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Terrain::TerrainArea",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberEntity* entity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Terrain::TerrainArea* tolua_ret = (  EmberOgre::Terrain::TerrainArea* ) new EmberOgre::Terrain::TerrainArea(  entity );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Terrain::TerrainArea" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Terrain::TerrainArea */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_new00_local
    5200  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Terrain::TerrainArea",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberEntity* entity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Terrain::TerrainArea* tolua_ret = (  EmberOgre::Terrain::TerrainArea* ) new EmberOgre::Terrain::TerrainArea(  entity );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Terrain::TerrainArea" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: init of class EmberOgre::Terrain::TerrainArea */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_init00
    5230  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_init00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainArea",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainArea* self = (  EmberOgre::Terrain::TerrainArea* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'init'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->init(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'init'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getArea of class EmberOgre::Terrain::TerrainArea */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_getArea00
    5262  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_getArea00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::TerrainArea",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::TerrainArea* self = (  const EmberOgre::Terrain::TerrainArea* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getArea'",  NULL );
          #endif
           {
           Mercator::Area* tolua_ret = (  Mercator::Area* ) self->getArea(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Mercator::Area" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getArea'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setArea of class EmberOgre::Terrain::TerrainArea */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_setArea00
    5294  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_setArea00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainArea",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Mercator::Area",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainArea* self = (  EmberOgre::Terrain::TerrainArea* ) tolua_tousertype(  tolua_S,  1,  0 );
           Mercator::Area* area = (  (  Mercator::Area* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setArea'",  NULL );
          #endif
           {
           self->setArea(  area );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setArea'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBasePoint of class EmberOgre::Terrain::BasePointUserObject */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getBasePoint00
    5327  static int tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getBasePoint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::BasePointUserObject",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::BasePointUserObject* self = (  const EmberOgre::Terrain::BasePointUserObject* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBasePoint'",  NULL );
          #endif
           {
           const Mercator::BasePoint& tolua_ret = (  const Mercator::BasePoint& ) self->getBasePoint(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Mercator::BasePoint" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBasePoint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBasePointMarkerNode of class EmberOgre::Terrain::BasePointUserObject */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getBasePointMarkerNode00
    5359  static int tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getBasePointMarkerNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::BasePointUserObject",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::BasePointUserObject* self = (  const EmberOgre::Terrain::BasePointUserObject* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBasePointMarkerNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->getBasePointMarkerNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBasePointMarkerNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPosition of class EmberOgre::Terrain::BasePointUserObject */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getPosition00
    5391  static int tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::BasePointUserObject",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::BasePointUserObject* self = (  const EmberOgre::Terrain::BasePointUserObject* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPosition'",  NULL );
          #endif
           {
           const EmberOgre::TerrainPosition& tolua_ret = (  const EmberOgre::TerrainPosition& ) self->getPosition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const EmberOgre::TerrainPosition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getHeight of class EmberOgre::Terrain::BasePointUserObject */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getHeight00
    5423  static int tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getHeight00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::BasePointUserObject",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::BasePointUserObject* self = (  const EmberOgre::Terrain::BasePointUserObject* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getHeight'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getHeight(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getHeight'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: translate of class EmberOgre::Terrain::BasePointUserObject */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_translate00
    5455  static int tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_translate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::BasePointUserObject",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::BasePointUserObject* self = (  EmberOgre::Terrain::BasePointUserObject* ) tolua_tousertype(  tolua_S,  1,  0 );
           float verticalMovement = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'translate'",  NULL );
          #endif
           {
           self->translate(  verticalMovement );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'translate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventUpdatedPosition of class EmberOgre::Terrain::BasePointUserObject */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Terrain__BasePointUserObject_EventUpdatedPosition
    5488  static int tolua_get_EmberOgre__Terrain__BasePointUserObject_EventUpdatedPosition(  lua_State* tolua_S )
          {
           EmberOgre::Terrain::BasePointUserObject* self = (  EmberOgre::Terrain::BasePointUserObject* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventUpdatedPosition'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventUpdatedPosition,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventUpdatedPosition of class EmberOgre::Terrain::BasePointUserObject */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Terrain__BasePointUserObject_EventUpdatedPosition
    5501  static int tolua_set_EmberOgre__Terrain__BasePointUserObject_EventUpdatedPosition(  lua_State* tolua_S )
          {
           EmberOgre::Terrain::BasePointUserObject* self = (  EmberOgre::Terrain::BasePointUserObject* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventUpdatedPosition'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventUpdatedPosition = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMovements of class EmberOgre::Terrain::TerrainEditAction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditAction_getMovements00
    5518  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditAction_getMovements00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::TerrainEditAction",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::TerrainEditAction* self = (  const EmberOgre::Terrain::TerrainEditAction* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMovements'",  NULL );
          #endif
           {
           const std::vector<EmberOgre::Terrain::TerrainEditBasePointMovement>& tolua_ret = (   const std::vector<EmberOgre::Terrain::TerrainEditBasePointMovement>& ) self->getMovements(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const std::vector<EmberOgre::Terrain::TerrainEditBasePointMovement>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMovements'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMovements of class EmberOgre::Terrain::TerrainEditAction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditAction_getMovements01
    5550  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditAction_getMovements01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditAction",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::Terrain::TerrainEditAction* self = (  EmberOgre::Terrain::TerrainEditAction* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMovements'",  NULL );
          #endif
           {
           std::vector<EmberOgre::Terrain::TerrainEditBasePointMovement>& tolua_ret = (   std::vector<EmberOgre::Terrain::TerrainEditBasePointMovement>& ) self->getMovements(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "std::vector<EmberOgre::Terrain::TerrainEditBasePointMovement>" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Terrain_TerrainEditAction_getMovements00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getVerticalMovement of class EmberOgre::Terrain::TerrainEditBasePointMovement */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditBasePointMovement_getVerticalMovement00
    5577  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditBasePointMovement_getVerticalMovement00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::TerrainEditBasePointMovement",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::TerrainEditBasePointMovement* self = (  const EmberOgre::Terrain::TerrainEditBasePointMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getVerticalMovement'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getVerticalMovement(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getVerticalMovement'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPosition of class EmberOgre::Terrain::TerrainEditBasePointMovement */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditBasePointMovement_getPosition00
    5609  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditBasePointMovement_getPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::TerrainEditBasePointMovement",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::TerrainEditBasePointMovement* self = (  const EmberOgre::Terrain::TerrainEditBasePointMovement* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPosition'",  NULL );
          #endif
           {
           const EmberOgre::TerrainPosition& tolua_ret = (  const EmberOgre::TerrainPosition& ) self->getPosition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const EmberOgre::TerrainPosition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_new00
    5641  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::Terrain::TerrainEditor* tolua_ret = (  EmberOgre::Terrain::TerrainEditor* ) new EmberOgre::Terrain::TerrainEditor(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Terrain::TerrainEditor" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_new00_local
    5669  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::Terrain::TerrainEditor* tolua_ret = (  EmberOgre::Terrain::TerrainEditor* ) new EmberOgre::Terrain::TerrainEditor(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Terrain::TerrainEditor" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_delete00
    5697  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showOverlay of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_showOverlay00
    5726  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_showOverlay00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showOverlay'",  NULL );
          #endif
           {
           self->showOverlay(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showOverlay'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hideOverlay of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_hideOverlay00
    5757  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_hideOverlay00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hideOverlay'",  NULL );
          #endif
           {
           self->hideOverlay(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hideOverlay'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createOverlay of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_createOverlay00
    5788  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_createOverlay00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createOverlay'",  NULL );
          #endif
           {
           self->createOverlay(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createOverlay'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isOverlayShown of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_isOverlayShown00
    5819  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_isOverlayShown00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::TerrainEditor* self = (  const EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isOverlayShown'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isOverlayShown(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isOverlayShown'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: commitAction of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_commitAction00
    5851  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_commitAction00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const EmberOgre::Terrain::TerrainEditAction",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
           const EmberOgre::Terrain::TerrainEditAction* action = (  (  const EmberOgre::Terrain::TerrainEditAction* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'commitAction'",  NULL );
          #endif
           {
           self->commitAction(  *action );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'commitAction'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventPickedBasePoint of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Terrain__TerrainEditor_EventPickedBasePoint
    5884  static int tolua_get_EmberOgre__Terrain__TerrainEditor_EventPickedBasePoint(  lua_State* tolua_S )
          {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventPickedBasePoint'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventPickedBasePoint,  "sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventPickedBasePoint of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Terrain__TerrainEditor_EventPickedBasePoint
    5897  static int tolua_set_EmberOgre__Terrain__TerrainEditor_EventPickedBasePoint(  lua_State* tolua_S )
          {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventPickedBasePoint'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventPickedBasePoint = *(  (  sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventActionCreated of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Terrain__TerrainEditor_EventActionCreated
    5914  static int tolua_get_EmberOgre__Terrain__TerrainEditor_EventActionCreated(  lua_State* tolua_S )
          {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventActionCreated'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventActionCreated,  "sigc::signal<void,  const EmberOgre::Terrain::TerrainEditAction*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventActionCreated of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Terrain__TerrainEditor_EventActionCreated
    5927  static int tolua_set_EmberOgre__Terrain__TerrainEditor_EventActionCreated(  lua_State* tolua_S )
          {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventActionCreated'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const EmberOgre::Terrain::TerrainEditAction*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventActionCreated = *(  (  sigc::signal<void,  const EmberOgre::Terrain::TerrainEditAction*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventSelectedBasePointUpdatedPosition of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Terrain__TerrainEditor_EventSelectedBasePointUpdatedPosition
    5944  static int tolua_get_EmberOgre__Terrain__TerrainEditor_EventSelectedBasePointUpdatedPosition(  lua_State* tolua_S )
          {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventSelectedBasePointUpdatedPosition'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventSelectedBasePointUpdatedPosition,  "sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventSelectedBasePointUpdatedPosition of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Terrain__TerrainEditor_EventSelectedBasePointUpdatedPosition
    5957  static int tolua_set_EmberOgre__Terrain__TerrainEditor_EventSelectedBasePointUpdatedPosition(  lua_State* tolua_S )
          {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventSelectedBasePointUpdatedPosition'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventSelectedBasePointUpdatedPosition = *(  (  sigc::signal<void,  EmberOgre::Terrain::BasePointUserObject*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCurrentBasePointUserObject of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_getCurrentBasePointUserObject00
    5974  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_getCurrentBasePointUserObject00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Terrain::TerrainEditor* self = (  const EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCurrentBasePointUserObject'",  NULL );
          #endif
           {
           EmberOgre::Terrain::BasePointUserObject* tolua_ret = (  EmberOgre::Terrain::BasePointUserObject* ) self->getCurrentBasePointUserObject(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Terrain::BasePointUserObject" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCurrentBasePointUserObject'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: sendChangesToServer of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_sendChangesToServer00
    6006  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_sendChangesToServer00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'sendChangesToServer'",  NULL );
          #endif
           {
           self->sendChangesToServer(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'sendChangesToServer'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createAction of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_createAction00
    6037  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_createAction00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool alsoCommit = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createAction'",  NULL );
          #endif
           {
           self->createAction(  alsoCommit );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createAction'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: undoLastAction of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_undoLastAction00
    6070  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_undoLastAction00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'undoLastAction'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->undoLastAction(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'undoLastAction'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: redoAction of class EmberOgre::Terrain::TerrainEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_redoAction00
    6102  static int tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_redoAction00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Terrain::TerrainEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Terrain::TerrainEditor* self = (  EmberOgre::Terrain::TerrainEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'redoAction'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->redoAction(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'redoAction'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: AnimatedEntities of class MotionManagerInfo */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MotionManager__MotionManagerInfo_AnimatedEntities
    6134  static int tolua_get_EmberOgre__MotionManager__MotionManagerInfo_AnimatedEntities(  lua_State* tolua_S )
          {
           EmberOgre::MotionManager::MotionManagerInfo* self = (  EmberOgre::MotionManager::MotionManagerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AnimatedEntities'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->AnimatedEntities );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: AnimatedEntities of class MotionManagerInfo */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MotionManager__MotionManagerInfo_AnimatedEntities
    6147  static int tolua_set_EmberOgre__MotionManager__MotionManagerInfo_AnimatedEntities(  lua_State* tolua_S )
          {
           EmberOgre::MotionManager::MotionManagerInfo* self = (  EmberOgre::MotionManager::MotionManagerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AnimatedEntities'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->AnimatedEntities = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: MovingEntities of class MotionManagerInfo */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MotionManager__MotionManagerInfo_MovingEntities
    6164  static int tolua_get_EmberOgre__MotionManager__MotionManagerInfo_MovingEntities(  lua_State* tolua_S )
          {
           EmberOgre::MotionManager::MotionManagerInfo* self = (  EmberOgre::MotionManager::MotionManagerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'MovingEntities'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->MovingEntities );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: MovingEntities of class MotionManagerInfo */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MotionManager__MotionManagerInfo_MovingEntities
    6177  static int tolua_set_EmberOgre__MotionManager__MotionManagerInfo_MovingEntities(  lua_State* tolua_S )
          {
           EmberOgre::MotionManager::MotionManagerInfo* self = (  EmberOgre::MotionManager::MotionManagerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'MovingEntities'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->MovingEntities = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Animations of class MotionManagerInfo */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MotionManager__MotionManagerInfo_Animations
    6194  static int tolua_get_EmberOgre__MotionManager__MotionManagerInfo_Animations(  lua_State* tolua_S )
          {
           EmberOgre::MotionManager::MotionManagerInfo* self = (  EmberOgre::MotionManager::MotionManagerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Animations'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->Animations );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Animations of class MotionManagerInfo */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MotionManager__MotionManagerInfo_Animations
    6207  static int tolua_set_EmberOgre__MotionManager__MotionManagerInfo_Animations(  lua_State* tolua_S )
          {
           EmberOgre::MotionManager::MotionManagerInfo* self = (  EmberOgre::MotionManager::MotionManagerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Animations'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Animations = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_getSingleton00
    6224  static int tolua_EmberOgre_EmberOgre_MotionManager_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::MotionManager& tolua_ret = (  EmberOgre::MotionManager& ) EmberOgre::MotionManager::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::MotionManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addEntity of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_addEntity00
    6252  static int tolua_EmberOgre_EmberOgre_MotionManager_addEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::MotionManager* self = (  EmberOgre::MotionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::EmberEntity* entity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addEntity'",  NULL );
          #endif
           {
           self->addEntity(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeEntity of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_removeEntity00
    6285  static int tolua_EmberOgre_EmberOgre_MotionManager_removeEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::MotionManager* self = (  EmberOgre::MotionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::EmberEntity* entity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeEntity'",  NULL );
          #endif
           {
           self->removeEntity(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addAnimation of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_addAnimation00
    6318  static int tolua_EmberOgre_EmberOgre_MotionManager_addAnimation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::AnimationState",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::MotionManager* self = (  EmberOgre::MotionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::AnimationState* animationState = (  (  Ogre::AnimationState* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addAnimation'",  NULL );
          #endif
           {
           self->addAnimation(  animationState );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addAnimation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeAnimation of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_removeAnimation00
    6351  static int tolua_EmberOgre_EmberOgre_MotionManager_removeAnimation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::AnimationState",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::MotionManager* self = (  EmberOgre::MotionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::AnimationState* animationState = (  (  Ogre::AnimationState* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeAnimation'",  NULL );
          #endif
           {
           self->removeAnimation(  animationState );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeAnimation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: pauseAnimation of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_pauseAnimation00
    6384  static int tolua_EmberOgre_EmberOgre_MotionManager_pauseAnimation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::AnimationState",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::MotionManager* self = (  EmberOgre::MotionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::AnimationState* animationState = (  (  Ogre::AnimationState* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'pauseAnimation'",  NULL );
          #endif
           {
           self->pauseAnimation(  animationState );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'pauseAnimation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: unpauseAnimation of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_unpauseAnimation00
    6417  static int tolua_EmberOgre_EmberOgre_MotionManager_unpauseAnimation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::AnimationState",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::MotionManager* self = (  EmberOgre::MotionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::AnimationState* animationState = (  (  Ogre::AnimationState* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'unpauseAnimation'",  NULL );
          #endif
           {
           self->unpauseAnimation(  animationState );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'unpauseAnimation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addAnimatedEntity of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_addAnimatedEntity00
    6450  static int tolua_EmberOgre_EmberOgre_MotionManager_addAnimatedEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::EmberPhysicalEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::MotionManager* self = (  EmberOgre::MotionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::EmberPhysicalEntity* entity = (  (  EmberOgre::EmberPhysicalEntity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addAnimatedEntity'",  NULL );
          #endif
           {
           self->addAnimatedEntity(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addAnimatedEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeAnimatedEntity of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_removeAnimatedEntity00
    6483  static int tolua_EmberOgre_EmberOgre_MotionManager_removeAnimatedEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::EmberPhysicalEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::MotionManager* self = (  EmberOgre::MotionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::EmberPhysicalEntity* entity = (  (  EmberOgre::EmberPhysicalEntity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeAnimatedEntity'",  NULL );
          #endif
           {
           self->removeAnimatedEntity(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeAnimatedEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getInfo of class EmberOgre::MotionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_MotionManager_getInfo00
    6516  static int tolua_EmberOgre_EmberOgre_MotionManager_getInfo00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::MotionManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::MotionManager* self = (  const EmberOgre::MotionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getInfo'",  NULL );
          #endif
           {
           const EmberOgre::MotionManager::MotionManagerInfo& tolua_ret = (  const EmberOgre::MotionManager::MotionManagerInfo& ) self->getInfo(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const EmberOgre::MotionManager::MotionManagerInfo" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInfo'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: show of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_show00
    6548  static int tolua_EmberOgre_EmberOgre_Gui_Widget_show00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'show'",  NULL );
          #endif
           {
           self->show(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'show'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hide of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_hide00
    6579  static int tolua_EmberOgre_EmberOgre_Gui_Widget_hide00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hide'",  NULL );
          #endif
           {
           self->hide(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hide'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWindow of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_getWindow00
    6610  static int tolua_EmberOgre_EmberOgre_Gui_Widget_getWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string windowName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWindow'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->getWindow(  windowName );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           tolua_pushcppstring(  tolua_S,  (  const char* )windowName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: enableCloseButton of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_enableCloseButton00
    6645  static int tolua_EmberOgre_EmberOgre_Gui_Widget_enableCloseButton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'enableCloseButton'",  NULL );
          #endif
           {
           self->enableCloseButton(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'enableCloseButton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: registerConsoleVisibilityToggleCommand of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_registerConsoleVisibilityToggleCommand00
    6676  static int tolua_EmberOgre_EmberOgre_Gui_Widget_registerConsoleVisibilityToggleCommand00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string commandSuffix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'registerConsoleVisibilityToggleCommand'",  NULL );
          #endif
           {
           self->registerConsoleVisibilityToggleCommand(  commandSuffix );
           tolua_pushcppstring(  tolua_S,  (  const char* )commandSuffix );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'registerConsoleVisibilityToggleCommand'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMainSheet of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_getMainSheet00
    6710  static int tolua_EmberOgre_EmberOgre_Gui_Widget_getMainSheet00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMainSheet'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->getMainSheet(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMainSheet'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMainWindow of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_getMainWindow00
    6742  static int tolua_EmberOgre_EmberOgre_Gui_Widget_getMainWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMainWindow'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->getMainWindow(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMainWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createWindow of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_createWindow00
    6774  static int tolua_EmberOgre_EmberOgre_Gui_Widget_createWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string windowType = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createWindow'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->createWindow(  windowType );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           tolua_pushcppstring(  tolua_S,  (  const char* )windowType );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createWindow of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_createWindow01
    6809  static int tolua_EmberOgre_EmberOgre_Gui_Widget_createWindow01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string windowType = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string windowName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createWindow'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->createWindow(  windowType,  windowName );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           tolua_pushcppstring(  tolua_S,  (  const char* )windowType );
           tolua_pushcppstring(  tolua_S,  (  const char* )windowName );
           }
           }
           return 3;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_Widget_createWindow00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: loadMainSheet of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_loadMainSheet00
    6842  static int tolua_EmberOgre_EmberOgre_Gui_Widget_loadMainSheet00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string filename = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string prefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'loadMainSheet'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->loadMainSheet(  filename,  prefix );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           tolua_pushcppstring(  tolua_S,  (  const char* )filename );
           tolua_pushcppstring(  tolua_S,  (  const char* )prefix );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'loadMainSheet'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPrefix of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_getPrefix00
    6880  static int tolua_EmberOgre_EmberOgre_Gui_Widget_getPrefix00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Widget* self = (  const EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPrefix'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getPrefix(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPrefix'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getIsActiveWindowOpaque of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_getIsActiveWindowOpaque00
    6912  static int tolua_EmberOgre_EmberOgre_Gui_Widget_getIsActiveWindowOpaque00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Widget* self = (  const EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getIsActiveWindowOpaque'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getIsActiveWindowOpaque(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getIsActiveWindowOpaque'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setIsActiveWindowOpaque of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_setIsActiveWindowOpaque00
    6944  static int tolua_EmberOgre_EmberOgre_Gui_Widget_setIsActiveWindowOpaque00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool isOpaque = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setIsActiveWindowOpaque'",  NULL );
          #endif
           {
           self->setIsActiveWindowOpaque(  isOpaque );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setIsActiveWindowOpaque'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDefaultScheme of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_getDefaultScheme00
    6977  static int tolua_EmberOgre_EmberOgre_Gui_Widget_getDefaultScheme00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Widget* self = (  const EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDefaultScheme'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getDefaultScheme(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDefaultScheme'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addTabbableWindow of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_addTabbableWindow00
    7009  static int tolua_EmberOgre_EmberOgre_Gui_Widget_addTabbableWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* window = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addTabbableWindow'",  NULL );
          #endif
           {
           self->addTabbableWindow(  window );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addTabbableWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: closeTabGroup of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Widget_closeTabGroup00
    7042  static int tolua_EmberOgre_EmberOgre_Gui_Widget_closeTabGroup00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Widget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'closeTabGroup'",  NULL );
          #endif
           {
           self->closeTabGroup(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'closeTabGroup'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventFrameStarted of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__Widget_EventFrameStarted
    7073  static int tolua_get_EmberOgre__Gui__Widget_EventFrameStarted(  lua_State* tolua_S )
          {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventFrameStarted'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventFrameStarted,  "sigc::signal<void,  float>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventFrameStarted of class EmberOgre::Gui::Widget */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__Widget_EventFrameStarted
    7086  static int tolua_set_EmberOgre__Gui__Widget_EventFrameStarted(  lua_State* tolua_S )
          {
           EmberOgre::Gui::Widget* self = (  EmberOgre::Gui::Widget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventFrameStarted'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  float>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventFrameStarted = *(  (  sigc::signal<void,  float>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::IconBase */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBase_new00
    7103  static int tolua_EmberOgre_EmberOgre_Gui_IconBase_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::IconBase",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const CEGUI::Image",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const CEGUI::Image",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const CEGUI::Image",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "const CEGUI::Image",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const CEGUI::Image* background = (  (  const CEGUI::Image* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const CEGUI::Image* foreground = (  (  const CEGUI::Image* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const CEGUI::Image* borderInactive = (  (  const CEGUI::Image* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           const CEGUI::Image* borderActive = (  (  const CEGUI::Image* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           EmberOgre::Gui::IconBase* tolua_ret = (  EmberOgre::Gui::IconBase* ) new EmberOgre::Gui::IconBase(  name,  background,  foreground,  borderInactive,  borderActive );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::IconBase" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::IconBase */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBase_new00_local
    7142  static int tolua_EmberOgre_EmberOgre_Gui_IconBase_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::IconBase",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const CEGUI::Image",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const CEGUI::Image",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const CEGUI::Image",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "const CEGUI::Image",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const CEGUI::Image* background = (  (  const CEGUI::Image* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const CEGUI::Image* foreground = (  (  const CEGUI::Image* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const CEGUI::Image* borderInactive = (  (  const CEGUI::Image* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           const CEGUI::Image* borderActive = (  (  const CEGUI::Image* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           EmberOgre::Gui::IconBase* tolua_ret = (  EmberOgre::Gui::IconBase* ) new EmberOgre::Gui::IconBase(  name,  background,  foreground,  borderInactive,  borderActive );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::IconBase" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::IconBase */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBase_delete00
    7181  static int tolua_EmberOgre_EmberOgre_Gui_IconBase_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBase* self = (  EmberOgre::Gui::IconBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getContainer of class EmberOgre::Gui::IconBase */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBase_getContainer00
    7210  static int tolua_EmberOgre_EmberOgre_Gui_IconBase_getContainer00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBase* self = (  EmberOgre::Gui::IconBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getContainer'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->getContainer(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getContainer'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getButton of class EmberOgre::Gui::IconBase */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBase_getButton00
    7242  static int tolua_EmberOgre_EmberOgre_Gui_IconBase_getButton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBase* self = (  EmberOgre::Gui::IconBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getButton'",  NULL );
          #endif
           {
           CEGUI::PushButton* tolua_ret = (  CEGUI::PushButton* ) self->getButton(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::PushButton" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getButton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setForeground of class EmberOgre::Gui::IconBase */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBase_setForeground00
    7274  static int tolua_EmberOgre_EmberOgre_Gui_IconBase_setForeground00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBase",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const CEGUI::Image",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBase* self = (  EmberOgre::Gui::IconBase* ) tolua_tousertype(  tolua_S,  1,  0 );
           const CEGUI::Image* image = (  (  const CEGUI::Image* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setForeground'",  NULL );
          #endif
           {
           self->setForeground(  image );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setForeground'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: loadImageFromImageset of class EmberOgre::Gui::IconBase */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBase_loadImageFromImageset00
    7307  static int tolua_EmberOgre_EmberOgre_Gui_IconBase_loadImageFromImageset00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::IconBase",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string imagesetName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string image = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           {
           const CEGUI::Image* tolua_ret = (  const CEGUI::Image* ) EmberOgre::Gui::IconBase::loadImageFromImageset(  imagesetName,  image );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const CEGUI::Image" );
           tolua_pushcppstring(  tolua_S,  (  const char* )imagesetName );
           tolua_pushcppstring(  tolua_S,  (  const char* )image );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'loadImageFromImageset'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::IconBar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBar_new00
    7341  static int tolua_EmberOgre_EmberOgre_Gui_IconBar_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::IconBar",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::IconBar* tolua_ret = (  EmberOgre::Gui::IconBar* ) new EmberOgre::Gui::IconBar(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::IconBar" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::IconBar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBar_new00_local
    7372  static int tolua_EmberOgre_EmberOgre_Gui_IconBar_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::IconBar",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::IconBar* tolua_ret = (  EmberOgre::Gui::IconBar* ) new EmberOgre::Gui::IconBar(  name );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::IconBar" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::IconBar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBar_delete00
    7403  static int tolua_EmberOgre_EmberOgre_Gui_IconBar_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBar",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBar* self = (  EmberOgre::Gui::IconBar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addIcon of class EmberOgre::Gui::IconBar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBar_addIcon00
    7432  static int tolua_EmberOgre_EmberOgre_Gui_IconBar_addIcon00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBar",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::IconBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBar* self = (  EmberOgre::Gui::IconBar* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::IconBase* iconBase = (  (  EmberOgre::Gui::IconBase* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addIcon'",  NULL );
          #endif
           {
           self->addIcon(  iconBase );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addIcon'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeIcon of class EmberOgre::Gui::IconBar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBar_removeIcon00
    7465  static int tolua_EmberOgre_EmberOgre_Gui_IconBar_removeIcon00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBar",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::IconBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBar* self = (  EmberOgre::Gui::IconBar* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::IconBase* iconBase = (  (  EmberOgre::Gui::IconBase* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeIcon'",  NULL );
          #endif
           {
           self->removeIcon(  iconBase );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeIcon'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWindow of class EmberOgre::Gui::IconBar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBar_getWindow00
    7498  static int tolua_EmberOgre_EmberOgre_Gui_IconBar_getWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBar",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBar* self = (  EmberOgre::Gui::IconBar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWindow'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->getWindow(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setIconPadding of class EmberOgre::Gui::IconBar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBar_setIconPadding00
    7530  static int tolua_EmberOgre_EmberOgre_Gui_IconBar_setIconPadding00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBar",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBar* self = (  EmberOgre::Gui::IconBar* ) tolua_tousertype(  tolua_S,  1,  0 );
           int iconPadding = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setIconPadding'",  NULL );
          #endif
           {
           self->setIconPadding(  iconPadding );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setIconPadding'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAbsoluteHeight of class EmberOgre::Gui::IconBar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBar_getAbsoluteHeight00
    7563  static int tolua_EmberOgre_EmberOgre_Gui_IconBar_getAbsoluteHeight00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBar",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBar* self = (  EmberOgre::Gui::IconBar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAbsoluteHeight'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getAbsoluteHeight(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAbsoluteHeight'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAbsoluteWidth of class EmberOgre::Gui::IconBar */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_IconBar_getAbsoluteWidth00
    7595  static int tolua_EmberOgre_EmberOgre_Gui_IconBar_getAbsoluteWidth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::IconBar",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::IconBar* self = (  EmberOgre::Gui::IconBar* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAbsoluteWidth'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getAbsoluteWidth(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAbsoluteWidth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_new00
    7627  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* rootAdapter = (  (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::EntityEditor* tolua_ret = (  EmberOgre::Gui::EntityEditor* ) new EmberOgre::Gui::EntityEditor(  entity,  rootAdapter );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::EntityEditor" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_new00_local
    7659  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* rootAdapter = (  (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::EntityEditor* tolua_ret = (  EmberOgre::Gui::EntityEditor* ) new EmberOgre::Gui::EntityEditor(  entity,  rootAdapter );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::EntityEditor" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_delete00
    7691  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityEditor* self = (  EmberOgre::Gui::EntityEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: submitChanges of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_submitChanges00
    7720  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_submitChanges00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityEditor* self = (  EmberOgre::Gui::EntityEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'submitChanges'",  NULL );
          #endif
           {
           self->submitChanges(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'submitChanges'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createMapElement of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createMapElement00
    7751  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createMapElement00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityEditor* self = (  EmberOgre::Gui::EntityEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createMapElement'",  NULL );
          #endif
           {
           Atlas::Message::Element tolua_ret = (  Atlas::Message::Element ) self->createMapElement(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Atlas::Message::Element(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Atlas::Message::Element ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createMapElement'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createListElement of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createListElement00
    7791  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createListElement00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityEditor* self = (  EmberOgre::Gui::EntityEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createListElement'",  NULL );
          #endif
           {
           Atlas::Message::Element tolua_ret = (  Atlas::Message::Element ) self->createListElement(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Atlas::Message::Element(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Atlas::Message::Element ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createListElement'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createStringElement of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createStringElement00
    7831  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createStringElement00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityEditor* self = (  EmberOgre::Gui::EntityEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createStringElement'",  NULL );
          #endif
           {
           Atlas::Message::Element tolua_ret = (  Atlas::Message::Element ) self->createStringElement(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Atlas::Message::Element(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Atlas::Message::Element ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createStringElement'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createIntElement of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createIntElement00
    7871  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createIntElement00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityEditor* self = (  EmberOgre::Gui::EntityEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createIntElement'",  NULL );
          #endif
           {
           Atlas::Message::Element tolua_ret = (  Atlas::Message::Element ) self->createIntElement(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Atlas::Message::Element(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Atlas::Message::Element ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createIntElement'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createFloatElement of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createFloatElement00
    7911  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createFloatElement00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityEditor* self = (  EmberOgre::Gui::EntityEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createFloatElement'",  NULL );
          #endif
           {
           Atlas::Message::Element tolua_ret = (  Atlas::Message::Element ) self->createFloatElement(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Atlas::Message::Element(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Atlas::Message::Element ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createFloatElement'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createPosition2dElement of class EmberOgre::Gui::EntityEditor */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createPosition2dElement00
    7951  static int tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createPosition2dElement00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityEditor",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityEditor* self = (  EmberOgre::Gui::EntityEditor* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createPosition2dElement'",  NULL );
          #endif
           {
           Atlas::Message::Element tolua_ret = (  Atlas::Message::Element ) self->createPosition2dElement(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Atlas::Message::Element(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Atlas::Message::Element ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::Element" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createPosition2dElement'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_new00
    7991  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* window = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::StackableContainer* tolua_ret = (  EmberOgre::Gui::StackableContainer* ) new EmberOgre::Gui::StackableContainer(  window );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::StackableContainer" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_new00_local
    8021  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* window = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::StackableContainer* tolua_ret = (  EmberOgre::Gui::StackableContainer* ) new EmberOgre::Gui::StackableContainer(  window );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::StackableContainer" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_delete00
    8051  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setInnerContainerWindow of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_setInnerContainerWindow00
    8080  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_setInnerContainerWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* window = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setInnerContainerWindow'",  NULL );
          #endif
           {
           self->setInnerContainerWindow(  window );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setInnerContainerWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWindow of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getWindow00
    8113  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWindow'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->getWindow(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setPadding of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_setPadding00
    8145  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_setPadding00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
           int padding = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setPadding'",  NULL );
          #endif
           {
           self->setPadding(  padding );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setPadding'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPadding of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getPadding00
    8178  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getPadding00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::StackableContainer* self = (  const EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPadding'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->getPadding(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPadding'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAbsoluteHeight of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getAbsoluteHeight00
    8210  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getAbsoluteHeight00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAbsoluteHeight'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getAbsoluteHeight(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAbsoluteHeight'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAbsoluteWidth of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getAbsoluteWidth00
    8242  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getAbsoluteWidth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAbsoluteWidth'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getAbsoluteWidth(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAbsoluteWidth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setFlowDirection of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_setFlowDirection00
    8274  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_setFlowDirection00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::StackableContainer::FlowDirection flowDirection = (  (  EmberOgre::Gui::StackableContainer::FlowDirection ) (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setFlowDirection'",  NULL );
          #endif
           {
           self->setFlowDirection(  flowDirection );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setFlowDirection'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getFlowDirection of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getFlowDirection00
    8307  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getFlowDirection00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::StackableContainer* self = (  const EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getFlowDirection'",  NULL );
          #endif
           {
           EmberOgre::Gui::StackableContainer::FlowDirection tolua_ret = (  EmberOgre::Gui::StackableContainer::FlowDirection ) self->getFlowDirection(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getFlowDirection'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: repositionWindows of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_repositionWindows00
    8339  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_repositionWindows00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'repositionWindows'",  NULL );
          #endif
           {
           self->repositionWindows(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'repositionWindows'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: disconnect of class EmberOgre::Gui::StackableContainer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_StackableContainer_disconnect00
    8370  static int tolua_EmberOgre_EmberOgre_Gui_StackableContainer_disconnect00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::StackableContainer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::StackableContainer* self = (  EmberOgre::Gui::StackableContainer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'disconnect'",  NULL );
          #endif
           {
           self->disconnect(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'disconnect'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::ConsoleAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_new00
    8401  static int tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::ConsoleAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Editbox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Editbox* inputBox = (  (  CEGUI::Editbox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::ConsoleAdapter* tolua_ret = (  EmberOgre::Gui::ConsoleAdapter* ) new EmberOgre::Gui::ConsoleAdapter(  inputBox );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::ConsoleAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::ConsoleAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_new00_local
    8431  static int tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::ConsoleAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Editbox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Editbox* inputBox = (  (  CEGUI::Editbox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::ConsoleAdapter* tolua_ret = (  EmberOgre::Gui::ConsoleAdapter* ) new EmberOgre::Gui::ConsoleAdapter(  inputBox );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::ConsoleAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::ConsoleAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_delete00
    8461  static int tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::ConsoleAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::ConsoleAdapter* self = (  EmberOgre::Gui::ConsoleAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventCommandExecuted of class EmberOgre::Gui::ConsoleAdapter */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__ConsoleAdapter_EventCommandExecuted
    8490  static int tolua_get_EmberOgre__Gui__ConsoleAdapter_EventCommandExecuted(  lua_State* tolua_S )
          {
           EmberOgre::Gui::ConsoleAdapter* self = (  EmberOgre::Gui::ConsoleAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCommandExecuted'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventCommandExecuted,  "sigc::signal<void,  const std::string&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventCommandExecuted of class EmberOgre::Gui::ConsoleAdapter */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__ConsoleAdapter_EventCommandExecuted
    8503  static int tolua_set_EmberOgre__Gui__ConsoleAdapter_EventCommandExecuted(  lua_State* tolua_S )
          {
           EmberOgre::Gui::ConsoleAdapter* self = (  EmberOgre::Gui::ConsoleAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCommandExecuted'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventCommandExecuted = *(  (  sigc::signal<void,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createColouredListItem of class EmberOgre::Gui::ColouredListItem */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new00
    8520  static int tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::ColouredListItem",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string text = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           {
           CEGUI::ListboxItem* tolua_ret = (  CEGUI::ListboxItem* ) EmberOgre::Gui::ColouredListItem::createColouredListItem(  text );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::ListboxItem" );
           tolua_pushcppstring(  tolua_S,  (  const char* )text );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createColouredListItem of class EmberOgre::Gui::ColouredListItem */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new01
    8551  static int tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::ColouredListItem",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const std::string text = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           unsigned int item_id = (  (  unsigned int ) tolua_tonumber(  tolua_S,  3,  0 ) );
           {
           CEGUI::ListboxItem* tolua_ret = (  CEGUI::ListboxItem* ) EmberOgre::Gui::ColouredListItem::createColouredListItem(  text,  item_id );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::ListboxItem" );
           tolua_pushcppstring(  tolua_S,  (  const char* )text );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createColouredListItem of class EmberOgre::Gui::ColouredListItem */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new02
    8579  static int tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::ColouredListItem",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isuserdata(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const std::string text = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           unsigned int item_id = (  (  unsigned int ) tolua_tonumber(  tolua_S,  3,  0 ) );
           void* item_data = (  (  void* ) tolua_touserdata(  tolua_S,  4,  0 ) );
           {
           CEGUI::ListboxItem* tolua_ret = (  CEGUI::ListboxItem* ) EmberOgre::Gui::ColouredListItem::createColouredListItem(  text,  item_id,  item_data );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::ListboxItem" );
           tolua_pushcppstring(  tolua_S,  (  const char* )text );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::AssetsManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_AssetsManager_new00
    8609  static int tolua_EmberOgre_EmberOgre_Gui_AssetsManager_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::AssetsManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::Gui::AssetsManager* tolua_ret = (  EmberOgre::Gui::AssetsManager* ) new EmberOgre::Gui::AssetsManager(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::AssetsManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::AssetsManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_AssetsManager_new00_local
    8637  static int tolua_EmberOgre_EmberOgre_Gui_AssetsManager_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::AssetsManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::Gui::AssetsManager* tolua_ret = (  EmberOgre::Gui::AssetsManager* ) new EmberOgre::Gui::AssetsManager(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::AssetsManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::AssetsManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_AssetsManager_delete00
    8665  static int tolua_EmberOgre_EmberOgre_Gui_AssetsManager_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::AssetsManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::AssetsManager* self = (  EmberOgre::Gui::AssetsManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCEGUIImage of class EmberOgre::Gui::AssetsManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_AssetsManager_getCEGUIImage00
    8694  static int tolua_EmberOgre_EmberOgre_Gui_AssetsManager_getCEGUIImage00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::AssetsManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::AssetsManager* self = (  EmberOgre::Gui::AssetsManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCEGUIImage'",  NULL );
          #endif
           {
           const CEGUI::Image* tolua_ret = (  const CEGUI::Image* ) self->getCEGUIImage(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const CEGUI::Image" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCEGUIImage'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showTexture of class EmberOgre::Gui::AssetsManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_AssetsManager_showTexture00
    8726  static int tolua_EmberOgre_EmberOgre_Gui_AssetsManager_showTexture00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::AssetsManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::AssetsManager* self = (  EmberOgre::Gui::AssetsManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string textureName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showTexture'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->showTexture(  textureName );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showTexture'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getImage of class EmberOgre::Gui::Icons::Icon */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Icons_Icon_getImage00
    8760  static int tolua_EmberOgre_EmberOgre_Gui_Icons_Icon_getImage00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Icons::Icon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Icons::Icon* self = (  EmberOgre::Gui::Icons::Icon* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getImage'",  NULL );
          #endif
           {
           const CEGUI::Image* tolua_ret = (  const CEGUI::Image* ) self->getImage(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const CEGUI::Image" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getImage'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getImage of class EmberOgre::Gui::Icons::Icon */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Icons_Icon_getImage01
    8792  static int tolua_EmberOgre_EmberOgre_Gui_Icons_Icon_getImage01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Icons::Icon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const EmberOgre::Gui::Icons::Icon* self = (  const EmberOgre::Gui::Icons::Icon* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getImage'",  NULL );
          #endif
           {
           const CEGUI::Image* tolua_ret = (  const CEGUI::Image* ) self->getImage(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const CEGUI::Image" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_Icons_Icon_getImage00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Icons::IconManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_new00
    8819  static int tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Icons::IconManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::Gui::Icons::IconManager* tolua_ret = (  EmberOgre::Gui::Icons::IconManager* ) new EmberOgre::Gui::Icons::IconManager(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Icons::IconManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Icons::IconManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_new00_local
    8847  static int tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Icons::IconManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::Gui::Icons::IconManager* tolua_ret = (  EmberOgre::Gui::Icons::IconManager* ) new EmberOgre::Gui::Icons::IconManager(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Icons::IconManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Icons::IconManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_delete00
    8875  static int tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Icons::IconManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Icons::IconManager* self = (  EmberOgre::Gui::Icons::IconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getIcon of class EmberOgre::Gui::Icons::IconManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_getIcon00
    8904  static int tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_getIcon00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Icons::IconManager",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Icons::IconManager* self = (  EmberOgre::Gui::Icons::IconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           int pixelWidth = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           EmberOgre::EmberEntity* entity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getIcon'",  NULL );
          #endif
           {
           EmberOgre::Gui::Icons::Icon* tolua_ret = (  EmberOgre::Gui::Icons::Icon* ) self->getIcon(  pixelWidth,  entity );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Icons::Icon" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getIcon'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getIcon of class EmberOgre::Gui::Icons::IconManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_getIcon01
    8940  static int tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_getIcon01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Icons::IconManager",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Eris::TypeInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::Gui::Icons::IconManager* self = (  EmberOgre::Gui::Icons::IconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           int pixelWidth = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           Eris::TypeInfo* erisType = (  (  Eris::TypeInfo* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getIcon'",  NULL );
          #endif
           {
           EmberOgre::Gui::Icons::Icon* tolua_ret = (  EmberOgre::Gui::Icons::Icon* ) self->getIcon(  pixelWidth,  erisType );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Icons::Icon" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_getIcon00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addEntityIcon of class EmberOgre::Gui::EntityIconSlot */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_addEntityIcon00
    8971  static int tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_addEntityIcon00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIconSlot",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIconSlot* self = (  EmberOgre::Gui::EntityIconSlot* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::EntityIcon* icon = (  (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addEntityIcon'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->addEntityIcon(  icon );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addEntityIcon'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeEntityIcon of class EmberOgre::Gui::EntityIconSlot */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_removeEntityIcon00
    9005  static int tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_removeEntityIcon00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIconSlot",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIconSlot* self = (  EmberOgre::Gui::EntityIconSlot* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeEntityIcon'",  NULL );
          #endif
           {
           EmberOgre::Gui::EntityIcon* tolua_ret = (  EmberOgre::Gui::EntityIcon* ) self->removeEntityIcon(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::EntityIcon" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeEntityIcon'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntityIcon of class EmberOgre::Gui::EntityIconSlot */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_getEntityIcon00
    9037  static int tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_getEntityIcon00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIconSlot",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIconSlot* self = (  EmberOgre::Gui::EntityIconSlot* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntityIcon'",  NULL );
          #endif
           {
           EmberOgre::Gui::EntityIcon* tolua_ret = (  EmberOgre::Gui::EntityIcon* ) self->getEntityIcon(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::EntityIcon" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntityIcon'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWindow of class EmberOgre::Gui::EntityIconSlot */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_getWindow00
    9069  static int tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_getWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIconSlot",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIconSlot* self = (  EmberOgre::Gui::EntityIconSlot* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWindow'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->getWindow(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: notifyIconDraggedOff of class EmberOgre::Gui::EntityIconSlot */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_notifyIconDraggedOff00
    9101  static int tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_notifyIconDraggedOff00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIconSlot",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIconSlot* self = (  EmberOgre::Gui::EntityIconSlot* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::EntityIcon* entityIcon = (  (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'notifyIconDraggedOff'",  NULL );
          #endif
           {
           self->notifyIconDraggedOff(  entityIcon );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'notifyIconDraggedOff'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventIconDraggedOff of class EmberOgre::Gui::EntityIconSlot */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__EntityIconSlot_EventIconDraggedOff
    9134  static int tolua_get_EmberOgre__Gui__EntityIconSlot_EventIconDraggedOff(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconSlot* self = (  EmberOgre::Gui::EntityIconSlot* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconDraggedOff'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventIconDraggedOff,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventIconDraggedOff of class EmberOgre::Gui::EntityIconSlot */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__EntityIconSlot_EventIconDraggedOff
    9147  static int tolua_set_EmberOgre__Gui__EntityIconSlot_EventIconDraggedOff(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconSlot* self = (  EmberOgre::Gui::EntityIconSlot* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconDraggedOff'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventIconDraggedOff = *(  (  sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getImage of class EmberOgre::Gui::EntityIcon */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getImage00
    9164  static int tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getImage00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIcon* self = (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getImage'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->getImage(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getImage'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDragContainer of class EmberOgre::Gui::EntityIcon */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getDragContainer00
    9196  static int tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getDragContainer00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIcon* self = (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDragContainer'",  NULL );
          #endif
           {
           CEGUI::DragContainer* tolua_ret = (  CEGUI::DragContainer* ) self->getDragContainer(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::DragContainer" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDragContainer'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getIcon of class EmberOgre::Gui::EntityIcon */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getIcon00
    9228  static int tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getIcon00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIcon* self = (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getIcon'",  NULL );
          #endif
           {
           EmberOgre::Gui::Icons::Icon* tolua_ret = (  EmberOgre::Gui::Icons::Icon* ) self->getIcon(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Icons::Icon" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getIcon'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setSlot of class EmberOgre::Gui::EntityIcon */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIcon_setSlot00
    9260  static int tolua_EmberOgre_EmberOgre_Gui_EntityIcon_setSlot00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::EntityIconSlot",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIcon* self = (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::EntityIconSlot* slot = (  (  EmberOgre::Gui::EntityIconSlot* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setSlot'",  NULL );
          #endif
           {
           self->setSlot(  slot );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setSlot'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSlot of class EmberOgre::Gui::EntityIcon */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getSlot00
    9293  static int tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getSlot00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIcon* self = (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSlot'",  NULL );
          #endif
           {
           EmberOgre::Gui::EntityIconSlot* tolua_ret = (  EmberOgre::Gui::EntityIconSlot* ) self->getSlot(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::EntityIconSlot" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSlot'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setTooltipText of class EmberOgre::Gui::EntityIcon */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIcon_setTooltipText00
    9325  static int tolua_EmberOgre_EmberOgre_Gui_EntityIcon_setTooltipText00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIcon* self = (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string text = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setTooltipText'",  NULL );
          #endif
           {
           self->setTooltipText(  text );
           tolua_pushcppstring(  tolua_S,  (  const char* )text );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setTooltipText'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntity of class EmberOgre::Gui::EntityIcon */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getEntity00
    9359  static int tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIcon* self = (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntity'",  NULL );
          #endif
           {
           EmberOgre::EmberEntity* tolua_ret = (  EmberOgre::EmberEntity* ) self->getEntity(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::EmberEntity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createSlot of class EmberOgre::Gui::EntityIconManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_createSlot00
    9391  static int tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_createSlot00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIconManager",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIconManager* self = (  EmberOgre::Gui::EntityIconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned int pixelSize = (  (  unsigned int ) tolua_tonumber(  tolua_S,  2,  64 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createSlot'",  NULL );
          #endif
           {
           EmberOgre::Gui::EntityIconSlot* tolua_ret = (  EmberOgre::Gui::EntityIconSlot* ) self->createSlot(  pixelSize );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::EntityIconSlot" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createSlot'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: destroySlot of class EmberOgre::Gui::EntityIconManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_destroySlot00
    9425  static int tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_destroySlot00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIconManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::EntityIconSlot",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIconManager* self = (  EmberOgre::Gui::EntityIconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::EntityIconSlot* slot = (  (  EmberOgre::Gui::EntityIconSlot* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'destroySlot'",  NULL );
          #endif
           {
           self->destroySlot(  slot );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'destroySlot'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createIcon of class EmberOgre::Gui::EntityIconManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_createIcon00
    9458  static int tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_createIcon00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIconManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::Icons::Icon",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIconManager* self = (  EmberOgre::Gui::EntityIconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::Icons::Icon* icon = (  (  EmberOgre::Gui::Icons::Icon* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           EmberOgre::EmberEntity* entity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           unsigned int pixelSize = (  (  unsigned int ) tolua_tonumber(  tolua_S,  4,  64 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createIcon'",  NULL );
          #endif
           {
           EmberOgre::Gui::EntityIcon* tolua_ret = (  EmberOgre::Gui::EntityIcon* ) self->createIcon(  icon,  entity,  pixelSize );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::EntityIcon" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createIcon'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: destroyIcon of class EmberOgre::Gui::EntityIconManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_destroyIcon00
    9496  static int tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_destroyIcon00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::EntityIconManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::EntityIcon",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::EntityIconManager* self = (  EmberOgre::Gui::EntityIconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::EntityIcon* icon = (  (  EmberOgre::Gui::EntityIcon* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'destroyIcon'",  NULL );
          #endif
           {
           self->destroyIcon(  icon );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'destroyIcon'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventIconDragStart of class EmberOgre::Gui::EntityIconManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__EntityIconManager_EventIconDragStart
    9529  static int tolua_get_EmberOgre__Gui__EntityIconManager_EventIconDragStart(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconManager* self = (  EmberOgre::Gui::EntityIconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconDragStart'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventIconDragStart,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventIconDragStart of class EmberOgre::Gui::EntityIconManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__EntityIconManager_EventIconDragStart
    9542  static int tolua_set_EmberOgre__Gui__EntityIconManager_EventIconDragStart(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconManager* self = (  EmberOgre::Gui::EntityIconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconDragStart'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventIconDragStart = *(  (  sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventIconDragStop of class EmberOgre::Gui::EntityIconManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__EntityIconManager_EventIconDragStop
    9559  static int tolua_get_EmberOgre__Gui__EntityIconManager_EventIconDragStop(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconManager* self = (  EmberOgre::Gui::EntityIconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconDragStop'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventIconDragStop,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventIconDragStop of class EmberOgre::Gui::EntityIconManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__EntityIconManager_EventIconDragStop
    9572  static int tolua_set_EmberOgre__Gui__EntityIconManager_EventIconDragStop(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconManager* self = (  EmberOgre::Gui::EntityIconManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconDragStop'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventIconDragStop = *(  (  sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventIconEntered of class EmberOgre::Gui::EntityIconDragDropTarget */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__EntityIconDragDropTarget_EventIconEntered
    9589  static int tolua_get_EmberOgre__Gui__EntityIconDragDropTarget_EventIconEntered(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconDragDropTarget* self = (  EmberOgre::Gui::EntityIconDragDropTarget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconEntered'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventIconEntered,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventIconEntered of class EmberOgre::Gui::EntityIconDragDropTarget */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__EntityIconDragDropTarget_EventIconEntered
    9602  static int tolua_set_EmberOgre__Gui__EntityIconDragDropTarget_EventIconEntered(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconDragDropTarget* self = (  EmberOgre::Gui::EntityIconDragDropTarget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconEntered'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventIconEntered = *(  (  sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventIconLeaves of class EmberOgre::Gui::EntityIconDragDropTarget */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__EntityIconDragDropTarget_EventIconLeaves
    9619  static int tolua_get_EmberOgre__Gui__EntityIconDragDropTarget_EventIconLeaves(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconDragDropTarget* self = (  EmberOgre::Gui::EntityIconDragDropTarget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconLeaves'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventIconLeaves,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventIconLeaves of class EmberOgre::Gui::EntityIconDragDropTarget */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__EntityIconDragDropTarget_EventIconLeaves
    9632  static int tolua_set_EmberOgre__Gui__EntityIconDragDropTarget_EventIconLeaves(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconDragDropTarget* self = (  EmberOgre::Gui::EntityIconDragDropTarget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconLeaves'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventIconLeaves = *(  (  sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventIconDropped of class EmberOgre::Gui::EntityIconDragDropTarget */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__EntityIconDragDropTarget_EventIconDropped
    9649  static int tolua_get_EmberOgre__Gui__EntityIconDragDropTarget_EventIconDropped(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconDragDropTarget* self = (  EmberOgre::Gui::EntityIconDragDropTarget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconDropped'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventIconDropped,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventIconDropped of class EmberOgre::Gui::EntityIconDragDropTarget */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__EntityIconDragDropTarget_EventIconDropped
    9662  static int tolua_set_EmberOgre__Gui__EntityIconDragDropTarget_EventIconDropped(  lua_State* tolua_S )
          {
           EmberOgre::Gui::EntityIconDragDropTarget* self = (  EmberOgre::Gui::EntityIconDragDropTarget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventIconDropped'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Gui::EntityIcon*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventIconDropped = *(  (  sigc::signal<void,  EmberOgre::Gui::EntityIcon*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createModel of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_createModel00
    9679  static int tolua_EmberOgre_EmberOgre_Model_Model_createModel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::SceneManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneManager* sceneManager = (  (  Ogre::SceneManager* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string modelType = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Model::Model* tolua_ret = (  EmberOgre::Model::Model* ) EmberOgre::Model::Model::createModel(  sceneManager,  modelType );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::Model" );
           tolua_pushcppstring(  tolua_S,  (  const char* )modelType );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createModel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createModel of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_createModel01
    9712  static int tolua_EmberOgre_EmberOgre_Model_Model_createModel01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::SceneManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneManager* sceneManager = (  (  Ogre::SceneManager* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string modelType = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  4,  0 ) );
           {
           EmberOgre::Model::Model* tolua_ret = (  EmberOgre::Model::Model* ) EmberOgre::Model::Model::createModel(  sceneManager,  modelType,  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::Model" );
           tolua_pushcppstring(  tolua_S,  (  const char* )modelType );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 3;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Model_Model_createModel00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: reload of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_reload00
    9743  static int tolua_EmberOgre_EmberOgre_Model_Model_reload00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'reload'",  NULL );
          #endif
           {
           self->reload(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'reload'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_delete00
    9774  static int tolua_EmberOgre_EmberOgre_Model_Model_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addSubmodel of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_addSubmodel00
    9803  static int tolua_EmberOgre_EmberOgre_Model_Model_addSubmodel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::SubModel",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::SubModel* submodel = (  (  EmberOgre::Model::SubModel* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addSubmodel'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->addSubmodel(  submodel );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addSubmodel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeSubmodel of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_removeSubmodel00
    9837  static int tolua_EmberOgre_EmberOgre_Model_Model_removeSubmodel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::SubModel",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::SubModel* submodel = (  (  EmberOgre::Model::SubModel* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeSubmodel'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->removeSubmodel(  submodel );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeSubmodel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAction of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_getAction00
    9871  static int tolua_EmberOgre_EmberOgre_Model_Model_getAction00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAction'",  NULL );
          #endif
           {
           EmberOgre::Model::Action* tolua_ret = (  EmberOgre::Model::Action* ) self->getAction(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::Action" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAction'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showPart of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_showPart00
    9906  static int tolua_EmberOgre_EmberOgre_Model_Model_showPart00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string partName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showPart'",  NULL );
          #endif
           {
           self->showPart(  partName );
           tolua_pushcppstring(  tolua_S,  (  const char* )partName );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showPart'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hidePart of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_hidePart00
    9940  static int tolua_EmberOgre_EmberOgre_Model_Model_hidePart00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string partName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hidePart'",  NULL );
          #endif
           {
           self->hidePart(  partName );
           tolua_pushcppstring(  tolua_S,  (  const char* )partName );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hidePart'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setVisible of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_setVisible00
    9974  static int tolua_EmberOgre_EmberOgre_Model_Model_setVisible00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool visible = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setVisible'",  NULL );
          #endif
           {
           self->setVisible(  visible );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setVisible'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getScale of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_getScale00
   10007  static int tolua_EmberOgre_EmberOgre_Model_Model_getScale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::Model* self = (  const EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getScale'",  NULL );
          #endif
           {
           const Ogre::Real tolua_ret = (  const Ogre::Real ) self->getScale(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Real(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "const Ogre::Real" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  const Ogre::Real ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "const Ogre::Real" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getScale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getRotation of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_getRotation00
   10047  static int tolua_EmberOgre_EmberOgre_Model_Model_getRotation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::Model* self = (  const EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getRotation'",  NULL );
          #endif
           {
           const Ogre::Quaternion& tolua_ret = (  const Ogre::Quaternion& ) self->getRotation(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getRotation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getUseScaleOf of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_getUseScaleOf00
   10079  static int tolua_EmberOgre_EmberOgre_Model_Model_getUseScaleOf00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::Model* self = (  const EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getUseScaleOf'",  NULL );
          #endif
           {
           const EmberOgre::Model::ModelDefinition::UseScaleOf tolua_ret = (  const EmberOgre::Model::ModelDefinition::UseScaleOf ) self->getUseScaleOf(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getUseScaleOf'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_getName00
   10111  static int tolua_EmberOgre_EmberOgre_Model_Model_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::Model* self = (  const EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDefinition of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_getDefinition00
   10143  static int tolua_EmberOgre_EmberOgre_Model_Model_getDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::Model* self = (  const EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::ModelDefnPtr tolua_ret = (  EmberOgre::Model::ModelDefnPtr ) self->getDefinition(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new EmberOgre::Model::ModelDefnPtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::Model::ModelDefnPtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  EmberOgre::Model::ModelDefnPtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::Model::ModelDefnPtr" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasAttachPoint of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_hasAttachPoint00
   10183  static int tolua_EmberOgre_EmberOgre_Model_Model_hasAttachPoint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::Model* self = (  const EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string attachPoint = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasAttachPoint'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasAttachPoint(  attachPoint );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )attachPoint );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasAttachPoint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasParticles of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_hasParticles00
   10218  static int tolua_EmberOgre_EmberOgre_Model_Model_hasParticles00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::Model* self = (  const EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasParticles'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasParticles(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasParticles'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubModel of class EmberOgre::Model::Model */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_Model_getSubModel00
   10250  static int tolua_EmberOgre_EmberOgre_Model_Model_getSubModel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::Model* self = (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned int index = (  (  unsigned int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSubModel'",  NULL );
          #endif
           {
           EmberOgre::Model::SubModel* tolua_ret = (  EmberOgre::Model::SubModel* ) self->getSubModel(  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::SubModel" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSubModel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntity of class EmberOgre::Model::SubModel */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubModel_getEntity00
   10284  static int tolua_EmberOgre_EmberOgre_Model_SubModel_getEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::SubModel",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::SubModel* self = (  const EmberOgre::Model::SubModel* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntity'",  NULL );
          #endif
           {
           Ogre::Entity* tolua_ret = (  Ogre::Entity* ) self->getEntity(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Entity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Name of class EmberOgre::Model::ViewDefinition */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Model__ViewDefinition_Name
   10316  static int tolua_get_EmberOgre__Model__ViewDefinition_Name(  lua_State* tolua_S )
          {
           EmberOgre::Model::ViewDefinition* self = (  EmberOgre::Model::ViewDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Name'",  NULL );
          #endif
           tolua_pushcppstring(  tolua_S,  (  const char* )self->Name );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Name of class EmberOgre::Model::ViewDefinition */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Model__ViewDefinition_Name
   10329  static int tolua_set_EmberOgre__Model__ViewDefinition_Name(  lua_State* tolua_S )
          {
           EmberOgre::Model::ViewDefinition* self = (  EmberOgre::Model::ViewDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Name'",  NULL );
           if (  !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Name = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Rotation of class EmberOgre::Model::ViewDefinition */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Model__ViewDefinition_Rotation
   10346  static int tolua_get_EmberOgre__Model__ViewDefinition_Rotation(  lua_State* tolua_S )
          {
           EmberOgre::Model::ViewDefinition* self = (  EmberOgre::Model::ViewDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Rotation'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Rotation,  "Ogre::Quaternion" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Rotation of class EmberOgre::Model::ViewDefinition */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Model__ViewDefinition_Rotation
   10359  static int tolua_set_EmberOgre__Model__ViewDefinition_Rotation(  lua_State* tolua_S )
          {
           EmberOgre::Model::ViewDefinition* self = (  EmberOgre::Model::ViewDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Rotation'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Quaternion",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Rotation = *(  (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Distance of class EmberOgre::Model::ViewDefinition */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Model__ViewDefinition_Distance
   10376  static int tolua_get_EmberOgre__Model__ViewDefinition_Distance(  lua_State* tolua_S )
          {
           EmberOgre::Model::ViewDefinition* self = (  EmberOgre::Model::ViewDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Distance'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->Distance );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Distance of class EmberOgre::Model::ViewDefinition */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Model__ViewDefinition_Distance
   10389  static int tolua_set_EmberOgre__Model__ViewDefinition_Distance(  lua_State* tolua_S )
          {
           EmberOgre::Model::ViewDefinition* self = (  EmberOgre::Model::ViewDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Distance'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Distance = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Name of class EmberOgre::Model::AttachPointDefinition */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Model__AttachPointDefinition_Name
   10406  static int tolua_get_EmberOgre__Model__AttachPointDefinition_Name(  lua_State* tolua_S )
          {
           EmberOgre::Model::AttachPointDefinition* self = (  EmberOgre::Model::AttachPointDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Name'",  NULL );
          #endif
           tolua_pushcppstring(  tolua_S,  (  const char* )self->Name );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Name of class EmberOgre::Model::AttachPointDefinition */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Model__AttachPointDefinition_Name
   10419  static int tolua_set_EmberOgre__Model__AttachPointDefinition_Name(  lua_State* tolua_S )
          {
           EmberOgre::Model::AttachPointDefinition* self = (  EmberOgre::Model::AttachPointDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Name'",  NULL );
           if (  !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Name = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: BoneName of class EmberOgre::Model::AttachPointDefinition */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Model__AttachPointDefinition_BoneName
   10436  static int tolua_get_EmberOgre__Model__AttachPointDefinition_BoneName(  lua_State* tolua_S )
          {
           EmberOgre::Model::AttachPointDefinition* self = (  EmberOgre::Model::AttachPointDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'BoneName'",  NULL );
          #endif
           tolua_pushcppstring(  tolua_S,  (  const char* )self->BoneName );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: BoneName of class EmberOgre::Model::AttachPointDefinition */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Model__AttachPointDefinition_BoneName
   10449  static int tolua_set_EmberOgre__Model__AttachPointDefinition_BoneName(  lua_State* tolua_S )
          {
           EmberOgre::Model::AttachPointDefinition* self = (  EmberOgre::Model::AttachPointDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'BoneName'",  NULL );
           if (  !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->BoneName = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Rotation of class EmberOgre::Model::AttachPointDefinition */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Model__AttachPointDefinition_Rotation
   10466  static int tolua_get_EmberOgre__Model__AttachPointDefinition_Rotation(  lua_State* tolua_S )
          {
           EmberOgre::Model::AttachPointDefinition* self = (  EmberOgre::Model::AttachPointDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Rotation'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Rotation,  "Ogre::Quaternion" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Rotation of class EmberOgre::Model::AttachPointDefinition */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Model__AttachPointDefinition_Rotation
   10479  static int tolua_set_EmberOgre__Model__AttachPointDefinition_Rotation(  lua_State* tolua_S )
          {
           EmberOgre::Model::AttachPointDefinition* self = (  EmberOgre::Model::AttachPointDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Rotation'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Quaternion",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Rotation = *(  (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubEntityName of class EmberOgre::Model::SubEntityDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getSubEntityName00
   10496  static int tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getSubEntityName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubEntityDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubEntityDefinition* self = (  EmberOgre::Model::SubEntityDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSubEntityName'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->getSubEntityName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSubEntityName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubEntityIndex of class EmberOgre::Model::SubEntityDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getSubEntityIndex00
   10528  static int tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getSubEntityIndex00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubEntityDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubEntityDefinition* self = (  EmberOgre::Model::SubEntityDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSubEntityIndex'",  NULL );
          #endif
           {
           unsigned int tolua_ret = (  unsigned int ) self->getSubEntityIndex(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSubEntityIndex'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMaterialName of class EmberOgre::Model::SubEntityDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getMaterialName00
   10560  static int tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getMaterialName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubEntityDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubEntityDefinition* self = (  EmberOgre::Model::SubEntityDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMaterialName'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->getMaterialName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMaterialName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaterialName of class EmberOgre::Model::SubEntityDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_setMaterialName00
   10592  static int tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_setMaterialName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubEntityDefinition",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubEntityDefinition* self = (  EmberOgre::Model::SubEntityDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           std::string materialName = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaterialName'",  NULL );
          #endif
           {
           self->setMaterialName(  materialName );
           tolua_pushcppstring(  tolua_S,  (  const char* )materialName );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMaterialName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPartDefinition of class EmberOgre::Model::SubEntityDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getPartDefinition00
   10626  static int tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getPartDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubEntityDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubEntityDefinition* self = (  EmberOgre::Model::SubEntityDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPartDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::PartDefinition& tolua_ret = (  EmberOgre::Model::PartDefinition& ) self->getPartDefinition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::Model::PartDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPartDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setName of class EmberOgre::Model::PartDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_PartDefinition_setName00
   10658  static int tolua_EmberOgre_EmberOgre_Model_PartDefinition_setName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::PartDefinition* self = (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           std::string name = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setName'",  NULL );
          #endif
           {
           self->setName(  name );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class EmberOgre::Model::PartDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_PartDefinition_getName00
   10692  static int tolua_EmberOgre_EmberOgre_Model_PartDefinition_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::PartDefinition* self = (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setShow of class EmberOgre::Model::PartDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_PartDefinition_setShow00
   10724  static int tolua_EmberOgre_EmberOgre_Model_PartDefinition_setShow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::PartDefinition* self = (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool show = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setShow'",  NULL );
          #endif
           {
           self->setShow(  show );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setShow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getShow of class EmberOgre::Model::PartDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_PartDefinition_getShow00
   10757  static int tolua_EmberOgre_EmberOgre_Model_PartDefinition_getShow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::PartDefinition* self = (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getShow'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getShow(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getShow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createSubEntityDefinition of class EmberOgre::Model::PartDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_PartDefinition_createSubEntityDefinition00
   10789  static int tolua_EmberOgre_EmberOgre_Model_PartDefinition_createSubEntityDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::PartDefinition* self = (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           std::string subEntityName = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createSubEntityDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::SubEntityDefinition* tolua_ret = (  EmberOgre::Model::SubEntityDefinition* ) self->createSubEntityDefinition(  subEntityName );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::SubEntityDefinition" );
           tolua_pushcppstring(  tolua_S,  (  const char* )subEntityName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createSubEntityDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createSubEntityDefinition of class EmberOgre::Model::PartDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_PartDefinition_createSubEntityDefinition01
   10824  static int tolua_EmberOgre_EmberOgre_Model_PartDefinition_createSubEntityDefinition01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::Model::PartDefinition* self = (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned int subEntityIndex = (  (  unsigned int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createSubEntityDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::SubEntityDefinition* tolua_ret = (  EmberOgre::Model::SubEntityDefinition* ) self->createSubEntityDefinition(  subEntityIndex );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::SubEntityDefinition" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Model_PartDefinition_createSubEntityDefinition00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubEntityDefinitions of class EmberOgre::Model::PartDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_PartDefinition_getSubEntityDefinitions00
   10853  static int tolua_EmberOgre_EmberOgre_Model_PartDefinition_getSubEntityDefinitions00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::PartDefinition* self = (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSubEntityDefinitions'",  NULL );
          #endif
           {
           std::vector<EmberOgre::Model::SubEntityDefinition*> tolua_ret = (  std::vector<EmberOgre::Model::SubEntityDefinition*> ) self->getSubEntityDefinitions(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::vector<EmberOgre::Model::SubEntityDefinition*>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<EmberOgre::Model::SubEntityDefinition*>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::vector<EmberOgre::Model::SubEntityDefinition*> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<EmberOgre::Model::SubEntityDefinition*>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSubEntityDefinitions'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeSubEntityDefinition of class EmberOgre::Model::PartDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_PartDefinition_removeSubEntityDefinition00
   10893  static int tolua_EmberOgre_EmberOgre_Model_PartDefinition_removeSubEntityDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::SubEntityDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::PartDefinition* self = (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::SubEntityDefinition* def = (  (  EmberOgre::Model::SubEntityDefinition* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeSubEntityDefinition'",  NULL );
          #endif
           {
           self->removeSubEntityDefinition(  def );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeSubEntityDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubModelDefinition of class EmberOgre::Model::PartDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_PartDefinition_getSubModelDefinition00
   10926  static int tolua_EmberOgre_EmberOgre_Model_PartDefinition_getSubModelDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::PartDefinition* self = (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSubModelDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::SubModelDefinition& tolua_ret = (  EmberOgre::Model::SubModelDefinition& ) self->getSubModelDefinition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::Model::SubModelDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSubModelDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMeshName of class EmberOgre::Model::SubModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_getMeshName00
   10958  static int tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_getMeshName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubModelDefinition* self = (  EmberOgre::Model::SubModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMeshName'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->getMeshName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMeshName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createPartDefinition of class EmberOgre::Model::SubModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_createPartDefinition00
   10990  static int tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_createPartDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubModelDefinition",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubModelDefinition* self = (  EmberOgre::Model::SubModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           std::string partname = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createPartDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::PartDefinition* tolua_ret = (  EmberOgre::Model::PartDefinition* ) self->createPartDefinition(  partname );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::PartDefinition" );
           tolua_pushcppstring(  tolua_S,  (  const char* )partname );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createPartDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPartDefinitions of class EmberOgre::Model::SubModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_getPartDefinitions00
   11025  static int tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_getPartDefinitions00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubModelDefinition* self = (  EmberOgre::Model::SubModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPartDefinitions'",  NULL );
          #endif
           {
           std::vector<EmberOgre::Model::PartDefinition*> tolua_ret = (  std::vector<EmberOgre::Model::PartDefinition*> ) self->getPartDefinitions(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::vector<EmberOgre::Model::PartDefinition*>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<EmberOgre::Model::PartDefinition*>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::vector<EmberOgre::Model::PartDefinition*> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<EmberOgre::Model::PartDefinition*>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPartDefinitions'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removePartDefinition of class EmberOgre::Model::SubModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_removePartDefinition00
   11065  static int tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_removePartDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubModelDefinition",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubModelDefinition* self = (  EmberOgre::Model::SubModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::PartDefinition* def = (  (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removePartDefinition'",  NULL );
          #endif
           {
           self->removePartDefinition(  def );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removePartDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getModelDefinition of class EmberOgre::Model::SubModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_getModelDefinition00
   11098  static int tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_getModelDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::SubModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::SubModelDefinition* self = (  EmberOgre::Model::SubModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getModelDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::ModelDefinition& tolua_ret = (  EmberOgre::Model::ModelDefinition& ) self->getModelDefinition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::Model::ModelDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getModelDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isValid of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_isValid00
   11130  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_isValid00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isValid'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isValid(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isValid'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setValid of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setValid00
   11162  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setValid00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool valid = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setValid'",  NULL );
          #endif
           {
           self->setValid(  valid );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setValid'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getScale of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getScale00
   11195  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getScale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getScale'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getScale(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getScale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setScale of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setScale00
   11227  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setScale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           float scale = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setScale'",  NULL );
          #endif
           {
           self->setScale(  scale );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setScale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getUseScaleOf of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getUseScaleOf00
   11260  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getUseScaleOf00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getUseScaleOf'",  NULL );
          #endif
           {
           EmberOgre::Model::ModelDefinition::UseScaleOf tolua_ret = (  EmberOgre::Model::ModelDefinition::UseScaleOf ) self->getUseScaleOf(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getUseScaleOf'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setUseScaleOf of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setUseScaleOf00
   11292  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setUseScaleOf00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::ModelDefinition::UseScaleOf useScale = (  (  EmberOgre::Model::ModelDefinition::UseScaleOf ) (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setUseScaleOf'",  NULL );
          #endif
           {
           self->setUseScaleOf(  useScale );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setUseScaleOf'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getTranslate of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getTranslate00
   11325  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getTranslate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getTranslate'",  NULL );
          #endif
           {
           Ogre::Vector3& tolua_ret = (  Ogre::Vector3& ) self->getTranslate(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getTranslate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setTranslate of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setTranslate00
   11357  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setTranslate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3 translate = *(  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setTranslate'",  NULL );
          #endif
           {
           self->setTranslate(  translate );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setTranslate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getShowContained of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getShowContained00
   11390  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getShowContained00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getShowContained'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getShowContained(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getShowContained'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getShowContained of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getShowContained01
   11422  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getShowContained01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool show = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getShowContained'",  NULL );
          #endif
           {
           self->getShowContained(  show );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getShowContained00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getContentOffset of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getContentOffset00
   11450  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getContentOffset00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::ModelDefinition* self = (  const EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getContentOffset'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getContentOffset(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getContentOffset'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setContentOffset of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setContentOffset00
   11482  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setContentOffset00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* tolua_var_1 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setContentOffset'",  NULL );
          #endif
           {
           self->setContentOffset(  *tolua_var_1 );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setContentOffset'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getRotation of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getRotation00
   11515  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getRotation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::ModelDefinition* self = (  const EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getRotation'",  NULL );
          #endif
           {
           const Ogre::Quaternion& tolua_ret = (  const Ogre::Quaternion& ) self->getRotation(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getRotation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setRotation of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setRotation00
   11547  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setRotation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion rotation = *(  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setRotation'",  NULL );
          #endif
           {
           self->setRotation(  rotation );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setRotation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createSubModelDefinition of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_createSubModelDefinition00
   11580  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_createSubModelDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           std::string meshname = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createSubModelDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::SubModelDefinition* tolua_ret = (  EmberOgre::Model::SubModelDefinition* ) self->createSubModelDefinition(  meshname );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::SubModelDefinition" );
           tolua_pushcppstring(  tolua_S,  (  const char* )meshname );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createSubModelDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubModelDefinitions of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getSubModelDefinitions00
   11615  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getSubModelDefinitions00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSubModelDefinitions'",  NULL );
          #endif
           {
           std::vector<EmberOgre::Model::SubModelDefinition*>& tolua_ret = (  std::vector<EmberOgre::Model::SubModelDefinition*>& ) self->getSubModelDefinitions(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "std::vector<EmberOgre::Model::SubModelDefinition*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSubModelDefinitions'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeSubModelDefinition of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_removeSubModelDefinition00
   11647  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_removeSubModelDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::SubModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::SubModelDefinition* def = (  (  EmberOgre::Model::SubModelDefinition* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeSubModelDefinition'",  NULL );
          #endif
           {
           self->removeSubModelDefinition(  def );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeSubModelDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createActionDefinition of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_createActionDefinition00
   11680  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_createActionDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           std::string actionname = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createActionDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::ActionDefinition* tolua_ret = (  EmberOgre::Model::ActionDefinition* ) self->createActionDefinition(  actionname );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::ActionDefinition" );
           tolua_pushcppstring(  tolua_S,  (  const char* )actionname );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createActionDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getActionDefinitions of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getActionDefinitions00
   11715  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getActionDefinitions00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getActionDefinitions'",  NULL );
          #endif
           {
           std::vector<EmberOgre::Model::ActionDefinition*>& tolua_ret = (  std::vector<EmberOgre::Model::ActionDefinition*>& ) self->getActionDefinitions(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "std::vector<EmberOgre::Model::ActionDefinition*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getActionDefinitions'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeActionDefinition of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_removeActionDefinition00
   11747  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_removeActionDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::ActionDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::ActionDefinition* def = (  (  EmberOgre::Model::ActionDefinition* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeActionDefinition'",  NULL );
          #endif
           {
           self->removeActionDefinition(  def );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeActionDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttachPointsDefinitions of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getAttachPointsDefinitions00
   11780  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getAttachPointsDefinitions00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttachPointsDefinitions'",  NULL );
          #endif
           {
           const std::vector<EmberOgre::Model::AttachPointDefinition>& tolua_ret = (  const std::vector<EmberOgre::Model::AttachPointDefinition>& ) self->getAttachPointsDefinitions(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const std::vector<EmberOgre::Model::AttachPointDefinition>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttachPointsDefinitions'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createViewDefinition of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_createViewDefinition00
   11812  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_createViewDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string viewname = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createViewDefinition'",  NULL );
          #endif
           {
           EmberOgre::Model::ViewDefinition* tolua_ret = (  EmberOgre::Model::ViewDefinition* ) self->createViewDefinition(  viewname );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::ViewDefinition" );
           tolua_pushcppstring(  tolua_S,  (  const char* )viewname );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createViewDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getViewDefinitions of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getViewDefinitions00
   11847  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getViewDefinitions00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getViewDefinitions'",  NULL );
          #endif
           {
           const std::map<std::string,  EmberOgre::Model::ViewDefinition*>& tolua_ret = (   const std::map<std::string,  EmberOgre::Model::ViewDefinition*>& ) self->getViewDefinitions(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const std::map<std::string,  EmberOgre::Model::ViewDefinition*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getViewDefinitions'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeViewDefinition of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_removeViewDefinition00
   11879  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_removeViewDefinition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeViewDefinition'",  NULL );
          #endif
           {
           self->removeViewDefinition(  name );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeViewDefinition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: reloadAllInstances of class EmberOgre::Model::ModelDefinition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinition_reloadAllInstances00
   11912  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinition_reloadAllInstances00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinition* self = (  EmberOgre::Model::ModelDefinition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'reloadAllInstances'",  NULL );
          #endif
           {
           self->reloadAllInstances(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'reloadAllInstances'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: get of class EmberOgre::Model::ModelDefnPtr */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefnPtr_get00
   11943  static int tolua_EmberOgre_EmberOgre_Model_ModelDefnPtr_get00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefnPtr",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefnPtr* self = (  EmberOgre::Model::ModelDefnPtr* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'get'",  NULL );
          #endif
           {
           EmberOgre::Model::ModelDefinition* tolua_ret = (  EmberOgre::Model::ModelDefinition* ) self->get(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::ModelDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'get'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: xPosition of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MouseMotion_xPosition
   11975  static int tolua_get_EmberOgre__MouseMotion_xPosition(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'xPosition'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->xPosition );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: xPosition of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MouseMotion_xPosition
   11988  static int tolua_set_EmberOgre__MouseMotion_xPosition(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'xPosition'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->xPosition = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: yPosition of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MouseMotion_yPosition
   12005  static int tolua_get_EmberOgre__MouseMotion_yPosition(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'yPosition'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->yPosition );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: yPosition of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MouseMotion_yPosition
   12018  static int tolua_set_EmberOgre__MouseMotion_yPosition(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'yPosition'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->yPosition = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: xRelativeMovement of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MouseMotion_xRelativeMovement
   12035  static int tolua_get_EmberOgre__MouseMotion_xRelativeMovement(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'xRelativeMovement'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->xRelativeMovement,  "Ogre::Real" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: xRelativeMovement of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MouseMotion_xRelativeMovement
   12048  static int tolua_set_EmberOgre__MouseMotion_xRelativeMovement(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'xRelativeMovement'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Real",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->xRelativeMovement = *(  (  Ogre::Real* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: yRelativeMovement of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MouseMotion_yRelativeMovement
   12065  static int tolua_get_EmberOgre__MouseMotion_yRelativeMovement(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'yRelativeMovement'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->yRelativeMovement,  "Ogre::Real" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: yRelativeMovement of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MouseMotion_yRelativeMovement
   12078  static int tolua_set_EmberOgre__MouseMotion_yRelativeMovement(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'yRelativeMovement'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Real",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->yRelativeMovement = *(  (  Ogre::Real* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: xRelativeMovementInPixels of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MouseMotion_xRelativeMovementInPixels
   12095  static int tolua_get_EmberOgre__MouseMotion_xRelativeMovementInPixels(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'xRelativeMovementInPixels'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->xRelativeMovementInPixels );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: xRelativeMovementInPixels of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MouseMotion_xRelativeMovementInPixels
   12108  static int tolua_set_EmberOgre__MouseMotion_xRelativeMovementInPixels(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'xRelativeMovementInPixels'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->xRelativeMovementInPixels = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: yRelativeMovementInPixels of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MouseMotion_yRelativeMovementInPixels
   12125  static int tolua_get_EmberOgre__MouseMotion_yRelativeMovementInPixels(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'yRelativeMovementInPixels'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->yRelativeMovementInPixels );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: yRelativeMovementInPixels of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MouseMotion_yRelativeMovementInPixels
   12138  static int tolua_set_EmberOgre__MouseMotion_yRelativeMovementInPixels(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'yRelativeMovementInPixels'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->yRelativeMovementInPixels = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: timeSinceLastMovement of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MouseMotion_timeSinceLastMovement
   12155  static int tolua_get_EmberOgre__MouseMotion_timeSinceLastMovement(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'timeSinceLastMovement'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->timeSinceLastMovement,  "Ogre::Real" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: timeSinceLastMovement of class EmberOgre::MouseMotion */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MouseMotion_timeSinceLastMovement
   12168  static int tolua_set_EmberOgre__MouseMotion_timeSinceLastMovement(  lua_State* tolua_S )
          {
           EmberOgre::MouseMotion* self = (  EmberOgre::MouseMotion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'timeSinceLastMovement'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Real",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->timeSinceLastMovement = *(  (  Ogre::Real* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Input_getSingleton00
   12185  static int tolua_EmberOgre_EmberOgre_Input_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Input",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::Input& tolua_ret = (  EmberOgre::Input& ) EmberOgre::Input::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::Input" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventKeyPressed of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Input_EventKeyPressed
   12213  static int tolua_get_EmberOgre__Input_EventKeyPressed(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventKeyPressed'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventKeyPressed,  "sigc::signal<void,  const SDL_keysym&,  EmberOgre::Input::InputMode>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventKeyPressed of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Input_EventKeyPressed
   12226  static int tolua_set_EmberOgre__Input_EventKeyPressed(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventKeyPressed'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const SDL_keysym&,  EmberOgre::Input::InputMode>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventKeyPressed = *(  (  sigc::signal<void,  const SDL_keysym&,  EmberOgre::Input::InputMode>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventKeyReleased of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Input_EventKeyReleased
   12243  static int tolua_get_EmberOgre__Input_EventKeyReleased(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventKeyReleased'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventKeyReleased,  "sigc::signal<void,  const SDL_keysym&,  EmberOgre::Input::InputMode>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventKeyReleased of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Input_EventKeyReleased
   12256  static int tolua_set_EmberOgre__Input_EventKeyReleased(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventKeyReleased'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const SDL_keysym&,  EmberOgre::Input::InputMode>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventKeyReleased = *(  (  sigc::signal<void,  const SDL_keysym&,  EmberOgre::Input::InputMode>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventMouseMoved of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Input_EventMouseMoved
   12273  static int tolua_get_EmberOgre__Input_EventMouseMoved(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMouseMoved'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventMouseMoved,  "sigc::signal<void,  const EmberOgre::MouseMotion&,  EmberOgre::Input::InputMode>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventMouseMoved of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Input_EventMouseMoved
   12286  static int tolua_set_EmberOgre__Input_EventMouseMoved(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMouseMoved'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const EmberOgre::MouseMotion&,  EmberOgre::Input::InputMode>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventMouseMoved = *(  (  sigc::signal<void,  const EmberOgre::MouseMotion&,  EmberOgre::Input::InputMode>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventMouseButtonPressed of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Input_EventMouseButtonPressed
   12303  static int tolua_get_EmberOgre__Input_EventMouseButtonPressed(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMouseButtonPressed'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventMouseButtonPressed,  "sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventMouseButtonPressed of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Input_EventMouseButtonPressed
   12316  static int tolua_set_EmberOgre__Input_EventMouseButtonPressed(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMouseButtonPressed'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventMouseButtonPressed = *(  (  sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventMouseButtonReleased of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Input_EventMouseButtonReleased
   12333  static int tolua_get_EmberOgre__Input_EventMouseButtonReleased(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMouseButtonReleased'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventMouseButtonReleased,  "sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventMouseButtonReleased of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Input_EventMouseButtonReleased
   12346  static int tolua_set_EmberOgre__Input_EventMouseButtonReleased(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMouseButtonReleased'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventMouseButtonReleased = *(  (  sigc::signal<void,  EmberOgre::Input::MouseButton,  EmberOgre::Input::InputMode>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventChangedInputMode of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Input_EventChangedInputMode
   12363  static int tolua_get_EmberOgre__Input_EventChangedInputMode(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventChangedInputMode'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventChangedInputMode,  "sigc::signal<void,  EmberOgre::Input::InputMode>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventChangedInputMode of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Input_EventChangedInputMode
   12376  static int tolua_set_EmberOgre__Input_EventChangedInputMode(  lua_State* tolua_S )
          {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventChangedInputMode'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Input::InputMode>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventChangedInputMode = *(  (  sigc::signal<void,  EmberOgre::Input::InputMode>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isKeyDown of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Input_isKeyDown00
   12393  static int tolua_EmberOgre_EmberOgre_Input_isKeyDown00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Input",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const SDLKey",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Input* self = (  const EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
           const SDLKey* tolua_var_2 = (  (  const SDLKey* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isKeyDown'",  NULL );
          #endif
           {
           const bool tolua_ret = (  const bool ) self->isKeyDown(  *tolua_var_2 );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isKeyDown'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setInputMode of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Input_setInputMode00
   12427  static int tolua_EmberOgre_EmberOgre_Input_setInputMode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Input",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Input::InputMode mode = (  (  EmberOgre::Input::InputMode ) (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setInputMode'",  NULL );
          #endif
           {
           self->setInputMode(  mode );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setInputMode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getInputMode of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Input_getInputMode00
   12460  static int tolua_EmberOgre_EmberOgre_Input_getInputMode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Input",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Input* self = (  const EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getInputMode'",  NULL );
          #endif
           {
           EmberOgre::Input::InputMode tolua_ret = (  EmberOgre::Input::InputMode ) self->getInputMode(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInputMode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: toggleInputMode of class EmberOgre::Input */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Input_toggleInputMode00
   12492  static int tolua_EmberOgre_EmberOgre_Input_toggleInputMode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Input",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Input* self = (  EmberOgre::Input* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'toggleInputMode'",  NULL );
          #endif
           {
           EmberOgre::Input::InputMode tolua_ret = (  EmberOgre::Input::InputMode ) self->toggleInputMode(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'toggleInputMode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Jesus */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Jesus_new00
   12524  static int tolua_EmberOgre_EmberOgre_Jesus_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::Carpenter* carpenter = (  (  Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Jesus* tolua_ret = (  EmberOgre::Jesus* ) new EmberOgre::Jesus(  carpenter );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Jesus" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Jesus */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Jesus_new00_local
   12554  static int tolua_EmberOgre_EmberOgre_Jesus_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Carpenter::Carpenter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::Carpenter* carpenter = (  (  Carpenter::Carpenter* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Jesus* tolua_ret = (  EmberOgre::Jesus* ) new EmberOgre::Jesus(  carpenter );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Jesus" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Jesus */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Jesus_delete00
   12584  static int tolua_EmberOgre_EmberOgre_Jesus_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Jesus* self = (  EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createModelForBlockType of class EmberOgre::Jesus */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Jesus_createModelForBlockType00
   12613  static int tolua_EmberOgre_EmberOgre_Jesus_createModelForBlockType00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Jesus* self = (  EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string blockType = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string modelName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createModelForBlockType'",  NULL );
          #endif
           {
           EmberOgre::Model::Model* tolua_ret = (  EmberOgre::Model::Model* ) self->createModelForBlockType(  blockType,  modelName );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::Model" );
           tolua_pushcppstring(  tolua_S,  (  const char* )blockType );
           tolua_pushcppstring(  tolua_S,  (  const char* )modelName );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createModelForBlockType'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getColourForAttachPoint of class EmberOgre::Jesus */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Jesus_getColourForAttachPoint00
   12651  static int tolua_EmberOgre_EmberOgre_Jesus_getColourForAttachPoint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Jesus* self = (  const EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Carpenter::AttachPoint* point = (  (  const Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getColourForAttachPoint'",  NULL );
          #endif
           {
           Ogre::ColourValue tolua_ret = (  Ogre::ColourValue ) self->getColourForAttachPoint(  point );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ColourValue(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ColourValue ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getColourForAttachPoint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCarpenter of class EmberOgre::Jesus */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Jesus_getCarpenter00
   12693  static int tolua_EmberOgre_EmberOgre_Jesus_getCarpenter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Jesus* self = (  const EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCarpenter'",  NULL );
          #endif
           {
           Carpenter::Carpenter* tolua_ret = (  Carpenter::Carpenter* ) self->getCarpenter(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::Carpenter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCarpenter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addBluePrint of class EmberOgre::Jesus */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Jesus_addBluePrint00
   12725  static int tolua_EmberOgre_EmberOgre_Jesus_addBluePrint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Carpenter::BluePrint",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Jesus* self = (  EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  1,  0 );
           Carpenter::BluePrint* blueprint = (  (  Carpenter::BluePrint* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addBluePrint'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->addBluePrint(  blueprint );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addBluePrint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBluePrint of class EmberOgre::Jesus */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Jesus_getBluePrint00
   12759  static int tolua_EmberOgre_EmberOgre_Jesus_getBluePrint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Jesus* self = (  const EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBluePrint'",  NULL );
          #endif
           {
           Carpenter::BluePrint* tolua_ret = (  Carpenter::BluePrint* ) self->getBluePrint(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::BluePrint" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBluePrint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAllBluePrints of class EmberOgre::Jesus */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Jesus_getAllBluePrints00
   12794  static int tolua_EmberOgre_EmberOgre_Jesus_getAllBluePrints00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Jesus* self = (  const EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAllBluePrints'",  NULL );
          #endif
           {
           const std::map<std::string,  Carpenter::BluePrint*>* tolua_ret = (  const std::map<std::string,  Carpenter::BluePrint*>* ) self->getAllBluePrints(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const std::map<std::string,  Carpenter::BluePrint*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAllBluePrints'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::LightWibbler */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_LightWibbler_new00
   12826  static int tolua_EmberOgre_EmberOgre_LightWibbler_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LightWibbler",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::Billboard",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* originalColour = (  (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Billboard* billboard = (  (  Ogre::Billboard* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::LightWibbler* tolua_ret = (  EmberOgre::LightWibbler* ) new EmberOgre::LightWibbler(  *originalColour,  billboard );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::LightWibbler" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::LightWibbler */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_LightWibbler_new00_local
   12858  static int tolua_EmberOgre_EmberOgre_LightWibbler_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::LightWibbler",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::Billboard",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* originalColour = (  (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Billboard* billboard = (  (  Ogre::Billboard* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::LightWibbler* tolua_ret = (  EmberOgre::LightWibbler* ) new EmberOgre::LightWibbler(  *originalColour,  billboard );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::LightWibbler" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getValue of class EmberOgre::LightWibbler */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_LightWibbler_getValue00
   12890  static int tolua_EmberOgre_EmberOgre_LightWibbler_getValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::LightWibbler",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::LightWibbler* self = (  const EmberOgre::LightWibbler* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getValue'",  NULL );
          #endif
           {
           Ogre::Real tolua_ret = (  Ogre::Real ) self->getValue(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Real(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Real" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Real ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Real" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setValue of class EmberOgre::LightWibbler */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_LightWibbler_setValue00
   12930  static int tolua_EmberOgre_EmberOgre_LightWibbler_setValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::LightWibbler",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Real",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::LightWibbler* self = (  EmberOgre::LightWibbler* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Real value = *(  (  Ogre::Real* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setValue'",  NULL );
          #endif
           {
           self->setValue(  value );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::AttachPointNode */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AttachPointNode_new00
   12963  static int tolua_EmberOgre_EmberOgre_AttachPointNode_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::AttachPointNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "Ogre::BillboardSet",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::ModelBlock* modelBlock = (  (  EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::SceneNode* modelNode = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Carpenter::AttachPoint* attachPoint = (  (  const Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           Ogre::ColourValue colour = *(  (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           Ogre::BillboardSet* billboardSet = (  (  Ogre::BillboardSet* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           EmberOgre::AttachPointNode* tolua_ret = (  EmberOgre::AttachPointNode* ) new EmberOgre::AttachPointNode(  modelBlock,  modelNode,  attachPoint,  colour,  billboardSet );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::AttachPointNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::AttachPointNode */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AttachPointNode_new00_local
   13001  static int tolua_EmberOgre_EmberOgre_AttachPointNode_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::AttachPointNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Carpenter::AttachPoint",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "Ogre::BillboardSet",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::ModelBlock* modelBlock = (  (  EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::SceneNode* modelNode = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Carpenter::AttachPoint* attachPoint = (  (  const Carpenter::AttachPoint* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           Ogre::ColourValue colour = *(  (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           Ogre::BillboardSet* billboardSet = (  (  Ogre::BillboardSet* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           EmberOgre::AttachPointNode* tolua_ret = (  EmberOgre::AttachPointNode* ) new EmberOgre::AttachPointNode(  modelBlock,  modelNode,  attachPoint,  colour,  billboardSet );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::AttachPointNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::AttachPointNode */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AttachPointNode_delete00
   13039  static int tolua_EmberOgre_EmberOgre_AttachPointNode_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AttachPointNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AttachPointNode* self = (  EmberOgre::AttachPointNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: select of class EmberOgre::AttachPointNode */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AttachPointNode_select00
   13068  static int tolua_EmberOgre_EmberOgre_AttachPointNode_select00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AttachPointNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AttachPointNode* self = (  EmberOgre::AttachPointNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'select'",  NULL );
          #endif
           {
           self->select(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'select'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: deselect of class EmberOgre::AttachPointNode */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AttachPointNode_deselect00
   13099  static int tolua_EmberOgre_EmberOgre_AttachPointNode_deselect00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AttachPointNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AttachPointNode* self = (  EmberOgre::AttachPointNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'deselect'",  NULL );
          #endif
           {
           self->deselect(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'deselect'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttachPoint of class EmberOgre::AttachPointNode */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AttachPointNode_getAttachPoint00
   13130  static int tolua_EmberOgre_EmberOgre_AttachPointNode_getAttachPoint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AttachPointNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AttachPointNode* self = (  EmberOgre::AttachPointNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttachPoint'",  NULL );
          #endif
           {
           const Carpenter::AttachPoint* tolua_ret = (  const Carpenter::AttachPoint* ) self->getAttachPoint(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const Carpenter::AttachPoint" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttachPoint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_new00
   13162  static int tolua_EmberOgre_EmberOgre_ModelBlock_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Carpenter::BuildingBlock",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* baseNode = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Carpenter::BuildingBlock* buildingBlock = (  (  const Carpenter::BuildingBlock* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           EmberOgre::Model::Model* model = (  (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           EmberOgre::Construction* construction = (  (  EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::ModelBlock* tolua_ret = (  EmberOgre::ModelBlock* ) new EmberOgre::ModelBlock(  baseNode,  buildingBlock,  model,  construction );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::ModelBlock" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_new00_local
   13198  static int tolua_EmberOgre_EmberOgre_ModelBlock_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Carpenter::BuildingBlock",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "EmberOgre::Model::Model",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* baseNode = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Carpenter::BuildingBlock* buildingBlock = (  (  const Carpenter::BuildingBlock* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           EmberOgre::Model::Model* model = (  (  EmberOgre::Model::Model* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           EmberOgre::Construction* construction = (  (  EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::ModelBlock* tolua_ret = (  EmberOgre::ModelBlock* ) new EmberOgre::ModelBlock(  baseNode,  buildingBlock,  model,  construction );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::ModelBlock" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_delete00
   13234  static int tolua_EmberOgre_EmberOgre_ModelBlock_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::ModelBlock* self = (  EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBuildingBlock of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_getBuildingBlock00
   13263  static int tolua_EmberOgre_EmberOgre_ModelBlock_getBuildingBlock00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::ModelBlock* self = (  EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBuildingBlock'",  NULL );
          #endif
           {
           const Carpenter::BuildingBlock* tolua_ret = (  const Carpenter::BuildingBlock* ) self->getBuildingBlock(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const Carpenter::BuildingBlock" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBuildingBlock'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getConstruction of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_getConstruction00
   13295  static int tolua_EmberOgre_EmberOgre_ModelBlock_getConstruction00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::ModelBlock* self = (  const EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getConstruction'",  NULL );
          #endif
           {
           EmberOgre::Construction* tolua_ret = (  EmberOgre::Construction* ) self->getConstruction(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Construction" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getConstruction'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createAttachPointNodes of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_createAttachPointNodes00
   13327  static int tolua_EmberOgre_EmberOgre_ModelBlock_createAttachPointNodes00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::ModelBlock* self = (  EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createAttachPointNodes'",  NULL );
          #endif
           {
           self->createAttachPointNodes(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createAttachPointNodes'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: select of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_select00
   13358  static int tolua_EmberOgre_EmberOgre_ModelBlock_select00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::ModelBlock* self = (  EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'select'",  NULL );
          #endif
           {
           self->select(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'select'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: deselect of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_deselect00
   13389  static int tolua_EmberOgre_EmberOgre_ModelBlock_deselect00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::ModelBlock* self = (  EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'deselect'",  NULL );
          #endif
           {
           self->deselect(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'deselect'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttachPointNodes of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_getAttachPointNodes00
   13420  static int tolua_EmberOgre_EmberOgre_ModelBlock_getAttachPointNodes00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::ModelBlock* self = (  const EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttachPointNodes'",  NULL );
          #endif
           {
           std::vector<EmberOgre::AttachPointNode*> tolua_ret = (  std::vector<EmberOgre::AttachPointNode*> ) self->getAttachPointNodes(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::vector<EmberOgre::AttachPointNode*>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<EmberOgre::AttachPointNode*>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::vector<EmberOgre::AttachPointNode*> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<EmberOgre::AttachPointNode*>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttachPointNodes'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getModel of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_getModel00
   13460  static int tolua_EmberOgre_EmberOgre_ModelBlock_getModel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::ModelBlock* self = (  const EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getModel'",  NULL );
          #endif
           {
           const EmberOgre::Model::Model* tolua_ret = (  const EmberOgre::Model::Model* ) self->getModel(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const EmberOgre::Model::Model" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getModel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNode of class EmberOgre::ModelBlock */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_ModelBlock_getNode00
   13492  static int tolua_EmberOgre_EmberOgre_ModelBlock_getNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::ModelBlock* self = (  const EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNode'",  NULL );
          #endif
           {
           const Ogre::SceneNode* tolua_ret = (  const Ogre::SceneNode* ) self->getNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: model of class EmberOgre::ModelMapping */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__ModelMapping_model
   13524  static int tolua_get_EmberOgre__ModelMapping_model(  lua_State* tolua_S )
          {
           EmberOgre::ModelMapping* self = (  EmberOgre::ModelMapping* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'model'",  NULL );
          #endif
           tolua_pushcppstring(  tolua_S,  (  const char* )self->model );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: blocktype of class EmberOgre::ModelMapping */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__ModelMapping_blocktype
   13537  static int tolua_get_EmberOgre__ModelMapping_blocktype(  lua_State* tolua_S )
          {
           EmberOgre::ModelMapping* self = (  EmberOgre::ModelMapping* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'blocktype'",  NULL );
          #endif
           tolua_pushcppstring(  tolua_S,  (  const char* )self->blocktype );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Construction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Construction_new00
   13550  static int tolua_EmberOgre_EmberOgre_Construction_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Carpenter::BluePrint",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::BluePrint* blueprint = (  (  Carpenter::BluePrint* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           EmberOgre::Jesus* jesus = (  (  EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           Ogre::SceneNode* node = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           EmberOgre::Construction* tolua_ret = (  EmberOgre::Construction* ) new EmberOgre::Construction(  blueprint,  jesus,  node );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Construction" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Construction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Construction_new00_local
   13584  static int tolua_EmberOgre_EmberOgre_Construction_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Carpenter::BluePrint",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::Jesus",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Carpenter::BluePrint* blueprint = (  (  Carpenter::BluePrint* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           EmberOgre::Jesus* jesus = (  (  EmberOgre::Jesus* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           Ogre::SceneNode* node = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           EmberOgre::Construction* tolua_ret = (  EmberOgre::Construction* ) new EmberOgre::Construction(  blueprint,  jesus,  node );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Construction" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Construction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Construction_delete00
   13618  static int tolua_EmberOgre_EmberOgre_Construction_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Construction* self = (  EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getJesus of class EmberOgre::Construction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Construction_getJesus00
   13647  static int tolua_EmberOgre_EmberOgre_Construction_getJesus00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Construction* self = (  const EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getJesus'",  NULL );
          #endif
           {
           EmberOgre::Jesus* tolua_ret = (  EmberOgre::Jesus* ) self->getJesus(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Jesus" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getJesus'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBluePrint of class EmberOgre::Construction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Construction_getBluePrint00
   13679  static int tolua_EmberOgre_EmberOgre_Construction_getBluePrint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Construction* self = (  const EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBluePrint'",  NULL );
          #endif
           {
           Carpenter::BluePrint* tolua_ret = (  Carpenter::BluePrint* ) self->getBluePrint(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Carpenter::BluePrint" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBluePrint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: buildFromBluePrint of class EmberOgre::Construction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Construction_buildFromBluePrint00
   13711  static int tolua_EmberOgre_EmberOgre_Construction_buildFromBluePrint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Construction* self = (  EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool createAttachPointNodes = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'buildFromBluePrint'",  NULL );
          #endif
           {
           self->buildFromBluePrint(  createAttachPointNodes );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'buildFromBluePrint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createModelBlock of class EmberOgre::Construction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Construction_createModelBlock00
   13744  static int tolua_EmberOgre_EmberOgre_Construction_createModelBlock00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Carpenter::BuildingBlock",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Construction* self = (  EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Carpenter::BuildingBlock* buildingBlock = (  (  const Carpenter::BuildingBlock* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           bool createAttachPointNodes = (  (  bool ) tolua_toboolean(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createModelBlock'",  NULL );
          #endif
           {
           EmberOgre::ModelBlock* tolua_ret = (  EmberOgre::ModelBlock* ) self->createModelBlock(  buildingBlock,  createAttachPointNodes );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::ModelBlock" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createModelBlock'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getModelBlocks of class EmberOgre::Construction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Construction_getModelBlocks00
   13780  static int tolua_EmberOgre_EmberOgre_Construction_getModelBlocks00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Construction* self = (  const EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getModelBlocks'",  NULL );
          #endif
           {
           std::vector<EmberOgre::ModelBlock*> tolua_ret = (  std::vector<EmberOgre::ModelBlock*> ) self->getModelBlocks(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::vector<EmberOgre::ModelBlock*>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<EmberOgre::ModelBlock*>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::vector<EmberOgre::ModelBlock*> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<EmberOgre::ModelBlock*>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getModelBlocks'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: remove of class EmberOgre::Construction */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Construction_remove00
   13820  static int tolua_EmberOgre_EmberOgre_Construction_remove00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Construction",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::ModelBlock",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Construction* self = (  EmberOgre::Construction* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::ModelBlock* modelBlock = (  (  EmberOgre::ModelBlock* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'remove'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->remove(  modelBlock );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'remove'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isValid of class EmberOgre::TerrainPosition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_TerrainPosition_isValid00
   13854  static int tolua_EmberOgre_EmberOgre_TerrainPosition_isValid00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::TerrainPosition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::TerrainPosition* self = (  const EmberOgre::TerrainPosition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isValid'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isValid(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isValid'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setToOrigin of class EmberOgre::TerrainPosition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_TerrainPosition_setToOrigin00
   13886  static int tolua_EmberOgre_EmberOgre_TerrainPosition_setToOrigin00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::TerrainPosition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::TerrainPosition* self = (  EmberOgre::TerrainPosition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setToOrigin'",  NULL );
          #endif
           {
           EmberOgre::TerrainPosition& tolua_ret = (  EmberOgre::TerrainPosition& ) self->setToOrigin(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::TerrainPosition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setToOrigin'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: x of class EmberOgre::TerrainPosition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_TerrainPosition_x00
   13918  static int tolua_EmberOgre_EmberOgre_TerrainPosition_x00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::TerrainPosition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::TerrainPosition* self = (  const EmberOgre::TerrainPosition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'x'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->x(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'x'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: x of class EmberOgre::TerrainPosition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_TerrainPosition_x01
   13950  static int tolua_EmberOgre_EmberOgre_TerrainPosition_x01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::TerrainPosition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::TerrainPosition* self = (  EmberOgre::TerrainPosition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'x'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->x(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_TerrainPosition_x00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: y of class EmberOgre::TerrainPosition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_TerrainPosition_y00
   13977  static int tolua_EmberOgre_EmberOgre_TerrainPosition_y00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::TerrainPosition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::TerrainPosition* self = (  const EmberOgre::TerrainPosition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'y'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->y(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'y'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: y of class EmberOgre::TerrainPosition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_TerrainPosition_y01
   14009  static int tolua_EmberOgre_EmberOgre_TerrainPosition_y01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::TerrainPosition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::TerrainPosition* self = (  EmberOgre::TerrainPosition* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'y'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->y(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_TerrainPosition_y00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* function: EmberOgre::Atlas2Ogre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Atlas2Ogre00
   14036  static int tolua_EmberOgre_EmberOgre_Atlas2Ogre00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::TerrainPosition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::TerrainPosition* p = (  (  const EmberOgre::TerrainPosition* ) tolua_tousertype(  tolua_S,  1,  0 ) );
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) EmberOgre::Atlas2Ogre(  *p );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Atlas2Ogre'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* function: EmberOgre::Ogre2Atlas */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Ogre2Atlas00
   14073  static int tolua_EmberOgre_EmberOgre_Ogre2Atlas00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* p = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 ) );
           {
           WFMath::Point<3> tolua_ret = (  WFMath::Point<3> ) EmberOgre::Ogre2Atlas(  *p );
           {
          #ifdef __cplusplus
           void* tolua_obj = new WFMath::Point<3>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Point<3>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  WFMath::Point<3> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Point<3>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Ogre2Atlas'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* function: EmberOgre::Ogre2Atlas */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Ogre2Atlas01
   14110  static int tolua_EmberOgre_EmberOgre_Ogre2Atlas01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Vector2",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Vector2* p = (  (  const Ogre::Vector2* ) tolua_tousertype(  tolua_S,  1,  0 ) );
           {
           EmberOgre::TerrainPosition tolua_ret = (  EmberOgre::TerrainPosition ) EmberOgre::Ogre2Atlas(  *p );
           {
          #ifdef __cplusplus
           void* tolua_obj = new EmberOgre::TerrainPosition(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::TerrainPosition" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  EmberOgre::TerrainPosition ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::TerrainPosition" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Ogre2Atlas00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* function: EmberOgre::Ogre2Atlas_TerrainPosition */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Ogre2Atlas_TerrainPosition00
   14142  static int tolua_EmberOgre_EmberOgre_Ogre2Atlas_TerrainPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* p = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 ) );
           {
           EmberOgre::TerrainPosition tolua_ret = (  EmberOgre::TerrainPosition ) EmberOgre::Ogre2Atlas_TerrainPosition(  *p );
           {
          #ifdef __cplusplus
           void* tolua_obj = new EmberOgre::TerrainPosition(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::TerrainPosition" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  EmberOgre::TerrainPosition ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::TerrainPosition" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Ogre2Atlas_TerrainPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* function: EmberOgre::Ogre2Atlas_Vector3 */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Ogre2Atlas_Vector300
   14179  static int tolua_EmberOgre_EmberOgre_Ogre2Atlas_Vector300(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* p = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 ) );
           {
           WFMath::Vector<3> tolua_ret = (  WFMath::Vector<3> ) EmberOgre::Ogre2Atlas_Vector3(  *p );
           {
          #ifdef __cplusplus
           void* tolua_obj = new WFMath::Vector<3>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Vector<3>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  WFMath::Vector<3> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Vector<3>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Ogre2Atlas_Vector3'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* function: EmberOgre::Atlas2Ogre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Atlas2Ogre01
   14216  static int tolua_EmberOgre_EmberOgre_Atlas2Ogre01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const WFMath::Point<3>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const WFMath::Point<3>* p = (  (  const WFMath::Point<3>* ) tolua_tousertype(  tolua_S,  1,  0 ) );
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) EmberOgre::Atlas2Ogre(  *p );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Atlas2Ogre00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* function: EmberOgre::Atlas2Ogre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Atlas2Ogre02
   14248  static int tolua_EmberOgre_EmberOgre_Atlas2Ogre02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const WFMath::Vector<3>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const WFMath::Vector<3>* v = (  (  const WFMath::Vector<3>* ) tolua_tousertype(  tolua_S,  1,  0 ) );
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) EmberOgre::Atlas2Ogre(  *v );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Atlas2Ogre01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* function: EmberOgre::Atlas2Ogre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Atlas2Ogre03
   14280  static int tolua_EmberOgre_EmberOgre_Atlas2Ogre03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const WFMath::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const WFMath::Quaternion* aq = (  (  const WFMath::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 ) );
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) EmberOgre::Atlas2Ogre(  *aq );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Atlas2Ogre02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* function: EmberOgre::Ogre2Atlas */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Ogre2Atlas02
   14312  static int tolua_EmberOgre_EmberOgre_Ogre2Atlas02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Quaternion* aq = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 ) );
           {
           WFMath::Quaternion tolua_ret = (  WFMath::Quaternion ) EmberOgre::Ogre2Atlas(  *aq );
           {
          #ifdef __cplusplus
           void* tolua_obj = new WFMath::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  WFMath::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Ogre2Atlas01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showFull of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_showFull00
   14344  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_showFull00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showFull'",  NULL );
          #endif
           {
           self->showFull(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showFull'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setCameraDistance of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setCameraDistance00
   14375  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setCameraDistance00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           float distance = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setCameraDistance'",  NULL );
          #endif
           {
           self->setCameraDistance(  distance );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setCameraDistance'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCameraDistance of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getCameraDistance00
   14408  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getCameraDistance00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCameraDistance'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getCameraDistance(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCameraDistance'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAbsoluteCameraDistance of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getAbsoluteCameraDistance00
   14440  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getAbsoluteCameraDistance00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAbsoluteCameraDistance'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getAbsoluteCameraDistance(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAbsoluteCameraDistance'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getIsInputCatchingAllowed of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getIsInputCatchingAllowed00
   14472  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getIsInputCatchingAllowed00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::MovableObjectRenderer* self = (  const EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getIsInputCatchingAllowed'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getIsInputCatchingAllowed(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getIsInputCatchingAllowed'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setIsInputCatchingAllowed of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setIsInputCatchingAllowed00
   14504  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setIsInputCatchingAllowed00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool allowed = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setIsInputCatchingAllowed'",  NULL );
          #endif
           {
           self->setIsInputCatchingAllowed(  allowed );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setIsInputCatchingAllowed'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAutoShowFull of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setAutoShowFull00
   14537  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setAutoShowFull00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool showFull = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAutoShowFull'",  NULL );
          #endif
           {
           self->setAutoShowFull(  showFull );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAutoShowFull'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAutoShowFull of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getAutoShowFull00
   14570  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getAutoShowFull00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::MovableObjectRenderer* self = (  const EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAutoShowFull'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getAutoShowFull(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAutoShowFull'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getActive of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getActive00
   14602  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getActive00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::MovableObjectRenderer* self = (  const EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getActive'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getActive(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getActive'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setActive of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setActive00
   14634  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setActive00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool isActive = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setActive'",  NULL );
          #endif
           {
           self->setActive(  isActive );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setActive'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntityRotation of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getEntityRotation00
   14667  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getEntityRotation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntityRotation'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->getEntityRotation(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntityRotation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: resetCameraOrientation of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_resetCameraOrientation00
   14707  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_resetCameraOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'resetCameraOrientation'",  NULL );
          #endif
           {
           self->resetCameraOrientation(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'resetCameraOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: pitch of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_pitch00
   14738  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_pitch00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Degree degrees = *(  (  Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'pitch'",  NULL );
          #endif
           {
           self->pitch(  degrees );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'pitch'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: yaw of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_yaw00
   14771  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_yaw00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Degree degrees = *(  (  Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'yaw'",  NULL );
          #endif
           {
           self->yaw(  degrees );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'yaw'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: roll of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_roll00
   14804  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_roll00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Degree degrees = *(  (  Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'roll'",  NULL );
          #endif
           {
           self->roll(  degrees );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'roll'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: updateRender of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_updateRender00
   14837  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_updateRender00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'updateRender'",  NULL );
          #endif
           {
           self->updateRender(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'updateRender'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setBackgroundColour of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setBackgroundColour00
   14868  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setBackgroundColour00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::ColourValue* colour = (  (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setBackgroundColour'",  NULL );
          #endif
           {
           self->setBackgroundColour(  *colour );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setBackgroundColour'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setBackgroundColour of class EmberOgre::Gui::MovableObjectRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setBackgroundColour01
   14901  static int tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setBackgroundColour01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::MovableObjectRenderer",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::Gui::MovableObjectRenderer* self = (  EmberOgre::Gui::MovableObjectRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           float red = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float green = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float blue = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           float alpha = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setBackgroundColour'",  NULL );
          #endif
           {
           self->setBackgroundColour(  red,  green,  blue,  alpha );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setBackgroundColour00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::OgreEntityRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_new00
   14935  static int tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::OgreEntityRenderer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* image = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::OgreEntityRenderer* tolua_ret = (  EmberOgre::Gui::OgreEntityRenderer* ) new EmberOgre::Gui::OgreEntityRenderer(  image );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::OgreEntityRenderer" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::OgreEntityRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_new00_local
   14965  static int tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::OgreEntityRenderer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* image = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::OgreEntityRenderer* tolua_ret = (  EmberOgre::Gui::OgreEntityRenderer* ) new EmberOgre::Gui::OgreEntityRenderer(  image );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::OgreEntityRenderer" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::OgreEntityRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_delete00
   14995  static int tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::OgreEntityRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::OgreEntityRenderer* self = (  EmberOgre::Gui::OgreEntityRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showEntity of class EmberOgre::Gui::OgreEntityRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_showEntity00
   15024  static int tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_showEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::OgreEntityRenderer",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::OgreEntityRenderer* self = (  EmberOgre::Gui::OgreEntityRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string mesh = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showEntity'",  NULL );
          #endif
           {
           self->showEntity(  mesh );
           tolua_pushcppstring(  tolua_S,  (  const char* )mesh );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntity of class EmberOgre::Gui::OgreEntityRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_getEntity00
   15058  static int tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_getEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::OgreEntityRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::OgreEntityRenderer* self = (  EmberOgre::Gui::OgreEntityRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntity'",  NULL );
          #endif
           {
           Ogre::Entity* tolua_ret = (  Ogre::Entity* ) self->getEntity(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Entity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::ModelRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_new00
   15090  static int tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::ModelRenderer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* image = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::ModelRenderer* tolua_ret = (  EmberOgre::Gui::ModelRenderer* ) new EmberOgre::Gui::ModelRenderer(  image );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::ModelRenderer" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::ModelRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_new00_local
   15120  static int tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::ModelRenderer",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* image = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::ModelRenderer* tolua_ret = (  EmberOgre::Gui::ModelRenderer* ) new EmberOgre::Gui::ModelRenderer(  image );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::ModelRenderer" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::ModelRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_delete00
   15150  static int tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::ModelRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::ModelRenderer* self = (  EmberOgre::Gui::ModelRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showModel of class EmberOgre::Gui::ModelRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_showModel00
   15179  static int tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_showModel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::ModelRenderer",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::ModelRenderer* self = (  EmberOgre::Gui::ModelRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string modelName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showModel'",  NULL );
          #endif
           {
           self->showModel(  modelName );
           tolua_pushcppstring(  tolua_S,  (  const char* )modelName );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showModel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getModel of class EmberOgre::Gui::ModelRenderer */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_getModel00
   15213  static int tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_getModel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::ModelRenderer",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::ModelRenderer* self = (  EmberOgre::Gui::ModelRenderer* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getModel'",  NULL );
          #endif
           {
           EmberOgre::Model::Model* tolua_ret = (  EmberOgre::Model::Model* ) self->getModel(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::Model" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getModel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::ListHolder */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ListHolder_new00
   15245  static int tolua_EmberOgre_EmberOgre_Gui_ListHolder_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::ListHolder",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Listbox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Editbox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Listbox* listbox = (  (  CEGUI::Listbox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Editbox* filterEditbox = (  (  CEGUI::Editbox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::ListHolder* tolua_ret = (  EmberOgre::Gui::ListHolder* ) new EmberOgre::Gui::ListHolder(  listbox,  filterEditbox );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::ListHolder" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::ListHolder */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ListHolder_new00_local
   15277  static int tolua_EmberOgre_EmberOgre_Gui_ListHolder_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::ListHolder",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Listbox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Editbox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Listbox* listbox = (  (  CEGUI::Listbox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Editbox* filterEditbox = (  (  CEGUI::Editbox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::ListHolder* tolua_ret = (  EmberOgre::Gui::ListHolder* ) new EmberOgre::Gui::ListHolder(  listbox,  filterEditbox );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::ListHolder" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::ListHolder */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ListHolder_delete00
   15309  static int tolua_EmberOgre_EmberOgre_Gui_ListHolder_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::ListHolder",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::ListHolder* self = (  EmberOgre::Gui::ListHolder* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addItem of class EmberOgre::Gui::ListHolder */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ListHolder_addItem00
   15338  static int tolua_EmberOgre_EmberOgre_Gui_ListHolder_addItem00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::ListHolder",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::ListboxItem",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::ListHolder* self = (  EmberOgre::Gui::ListHolder* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::ListboxItem* item = (  (  CEGUI::ListboxItem* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addItem'",  NULL );
          #endif
           {
           self->addItem(  item );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addItem'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: insertItem of class EmberOgre::Gui::ListHolder */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ListHolder_insertItem00
   15371  static int tolua_EmberOgre_EmberOgre_Gui_ListHolder_insertItem00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::ListHolder",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::ListboxItem",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const CEGUI::ListboxItem",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::ListHolder* self = (  EmberOgre::Gui::ListHolder* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::ListboxItem* item = (  (  CEGUI::ListboxItem* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const CEGUI::ListboxItem* position = (  (  const CEGUI::ListboxItem* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'insertItem'",  NULL );
          #endif
           {
           self->insertItem(  item,  position );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'insertItem'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeItem of class EmberOgre::Gui::ListHolder */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ListHolder_removeItem00
   15406  static int tolua_EmberOgre_EmberOgre_Gui_ListHolder_removeItem00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::ListHolder",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const CEGUI::ListboxItem",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::ListHolder* self = (  EmberOgre::Gui::ListHolder* ) tolua_tousertype(  tolua_S,  1,  0 );
           const CEGUI::ListboxItem* item = (  (  const CEGUI::ListboxItem* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeItem'",  NULL );
          #endif
           {
           self->removeItem(  item );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeItem'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: resetList of class EmberOgre::Gui::ListHolder */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_ListHolder_resetList00
   15439  static int tolua_EmberOgre_EmberOgre_Gui_ListHolder_resetList00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::ListHolder",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::ListHolder* self = (  EmberOgre::Gui::ListHolder* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'resetList'",  NULL );
          #endif
           {
           self->resetList(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'resetList'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: windowX of class EmberOgre::MousePickerArgs */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MousePickerArgs_windowX
   15470  static int tolua_get_EmberOgre__MousePickerArgs_windowX(  lua_State* tolua_S )
          {
           EmberOgre::MousePickerArgs* self = (  EmberOgre::MousePickerArgs* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'windowX'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->windowX );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: windowX of class EmberOgre::MousePickerArgs */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MousePickerArgs_windowX
   15483  static int tolua_set_EmberOgre__MousePickerArgs_windowX(  lua_State* tolua_S )
          {
           EmberOgre::MousePickerArgs* self = (  EmberOgre::MousePickerArgs* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'windowX'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->windowX = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: windowY of class EmberOgre::MousePickerArgs */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MousePickerArgs_windowY
   15500  static int tolua_get_EmberOgre__MousePickerArgs_windowY(  lua_State* tolua_S )
          {
           EmberOgre::MousePickerArgs* self = (  EmberOgre::MousePickerArgs* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'windowY'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->windowY );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: windowY of class EmberOgre::MousePickerArgs */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MousePickerArgs_windowY
   15513  static int tolua_set_EmberOgre__MousePickerArgs_windowY(  lua_State* tolua_S )
          {
           EmberOgre::MousePickerArgs* self = (  EmberOgre::MousePickerArgs* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'windowY'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->windowY = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: pickType of class EmberOgre::MousePickerArgs */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__MousePickerArgs_pickType
   15530  static int tolua_get_EmberOgre__MousePickerArgs_pickType(  lua_State* tolua_S )
          {
           EmberOgre::MousePickerArgs* self = (  EmberOgre::MousePickerArgs* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'pickType'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->pickType );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: pickType of class EmberOgre::MousePickerArgs */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__MousePickerArgs_pickType
   15543  static int tolua_set_EmberOgre__MousePickerArgs_pickType(  lua_State* tolua_S )
          {
           EmberOgre::MousePickerArgs* self = (  EmberOgre::MousePickerArgs* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'pickType'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->pickType = (  (  EmberOgre::MousePickType ) (  int ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: entity of class EmberOgre::EntityPickResult */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EntityPickResult_entity_ptr
   15560  static int tolua_get_EmberOgre__EntityPickResult_entity_ptr(  lua_State* tolua_S )
          {
           EmberOgre::EntityPickResult* self = (  EmberOgre::EntityPickResult* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'entity'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )self->entity,  "EmberOgre::EmberEntity" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: entity of class EmberOgre::EntityPickResult */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EntityPickResult_entity_ptr
   15573  static int tolua_set_EmberOgre__EntityPickResult_entity_ptr(  lua_State* tolua_S )
          {
           EmberOgre::EntityPickResult* self = (  EmberOgre::EntityPickResult* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'entity'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "EmberOgre::EmberEntity",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->entity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: position of class EmberOgre::EntityPickResult */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EntityPickResult_position
   15590  static int tolua_get_EmberOgre__EntityPickResult_position(  lua_State* tolua_S )
          {
           EmberOgre::EntityPickResult* self = (  EmberOgre::EntityPickResult* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'position'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->position,  "Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: position of class EmberOgre::EntityPickResult */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EntityPickResult_position
   15603  static int tolua_set_EmberOgre__EntityPickResult_position(  lua_State* tolua_S )
          {
           EmberOgre::EntityPickResult* self = (  EmberOgre::EntityPickResult* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'position'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Vector3",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->position = *(  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: distance of class EmberOgre::EntityPickResult */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EntityPickResult_distance
   15620  static int tolua_get_EmberOgre__EntityPickResult_distance(  lua_State* tolua_S )
          {
           EmberOgre::EntityPickResult* self = (  EmberOgre::EntityPickResult* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'distance'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->distance,  "Ogre::Real" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: distance of class EmberOgre::EntityPickResult */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EntityPickResult_distance
   15633  static int tolua_set_EmberOgre__EntityPickResult_distance(  lua_State* tolua_S )
          {
           EmberOgre::EntityPickResult* self = (  EmberOgre::EntityPickResult* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'distance'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Real",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->distance = *(  (  Ogre::Real* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventPickedEntity of class EmberOgre::EntityWorldPickListener */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EntityWorldPickListener_EventPickedEntity
   15650  static int tolua_get_EmberOgre__EntityWorldPickListener_EventPickedEntity(  lua_State* tolua_S )
          {
           EmberOgre::EntityWorldPickListener* self = (  EmberOgre::EntityWorldPickListener* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventPickedEntity'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventPickedEntity,  "sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventPickedEntity of class EmberOgre::EntityWorldPickListener */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EntityWorldPickListener_EventPickedEntity
   15663  static int tolua_set_EmberOgre__EntityWorldPickListener_EventPickedEntity(  lua_State* tolua_S )
          {
           EmberOgre::EntityWorldPickListener* self = (  EmberOgre::EntityWorldPickListener* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventPickedEntity'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventPickedEntity = *(  (  sigc::signal<void,  const EmberOgre::EntityPickResult&,  const EmberOgre::MousePickerArgs&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getSingleton00
   15680  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::Model::ModelDefinitionManager& tolua_ret = (  EmberOgre::Model::ModelDefinitionManager& ) EmberOgre::Model::ModelDefinitionManager::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::Model::ModelDefinitionManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: exportScript of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_exportScript00
   15708  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_exportScript00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::ModelDefnPtr",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinitionManager* self = (  EmberOgre::Model::ModelDefinitionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::ModelDefnPtr definition = *(  (  EmberOgre::Model::ModelDefnPtr* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'exportScript'",  NULL );
          #endif
           {
           self->exportScript(  definition );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'exportScript'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: create of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_create00
   15741  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_create00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinitionManager* self = (  EmberOgre::Model::ModelDefinitionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string group = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'create'",  NULL );
          #endif
           {
           EmberOgre::Model::ModelDefnPtr tolua_ret = (  EmberOgre::Model::ModelDefnPtr ) self->create(  name,  group );
           {
          #ifdef __cplusplus
           void* tolua_obj = new EmberOgre::Model::ModelDefnPtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::Model::ModelDefnPtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  EmberOgre::Model::ModelDefnPtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::Model::ModelDefnPtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           tolua_pushcppstring(  tolua_S,  (  const char* )group );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'create'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: remove of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_remove00
   15787  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_remove00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinitionManager* self = (  EmberOgre::Model::ModelDefinitionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'remove'",  NULL );
          #endif
           {
           self->remove(  name );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'remove'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getByName of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getByName00
   15821  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getByName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinitionManager* self = (  EmberOgre::Model::ModelDefinitionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getByName'",  NULL );
          #endif
           {
           EmberOgre::Model::ModelDefnPtr tolua_ret = (  EmberOgre::Model::ModelDefnPtr ) self->getByName(  name );
           {
          #ifdef __cplusplus
           void* tolua_obj = new EmberOgre::Model::ModelDefnPtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::Model::ModelDefnPtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  EmberOgre::Model::ModelDefnPtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "EmberOgre::Model::ModelDefnPtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getByName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: resourceExists of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_resourceExists00
   15864  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_resourceExists00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinitionManager* self = (  EmberOgre::Model::ModelDefinitionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'resourceExists'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->resourceExists(  name );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'resourceExists'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getResourceIterator of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getResourceIterator00
   15899  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getResourceIterator00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinitionManager* self = (  EmberOgre::Model::ModelDefinitionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getResourceIterator'",  NULL );
          #endif
           {
           Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> tolua_ret = (  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> ) self->getResourceIterator(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getResourceIterator'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAllMeshes of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getAllMeshes00
   15939  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getAllMeshes00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::ModelDefinitionManager* self = (  const EmberOgre::Model::ModelDefinitionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAllMeshes'",  NULL );
          #endif
           {
           const std::vector<std::string> tolua_ret = (  const std::vector<std::string> ) self->getAllMeshes(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::vector<std::string>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "const std::vector<std::string>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  const std::vector<std::string> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "const std::vector<std::string>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAllMeshes'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getShowModels of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getShowModels00
   15979  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getShowModels00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Model::ModelDefinitionManager* self = (  const EmberOgre::Model::ModelDefinitionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getShowModels'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getShowModels(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getShowModels'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setShowModels of class EmberOgre::Model::ModelDefinitionManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_setShowModels00
   16011  static int tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_setShowModels00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Model::ModelDefinitionManager",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Model::ModelDefinitionManager* self = (  EmberOgre::Model::ModelDefinitionManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool show = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setShowModels'",  NULL );
          #endif
           {
           self->setShowModels(  show );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setShowModels'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: startMove of class EmberOgre::EntityMoveManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EntityMoveManager_startMove00
   16044  static int tolua_EmberOgre_EmberOgre_EntityMoveManager_startMove00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EntityMoveManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::EmberEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EntityMoveManager* self = (  EmberOgre::EntityMoveManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::EmberEntity* entity = (  (  EmberOgre::EmberEntity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'startMove'",  NULL );
          #endif
           {
           self->startMove(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'startMove'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: runCommand of class EmberOgre::EntityMoveManager */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EntityMoveManager_runCommand00
   16077  static int tolua_EmberOgre_EmberOgre_EntityMoveManager_runCommand00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EntityMoveManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EntityMoveManager* self = (  EmberOgre::EntityMoveManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string command = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string args = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'runCommand'",  NULL );
          #endif
           {
           self->runCommand(  command,  args );
           tolua_pushcppstring(  tolua_S,  (  const char* )command );
           tolua_pushcppstring(  tolua_S,  (  const char* )args );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'runCommand'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventStartMoving of class EmberOgre::EntityMoveManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EntityMoveManager_EventStartMoving
   16114  static int tolua_get_EmberOgre__EntityMoveManager_EventStartMoving(  lua_State* tolua_S )
          {
           EmberOgre::EntityMoveManager* self = (  EmberOgre::EntityMoveManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventStartMoving'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventStartMoving,  "sigc::signal<void,  EmberOgre::EmberEntity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventStartMoving of class EmberOgre::EntityMoveManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EntityMoveManager_EventStartMoving
   16127  static int tolua_set_EmberOgre__EntityMoveManager_EventStartMoving(  lua_State* tolua_S )
          {
           EmberOgre::EntityMoveManager* self = (  EmberOgre::EntityMoveManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventStartMoving'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::EmberEntity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventStartMoving = *(  (  sigc::signal<void,  EmberOgre::EmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventFinishedMoving of class EmberOgre::EntityMoveManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EntityMoveManager_EventFinishedMoving
   16144  static int tolua_get_EmberOgre__EntityMoveManager_EventFinishedMoving(  lua_State* tolua_S )
          {
           EmberOgre::EntityMoveManager* self = (  EmberOgre::EntityMoveManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventFinishedMoving'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventFinishedMoving,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventFinishedMoving of class EmberOgre::EntityMoveManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EntityMoveManager_EventFinishedMoving
   16157  static int tolua_set_EmberOgre__EntityMoveManager_EventFinishedMoving(  lua_State* tolua_S )
          {
           EmberOgre::EntityMoveManager* self = (  EmberOgre::EntityMoveManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventFinishedMoving'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventFinishedMoving = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventCancelledMoving of class EmberOgre::EntityMoveManager */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EntityMoveManager_EventCancelledMoving
   16174  static int tolua_get_EmberOgre__EntityMoveManager_EventCancelledMoving(  lua_State* tolua_S )
          {
           EmberOgre::EntityMoveManager* self = (  EmberOgre::EntityMoveManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCancelledMoving'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventCancelledMoving,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventCancelledMoving of class EmberOgre::EntityMoveManager */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EntityMoveManager_EventCancelledMoving
   16187  static int tolua_set_EmberOgre__EntityMoveManager_EventCancelledMoving(  lua_State* tolua_S )
          {
           EmberOgre::EntityMoveManager* self = (  EmberOgre::EntityMoveManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCancelledMoving'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventCancelledMoving = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: clear of class std::vector<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_std__string__clear00
   16204  static int tolua_EmberOgre_std_vector_std__string__clear00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<std::string>* self = (  std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'clear'",  NULL );
          #endif
           {
           self->clear(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'clear'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: size of class std::vector<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_std__string__size00
   16235  static int tolua_EmberOgre_std_vector_std__string__size00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<std::string>* self = (  const std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'size'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->size(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'size'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_std__string___geti00
   16267  static int tolua_EmberOgre_std_vector_std__string___geti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<std::string>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<std::string>* self = (  const std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->operator[](  index );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.geti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator&[] of class std::vector<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_std__string___seti00
   16301  static int tolua_EmberOgre_std_vector_std__string___seti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<std::string>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<std::string>* self = (  std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           std::string tolua_value = (  (  std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator&[]'",  NULL );
          #endif
           self->operator[](  index ) = tolua_value;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.seti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_std__string___geti01
   16334  static int tolua_EmberOgre_std_vector_std__string___geti01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<std::string>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           std::vector<std::string>* self = (  std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->operator[](  index );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_std_vector_std__string___geti00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: push_back of class std::vector<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_std__string__push_back00
   16363  static int tolua_EmberOgre_std_vector_std__string__push_back00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<std::string>",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<std::string>* self = (  std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
           std::string val = (  (  std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'push_back'",  NULL );
          #endif
           {
           self->push_back(  val );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'push_back'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class std::vector<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_std__string__new00
   16396  static int tolua_EmberOgre_std_vector_std__string__new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<std::string>* tolua_ret = (  std::vector<std::string>* ) new std::vector<std::string>(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "std::vector<std::string>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class std::vector<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_std__string__new00_local
   16424  static int tolua_EmberOgre_std_vector_std__string__new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<std::string>* tolua_ret = (  std::vector<std::string>* ) new std::vector<std::string>(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "std::vector<std::string>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class std::vector<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_std__string__delete00
   16452  static int tolua_EmberOgre_std_vector_std__string__delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<std::string>* self = (  std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: clear of class std::vector<EmberOgre::Model::SubModelDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___clear00
   16481  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___clear00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubModelDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::SubModelDefinition*>* self = (  std::vector<EmberOgre::Model::SubModelDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'clear'",  NULL );
          #endif
           {
           self->clear(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'clear'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: size of class std::vector<EmberOgre::Model::SubModelDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___size00
   16512  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___size00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<EmberOgre::Model::SubModelDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<EmberOgre::Model::SubModelDefinition*>* self = (  const std::vector<EmberOgre::Model::SubModelDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'size'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->size(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'size'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<EmberOgre::Model::SubModelDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____geti00
   16544  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____geti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<EmberOgre::Model::SubModelDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<EmberOgre::Model::SubModelDefinition*>* self = (  const std::vector<EmberOgre::Model::SubModelDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           const EmberOgre::Model::SubModelDefinition* tolua_ret = (  const EmberOgre::Model::SubModelDefinition* ) self->operator[](  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const EmberOgre::Model::SubModelDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.geti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator&[] of class std::vector<EmberOgre::Model::SubModelDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____seti00
   16578  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____seti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubModelDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::Model::SubModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::SubModelDefinition*>* self = (  std::vector<EmberOgre::Model::SubModelDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           EmberOgre::Model::SubModelDefinition* tolua_value = (  (  EmberOgre::Model::SubModelDefinition* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator&[]'",  NULL );
          #endif
           self->operator[](  index ) = tolua_value;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.seti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<EmberOgre::Model::SubModelDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____geti01
   16611  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____geti01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubModelDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           std::vector<EmberOgre::Model::SubModelDefinition*>* self = (  std::vector<EmberOgre::Model::SubModelDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           EmberOgre::Model::SubModelDefinition* tolua_ret = (  EmberOgre::Model::SubModelDefinition* ) self->operator[](  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::SubModelDefinition" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____geti00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: push_back of class std::vector<EmberOgre::Model::SubModelDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___push_back00
   16640  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___push_back00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubModelDefinition*>",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::SubModelDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::SubModelDefinition*>* self = (  std::vector<EmberOgre::Model::SubModelDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::SubModelDefinition* val = (  (  EmberOgre::Model::SubModelDefinition* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'push_back'",  NULL );
          #endif
           {
           self->push_back(  val );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'push_back'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class std::vector<EmberOgre::Model::SubModelDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___new00
   16673  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubModelDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<EmberOgre::Model::SubModelDefinition*>* tolua_ret = (  std::vector<EmberOgre::Model::SubModelDefinition*>* ) new std::vector<EmberOgre::Model::SubModelDefinition*>(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "std::vector<EmberOgre::Model::SubModelDefinition*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class std::vector<EmberOgre::Model::SubModelDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___new00_local
   16701  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubModelDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<EmberOgre::Model::SubModelDefinition*>* tolua_ret = (  std::vector<EmberOgre::Model::SubModelDefinition*>* ) new std::vector<EmberOgre::Model::SubModelDefinition*>(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "std::vector<EmberOgre::Model::SubModelDefinition*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class std::vector<EmberOgre::Model::SubModelDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___delete00
   16729  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubModelDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::SubModelDefinition*>* self = (  std::vector<EmberOgre::Model::SubModelDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: clear of class std::vector<EmberOgre::Model::PartDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___clear00
   16758  static int tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___clear00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::PartDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::PartDefinition*>* self = (  std::vector<EmberOgre::Model::PartDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'clear'",  NULL );
          #endif
           {
           self->clear(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'clear'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: size of class std::vector<EmberOgre::Model::PartDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___size00
   16789  static int tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___size00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<EmberOgre::Model::PartDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<EmberOgre::Model::PartDefinition*>* self = (  const std::vector<EmberOgre::Model::PartDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'size'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->size(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'size'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<EmberOgre::Model::PartDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____geti00
   16821  static int tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____geti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<EmberOgre::Model::PartDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<EmberOgre::Model::PartDefinition*>* self = (  const std::vector<EmberOgre::Model::PartDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           const EmberOgre::Model::PartDefinition* tolua_ret = (  const EmberOgre::Model::PartDefinition* ) self->operator[](  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const EmberOgre::Model::PartDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.geti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator&[] of class std::vector<EmberOgre::Model::PartDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____seti00
   16855  static int tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____seti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::PartDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::PartDefinition*>* self = (  std::vector<EmberOgre::Model::PartDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           EmberOgre::Model::PartDefinition* tolua_value = (  (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator&[]'",  NULL );
          #endif
           self->operator[](  index ) = tolua_value;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.seti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<EmberOgre::Model::PartDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____geti01
   16888  static int tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____geti01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::PartDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           std::vector<EmberOgre::Model::PartDefinition*>* self = (  std::vector<EmberOgre::Model::PartDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           EmberOgre::Model::PartDefinition* tolua_ret = (  EmberOgre::Model::PartDefinition* ) self->operator[](  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::PartDefinition" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____geti00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: push_back of class std::vector<EmberOgre::Model::PartDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___push_back00
   16917  static int tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___push_back00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::PartDefinition*>",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::PartDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::PartDefinition*>* self = (  std::vector<EmberOgre::Model::PartDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::PartDefinition* val = (  (  EmberOgre::Model::PartDefinition* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'push_back'",  NULL );
          #endif
           {
           self->push_back(  val );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'push_back'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class std::vector<EmberOgre::Model::PartDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___new00
   16950  static int tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<EmberOgre::Model::PartDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<EmberOgre::Model::PartDefinition*>* tolua_ret = (  std::vector<EmberOgre::Model::PartDefinition*>* ) new std::vector<EmberOgre::Model::PartDefinition*>(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "std::vector<EmberOgre::Model::PartDefinition*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class std::vector<EmberOgre::Model::PartDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___new00_local
   16978  static int tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<EmberOgre::Model::PartDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<EmberOgre::Model::PartDefinition*>* tolua_ret = (  std::vector<EmberOgre::Model::PartDefinition*>* ) new std::vector<EmberOgre::Model::PartDefinition*>(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "std::vector<EmberOgre::Model::PartDefinition*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class std::vector<EmberOgre::Model::PartDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___delete00
   17006  static int tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::PartDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::PartDefinition*>* self = (  std::vector<EmberOgre::Model::PartDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: clear of class std::vector<EmberOgre::Model::SubEntityDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___clear00
   17035  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___clear00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubEntityDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::SubEntityDefinition*>* self = (  std::vector<EmberOgre::Model::SubEntityDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'clear'",  NULL );
          #endif
           {
           self->clear(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'clear'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: size of class std::vector<EmberOgre::Model::SubEntityDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___size00
   17066  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___size00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<EmberOgre::Model::SubEntityDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<EmberOgre::Model::SubEntityDefinition*>* self = (  const std::vector<EmberOgre::Model::SubEntityDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'size'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->size(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'size'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<EmberOgre::Model::SubEntityDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____geti00
   17098  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____geti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<EmberOgre::Model::SubEntityDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<EmberOgre::Model::SubEntityDefinition*>* self = (  const std::vector<EmberOgre::Model::SubEntityDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           const EmberOgre::Model::SubEntityDefinition* tolua_ret = (  const EmberOgre::Model::SubEntityDefinition* ) self->operator[](  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const EmberOgre::Model::SubEntityDefinition" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.geti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator&[] of class std::vector<EmberOgre::Model::SubEntityDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____seti00
   17132  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____seti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubEntityDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::Model::SubEntityDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::SubEntityDefinition*>* self = (  std::vector<EmberOgre::Model::SubEntityDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           EmberOgre::Model::SubEntityDefinition* tolua_value = (  (  EmberOgre::Model::SubEntityDefinition* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator&[]'",  NULL );
          #endif
           self->operator[](  index ) = tolua_value;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.seti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<EmberOgre::Model::SubEntityDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____geti01
   17165  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____geti01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubEntityDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           std::vector<EmberOgre::Model::SubEntityDefinition*>* self = (  std::vector<EmberOgre::Model::SubEntityDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           EmberOgre::Model::SubEntityDefinition* tolua_ret = (  EmberOgre::Model::SubEntityDefinition* ) self->operator[](  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Model::SubEntityDefinition" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____geti00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: push_back of class std::vector<EmberOgre::Model::SubEntityDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___push_back00
   17194  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___push_back00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubEntityDefinition*>",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Model::SubEntityDefinition",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::SubEntityDefinition*>* self = (  std::vector<EmberOgre::Model::SubEntityDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Model::SubEntityDefinition* val = (  (  EmberOgre::Model::SubEntityDefinition* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'push_back'",  NULL );
          #endif
           {
           self->push_back(  val );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'push_back'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class std::vector<EmberOgre::Model::SubEntityDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___new00
   17227  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubEntityDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<EmberOgre::Model::SubEntityDefinition*>* tolua_ret = (  std::vector<EmberOgre::Model::SubEntityDefinition*>* ) new std::vector<EmberOgre::Model::SubEntityDefinition*>(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "std::vector<EmberOgre::Model::SubEntityDefinition*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class std::vector<EmberOgre::Model::SubEntityDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___new00_local
   17255  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubEntityDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<EmberOgre::Model::SubEntityDefinition*>* tolua_ret = (  std::vector<EmberOgre::Model::SubEntityDefinition*>* ) new std::vector<EmberOgre::Model::SubEntityDefinition*>(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "std::vector<EmberOgre::Model::SubEntityDefinition*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class std::vector<EmberOgre::Model::SubEntityDefinition*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___delete00
   17283  static int tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<EmberOgre::Model::SubEntityDefinition*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<EmberOgre::Model::SubEntityDefinition*>* self = (  std::vector<EmberOgre::Model::SubEntityDefinition*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: clear of class std::vector<Eris::Task*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_Eris__Task___clear00
   17312  static int tolua_EmberOgre_std_vector_Eris__Task___clear00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<Eris::Task*>* self = (  std::vector<Eris::Task*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'clear'",  NULL );
          #endif
           {
           self->clear(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'clear'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: size of class std::vector<Eris::Task*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_Eris__Task___size00
   17343  static int tolua_EmberOgre_std_vector_Eris__Task___size00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<Eris::Task*>* self = (  const std::vector<Eris::Task*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'size'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->size(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'size'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<Eris::Task*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_Eris__Task____geti00
   17375  static int tolua_EmberOgre_std_vector_Eris__Task____geti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::vector<Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::vector<Eris::Task*>* self = (  const std::vector<Eris::Task*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           const Eris::Task* tolua_ret = (  const Eris::Task* ) self->operator[](  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const Eris::Task" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.geti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator&[] of class std::vector<Eris::Task*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_Eris__Task____seti00
   17409  static int tolua_EmberOgre_std_vector_Eris__Task____seti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Eris::Task",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<Eris::Task*>* self = (  std::vector<Eris::Task*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           Eris::Task* tolua_value = (  (  Eris::Task* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator&[]'",  NULL );
          #endif
           self->operator[](  index ) = tolua_value;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.seti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class std::vector<Eris::Task*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_Eris__Task____geti01
   17442  static int tolua_EmberOgre_std_vector_Eris__Task____geti01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           std::vector<Eris::Task*>* self = (  std::vector<Eris::Task*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           Eris::Task* tolua_ret = (  Eris::Task* ) self->operator[](  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Eris::Task" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_std_vector_Eris__Task____geti00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: push_back of class std::vector<Eris::Task*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_Eris__Task___push_back00
   17471  static int tolua_EmberOgre_std_vector_Eris__Task___push_back00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Task",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<Eris::Task*>* self = (  std::vector<Eris::Task*>* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Task* val = (  (  Eris::Task* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'push_back'",  NULL );
          #endif
           {
           self->push_back(  val );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'push_back'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class std::vector<Eris::Task*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_Eris__Task___new00
   17504  static int tolua_EmberOgre_std_vector_Eris__Task___new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<Eris::Task*>* tolua_ret = (  std::vector<Eris::Task*>* ) new std::vector<Eris::Task*>(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "std::vector<Eris::Task*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class std::vector<Eris::Task*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_Eris__Task___new00_local
   17532  static int tolua_EmberOgre_std_vector_Eris__Task___new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::vector<Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::vector<Eris::Task*>* tolua_ret = (  std::vector<Eris::Task*>* ) new std::vector<Eris::Task*>(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "std::vector<Eris::Task*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class std::vector<Eris::Task*> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_vector_Eris__Task___delete00
   17560  static int tolua_EmberOgre_std_vector_Eris__Task___delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::vector<Eris::Task*>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::vector<Eris::Task*>* self = (  std::vector<Eris::Task*>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: clear of class std::set<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_set_std__string__clear00
   17589  static int tolua_EmberOgre_std_set_std__string__clear00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::set<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::set<std::string>* self = (  std::set<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'clear'",  NULL );
          #endif
           {
           self->clear(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'clear'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: size of class std::set<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_set_std__string__size00
   17620  static int tolua_EmberOgre_std_set_std__string__size00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const std::set<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::set<std::string>* self = (  const std::set<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'size'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->size(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'size'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class std::set<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_set_std__string__new00
   17652  static int tolua_EmberOgre_std_set_std__string__new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::set<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::set<std::string>* tolua_ret = (  std::set<std::string>* ) new std::set<std::string>(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "std::set<std::string>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class std::set<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_set_std__string__new00_local
   17680  static int tolua_EmberOgre_std_set_std__string__new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "std::set<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           std::set<std::string>* tolua_ret = (  std::set<std::string>* ) new std::set<std::string>(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "std::set<std::string>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class std::set<std::string> */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_std_set_std__string__delete00
   17708  static int tolua_EmberOgre_std_set_std__string__delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "std::set<std::string>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           std::set<std::string>* self = (  std::set<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new00
   17737  static int tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Vector3Adapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const Ogre::Vector3* vector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::Gui::Vector3Adapter* tolua_ret = (  EmberOgre::Gui::Vector3Adapter* ) new EmberOgre::Gui::Vector3Adapter(  xWindow,  yWindow,  zWindow,  *vector );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Vector3Adapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new00_local
   17773  static int tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Vector3Adapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const Ogre::Vector3* vector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::Gui::Vector3Adapter* tolua_ret = (  EmberOgre::Gui::Vector3Adapter* ) new EmberOgre::Gui::Vector3Adapter(  xWindow,  yWindow,  zWindow,  *vector );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Vector3Adapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new01
   17809  static int tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Vector3Adapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           EmberOgre::Gui::Vector3Adapter* tolua_ret = (  EmberOgre::Gui::Vector3Adapter* ) new EmberOgre::Gui::Vector3Adapter(  xWindow,  yWindow,  zWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Vector3Adapter" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new01_local
   17838  static int tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Vector3Adapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           EmberOgre::Gui::Vector3Adapter* tolua_ret = (  EmberOgre::Gui::Vector3Adapter* ) new EmberOgre::Gui::Vector3Adapter(  xWindow,  yWindow,  zWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Vector3Adapter" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_delete00
   17867  static int tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Vector3Adapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Vector3Adapter* self = (  EmberOgre::Gui::Vector3Adapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getValue of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_getValue00
   17896  static int tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_getValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Vector3Adapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Vector3Adapter* self = (  const EmberOgre::Gui::Vector3Adapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getValue'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getValue(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getOriginalValue of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_getOriginalValue00
   17928  static int tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_getOriginalValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Vector3Adapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Vector3Adapter* self = (  const EmberOgre::Gui::Vector3Adapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getOriginalValue'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getOriginalValue(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getOriginalValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setValue of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_setValue00
   17960  static int tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_setValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Vector3Adapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Vector3Adapter* self = (  EmberOgre::Gui::Vector3Adapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* vector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setValue'",  NULL );
          #endif
           {
           self->setValue(  *vector );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: updateGui of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_updateGui00
   17993  static int tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_updateGui00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Vector3Adapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Vector3Adapter* self = (  EmberOgre::Gui::Vector3Adapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* vector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'updateGui'",  NULL );
          #endif
           {
           self->updateGui(  *vector );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'updateGui'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventValueChanged of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__Vector3Adapter_EventValueChanged
   18026  static int tolua_get_EmberOgre__Gui__Vector3Adapter_EventValueChanged(  lua_State* tolua_S )
          {
           EmberOgre::Gui::Vector3Adapter* self = (  EmberOgre::Gui::Vector3Adapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventValueChanged'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventValueChanged,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventValueChanged of class EmberOgre::Gui::Vector3Adapter */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__Vector3Adapter_EventValueChanged
   18039  static int tolua_set_EmberOgre__Gui__Vector3Adapter_EventValueChanged(  lua_State* tolua_S )
          {
           EmberOgre::Gui::Vector3Adapter* self = (  EmberOgre::Gui::Vector3Adapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventValueChanged'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventValueChanged = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new00
   18056  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* degreeWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::Gui::QuaternionAdapter* tolua_ret = (  EmberOgre::Gui::QuaternionAdapter* ) new EmberOgre::Gui::QuaternionAdapter(  degreeWindow,  xWindow,  yWindow,  zWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::QuaternionAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new00_local
   18092  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           CEGUI::Window* degreeWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::Gui::QuaternionAdapter* tolua_ret = (  EmberOgre::Gui::QuaternionAdapter* ) new EmberOgre::Gui::QuaternionAdapter(  degreeWindow,  xWindow,  yWindow,  zWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::QuaternionAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new01
   18128  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           CEGUI::Window* degreeWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           const Ogre::Quaternion* quaternion = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           EmberOgre::Gui::QuaternionAdapter* tolua_ret = (  EmberOgre::Gui::QuaternionAdapter* ) new EmberOgre::Gui::QuaternionAdapter(  degreeWindow,  xWindow,  yWindow,  zWindow,  *quaternion );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::QuaternionAdapter" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new01_local
   18161  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           CEGUI::Window* degreeWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           const Ogre::Quaternion* quaternion = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           EmberOgre::Gui::QuaternionAdapter* tolua_ret = (  EmberOgre::Gui::QuaternionAdapter* ) new EmberOgre::Gui::QuaternionAdapter(  degreeWindow,  xWindow,  yWindow,  zWindow,  *quaternion );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::QuaternionAdapter" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new02
   18194  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           CEGUI::Window* degreeWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::Gui::QuaternionAdapter* tolua_ret = (  EmberOgre::Gui::QuaternionAdapter* ) new EmberOgre::Gui::QuaternionAdapter(  degreeWindow,  xWindow,  yWindow,  zWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::QuaternionAdapter" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new02_local
   18225  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new02_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           CEGUI::Window* degreeWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::Gui::QuaternionAdapter* tolua_ret = (  EmberOgre::Gui::QuaternionAdapter* ) new EmberOgre::Gui::QuaternionAdapter(  degreeWindow,  xWindow,  yWindow,  zWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::QuaternionAdapter" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new01_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_delete00
   18256  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::QuaternionAdapter* self = (  EmberOgre::Gui::QuaternionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getValue of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_getValue00
   18285  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_getValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::QuaternionAdapter* self = (  const EmberOgre::Gui::QuaternionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getValue'",  NULL );
          #endif
           {
           const Ogre::Quaternion& tolua_ret = (  const Ogre::Quaternion& ) self->getValue(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getOriginalValue of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_getOriginalValue00
   18317  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_getOriginalValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::QuaternionAdapter* self = (  const EmberOgre::Gui::QuaternionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getOriginalValue'",  NULL );
          #endif
           {
           const Ogre::Quaternion& tolua_ret = (  const Ogre::Quaternion& ) self->getOriginalValue(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getOriginalValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setValue of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_setValue00
   18349  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_setValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::QuaternionAdapter* self = (  EmberOgre::Gui::QuaternionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* quaternion = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setValue'",  NULL );
          #endif
           {
           self->setValue(  *quaternion );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: updateGui of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_updateGui00
   18382  static int tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_updateGui00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::QuaternionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::QuaternionAdapter* self = (  EmberOgre::Gui::QuaternionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* vector = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'updateGui'",  NULL );
          #endif
           {
           self->updateGui(  *vector );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'updateGui'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventValueChanged of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__QuaternionAdapter_EventValueChanged
   18415  static int tolua_get_EmberOgre__Gui__QuaternionAdapter_EventValueChanged(  lua_State* tolua_S )
          {
           EmberOgre::Gui::QuaternionAdapter* self = (  EmberOgre::Gui::QuaternionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventValueChanged'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventValueChanged,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventValueChanged of class EmberOgre::Gui::QuaternionAdapter */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__QuaternionAdapter_EventValueChanged
   18428  static int tolua_set_EmberOgre__Gui__QuaternionAdapter_EventValueChanged(  lua_State* tolua_S )
          {
           EmberOgre::Gui::QuaternionAdapter* self = (  EmberOgre::Gui::QuaternionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventValueChanged'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventValueChanged = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::OgreInfo */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_OgreInfo_new00
   18445  static int tolua_EmberOgre_EmberOgre_OgreInfo_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::OgreInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::OgreInfo* tolua_ret = (  EmberOgre::OgreInfo* ) new EmberOgre::OgreInfo(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::OgreInfo" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::OgreInfo */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_OgreInfo_new00_local
   18473  static int tolua_EmberOgre_EmberOgre_OgreInfo_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::OgreInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::OgreInfo* tolua_ret = (  EmberOgre::OgreInfo* ) new EmberOgre::OgreInfo(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::OgreInfo" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::OgreInfo */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_OgreInfo_delete00
   18501  static int tolua_EmberOgre_EmberOgre_OgreInfo_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::OgreInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::OgreInfo* self = (  EmberOgre::OgreInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isIndirect of class EmberOgre::OgreInfo */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_OgreInfo_isIndirect00
   18530  static int tolua_EmberOgre_EmberOgre_OgreInfo_isIndirect00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::OgreInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::OgreInfo* self = (  const EmberOgre::OgreInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isIndirect'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isIndirect(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isIndirect'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::AttributeObserver */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AttributeObserver_new00
   18562  static int tolua_EmberOgre_EmberOgre_AttributeObserver_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::AttributeObserver",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string attributeName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           {
           EmberOgre::AttributeObserver* tolua_ret = (  EmberOgre::AttributeObserver* ) new EmberOgre::AttributeObserver(  entity,  attributeName );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::AttributeObserver" );
           tolua_pushcppstring(  tolua_S,  (  const char* )attributeName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::AttributeObserver */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AttributeObserver_new00_local
   18595  static int tolua_EmberOgre_EmberOgre_AttributeObserver_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::AttributeObserver",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string attributeName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           {
           EmberOgre::AttributeObserver* tolua_ret = (  EmberOgre::AttributeObserver* ) new EmberOgre::AttributeObserver(  entity,  attributeName );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::AttributeObserver" );
           tolua_pushcppstring(  tolua_S,  (  const char* )attributeName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::AttributeObserver */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_AttributeObserver_delete00
   18628  static int tolua_EmberOgre_EmberOgre_AttributeObserver_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::AttributeObserver",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::AttributeObserver* self = (  EmberOgre::AttributeObserver* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventChanged of class EmberOgre::AttributeObserver */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__AttributeObserver_EventChanged
   18657  static int tolua_get_EmberOgre__AttributeObserver_EventChanged(  lua_State* tolua_S )
          {
           EmberOgre::AttributeObserver* self = (  EmberOgre::AttributeObserver* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventChanged'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventChanged,  "sigc::signal<void,  const Atlas::Message::Element&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventChanged of class EmberOgre::AttributeObserver */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__AttributeObserver_EventChanged
   18670  static int tolua_set_EmberOgre__AttributeObserver_EventChanged(  lua_State* tolua_S )
          {
           EmberOgre::AttributeObserver* self = (  EmberOgre::AttributeObserver* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventChanged'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Atlas::Message::Element&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventChanged = *(  (  sigc::signal<void,  const Atlas::Message::Element&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getSingleton00
   18687  static int tolua_EmberOgre_EmberOgre_EmberOgre_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           EmberOgre::EmberOgre& tolua_ret = (  EmberOgre::EmberOgre& ) EmberOgre::EmberOgre::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "EmberOgre::EmberOgre" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAvatar of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getAvatar00
   18715  static int tolua_EmberOgre_EmberOgre_EmberOgre_getAvatar00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAvatar'",  NULL );
          #endif
           {
           EmberOgre::Avatar* tolua_ret = (  EmberOgre::Avatar* ) self->getAvatar(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Avatar" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAvatar'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMotionManager of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getMotionManager00
   18747  static int tolua_EmberOgre_EmberOgre_EmberOgre_getMotionManager00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMotionManager'",  NULL );
          #endif
           {
           EmberOgre::MotionManager* tolua_ret = (  EmberOgre::MotionManager* ) self->getMotionManager(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::MotionManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMotionManager'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntityFactory of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getEntityFactory00
   18779  static int tolua_EmberOgre_EmberOgre_EmberOgre_getEntityFactory00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntityFactory'",  NULL );
          #endif
           {
           EmberOgre::EmberEntityFactory* tolua_ret = (  EmberOgre::EmberEntityFactory* ) self->getEntityFactory(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::EmberEntityFactory" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntityFactory'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMainCamera of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getMainCamera00
   18811  static int tolua_EmberOgre_EmberOgre_EmberOgre_getMainCamera00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMainCamera'",  NULL );
          #endif
           {
           EmberOgre::AvatarCamera* tolua_ret = (  EmberOgre::AvatarCamera* ) self->getMainCamera(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::AvatarCamera" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMainCamera'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAvatarController of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getAvatarController00
   18843  static int tolua_EmberOgre_EmberOgre_EmberOgre_getAvatarController00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAvatarController'",  NULL );
          #endif
           {
           EmberOgre::AvatarController* tolua_ret = (  EmberOgre::AvatarController* ) self->getAvatarController(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::AvatarController" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAvatarController'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMoveManager of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getMoveManager00
   18875  static int tolua_EmberOgre_EmberOgre_EmberOgre_getMoveManager00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMoveManager'",  NULL );
          #endif
           {
           EmberOgre::EntityMoveManager* tolua_ret = (  EmberOgre::EntityMoveManager* ) self->getMoveManager(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::EntityMoveManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMoveManager'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEmberEntity of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getEmberEntity00
   18907  static int tolua_EmberOgre_EmberOgre_EmberOgre_getEmberEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string eid = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEmberEntity'",  NULL );
          #endif
           {
           EmberOgre::EmberEntity* tolua_ret = (  EmberOgre::EmberEntity* ) self->getEmberEntity(  eid );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::EmberEntity" );
           tolua_pushcppstring(  tolua_S,  (  const char* )eid );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEmberEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getJesus of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getJesus00
   18942  static int tolua_EmberOgre_EmberOgre_EmberOgre_getJesus00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getJesus'",  NULL );
          #endif
           {
           EmberOgre::Jesus* tolua_ret = (  EmberOgre::Jesus* ) self->getJesus(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Jesus" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getJesus'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getRenderWindow of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getRenderWindow00
   18974  static int tolua_EmberOgre_EmberOgre_EmberOgre_getRenderWindow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getRenderWindow'",  NULL );
          #endif
           {
           Ogre::RenderWindow* tolua_ret = (  Ogre::RenderWindow* ) self->getRenderWindow(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::RenderWindow" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getRenderWindow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventCreatedEmberEntityFactory of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberOgre_EventCreatedEmberEntityFactory
   19006  static int tolua_get_EmberOgre__EmberOgre_EventCreatedEmberEntityFactory(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCreatedEmberEntityFactory'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventCreatedEmberEntityFactory,  "sigc::signal<void,  EmberOgre::EmberEntityFactory*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventCreatedEmberEntityFactory of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EmberOgre_EventCreatedEmberEntityFactory
   19019  static int tolua_set_EmberOgre__EmberOgre_EventCreatedEmberEntityFactory(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCreatedEmberEntityFactory'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::EmberEntityFactory*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventCreatedEmberEntityFactory = *(  (  sigc::signal<void,  EmberOgre::EmberEntityFactory*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventCreatedAvatarEntity of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberOgre_EventCreatedAvatarEntity
   19036  static int tolua_get_EmberOgre__EmberOgre_EventCreatedAvatarEntity(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCreatedAvatarEntity'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventCreatedAvatarEntity,  "sigc::signal<void,  EmberOgre::AvatarEmberEntity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventCreatedAvatarEntity of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EmberOgre_EventCreatedAvatarEntity
   19049  static int tolua_set_EmberOgre__EmberOgre_EventCreatedAvatarEntity(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCreatedAvatarEntity'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::AvatarEmberEntity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventCreatedAvatarEntity = *(  (  sigc::signal<void,  EmberOgre::AvatarEmberEntity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventCreatedJesus of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberOgre_EventCreatedJesus
   19066  static int tolua_get_EmberOgre__EmberOgre_EventCreatedJesus(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCreatedJesus'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventCreatedJesus,  "sigc::signal<void,  EmberOgre::Jesus*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventCreatedJesus of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EmberOgre_EventCreatedJesus
   19079  static int tolua_set_EmberOgre__EmberOgre_EventCreatedJesus(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventCreatedJesus'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Jesus*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventCreatedJesus = *(  (  sigc::signal<void,  EmberOgre::Jesus*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWorldSceneNode of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getWorldSceneNode00
   19096  static int tolua_EmberOgre_EmberOgre_EmberOgre_getWorldSceneNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWorldSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->getWorldSceneNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWorldSceneNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getRootSceneNode of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getRootSceneNode00
   19128  static int tolua_EmberOgre_EmberOgre_EmberOgre_getRootSceneNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::EmberOgre* self = (  const EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getRootSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->getRootSceneNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getRootSceneNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventGUIManagerCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberOgre_EventGUIManagerCreated
   19160  static int tolua_get_EmberOgre__EmberOgre_EventGUIManagerCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventGUIManagerCreated'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventGUIManagerCreated,  "sigc::signal<void,  EmberOgre::GUIManager&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventGUIManagerCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EmberOgre_EventGUIManagerCreated
   19173  static int tolua_set_EmberOgre__EmberOgre_EventGUIManagerCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventGUIManagerCreated'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::GUIManager&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventGUIManagerCreated = *(  (  sigc::signal<void,  EmberOgre::GUIManager&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventGUIManagerInitialized of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberOgre_EventGUIManagerInitialized
   19190  static int tolua_get_EmberOgre__EmberOgre_EventGUIManagerInitialized(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventGUIManagerInitialized'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventGUIManagerInitialized,  "sigc::signal<void,  EmberOgre::GUIManager&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventGUIManagerInitialized of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EmberOgre_EventGUIManagerInitialized
   19203  static int tolua_set_EmberOgre__EmberOgre_EventGUIManagerInitialized(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventGUIManagerInitialized'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::GUIManager&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventGUIManagerInitialized = *(  (  sigc::signal<void,  EmberOgre::GUIManager&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventMotionManagerCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberOgre_EventMotionManagerCreated
   19220  static int tolua_get_EmberOgre__EmberOgre_EventMotionManagerCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMotionManagerCreated'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventMotionManagerCreated,  "sigc::signal<void,  EmberOgre::MotionManager&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventMotionManagerCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EmberOgre_EventMotionManagerCreated
   19233  static int tolua_set_EmberOgre__EmberOgre_EventMotionManagerCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventMotionManagerCreated'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::MotionManager&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventMotionManagerCreated = *(  (  sigc::signal<void,  EmberOgre::MotionManager&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventTerrainGeneratorCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberOgre_EventTerrainGeneratorCreated
   19250  static int tolua_get_EmberOgre__EmberOgre_EventTerrainGeneratorCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventTerrainGeneratorCreated'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventTerrainGeneratorCreated,  "sigc::signal<void,  EmberOgre::Terrain::TerrainGenerator&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventTerrainGeneratorCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EmberOgre_EventTerrainGeneratorCreated
   19263  static int tolua_set_EmberOgre__EmberOgre_EventTerrainGeneratorCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventTerrainGeneratorCreated'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::Terrain::TerrainGenerator&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventTerrainGeneratorCreated = *(  (  sigc::signal<void,  EmberOgre::Terrain::TerrainGenerator&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventAvatarControllerCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberOgre_EventAvatarControllerCreated
   19280  static int tolua_get_EmberOgre__EmberOgre_EventAvatarControllerCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventAvatarControllerCreated'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventAvatarControllerCreated,  "sigc::signal<void,  EmberOgre::AvatarController&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventAvatarControllerCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EmberOgre_EventAvatarControllerCreated
   19293  static int tolua_set_EmberOgre__EmberOgre_EventAvatarControllerCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventAvatarControllerCreated'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  EmberOgre::AvatarController&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventAvatarControllerCreated = *(  (  sigc::signal<void,  EmberOgre::AvatarController&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventSceneCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__EmberOgre_EventSceneCreated
   19310  static int tolua_get_EmberOgre__EmberOgre_EventSceneCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventSceneCreated'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventSceneCreated,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventSceneCreated of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__EmberOgre_EventSceneCreated
   19323  static int tolua_set_EmberOgre__EmberOgre_EventSceneCreated(  lua_State* tolua_S )
          {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventSceneCreated'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventSceneCreated = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEntity of class EmberOgre::EmberOgre */
          #ifndef TOLUA_DISABLE_tolua_EmberOgre_EmberOgre_EmberOgre_getEntity00
   19340  static int tolua_EmberOgre_EmberOgre_EmberOgre_getEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::EmberOgre",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::EmberOgre* self = (  EmberOgre::EmberOgre* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string id = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEntity'",  NULL );
          #endif
           {
           EmberOgre::EmberEntity* tolua_ret = (  EmberOgre::EmberEntity* ) self->getEntity(  id );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::EmberEntity" );
           tolua_pushcppstring(  tolua_S,  (  const char* )id );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* Open function */
   19374  TOLUA_API int tolua_EmberOgre_open (  lua_State* tolua_S )
          {
           tolua_open(  tolua_S );
           tolua_reg_types(  tolua_S );
           tolua_module(  tolua_S,  NULL,  0 );
           tolua_beginmodule(  tolua_S,  NULL );
           tolua_module(  tolua_S,  "Carpenter",  0 );
           tolua_beginmodule(  tolua_S,  "Carpenter" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "AttachPair",  "Carpenter::AttachPair",  "",  tolua_collect_Carpenter__AttachPair );
           #else
           tolua_cclass(  tolua_S,  "AttachPair",  "Carpenter::AttachPair",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "AttachPair" );
           tolua_function(  tolua_S,  "getAttachPoint",  tolua_EmberOgre_Carpenter_AttachPair_getAttachPoint00 );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_Carpenter_AttachPair_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_Carpenter_AttachPair_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_Carpenter_AttachPair_new00_local );
           tolua_function(  tolua_S,  "getPoint1",  tolua_EmberOgre_Carpenter_AttachPair_getPoint100 );
           tolua_function(  tolua_S,  "getPoint2",  tolua_EmberOgre_Carpenter_AttachPair_getPoint200 );
           tolua_function(  tolua_S,  "getName",  tolua_EmberOgre_Carpenter_AttachPair_getName00 );
           tolua_function(  tolua_S,  "getType",  tolua_EmberOgre_Carpenter_AttachPair_getType00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "AttachPoint",  "Carpenter::AttachPoint",  "",  tolua_collect_Carpenter__AttachPoint );
           #else
           tolua_cclass(  tolua_S,  "AttachPoint",  "Carpenter::AttachPoint",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "AttachPoint" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_Carpenter_AttachPoint_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_Carpenter_AttachPoint_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_Carpenter_AttachPoint_new00_local );
           tolua_function(  tolua_S,  "getName",  tolua_EmberOgre_Carpenter_AttachPoint_getName00 );
           tolua_function(  tolua_S,  "getNormal",  tolua_EmberOgre_Carpenter_AttachPoint_getNormal00 );
           tolua_function(  tolua_S,  "getPosition",  tolua_EmberOgre_Carpenter_AttachPoint_getPosition00 );
           tolua_function(  tolua_S,  "getAttachPair",  tolua_EmberOgre_Carpenter_AttachPoint_getAttachPair00 );
           tolua_function(  tolua_S,  "getSibling",  tolua_EmberOgre_Carpenter_AttachPoint_getSibling00 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "BlockSpec",  "Carpenter::BlockSpec",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "BlockSpec" );
           tolua_function(  tolua_S,  "getName",  tolua_EmberOgre_Carpenter_BlockSpec_getName00 );
           tolua_function(  tolua_S,  "getBoundingBox",  tolua_EmberOgre_Carpenter_BlockSpec_getBoundingBox00 );
           tolua_function(  tolua_S,  "getAttachPair",  tolua_EmberOgre_Carpenter_BlockSpec_getAttachPair00 );
           tolua_function(  tolua_S,  "addAttachPair",  tolua_EmberOgre_Carpenter_BlockSpec_addAttachPair00 );
           tolua_function(  tolua_S,  "setBoundingBox",  tolua_EmberOgre_Carpenter_BlockSpec_setBoundingBox00 );
           tolua_function(  tolua_S,  "getAllPoints",  tolua_EmberOgre_Carpenter_BlockSpec_getAllPoints00 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "BuildingBlock",  "Carpenter::BuildingBlock",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "BuildingBlock" );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "BuildingBlockSpec",  "Carpenter::BuildingBlockSpec",  "",  tolua_collect_Carpenter__BuildingBlockSpec );
           #else
           tolua_cclass(  tolua_S,  "BuildingBlockSpec",  "Carpenter::BuildingBlockSpec",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "BuildingBlockSpec" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_Carpenter_BuildingBlockSpec_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_Carpenter_BuildingBlockSpec_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_Carpenter_BuildingBlockSpec_new00_local );
           tolua_function(  tolua_S,  "getDefinition",  tolua_EmberOgre_Carpenter_BuildingBlockSpec_getDefinition00 );
           tolua_function(  tolua_S,  "getBlockSpec",  tolua_EmberOgre_Carpenter_BuildingBlockSpec_getBlockSpec00 );
           tolua_function(  tolua_S,  "getName",  tolua_EmberOgre_Carpenter_BuildingBlockSpec_getName00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "BuildingBlockSpecDefinition",  "Carpenter::BuildingBlockSpecDefinition",  "",  tolua_collect_Carpenter__BuildingBlockSpecDefinition );
           #else
           tolua_cclass(  tolua_S,  "BuildingBlockSpecDefinition",  "Carpenter::BuildingBlockSpecDefinition",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "BuildingBlockSpecDefinition" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_Carpenter_BuildingBlockSpecDefinition_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_Carpenter_BuildingBlockSpecDefinition_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_Carpenter_BuildingBlockSpecDefinition_new00_local );
           tolua_variable(  tolua_S,  "mName",  tolua_get_Carpenter__BuildingBlockSpecDefinition_mName,  tolua_set_Carpenter__BuildingBlockSpecDefinition_mName );
           tolua_variable(  tolua_S,  "mBlockSpecName",  tolua_get_Carpenter__BuildingBlockSpecDefinition_mBlockSpecName,  tolua_set_Carpenter__BuildingBlockSpecDefinition_mBlockSpecName );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "BuildingBlockBinding",  "Carpenter::BuildingBlockBinding",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "BuildingBlockBinding" );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "BuildingBlockBindingDefinition",  "Carpenter::BuildingBlockBindingDefinition",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "BuildingBlockBindingDefinition" );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "BuildingBlockDefinition",  "Carpenter::BuildingBlockDefinition",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "BuildingBlockDefinition" );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "BluePrint",  "Carpenter::BluePrint",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "BluePrint" );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Carpenter",  "Carpenter::Carpenter",  "",  tolua_collect_Carpenter__Carpenter );
           #else
           tolua_cclass(  tolua_S,  "Carpenter",  "Carpenter::Carpenter",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Carpenter" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_Carpenter_Carpenter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_Carpenter_Carpenter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_Carpenter_Carpenter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_Carpenter_Carpenter_delete00 );
           tolua_function(  tolua_S,  "createBlueprint",  tolua_EmberOgre_Carpenter_Carpenter_createBlueprint00 );
           tolua_function(  tolua_S,  "getBuildingBlockSpec",  tolua_EmberOgre_Carpenter_Carpenter_getBuildingBlockSpec00 );
           tolua_function(  tolua_S,  "createBlockSpec",  tolua_EmberOgre_Carpenter_Carpenter_createBlockSpec00 );
           tolua_function(  tolua_S,  "createBuildingBlockSpec",  tolua_EmberOgre_Carpenter_Carpenter_createBuildingBlockSpec00 );
           tolua_function(  tolua_S,  "getBlockSpecs",  tolua_EmberOgre_Carpenter_Carpenter_getBlockSpecs00 );
           tolua_function(  tolua_S,  "getBuildingBlockSpecs",  tolua_EmberOgre_Carpenter_Carpenter_getBuildingBlockSpecs00 );
           tolua_function(  tolua_S,  "getBluePrints",  tolua_EmberOgre_Carpenter_Carpenter_getBluePrints00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "AvatarCamera",  "EmberOgre::AvatarCamera",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "AvatarCamera" );
           tolua_constant(  tolua_S,  "MODE_THIRD_PERSON",  EmberOgre::AvatarCamera::MODE_THIRD_PERSON );
           tolua_constant(  tolua_S,  "MODE_FIRST_PERSON",  EmberOgre::AvatarCamera::MODE_FIRST_PERSON );
           tolua_function(  tolua_S,  "pitch",  tolua_EmberOgre_EmberOgre_AvatarCamera_pitch00 );
           tolua_function(  tolua_S,  "yaw",  tolua_EmberOgre_EmberOgre_AvatarCamera_yaw00 );
           tolua_function(  tolua_S,  "getPitch",  tolua_EmberOgre_EmberOgre_AvatarCamera_getPitch00 );
           tolua_function(  tolua_S,  "getYaw",  tolua_EmberOgre_EmberOgre_AvatarCamera_getYaw00 );
           tolua_function(  tolua_S,  "getCamera",  tolua_EmberOgre_EmberOgre_AvatarCamera_getCamera00 );
           tolua_function(  tolua_S,  "getCamera",  tolua_EmberOgre_EmberOgre_AvatarCamera_getCamera01 );
           tolua_function(  tolua_S,  "getOrientation",  tolua_EmberOgre_EmberOgre_AvatarCamera_getOrientation00 );
           tolua_function(  tolua_S,  "getPosition",  tolua_EmberOgre_EmberOgre_AvatarCamera_getPosition00 );
           tolua_function(  tolua_S,  "setMode",  tolua_EmberOgre_EmberOgre_AvatarCamera_setMode00 );
           tolua_function(  tolua_S,  "setAvatarNode",  tolua_EmberOgre_EmberOgre_AvatarCamera_setAvatarNode00 );
           tolua_variable(  tolua_S,  "MovedCamera",  tolua_get_EmberOgre__AvatarCamera_MovedCamera,  tolua_set_EmberOgre__AvatarCamera_MovedCamera );
           tolua_variable(  tolua_S,  "EventChangedCameraDistance",  tolua_get_EmberOgre__AvatarCamera_EventChangedCameraDistance,  tolua_set_EmberOgre__AvatarCamera_EventChangedCameraDistance );
           tolua_function(  tolua_S,  "pickInWorld",  tolua_EmberOgre_EmberOgre_AvatarCamera_pickInWorld00 );
           tolua_function(  tolua_S,  "worldToScreen",  tolua_EmberOgre_EmberOgre_AvatarCamera_worldToScreen00 );
           tolua_function(  tolua_S,  "attach",  tolua_EmberOgre_EmberOgre_AvatarCamera_attach00 );
           tolua_function(  tolua_S,  "setCameraDistance",  tolua_EmberOgre_EmberOgre_AvatarCamera_setCameraDistance00 );
           tolua_function(  tolua_S,  "enableCompositor",  tolua_EmberOgre_EmberOgre_AvatarCamera_enableCompositor00 );
           tolua_function(  tolua_S,  "toggleRenderMode",  tolua_EmberOgre_EmberOgre_AvatarCamera_toggleRenderMode00 );
           tolua_function(  tolua_S,  "takeScreenshot",  tolua_EmberOgre_EmberOgre_AvatarCamera_takeScreenshot00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "AvatarMovementMode",  "EmberOgre::AvatarMovementMode",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "AvatarMovementMode" );
           tolua_constant(  tolua_S,  "MM_WALK",  EmberOgre::AvatarMovementMode::MM_WALK );
           tolua_constant(  tolua_S,  "MM_RUN",  EmberOgre::AvatarMovementMode::MM_RUN );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "AvatarControllerMovement",  "EmberOgre::AvatarControllerMovement",  "",  tolua_collect_EmberOgre__AvatarControllerMovement );
           #else
           tolua_cclass(  tolua_S,  "AvatarControllerMovement",  "EmberOgre::AvatarControllerMovement",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "AvatarControllerMovement" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_AvatarControllerMovement_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_AvatarControllerMovement_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_AvatarControllerMovement_new00_local );
           tolua_variable(  tolua_S,  "rotationDegHoriz",  tolua_get_EmberOgre__AvatarControllerMovement_rotationDegHoriz,  tolua_set_EmberOgre__AvatarControllerMovement_rotationDegHoriz );
           tolua_variable(  tolua_S,  "rotationDegVert",  tolua_get_EmberOgre__AvatarControllerMovement_rotationDegVert,  tolua_set_EmberOgre__AvatarControllerMovement_rotationDegVert );
           tolua_variable(  tolua_S,  "timeSlice",  tolua_get_EmberOgre__AvatarControllerMovement_timeSlice,  tolua_set_EmberOgre__AvatarControllerMovement_timeSlice );
           tolua_variable(  tolua_S,  "movementDirection",  tolua_get_EmberOgre__AvatarControllerMovement_movementDirection,  tolua_set_EmberOgre__AvatarControllerMovement_movementDirection );
           tolua_variable(  tolua_S,  "mode",  tolua_get_EmberOgre__AvatarControllerMovement_mode,  tolua_set_EmberOgre__AvatarControllerMovement_mode );
           tolua_variable(  tolua_S,  "isMoving",  tolua_get_EmberOgre__AvatarControllerMovement_isMoving,  tolua_set_EmberOgre__AvatarControllerMovement_isMoving );
           tolua_variable(  tolua_S,  "cameraOrientation",  tolua_get_EmberOgre__AvatarControllerMovement_cameraOrientation,  tolua_set_EmberOgre__AvatarControllerMovement_cameraOrientation );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "AvatarController",  "EmberOgre::AvatarController",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "AvatarController" );
           tolua_variable(  tolua_S,  "EventMovementModeChanged",  tolua_get_EmberOgre__AvatarController_EventMovementModeChanged,  tolua_set_EmberOgre__AvatarController_EventMovementModeChanged );
           tolua_function(  tolua_S,  "getAvatarCamera",  tolua_EmberOgre_EmberOgre_AvatarController_getAvatarCamera00 );
           tolua_function(  tolua_S,  "detachCamera",  tolua_EmberOgre_EmberOgre_AvatarController_detachCamera00 );
           tolua_function(  tolua_S,  "attachCamera",  tolua_EmberOgre_EmberOgre_AvatarController_attachCamera00 );
           tolua_function(  tolua_S,  "getCurrentMovement",  tolua_EmberOgre_EmberOgre_AvatarController_getCurrentMovement00 );
           tolua_function(  tolua_S,  "moveToPoint",  tolua_EmberOgre_EmberOgre_AvatarController_moveToPoint00 );
           tolua_function(  tolua_S,  "teleportTo",  tolua_EmberOgre_EmberOgre_AvatarController_teleportTo00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "AvatarMovementState",  "EmberOgre::AvatarMovementState",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "AvatarMovementState" );
           tolua_variable(  tolua_S,  "isMoving",  tolua_get_EmberOgre__AvatarMovementState_isMoving,  tolua_set_EmberOgre__AvatarMovementState_isMoving );
           tolua_variable(  tolua_S,  "isRunning",  tolua_get_EmberOgre__AvatarMovementState_isRunning,  tolua_set_EmberOgre__AvatarMovementState_isRunning );
           tolua_variable(  tolua_S,  "velocity",  tolua_get_EmberOgre__AvatarMovementState_velocity,  tolua_set_EmberOgre__AvatarMovementState_velocity );
           tolua_variable(  tolua_S,  "orientation",  tolua_get_EmberOgre__AvatarMovementState_orientation,  tolua_set_EmberOgre__AvatarMovementState_orientation );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "Avatar",  "EmberOgre::Avatar",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Avatar" );
           tolua_function(  tolua_S,  "getAvatarCamera",  tolua_EmberOgre_EmberOgre_Avatar_getAvatarCamera00 );
           tolua_function(  tolua_S,  "getAvatarSceneNode",  tolua_EmberOgre_EmberOgre_Avatar_getAvatarSceneNode00 );
           tolua_function(  tolua_S,  "setAvatarController",  tolua_EmberOgre_EmberOgre_Avatar_setAvatarController00 );
           tolua_function(  tolua_S,  "getAvatarEmberEntity",  tolua_EmberOgre_EmberOgre_Avatar_getAvatarEmberEntity00 );
           tolua_function(  tolua_S,  "setMinIntervalOfRotationChanges",  tolua_EmberOgre_EmberOgre_Avatar_setMinIntervalOfRotationChanges00 );
           tolua_variable(  tolua_S,  "EventAddedEntityToInventory",  tolua_get_EmberOgre__Avatar_EventAddedEntityToInventory,  tolua_set_EmberOgre__Avatar_EventAddedEntityToInventory );
           tolua_variable(  tolua_S,  "EventRemovedEntityFromInventory",  tolua_get_EmberOgre__Avatar_EventRemovedEntityFromInventory,  tolua_set_EmberOgre__Avatar_EventRemovedEntityFromInventory );
           tolua_function(  tolua_S,  "isAdmin",  tolua_EmberOgre_EmberOgre_Avatar_isAdmin00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "EmberEntityFactory",  "EmberOgre::EmberEntityFactory",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "EmberEntityFactory" );
           tolua_function(  tolua_S,  "getWorld",  tolua_EmberOgre_EmberOgre_EmberEntityFactory_getWorld00 );
           tolua_function(  tolua_S,  "dumpAttributesOfEntity",  tolua_EmberOgre_EmberOgre_EmberEntityFactory_dumpAttributesOfEntity00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "EmberEntity",  "EmberOgre::EmberEntity",  "Eris::Entity",  NULL );
           tolua_beginmodule(  tolua_S,  "EmberEntity" );
           tolua_constant(  tolua_S,  "MM_DEFAULT",  EmberOgre::EmberEntity::MM_DEFAULT );
           tolua_constant(  tolua_S,  "MM_STANDING",  EmberOgre::EmberEntity::MM_STANDING );
           tolua_constant(  tolua_S,  "MM_FLOATING",  EmberOgre::EmberEntity::MM_FLOATING );
           tolua_constant(  tolua_S,  "MM_PROJECTILE",  EmberOgre::EmberEntity::MM_PROJECTILE );
           tolua_constant(  tolua_S,  "MM_SWIMMING",  EmberOgre::EmberEntity::MM_SWIMMING );
           tolua_constant(  tolua_S,  "MM_WALKING",  EmberOgre::EmberEntity::MM_WALKING );
           tolua_constant(  tolua_S,  "MM_RUNNING",  EmberOgre::EmberEntity::MM_RUNNING );
           tolua_constant(  tolua_S,  "MM_FIXED",  EmberOgre::EmberEntity::MM_FIXED );
           tolua_function(  tolua_S,  "getSceneNode",  tolua_EmberOgre_EmberOgre_EmberEntity_getSceneNode00 );
           tolua_function(  tolua_S,  "hasSuggestedResponses",  tolua_EmberOgre_EmberOgre_EmberEntity_hasSuggestedResponses00 );
           tolua_function(  tolua_S,  "getSuggestedResponses",  tolua_EmberOgre_EmberOgre_EmberEntity_getSuggestedResponses00 );
           tolua_function(  tolua_S,  "setVisible",  tolua_EmberOgre_EmberOgre_EmberEntity_setVisible00 );
           tolua_function(  tolua_S,  "getEmberLocation",  tolua_EmberOgre_EmberOgre_EmberEntity_getEmberLocation00 );
           tolua_function(  tolua_S,  "isInitialized",  tolua_EmberOgre_EmberOgre_EmberEntity_isInitialized00 );
           tolua_function(  tolua_S,  "getMovementMode",  tolua_EmberOgre_EmberOgre_EmberEntity_getMovementMode00 );
           tolua_function(  tolua_S,  "showOgreBoundingBox",  tolua_EmberOgre_EmberOgre_EmberEntity_showOgreBoundingBox00 );
           tolua_function(  tolua_S,  "showErisBoundingBox",  tolua_EmberOgre_EmberOgre_EmberEntity_showErisBoundingBox00 );
           tolua_function(  tolua_S,  "getShowOgreBoundingBox",  tolua_EmberOgre_EmberOgre_EmberEntity_getShowOgreBoundingBox00 );
           tolua_function(  tolua_S,  "getShowErisBoundingBox",  tolua_EmberOgre_EmberOgre_EmberEntity_getShowErisBoundingBox00 );
           tolua_function(  tolua_S,  "getWorldBoundingBox",  tolua_EmberOgre_EmberOgre_EmberEntity_getWorldBoundingBox00 );
           tolua_function(  tolua_S,  "getDefaultUseOperators",  tolua_EmberOgre_EmberOgre_EmberEntity_getDefaultUseOperators00 );
           tolua_function(  tolua_S,  "setVisualize",  tolua_EmberOgre_EmberOgre_EmberEntity_setVisualize00 );
           tolua_function(  tolua_S,  "getVisualize",  tolua_EmberOgre_EmberOgre_EmberEntity_getVisualize00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "EmberPhysicalEntity",  "EmberOgre::EmberPhysicalEntity",  "EmberOgre::EmberEntity",  NULL );
           tolua_beginmodule(  tolua_S,  "EmberPhysicalEntity" );
           tolua_variable(  tolua_S,  "ACTION_STAND",  tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_STAND,  NULL );
           tolua_variable(  tolua_S,  "ACTION_RUN",  tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_RUN,  NULL );
           tolua_variable(  tolua_S,  "ACTION_WALK",  tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_WALK,  NULL );
           tolua_variable(  tolua_S,  "ACTION_SWIM",  tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_SWIM,  NULL );
           tolua_variable(  tolua_S,  "ACTION_FLOAT",  tolua_get_EmberOgre__EmberPhysicalEntity_ACTION_FLOAT,  NULL );
           tolua_function(  tolua_S,  "getModel",  tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getModel00 );
           tolua_function(  tolua_S,  "getScaleNode",  tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getScaleNode00 );
           tolua_function(  tolua_S,  "getEntityAttachedToPoint",  tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getEntityAttachedToPoint00 );
           tolua_function(  tolua_S,  "getWorldBoundingBox",  tolua_EmberOgre_EmberOgre_EmberPhysicalEntity_getWorldBoundingBox00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "AvatarEmberEntity",  "EmberOgre::AvatarEmberEntity",  "EmberOgre::EmberPhysicalEntity",  NULL );
           tolua_beginmodule(  tolua_S,  "AvatarEmberEntity" );
           tolua_function(  tolua_S,  "getAvatar",  tolua_EmberOgre_EmberOgre_AvatarEmberEntity_getAvatar00 );
           tolua_function(  tolua_S,  "getAvatarSceneNode",  tolua_EmberOgre_EmberOgre_AvatarEmberEntity_getAvatarSceneNode00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "WorldEmberEntity",  "EmberOgre::WorldEmberEntity",  "EmberOgre::EmberEntity",  NULL );
           tolua_beginmodule(  tolua_S,  "WorldEmberEntity" );
           tolua_function(  tolua_S,  "getEnvironment",  tolua_EmberOgre_EmberOgre_WorldEmberEntity_getEnvironment00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Environment",  0 );
           tolua_beginmodule(  tolua_S,  "Environment" );
           tolua_cclass(  tolua_S,  "ISun",  "EmberOgre::Environment::ISun",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ISun" );
           tolua_function(  tolua_S,  "setAmbientLight",  tolua_EmberOgre_EmberOgre_Environment_ISun_setAmbientLight00 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "ISky",  "EmberOgre::Environment::ISky",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ISky" );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "IFog",  "EmberOgre::Environment::IFog",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "IFog" );
           tolua_function(  tolua_S,  "setDensity",  tolua_EmberOgre_EmberOgre_Environment_IFog_setDensity00 );
           tolua_function(  tolua_S,  "getDensity",  tolua_EmberOgre_EmberOgre_Environment_IFog_getDensity00 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "IWater",  "EmberOgre::Environment::IWater",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "IWater" );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "Environment",  "EmberOgre::Environment::Environment",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Environment" );
           tolua_function(  tolua_S,  "getSun",  tolua_EmberOgre_EmberOgre_Environment_Environment_getSun00 );
           tolua_function(  tolua_S,  "getSky",  tolua_EmberOgre_EmberOgre_Environment_Environment_getSky00 );
           tolua_function(  tolua_S,  "getFog",  tolua_EmberOgre_EmberOgre_Environment_Environment_getFog00 );
           tolua_function(  tolua_S,  "getWater",  tolua_EmberOgre_EmberOgre_Environment_Environment_getWater00 );
           tolua_function(  tolua_S,  "setTime",  tolua_EmberOgre_EmberOgre_Environment_Environment_setTime00 );
           tolua_function(  tolua_S,  "setTime",  tolua_EmberOgre_EmberOgre_Environment_Environment_setTime01 );
           tolua_function(  tolua_S,  "setAmbientLight",  tolua_EmberOgre_EmberOgre_Environment_Environment_setAmbientLight00 );
           tolua_variable(  tolua_S,  "EventUpdatedAmbientLight",  tolua_get_EmberOgre__Environment__Environment_EventUpdatedAmbientLight,  tolua_set_EmberOgre__Environment__Environment_EventUpdatedAmbientLight );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "GUIManager",  "EmberOgre::GUIManager",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "GUIManager" );
           tolua_function(  tolua_S,  "getSingleton",  tolua_EmberOgre_EmberOgre_GUIManager_getSingleton00 );
           tolua_variable(  tolua_S,  "AppendIGChatLine",  tolua_get_EmberOgre__GUIManager_AppendIGChatLine,  tolua_set_EmberOgre__GUIManager_AppendIGChatLine );
           tolua_variable(  tolua_S,  "AppendOOGChatLine",  tolua_get_EmberOgre__GUIManager_AppendOOGChatLine,  tolua_set_EmberOgre__GUIManager_AppendOOGChatLine );
           tolua_variable(  tolua_S,  "AppendAvatarImaginary",  tolua_get_EmberOgre__GUIManager_AppendAvatarImaginary,  tolua_set_EmberOgre__GUIManager_AppendAvatarImaginary );
           tolua_variable(  tolua_S,  "EventEntityAction",  tolua_get_EmberOgre__GUIManager_EventEntityAction,  tolua_set_EmberOgre__GUIManager_EventEntityAction );
           tolua_variable(  tolua_S,  "EventFrameStarted",  tolua_get_EmberOgre__GUIManager_EventFrameStarted,  tolua_set_EmberOgre__GUIManager_EventFrameStarted );
           tolua_function(  tolua_S,  "removeWidget",  tolua_EmberOgre_EmberOgre_GUIManager_removeWidget00 );
           tolua_function(  tolua_S,  "addWidget",  tolua_EmberOgre_EmberOgre_GUIManager_addWidget00 );
           tolua_function(  tolua_S,  "EmitEntityAction",  tolua_EmberOgre_EmberOgre_GUIManager_EmitEntityAction00 );
           tolua_function(  tolua_S,  "getMainSheet",  tolua_EmberOgre_EmberOgre_GUIManager_getMainSheet00 );
           tolua_function(  tolua_S,  "setDebugText",  tolua_EmberOgre_EmberOgre_GUIManager_setDebugText00 );
           tolua_function(  tolua_S,  "isInGUIMode",  tolua_EmberOgre_EmberOgre_GUIManager_isInGUIMode00 );
           tolua_function(  tolua_S,  "isInMovementKeysMode",  tolua_EmberOgre_EmberOgre_GUIManager_isInMovementKeysMode00 );
           tolua_function(  tolua_S,  "getInput",  tolua_EmberOgre_EmberOgre_GUIManager_getInput00 );
           tolua_function(  tolua_S,  "createWindow",  tolua_EmberOgre_EmberOgre_GUIManager_createWindow00 );
           tolua_function(  tolua_S,  "createWindow",  tolua_EmberOgre_EmberOgre_GUIManager_createWindow01 );
           tolua_function(  tolua_S,  "createWidget",  tolua_EmberOgre_EmberOgre_GUIManager_createWidget00 );
           tolua_function(  tolua_S,  "createWidget",  tolua_EmberOgre_EmberOgre_GUIManager_createWidget01 );
           tolua_function(  tolua_S,  "getDefaultScheme",  tolua_EmberOgre_EmberOgre_GUIManager_getDefaultScheme00 );
           tolua_function(  tolua_S,  "getEntityPickListener",  tolua_EmberOgre_EmberOgre_GUIManager_getEntityPickListener00 );
           tolua_function(  tolua_S,  "getIconManager",  tolua_EmberOgre_EmberOgre_GUIManager_getIconManager00 );
           tolua_function(  tolua_S,  "getEntityIconManager",  tolua_EmberOgre_EmberOgre_GUIManager_getEntityIconManager00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Mercator",  0 );
           tolua_beginmodule(  tolua_S,  "Mercator" );
           tolua_cclass(  tolua_S,  "Area",  "Mercator::Area",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Area" );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Terrain",  0 );
           tolua_beginmodule(  tolua_S,  "Terrain" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "TerrainArea",  "EmberOgre::Terrain::TerrainArea",  "",  tolua_collect_EmberOgre__Terrain__TerrainArea );
           #else
           tolua_cclass(  tolua_S,  "TerrainArea",  "EmberOgre::Terrain::TerrainArea",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "TerrainArea" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_new00_local );
           tolua_function(  tolua_S,  "init",  tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_init00 );
           tolua_function(  tolua_S,  "getArea",  tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_getArea00 );
           tolua_function(  tolua_S,  "setArea",  tolua_EmberOgre_EmberOgre_Terrain_TerrainArea_setArea00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Terrain",  0 );
           tolua_beginmodule(  tolua_S,  "Terrain" );
           tolua_cclass(  tolua_S,  "BasePointUserObject",  "EmberOgre::Terrain::BasePointUserObject",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "BasePointUserObject" );
           tolua_function(  tolua_S,  "getBasePoint",  tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getBasePoint00 );
           tolua_function(  tolua_S,  "getBasePointMarkerNode",  tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getBasePointMarkerNode00 );
           tolua_function(  tolua_S,  "getPosition",  tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getPosition00 );
           tolua_function(  tolua_S,  "getHeight",  tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_getHeight00 );
           tolua_function(  tolua_S,  "translate",  tolua_EmberOgre_EmberOgre_Terrain_BasePointUserObject_translate00 );
           tolua_variable(  tolua_S,  "EventUpdatedPosition",  tolua_get_EmberOgre__Terrain__BasePointUserObject_EventUpdatedPosition,  tolua_set_EmberOgre__Terrain__BasePointUserObject_EventUpdatedPosition );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "TerrainEditAction",  "EmberOgre::Terrain::TerrainEditAction",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "TerrainEditAction" );
           tolua_function(  tolua_S,  "getMovements",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditAction_getMovements00 );
           tolua_function(  tolua_S,  "getMovements",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditAction_getMovements01 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "TerrainEditBasePointMovement",  "EmberOgre::Terrain::TerrainEditBasePointMovement",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "TerrainEditBasePointMovement" );
           tolua_function(  tolua_S,  "getVerticalMovement",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditBasePointMovement_getVerticalMovement00 );
           tolua_function(  tolua_S,  "getPosition",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditBasePointMovement_getPosition00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "TerrainEditor",  "EmberOgre::Terrain::TerrainEditor",  "",  tolua_collect_EmberOgre__Terrain__TerrainEditor );
           #else
           tolua_cclass(  tolua_S,  "TerrainEditor",  "EmberOgre::Terrain::TerrainEditor",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "TerrainEditor" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_delete00 );
           tolua_function(  tolua_S,  "showOverlay",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_showOverlay00 );
           tolua_function(  tolua_S,  "hideOverlay",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_hideOverlay00 );
           tolua_function(  tolua_S,  "createOverlay",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_createOverlay00 );
           tolua_function(  tolua_S,  "isOverlayShown",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_isOverlayShown00 );
           tolua_function(  tolua_S,  "commitAction",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_commitAction00 );
           tolua_variable(  tolua_S,  "EventPickedBasePoint",  tolua_get_EmberOgre__Terrain__TerrainEditor_EventPickedBasePoint,  tolua_set_EmberOgre__Terrain__TerrainEditor_EventPickedBasePoint );
           tolua_variable(  tolua_S,  "EventActionCreated",  tolua_get_EmberOgre__Terrain__TerrainEditor_EventActionCreated,  tolua_set_EmberOgre__Terrain__TerrainEditor_EventActionCreated );
           tolua_variable(  tolua_S,  "EventSelectedBasePointUpdatedPosition",  tolua_get_EmberOgre__Terrain__TerrainEditor_EventSelectedBasePointUpdatedPosition,  tolua_set_EmberOgre__Terrain__TerrainEditor_EventSelectedBasePointUpdatedPosition );
           tolua_function(  tolua_S,  "getCurrentBasePointUserObject",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_getCurrentBasePointUserObject00 );
           tolua_function(  tolua_S,  "sendChangesToServer",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_sendChangesToServer00 );
           tolua_function(  tolua_S,  "createAction",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_createAction00 );
           tolua_function(  tolua_S,  "undoLastAction",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_undoLastAction00 );
           tolua_function(  tolua_S,  "redoAction",  tolua_EmberOgre_EmberOgre_Terrain_TerrainEditor_redoAction00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "MotionManager",  "EmberOgre::MotionManager",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "MotionManager" );
           tolua_cclass(  tolua_S,  "MotionManagerInfo",  "EmberOgre::MotionManager::MotionManagerInfo",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "MotionManagerInfo" );
           tolua_variable(  tolua_S,  "AnimatedEntities",  tolua_get_EmberOgre__MotionManager__MotionManagerInfo_AnimatedEntities,  tolua_set_EmberOgre__MotionManager__MotionManagerInfo_AnimatedEntities );
           tolua_variable(  tolua_S,  "MovingEntities",  tolua_get_EmberOgre__MotionManager__MotionManagerInfo_MovingEntities,  tolua_set_EmberOgre__MotionManager__MotionManagerInfo_MovingEntities );
           tolua_variable(  tolua_S,  "Animations",  tolua_get_EmberOgre__MotionManager__MotionManagerInfo_Animations,  tolua_set_EmberOgre__MotionManager__MotionManagerInfo_Animations );
           tolua_endmodule(  tolua_S );
           tolua_function(  tolua_S,  "getSingleton",  tolua_EmberOgre_EmberOgre_MotionManager_getSingleton00 );
           tolua_function(  tolua_S,  "addEntity",  tolua_EmberOgre_EmberOgre_MotionManager_addEntity00 );
           tolua_function(  tolua_S,  "removeEntity",  tolua_EmberOgre_EmberOgre_MotionManager_removeEntity00 );
           tolua_function(  tolua_S,  "addAnimation",  tolua_EmberOgre_EmberOgre_MotionManager_addAnimation00 );
           tolua_function(  tolua_S,  "removeAnimation",  tolua_EmberOgre_EmberOgre_MotionManager_removeAnimation00 );
           tolua_function(  tolua_S,  "pauseAnimation",  tolua_EmberOgre_EmberOgre_MotionManager_pauseAnimation00 );
           tolua_function(  tolua_S,  "unpauseAnimation",  tolua_EmberOgre_EmberOgre_MotionManager_unpauseAnimation00 );
           tolua_function(  tolua_S,  "addAnimatedEntity",  tolua_EmberOgre_EmberOgre_MotionManager_addAnimatedEntity00 );
           tolua_function(  tolua_S,  "removeAnimatedEntity",  tolua_EmberOgre_EmberOgre_MotionManager_removeAnimatedEntity00 );
           tolua_function(  tolua_S,  "getInfo",  tolua_EmberOgre_EmberOgre_MotionManager_getInfo00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_cclass(  tolua_S,  "Widget",  "EmberOgre::Gui::Widget",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Widget" );
           tolua_function(  tolua_S,  "show",  tolua_EmberOgre_EmberOgre_Gui_Widget_show00 );
           tolua_function(  tolua_S,  "hide",  tolua_EmberOgre_EmberOgre_Gui_Widget_hide00 );
           tolua_function(  tolua_S,  "getWindow",  tolua_EmberOgre_EmberOgre_Gui_Widget_getWindow00 );
           tolua_function(  tolua_S,  "enableCloseButton",  tolua_EmberOgre_EmberOgre_Gui_Widget_enableCloseButton00 );
           tolua_function(  tolua_S,  "registerConsoleVisibilityToggleCommand",  tolua_EmberOgre_EmberOgre_Gui_Widget_registerConsoleVisibilityToggleCommand00 );
           tolua_function(  tolua_S,  "getMainSheet",  tolua_EmberOgre_EmberOgre_Gui_Widget_getMainSheet00 );
           tolua_function(  tolua_S,  "getMainWindow",  tolua_EmberOgre_EmberOgre_Gui_Widget_getMainWindow00 );
           tolua_function(  tolua_S,  "createWindow",  tolua_EmberOgre_EmberOgre_Gui_Widget_createWindow00 );
           tolua_function(  tolua_S,  "createWindow",  tolua_EmberOgre_EmberOgre_Gui_Widget_createWindow01 );
           tolua_function(  tolua_S,  "loadMainSheet",  tolua_EmberOgre_EmberOgre_Gui_Widget_loadMainSheet00 );
           tolua_function(  tolua_S,  "getPrefix",  tolua_EmberOgre_EmberOgre_Gui_Widget_getPrefix00 );
           tolua_function(  tolua_S,  "getIsActiveWindowOpaque",  tolua_EmberOgre_EmberOgre_Gui_Widget_getIsActiveWindowOpaque00 );
           tolua_function(  tolua_S,  "setIsActiveWindowOpaque",  tolua_EmberOgre_EmberOgre_Gui_Widget_setIsActiveWindowOpaque00 );
           tolua_function(  tolua_S,  "getDefaultScheme",  tolua_EmberOgre_EmberOgre_Gui_Widget_getDefaultScheme00 );
           tolua_function(  tolua_S,  "addTabbableWindow",  tolua_EmberOgre_EmberOgre_Gui_Widget_addTabbableWindow00 );
           tolua_function(  tolua_S,  "closeTabGroup",  tolua_EmberOgre_EmberOgre_Gui_Widget_closeTabGroup00 );
           tolua_variable(  tolua_S,  "EventFrameStarted",  tolua_get_EmberOgre__Gui__Widget_EventFrameStarted,  tolua_set_EmberOgre__Gui__Widget_EventFrameStarted );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "IconBase",  "EmberOgre::Gui::IconBase",  "",  tolua_collect_EmberOgre__Gui__IconBase );
           #else
           tolua_cclass(  tolua_S,  "IconBase",  "EmberOgre::Gui::IconBase",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "IconBase" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_IconBase_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_IconBase_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_IconBase_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_IconBase_delete00 );
           tolua_function(  tolua_S,  "getContainer",  tolua_EmberOgre_EmberOgre_Gui_IconBase_getContainer00 );
           tolua_function(  tolua_S,  "getButton",  tolua_EmberOgre_EmberOgre_Gui_IconBase_getButton00 );
           tolua_function(  tolua_S,  "setForeground",  tolua_EmberOgre_EmberOgre_Gui_IconBase_setForeground00 );
           tolua_function(  tolua_S,  "loadImageFromImageset",  tolua_EmberOgre_EmberOgre_Gui_IconBase_loadImageFromImageset00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "IconBar",  "EmberOgre::Gui::IconBar",  "",  tolua_collect_EmberOgre__Gui__IconBar );
           #else
           tolua_cclass(  tolua_S,  "IconBar",  "EmberOgre::Gui::IconBar",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "IconBar" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_IconBar_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_IconBar_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_IconBar_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_IconBar_delete00 );
           tolua_function(  tolua_S,  "addIcon",  tolua_EmberOgre_EmberOgre_Gui_IconBar_addIcon00 );
           tolua_function(  tolua_S,  "removeIcon",  tolua_EmberOgre_EmberOgre_Gui_IconBar_removeIcon00 );
           tolua_function(  tolua_S,  "getWindow",  tolua_EmberOgre_EmberOgre_Gui_IconBar_getWindow00 );
           tolua_function(  tolua_S,  "setIconPadding",  tolua_EmberOgre_EmberOgre_Gui_IconBar_setIconPadding00 );
           tolua_function(  tolua_S,  "getAbsoluteHeight",  tolua_EmberOgre_EmberOgre_Gui_IconBar_getAbsoluteHeight00 );
           tolua_function(  tolua_S,  "getAbsoluteWidth",  tolua_EmberOgre_EmberOgre_Gui_IconBar_getAbsoluteWidth00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "EntityEditor",  "EmberOgre::Gui::EntityEditor",  "",  tolua_collect_EmberOgre__Gui__EntityEditor );
           #else
           tolua_cclass(  tolua_S,  "EntityEditor",  "EmberOgre::Gui::EntityEditor",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "EntityEditor" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_delete00 );
           tolua_function(  tolua_S,  "submitChanges",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_submitChanges00 );
           tolua_function(  tolua_S,  "createMapElement",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createMapElement00 );
           tolua_function(  tolua_S,  "createListElement",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createListElement00 );
           tolua_function(  tolua_S,  "createStringElement",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createStringElement00 );
           tolua_function(  tolua_S,  "createIntElement",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createIntElement00 );
           tolua_function(  tolua_S,  "createFloatElement",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createFloatElement00 );
           tolua_function(  tolua_S,  "createPosition2dElement",  tolua_EmberOgre_EmberOgre_Gui_EntityEditor_createPosition2dElement00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "StackableContainer",  "EmberOgre::Gui::StackableContainer",  "",  tolua_collect_EmberOgre__Gui__StackableContainer );
           #else
           tolua_cclass(  tolua_S,  "StackableContainer",  "EmberOgre::Gui::StackableContainer",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "StackableContainer" );
           tolua_constant(  tolua_S,  "Horizontal",  EmberOgre::Gui::StackableContainer::Horizontal );
           tolua_constant(  tolua_S,  "Vertical",  EmberOgre::Gui::StackableContainer::Vertical );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_delete00 );
           tolua_function(  tolua_S,  "setInnerContainerWindow",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_setInnerContainerWindow00 );
           tolua_function(  tolua_S,  "getWindow",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getWindow00 );
           tolua_function(  tolua_S,  "setPadding",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_setPadding00 );
           tolua_function(  tolua_S,  "getPadding",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getPadding00 );
           tolua_function(  tolua_S,  "getAbsoluteHeight",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getAbsoluteHeight00 );
           tolua_function(  tolua_S,  "getAbsoluteWidth",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getAbsoluteWidth00 );
           tolua_function(  tolua_S,  "setFlowDirection",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_setFlowDirection00 );
           tolua_function(  tolua_S,  "getFlowDirection",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_getFlowDirection00 );
           tolua_function(  tolua_S,  "repositionWindows",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_repositionWindows00 );
           tolua_function(  tolua_S,  "disconnect",  tolua_EmberOgre_EmberOgre_Gui_StackableContainer_disconnect00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "ConsoleAdapter",  "EmberOgre::Gui::ConsoleAdapter",  "",  tolua_collect_EmberOgre__Gui__ConsoleAdapter );
           #else
           tolua_cclass(  tolua_S,  "ConsoleAdapter",  "EmberOgre::Gui::ConsoleAdapter",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "ConsoleAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_ConsoleAdapter_delete00 );
           tolua_variable(  tolua_S,  "EventCommandExecuted",  tolua_get_EmberOgre__Gui__ConsoleAdapter_EventCommandExecuted,  tolua_set_EmberOgre__Gui__ConsoleAdapter_EventCommandExecuted );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_cclass(  tolua_S,  "ColouredListItem",  "EmberOgre::Gui::ColouredListItem",  "CEGUI::ListboxTextItem",  NULL );
           tolua_beginmodule(  tolua_S,  "ColouredListItem" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new00 );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new01 );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_ColouredListItem_new02 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "AssetsManager",  "EmberOgre::Gui::AssetsManager",  "",  tolua_collect_EmberOgre__Gui__AssetsManager );
           #else
           tolua_cclass(  tolua_S,  "AssetsManager",  "EmberOgre::Gui::AssetsManager",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "AssetsManager" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_AssetsManager_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_AssetsManager_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_AssetsManager_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_AssetsManager_delete00 );
           tolua_function(  tolua_S,  "getCEGUIImage",  tolua_EmberOgre_EmberOgre_Gui_AssetsManager_getCEGUIImage00 );
           tolua_function(  tolua_S,  "showTexture",  tolua_EmberOgre_EmberOgre_Gui_AssetsManager_showTexture00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Icons",  0 );
           tolua_beginmodule(  tolua_S,  "Icons" );
           tolua_cclass(  tolua_S,  "Icon",  "EmberOgre::Gui::Icons::Icon",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Icon" );
           tolua_function(  tolua_S,  "getImage",  tolua_EmberOgre_EmberOgre_Gui_Icons_Icon_getImage00 );
           tolua_function(  tolua_S,  "getImage",  tolua_EmberOgre_EmberOgre_Gui_Icons_Icon_getImage01 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Icons",  0 );
           tolua_beginmodule(  tolua_S,  "Icons" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "IconManager",  "EmberOgre::Gui::Icons::IconManager",  "",  tolua_collect_EmberOgre__Gui__Icons__IconManager );
           #else
           tolua_cclass(  tolua_S,  "IconManager",  "EmberOgre::Gui::Icons::IconManager",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "IconManager" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_delete00 );
           tolua_function(  tolua_S,  "getIcon",  tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_getIcon00 );
           tolua_function(  tolua_S,  "getIcon",  tolua_EmberOgre_EmberOgre_Gui_Icons_IconManager_getIcon01 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_cclass(  tolua_S,  "EntityIconSlot",  "EmberOgre::Gui::EntityIconSlot",  "EmberOgre::Gui::EntityIconDragDropTarget",  NULL );
           tolua_beginmodule(  tolua_S,  "EntityIconSlot" );
           tolua_function(  tolua_S,  "addEntityIcon",  tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_addEntityIcon00 );
           tolua_function(  tolua_S,  "removeEntityIcon",  tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_removeEntityIcon00 );
           tolua_function(  tolua_S,  "getEntityIcon",  tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_getEntityIcon00 );
           tolua_function(  tolua_S,  "getWindow",  tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_getWindow00 );
           tolua_function(  tolua_S,  "notifyIconDraggedOff",  tolua_EmberOgre_EmberOgre_Gui_EntityIconSlot_notifyIconDraggedOff00 );
           tolua_variable(  tolua_S,  "EventIconDraggedOff",  tolua_get_EmberOgre__Gui__EntityIconSlot_EventIconDraggedOff,  tolua_set_EmberOgre__Gui__EntityIconSlot_EventIconDraggedOff );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_cclass(  tolua_S,  "EntityIcon",  "EmberOgre::Gui::EntityIcon",  "EmberOgre::Gui::EntityIconDragDropTarget",  NULL );
           tolua_beginmodule(  tolua_S,  "EntityIcon" );
           tolua_function(  tolua_S,  "getImage",  tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getImage00 );
           tolua_function(  tolua_S,  "getDragContainer",  tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getDragContainer00 );
           tolua_function(  tolua_S,  "getIcon",  tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getIcon00 );
           tolua_function(  tolua_S,  "setSlot",  tolua_EmberOgre_EmberOgre_Gui_EntityIcon_setSlot00 );
           tolua_function(  tolua_S,  "getSlot",  tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getSlot00 );
           tolua_function(  tolua_S,  "setTooltipText",  tolua_EmberOgre_EmberOgre_Gui_EntityIcon_setTooltipText00 );
           tolua_function(  tolua_S,  "getEntity",  tolua_EmberOgre_EmberOgre_Gui_EntityIcon_getEntity00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_cclass(  tolua_S,  "EntityIconManager",  "EmberOgre::Gui::EntityIconManager",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "EntityIconManager" );
           tolua_function(  tolua_S,  "createSlot",  tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_createSlot00 );
           tolua_function(  tolua_S,  "destroySlot",  tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_destroySlot00 );
           tolua_function(  tolua_S,  "createIcon",  tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_createIcon00 );
           tolua_function(  tolua_S,  "destroyIcon",  tolua_EmberOgre_EmberOgre_Gui_EntityIconManager_destroyIcon00 );
           tolua_variable(  tolua_S,  "EventIconDragStart",  tolua_get_EmberOgre__Gui__EntityIconManager_EventIconDragStart,  tolua_set_EmberOgre__Gui__EntityIconManager_EventIconDragStart );
           tolua_variable(  tolua_S,  "EventIconDragStop",  tolua_get_EmberOgre__Gui__EntityIconManager_EventIconDragStop,  tolua_set_EmberOgre__Gui__EntityIconManager_EventIconDragStop );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_cclass(  tolua_S,  "EntityIconDragDropTarget",  "EmberOgre::Gui::EntityIconDragDropTarget",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "EntityIconDragDropTarget" );
           tolua_variable(  tolua_S,  "EventIconEntered",  tolua_get_EmberOgre__Gui__EntityIconDragDropTarget_EventIconEntered,  tolua_set_EmberOgre__Gui__EntityIconDragDropTarget_EventIconEntered );
           tolua_variable(  tolua_S,  "EventIconLeaves",  tolua_get_EmberOgre__Gui__EntityIconDragDropTarget_EventIconLeaves,  tolua_set_EmberOgre__Gui__EntityIconDragDropTarget_EventIconLeaves );
           tolua_variable(  tolua_S,  "EventIconDropped",  tolua_get_EmberOgre__Gui__EntityIconDragDropTarget_EventIconDropped,  tolua_set_EmberOgre__Gui__EntityIconDragDropTarget_EventIconDropped );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Model",  0 );
           tolua_beginmodule(  tolua_S,  "Model" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Model",  "EmberOgre::Model::Model",  "",  tolua_collect_EmberOgre__Model__Model );
           #else
           tolua_cclass(  tolua_S,  "Model",  "EmberOgre::Model::Model",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Model" );
           tolua_function(  tolua_S,  "createModel",  tolua_EmberOgre_EmberOgre_Model_Model_createModel00 );
           tolua_function(  tolua_S,  "createModel",  tolua_EmberOgre_EmberOgre_Model_Model_createModel01 );
           tolua_function(  tolua_S,  "reload",  tolua_EmberOgre_EmberOgre_Model_Model_reload00 );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Model_Model_delete00 );
           tolua_function(  tolua_S,  "addSubmodel",  tolua_EmberOgre_EmberOgre_Model_Model_addSubmodel00 );
           tolua_function(  tolua_S,  "removeSubmodel",  tolua_EmberOgre_EmberOgre_Model_Model_removeSubmodel00 );
           tolua_function(  tolua_S,  "getAction",  tolua_EmberOgre_EmberOgre_Model_Model_getAction00 );
           tolua_function(  tolua_S,  "showPart",  tolua_EmberOgre_EmberOgre_Model_Model_showPart00 );
           tolua_function(  tolua_S,  "hidePart",  tolua_EmberOgre_EmberOgre_Model_Model_hidePart00 );
           tolua_function(  tolua_S,  "setVisible",  tolua_EmberOgre_EmberOgre_Model_Model_setVisible00 );
           tolua_function(  tolua_S,  "getScale",  tolua_EmberOgre_EmberOgre_Model_Model_getScale00 );
           tolua_function(  tolua_S,  "getRotation",  tolua_EmberOgre_EmberOgre_Model_Model_getRotation00 );
           tolua_function(  tolua_S,  "getUseScaleOf",  tolua_EmberOgre_EmberOgre_Model_Model_getUseScaleOf00 );
           tolua_function(  tolua_S,  "getName",  tolua_EmberOgre_EmberOgre_Model_Model_getName00 );
           tolua_function(  tolua_S,  "getDefinition",  tolua_EmberOgre_EmberOgre_Model_Model_getDefinition00 );
           tolua_function(  tolua_S,  "hasAttachPoint",  tolua_EmberOgre_EmberOgre_Model_Model_hasAttachPoint00 );
           tolua_function(  tolua_S,  "hasParticles",  tolua_EmberOgre_EmberOgre_Model_Model_hasParticles00 );
           tolua_function(  tolua_S,  "getSubModel",  tolua_EmberOgre_EmberOgre_Model_Model_getSubModel00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Model",  0 );
           tolua_beginmodule(  tolua_S,  "Model" );
           tolua_cclass(  tolua_S,  "SubModel",  "EmberOgre::Model::SubModel",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "SubModel" );
           tolua_function(  tolua_S,  "getEntity",  tolua_EmberOgre_EmberOgre_Model_SubModel_getEntity00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Model",  0 );
           tolua_beginmodule(  tolua_S,  "Model" );
           tolua_cclass(  tolua_S,  "ViewDefinition",  "EmberOgre::Model::ViewDefinition",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ViewDefinition" );
           tolua_variable(  tolua_S,  "Name",  tolua_get_EmberOgre__Model__ViewDefinition_Name,  tolua_set_EmberOgre__Model__ViewDefinition_Name );
           tolua_variable(  tolua_S,  "Rotation",  tolua_get_EmberOgre__Model__ViewDefinition_Rotation,  tolua_set_EmberOgre__Model__ViewDefinition_Rotation );
           tolua_variable(  tolua_S,  "Distance",  tolua_get_EmberOgre__Model__ViewDefinition_Distance,  tolua_set_EmberOgre__Model__ViewDefinition_Distance );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "AttachPointDefinition",  "EmberOgre::Model::AttachPointDefinition",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "AttachPointDefinition" );
           tolua_variable(  tolua_S,  "Name",  tolua_get_EmberOgre__Model__AttachPointDefinition_Name,  tolua_set_EmberOgre__Model__AttachPointDefinition_Name );
           tolua_variable(  tolua_S,  "BoneName",  tolua_get_EmberOgre__Model__AttachPointDefinition_BoneName,  tolua_set_EmberOgre__Model__AttachPointDefinition_BoneName );
           tolua_variable(  tolua_S,  "Rotation",  tolua_get_EmberOgre__Model__AttachPointDefinition_Rotation,  tolua_set_EmberOgre__Model__AttachPointDefinition_Rotation );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "SubEntityDefinition",  "EmberOgre::Model::SubEntityDefinition",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "SubEntityDefinition" );
           tolua_function(  tolua_S,  "getSubEntityName",  tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getSubEntityName00 );
           tolua_function(  tolua_S,  "getSubEntityIndex",  tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getSubEntityIndex00 );
           tolua_function(  tolua_S,  "getMaterialName",  tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getMaterialName00 );
           tolua_function(  tolua_S,  "setMaterialName",  tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_setMaterialName00 );
           tolua_function(  tolua_S,  "getPartDefinition",  tolua_EmberOgre_EmberOgre_Model_SubEntityDefinition_getPartDefinition00 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "PartDefinition",  "EmberOgre::Model::PartDefinition",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "PartDefinition" );
           tolua_function(  tolua_S,  "setName",  tolua_EmberOgre_EmberOgre_Model_PartDefinition_setName00 );
           tolua_function(  tolua_S,  "getName",  tolua_EmberOgre_EmberOgre_Model_PartDefinition_getName00 );
           tolua_function(  tolua_S,  "setShow",  tolua_EmberOgre_EmberOgre_Model_PartDefinition_setShow00 );
           tolua_function(  tolua_S,  "getShow",  tolua_EmberOgre_EmberOgre_Model_PartDefinition_getShow00 );
           tolua_function(  tolua_S,  "createSubEntityDefinition",  tolua_EmberOgre_EmberOgre_Model_PartDefinition_createSubEntityDefinition00 );
           tolua_function(  tolua_S,  "createSubEntityDefinition",  tolua_EmberOgre_EmberOgre_Model_PartDefinition_createSubEntityDefinition01 );
           tolua_function(  tolua_S,  "getSubEntityDefinitions",  tolua_EmberOgre_EmberOgre_Model_PartDefinition_getSubEntityDefinitions00 );
           tolua_function(  tolua_S,  "removeSubEntityDefinition",  tolua_EmberOgre_EmberOgre_Model_PartDefinition_removeSubEntityDefinition00 );
           tolua_function(  tolua_S,  "getSubModelDefinition",  tolua_EmberOgre_EmberOgre_Model_PartDefinition_getSubModelDefinition00 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "SubModelDefinition",  "EmberOgre::Model::SubModelDefinition",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "SubModelDefinition" );
           tolua_function(  tolua_S,  "getMeshName",  tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_getMeshName00 );
           tolua_function(  tolua_S,  "createPartDefinition",  tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_createPartDefinition00 );
           tolua_function(  tolua_S,  "getPartDefinitions",  tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_getPartDefinitions00 );
           tolua_function(  tolua_S,  "removePartDefinition",  tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_removePartDefinition00 );
           tolua_function(  tolua_S,  "getModelDefinition",  tolua_EmberOgre_EmberOgre_Model_SubModelDefinition_getModelDefinition00 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "ModelDefinition",  "EmberOgre::Model::ModelDefinition",  "Ogre::Resource",  NULL );
           tolua_beginmodule(  tolua_S,  "ModelDefinition" );
           tolua_constant(  tolua_S,  "MODEL_ALL",  EmberOgre::Model::ModelDefinition::MODEL_ALL );
           tolua_constant(  tolua_S,  "MODEL_NONE",  EmberOgre::Model::ModelDefinition::MODEL_NONE );
           tolua_constant(  tolua_S,  "MODEL_WIDTH",  EmberOgre::Model::ModelDefinition::MODEL_WIDTH );
           tolua_constant(  tolua_S,  "MODEL_DEPTH",  EmberOgre::Model::ModelDefinition::MODEL_DEPTH );
           tolua_constant(  tolua_S,  "MODEL_HEIGHT",  EmberOgre::Model::ModelDefinition::MODEL_HEIGHT );
           tolua_function(  tolua_S,  "isValid",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_isValid00 );
           tolua_function(  tolua_S,  "setValid",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setValid00 );
           tolua_function(  tolua_S,  "getScale",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getScale00 );
           tolua_function(  tolua_S,  "setScale",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setScale00 );
           tolua_function(  tolua_S,  "getUseScaleOf",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getUseScaleOf00 );
           tolua_function(  tolua_S,  "setUseScaleOf",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setUseScaleOf00 );
           tolua_function(  tolua_S,  "getTranslate",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getTranslate00 );
           tolua_function(  tolua_S,  "setTranslate",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setTranslate00 );
           tolua_function(  tolua_S,  "getShowContained",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getShowContained00 );
           tolua_function(  tolua_S,  "getShowContained",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getShowContained01 );
           tolua_function(  tolua_S,  "getContentOffset",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getContentOffset00 );
           tolua_function(  tolua_S,  "setContentOffset",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setContentOffset00 );
           tolua_function(  tolua_S,  "getRotation",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getRotation00 );
           tolua_function(  tolua_S,  "setRotation",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_setRotation00 );
           tolua_function(  tolua_S,  "createSubModelDefinition",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_createSubModelDefinition00 );
           tolua_function(  tolua_S,  "getSubModelDefinitions",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getSubModelDefinitions00 );
           tolua_function(  tolua_S,  "removeSubModelDefinition",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_removeSubModelDefinition00 );
           tolua_function(  tolua_S,  "createActionDefinition",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_createActionDefinition00 );
           tolua_function(  tolua_S,  "getActionDefinitions",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getActionDefinitions00 );
           tolua_function(  tolua_S,  "removeActionDefinition",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_removeActionDefinition00 );
           tolua_function(  tolua_S,  "getAttachPointsDefinitions",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getAttachPointsDefinitions00 );
           tolua_function(  tolua_S,  "createViewDefinition",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_createViewDefinition00 );
           tolua_function(  tolua_S,  "getViewDefinitions",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_getViewDefinitions00 );
           tolua_function(  tolua_S,  "removeViewDefinition",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_removeViewDefinition00 );
           tolua_function(  tolua_S,  "reloadAllInstances",  tolua_EmberOgre_EmberOgre_Model_ModelDefinition_reloadAllInstances00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "ModelDefnPtr",  "EmberOgre::Model::ModelDefnPtr",  "",  tolua_collect_EmberOgre__Model__ModelDefnPtr );
           #else
           tolua_cclass(  tolua_S,  "ModelDefnPtr",  "EmberOgre::Model::ModelDefnPtr",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "ModelDefnPtr" );
           tolua_function(  tolua_S,  "get",  tolua_EmberOgre_EmberOgre_Model_ModelDefnPtr_get00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "MouseMotion",  "EmberOgre::MouseMotion",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "MouseMotion" );
           tolua_variable(  tolua_S,  "xPosition",  tolua_get_EmberOgre__MouseMotion_xPosition,  tolua_set_EmberOgre__MouseMotion_xPosition );
           tolua_variable(  tolua_S,  "yPosition",  tolua_get_EmberOgre__MouseMotion_yPosition,  tolua_set_EmberOgre__MouseMotion_yPosition );
           tolua_variable(  tolua_S,  "xRelativeMovement",  tolua_get_EmberOgre__MouseMotion_xRelativeMovement,  tolua_set_EmberOgre__MouseMotion_xRelativeMovement );
           tolua_variable(  tolua_S,  "yRelativeMovement",  tolua_get_EmberOgre__MouseMotion_yRelativeMovement,  tolua_set_EmberOgre__MouseMotion_yRelativeMovement );
           tolua_variable(  tolua_S,  "xRelativeMovementInPixels",  tolua_get_EmberOgre__MouseMotion_xRelativeMovementInPixels,  tolua_set_EmberOgre__MouseMotion_xRelativeMovementInPixels );
           tolua_variable(  tolua_S,  "yRelativeMovementInPixels",  tolua_get_EmberOgre__MouseMotion_yRelativeMovementInPixels,  tolua_set_EmberOgre__MouseMotion_yRelativeMovementInPixels );
           tolua_variable(  tolua_S,  "timeSinceLastMovement",  tolua_get_EmberOgre__MouseMotion_timeSinceLastMovement,  tolua_set_EmberOgre__MouseMotion_timeSinceLastMovement );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "Input",  "EmberOgre::Input",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Input" );
           tolua_function(  tolua_S,  "getSingleton",  tolua_EmberOgre_EmberOgre_Input_getSingleton00 );
           tolua_constant(  tolua_S,  "MouseButtonLeft",  EmberOgre::Input::MouseButtonLeft );
           tolua_constant(  tolua_S,  "MouseButtonRight",  EmberOgre::Input::MouseButtonRight );
           tolua_constant(  tolua_S,  "MouseButtonMiddle",  EmberOgre::Input::MouseButtonMiddle );
           tolua_constant(  tolua_S,  "IM_GUI",  EmberOgre::Input::IM_GUI );
           tolua_constant(  tolua_S,  "IM_MOVEMENT",  EmberOgre::Input::IM_MOVEMENT );
           tolua_variable(  tolua_S,  "EventKeyPressed",  tolua_get_EmberOgre__Input_EventKeyPressed,  tolua_set_EmberOgre__Input_EventKeyPressed );
           tolua_variable(  tolua_S,  "EventKeyReleased",  tolua_get_EmberOgre__Input_EventKeyReleased,  tolua_set_EmberOgre__Input_EventKeyReleased );
           tolua_variable(  tolua_S,  "EventMouseMoved",  tolua_get_EmberOgre__Input_EventMouseMoved,  tolua_set_EmberOgre__Input_EventMouseMoved );
           tolua_variable(  tolua_S,  "EventMouseButtonPressed",  tolua_get_EmberOgre__Input_EventMouseButtonPressed,  tolua_set_EmberOgre__Input_EventMouseButtonPressed );
           tolua_variable(  tolua_S,  "EventMouseButtonReleased",  tolua_get_EmberOgre__Input_EventMouseButtonReleased,  tolua_set_EmberOgre__Input_EventMouseButtonReleased );
           tolua_variable(  tolua_S,  "EventChangedInputMode",  tolua_get_EmberOgre__Input_EventChangedInputMode,  tolua_set_EmberOgre__Input_EventChangedInputMode );
           tolua_function(  tolua_S,  "isKeyDown",  tolua_EmberOgre_EmberOgre_Input_isKeyDown00 );
           tolua_function(  tolua_S,  "setInputMode",  tolua_EmberOgre_EmberOgre_Input_setInputMode00 );
           tolua_function(  tolua_S,  "getInputMode",  tolua_EmberOgre_EmberOgre_Input_getInputMode00 );
           tolua_function(  tolua_S,  "toggleInputMode",  tolua_EmberOgre_EmberOgre_Input_toggleInputMode00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Jesus",  "EmberOgre::Jesus",  "",  tolua_collect_EmberOgre__Jesus );
           #else
           tolua_cclass(  tolua_S,  "Jesus",  "EmberOgre::Jesus",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Jesus" );
           tolua_constant(  tolua_S,  "CM_MODELBLOCK",  EmberOgre::Jesus::CM_MODELBLOCK );
           tolua_constant(  tolua_S,  "CM_ATTACHPOINT",  EmberOgre::Jesus::CM_ATTACHPOINT );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Jesus_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Jesus_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Jesus_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Jesus_delete00 );
           tolua_function(  tolua_S,  "createModelForBlockType",  tolua_EmberOgre_EmberOgre_Jesus_createModelForBlockType00 );
           tolua_function(  tolua_S,  "getColourForAttachPoint",  tolua_EmberOgre_EmberOgre_Jesus_getColourForAttachPoint00 );
           tolua_function(  tolua_S,  "getCarpenter",  tolua_EmberOgre_EmberOgre_Jesus_getCarpenter00 );
           tolua_function(  tolua_S,  "addBluePrint",  tolua_EmberOgre_EmberOgre_Jesus_addBluePrint00 );
           tolua_function(  tolua_S,  "getBluePrint",  tolua_EmberOgre_EmberOgre_Jesus_getBluePrint00 );
           tolua_function(  tolua_S,  "getAllBluePrints",  tolua_EmberOgre_EmberOgre_Jesus_getAllBluePrints00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "LightWibbler",  "EmberOgre::LightWibbler",  "Ogre::ControllerValue<Ogre::Real>",  tolua_collect_EmberOgre__LightWibbler );
           #else
           tolua_cclass(  tolua_S,  "LightWibbler",  "EmberOgre::LightWibbler",  "Ogre::ControllerValue<Ogre::Real>",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "LightWibbler" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_LightWibbler_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_LightWibbler_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_LightWibbler_new00_local );
           tolua_function(  tolua_S,  "getValue",  tolua_EmberOgre_EmberOgre_LightWibbler_getValue00 );
           tolua_function(  tolua_S,  "setValue",  tolua_EmberOgre_EmberOgre_LightWibbler_setValue00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "AttachPointNode",  "EmberOgre::AttachPointNode",  "",  tolua_collect_EmberOgre__AttachPointNode );
           #else
           tolua_cclass(  tolua_S,  "AttachPointNode",  "EmberOgre::AttachPointNode",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "AttachPointNode" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_AttachPointNode_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_AttachPointNode_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_AttachPointNode_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_AttachPointNode_delete00 );
           tolua_function(  tolua_S,  "select",  tolua_EmberOgre_EmberOgre_AttachPointNode_select00 );
           tolua_function(  tolua_S,  "deselect",  tolua_EmberOgre_EmberOgre_AttachPointNode_deselect00 );
           tolua_function(  tolua_S,  "getAttachPoint",  tolua_EmberOgre_EmberOgre_AttachPointNode_getAttachPoint00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "ModelBlock",  "EmberOgre::ModelBlock",  "",  tolua_collect_EmberOgre__ModelBlock );
           #else
           tolua_cclass(  tolua_S,  "ModelBlock",  "EmberOgre::ModelBlock",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "ModelBlock" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_ModelBlock_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_ModelBlock_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_ModelBlock_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_ModelBlock_delete00 );
           tolua_function(  tolua_S,  "getBuildingBlock",  tolua_EmberOgre_EmberOgre_ModelBlock_getBuildingBlock00 );
           tolua_function(  tolua_S,  "getConstruction",  tolua_EmberOgre_EmberOgre_ModelBlock_getConstruction00 );
           tolua_function(  tolua_S,  "createAttachPointNodes",  tolua_EmberOgre_EmberOgre_ModelBlock_createAttachPointNodes00 );
           tolua_function(  tolua_S,  "select",  tolua_EmberOgre_EmberOgre_ModelBlock_select00 );
           tolua_function(  tolua_S,  "deselect",  tolua_EmberOgre_EmberOgre_ModelBlock_deselect00 );
           tolua_function(  tolua_S,  "getAttachPointNodes",  tolua_EmberOgre_EmberOgre_ModelBlock_getAttachPointNodes00 );
           tolua_function(  tolua_S,  "getModel",  tolua_EmberOgre_EmberOgre_ModelBlock_getModel00 );
           tolua_function(  tolua_S,  "getNode",  tolua_EmberOgre_EmberOgre_ModelBlock_getNode00 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "ModelMapping",  "EmberOgre::ModelMapping",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ModelMapping" );
           tolua_variable(  tolua_S,  "model",  tolua_get_EmberOgre__ModelMapping_model,  NULL );
           tolua_variable(  tolua_S,  "blocktype",  tolua_get_EmberOgre__ModelMapping_blocktype,  NULL );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Construction",  "EmberOgre::Construction",  "",  tolua_collect_EmberOgre__Construction );
           #else
           tolua_cclass(  tolua_S,  "Construction",  "EmberOgre::Construction",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Construction" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Construction_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Construction_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Construction_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Construction_delete00 );
           tolua_function(  tolua_S,  "getJesus",  tolua_EmberOgre_EmberOgre_Construction_getJesus00 );
           tolua_function(  tolua_S,  "getBluePrint",  tolua_EmberOgre_EmberOgre_Construction_getBluePrint00 );
           tolua_function(  tolua_S,  "buildFromBluePrint",  tolua_EmberOgre_EmberOgre_Construction_buildFromBluePrint00 );
           tolua_function(  tolua_S,  "createModelBlock",  tolua_EmberOgre_EmberOgre_Construction_createModelBlock00 );
           tolua_function(  tolua_S,  "getModelBlocks",  tolua_EmberOgre_EmberOgre_Construction_getModelBlocks00 );
           tolua_function(  tolua_S,  "remove",  tolua_EmberOgre_EmberOgre_Construction_remove00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "TerrainPosition",  "EmberOgre::TerrainPosition",  "",  tolua_collect_EmberOgre__TerrainPosition );
           #else
           tolua_cclass(  tolua_S,  "TerrainPosition",  "EmberOgre::TerrainPosition",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "TerrainPosition" );
           tolua_function(  tolua_S,  "isValid",  tolua_EmberOgre_EmberOgre_TerrainPosition_isValid00 );
           tolua_function(  tolua_S,  "setToOrigin",  tolua_EmberOgre_EmberOgre_TerrainPosition_setToOrigin00 );
           tolua_function(  tolua_S,  "x",  tolua_EmberOgre_EmberOgre_TerrainPosition_x00 );
           tolua_function(  tolua_S,  "x",  tolua_EmberOgre_EmberOgre_TerrainPosition_x01 );
           tolua_function(  tolua_S,  "y",  tolua_EmberOgre_EmberOgre_TerrainPosition_y00 );
           tolua_function(  tolua_S,  "y",  tolua_EmberOgre_EmberOgre_TerrainPosition_y01 );
           tolua_endmodule(  tolua_S );
           tolua_function(  tolua_S,  "Atlas2Ogre",  tolua_EmberOgre_EmberOgre_Atlas2Ogre00 );
           tolua_function(  tolua_S,  "Ogre2Atlas",  tolua_EmberOgre_EmberOgre_Ogre2Atlas00 );
           tolua_function(  tolua_S,  "Ogre2Atlas",  tolua_EmberOgre_EmberOgre_Ogre2Atlas01 );
           tolua_function(  tolua_S,  "Ogre2Atlas_TerrainPosition",  tolua_EmberOgre_EmberOgre_Ogre2Atlas_TerrainPosition00 );
           tolua_function(  tolua_S,  "Ogre2Atlas_Vector3",  tolua_EmberOgre_EmberOgre_Ogre2Atlas_Vector300 );
           tolua_function(  tolua_S,  "Atlas2Ogre",  tolua_EmberOgre_EmberOgre_Atlas2Ogre01 );
           tolua_function(  tolua_S,  "Atlas2Ogre",  tolua_EmberOgre_EmberOgre_Atlas2Ogre02 );
           tolua_function(  tolua_S,  "Atlas2Ogre",  tolua_EmberOgre_EmberOgre_Atlas2Ogre03 );
           tolua_function(  tolua_S,  "Ogre2Atlas",  tolua_EmberOgre_EmberOgre_Ogre2Atlas02 );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_cclass(  tolua_S,  "MovableObjectRenderer",  "EmberOgre::Gui::MovableObjectRenderer",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "MovableObjectRenderer" );
           tolua_function(  tolua_S,  "showFull",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_showFull00 );
           tolua_function(  tolua_S,  "setCameraDistance",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setCameraDistance00 );
           tolua_function(  tolua_S,  "getCameraDistance",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getCameraDistance00 );
           tolua_function(  tolua_S,  "getAbsoluteCameraDistance",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getAbsoluteCameraDistance00 );
           tolua_function(  tolua_S,  "getIsInputCatchingAllowed",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getIsInputCatchingAllowed00 );
           tolua_function(  tolua_S,  "setIsInputCatchingAllowed",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setIsInputCatchingAllowed00 );
           tolua_function(  tolua_S,  "setAutoShowFull",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setAutoShowFull00 );
           tolua_function(  tolua_S,  "getAutoShowFull",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getAutoShowFull00 );
           tolua_function(  tolua_S,  "getActive",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getActive00 );
           tolua_function(  tolua_S,  "setActive",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setActive00 );
           tolua_function(  tolua_S,  "getEntityRotation",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_getEntityRotation00 );
           tolua_function(  tolua_S,  "resetCameraOrientation",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_resetCameraOrientation00 );
           tolua_function(  tolua_S,  "pitch",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_pitch00 );
           tolua_function(  tolua_S,  "yaw",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_yaw00 );
           tolua_function(  tolua_S,  "roll",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_roll00 );
           tolua_function(  tolua_S,  "updateRender",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_updateRender00 );
           tolua_function(  tolua_S,  "setBackgroundColour",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setBackgroundColour00 );
           tolua_function(  tolua_S,  "setBackgroundColour",  tolua_EmberOgre_EmberOgre_Gui_MovableObjectRenderer_setBackgroundColour01 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "OgreEntityRenderer",  "EmberOgre::Gui::OgreEntityRenderer",  "EmberOgre::MovableObjectRenderer",  tolua_collect_EmberOgre__Gui__OgreEntityRenderer );
           #else
           tolua_cclass(  tolua_S,  "OgreEntityRenderer",  "EmberOgre::Gui::OgreEntityRenderer",  "EmberOgre::MovableObjectRenderer",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "OgreEntityRenderer" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_delete00 );
           tolua_function(  tolua_S,  "showEntity",  tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_showEntity00 );
           tolua_function(  tolua_S,  "getEntity",  tolua_EmberOgre_EmberOgre_Gui_OgreEntityRenderer_getEntity00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "ModelRenderer",  "EmberOgre::Gui::ModelRenderer",  "EmberOgre::Gui::MovableObjectRenderer",  tolua_collect_EmberOgre__Gui__ModelRenderer );
           #else
           tolua_cclass(  tolua_S,  "ModelRenderer",  "EmberOgre::Gui::ModelRenderer",  "EmberOgre::Gui::MovableObjectRenderer",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "ModelRenderer" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_delete00 );
           tolua_function(  tolua_S,  "showModel",  tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_showModel00 );
           tolua_function(  tolua_S,  "getModel",  tolua_EmberOgre_EmberOgre_Gui_ModelRenderer_getModel00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "ListHolder",  "EmberOgre::Gui::ListHolder",  "",  tolua_collect_EmberOgre__Gui__ListHolder );
           #else
           tolua_cclass(  tolua_S,  "ListHolder",  "EmberOgre::Gui::ListHolder",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "ListHolder" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_ListHolder_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_ListHolder_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_ListHolder_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_ListHolder_delete00 );
           tolua_function(  tolua_S,  "addItem",  tolua_EmberOgre_EmberOgre_Gui_ListHolder_addItem00 );
           tolua_function(  tolua_S,  "insertItem",  tolua_EmberOgre_EmberOgre_Gui_ListHolder_insertItem00 );
           tolua_function(  tolua_S,  "removeItem",  tolua_EmberOgre_EmberOgre_Gui_ListHolder_removeItem00 );
           tolua_function(  tolua_S,  "resetList",  tolua_EmberOgre_EmberOgre_Gui_ListHolder_resetList00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_constant(  tolua_S,  "MPT_CLICK",  EmberOgre::MPT_CLICK );
           tolua_constant(  tolua_S,  "MPT_DOUBLECLICK",  EmberOgre::MPT_DOUBLECLICK );
           tolua_cclass(  tolua_S,  "MousePickerArgs",  "EmberOgre::MousePickerArgs",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "MousePickerArgs" );
           tolua_variable(  tolua_S,  "windowX",  tolua_get_EmberOgre__MousePickerArgs_windowX,  tolua_set_EmberOgre__MousePickerArgs_windowX );
           tolua_variable(  tolua_S,  "windowY",  tolua_get_EmberOgre__MousePickerArgs_windowY,  tolua_set_EmberOgre__MousePickerArgs_windowY );
           tolua_variable(  tolua_S,  "pickType",  tolua_get_EmberOgre__MousePickerArgs_pickType,  tolua_set_EmberOgre__MousePickerArgs_pickType );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "EntityPickResult",  "EmberOgre::EntityPickResult",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "EntityPickResult" );
           tolua_variable(  tolua_S,  "entity",  tolua_get_EmberOgre__EntityPickResult_entity_ptr,  tolua_set_EmberOgre__EntityPickResult_entity_ptr );
           tolua_variable(  tolua_S,  "position",  tolua_get_EmberOgre__EntityPickResult_position,  tolua_set_EmberOgre__EntityPickResult_position );
           tolua_variable(  tolua_S,  "distance",  tolua_get_EmberOgre__EntityPickResult_distance,  tolua_set_EmberOgre__EntityPickResult_distance );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "EntityWorldPickListener",  "EmberOgre::EntityWorldPickListener",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "EntityWorldPickListener" );
           tolua_variable(  tolua_S,  "EventPickedEntity",  tolua_get_EmberOgre__EntityWorldPickListener_EventPickedEntity,  tolua_set_EmberOgre__EntityWorldPickListener_EventPickedEntity );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Model",  0 );
           tolua_beginmodule(  tolua_S,  "Model" );
           tolua_cclass(  tolua_S,  "ModelDefinitionManager",  "EmberOgre::Model::ModelDefinitionManager",  "Ogre;;ResourceManager",  NULL );
           tolua_beginmodule(  tolua_S,  "ModelDefinitionManager" );
           tolua_function(  tolua_S,  "getSingleton",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getSingleton00 );
           tolua_function(  tolua_S,  "exportScript",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_exportScript00 );
           tolua_function(  tolua_S,  "create",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_create00 );
           tolua_function(  tolua_S,  "remove",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_remove00 );
           tolua_function(  tolua_S,  "getByName",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getByName00 );
           tolua_function(  tolua_S,  "resourceExists",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_resourceExists00 );
           tolua_function(  tolua_S,  "getResourceIterator",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getResourceIterator00 );
           tolua_function(  tolua_S,  "getAllMeshes",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getAllMeshes00 );
           tolua_function(  tolua_S,  "getShowModels",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_getShowModels00 );
           tolua_function(  tolua_S,  "setShowModels",  tolua_EmberOgre_EmberOgre_Model_ModelDefinitionManager_setShowModels00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "EntityMoveManager",  "EmberOgre::EntityMoveManager",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "EntityMoveManager" );
           tolua_function(  tolua_S,  "startMove",  tolua_EmberOgre_EmberOgre_EntityMoveManager_startMove00 );
           tolua_function(  tolua_S,  "runCommand",  tolua_EmberOgre_EmberOgre_EntityMoveManager_runCommand00 );
           tolua_variable(  tolua_S,  "EventStartMoving",  tolua_get_EmberOgre__EntityMoveManager_EventStartMoving,  tolua_set_EmberOgre__EntityMoveManager_EventStartMoving );
           tolua_variable(  tolua_S,  "EventFinishedMoving",  tolua_get_EmberOgre__EntityMoveManager_EventFinishedMoving,  tolua_set_EmberOgre__EntityMoveManager_EventFinishedMoving );
           tolua_variable(  tolua_S,  "EventCancelledMoving",  tolua_get_EmberOgre__EntityMoveManager_EventCancelledMoving,  tolua_set_EmberOgre__EntityMoveManager_EventCancelledMoving );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "std",  0 );
           tolua_beginmodule(  tolua_S,  "std" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "vector_std__string_",  "std::vector<std::string>",  "",  tolua_collect_std__vector_std__string_ );
           #else
           tolua_cclass(  tolua_S,  "vector_std__string_",  "std::vector<std::string>",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "vector_std__string_" );
           tolua_function(  tolua_S,  "clear",  tolua_EmberOgre_std_vector_std__string__clear00 );
           tolua_function(  tolua_S,  "size",  tolua_EmberOgre_std_vector_std__string__size00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_std__string___geti00 );
           tolua_function(  tolua_S,  ".seti",  tolua_EmberOgre_std_vector_std__string___seti00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_std__string___geti01 );
           tolua_function(  tolua_S,  "push_back",  tolua_EmberOgre_std_vector_std__string__push_back00 );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_std_vector_std__string__new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_std_vector_std__string__new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_std_vector_std__string__new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_std_vector_std__string__delete00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "vector_EmberOgre__Model__SubModelDefinition__",  "std::vector<EmberOgre::Model::SubModelDefinition*>",  "",  tolua_collect_std__vector_EmberOgre__Model__SubModelDefinition__ );
           #else
           tolua_cclass(  tolua_S,  "vector_EmberOgre__Model__SubModelDefinition__",  "std::vector<EmberOgre::Model::SubModelDefinition*>",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "vector_EmberOgre__Model__SubModelDefinition__" );
           tolua_function(  tolua_S,  "clear",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___clear00 );
           tolua_function(  tolua_S,  "size",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___size00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____geti00 );
           tolua_function(  tolua_S,  ".seti",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____seti00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition____geti01 );
           tolua_function(  tolua_S,  "push_back",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___push_back00 );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubModelDefinition___delete00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "vector_EmberOgre__Model__PartDefinition__",  "std::vector<EmberOgre::Model::PartDefinition*>",  "",  tolua_collect_std__vector_EmberOgre__Model__PartDefinition__ );
           #else
           tolua_cclass(  tolua_S,  "vector_EmberOgre__Model__PartDefinition__",  "std::vector<EmberOgre::Model::PartDefinition*>",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "vector_EmberOgre__Model__PartDefinition__" );
           tolua_function(  tolua_S,  "clear",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___clear00 );
           tolua_function(  tolua_S,  "size",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___size00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____geti00 );
           tolua_function(  tolua_S,  ".seti",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____seti00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition____geti01 );
           tolua_function(  tolua_S,  "push_back",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___push_back00 );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_std_vector_EmberOgre__Model__PartDefinition___delete00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "vector_EmberOgre__Model__SubEntityDefinition__",  "std::vector<EmberOgre::Model::SubEntityDefinition*>",  "",  tolua_collect_std__vector_EmberOgre__Model__SubEntityDefinition__ );
           #else
           tolua_cclass(  tolua_S,  "vector_EmberOgre__Model__SubEntityDefinition__",  "std::vector<EmberOgre::Model::SubEntityDefinition*>",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "vector_EmberOgre__Model__SubEntityDefinition__" );
           tolua_function(  tolua_S,  "clear",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___clear00 );
           tolua_function(  tolua_S,  "size",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___size00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____geti00 );
           tolua_function(  tolua_S,  ".seti",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____seti00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition____geti01 );
           tolua_function(  tolua_S,  "push_back",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___push_back00 );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_std_vector_EmberOgre__Model__SubEntityDefinition___delete00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "vector_Eris__Task__",  "std::vector<Eris::Task*>",  "",  tolua_collect_std__vector_Eris__Task__ );
           #else
           tolua_cclass(  tolua_S,  "vector_Eris__Task__",  "std::vector<Eris::Task*>",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "vector_Eris__Task__" );
           tolua_function(  tolua_S,  "clear",  tolua_EmberOgre_std_vector_Eris__Task___clear00 );
           tolua_function(  tolua_S,  "size",  tolua_EmberOgre_std_vector_Eris__Task___size00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_Eris__Task____geti00 );
           tolua_function(  tolua_S,  ".seti",  tolua_EmberOgre_std_vector_Eris__Task____seti00 );
           tolua_function(  tolua_S,  ".geti",  tolua_EmberOgre_std_vector_Eris__Task____geti01 );
           tolua_function(  tolua_S,  "push_back",  tolua_EmberOgre_std_vector_Eris__Task___push_back00 );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_std_vector_Eris__Task___new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_std_vector_Eris__Task___new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_std_vector_Eris__Task___new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_std_vector_Eris__Task___delete00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "set_std__string_",  "std::set<std::string>",  "",  tolua_collect_std__set_std__string_ );
           #else
           tolua_cclass(  tolua_S,  "set_std__string_",  "std::set<std::string>",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "set_std__string_" );
           tolua_function(  tolua_S,  "clear",  tolua_EmberOgre_std_set_std__string__clear00 );
           tolua_function(  tolua_S,  "size",  tolua_EmberOgre_std_set_std__string__size00 );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_std_set_std__string__new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_std_set_std__string__new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_std_set_std__string__new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_std_set_std__string__delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Vector3Adapter",  "EmberOgre::Gui::Vector3Adapter",  "",  tolua_collect_EmberOgre__Gui__Vector3Adapter );
           #else
           tolua_cclass(  tolua_S,  "Vector3Adapter",  "EmberOgre::Gui::Vector3Adapter",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Vector3Adapter" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new00_local );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_new01_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_delete00 );
           tolua_function(  tolua_S,  "getValue",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_getValue00 );
           tolua_function(  tolua_S,  "getOriginalValue",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_getOriginalValue00 );
           tolua_function(  tolua_S,  "setValue",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_setValue00 );
           tolua_function(  tolua_S,  "updateGui",  tolua_EmberOgre_EmberOgre_Gui_Vector3Adapter_updateGui00 );
           tolua_variable(  tolua_S,  "EventValueChanged",  tolua_get_EmberOgre__Gui__Vector3Adapter_EventValueChanged,  tolua_set_EmberOgre__Gui__Vector3Adapter_EventValueChanged );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "QuaternionAdapter",  "EmberOgre::Gui::QuaternionAdapter",  "",  tolua_collect_EmberOgre__Gui__QuaternionAdapter );
           #else
           tolua_cclass(  tolua_S,  "QuaternionAdapter",  "EmberOgre::Gui::QuaternionAdapter",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "QuaternionAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new00_local );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new01_local );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new02 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new02_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_new02_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_delete00 );
           tolua_function(  tolua_S,  "getValue",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_getValue00 );
           tolua_function(  tolua_S,  "getOriginalValue",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_getOriginalValue00 );
           tolua_function(  tolua_S,  "setValue",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_setValue00 );
           tolua_function(  tolua_S,  "updateGui",  tolua_EmberOgre_EmberOgre_Gui_QuaternionAdapter_updateGui00 );
           tolua_variable(  tolua_S,  "EventValueChanged",  tolua_get_EmberOgre__Gui__QuaternionAdapter_EventValueChanged,  tolua_set_EmberOgre__Gui__QuaternionAdapter_EventValueChanged );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "OgreInfo",  "EmberOgre::OgreInfo",  "",  tolua_collect_EmberOgre__OgreInfo );
           #else
           tolua_cclass(  tolua_S,  "OgreInfo",  "EmberOgre::OgreInfo",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "OgreInfo" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_OgreInfo_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_OgreInfo_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_OgreInfo_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_OgreInfo_delete00 );
           tolua_function(  tolua_S,  "isIndirect",  tolua_EmberOgre_EmberOgre_OgreInfo_isIndirect00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "AttributeObserver",  "EmberOgre::AttributeObserver",  "",  tolua_collect_EmberOgre__AttributeObserver );
           #else
           tolua_cclass(  tolua_S,  "AttributeObserver",  "EmberOgre::AttributeObserver",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "AttributeObserver" );
           tolua_function(  tolua_S,  "new",  tolua_EmberOgre_EmberOgre_AttributeObserver_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_EmberOgre_EmberOgre_AttributeObserver_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_EmberOgre_EmberOgre_AttributeObserver_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_EmberOgre_EmberOgre_AttributeObserver_delete00 );
           tolua_variable(  tolua_S,  "EventChanged",  tolua_get_EmberOgre__AttributeObserver_EventChanged,  tolua_set_EmberOgre__AttributeObserver_EventChanged );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_cclass(  tolua_S,  "EmberOgre",  "EmberOgre::EmberOgre",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_function(  tolua_S,  "getSingleton",  tolua_EmberOgre_EmberOgre_EmberOgre_getSingleton00 );
           tolua_function(  tolua_S,  "getAvatar",  tolua_EmberOgre_EmberOgre_EmberOgre_getAvatar00 );
           tolua_function(  tolua_S,  "getMotionManager",  tolua_EmberOgre_EmberOgre_EmberOgre_getMotionManager00 );
           tolua_function(  tolua_S,  "getEntityFactory",  tolua_EmberOgre_EmberOgre_EmberOgre_getEntityFactory00 );
           tolua_function(  tolua_S,  "getMainCamera",  tolua_EmberOgre_EmberOgre_EmberOgre_getMainCamera00 );
           tolua_function(  tolua_S,  "getAvatarController",  tolua_EmberOgre_EmberOgre_EmberOgre_getAvatarController00 );
           tolua_function(  tolua_S,  "getMoveManager",  tolua_EmberOgre_EmberOgre_EmberOgre_getMoveManager00 );
           tolua_function(  tolua_S,  "getEmberEntity",  tolua_EmberOgre_EmberOgre_EmberOgre_getEmberEntity00 );
           tolua_function(  tolua_S,  "getJesus",  tolua_EmberOgre_EmberOgre_EmberOgre_getJesus00 );
           tolua_function(  tolua_S,  "getRenderWindow",  tolua_EmberOgre_EmberOgre_EmberOgre_getRenderWindow00 );
           tolua_variable(  tolua_S,  "EventCreatedEmberEntityFactory",  tolua_get_EmberOgre__EmberOgre_EventCreatedEmberEntityFactory,  tolua_set_EmberOgre__EmberOgre_EventCreatedEmberEntityFactory );
           tolua_variable(  tolua_S,  "EventCreatedAvatarEntity",  tolua_get_EmberOgre__EmberOgre_EventCreatedAvatarEntity,  tolua_set_EmberOgre__EmberOgre_EventCreatedAvatarEntity );
           tolua_variable(  tolua_S,  "EventCreatedJesus",  tolua_get_EmberOgre__EmberOgre_EventCreatedJesus,  tolua_set_EmberOgre__EmberOgre_EventCreatedJesus );
           tolua_function(  tolua_S,  "getWorldSceneNode",  tolua_EmberOgre_EmberOgre_EmberOgre_getWorldSceneNode00 );
           tolua_function(  tolua_S,  "getRootSceneNode",  tolua_EmberOgre_EmberOgre_EmberOgre_getRootSceneNode00 );
           tolua_variable(  tolua_S,  "EventGUIManagerCreated",  tolua_get_EmberOgre__EmberOgre_EventGUIManagerCreated,  tolua_set_EmberOgre__EmberOgre_EventGUIManagerCreated );
           tolua_variable(  tolua_S,  "EventGUIManagerInitialized",  tolua_get_EmberOgre__EmberOgre_EventGUIManagerInitialized,  tolua_set_EmberOgre__EmberOgre_EventGUIManagerInitialized );
           tolua_variable(  tolua_S,  "EventMotionManagerCreated",  tolua_get_EmberOgre__EmberOgre_EventMotionManagerCreated,  tolua_set_EmberOgre__EmberOgre_EventMotionManagerCreated );
           tolua_variable(  tolua_S,  "EventTerrainGeneratorCreated",  tolua_get_EmberOgre__EmberOgre_EventTerrainGeneratorCreated,  tolua_set_EmberOgre__EmberOgre_EventTerrainGeneratorCreated );
           tolua_variable(  tolua_S,  "EventAvatarControllerCreated",  tolua_get_EmberOgre__EmberOgre_EventAvatarControllerCreated,  tolua_set_EmberOgre__EmberOgre_EventAvatarControllerCreated );
           tolua_variable(  tolua_S,  "EventSceneCreated",  tolua_get_EmberOgre__EmberOgre_EventSceneCreated,  tolua_set_EmberOgre__EmberOgre_EventSceneCreated );
           tolua_function(  tolua_S,  "getEntity",  tolua_EmberOgre_EmberOgre_EmberOgre_getEntity00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           return 1;
          }
          
          
          #if defined(  LUA_VERSION_NUM ) && LUA_VERSION_NUM >= 501
   20684   TOLUA_API int luaopen_EmberOgre (  lua_State* tolua_S ) {
           return tolua_EmberOgre_open(  tolua_S );
          };
          #endif
          

./components/ogre/scripting/bindings/lua/ogre/lua_Ogre.cpp

       1  /*
          ** Lua binding: Ogre
          ** Generated automatically by tolua++-1.0.92 on Mon Jan 21 23:19:54 2008.
          */
          
          #ifndef __cplusplus
          #include "stdlib.h"
          #endif
          #include "string.h"
          
          #include "tolua++.h"
          
          /* Exported function */
      14  TOLUA_API int tolua_Ogre_open (  lua_State* tolua_S );
          
          #include "required.h"
          #include <OgreRoot.h>
          
          /* function to release collected object via destructor */
          #ifdef __cplusplus
          
      22  static int tolua_collect_Ogre__Math (  lua_State* tolua_S )
          {
           Ogre::Math* self = (  Ogre::Math* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      29  static int tolua_collect_Ogre__MapIterator_Ogre__Entity__ChildObjectList_ (  lua_State* tolua_S )
          {
           Ogre::MapIterator<Ogre::Entity::ChildObjectList>* self = (  Ogre::MapIterator<Ogre::Entity::ChildObjectList>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      36  static int tolua_collect_Ogre__Radian (  lua_State* tolua_S )
          {
           Ogre::Radian* self = (  Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      43  static int tolua_collect_Ogre__ResourceManager__ResourceHandleMap__key_type (  lua_State* tolua_S )
          {
           Ogre::ResourceManager::ResourceHandleMap::key_type* self = (  Ogre::ResourceManager::ResourceHandleMap::key_type* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      50  static int tolua_collect_Ogre__Quaternion (  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      57  static int tolua_collect_Ogre__AxisAlignedBox (  lua_State* tolua_S )
          {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      64  static int tolua_collect_Ogre__MaterialPtr (  lua_State* tolua_S )
          {
           Ogre::MaterialPtr* self = (  Ogre::MaterialPtr* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      71  static int tolua_collect_ushort (  lua_State* tolua_S )
          {
           ushort* self = (  ushort* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      78  static int tolua_collect_Ogre__Degree (  lua_State* tolua_S )
          {
           Ogre::Degree* self = (  Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      85  static int tolua_collect_Ogre__ResourcePtr (  lua_State* tolua_S )
          {
           Ogre::ResourcePtr* self = (  Ogre::ResourcePtr* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      92  static int tolua_collect_std__pair_bool_float_ (  lua_State* tolua_S )
          {
           std::pair<bool,  float>* self = (  std::pair<bool,  float>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      99  static int tolua_collect_Ogre__ColourValue (  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     106  static int tolua_collect_size_t (  lua_State* tolua_S )
          {
           size_t* self = (  size_t* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     113  static int tolua_collect_Ogre__MapIterator_Ogre__ResourceManager__ResourceHandleMap_ (  lua_State* tolua_S )
          {
           Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* self = (  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     120  static int tolua_collect_Ogre__Vector3 (  lua_State* tolua_S )
          {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     127  static int tolua_collect_Ogre__MeshPtr (  lua_State* tolua_S )
          {
           Ogre::MeshPtr* self = (  Ogre::MeshPtr* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     134  static int tolua_collect_Ogre__ResourceManager__ResourceHandleMap__mapped_type (  lua_State* tolua_S )
          {
           Ogre::ResourceManager::ResourceHandleMap::mapped_type* self = (  Ogre::ResourceManager::ResourceHandleMap::mapped_type* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     141  static int tolua_collect_uint (  lua_State* tolua_S )
          {
           uint* self = (  uint* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     148  static int tolua_collect_Ogre__Vector4 (  lua_State* tolua_S )
          {
           Ogre::Vector4* self = (  Ogre::Vector4* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     155  static int tolua_collect_Ogre__Matrix4 (  lua_State* tolua_S )
          {
           Ogre::Matrix4* self = (  Ogre::Matrix4* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     162  static int tolua_collect_Ogre__Matrix3 (  lua_State* tolua_S )
          {
           Ogre::Matrix3* self = (  Ogre::Matrix3* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          #endif
          
          
          /* function to register type */
     172  static void tolua_reg_types (  lua_State* tolua_S )
          {
           tolua_usertype(  tolua_S,  "Ogre::Vector2" );
           tolua_usertype(  tolua_S,  "Ogre::RenderTarget" );
           tolua_usertype(  tolua_S,  "Ogre::Timer" );
           tolua_usertype(  tolua_S,  "Ogre::Radian" );
           tolua_usertype(  tolua_S,  "Ogre::RenderWindow" );
           tolua_usertype(  tolua_S,  "Ogre::ResourceManager::ResourceHandleMap::key_type" );
           tolua_usertype(  tolua_S,  "Ogre::Vector4" );
           tolua_usertype(  tolua_S,  "Ogre::SceneManager" );
           tolua_usertype(  tolua_S,  "Ogre::AxisAlignedBox" );
           tolua_usertype(  tolua_S,  "Ogre::Image" );
           tolua_usertype(  tolua_S,  "Ogre::FrameListener" );
           tolua_usertype(  tolua_S,  "Ogre::Root" );
           tolua_usertype(  tolua_S,  "Ogre::MeshPtr" );
           tolua_usertype(  tolua_S,  "Ogre::ColourValue" );
           tolua_usertype(  tolua_S,  "Ogre::TextureManager" );
           tolua_usertype(  tolua_S,  "size_t" );
           tolua_usertype(  tolua_S,  "Ogre::Material" );
           tolua_usertype(  tolua_S,  "Ogre::MaterialManager" );
           tolua_usertype(  tolua_S,  "Ogre::Texture" );
           tolua_usertype(  tolua_S,  "Ogre::TexturePtr" );
           tolua_usertype(  tolua_S,  "Ogre::SceneNode" );
           tolua_usertype(  tolua_S,  "Ogre::VisibleObjectsBoundsInfo" );
           tolua_usertype(  tolua_S,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>" );
           tolua_usertype(  tolua_S,  "Ogre::SubEntity" );
           tolua_usertype(  tolua_S,  "Ogre::MeshManager" );
           tolua_usertype(  tolua_S,  "Ogre::Matrix3" );
           tolua_usertype(  tolua_S,  "std::vector<Ogre::Plane>" );
           tolua_usertype(  tolua_S,  "Ogre::RenderTarget::FrameStats" );
           tolua_usertype(  tolua_S,  "Ogre::Math" );
           tolua_usertype(  tolua_S,  "Ogre::Plane" );
           tolua_usertype(  tolua_S,  "Ogre::SkeletonInstance" );
           tolua_usertype(  tolua_S,  "Ogre::Node" );
           tolua_usertype(  tolua_S,  "Ogre::MapIterator<Ogre::Entity::ChildObjectList>" );
           tolua_usertype(  tolua_S,  "Ogre::AnimationState" );
           tolua_usertype(  tolua_S,  "std::list<Ogre::Plane>" );
           tolua_usertype(  tolua_S,  "Ogre::Resource" );
           tolua_usertype(  tolua_S,  "Ogre::TagPoint" );
           tolua_usertype(  tolua_S,  "Ogre::Sphere" );
           tolua_usertype(  tolua_S,  "Ogre::Quaternion" );
           tolua_usertype(  tolua_S,  "Ogre::ResourceManager" );
           tolua_usertype(  tolua_S,  "std::set<Ogre::Entity*>" );
           tolua_usertype(  tolua_S,  "Ogre::MaterialPtr" );
           tolua_usertype(  tolua_S,  "ushort" );
           tolua_usertype(  tolua_S,  "Ogre::Degree" );
           tolua_usertype(  tolua_S,  "std::pair<bool,  float>" );
           tolua_usertype(  tolua_S,  "Ogre::ResourcePtr" );
           tolua_usertype(  tolua_S,  "Ogre::ResourceManager::ResourceHandleMap::mapped_type" );
           tolua_usertype(  tolua_S,  "Ogre::Matrix4" );
           tolua_usertype(  tolua_S,  "Ogre::SubMesh" );
           tolua_usertype(  tolua_S,  "Ogre::Mesh" );
           tolua_usertype(  tolua_S,  "Ogre::Entity" );
           tolua_usertype(  tolua_S,  "Ogre::Vector3" );
           tolua_usertype(  tolua_S,  "Renderable" );
           tolua_usertype(  tolua_S,  "Ogre::AnimationStateSet" );
           tolua_usertype(  tolua_S,  "uint" );
           tolua_usertype(  tolua_S,  "Ogre::MovableObject" );
           tolua_usertype(  tolua_S,  "Ogre::Ray" );
           tolua_usertype(  tolua_S,  "Ogre::Camera" );
          }
          
          /* get function: lastFPS of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__RenderTarget__FrameStats_lastFPS
     236  static int tolua_get_Ogre__RenderTarget__FrameStats_lastFPS(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'lastFPS'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->lastFPS );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: lastFPS of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__RenderTarget__FrameStats_lastFPS
     249  static int tolua_set_Ogre__RenderTarget__FrameStats_lastFPS(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'lastFPS'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->lastFPS = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: avgFPS of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__RenderTarget__FrameStats_avgFPS
     266  static int tolua_get_Ogre__RenderTarget__FrameStats_avgFPS(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'avgFPS'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->avgFPS );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: avgFPS of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__RenderTarget__FrameStats_avgFPS
     279  static int tolua_set_Ogre__RenderTarget__FrameStats_avgFPS(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'avgFPS'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->avgFPS = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: bestFPS of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__RenderTarget__FrameStats_bestFPS
     296  static int tolua_get_Ogre__RenderTarget__FrameStats_bestFPS(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'bestFPS'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->bestFPS );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: bestFPS of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__RenderTarget__FrameStats_bestFPS
     309  static int tolua_set_Ogre__RenderTarget__FrameStats_bestFPS(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'bestFPS'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->bestFPS = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: worstFPS of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__RenderTarget__FrameStats_worstFPS
     326  static int tolua_get_Ogre__RenderTarget__FrameStats_worstFPS(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'worstFPS'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->worstFPS );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: worstFPS of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__RenderTarget__FrameStats_worstFPS
     339  static int tolua_set_Ogre__RenderTarget__FrameStats_worstFPS(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'worstFPS'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->worstFPS = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: bestFrameTime of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__RenderTarget__FrameStats_unsigned_bestFrameTime
     356  static int tolua_get_Ogre__RenderTarget__FrameStats_unsigned_bestFrameTime(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'bestFrameTime'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->bestFrameTime );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: bestFrameTime of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__RenderTarget__FrameStats_unsigned_bestFrameTime
     369  static int tolua_set_Ogre__RenderTarget__FrameStats_unsigned_bestFrameTime(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'bestFrameTime'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->bestFrameTime = (  (  unsigned long ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: worstFrameTime of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__RenderTarget__FrameStats_unsigned_worstFrameTime
     386  static int tolua_get_Ogre__RenderTarget__FrameStats_unsigned_worstFrameTime(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'worstFrameTime'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->worstFrameTime );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: worstFrameTime of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__RenderTarget__FrameStats_unsigned_worstFrameTime
     399  static int tolua_set_Ogre__RenderTarget__FrameStats_unsigned_worstFrameTime(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'worstFrameTime'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->worstFrameTime = (  (  unsigned long ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: triangleCount of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__RenderTarget__FrameStats_unsigned_triangleCount
     416  static int tolua_get_Ogre__RenderTarget__FrameStats_unsigned_triangleCount(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'triangleCount'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->triangleCount );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: triangleCount of class FrameStats */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__RenderTarget__FrameStats_unsigned_triangleCount
     429  static int tolua_set_Ogre__RenderTarget__FrameStats_unsigned_triangleCount(  lua_State* tolua_S )
          {
           Ogre::RenderTarget::FrameStats* self = (  Ogre::RenderTarget::FrameStats* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'triangleCount'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->triangleCount = (  (  unsigned long ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getStatistics of class Ogre::RenderTarget */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_RenderTarget_getStatistics00
     446  static int tolua_Ogre_Ogre_RenderTarget_getStatistics00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::RenderTarget",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::RenderTarget* self = (  const Ogre::RenderTarget* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getStatistics'",  NULL );
          #endif
           {
           const Ogre::RenderTarget::FrameStats& tolua_ret = (  const Ogre::RenderTarget::FrameStats& ) self->getStatistics(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::RenderTarget::FrameStats" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getStatistics'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasMoreElements of class Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__hasMoreElements00
     478  static int tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__hasMoreElements00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* self = (  const Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasMoreElements'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasMoreElements(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasMoreElements'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNext of class Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__getNext00
     510  static int tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__getNext00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* self = (  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNext'",  NULL );
          #endif
           {
           Ogre::ResourceManager::ResourceHandleMap::mapped_type tolua_ret = (  Ogre::ResourceManager::ResourceHandleMap::mapped_type ) self->getNext(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ResourceManager::ResourceHandleMap::mapped_type(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourceManager::ResourceHandleMap::mapped_type" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ResourceManager::ResourceHandleMap::mapped_type ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourceManager::ResourceHandleMap::mapped_type" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNext'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: peekNextValue of class Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__peekNextValue00
     550  static int tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__peekNextValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* self = (  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'peekNextValue'",  NULL );
          #endif
           {
           Ogre::ResourceManager::ResourceHandleMap::mapped_type tolua_ret = (  Ogre::ResourceManager::ResourceHandleMap::mapped_type ) self->peekNextValue(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ResourceManager::ResourceHandleMap::mapped_type(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourceManager::ResourceHandleMap::mapped_type" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ResourceManager::ResourceHandleMap::mapped_type ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourceManager::ResourceHandleMap::mapped_type" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'peekNextValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: peekNextKey of class Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__peekNextKey00
     590  static int tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__peekNextKey00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* self = (  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'peekNextKey'",  NULL );
          #endif
           {
           Ogre::ResourceManager::ResourceHandleMap::key_type tolua_ret = (  Ogre::ResourceManager::ResourceHandleMap::key_type ) self->peekNextKey(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ResourceManager::ResourceHandleMap::key_type(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourceManager::ResourceHandleMap::key_type" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ResourceManager::ResourceHandleMap::key_type ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourceManager::ResourceHandleMap::key_type" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'peekNextKey'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: moveNext of class Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__moveNext00
     630  static int tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__moveNext00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* self = (  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'moveNext'",  NULL );
          #endif
           {
           self->moveNext(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'moveNext'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: load of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_load00
     661  static int tolua_Ogre_Ogre_Resource_load00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Resource* self = (  Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'load'",  NULL );
          #endif
           {
           self->load(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'load'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: reload of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_reload00
     692  static int tolua_Ogre_Ogre_Resource_reload00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Resource* self = (  Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'reload'",  NULL );
          #endif
           {
           self->reload(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'reload'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isManuallyLoaded of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_isManuallyLoaded00
     723  static int tolua_Ogre_Ogre_Resource_isManuallyLoaded00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Resource* self = (  const Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isManuallyLoaded'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isManuallyLoaded(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isManuallyLoaded'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: unload of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_unload00
     755  static int tolua_Ogre_Ogre_Resource_unload00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Resource* self = (  Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'unload'",  NULL );
          #endif
           {
           self->unload(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'unload'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSize of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_getSize00
     786  static int tolua_Ogre_Ogre_Resource_getSize00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Resource* self = (  const Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSize'",  NULL );
          #endif
           {
           uint tolua_ret = (  uint ) self->getSize(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new uint(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "uint" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  uint ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "uint" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSize'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: touch of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_touch00
     826  static int tolua_Ogre_Ogre_Resource_touch00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Resource* self = (  Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'touch'",  NULL );
          #endif
           {
           self->touch(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'touch'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_getName00
     857  static int tolua_Ogre_Ogre_Resource_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Resource* self = (  const Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isLoaded of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_isLoaded00
     889  static int tolua_Ogre_Ogre_Resource_isLoaded00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Resource* self = (  const Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isLoaded'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isLoaded(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isLoaded'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getGroup of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_getGroup00
     921  static int tolua_Ogre_Ogre_Resource_getGroup00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Resource* self = (  Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getGroup'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getGroup(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getGroup'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getOrigin of class Ogre::Resource */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Resource_getOrigin00
     953  static int tolua_Ogre_Ogre_Resource_getOrigin00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Resource",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Resource* self = (  const Ogre::Resource* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getOrigin'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getOrigin(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getOrigin'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: create of class Ogre::ResourceManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ResourceManager_create00
     985  static int tolua_Ogre_Ogre_ResourceManager_create00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ResourceManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ResourceManager* self = (  Ogre::ResourceManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string group = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'create'",  NULL );
          #endif
           {
           Ogre::ResourcePtr tolua_ret = (  Ogre::ResourcePtr ) self->create(  name,  group );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ResourcePtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourcePtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ResourcePtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourcePtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           tolua_pushcppstring(  tolua_S,  (  const char* )group );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'create'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: reloadAll of class Ogre::ResourceManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ResourceManager_reloadAll00
    1031  static int tolua_Ogre_Ogre_ResourceManager_reloadAll00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ResourceManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ResourceManager* self = (  Ogre::ResourceManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'reloadAll'",  NULL );
          #endif
           {
           self->reloadAll(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'reloadAll'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: remove of class Ogre::ResourceManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ResourceManager_remove00
    1062  static int tolua_Ogre_Ogre_ResourceManager_remove00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ResourceManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::ResourcePtr",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ResourceManager* self = (  Ogre::ResourceManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::ResourcePtr* r = (  (  Ogre::ResourcePtr* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'remove'",  NULL );
          #endif
           {
           self->remove(  *r );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'remove'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: remove of class Ogre::ResourceManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ResourceManager_remove01
    1095  static int tolua_Ogre_Ogre_ResourceManager_remove01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ResourceManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::ResourceManager* self = (  Ogre::ResourceManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'remove'",  NULL );
          #endif
           {
           self->remove(  name );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_ResourceManager_remove00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getByName of class Ogre::ResourceManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ResourceManager_getByName00
    1124  static int tolua_Ogre_Ogre_ResourceManager_getByName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ResourceManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ResourceManager* self = (  Ogre::ResourceManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getByName'",  NULL );
          #endif
           {
           Ogre::ResourcePtr tolua_ret = (  Ogre::ResourcePtr ) self->getByName(  name );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ResourcePtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourcePtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ResourcePtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ResourcePtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getByName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: resourceExists of class Ogre::ResourceManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ResourceManager_resourceExists00
    1167  static int tolua_Ogre_Ogre_ResourceManager_resourceExists00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ResourceManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ResourceManager* self = (  Ogre::ResourceManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'resourceExists'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->resourceExists(  name );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'resourceExists'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getResourceIterator of class Ogre::ResourceManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ResourceManager_getResourceIterator00
    1202  static int tolua_Ogre_Ogre_ResourceManager_getResourceIterator00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ResourceManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ResourceManager* self = (  Ogre::ResourceManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getResourceIterator'",  NULL );
          #endif
           {
           Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> tolua_ret = (  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> ) self->getResourceIterator(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getResourceIterator'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class Ogre::MaterialManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MaterialManager_getSingleton00
    1242  static int tolua_Ogre_Ogre_MaterialManager_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::MaterialManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::MaterialManager& tolua_ret = (  Ogre::MaterialManager& ) Ogre::MaterialManager::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Ogre::MaterialManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: load of class Ogre::MaterialManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MaterialManager_load00
    1270  static int tolua_Ogre_Ogre_MaterialManager_load00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MaterialManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MaterialManager* self = (  Ogre::MaterialManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string group = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'load'",  NULL );
          #endif
           {
           Ogre::MaterialPtr tolua_ret = (  Ogre::MaterialPtr ) self->load(  name,  group );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::MaterialPtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MaterialPtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::MaterialPtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MaterialPtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           tolua_pushcppstring(  tolua_S,  (  const char* )group );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'load'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getByName of class Ogre::MaterialManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MaterialManager_getByName00
    1316  static int tolua_Ogre_Ogre_MaterialManager_getByName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MaterialManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MaterialManager* self = (  Ogre::MaterialManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getByName'",  NULL );
          #endif
           {
           Ogre::MaterialPtr tolua_ret = (  Ogre::MaterialPtr ) self->getByName(  name );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::MaterialPtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MaterialPtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::MaterialPtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MaterialPtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getByName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: create of class Ogre::MaterialManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MaterialManager_create00
    1359  static int tolua_Ogre_Ogre_MaterialManager_create00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MaterialManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MaterialManager* self = (  Ogre::MaterialManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string group = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'create'",  NULL );
          #endif
           {
           Ogre::MaterialPtr tolua_ret = (  Ogre::MaterialPtr ) self->create(  name,  group );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::MaterialPtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MaterialPtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::MaterialPtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MaterialPtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           tolua_pushcppstring(  tolua_S,  (  const char* )group );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'create'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isTransparent of class Ogre::Material */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Material_isTransparent00
    1405  static int tolua_Ogre_Ogre_Material_isTransparent00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Material",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Material* self = (  const Ogre::Material* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isTransparent'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isTransparent(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isTransparent'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setReceiveShadows of class Ogre::Material */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Material_setReceiveShadows00
    1437  static int tolua_Ogre_Ogre_Material_setReceiveShadows00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Material",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Material* self = (  Ogre::Material* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool enabled = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setReceiveShadows'",  NULL );
          #endif
           {
           self->setReceiveShadows(  enabled );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setReceiveShadows'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getReceiveShadows of class Ogre::Material */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Material_getReceiveShadows00
    1470  static int tolua_Ogre_Ogre_Material_getReceiveShadows00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Material",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Material* self = (  const Ogre::Material* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getReceiveShadows'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getReceiveShadows(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getReceiveShadows'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setTransparencyCastsShadows of class Ogre::Material */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Material_setTransparencyCastsShadows00
    1502  static int tolua_Ogre_Ogre_Material_setTransparencyCastsShadows00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Material",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Material* self = (  Ogre::Material* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool enabled = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setTransparencyCastsShadows'",  NULL );
          #endif
           {
           self->setTransparencyCastsShadows(  enabled );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setTransparencyCastsShadows'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getTransparencyCastsShadows of class Ogre::Material */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Material_getTransparencyCastsShadows00
    1535  static int tolua_Ogre_Ogre_Material_getTransparencyCastsShadows00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Material",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Material* self = (  const Ogre::Material* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getTransparencyCastsShadows'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getTransparencyCastsShadows(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getTransparencyCastsShadows'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNumTechniques of class Ogre::Material */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Material_getNumTechniques00
    1567  static int tolua_Ogre_Ogre_Material_getNumTechniques00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Material",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Material* self = (  const Ogre::Material* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNumTechniques'",  NULL );
          #endif
           {
           unsigned short tolua_ret = (  unsigned short ) self->getNumTechniques(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNumTechniques'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: touch of class Ogre::Material */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Material_touch00
    1599  static int tolua_Ogre_Ogre_Material_touch00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Material",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Material* self = (  Ogre::Material* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'touch'",  NULL );
          #endif
           {
           self->touch(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'touch'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: get of class Ogre::MaterialPtr */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MaterialPtr_get00
    1630  static int tolua_Ogre_Ogre_MaterialPtr_get00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MaterialPtr",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MaterialPtr* self = (  Ogre::MaterialPtr* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'get'",  NULL );
          #endif
           {
           Ogre::Material* tolua_ret = (  Ogre::Material* ) self->get(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Material" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'get'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMaterialName of class Ogre::SubEntity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SubEntity_getMaterialName00
    1662  static int tolua_Ogre_Ogre_SubEntity_getMaterialName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SubEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SubEntity* self = (  const Ogre::SubEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMaterialName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getMaterialName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMaterialName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaterialName of class Ogre::SubEntity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SubEntity_setMaterialName00
    1694  static int tolua_Ogre_Ogre_SubEntity_setMaterialName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SubEntity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SubEntity* self = (  Ogre::SubEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaterialName'",  NULL );
          #endif
           {
           self->setMaterialName(  name );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMaterialName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setVisible of class Ogre::SubEntity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SubEntity_setVisible00
    1728  static int tolua_Ogre_Ogre_SubEntity_setVisible00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SubEntity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SubEntity* self = (  Ogre::SubEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool visible = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setVisible'",  NULL );
          #endif
           {
           self->setVisible(  visible );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setVisible'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isVisible of class Ogre::SubEntity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SubEntity_isVisible00
    1761  static int tolua_Ogre_Ogre_SubEntity_isVisible00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SubEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SubEntity* self = (  const Ogre::SubEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isVisible'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isVisible(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isVisible'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMaterial of class Ogre::SubEntity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SubEntity_getMaterial00
    1793  static int tolua_Ogre_Ogre_SubEntity_getMaterial00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SubEntity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SubEntity* self = (  const Ogre::SubEntity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMaterial'",  NULL );
          #endif
           {
           const Ogre::MaterialPtr& tolua_ret = (  const Ogre::MaterialPtr& ) self->getMaterial(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::MaterialPtr" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMaterial'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class Ogre::MeshManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MeshManager_getSingleton00
    1825  static int tolua_Ogre_Ogre_MeshManager_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::MeshManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::MeshManager& tolua_ret = (  Ogre::MeshManager& ) Ogre::MeshManager::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Ogre::MeshManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: load of class Ogre::MeshManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MeshManager_load00
    1853  static int tolua_Ogre_Ogre_MeshManager_load00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MeshManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MeshManager* self = (  Ogre::MeshManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string group = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'load'",  NULL );
          #endif
           {
           Ogre::MeshPtr tolua_ret = (  Ogre::MeshPtr ) self->load(  name,  group );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::MeshPtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MeshPtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::MeshPtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MeshPtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           tolua_pushcppstring(  tolua_S,  (  const char* )group );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'load'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getByName of class Ogre::MeshManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MeshManager_getByName00
    1899  static int tolua_Ogre_Ogre_MeshManager_getByName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MeshManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MeshManager* self = (  Ogre::MeshManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getByName'",  NULL );
          #endif
           {
           Ogre::MeshPtr tolua_ret = (  Ogre::MeshPtr ) self->getByName(  name );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::MeshPtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MeshPtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::MeshPtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MeshPtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getByName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: create of class Ogre::MeshManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MeshManager_create00
    1942  static int tolua_Ogre_Ogre_MeshManager_create00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MeshManager",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MeshManager* self = (  Ogre::MeshManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string group = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'create'",  NULL );
          #endif
           {
           Ogre::MeshPtr tolua_ret = (  Ogre::MeshPtr ) self->create(  name,  group );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::MeshPtr(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MeshPtr" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::MeshPtr ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MeshPtr" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           tolua_pushcppstring(  tolua_S,  (  const char* )group );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'create'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNumSubMeshes of class Ogre::Mesh */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Mesh_getNumSubMeshes00
    1988  static int tolua_Ogre_Ogre_Mesh_getNumSubMeshes00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Mesh",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Mesh* self = (  const Ogre::Mesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNumSubMeshes'",  NULL );
          #endif
           {
           unsigned short tolua_ret = (  unsigned short ) self->getNumSubMeshes(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNumSubMeshes'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubMesh of class Ogre::Mesh */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Mesh_getSubMesh00
    2020  static int tolua_Ogre_Ogre_Mesh_getSubMesh00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Mesh",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Mesh* self = (  const Ogre::Mesh* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned short index = (  (  unsigned short ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSubMesh'",  NULL );
          #endif
           {
           Ogre::SubMesh* tolua_ret = (  Ogre::SubMesh* ) self->getSubMesh(  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SubMesh" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSubMesh'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBounds of class Ogre::Mesh */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Mesh_getBounds00
    2054  static int tolua_Ogre_Ogre_Mesh_getBounds00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Mesh",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Mesh* self = (  const Ogre::Mesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBounds'",  NULL );
          #endif
           {
           const Ogre::AxisAlignedBox& tolua_ret = (  const Ogre::AxisAlignedBox& ) self->getBounds(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBounds'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasSkeleton of class Ogre::Mesh */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Mesh_hasSkeleton00
    2086  static int tolua_Ogre_Ogre_Mesh_hasSkeleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Mesh",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Mesh* self = (  const Ogre::Mesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasSkeleton'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasSkeleton(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasSkeleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSkeletonName of class Ogre::Mesh */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Mesh_getSkeletonName00
    2118  static int tolua_Ogre_Ogre_Mesh_getSkeletonName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Mesh",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Mesh* self = (  const Ogre::Mesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSkeletonName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getSkeletonName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSkeletonName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNumLodLevels of class Ogre::Mesh */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Mesh_getNumLodLevels00
    2150  static int tolua_Ogre_Ogre_Mesh_getNumLodLevels00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Mesh",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Mesh* self = (  const Ogre::Mesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNumLodLevels'",  NULL );
          #endif
           {
           ushort tolua_ret = (  ushort ) self->getNumLodLevels(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new ushort(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "ushort" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  ushort ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "ushort" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNumLodLevels'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: get of class Ogre::MeshPtr */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MeshPtr_get00
    2190  static int tolua_Ogre_Ogre_MeshPtr_get00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::MeshPtr",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::MeshPtr* self = (  Ogre::MeshPtr* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'get'",  NULL );
          #endif
           {
           Ogre::Mesh* tolua_ret = (  Ogre::Mesh* ) self->get(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Mesh" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'get'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: get of class Ogre::MeshPtr */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_MeshPtr_get01
    2222  static int tolua_Ogre_Ogre_MeshPtr_get01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::MeshPtr",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::MeshPtr* self = (  const Ogre::MeshPtr* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'get'",  NULL );
          #endif
           {
           Ogre::Mesh* tolua_ret = (  Ogre::Mesh* ) self->get(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Mesh" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_MeshPtr_get00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: useSharedVertices of class Ogre::SubMesh */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__SubMesh_useSharedVertices
    2249  static int tolua_get_Ogre__SubMesh_useSharedVertices(  lua_State* tolua_S )
          {
           Ogre::SubMesh* self = (  Ogre::SubMesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'useSharedVertices'",  NULL );
          #endif
           tolua_pushboolean(  tolua_S,  (  bool )self->useSharedVertices );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: useSharedVertices of class Ogre::SubMesh */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__SubMesh_useSharedVertices
    2262  static int tolua_set_Ogre__SubMesh_useSharedVertices(  lua_State* tolua_S )
          {
           Ogre::SubMesh* self = (  Ogre::SubMesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'useSharedVertices'",  NULL );
           if (  !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->useSharedVertices = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: parent of class Ogre::SubMesh */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__SubMesh_parent_ptr
    2279  static int tolua_get_Ogre__SubMesh_parent_ptr(  lua_State* tolua_S )
          {
           Ogre::SubMesh* self = (  Ogre::SubMesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'parent'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )self->parent,  "Ogre::Mesh" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: parent of class Ogre::SubMesh */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__SubMesh_parent_ptr
    2292  static int tolua_set_Ogre__SubMesh_parent_ptr(  lua_State* tolua_S )
          {
           Ogre::SubMesh* self = (  Ogre::SubMesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'parent'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Ogre::Mesh",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->parent = (  (  Ogre::Mesh* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaterialName of class Ogre::SubMesh */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SubMesh_setMaterialName00
    2309  static int tolua_Ogre_Ogre_SubMesh_setMaterialName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SubMesh",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SubMesh* self = (  Ogre::SubMesh* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string matName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaterialName'",  NULL );
          #endif
           {
           self->setMaterialName(  matName );
           tolua_pushcppstring(  tolua_S,  (  const char* )matName );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMaterialName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMaterialName of class Ogre::SubMesh */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SubMesh_getMaterialName00
    2343  static int tolua_Ogre_Ogre_SubMesh_getMaterialName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SubMesh",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SubMesh* self = (  const Ogre::SubMesh* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMaterialName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getMaterialName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMaterialName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: x of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_x
    2375  static int tolua_get_Ogre__Vector3_x(  lua_State* tolua_S )
          {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'x'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->x );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: x of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__Vector3_x
    2388  static int tolua_set_Ogre__Vector3_x(  lua_State* tolua_S )
          {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'x'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: y of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_y
    2405  static int tolua_get_Ogre__Vector3_y(  lua_State* tolua_S )
          {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'y'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->y );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: y of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__Vector3_y
    2418  static int tolua_set_Ogre__Vector3_y(  lua_State* tolua_S )
          {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'y'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->y = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: z of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_z
    2435  static int tolua_get_Ogre__Vector3_z(  lua_State* tolua_S )
          {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'z'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->z );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: z of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__Vector3_z
    2448  static int tolua_set_Ogre__Vector3_z(  lua_State* tolua_S )
          {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'z'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->z = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new00
    2465  static int tolua_Ogre_Ogre_Vector3_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new00_local
    2493  static int tolua_Ogre_Ogre_Vector3_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new01
    2521  static int tolua_Ogre_Ogre_Vector3_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float fX = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float fY = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float fZ = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(  fX,  fY,  fZ );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Vector3" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new01_local
    2550  static int tolua_Ogre_Ogre_Vector3_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float fX = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float fY = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float fZ = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(  fX,  fY,  fZ );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Vector3" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new02
    2579  static int tolua_Ogre_Ogre_Vector3_new02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_istable(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float afCoordinate[3];
           {
          #ifndef TOLUA_RELEASE
           if (  !tolua_isnumberarray(  tolua_S,  2,  3,  0,  &tolua_err ) )
           goto tolua_lerror;
           else
          #endif
           {
           int i;
           for(  i=0; i<3;i++ )
           afCoordinate[i] = (  (  float ) tolua_tofieldnumber(  tolua_S,  2,  i+1,  0 ) );
           }
           }
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(  afCoordinate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Vector3" );
           }
           {
           int i;
           for(  i=0; i<3;i++ )
           tolua_pushfieldnumber(  tolua_S,  2,  i+1,  (  lua_Number ) afCoordinate[i] );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3_new01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new02_local
    2621  static int tolua_Ogre_Ogre_Vector3_new02_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_istable(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float afCoordinate[3];
           {
          #ifndef TOLUA_RELEASE
           if (  !tolua_isnumberarray(  tolua_S,  2,  3,  0,  &tolua_err ) )
           goto tolua_lerror;
           else
          #endif
           {
           int i;
           for(  i=0; i<3;i++ )
           afCoordinate[i] = (  (  float ) tolua_tofieldnumber(  tolua_S,  2,  i+1,  0 ) );
           }
           }
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(  afCoordinate );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Vector3" );
           }
           {
           int i;
           for(  i=0; i<3;i++ )
           tolua_pushfieldnumber(  tolua_S,  2,  i+1,  (  lua_Number ) afCoordinate[i] );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3_new01_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new03
    2663  static int tolua_Ogre_Ogre_Vector3_new03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_istable(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           int afCoordinate[3];
           {
          #ifndef TOLUA_RELEASE
           if (  !tolua_isnumberarray(  tolua_S,  2,  3,  0,  &tolua_err ) )
           goto tolua_lerror;
           else
          #endif
           {
           int i;
           for(  i=0; i<3;i++ )
           afCoordinate[i] = (  (  int ) tolua_tofieldnumber(  tolua_S,  2,  i+1,  0 ) );
           }
           }
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(  afCoordinate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Vector3" );
           }
           {
           int i;
           for(  i=0; i<3;i++ )
           tolua_pushfieldnumber(  tolua_S,  2,  i+1,  (  lua_Number ) afCoordinate[i] );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3_new02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new03_local
    2705  static int tolua_Ogre_Ogre_Vector3_new03_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_istable(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           int afCoordinate[3];
           {
          #ifndef TOLUA_RELEASE
           if (  !tolua_isnumberarray(  tolua_S,  2,  3,  0,  &tolua_err ) )
           goto tolua_lerror;
           else
          #endif
           {
           int i;
           for(  i=0; i<3;i++ )
           afCoordinate[i] = (  (  int ) tolua_tofieldnumber(  tolua_S,  2,  i+1,  0 ) );
           }
           }
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(  afCoordinate );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Vector3" );
           }
           {
           int i;
           for(  i=0; i<3;i++ )
           tolua_pushfieldnumber(  tolua_S,  2,  i+1,  (  lua_Number ) afCoordinate[i] );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3_new02_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new04
    2747  static int tolua_Ogre_Ogre_Vector3_new04(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Vector3* rkVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(  *rkVector );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Vector3" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3_new03(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_new04_local
    2772  static int tolua_Ogre_Ogre_Vector3_new04_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Vector3* rkVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Vector3* tolua_ret = (  Ogre::Vector3* ) new Ogre::Vector3(  *rkVector );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Vector3" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3_new03_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__geti00
    2797  static int tolua_Ogre_Ogre_Vector3__geti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* self = (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           long i = (  (  long ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->operator[](  i );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.geti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator&[] of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__seti00
    2831  static int tolua_Ogre_Ogre_Vector3__seti00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           long i = (  (  long ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float tolua_value = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator&[]'",  NULL );
          #endif
           self->operator[](  i ) = tolua_value;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.seti'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator[] of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__geti01
    2864  static int tolua_Ogre_Ogre_Vector3__geti01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           long i = (  (  long ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator[]'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->operator[](  i );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3__geti00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__eq00
    2893  static int tolua_Ogre_Ogre_Vector3__eq00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rkVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  *rkVector );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.eq'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator+ of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__add00
    2927  static int tolua_Ogre_Ogre_Vector3__add00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rkVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator+'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->operator+(  *rkVector );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.add'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__sub00
    2969  static int tolua_Ogre_Ogre_Vector3__sub00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rkVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->operator-(  *rkVector );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.sub'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__mul00
    3011  static int tolua_Ogre_Ogre_Vector3__mul00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           float fScalar = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->operator*(  fScalar );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.mul'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__mul01
    3053  static int tolua_Ogre_Ogre_Vector3__mul01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rhs = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->operator*(  *rhs );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3__mul00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator/ of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__div00
    3090  static int tolua_Ogre_Ogre_Vector3__div00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           float fScalar = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator/'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->operator/(  fScalar );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.div'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator/ of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__div01
    3132  static int tolua_Ogre_Ogre_Vector3__div01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rhs = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator/'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->operator/(  *rhs );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3__div00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__sub01
    3169  static int tolua_Ogre_Ogre_Vector3__sub01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->operator-(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Vector3__sub00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: length of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_length00
    3204  static int tolua_Ogre_Ogre_Vector3_length00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'length'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->length(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'length'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: squaredLength of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_squaredLength00
    3236  static int tolua_Ogre_Ogre_Vector3_squaredLength00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'squaredLength'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->squaredLength(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'squaredLength'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: dotProduct of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_dotProduct00
    3268  static int tolua_Ogre_Ogre_Vector3_dotProduct00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* vec = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'dotProduct'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->dotProduct(  *vec );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'dotProduct'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: normalise of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_normalise00
    3302  static int tolua_Ogre_Ogre_Vector3_normalise00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'normalise'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->normalise(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'normalise'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: crossProduct of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_crossProduct00
    3334  static int tolua_Ogre_Ogre_Vector3_crossProduct00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rkVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'crossProduct'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->crossProduct(  *rkVector );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'crossProduct'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: midPoint of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_midPoint00
    3376  static int tolua_Ogre_Ogre_Vector3_midPoint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* vec = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'midPoint'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->midPoint(  *vec );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'midPoint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator< of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3__lt00
    3418  static int tolua_Ogre_Ogre_Vector3__lt00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rhs = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator<'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator<(  *rhs );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.lt'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: makeFloor of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_makeFloor00
    3452  static int tolua_Ogre_Ogre_Vector3_makeFloor00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* cmp = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'makeFloor'",  NULL );
          #endif
           {
           self->makeFloor(  *cmp );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'makeFloor'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: makeCeil of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_makeCeil00
    3485  static int tolua_Ogre_Ogre_Vector3_makeCeil00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* cmp = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'makeCeil'",  NULL );
          #endif
           {
           self->makeCeil(  *cmp );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'makeCeil'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: perpendicular of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_perpendicular00
    3518  static int tolua_Ogre_Ogre_Vector3_perpendicular00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'perpendicular'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->perpendicular(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'perpendicular'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: randomDeviant of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_randomDeviant00
    3558  static int tolua_Ogre_Ogre_Vector3_randomDeviant00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* angle = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* up = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'randomDeviant'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->randomDeviant(  *angle,  *up );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'randomDeviant'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getRotationTo of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_getRotationTo00
    3602  static int tolua_Ogre_Ogre_Vector3_getRotationTo00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* dest = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getRotationTo'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->getRotationTo(  *dest );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getRotationTo'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isZeroLength of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_isZeroLength00
    3644  static int tolua_Ogre_Ogre_Vector3_isZeroLength00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isZeroLength'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isZeroLength(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isZeroLength'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: normalisedCopy of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_normalisedCopy00
    3676  static int tolua_Ogre_Ogre_Vector3_normalisedCopy00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'normalisedCopy'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->normalisedCopy(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'normalisedCopy'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: reflect of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_reflect00
    3716  static int tolua_Ogre_Ogre_Vector3_reflect00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* normal = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'reflect'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->reflect(  *normal );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'reflect'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: positionEquals of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_positionEquals00
    3758  static int tolua_Ogre_Ogre_Vector3_positionEquals00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rhs = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           float tolerance = (  (  float ) tolua_tonumber(  tolua_S,  3,  1e-03 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'positionEquals'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->positionEquals(  *rhs,  tolerance );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'positionEquals'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: directionEquals of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Vector3_directionEquals00
    3794  static int tolua_Ogre_Ogre_Vector3_directionEquals00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Vector3* self = (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rhs = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Radian* tolerance = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'directionEquals'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->directionEquals(  *rhs,  *tolerance );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'directionEquals'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ZERO of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_ZERO
    3830  static int tolua_get_Ogre__Vector3_ZERO(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Vector3::ZERO,  "const Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: UNIT_X of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_UNIT_X
    3839  static int tolua_get_Ogre__Vector3_UNIT_X(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Vector3::UNIT_X,  "const Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: UNIT_Y of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_UNIT_Y
    3848  static int tolua_get_Ogre__Vector3_UNIT_Y(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Vector3::UNIT_Y,  "const Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: UNIT_Z of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_UNIT_Z
    3857  static int tolua_get_Ogre__Vector3_UNIT_Z(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Vector3::UNIT_Z,  "const Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: NEGATIVE_UNIT_X of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_NEGATIVE_UNIT_X
    3866  static int tolua_get_Ogre__Vector3_NEGATIVE_UNIT_X(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Vector3::NEGATIVE_UNIT_X,  "const Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: NEGATIVE_UNIT_Y of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_NEGATIVE_UNIT_Y
    3875  static int tolua_get_Ogre__Vector3_NEGATIVE_UNIT_Y(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Vector3::NEGATIVE_UNIT_Y,  "const Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: NEGATIVE_UNIT_Z of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_NEGATIVE_UNIT_Z
    3884  static int tolua_get_Ogre__Vector3_NEGATIVE_UNIT_Z(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Vector3::NEGATIVE_UNIT_Z,  "const Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: UNIT_SCALE of class Ogre::Vector3 */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Vector3_UNIT_SCALE
    3893  static int tolua_get_Ogre__Vector3_UNIT_SCALE(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Vector3::UNIT_SCALE,  "const Ogre::Vector3" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new00
    3902  static int tolua_Ogre_Ogre_Quaternion_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fW = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float fX = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float fY = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           float fZ = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  fW,  fX,  fY,  fZ );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new00_local
    3938  static int tolua_Ogre_Ogre_Quaternion_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fW = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float fX = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float fY = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           float fZ = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  fW,  fX,  fY,  fZ );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new01
    3974  static int tolua_Ogre_Ogre_Quaternion_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  *rkQ );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new01_local
    3999  static int tolua_Ogre_Ogre_Quaternion_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  *rkQ );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new02
    4024  static int tolua_Ogre_Ogre_Quaternion_new02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Matrix3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Matrix3* rot = (  (  const Ogre::Matrix3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  *rot );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_new01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new02_local
    4049  static int tolua_Ogre_Ogre_Quaternion_new02_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Matrix3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Matrix3* rot = (  (  const Ogre::Matrix3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  *rot );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_new01_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new03
    4074  static int tolua_Ogre_Ogre_Quaternion_new03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* rfAngle = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* rkAxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  *rfAngle,  *rkAxis );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_new02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new03_local
    4101  static int tolua_Ogre_Ogre_Quaternion_new03_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* rfAngle = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* rkAxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  *rfAngle,  *rkAxis );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_new02_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new04
    4128  static int tolua_Ogre_Ogre_Quaternion_new04(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Vector3* xaxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* yaxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* zaxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  *xaxis,  *yaxis,  *zaxis );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_new03(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_new04_local
    4157  static int tolua_Ogre_Ogre_Quaternion_new04_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Vector3* xaxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* yaxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* zaxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           Ogre::Quaternion* tolua_ret = (  Ogre::Quaternion* ) new Ogre::Quaternion(  *xaxis,  *yaxis,  *zaxis );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Quaternion" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_new03_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: FromRotationMatrix of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_FromRotationMatrix00
    4186  static int tolua_Ogre_Ogre_Quaternion_FromRotationMatrix00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Matrix3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Matrix3* kRot = (  (  const Ogre::Matrix3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'FromRotationMatrix'",  NULL );
          #endif
           {
           self->FromRotationMatrix(  *kRot );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'FromRotationMatrix'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ToRotationMatrix of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_ToRotationMatrix00
    4219  static int tolua_Ogre_Ogre_Quaternion_ToRotationMatrix00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Matrix3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Matrix3* kRot = (  (  Ogre::Matrix3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'ToRotationMatrix'",  NULL );
          #endif
           {
           self->ToRotationMatrix(  *kRot );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'ToRotationMatrix'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: FromAngleAxis of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_FromAngleAxis00
    4252  static int tolua_Ogre_Ogre_Quaternion_FromAngleAxis00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* rfAngle = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* rkAxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'FromAngleAxis'",  NULL );
          #endif
           {
           self->FromAngleAxis(  *rfAngle,  *rkAxis );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'FromAngleAxis'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ToAngleAxis of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_ToAngleAxis00
    4287  static int tolua_Ogre_Ogre_Quaternion_ToAngleAxis00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Radian* rfAngle = (  (  Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Vector3* rkAxis = (  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'ToAngleAxis'",  NULL );
          #endif
           {
           self->ToAngleAxis(  *rfAngle,  *rkAxis );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'ToAngleAxis'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ToAngleAxis of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_ToAngleAxis01
    4322  static int tolua_Ogre_Ogre_Quaternion_ToAngleAxis01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Degree* dAngle = (  (  Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Vector3* rkAxis = (  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'ToAngleAxis'",  NULL );
          #endif
           {
           self->ToAngleAxis(  *dAngle,  *rkAxis );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_ToAngleAxis00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: FromAxes of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_FromAxes00
    4352  static int tolua_Ogre_Ogre_Quaternion_FromAxes00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* akAxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'FromAxes'",  NULL );
          #endif
           {
           self->FromAxes(  akAxis );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'FromAxes'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: FromAxes of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_FromAxes01
    4385  static int tolua_Ogre_Ogre_Quaternion_FromAxes01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* xAxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* yAxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* zAxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'FromAxes'",  NULL );
          #endif
           {
           self->FromAxes(  *xAxis,  *yAxis,  *zAxis );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_FromAxes00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ToAxes of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_ToAxes00
    4417  static int tolua_Ogre_Ogre_Quaternion_ToAxes00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Vector3* akAxis = (  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'ToAxes'",  NULL );
          #endif
           {
           self->ToAxes(  akAxis );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'ToAxes'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ToAxes of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_ToAxes01
    4450  static int tolua_Ogre_Ogre_Quaternion_ToAxes01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Vector3* xAxis = (  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Vector3* yAxis = (  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           Ogre::Vector3* zAxis = (  (  Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'ToAxes'",  NULL );
          #endif
           {
           self->ToAxes(  *xAxis,  *yAxis,  *zAxis );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion_ToAxes00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: xAxis of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_xAxis00
    4482  static int tolua_Ogre_Ogre_Quaternion_xAxis00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'xAxis'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->xAxis(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'xAxis'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: yAxis of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_yAxis00
    4522  static int tolua_Ogre_Ogre_Quaternion_yAxis00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'yAxis'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->yAxis(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'yAxis'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: zAxis of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_zAxis00
    4562  static int tolua_Ogre_Ogre_Quaternion_zAxis00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'zAxis'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->zAxis(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'zAxis'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator+ of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion__add00
    4602  static int tolua_Ogre_Ogre_Quaternion__add00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator+'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->operator+(  *rkQ );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.add'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion__sub00
    4644  static int tolua_Ogre_Ogre_Quaternion__sub00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->operator-(  *rkQ );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.sub'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion__mul00
    4686  static int tolua_Ogre_Ogre_Quaternion__mul00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->operator*(  *rkQ );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.mul'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion__mul01
    4728  static int tolua_Ogre_Ogre_Quaternion__mul01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           float fScalar = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->operator*(  fScalar );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion__mul00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion__sub01
    4765  static int tolua_Ogre_Ogre_Quaternion__sub01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->operator-(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion__sub00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion__eq00
    4800  static int tolua_Ogre_Ogre_Quaternion__eq00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* rhs = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  *rhs );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.eq'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Dot of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_Dot00
    4834  static int tolua_Ogre_Ogre_Quaternion_Dot00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'Dot'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->Dot(  *rkQ );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Dot'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Norm of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_Norm00
    4868  static int tolua_Ogre_Ogre_Quaternion_Norm00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'Norm'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->Norm(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Norm'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: normalise of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_normalise00
    4900  static int tolua_Ogre_Ogre_Quaternion_normalise00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'normalise'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->normalise(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'normalise'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Inverse of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_Inverse00
    4932  static int tolua_Ogre_Ogre_Quaternion_Inverse00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'Inverse'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->Inverse(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Inverse'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: UnitInverse of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_UnitInverse00
    4972  static int tolua_Ogre_Ogre_Quaternion_UnitInverse00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'UnitInverse'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->UnitInverse(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'UnitInverse'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Exp of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_Exp00
    5012  static int tolua_Ogre_Ogre_Quaternion_Exp00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'Exp'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->Exp(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Exp'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Log of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_Log00
    5052  static int tolua_Ogre_Ogre_Quaternion_Log00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'Log'",  NULL );
          #endif
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) self->Log(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Log'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion__mul02
    5092  static int tolua_Ogre_Ogre_Quaternion__mul02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* rkVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->operator*(  *rkVector );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Quaternion__mul01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getRoll of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_getRoll00
    5129  static int tolua_Ogre_Ogre_Quaternion_getRoll00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getRoll'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->getRoll(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getRoll'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPitch of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_getPitch00
    5169  static int tolua_Ogre_Ogre_Quaternion_getPitch00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPitch'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->getPitch(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPitch'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getYaw of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_getYaw00
    5209  static int tolua_Ogre_Ogre_Quaternion_getYaw00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getYaw'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->getYaw(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getYaw'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: equals of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_equals00
    5249  static int tolua_Ogre_Ogre_Quaternion_equals00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* self = (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* rhs = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Radian* tolerance = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'equals'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->equals(  *rhs,  *tolerance );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'equals'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Slerp of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_Slerp00
    5285  static int tolua_Ogre_Ogre_Quaternion_Slerp00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  5,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fT = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           const Ogre::Quaternion* rkP = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           bool shortestPath = (  (  bool ) tolua_toboolean(  tolua_S,  5,  false ) );
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) Ogre::Quaternion::Slerp(  fT,  *rkP,  *rkQ,  shortestPath );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Slerp'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: SlerpExtraSpins of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_SlerpExtraSpins00
    5329  static int tolua_Ogre_Ogre_Quaternion_SlerpExtraSpins00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fT = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           const Ogre::Quaternion* rkP = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           int iExtraSpins = (  (  int ) tolua_tonumber(  tolua_S,  5,  0 ) );
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) Ogre::Quaternion::SlerpExtraSpins(  fT,  *rkP,  *rkQ,  iExtraSpins );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'SlerpExtraSpins'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Intermediate of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_Intermediate00
    5373  static int tolua_Ogre_Ogre_Quaternion_Intermediate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Quaternion* rkQ0 = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Quaternion* rkQ1 = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Quaternion* rkQ2 = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           Ogre::Quaternion* rka = (  (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           Ogre::Quaternion* rkB = (  (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           Ogre::Quaternion::Intermediate(  *rkQ0,  *rkQ1,  *rkQ2,  *rka,  *rkB );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Intermediate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Squad of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_Squad00
    5410  static int tolua_Ogre_Ogre_Quaternion_Squad00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  7,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  8,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fT = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           const Ogre::Quaternion* rkP = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Quaternion* rkA = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const Ogre::Quaternion* rkB = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           bool shortestPath = (  (  bool ) tolua_toboolean(  tolua_S,  7,  false ) );
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) Ogre::Quaternion::Squad(  fT,  *rkP,  *rkA,  *rkB,  *rkQ,  shortestPath );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Squad'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: nlerp of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Quaternion_nlerp00
    5458  static int tolua_Ogre_Ogre_Quaternion_nlerp00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  5,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fT = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           const Ogre::Quaternion* rkP = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Quaternion* rkQ = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           bool shortestPath = (  (  bool ) tolua_toboolean(  tolua_S,  5,  false ) );
           {
           Ogre::Quaternion tolua_ret = (  Ogre::Quaternion ) Ogre::Quaternion::nlerp(  fT,  *rkP,  *rkQ,  shortestPath );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'nlerp'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ms_fEpsilon of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Quaternion_ms_fEpsilon
    5502  static int tolua_get_Ogre__Quaternion_ms_fEpsilon(  lua_State* tolua_S )
          {
           tolua_pushnumber(  tolua_S,  (  lua_Number )Ogre::Quaternion::ms_fEpsilon );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ZERO of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Quaternion_ZERO
    5511  static int tolua_get_Ogre__Quaternion_ZERO(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Quaternion::ZERO,  "const Ogre::Quaternion" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: IDENTITY of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Quaternion_IDENTITY
    5520  static int tolua_get_Ogre__Quaternion_IDENTITY(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::Quaternion::IDENTITY,  "const Ogre::Quaternion" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: w of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Quaternion_w
    5529  static int tolua_get_Ogre__Quaternion_w(  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'w'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->w );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: w of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__Quaternion_w
    5542  static int tolua_set_Ogre__Quaternion_w(  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'w'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->w = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: x of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Quaternion_x
    5559  static int tolua_get_Ogre__Quaternion_x(  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'x'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->x );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: x of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__Quaternion_x
    5572  static int tolua_set_Ogre__Quaternion_x(  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'x'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: y of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Quaternion_y
    5589  static int tolua_get_Ogre__Quaternion_y(  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'y'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->y );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: y of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__Quaternion_y
    5602  static int tolua_set_Ogre__Quaternion_y(  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'y'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->y = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: z of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Quaternion_z
    5619  static int tolua_get_Ogre__Quaternion_z(  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'z'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->z );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: z of class Ogre::Quaternion */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__Quaternion_z
    5632  static int tolua_set_Ogre__Quaternion_z(  lua_State* tolua_S )
          {
           Ogre::Quaternion* self = (  Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'z'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->z = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian_new00
    5649  static int tolua_Ogre_Ogre_Radian_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float r = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian* tolua_ret = (  Ogre::Radian* ) new Ogre::Radian(  r );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Radian" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian_new00_local
    5679  static int tolua_Ogre_Ogre_Radian_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float r = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian* tolua_ret = (  Ogre::Radian* ) new Ogre::Radian(  r );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Radian" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian_new01
    5709  static int tolua_Ogre_Ogre_Radian_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian* tolua_ret = (  Ogre::Radian* ) new Ogre::Radian(  *d );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Radian" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian_new01_local
    5734  static int tolua_Ogre_Ogre_Radian_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian* tolua_ret = (  Ogre::Radian* ) new Ogre::Radian(  *d );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Radian" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: valueDegrees of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian_valueDegrees00
    5759  static int tolua_Ogre_Ogre_Radian_valueDegrees00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'valueDegrees'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->valueDegrees(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'valueDegrees'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: valueRadians of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian_valueRadians00
    5791  static int tolua_Ogre_Ogre_Radian_valueRadians00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'valueRadians'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->valueRadians(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'valueRadians'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: valueAngleUnits of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian_valueAngleUnits00
    5823  static int tolua_Ogre_Ogre_Radian_valueAngleUnits00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'valueAngleUnits'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->valueAngleUnits(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'valueAngleUnits'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator+ of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__add00
    5855  static int tolua_Ogre_Ogre_Radian__add00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* r = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator+'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator+(  *r );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.add'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator+ of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__add01
    5897  static int tolua_Ogre_Ogre_Radian__add01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator+'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator+(  *d );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian__add00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__sub00
    5934  static int tolua_Ogre_Ogre_Radian__sub00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Radian* self = (  Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator-(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.sub'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__sub01
    5974  static int tolua_Ogre_Ogre_Radian__sub01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* r = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator-(  *r );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian__sub00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__sub02
    6011  static int tolua_Ogre_Ogre_Radian__sub02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator-(  *d );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian__sub01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__mul00
    6048  static int tolua_Ogre_Ogre_Radian__mul00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           float f = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator*(  f );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.mul'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__mul01
    6090  static int tolua_Ogre_Ogre_Radian__mul01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* f = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator*(  *f );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian__mul00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator/ of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__div00
    6127  static int tolua_Ogre_Ogre_Radian__div00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           float f = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator/'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator/(  f );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.div'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator< of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__lt00
    6169  static int tolua_Ogre_Ogre_Radian__lt00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* r = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator<'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator<(  *r );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.lt'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator<= of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__le00
    6203  static int tolua_Ogre_Ogre_Radian__le00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* r = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator<='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator<=(  *r );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.le'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__eq00
    6237  static int tolua_Ogre_Ogre_Radian__eq00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* r = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  *r );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.eq'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian_new02
    6271  static int tolua_Ogre_Ogre_Radian_new02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian* tolua_ret = (  Ogre::Radian* ) new Ogre::Radian(  *d );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Radian" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian_new01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian_new02_local
    6296  static int tolua_Ogre_Ogre_Radian_new02_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian* tolua_ret = (  Ogre::Radian* ) new Ogre::Radian(  *d );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Radian" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian_new01_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator+ of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__add02
    6321  static int tolua_Ogre_Ogre_Radian__add02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator+'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator+(  *d );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian__add01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Radian */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Radian__sub03
    6358  static int tolua_Ogre_Ogre_Radian__sub03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* self = (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) self->operator-(  *d );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Radian__sub02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree_new00
    6395  static int tolua_Ogre_Ogre_Degree_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float d = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Ogre::Degree* tolua_ret = (  Ogre::Degree* ) new Ogre::Degree(  d );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Degree" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree_new00_local
    6425  static int tolua_Ogre_Ogre_Degree_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float d = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Ogre::Degree* tolua_ret = (  Ogre::Degree* ) new Ogre::Degree(  d );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Degree" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree_new01
    6455  static int tolua_Ogre_Ogre_Degree_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* r = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Degree* tolua_ret = (  Ogre::Degree* ) new Ogre::Degree(  *r );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Degree" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Degree_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree_new01_local
    6480  static int tolua_Ogre_Ogre_Degree_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* r = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Degree* tolua_ret = (  Ogre::Degree* ) new Ogre::Degree(  *r );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Degree" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Degree_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: valueDegrees of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree_valueDegrees00
    6505  static int tolua_Ogre_Ogre_Degree_valueDegrees00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'valueDegrees'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->valueDegrees(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'valueDegrees'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: valueRadians of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree_valueRadians00
    6537  static int tolua_Ogre_Ogre_Degree_valueRadians00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'valueRadians'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->valueRadians(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'valueRadians'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: valueAngleUnits of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree_valueAngleUnits00
    6569  static int tolua_Ogre_Ogre_Degree_valueAngleUnits00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'valueAngleUnits'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->valueAngleUnits(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'valueAngleUnits'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator+ of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__add00
    6601  static int tolua_Ogre_Ogre_Degree__add00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator+'",  NULL );
          #endif
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) self->operator+(  *d );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.add'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator+ of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__add01
    6643  static int tolua_Ogre_Ogre_Degree__add01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* r = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator+'",  NULL );
          #endif
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) self->operator+(  *r );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Degree__add00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__sub00
    6680  static int tolua_Ogre_Ogre_Degree__sub00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Degree* self = (  Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) self->operator-(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.sub'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__sub01
    6720  static int tolua_Ogre_Ogre_Degree__sub01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) self->operator-(  *d );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Degree__sub00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__sub02
    6757  static int tolua_Ogre_Ogre_Degree__sub02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* r = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) self->operator-(  *r );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Degree__sub01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__mul00
    6794  static int tolua_Ogre_Ogre_Degree__mul00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           float f = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) self->operator*(  f );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.mul'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__mul01
    6836  static int tolua_Ogre_Ogre_Degree__mul01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* f = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) self->operator*(  *f );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Degree__mul00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator/ of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__div00
    6873  static int tolua_Ogre_Ogre_Degree__div00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           float f = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator/'",  NULL );
          #endif
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) self->operator/(  f );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.div'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator< of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__lt00
    6915  static int tolua_Ogre_Ogre_Degree__lt00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator<'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator<(  *d );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.lt'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator<= of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__le00
    6949  static int tolua_Ogre_Ogre_Degree__le00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator<='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator<=(  *d );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.le'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Ogre::Degree */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Degree__eq00
    6983  static int tolua_Ogre_Ogre_Degree__eq00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Degree* self = (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Degree* d = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  *d );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.eq'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_new00
    7017  static int tolua_Ogre_Ogre_Math_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           unsigned int trigTableSize = (  (  unsigned int ) tolua_tonumber(  tolua_S,  2,  4096 ) );
           {
           Ogre::Math* tolua_ret = (  Ogre::Math* ) new Ogre::Math(  trigTableSize );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Math" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_new00_local
    7047  static int tolua_Ogre_Ogre_Math_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           unsigned int trigTableSize = (  (  unsigned int ) tolua_tonumber(  tolua_S,  2,  4096 ) );
           {
           Ogre::Math* tolua_ret = (  Ogre::Math* ) new Ogre::Math(  trigTableSize );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::Math" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_delete00
    7077  static int tolua_Ogre_Ogre_Math_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Math* self = (  Ogre::Math* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: IAbs of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_IAbs00
    7106  static int tolua_Ogre_Ogre_Math_IAbs00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           int iValue = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           int tolua_ret = (  int ) Ogre::Math::IAbs(  iValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'IAbs'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ICeil of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_ICeil00
    7136  static int tolua_Ogre_Ogre_Math_ICeil00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           int tolua_ret = (  int ) Ogre::Math::ICeil(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'ICeil'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: IFloor of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_IFloor00
    7166  static int tolua_Ogre_Ogre_Math_IFloor00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           int tolua_ret = (  int ) Ogre::Math::IFloor(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'IFloor'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ISign of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_ISign00
    7196  static int tolua_Ogre_Ogre_Math_ISign00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           int iValue = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           int tolua_ret = (  int ) Ogre::Math::ISign(  iValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'ISign'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Abs of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Abs00
    7226  static int tolua_Ogre_Ogre_Math_Abs00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Abs(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Abs'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Abs of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Abs01
    7256  static int tolua_Ogre_Ogre_Math_Abs01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* dValue = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) Ogre::Math::Abs(  *dValue );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_Abs00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Abs of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Abs02
    7289  static int tolua_Ogre_Ogre_Math_Abs02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* rValue = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) Ogre::Math::Abs(  *rValue );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_Abs01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ACos of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_ACos00
    7322  static int tolua_Ogre_Ogre_Math_ACos00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) Ogre::Math::ACos(  fValue );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'ACos'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ASin of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_ASin00
    7360  static int tolua_Ogre_Ogre_Math_ASin00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) Ogre::Math::ASin(  fValue );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'ASin'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ATan of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_ATan00
    7398  static int tolua_Ogre_Ogre_Math_ATan00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) Ogre::Math::ATan(  fValue );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'ATan'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: ATan2 of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_ATan200
    7436  static int tolua_Ogre_Ogre_Math_ATan200(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fY = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float fX = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) Ogre::Math::ATan2(  fY,  fX );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'ATan2'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Ceil of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Ceil00
    7476  static int tolua_Ogre_Ogre_Math_Ceil00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Ceil(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Ceil'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Cos of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Cos00
    7506  static int tolua_Ogre_Ogre_Math_Cos00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* fValue = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           bool useTables = (  (  bool ) tolua_toboolean(  tolua_S,  3,  false ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Cos(  *fValue,  useTables );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Cos'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Cos of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Cos01
    7538  static int tolua_Ogre_Ogre_Math_Cos01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           bool useTables = (  (  bool ) tolua_toboolean(  tolua_S,  3,  false ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Cos(  fValue,  useTables );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_Cos00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Exp of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Exp00
    7565  static int tolua_Ogre_Ogre_Math_Exp00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Exp(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Exp'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Floor of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Floor00
    7595  static int tolua_Ogre_Ogre_Math_Floor00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Floor(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Floor'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Log of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Log00
    7625  static int tolua_Ogre_Ogre_Math_Log00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Log(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Log'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Pow of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Pow00
    7655  static int tolua_Ogre_Ogre_Math_Pow00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fBase = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float fExponent = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Pow(  fBase,  fExponent );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Pow'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Sign of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Sign00
    7687  static int tolua_Ogre_Ogre_Math_Sign00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Sign(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Sign'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Sign of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Sign01
    7717  static int tolua_Ogre_Ogre_Math_Sign01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* rValue = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) Ogre::Math::Sign(  *rValue );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_Sign00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Sign of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Sign02
    7750  static int tolua_Ogre_Ogre_Math_Sign02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* dValue = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) Ogre::Math::Sign(  *dValue );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_Sign01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Sin of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Sin00
    7783  static int tolua_Ogre_Ogre_Math_Sin00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* fValue = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           bool useTables = (  (  bool ) tolua_toboolean(  tolua_S,  3,  false ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Sin(  *fValue,  useTables );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Sin'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Sin of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Sin01
    7815  static int tolua_Ogre_Ogre_Math_Sin01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           bool useTables = (  (  bool ) tolua_toboolean(  tolua_S,  3,  false ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Sin(  fValue,  useTables );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_Sin00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Sqr of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Sqr00
    7842  static int tolua_Ogre_Ogre_Math_Sqr00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Sqr(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Sqr'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Sqrt of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Sqrt00
    7872  static int tolua_Ogre_Ogre_Math_Sqrt00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Sqrt(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Sqrt'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Sqrt of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Sqrt01
    7902  static int tolua_Ogre_Ogre_Math_Sqrt01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Radian* fValue = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Radian tolua_ret = (  Ogre::Radian ) Ogre::Math::Sqrt(  *fValue );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Radian(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Radian ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Radian" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_Sqrt00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Sqrt of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Sqrt02
    7935  static int tolua_Ogre_Ogre_Math_Sqrt02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Degree",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Degree* fValue = (  (  const Ogre::Degree* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Degree tolua_ret = (  Ogre::Degree ) Ogre::Math::Sqrt(  *fValue );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Degree(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Degree ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Degree" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_Sqrt01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: InvSqrt of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_InvSqrt00
    7968  static int tolua_Ogre_Ogre_Math_InvSqrt00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::InvSqrt(  fValue );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'InvSqrt'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: UnitRandom of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_UnitRandom00
    7998  static int tolua_Ogre_Ogre_Math_UnitRandom00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           float tolua_ret = (  float ) Ogre::Math::UnitRandom(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'UnitRandom'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: RangeRandom of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_RangeRandom00
    8026  static int tolua_Ogre_Ogre_Math_RangeRandom00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float fLow = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float fHigh = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::RangeRandom(  fLow,  fHigh );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'RangeRandom'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: SymmetricRandom of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_SymmetricRandom00
    8058  static int tolua_Ogre_Ogre_Math_SymmetricRandom00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           float tolua_ret = (  float ) Ogre::Math::SymmetricRandom(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'SymmetricRandom'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Tan of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Tan00
    8086  static int tolua_Ogre_Ogre_Math_Tan00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Radian* fValue = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           bool useTables = (  (  bool ) tolua_toboolean(  tolua_S,  3,  false ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Tan(  *fValue,  useTables );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Tan'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Tan of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_Tan01
    8118  static int tolua_Ogre_Ogre_Math_Tan01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float fValue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           bool useTables = (  (  bool ) tolua_toboolean(  tolua_S,  3,  false ) );
           {
           float tolua_ret = (  float ) Ogre::Math::Tan(  fValue,  useTables );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_Tan00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: DegreesToRadians of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_DegreesToRadians00
    8145  static int tolua_Ogre_Ogre_Math_DegreesToRadians00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float degrees = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::DegreesToRadians(  degrees );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'DegreesToRadians'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: RadiansToDegrees of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_RadiansToDegrees00
    8175  static int tolua_Ogre_Ogre_Math_RadiansToDegrees00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float radians = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::RadiansToDegrees(  radians );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'RadiansToDegrees'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAngleUnit of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_setAngleUnit00
    8205  static int tolua_Ogre_Ogre_Math_setAngleUnit00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Math::AngleUnit unit = (  (  Ogre::Math::AngleUnit ) (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Ogre::Math::setAngleUnit(  unit );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAngleUnit'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAngleUnit of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_getAngleUnit00
    8234  static int tolua_Ogre_Ogre_Math_getAngleUnit00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::Math::AngleUnit tolua_ret = (  Ogre::Math::AngleUnit ) Ogre::Math::getAngleUnit(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAngleUnit'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: AngleUnitsToRadians of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_AngleUnitsToRadians00
    8262  static int tolua_Ogre_Ogre_Math_AngleUnitsToRadians00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float units = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::AngleUnitsToRadians(  units );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'AngleUnitsToRadians'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: RadiansToAngleUnits of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_RadiansToAngleUnits00
    8292  static int tolua_Ogre_Ogre_Math_RadiansToAngleUnits00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float radians = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::RadiansToAngleUnits(  radians );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'RadiansToAngleUnits'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: AngleUnitsToDegrees of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_AngleUnitsToDegrees00
    8322  static int tolua_Ogre_Ogre_Math_AngleUnitsToDegrees00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float units = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::AngleUnitsToDegrees(  units );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'AngleUnitsToDegrees'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: DegreesToAngleUnits of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_DegreesToAngleUnits00
    8352  static int tolua_Ogre_Ogre_Math_DegreesToAngleUnits00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float degrees = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           float tolua_ret = (  float ) Ogre::Math::DegreesToAngleUnits(  degrees );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'DegreesToAngleUnits'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: pointInTri2D of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_pointInTri2D00
    8382  static int tolua_Ogre_Ogre_Math_pointInTri2D00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector2",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector2",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector2",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const Ogre::Vector2",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector2* p = (  (  const Ogre::Vector2* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector2* a = (  (  const Ogre::Vector2* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector2* b = (  (  const Ogre::Vector2* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const Ogre::Vector2* c = (  (  const Ogre::Vector2* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           bool tolua_ret = (  bool ) Ogre::Math::pointInTri2D(  *p,  *a,  *b,  *c );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'pointInTri2D'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: pointInTri3D of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_pointInTri3D00
    8418  static int tolua_Ogre_Ogre_Math_pointInTri3D00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* p = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* a = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* b = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const Ogre::Vector3* c = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           const Ogre::Vector3* normal = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           bool tolua_ret = (  bool ) Ogre::Math::pointInTri3D(  *p,  *a,  *b,  *c,  *normal );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'pointInTri3D'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects00
    8456  static int tolua_Ogre_Ogre_Math_intersects00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Ray",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Plane",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Ray* ray = (  (  const Ogre::Ray* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Plane* plane = (  (  const Ogre::Plane* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           std::pair<bool,  float> tolua_ret = (  std::pair<bool,  float> ) Ogre::Math::intersects(  *ray,  *plane );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::pair<bool,  float>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::pair<bool,  float> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'intersects'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects01
    8496  static int tolua_Ogre_Ogre_Math_intersects01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Ray",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Sphere",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  4,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Ray* ray = (  (  const Ogre::Ray* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Sphere* sphere = (  (  const Ogre::Sphere* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           bool discardInside = (  (  bool ) tolua_toboolean(  tolua_S,  4,  true ) );
           {
           std::pair<bool,  float> tolua_ret = (  std::pair<bool,  float> ) Ogre::Math::intersects(  *ray,  *sphere,  discardInside );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::pair<bool,  float>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::pair<bool,  float> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects02
    8533  static int tolua_Ogre_Ogre_Math_intersects02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Ray",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Ray* ray = (  (  const Ogre::Ray* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::AxisAlignedBox* box = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           std::pair<bool,  float> tolua_ret = (  std::pair<bool,  float> ) Ogre::Math::intersects(  *ray,  *box );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::pair<bool,  float>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::pair<bool,  float> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects03
    8568  static int tolua_Ogre_Ogre_Math_intersects03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Ray",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Ray* ray = (  (  const Ogre::Ray* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::AxisAlignedBox* box = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           float d1 = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           float d2 = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
           {
           bool tolua_ret = (  bool ) Ogre::Math::intersects(  *ray,  *box,  &d1,  &d2 );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushnumber(  tolua_S,  (  lua_Number )d1 );
           tolua_pushnumber(  tolua_S,  (  lua_Number )d2 );
           }
           }
           return 3;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects04
    8601  static int tolua_Ogre_Ogre_Math_intersects04(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Ray",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  7,  1,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  8,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  9,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Ray* ray = (  (  const Ogre::Ray* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* a = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* b = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const Ogre::Vector3* c = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           const Ogre::Vector3* normal = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           bool positiveSide = (  (  bool ) tolua_toboolean(  tolua_S,  7,  true ) );
           bool negativeSide = (  (  bool ) tolua_toboolean(  tolua_S,  8,  true ) );
           {
           std::pair<bool,  float> tolua_ret = (  std::pair<bool,  float> ) Ogre::Math::intersects(  *ray,  *a,  *b,  *c,  *normal,  positiveSide,  negativeSide );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::pair<bool,  float>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::pair<bool,  float> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects03(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects05
    8646  static int tolua_Ogre_Ogre_Math_intersects05(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Ray",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  6,  1,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  7,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  8,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Ray* ray = (  (  const Ogre::Ray* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* a = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* b = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const Ogre::Vector3* c = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           bool positiveSide = (  (  bool ) tolua_toboolean(  tolua_S,  6,  true ) );
           bool negativeSide = (  (  bool ) tolua_toboolean(  tolua_S,  7,  true ) );
           {
           std::pair<bool,  float> tolua_ret = (  std::pair<bool,  float> ) Ogre::Math::intersects(  *ray,  *a,  *b,  *c,  positiveSide,  negativeSide );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::pair<bool,  float>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::pair<bool,  float> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects04(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects06
    8689  static int tolua_Ogre_Ogre_Math_intersects06(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Sphere",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Sphere* sphere = (  (  const Ogre::Sphere* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::AxisAlignedBox* box = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           bool tolua_ret = (  bool ) Ogre::Math::intersects(  *sphere,  *box );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects05(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects07
    8716  static int tolua_Ogre_Ogre_Math_intersects07(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Plane",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Plane* plane = (  (  const Ogre::Plane* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::AxisAlignedBox* box = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           bool tolua_ret = (  bool ) Ogre::Math::intersects(  *plane,  *box );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects06(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects08
    8743  static int tolua_Ogre_Ogre_Math_intersects08(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Ray",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const std::vector<Ogre::Plane>",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Ray* ray = (  (  const Ogre::Ray* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::vector<Ogre::Plane>* planeList = (  (  const std::vector<Ogre::Plane>* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           bool normalIsOutside = (  (  bool ) tolua_toboolean(  tolua_S,  4,  0 ) );
           {
           std::pair<bool,  float> tolua_ret = (  std::pair<bool,  float> ) Ogre::Math::intersects(  *ray,  *planeList,  normalIsOutside );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::pair<bool,  float>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::pair<bool,  float> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects07(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects09
    8780  static int tolua_Ogre_Ogre_Math_intersects09(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Ray",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const std::list<Ogre::Plane>",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Ray* ray = (  (  const Ogre::Ray* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::list<Ogre::Plane>* planeList = (  (  const std::list<Ogre::Plane>* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           bool normalIsOutside = (  (  bool ) tolua_toboolean(  tolua_S,  4,  0 ) );
           {
           std::pair<bool,  float> tolua_ret = (  std::pair<bool,  float> ) Ogre::Math::intersects(  *ray,  *planeList,  normalIsOutside );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::pair<bool,  float>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::pair<bool,  float> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::pair<bool,  float>" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects08(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_intersects10
    8817  static int tolua_Ogre_Ogre_Math_intersects10(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Sphere",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Plane",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Sphere* sphere = (  (  const Ogre::Sphere* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Plane* plane = (  (  const Ogre::Plane* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           bool tolua_ret = (  bool ) Ogre::Math::intersects(  *sphere,  *plane );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_intersects09(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: RealEqual of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_RealEqual00
    8844  static int tolua_Ogre_Ogre_Math_RealEqual00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float a = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float b = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           {
           bool tolua_ret = (  bool ) Ogre::Math::RealEqual(  a,  b );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'RealEqual'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: RealEqual of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_RealEqual01
    8876  static int tolua_Ogre_Ogre_Math_RealEqual01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float a = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float b = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float tolerance = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           {
           bool tolua_ret = (  bool ) Ogre::Math::RealEqual(  a,  b,  tolerance );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Math_RealEqual00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: calculateTangentSpaceVector of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_calculateTangentSpaceVector00
    8905  static int tolua_Ogre_Ogre_Math_calculateTangentSpaceVector00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  6,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  7,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  8,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  9,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  10,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  11,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* position1 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* position2 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* position3 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           float u1 = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
           float v1 = (  (  float ) tolua_tonumber(  tolua_S,  6,  0 ) );
           float u2 = (  (  float ) tolua_tonumber(  tolua_S,  7,  0 ) );
           float v2 = (  (  float ) tolua_tonumber(  tolua_S,  8,  0 ) );
           float u3 = (  (  float ) tolua_tonumber(  tolua_S,  9,  0 ) );
           float v3 = (  (  float ) tolua_tonumber(  tolua_S,  10,  0 ) );
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) Ogre::Math::calculateTangentSpaceVector(  *position1,  *position2,  *position3,  u1,  v1,  u2,  v2,  u3,  v3 );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'calculateTangentSpaceVector'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: buildReflectionMatrix of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_buildReflectionMatrix00
    8959  static int tolua_Ogre_Ogre_Math_buildReflectionMatrix00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Plane",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Plane* p = (  (  const Ogre::Plane* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Matrix4 tolua_ret = (  Ogre::Matrix4 ) Ogre::Math::buildReflectionMatrix(  *p );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Matrix4(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Matrix4" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Matrix4 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Matrix4" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'buildReflectionMatrix'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: calculateFaceNormal of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_calculateFaceNormal00
    8997  static int tolua_Ogre_Ogre_Math_calculateFaceNormal00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* v1 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* v2 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* v3 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           Ogre::Vector4 tolua_ret = (  Ogre::Vector4 ) Ogre::Math::calculateFaceNormal(  *v1,  *v2,  *v3 );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector4(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector4" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector4 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector4" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'calculateFaceNormal'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: calculateBasicFaceNormal of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_calculateBasicFaceNormal00
    9039  static int tolua_Ogre_Ogre_Math_calculateBasicFaceNormal00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* v1 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* v2 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* v3 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) Ogre::Math::calculateBasicFaceNormal(  *v1,  *v2,  *v3 );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'calculateBasicFaceNormal'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: calculateFaceNormalWithoutNormalize of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_calculateFaceNormalWithoutNormalize00
    9081  static int tolua_Ogre_Ogre_Math_calculateFaceNormalWithoutNormalize00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* v1 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* v2 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* v3 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           Ogre::Vector4 tolua_ret = (  Ogre::Vector4 ) Ogre::Math::calculateFaceNormalWithoutNormalize(  *v1,  *v2,  *v3 );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector4(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector4" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector4 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector4" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'calculateFaceNormalWithoutNormalize'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: calculateBasicFaceNormalWithoutNormalize of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_calculateBasicFaceNormalWithoutNormalize00
    9123  static int tolua_Ogre_Ogre_Math_calculateBasicFaceNormalWithoutNormalize00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Vector3* v1 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* v2 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* v3 = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) Ogre::Math::calculateBasicFaceNormalWithoutNormalize(  *v1,  *v2,  *v3 );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'calculateBasicFaceNormalWithoutNormalize'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: gaussianDistribution of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Math_gaussianDistribution00
    9165  static int tolua_Ogre_Ogre_Math_gaussianDistribution00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Math",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float offset = (  (  float ) tolua_tonumber(  tolua_S,  3,  0.0f ) );
           float scale = (  (  float ) tolua_tonumber(  tolua_S,  4,  1.0f ) );
           {
           float tolua_ret = (  float ) Ogre::Math::gaussianDistribution(  x,  offset,  scale );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'gaussianDistribution'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: POS_INFINITY of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Math_POS_INFINITY
    9199  static int tolua_get_Ogre__Math_POS_INFINITY(  lua_State* tolua_S )
          {
           tolua_pushnumber(  tolua_S,  (  lua_Number )Ogre::Math::POS_INFINITY );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: NEG_INFINITY of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Math_NEG_INFINITY
    9208  static int tolua_get_Ogre__Math_NEG_INFINITY(  lua_State* tolua_S )
          {
           tolua_pushnumber(  tolua_S,  (  lua_Number )Ogre::Math::NEG_INFINITY );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: PI of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Math_PI
    9217  static int tolua_get_Ogre__Math_PI(  lua_State* tolua_S )
          {
           tolua_pushnumber(  tolua_S,  (  lua_Number )Ogre::Math::PI );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: TWO_PI of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Math_TWO_PI
    9226  static int tolua_get_Ogre__Math_TWO_PI(  lua_State* tolua_S )
          {
           tolua_pushnumber(  tolua_S,  (  lua_Number )Ogre::Math::TWO_PI );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: HALF_PI of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Math_HALF_PI
    9235  static int tolua_get_Ogre__Math_HALF_PI(  lua_State* tolua_S )
          {
           tolua_pushnumber(  tolua_S,  (  lua_Number )Ogre::Math::HALF_PI );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: fDeg2Rad of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Math_fDeg2Rad
    9244  static int tolua_get_Ogre__Math_fDeg2Rad(  lua_State* tolua_S )
          {
           tolua_pushnumber(  tolua_S,  (  lua_Number )Ogre::Math::fDeg2Rad );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: fRad2Deg of class Ogre::Math */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__Math_fRad2Deg
    9253  static int tolua_get_Ogre__Math_fRad2Deg(  lua_State* tolua_S )
          {
           tolua_pushnumber(  tolua_S,  (  lua_Number )Ogre::Math::fRad2Deg );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMesh of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getMesh00
    9262  static int tolua_Ogre_Ogre_Entity_getMesh00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMesh'",  NULL );
          #endif
           {
           const Ogre::MeshPtr& tolua_ret = (  const Ogre::MeshPtr& ) self->getMesh(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::MeshPtr" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMesh'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubEntity of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getSubEntity00
    9294  static int tolua_Ogre_Ogre_Entity_getSubEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned int index = (  (  unsigned int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSubEntity'",  NULL );
          #endif
           {
           Ogre::SubEntity* tolua_ret = (  Ogre::SubEntity* ) self->getSubEntity(  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SubEntity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSubEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSubEntity of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getSubEntity01
    9328  static int tolua_Ogre_Ogre_Entity_getSubEntity01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSubEntity'",  NULL );
          #endif
           {
           Ogre::SubEntity* tolua_ret = (  Ogre::SubEntity* ) self->getSubEntity(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SubEntity" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_Entity_getSubEntity00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNumSubEntities of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getNumSubEntities00
    9358  static int tolua_Ogre_Ogre_Entity_getNumSubEntities00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNumSubEntities'",  NULL );
          #endif
           {
           unsigned int tolua_ret = (  unsigned int ) self->getNumSubEntities(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNumSubEntities'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: clone of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_clone00
    9390  static int tolua_Ogre_Ogre_Entity_clone00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string newName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'clone'",  NULL );
          #endif
           {
           Ogre::Entity* tolua_ret = (  Ogre::Entity* ) self->clone(  newName );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Entity" );
           tolua_pushcppstring(  tolua_S,  (  const char* )newName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'clone'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaterialName of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_setMaterialName00
    9425  static int tolua_Ogre_Ogre_Entity_setMaterialName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaterialName'",  NULL );
          #endif
           {
           self->setMaterialName(  name );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMaterialName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setRenderQueueGroup of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_setRenderQueueGroup00
    9459  static int tolua_Ogre_Ogre_Entity_setRenderQueueGroup00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           char queueID = (  (  char ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setRenderQueueGroup'",  NULL );
          #endif
           {
           self->setRenderQueueGroup(  queueID );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setRenderQueueGroup'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBoundingBox of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getBoundingBox00
    9492  static int tolua_Ogre_Ogre_Entity_getBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBoundingBox'",  NULL );
          #endif
           {
           const Ogre::AxisAlignedBox& tolua_ret = (  const Ogre::AxisAlignedBox& ) self->getBoundingBox(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getChildObjectsBoundingBox of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getChildObjectsBoundingBox00
    9524  static int tolua_Ogre_Ogre_Entity_getChildObjectsBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getChildObjectsBoundingBox'",  NULL );
          #endif
           {
           Ogre::AxisAlignedBox tolua_ret = (  Ogre::AxisAlignedBox ) self->getChildObjectsBoundingBox(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::AxisAlignedBox(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::AxisAlignedBox" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::AxisAlignedBox ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::AxisAlignedBox" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getChildObjectsBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMovableType of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getMovableType00
    9564  static int tolua_Ogre_Ogre_Entity_getMovableType00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMovableType'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getMovableType(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMovableType'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAnimationState of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getAnimationState00
    9596  static int tolua_Ogre_Ogre_Entity_getAnimationState00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAnimationState'",  NULL );
          #endif
           {
           Ogre::AnimationState* tolua_ret = (  Ogre::AnimationState* ) self->getAnimationState(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::AnimationState" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAnimationState'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAllAnimationStates of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getAllAnimationStates00
    9631  static int tolua_Ogre_Ogre_Entity_getAllAnimationStates00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAllAnimationStates'",  NULL );
          #endif
           {
           Ogre::AnimationStateSet* tolua_ret = (  Ogre::AnimationStateSet* ) self->getAllAnimationStates(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::AnimationStateSet" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAllAnimationStates'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDisplaySkeleton of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_setDisplaySkeleton00
    9663  static int tolua_Ogre_Ogre_Entity_setDisplaySkeleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool display = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDisplaySkeleton'",  NULL );
          #endif
           {
           self->setDisplaySkeleton(  display );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setDisplaySkeleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDisplaySkeleton of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getDisplaySkeleton00
    9696  static int tolua_Ogre_Ogre_Entity_getDisplaySkeleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDisplaySkeleton'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getDisplaySkeleton(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDisplaySkeleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getManualLodLevel of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getManualLodLevel00
    9728  static int tolua_Ogre_Ogre_Entity_getManualLodLevel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getManualLodLevel'",  NULL );
          #endif
           {
           Ogre::Entity* tolua_ret = (  Ogre::Entity* ) self->getManualLodLevel(  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Entity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getManualLodLevel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNumManualLodLevels of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getNumManualLodLevels00
    9762  static int tolua_Ogre_Ogre_Entity_getNumManualLodLevels00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNumManualLodLevels'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->getNumManualLodLevels(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNumManualLodLevels'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMeshLodBias of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_setMeshLodBias00
    9794  static int tolua_Ogre_Ogre_Entity_setMeshLodBias00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           float factor = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           unsigned short maxDetailIndex = (  (  unsigned short ) tolua_tonumber(  tolua_S,  3,  0 ) );
           unsigned short minDetailIndex = (  (  unsigned short ) tolua_tonumber(  tolua_S,  4,  99 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMeshLodBias'",  NULL );
          #endif
           {
           self->setMeshLodBias(  factor,  maxDetailIndex,  minDetailIndex );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMeshLodBias'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaterialLodBias of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_setMaterialLodBias00
    9831  static int tolua_Ogre_Ogre_Entity_setMaterialLodBias00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           float factor = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           unsigned short maxDetailIndex = (  (  unsigned short ) tolua_tonumber(  tolua_S,  3,  0 ) );
           unsigned short minDetailIndex = (  (  unsigned short ) tolua_tonumber(  tolua_S,  4,  99 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaterialLodBias'",  NULL );
          #endif
           {
           self->setMaterialLodBias(  factor,  maxDetailIndex,  minDetailIndex );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMaterialLodBias'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setPolygonModeOverrideable of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_setPolygonModeOverrideable00
    9868  static int tolua_Ogre_Ogre_Entity_setPolygonModeOverrideable00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool PolygonModeOverrideable = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setPolygonModeOverrideable'",  NULL );
          #endif
           {
           self->setPolygonModeOverrideable(  PolygonModeOverrideable );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setPolygonModeOverrideable'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: attachObjectToBone of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_attachObjectToBone00
    9901  static int tolua_Ogre_Ogre_Entity_attachObjectToBone00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::MovableObject",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string boneName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           Ogre::MovableObject* pMovable = (  (  Ogre::MovableObject* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'attachObjectToBone'",  NULL );
          #endif
           {
           Ogre::TagPoint* tolua_ret = (  Ogre::TagPoint* ) self->attachObjectToBone(  boneName,  pMovable );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::TagPoint" );
           tolua_pushcppstring(  tolua_S,  (  const char* )boneName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'attachObjectToBone'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: attachObjectToBone of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_attachObjectToBone01
    9938  static int tolua_Ogre_Ogre_Entity_attachObjectToBone01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::MovableObject",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string boneName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           Ogre::MovableObject* pMovable = (  (  Ogre::MovableObject* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Quaternion* offsetOrientation = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'attachObjectToBone'",  NULL );
          #endif
           {
           Ogre::TagPoint* tolua_ret = (  Ogre::TagPoint* ) self->attachObjectToBone(  boneName,  pMovable,  *offsetOrientation );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::TagPoint" );
           tolua_pushcppstring(  tolua_S,  (  const char* )boneName );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_Entity_attachObjectToBone00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: attachObjectToBone of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_attachObjectToBone02
    9972  static int tolua_Ogre_Ogre_Entity_attachObjectToBone02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::MovableObject",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string boneName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           Ogre::MovableObject* pMovable = (  (  Ogre::MovableObject* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Quaternion* offsetOrientation = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const Ogre::Vector3* offsetPosition = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  5,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'attachObjectToBone'",  NULL );
          #endif
           {
           Ogre::TagPoint* tolua_ret = (  Ogre::TagPoint* ) self->attachObjectToBone(  boneName,  pMovable,  *offsetOrientation,  *offsetPosition );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::TagPoint" );
           tolua_pushcppstring(  tolua_S,  (  const char* )boneName );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_Entity_attachObjectToBone01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: detachObjectFromBone of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_detachObjectFromBone00
   10008  static int tolua_Ogre_Ogre_Entity_detachObjectFromBone00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string movableName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'detachObjectFromBone'",  NULL );
          #endif
           {
           Ogre::MovableObject* tolua_ret = (  Ogre::MovableObject* ) self->detachObjectFromBone(  movableName );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::MovableObject" );
           tolua_pushcppstring(  tolua_S,  (  const char* )movableName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'detachObjectFromBone'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: detachObjectFromBone of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_detachObjectFromBone01
   10043  static int tolua_Ogre_Ogre_Entity_detachObjectFromBone01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::MovableObject",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::MovableObject* obj = (  (  Ogre::MovableObject* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'detachObjectFromBone'",  NULL );
          #endif
           {
           self->detachObjectFromBone(  obj );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Entity_detachObjectFromBone00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: detachAllObjectsFromBone of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_detachAllObjectsFromBone00
   10071  static int tolua_Ogre_Ogre_Entity_detachAllObjectsFromBone00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'detachAllObjectsFromBone'",  NULL );
          #endif
           {
           self->detachAllObjectsFromBone(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'detachAllObjectsFromBone'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttachedObjectIterator of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getAttachedObjectIterator00
   10102  static int tolua_Ogre_Ogre_Entity_getAttachedObjectIterator00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttachedObjectIterator'",  NULL );
          #endif
           {
           Ogre::MapIterator<Ogre::Entity::ChildObjectList> tolua_ret = (   Ogre::MapIterator<Ogre::Entity::ChildObjectList> ) self->getAttachedObjectIterator(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::MapIterator<Ogre::Entity::ChildObjectList>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MapIterator<Ogre::Entity::ChildObjectList>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::MapIterator<Ogre::Entity::ChildObjectList> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::MapIterator<Ogre::Entity::ChildObjectList>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttachedObjectIterator'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBoundingRadius of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getBoundingRadius00
   10142  static int tolua_Ogre_Ogre_Entity_getBoundingRadius00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBoundingRadius'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getBoundingRadius(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBoundingRadius'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWorldBoundingBox of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getWorldBoundingBox00
   10174  static int tolua_Ogre_Ogre_Entity_getWorldBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool derive = (  (  bool ) tolua_toboolean(  tolua_S,  2,  false ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWorldBoundingBox'",  NULL );
          #endif
           {
           const Ogre::AxisAlignedBox& tolua_ret = (  const Ogre::AxisAlignedBox& ) self->getWorldBoundingBox(  derive );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWorldBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWorldBoundingSphere of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getWorldBoundingSphere00
   10208  static int tolua_Ogre_Ogre_Entity_getWorldBoundingSphere00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool derive = (  (  bool ) tolua_toboolean(  tolua_S,  2,  false ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWorldBoundingSphere'",  NULL );
          #endif
           {
           const Ogre::Sphere& tolua_ret = (  const Ogre::Sphere& ) self->getWorldBoundingSphere(  derive );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Sphere" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWorldBoundingSphere'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setNormaliseNormals of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_setNormaliseNormals00
   10242  static int tolua_Ogre_Ogre_Entity_setNormaliseNormals00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool normalise = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setNormaliseNormals'",  NULL );
          #endif
           {
           self->setNormaliseNormals(  normalise );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setNormaliseNormals'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNormaliseNormals of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getNormaliseNormals00
   10275  static int tolua_Ogre_Ogre_Entity_getNormaliseNormals00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNormaliseNormals'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getNormaliseNormals(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNormaliseNormals'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasSkeleton of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_hasSkeleton00
   10307  static int tolua_Ogre_Ogre_Entity_hasSkeleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasSkeleton'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasSkeleton(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasSkeleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSkeleton of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getSkeleton00
   10339  static int tolua_Ogre_Ogre_Entity_getSkeleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSkeleton'",  NULL );
          #endif
           {
           Ogre::SkeletonInstance* tolua_ret = (  Ogre::SkeletonInstance* ) self->getSkeleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SkeletonInstance" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSkeleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isHardwareAnimationEnabled of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_isHardwareAnimationEnabled00
   10371  static int tolua_Ogre_Ogre_Entity_isHardwareAnimationEnabled00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isHardwareAnimationEnabled'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isHardwareAnimationEnabled(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isHardwareAnimationEnabled'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSoftwareAnimationRequests of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getSoftwareAnimationRequests00
   10403  static int tolua_Ogre_Ogre_Entity_getSoftwareAnimationRequests00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSoftwareAnimationRequests'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->getSoftwareAnimationRequests(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSoftwareAnimationRequests'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSoftwareAnimationNormalsRequests of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getSoftwareAnimationNormalsRequests00
   10435  static int tolua_Ogre_Ogre_Entity_getSoftwareAnimationNormalsRequests00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSoftwareAnimationNormalsRequests'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->getSoftwareAnimationNormalsRequests(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSoftwareAnimationNormalsRequests'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addSoftwareAnimationRequest of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_addSoftwareAnimationRequest00
   10467  static int tolua_Ogre_Ogre_Entity_addSoftwareAnimationRequest00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool normalsAlso = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addSoftwareAnimationRequest'",  NULL );
          #endif
           {
           self->addSoftwareAnimationRequest(  normalsAlso );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addSoftwareAnimationRequest'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeSoftwareAnimationRequest of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_removeSoftwareAnimationRequest00
   10500  static int tolua_Ogre_Ogre_Entity_removeSoftwareAnimationRequest00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool normalsAlso = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeSoftwareAnimationRequest'",  NULL );
          #endif
           {
           self->removeSoftwareAnimationRequest(  normalsAlso );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeSoftwareAnimationRequest'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: shareSkeletonInstanceWith of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_shareSkeletonInstanceWith00
   10533  static int tolua_Ogre_Ogre_Entity_shareSkeletonInstanceWith00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Entity* entity = (  (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'shareSkeletonInstanceWith'",  NULL );
          #endif
           {
           self->shareSkeletonInstanceWith(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'shareSkeletonInstanceWith'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasVertexAnimation of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_hasVertexAnimation00
   10566  static int tolua_Ogre_Ogre_Entity_hasVertexAnimation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasVertexAnimation'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasVertexAnimation(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasVertexAnimation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: stopSharingSkeletonInstance of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_stopSharingSkeletonInstance00
   10598  static int tolua_Ogre_Ogre_Entity_stopSharingSkeletonInstance00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'stopSharingSkeletonInstance'",  NULL );
          #endif
           {
           self->stopSharingSkeletonInstance(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'stopSharingSkeletonInstance'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: sharesSkeletonInstance of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_sharesSkeletonInstance00
   10629  static int tolua_Ogre_Ogre_Entity_sharesSkeletonInstance00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'sharesSkeletonInstance'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->sharesSkeletonInstance(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'sharesSkeletonInstance'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSkeletonInstanceSharingSet of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getSkeletonInstanceSharingSet00
   10661  static int tolua_Ogre_Ogre_Entity_getSkeletonInstanceSharingSet00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSkeletonInstanceSharingSet'",  NULL );
          #endif
           {
           const std::set<Ogre::Entity*>* tolua_ret = (   const std::set<Ogre::Entity*>* ) self->getSkeletonInstanceSharingSet(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "const std::set<Ogre::Entity*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSkeletonInstanceSharingSet'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: refreshAvailableAnimationState of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_refreshAvailableAnimationState00
   10693  static int tolua_Ogre_Ogre_Entity_refreshAvailableAnimationState00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'refreshAvailableAnimationState'",  NULL );
          #endif
           {
           self->refreshAvailableAnimationState(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'refreshAvailableAnimationState'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _updateAnimation of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity__updateAnimation00
   10724  static int tolua_Ogre_Ogre_Entity__updateAnimation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_updateAnimation'",  NULL );
          #endif
           {
           self->_updateAnimation(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_updateAnimation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _isAnimated of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity__isAnimated00
   10755  static int tolua_Ogre_Ogre_Entity__isAnimated00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_isAnimated'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->_isAnimated(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_isAnimated'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _isSkeletonAnimated of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity__isSkeletonAnimated00
   10787  static int tolua_Ogre_Ogre_Entity__isSkeletonAnimated00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_isSkeletonAnimated'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->_isSkeletonAnimated(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_isSkeletonAnimated'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getTypeFlags of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_getTypeFlags00
   10819  static int tolua_Ogre_Ogre_Entity_getTypeFlags00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getTypeFlags'",  NULL );
          #endif
           {
           long tolua_ret = (  long ) self->getTypeFlags(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getTypeFlags'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: chooseVertexDataForBinding of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity_chooseVertexDataForBinding00
   10851  static int tolua_Ogre_Ogre_Entity_chooseVertexDataForBinding00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool hasVertexAnim = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'chooseVertexDataForBinding'",  NULL );
          #endif
           {
           Ogre::Entity::VertexDataBindChoice tolua_ret = (  Ogre::Entity::VertexDataBindChoice ) self->chooseVertexDataForBinding(  hasVertexAnim );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'chooseVertexDataForBinding'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _getBuffersMarkedForAnimation of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity__getBuffersMarkedForAnimation00
   10885  static int tolua_Ogre_Ogre_Entity__getBuffersMarkedForAnimation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Entity* self = (  const Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_getBuffersMarkedForAnimation'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->_getBuffersMarkedForAnimation(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_getBuffersMarkedForAnimation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _markBuffersUsedForAnimation of class Ogre::Entity */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Entity__markBuffersUsedForAnimation00
   10917  static int tolua_Ogre_Ogre_Entity__markBuffersUsedForAnimation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Entity* self = (  Ogre::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_markBuffersUsedForAnimation'",  NULL );
          #endif
           {
           self->_markBuffersUsedForAnimation(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_markBuffersUsedForAnimation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getName00
   10948  static int tolua_Ogre_Ogre_Node_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getParent of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getParent00
   10980  static int tolua_Ogre_Ogre_Node_getParent00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getParent'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->getParent(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getParent'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getOrientation of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getOrientation00
   11012  static int tolua_Ogre_Ogre_Node_getOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getOrientation'",  NULL );
          #endif
           {
           const Ogre::Quaternion& tolua_ret = (  const Ogre::Quaternion& ) self->getOrientation(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setOrientation of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_setOrientation00
   11044  static int tolua_Ogre_Ogre_Node_setOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* q = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setOrientation'",  NULL );
          #endif
           {
           self->setOrientation(  *q );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setOrientation of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_setOrientation01
   11077  static int tolua_Ogre_Ogre_Node_setOrientation01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           float w = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setOrientation'",  NULL );
          #endif
           {
           self->setOrientation(  w,  x,  y,  z );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_setOrientation00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: resetOrientation of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_resetOrientation00
   11111  static int tolua_Ogre_Ogre_Node_resetOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'resetOrientation'",  NULL );
          #endif
           {
           self->resetOrientation(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'resetOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setPosition of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_setPosition00
   11142  static int tolua_Ogre_Ogre_Node_setPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* pos = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setPosition'",  NULL );
          #endif
           {
           self->setPosition(  *pos );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setPosition of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_setPosition01
   11175  static int tolua_Ogre_Ogre_Node_setPosition01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setPosition'",  NULL );
          #endif
           {
           self->setPosition(  x,  y,  z );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_setPosition00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPosition of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getPosition00
   11207  static int tolua_Ogre_Ogre_Node_getPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPosition'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getPosition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setScale of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_setScale00
   11239  static int tolua_Ogre_Ogre_Node_setScale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* scale = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setScale'",  NULL );
          #endif
           {
           self->setScale(  *scale );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setScale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setScale of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_setScale01
   11272  static int tolua_Ogre_Ogre_Node_setScale01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setScale'",  NULL );
          #endif
           {
           self->setScale(  x,  y,  z );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_setScale00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getScale of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getScale00
   11304  static int tolua_Ogre_Ogre_Node_getScale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getScale'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getScale(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getScale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setInheritOrientation of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_setInheritOrientation00
   11336  static int tolua_Ogre_Ogre_Node_setInheritOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool inherit = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setInheritOrientation'",  NULL );
          #endif
           {
           self->setInheritOrientation(  inherit );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setInheritOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getInheritOrientation of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getInheritOrientation00
   11369  static int tolua_Ogre_Ogre_Node_getInheritOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getInheritOrientation'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getInheritOrientation(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInheritOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setInheritScale of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_setInheritScale00
   11401  static int tolua_Ogre_Ogre_Node_setInheritScale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool inherit = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setInheritScale'",  NULL );
          #endif
           {
           self->setInheritScale(  inherit );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setInheritScale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getInheritScale of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getInheritScale00
   11434  static int tolua_Ogre_Ogre_Node_getInheritScale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getInheritScale'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getInheritScale(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInheritScale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: scale of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_scale00
   11466  static int tolua_Ogre_Ogre_Node_scale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* scale = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'scale'",  NULL );
          #endif
           {
           self->scale(  *scale );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'scale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: scale of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_scale01
   11499  static int tolua_Ogre_Ogre_Node_scale01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'scale'",  NULL );
          #endif
           {
           self->scale(  x,  y,  z );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_scale00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: translate of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_translate00
   11531  static int tolua_Ogre_Ogre_Node_translate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* d = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  Ogre::Node::TS_PARENT ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'translate'",  NULL );
          #endif
           {
           self->translate(  *d,  relativeTo );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'translate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: translate of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_translate01
   11566  static int tolua_Ogre_Ogre_Node_translate01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  5,  Ogre::Node::TS_PARENT ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'translate'",  NULL );
          #endif
           {
           self->translate(  x,  y,  z,  relativeTo );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_translate00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: translate of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_translate02
   11600  static int tolua_Ogre_Ogre_Node_translate02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Matrix3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  6,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Matrix3* axes = (  (  const Ogre::Matrix3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  6,  Ogre::Node::TS_PARENT ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'translate'",  NULL );
          #endif
           {
           self->translate(  *axes,  x,  y,  z,  relativeTo );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_translate01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: roll of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_roll00
   11636  static int tolua_Ogre_Ogre_Node_roll00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* angle = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  Ogre::Node::TS_LOCAL ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'roll'",  NULL );
          #endif
           {
           self->roll(  *angle,  relativeTo );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'roll'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: pitch of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_pitch00
   11671  static int tolua_Ogre_Ogre_Node_pitch00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* angle = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  Ogre::Node::TS_LOCAL ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'pitch'",  NULL );
          #endif
           {
           self->pitch(  *angle,  relativeTo );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'pitch'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: yaw of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_yaw00
   11706  static int tolua_Ogre_Ogre_Node_yaw00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* angle = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  Ogre::Node::TS_LOCAL ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'yaw'",  NULL );
          #endif
           {
           self->yaw(  *angle,  relativeTo );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'yaw'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: rotate of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_rotate00
   11741  static int tolua_Ogre_Ogre_Node_rotate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* axis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Radian* angle = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  4,  Ogre::Node::TS_LOCAL ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'rotate'",  NULL );
          #endif
           {
           self->rotate(  *axis,  *angle,  relativeTo );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'rotate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: rotate of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_rotate01
   11778  static int tolua_Ogre_Ogre_Node_rotate01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Quaternion* q = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  Ogre::Node::TS_LOCAL ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'rotate'",  NULL );
          #endif
           {
           self->rotate(  *q,  relativeTo );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_rotate00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getLocalAxes of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getLocalAxes00
   11808  static int tolua_Ogre_Ogre_Node_getLocalAxes00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getLocalAxes'",  NULL );
          #endif
           {
           Ogre::Matrix3 tolua_ret = (  Ogre::Matrix3 ) self->getLocalAxes(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Matrix3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Matrix3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Matrix3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Matrix3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getLocalAxes'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_createChild00
   11848  static int tolua_Ogre_Ogre_Node_createChild00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->createChild(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createChild'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_createChild01
   11880  static int tolua_Ogre_Ogre_Node_createChild01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* translate = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->createChild(  *translate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_createChild00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_createChild02
   11909  static int tolua_Ogre_Ogre_Node_createChild02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* translate = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Quaternion* rotate = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->createChild(  *translate,  *rotate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_createChild01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_createChild03
   11940  static int tolua_Ogre_Ogre_Node_createChild03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->createChild(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_createChild02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_createChild04
   11970  static int tolua_Ogre_Ogre_Node_createChild04(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* translate = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->createChild(  name,  *translate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_createChild03(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_createChild05
   12002  static int tolua_Ogre_Ogre_Node_createChild05(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* translate = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Quaternion* rotate = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->createChild(  name,  *translate,  *rotate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_createChild04(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_addChild00
   12036  static int tolua_Ogre_Ogre_Node_addChild00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Node* child = (  (  Ogre::Node* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addChild'",  NULL );
          #endif
           {
           self->addChild(  child );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addChild'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: numChildren of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_numChildren00
   12069  static int tolua_Ogre_Ogre_Node_numChildren00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'numChildren'",  NULL );
          #endif
           {
           unsigned short tolua_ret = (  unsigned short ) self->numChildren(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'numChildren'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getChildByIndex00
   12101  static int tolua_Ogre_Ogre_Node_getChildByIndex00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned short index = (  (  unsigned short ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->getChild(  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getChildByIndex'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getChild00
   12135  static int tolua_Ogre_Ogre_Node_getChild00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->getChild(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getChild'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_removeChild00
   12170  static int tolua_Ogre_Ogre_Node_removeChild00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned short index = (  (  unsigned short ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->removeChild(  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeChild'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_removeChild01
   12204  static int tolua_Ogre_Ogre_Node_removeChild01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Node* child = (  (  Ogre::Node* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->removeChild(  child );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_removeChild00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeChild of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_removeChild02
   12233  static int tolua_Ogre_Ogre_Node_removeChild02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeChild'",  NULL );
          #endif
           {
           Ogre::Node* tolua_ret = (  Ogre::Node* ) self->removeChild(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Node" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_Node_removeChild01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeAllChildren of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_removeAllChildren00
   12263  static int tolua_Ogre_Ogre_Node_removeAllChildren00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeAllChildren'",  NULL );
          #endif
           {
           self->removeAllChildren(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeAllChildren'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _getDerivedOrientation of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node__getDerivedOrientation00
   12294  static int tolua_Ogre_Ogre_Node__getDerivedOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_getDerivedOrientation'",  NULL );
          #endif
           {
           const Ogre::Quaternion& tolua_ret = (  const Ogre::Quaternion& ) self->_getDerivedOrientation(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_getDerivedOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _getDerivedPosition of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node__getDerivedPosition00
   12326  static int tolua_Ogre_Ogre_Node__getDerivedPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_getDerivedPosition'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->_getDerivedPosition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_getDerivedPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _getDerivedScale of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node__getDerivedScale00
   12358  static int tolua_Ogre_Ogre_Node__getDerivedScale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_getDerivedScale'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->_getDerivedScale(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_getDerivedScale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _getFullTransform of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node__getFullTransform00
   12390  static int tolua_Ogre_Ogre_Node__getFullTransform00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_getFullTransform'",  NULL );
          #endif
           {
           const Ogre::Matrix4& tolua_ret = (  const Ogre::Matrix4& ) self->_getFullTransform(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Matrix4" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_getFullTransform'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _update of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node__update00
   12422  static int tolua_Ogre_Ogre_Node__update00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool updateChildren = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
           bool parentHasChanged = (  (  bool ) tolua_toboolean(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_update'",  NULL );
          #endif
           {
           self->_update(  updateChildren,  parentHasChanged );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_update'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMaterial of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getMaterial00
   12457  static int tolua_Ogre_Ogre_Node_getMaterial00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMaterial'",  NULL );
          #endif
           {
           const Ogre::MaterialPtr& tolua_ret = (  const Ogre::MaterialPtr& ) self->getMaterial(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::MaterialPtr" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMaterial'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWorldTransforms of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getWorldTransforms00
   12489  static int tolua_Ogre_Ogre_Node_getWorldTransforms00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Matrix4",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Matrix4* xform = (  (  Ogre::Matrix4* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWorldTransforms'",  NULL );
          #endif
           {
           self->getWorldTransforms(  xform );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWorldTransforms'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWorldOrientation of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getWorldOrientation00
   12522  static int tolua_Ogre_Ogre_Node_getWorldOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWorldOrientation'",  NULL );
          #endif
           {
           const Ogre::Quaternion& tolua_ret = (  const Ogre::Quaternion& ) self->getWorldOrientation(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWorldOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWorldPosition of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getWorldPosition00
   12554  static int tolua_Ogre_Ogre_Node_getWorldPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWorldPosition'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getWorldPosition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWorldPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setInitialState of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_setInitialState00
   12586  static int tolua_Ogre_Ogre_Node_setInitialState00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setInitialState'",  NULL );
          #endif
           {
           self->setInitialState(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setInitialState'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: resetToInitialState of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_resetToInitialState00
   12617  static int tolua_Ogre_Ogre_Node_resetToInitialState00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'resetToInitialState'",  NULL );
          #endif
           {
           self->resetToInitialState(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'resetToInitialState'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getInitialPosition of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getInitialPosition00
   12648  static int tolua_Ogre_Ogre_Node_getInitialPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getInitialPosition'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getInitialPosition(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInitialPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getInitialOrientation of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getInitialOrientation00
   12680  static int tolua_Ogre_Ogre_Node_getInitialOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getInitialOrientation'",  NULL );
          #endif
           {
           const Ogre::Quaternion& tolua_ret = (  const Ogre::Quaternion& ) self->getInitialOrientation(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInitialOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getInitialScale of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getInitialScale00
   12712  static int tolua_Ogre_Ogre_Node_getInitialScale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getInitialScale'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getInitialScale(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInitialScale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSquaredViewDepth of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_getSquaredViewDepth00
   12744  static int tolua_Ogre_Ogre_Node_getSquaredViewDepth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Camera",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Node* self = (  const Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Camera* cam = (  (  const Ogre::Camera* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSquaredViewDepth'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getSquaredViewDepth(  cam );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSquaredViewDepth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: needUpdate of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_needUpdate00
   12778  static int tolua_Ogre_Ogre_Node_needUpdate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool forceParentUpdate = (  (  bool ) tolua_toboolean(  tolua_S,  2,  false ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'needUpdate'",  NULL );
          #endif
           {
           self->needUpdate(  forceParentUpdate );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'needUpdate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: requestUpdate of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_requestUpdate00
   12811  static int tolua_Ogre_Ogre_Node_requestUpdate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Node* child = (  (  Ogre::Node* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           bool forceParentUpdate = (  (  bool ) tolua_toboolean(  tolua_S,  3,  false ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'requestUpdate'",  NULL );
          #endif
           {
           self->requestUpdate(  child,  forceParentUpdate );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'requestUpdate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: cancelUpdate of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_cancelUpdate00
   12846  static int tolua_Ogre_Ogre_Node_cancelUpdate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* self = (  Ogre::Node* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::Node* child = (  (  Ogre::Node* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'cancelUpdate'",  NULL );
          #endif
           {
           self->cancelUpdate(  child );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'cancelUpdate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: queueNeedUpdate of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_queueNeedUpdate00
   12879  static int tolua_Ogre_Ogre_Node_queueNeedUpdate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Node* n = (  (  Ogre::Node* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::Node::queueNeedUpdate(  n );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'queueNeedUpdate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: processQueuedUpdates of class Ogre::Node */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Node_processQueuedUpdates00
   12908  static int tolua_Ogre_Ogre_Node_processQueuedUpdates00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Node",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::Node::processQueuedUpdates(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'processQueuedUpdates'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: attachObject of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_attachObject00
   12935  static int tolua_Ogre_Ogre_SceneNode_attachObject00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::MovableObject",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::MovableObject* obj = (  (  Ogre::MovableObject* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'attachObject'",  NULL );
          #endif
           {
           self->attachObject(  obj );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'attachObject'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: numAttachedObjects of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_numAttachedObjects00
   12968  static int tolua_Ogre_Ogre_SceneNode_numAttachedObjects00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SceneNode* self = (  const Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'numAttachedObjects'",  NULL );
          #endif
           {
           unsigned short tolua_ret = (  unsigned short ) self->numAttachedObjects(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'numAttachedObjects'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttachedObject of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_getAttachedObject00
   13000  static int tolua_Ogre_Ogre_SceneNode_getAttachedObject00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned short index = (  (  unsigned short ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttachedObject'",  NULL );
          #endif
           {
           Ogre::MovableObject* tolua_ret = (  Ogre::MovableObject* ) self->getAttachedObject(  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::MovableObject" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttachedObject'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttachedObject of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_getAttachedObject01
   13034  static int tolua_Ogre_Ogre_SceneNode_getAttachedObject01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttachedObject'",  NULL );
          #endif
           {
           Ogre::MovableObject* tolua_ret = (  Ogre::MovableObject* ) self->getAttachedObject(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::MovableObject" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_getAttachedObject00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: detachObject of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_detachObject00
   13064  static int tolua_Ogre_Ogre_SceneNode_detachObject00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned short index = (  (  unsigned short ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'detachObject'",  NULL );
          #endif
           {
           Ogre::MovableObject* tolua_ret = (  Ogre::MovableObject* ) self->detachObject(  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::MovableObject" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'detachObject'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: detachObject of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_detachObject01
   13098  static int tolua_Ogre_Ogre_SceneNode_detachObject01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::MovableObject",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::MovableObject* obj = (  (  Ogre::MovableObject* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'detachObject'",  NULL );
          #endif
           {
           self->detachObject(  obj );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_detachObject00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: detachObject of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_detachObject02
   13126  static int tolua_Ogre_Ogre_SceneNode_detachObject02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'detachObject'",  NULL );
          #endif
           {
           Ogre::MovableObject* tolua_ret = (  Ogre::MovableObject* ) self->detachObject(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::MovableObject" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_detachObject01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: detachAllObjects of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_detachAllObjects00
   13156  static int tolua_Ogre_Ogre_SceneNode_detachAllObjects00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'detachAllObjects'",  NULL );
          #endif
           {
           self->detachAllObjects(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'detachAllObjects'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isInSceneGraph of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_isInSceneGraph00
   13187  static int tolua_Ogre_Ogre_SceneNode_isInSceneGraph00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SceneNode* self = (  const Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isInSceneGraph'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isInSceneGraph(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isInSceneGraph'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _notifyRootNode of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode__notifyRootNode00
   13219  static int tolua_Ogre_Ogre_SceneNode__notifyRootNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_notifyRootNode'",  NULL );
          #endif
           {
           self->_notifyRootNode(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_notifyRootNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _update of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode__update00
   13250  static int tolua_Ogre_Ogre_SceneNode__update00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool updateChildren = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
           bool parentHasChanged = (  (  bool ) tolua_toboolean(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_update'",  NULL );
          #endif
           {
           self->_update(  updateChildren,  parentHasChanged );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_update'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _updateBounds of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode__updateBounds00
   13285  static int tolua_Ogre_Ogre_SceneNode__updateBounds00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_updateBounds'",  NULL );
          #endif
           {
           self->_updateBounds(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_updateBounds'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: _getWorldAABB of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode__getWorldAABB00
   13316  static int tolua_Ogre_Ogre_SceneNode__getWorldAABB00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SceneNode* self = (  const Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '_getWorldAABB'",  NULL );
          #endif
           {
           const Ogre::AxisAlignedBox& tolua_ret = (  const Ogre::AxisAlignedBox& ) self->_getWorldAABB(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '_getWorldAABB'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCreator of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_getCreator00
   13348  static int tolua_Ogre_Ogre_SceneNode_getCreator00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SceneNode* self = (  const Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCreator'",  NULL );
          #endif
           {
           Ogre::SceneManager* tolua_ret = (  Ogre::SceneManager* ) self->getCreator(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCreator'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeAndDestroyChild of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_removeAndDestroyChild00
   13380  static int tolua_Ogre_Ogre_SceneNode_removeAndDestroyChild00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeAndDestroyChild'",  NULL );
          #endif
           {
           self->removeAndDestroyChild(  name );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeAndDestroyChild'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeAndDestroyChild of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_removeAndDestroyChild01
   13414  static int tolua_Ogre_Ogre_SceneNode_removeAndDestroyChild01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned short index = (  (  unsigned short ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeAndDestroyChild'",  NULL );
          #endif
           {
           self->removeAndDestroyChild(  index );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_removeAndDestroyChild00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeAndDestroyAllChildren of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_removeAndDestroyAllChildren00
   13442  static int tolua_Ogre_Ogre_SceneNode_removeAndDestroyAllChildren00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeAndDestroyAllChildren'",  NULL );
          #endif
           {
           self->removeAndDestroyAllChildren(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeAndDestroyAllChildren'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showBoundingBox of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_showBoundingBox00
   13473  static int tolua_Ogre_Ogre_SceneNode_showBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool bShow = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showBoundingBox'",  NULL );
          #endif
           {
           self->showBoundingBox(  bShow );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getShowBoundingBox of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_getShowBoundingBox00
   13506  static int tolua_Ogre_Ogre_SceneNode_getShowBoundingBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SceneNode* self = (  const Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getShowBoundingBox'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getShowBoundingBox(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getShowBoundingBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChildSceneNode of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_createChildSceneNode00
   13538  static int tolua_Ogre_Ogre_SceneNode_createChildSceneNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChildSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->createChildSceneNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createChildSceneNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChildSceneNode of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_createChildSceneNode01
   13570  static int tolua_Ogre_Ogre_SceneNode_createChildSceneNode01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* translate = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChildSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->createChildSceneNode(  *translate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_createChildSceneNode00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChildSceneNode of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_createChildSceneNode02
   13599  static int tolua_Ogre_Ogre_SceneNode_createChildSceneNode02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* translate = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Quaternion* rotate = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChildSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->createChildSceneNode(  *translate,  *rotate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_createChildSceneNode01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChildSceneNode of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_createChildSceneNode03
   13630  static int tolua_Ogre_Ogre_SceneNode_createChildSceneNode03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChildSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->createChildSceneNode(  name );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_createChildSceneNode02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChildSceneNode of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_createChildSceneNode04
   13660  static int tolua_Ogre_Ogre_SceneNode_createChildSceneNode04(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* translate = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChildSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->createChildSceneNode(  name,  *translate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_createChildSceneNode03(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createChildSceneNode of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_createChildSceneNode05
   13692  static int tolua_Ogre_Ogre_SceneNode_createChildSceneNode05(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* translate = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Quaternion* rotate = (  (  const Ogre::Quaternion* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createChildSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->createChildSceneNode(  name,  *translate,  *rotate );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_createChildSceneNode04(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setFixedYawAxis of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setFixedYawAxis00
   13726  static int tolua_Ogre_Ogre_SceneNode_setFixedYawAxis00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool useFixed = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setFixedYawAxis'",  NULL );
          #endif
           {
           self->setFixedYawAxis(  useFixed );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setFixedYawAxis'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setFixedYawAxis of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setFixedYawAxis01
   13759  static int tolua_Ogre_Ogre_SceneNode_setFixedYawAxis01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool useFixed = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* fixedAxis = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setFixedYawAxis'",  NULL );
          #endif
           {
           self->setFixedYawAxis(  useFixed,  *fixedAxis );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_setFixedYawAxis00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: yaw of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_yaw00
   13789  static int tolua_Ogre_Ogre_SceneNode_yaw00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Radian",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Radian* angle = (  (  const Ogre::Radian* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  Ogre::Node::TS_LOCAL ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'yaw'",  NULL );
          #endif
           {
           self->yaw(  *angle,  relativeTo );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'yaw'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDirection of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setDirection00
   13824  static int tolua_Ogre_Ogre_SceneNode_setDirection00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  5,  Ogre::Node::TS_LOCAL ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDirection'",  NULL );
          #endif
           {
           self->setDirection(  x,  y,  z,  relativeTo );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setDirection'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDirection of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setDirection01
   13863  static int tolua_Ogre_Ogre_SceneNode_setDirection01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  5,  0 ) );
           const Ogre::Vector3* localDirectionVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  6,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDirection'",  NULL );
          #endif
           {
           self->setDirection(  x,  y,  z,  relativeTo,  *localDirectionVector );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_setDirection00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDirection of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setDirection02
   13899  static int tolua_Ogre_Ogre_SceneNode_setDirection02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* vec = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  Ogre::Node::TS_LOCAL ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDirection'",  NULL );
          #endif
           {
           self->setDirection(  *vec,  relativeTo );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_setDirection01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDirection of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setDirection03
   13929  static int tolua_Ogre_Ogre_SceneNode_setDirection03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* vec = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* localDirectionVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDirection'",  NULL );
          #endif
           {
           self->setDirection(  *vec,  relativeTo,  *localDirectionVector );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_setDirection02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: lookAt of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_lookAt00
   13961  static int tolua_Ogre_Ogre_SceneNode_lookAt00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* targetPoint = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'lookAt'",  NULL );
          #endif
           {
           self->lookAt(  *targetPoint,  relativeTo );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'lookAt'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: lookAt of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_lookAt01
   13996  static int tolua_Ogre_Ogre_SceneNode_lookAt01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* targetPoint = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Ogre::Node::TransformSpace relativeTo = (  (  Ogre::Node::TransformSpace ) (  int ) tolua_tonumber(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* localDirectionVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'lookAt'",  NULL );
          #endif
           {
           self->lookAt(  *targetPoint,  relativeTo,  *localDirectionVector );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_lookAt00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAutoTracking of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setAutoTracking00
   14028  static int tolua_Ogre_Ogre_SceneNode_setAutoTracking00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::SceneNode",  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool enabled = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
           Ogre::SceneNode* target = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAutoTracking'",  NULL );
          #endif
           {
           self->setAutoTracking(  enabled,  target );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAutoTracking'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAutoTracking of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setAutoTracking01
   14063  static int tolua_Ogre_Ogre_SceneNode_setAutoTracking01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool enabled = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
           Ogre::SceneNode* target = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* localDirectionVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAutoTracking'",  NULL );
          #endif
           {
           self->setAutoTracking(  enabled,  target,  *localDirectionVector );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_setAutoTracking00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAutoTracking of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setAutoTracking02
   14095  static int tolua_Ogre_Ogre_SceneNode_setAutoTracking02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool enabled = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
           Ogre::SceneNode* target = (  (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           const Ogre::Vector3* localDirectionVector = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           const Ogre::Vector3* offset = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  5,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAutoTracking'",  NULL );
          #endif
           {
           self->setAutoTracking(  enabled,  target,  *localDirectionVector,  *offset );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_SceneNode_setAutoTracking01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAutoTrackTarget of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_getAutoTrackTarget00
   14129  static int tolua_Ogre_Ogre_SceneNode_getAutoTrackTarget00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAutoTrackTarget'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->getAutoTrackTarget(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAutoTrackTarget'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAutoTrackOffset of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_getAutoTrackOffset00
   14161  static int tolua_Ogre_Ogre_SceneNode_getAutoTrackOffset00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAutoTrackOffset'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getAutoTrackOffset(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAutoTrackOffset'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAutoTrackLocalDirection of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_getAutoTrackLocalDirection00
   14193  static int tolua_Ogre_Ogre_SceneNode_getAutoTrackLocalDirection00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAutoTrackLocalDirection'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getAutoTrackLocalDirection(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAutoTrackLocalDirection'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getParentSceneNode of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_getParentSceneNode00
   14225  static int tolua_Ogre_Ogre_SceneNode_getParentSceneNode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::SceneNode* self = (  const Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getParentSceneNode'",  NULL );
          #endif
           {
           Ogre::SceneNode* tolua_ret = (  Ogre::SceneNode* ) self->getParentSceneNode(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::SceneNode" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getParentSceneNode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setVisible of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_setVisible00
   14257  static int tolua_Ogre_Ogre_SceneNode_setVisible00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool visible = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
           bool cascade = (  (  bool ) tolua_toboolean(  tolua_S,  3,  true ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setVisible'",  NULL );
          #endif
           {
           self->setVisible(  visible,  cascade );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setVisible'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: flipVisibility of class Ogre::SceneNode */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_SceneNode_flipVisibility00
   14292  static int tolua_Ogre_Ogre_SceneNode_flipVisibility00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::SceneNode",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::SceneNode* self = (  Ogre::SceneNode* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool cascade = (  (  bool ) tolua_toboolean(  tolua_S,  2,  true ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'flipVisibility'",  NULL );
          #endif
           {
           self->flipVisibility(  cascade );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'flipVisibility'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: get of class Ogre::TexturePtr */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_TexturePtr_get00
   14325  static int tolua_Ogre_Ogre_TexturePtr_get00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::TexturePtr",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::TexturePtr* self = (  Ogre::TexturePtr* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'get'",  NULL );
          #endif
           {
           Ogre::Texture* tolua_ret = (  Ogre::Texture* ) self->get(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Texture" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'get'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setTextureType of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setTextureType00
   14357  static int tolua_Ogre_Ogre_Texture_setTextureType00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::TextureType ttype = (  (  Ogre::TextureType ) (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setTextureType'",  NULL );
          #endif
           {
           self->setTextureType(  ttype );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setTextureType'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getTextureType of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getTextureType00
   14390  static int tolua_Ogre_Ogre_Texture_getTextureType00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getTextureType'",  NULL );
          #endif
           {
           Ogre::TextureType tolua_ret = (  Ogre::TextureType ) self->getTextureType(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getTextureType'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNumMipmaps of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getNumMipmaps00
   14422  static int tolua_Ogre_Ogre_Texture_getNumMipmaps00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNumMipmaps'",  NULL );
          #endif
           {
           size_t tolua_ret = (  size_t ) self->getNumMipmaps(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new size_t(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  size_t ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNumMipmaps'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setNumMipmaps of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setNumMipmaps00
   14462  static int tolua_Ogre_Ogre_Texture_setNumMipmaps00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "size_t",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           size_t num = *(  (  size_t* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setNumMipmaps'",  NULL );
          #endif
           {
           self->setNumMipmaps(  num );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setNumMipmaps'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMipmapsHardwareGenerated of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getMipmapsHardwareGenerated00
   14495  static int tolua_Ogre_Ogre_Texture_getMipmapsHardwareGenerated00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMipmapsHardwareGenerated'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getMipmapsHardwareGenerated(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMipmapsHardwareGenerated'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getGamma of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getGamma00
   14527  static int tolua_Ogre_Ogre_Texture_getGamma00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getGamma'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getGamma(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getGamma'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setGamma of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setGamma00
   14559  static int tolua_Ogre_Ogre_Texture_setGamma00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           float g = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setGamma'",  NULL );
          #endif
           {
           self->setGamma(  g );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setGamma'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getHeight of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getHeight00
   14592  static int tolua_Ogre_Ogre_Texture_getHeight00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getHeight'",  NULL );
          #endif
           {
           size_t tolua_ret = (  size_t ) self->getHeight(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new size_t(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  size_t ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getHeight'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getWidth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getWidth00
   14632  static int tolua_Ogre_Ogre_Texture_getWidth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getWidth'",  NULL );
          #endif
           {
           size_t tolua_ret = (  size_t ) self->getWidth(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new size_t(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  size_t ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getWidth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDepth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getDepth00
   14672  static int tolua_Ogre_Ogre_Texture_getDepth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDepth'",  NULL );
          #endif
           {
           size_t tolua_ret = (  size_t ) self->getDepth(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new size_t(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  size_t ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDepth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSrcHeight of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getSrcHeight00
   14712  static int tolua_Ogre_Ogre_Texture_getSrcHeight00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSrcHeight'",  NULL );
          #endif
           {
           size_t tolua_ret = (  size_t ) self->getSrcHeight(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new size_t(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  size_t ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSrcHeight'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSrcWidth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getSrcWidth00
   14752  static int tolua_Ogre_Ogre_Texture_getSrcWidth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSrcWidth'",  NULL );
          #endif
           {
           size_t tolua_ret = (  size_t ) self->getSrcWidth(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new size_t(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  size_t ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSrcWidth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSrcDepth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getSrcDepth00
   14792  static int tolua_Ogre_Ogre_Texture_getSrcDepth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSrcDepth'",  NULL );
          #endif
           {
           size_t tolua_ret = (  size_t ) self->getSrcDepth(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new size_t(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  size_t ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSrcDepth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setHeight of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setHeight00
   14832  static int tolua_Ogre_Ogre_Texture_setHeight00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "size_t",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           size_t h = *(  (  size_t* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setHeight'",  NULL );
          #endif
           {
           self->setHeight(  h );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setHeight'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setWidth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setWidth00
   14865  static int tolua_Ogre_Ogre_Texture_setWidth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "size_t",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           size_t w = *(  (  size_t* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setWidth'",  NULL );
          #endif
           {
           self->setWidth(  w );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setWidth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDepth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setDepth00
   14898  static int tolua_Ogre_Ogre_Texture_setDepth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "size_t",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           size_t d = *(  (  size_t* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDepth'",  NULL );
          #endif
           {
           self->setDepth(  d );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setDepth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getUsage of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getUsage00
   14931  static int tolua_Ogre_Ogre_Texture_getUsage00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getUsage'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->getUsage(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getUsage'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setUsage of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setUsage00
   14963  static int tolua_Ogre_Ogre_Texture_setUsage00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           int u = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setUsage'",  NULL );
          #endif
           {
           self->setUsage(  u );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setUsage'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: copyToTexture of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_copyToTexture00
   14996  static int tolua_Ogre_Ogre_Texture_copyToTexture00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::TexturePtr",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::TexturePtr* target = (  (  Ogre::TexturePtr* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'copyToTexture'",  NULL );
          #endif
           {
           self->copyToTexture(  *target );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'copyToTexture'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: loadImage of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_loadImage00
   15029  static int tolua_Ogre_Ogre_Texture_loadImage00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Image",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Image* img = (  (  const Ogre::Image* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'loadImage'",  NULL );
          #endif
           {
           self->loadImage(  *img );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'loadImage'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasAlpha of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_hasAlpha00
   15062  static int tolua_Ogre_Ogre_Texture_hasAlpha00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasAlpha'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasAlpha(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasAlpha'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDesiredIntegerBitDepth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setDesiredIntegerBitDepth00
   15094  static int tolua_Ogre_Ogre_Texture_setDesiredIntegerBitDepth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned short bits = (  (  unsigned short ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDesiredIntegerBitDepth'",  NULL );
          #endif
           {
           self->setDesiredIntegerBitDepth(  bits );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setDesiredIntegerBitDepth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDesiredIntegerBitDepth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getDesiredIntegerBitDepth00
   15127  static int tolua_Ogre_Ogre_Texture_getDesiredIntegerBitDepth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDesiredIntegerBitDepth'",  NULL );
          #endif
           {
           unsigned short tolua_ret = (  unsigned short ) self->getDesiredIntegerBitDepth(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDesiredIntegerBitDepth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDesiredFloatBitDepth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setDesiredFloatBitDepth00
   15159  static int tolua_Ogre_Ogre_Texture_setDesiredFloatBitDepth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned short bits = (  (  unsigned short ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDesiredFloatBitDepth'",  NULL );
          #endif
           {
           self->setDesiredFloatBitDepth(  bits );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setDesiredFloatBitDepth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDesiredFloatBitDepth of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getDesiredFloatBitDepth00
   15192  static int tolua_Ogre_Ogre_Texture_getDesiredFloatBitDepth00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDesiredFloatBitDepth'",  NULL );
          #endif
           {
           unsigned short tolua_ret = (  unsigned short ) self->getDesiredFloatBitDepth(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDesiredFloatBitDepth'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDesiredBitDepths of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setDesiredBitDepths00
   15224  static int tolua_Ogre_Ogre_Texture_setDesiredBitDepths00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned short integerBits = (  (  unsigned short ) tolua_tonumber(  tolua_S,  2,  0 ) );
           unsigned short floatBits = (  (  unsigned short ) tolua_tonumber(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDesiredBitDepths'",  NULL );
          #endif
           {
           self->setDesiredBitDepths(  integerBits,  floatBits );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setDesiredBitDepths'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setTreatLuminanceAsAlpha of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_setTreatLuminanceAsAlpha00
   15259  static int tolua_Ogre_Ogre_Texture_setTreatLuminanceAsAlpha00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Texture* self = (  Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool asAlpha = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setTreatLuminanceAsAlpha'",  NULL );
          #endif
           {
           self->setTreatLuminanceAsAlpha(  asAlpha );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setTreatLuminanceAsAlpha'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getTreatLuminanceAsAlpha of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getTreatLuminanceAsAlpha00
   15292  static int tolua_Ogre_Ogre_Texture_getTreatLuminanceAsAlpha00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getTreatLuminanceAsAlpha'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getTreatLuminanceAsAlpha(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getTreatLuminanceAsAlpha'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNumFaces of class Ogre::Texture */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Texture_getNumFaces00
   15324  static int tolua_Ogre_Ogre_Texture_getNumFaces00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Texture",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Texture* self = (  const Ogre::Texture* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNumFaces'",  NULL );
          #endif
           {
           size_t tolua_ret = (  size_t ) self->getNumFaces(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new size_t(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  size_t ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNumFaces'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setDefaultNumMipmaps of class Ogre::TextureManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_TextureManager_setDefaultNumMipmaps00
   15364  static int tolua_Ogre_Ogre_TextureManager_setDefaultNumMipmaps00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::TextureManager",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "size_t",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::TextureManager* self = (  Ogre::TextureManager* ) tolua_tousertype(  tolua_S,  1,  0 );
           size_t num = *(  (  size_t* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setDefaultNumMipmaps'",  NULL );
          #endif
           {
           self->setDefaultNumMipmaps(  num );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setDefaultNumMipmaps'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getDefaultNumMipmaps of class Ogre::TextureManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_TextureManager_getDefaultNumMipmaps00
   15397  static int tolua_Ogre_Ogre_TextureManager_getDefaultNumMipmaps00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::TextureManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::TextureManager* self = (  Ogre::TextureManager* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getDefaultNumMipmaps'",  NULL );
          #endif
           {
           size_t tolua_ret = (  size_t ) self->getDefaultNumMipmaps(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new size_t(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  size_t ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "size_t" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getDefaultNumMipmaps'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class Ogre::TextureManager */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_TextureManager_getSingleton00
   15437  static int tolua_Ogre_Ogre_TextureManager_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::TextureManager",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::TextureManager& tolua_ret = (  Ogre::TextureManager& ) Ogre::TextureManager::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Ogre::TextureManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_new00
   15465  static int tolua_Ogre_Ogre_AxisAlignedBox_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::AxisAlignedBox* tolua_ret = (  Ogre::AxisAlignedBox* ) new Ogre::AxisAlignedBox(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_new00_local
   15493  static int tolua_Ogre_Ogre_AxisAlignedBox_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::AxisAlignedBox* tolua_ret = (  Ogre::AxisAlignedBox* ) new Ogre::AxisAlignedBox(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_new01
   15521  static int tolua_Ogre_Ogre_AxisAlignedBox_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::AxisAlignedBox* rkBox = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::AxisAlignedBox* tolua_ret = (  Ogre::AxisAlignedBox* ) new Ogre::AxisAlignedBox(  *rkBox );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_new01_local
   15546  static int tolua_Ogre_Ogre_AxisAlignedBox_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::AxisAlignedBox* rkBox = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Ogre::AxisAlignedBox* tolua_ret = (  Ogre::AxisAlignedBox* ) new Ogre::AxisAlignedBox(  *rkBox );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_new02
   15571  static int tolua_Ogre_Ogre_AxisAlignedBox_new02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Vector3* min = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* max = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           Ogre::AxisAlignedBox* tolua_ret = (  Ogre::AxisAlignedBox* ) new Ogre::AxisAlignedBox(  *min,  *max );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_new01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_new02_local
   15598  static int tolua_Ogre_Ogre_AxisAlignedBox_new02_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::Vector3* min = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* max = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           Ogre::AxisAlignedBox* tolua_ret = (  Ogre::AxisAlignedBox* ) new Ogre::AxisAlignedBox(  *min,  *max );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_new01_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_new03
   15625  static int tolua_Ogre_Ogre_AxisAlignedBox_new03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  6,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  7,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  8,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float mx = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float my = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float mz = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           float Mx = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
           float My = (  (  float ) tolua_tonumber(  tolua_S,  6,  0 ) );
           float Mz = (  (  float ) tolua_tonumber(  tolua_S,  7,  0 ) );
           {
           Ogre::AxisAlignedBox* tolua_ret = (  Ogre::AxisAlignedBox* ) new Ogre::AxisAlignedBox(  mx,  my,  mz,  Mx,  My,  Mz );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_new02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_new03_local
   15660  static int tolua_Ogre_Ogre_AxisAlignedBox_new03_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  6,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  7,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  8,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float mx = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float my = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float mz = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           float Mx = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
           float My = (  (  float ) tolua_tonumber(  tolua_S,  6,  0 ) );
           float Mz = (  (  float ) tolua_tonumber(  tolua_S,  7,  0 ) );
           {
           Ogre::AxisAlignedBox* tolua_ret = (  Ogre::AxisAlignedBox* ) new Ogre::AxisAlignedBox(  mx,  my,  mz,  Mx,  My,  Mz );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::AxisAlignedBox" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_new02_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_delete00
   15695  static int tolua_Ogre_Ogre_AxisAlignedBox_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMinimum of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_getMinimum00
   15724  static int tolua_Ogre_Ogre_AxisAlignedBox_getMinimum00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMinimum'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getMinimum(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMinimum'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMinimum of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_getMinimum01
   15756  static int tolua_Ogre_Ogre_AxisAlignedBox_getMinimum01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMinimum'",  NULL );
          #endif
           {
           Ogre::Vector3& tolua_ret = (  Ogre::Vector3& ) self->getMinimum(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Ogre::Vector3" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_getMinimum00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMaximum of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_getMaximum00
   15783  static int tolua_Ogre_Ogre_AxisAlignedBox_getMaximum00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMaximum'",  NULL );
          #endif
           {
           const Ogre::Vector3& tolua_ret = (  const Ogre::Vector3& ) self->getMaximum(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Ogre::Vector3" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMaximum'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMaximum of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_getMaximum01
   15815  static int tolua_Ogre_Ogre_AxisAlignedBox_getMaximum01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMaximum'",  NULL );
          #endif
           {
           Ogre::Vector3& tolua_ret = (  Ogre::Vector3& ) self->getMaximum(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Ogre::Vector3" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_getMaximum00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMinimum of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMinimum00
   15842  static int tolua_Ogre_Ogre_AxisAlignedBox_setMinimum00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* vec = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMinimum'",  NULL );
          #endif
           {
           self->setMinimum(  *vec );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMinimum'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMinimum of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMinimum01
   15875  static int tolua_Ogre_Ogre_AxisAlignedBox_setMinimum01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMinimum'",  NULL );
          #endif
           {
           self->setMinimum(  x,  y,  z );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_setMinimum00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMinimumX of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMinimumX00
   15907  static int tolua_Ogre_Ogre_AxisAlignedBox_setMinimumX00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMinimumX'",  NULL );
          #endif
           {
           self->setMinimumX(  x );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMinimumX'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMinimumY of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMinimumY00
   15940  static int tolua_Ogre_Ogre_AxisAlignedBox_setMinimumY00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMinimumY'",  NULL );
          #endif
           {
           self->setMinimumY(  y );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMinimumY'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMinimumZ of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMinimumZ00
   15973  static int tolua_Ogre_Ogre_AxisAlignedBox_setMinimumZ00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMinimumZ'",  NULL );
          #endif
           {
           self->setMinimumZ(  z );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMinimumZ'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaximum of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMaximum00
   16006  static int tolua_Ogre_Ogre_AxisAlignedBox_setMaximum00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* vec = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaximum'",  NULL );
          #endif
           {
           self->setMaximum(  *vec );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMaximum'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaximum of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMaximum01
   16039  static int tolua_Ogre_Ogre_AxisAlignedBox_setMaximum01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaximum'",  NULL );
          #endif
           {
           self->setMaximum(  x,  y,  z );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_setMaximum00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaximumX of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMaximumX00
   16071  static int tolua_Ogre_Ogre_AxisAlignedBox_setMaximumX00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           float x = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaximumX'",  NULL );
          #endif
           {
           self->setMaximumX(  x );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMaximumX'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaximumY of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMaximumY00
   16104  static int tolua_Ogre_Ogre_AxisAlignedBox_setMaximumY00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           float y = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaximumY'",  NULL );
          #endif
           {
           self->setMaximumY(  y );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMaximumY'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setMaximumZ of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setMaximumZ00
   16137  static int tolua_Ogre_Ogre_AxisAlignedBox_setMaximumZ00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           float z = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setMaximumZ'",  NULL );
          #endif
           {
           self->setMaximumZ(  z );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setMaximumZ'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setExtents of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setExtents00
   16170  static int tolua_Ogre_Ogre_AxisAlignedBox_setExtents00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* min = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const Ogre::Vector3* max = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setExtents'",  NULL );
          #endif
           {
           self->setExtents(  *min,  *max );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setExtents'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setExtents of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setExtents01
   16205  static int tolua_Ogre_Ogre_AxisAlignedBox_setExtents01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  6,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  7,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  8,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           float mx = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float my = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float mz = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
           float Mx = (  (  float ) tolua_tonumber(  tolua_S,  5,  0 ) );
           float My = (  (  float ) tolua_tonumber(  tolua_S,  6,  0 ) );
           float Mz = (  (  float ) tolua_tonumber(  tolua_S,  7,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setExtents'",  NULL );
          #endif
           {
           self->setExtents(  mx,  my,  mz,  Mx,  My,  Mz );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_setExtents00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCorner of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_getCorner00
   16243  static int tolua_Ogre_Ogre_AxisAlignedBox_getCorner00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::AxisAlignedBox::CornerEnum cornerToGet = (  (  Ogre::AxisAlignedBox::CornerEnum ) (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCorner'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->getCorner(  cornerToGet );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCorner'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: merge of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_merge00
   16285  static int tolua_Ogre_Ogre_AxisAlignedBox_merge00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::AxisAlignedBox* rhs = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'merge'",  NULL );
          #endif
           {
           self->merge(  *rhs );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'merge'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: merge of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_merge01
   16318  static int tolua_Ogre_Ogre_AxisAlignedBox_merge01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* point = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'merge'",  NULL );
          #endif
           {
           self->merge(  *point );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_merge00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: transform of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_transform00
   16346  static int tolua_Ogre_Ogre_AxisAlignedBox_transform00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Matrix4",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Matrix4* matrix = (  (  const Ogre::Matrix4* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'transform'",  NULL );
          #endif
           {
           self->transform(  *matrix );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'transform'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: transformAffine of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_transformAffine00
   16379  static int tolua_Ogre_Ogre_AxisAlignedBox_transformAffine00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Matrix4",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Matrix4* m = (  (  const Ogre::Matrix4* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'transformAffine'",  NULL );
          #endif
           {
           self->transformAffine(  *m );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'transformAffine'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setNull of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setNull00
   16412  static int tolua_Ogre_Ogre_AxisAlignedBox_setNull00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setNull'",  NULL );
          #endif
           {
           self->setNull(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setNull'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isNull of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_isNull00
   16443  static int tolua_Ogre_Ogre_AxisAlignedBox_isNull00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isNull'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isNull(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isNull'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isFinite of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_isFinite00
   16475  static int tolua_Ogre_Ogre_AxisAlignedBox_isFinite00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isFinite'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isFinite(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isFinite'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setInfinite of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_setInfinite00
   16507  static int tolua_Ogre_Ogre_AxisAlignedBox_setInfinite00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setInfinite'",  NULL );
          #endif
           {
           self->setInfinite(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setInfinite'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isInfinite of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_isInfinite00
   16538  static int tolua_Ogre_Ogre_AxisAlignedBox_isInfinite00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isInfinite'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isInfinite(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isInfinite'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_intersects00
   16570  static int tolua_Ogre_Ogre_AxisAlignedBox_intersects00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::AxisAlignedBox* b2 = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'intersects'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->intersects(  *b2 );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'intersects'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersection of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_intersection00
   16604  static int tolua_Ogre_Ogre_AxisAlignedBox_intersection00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::AxisAlignedBox* b2 = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'intersection'",  NULL );
          #endif
           {
           Ogre::AxisAlignedBox tolua_ret = (  Ogre::AxisAlignedBox ) self->intersection(  *b2 );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::AxisAlignedBox(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::AxisAlignedBox" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::AxisAlignedBox ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::AxisAlignedBox" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'intersection'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: volume of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_volume00
   16646  static int tolua_Ogre_Ogre_AxisAlignedBox_volume00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'volume'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->volume(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'volume'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: scale of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_scale00
   16678  static int tolua_Ogre_Ogre_AxisAlignedBox_scale00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::AxisAlignedBox* self = (  Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* s = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'scale'",  NULL );
          #endif
           {
           self->scale(  *s );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'scale'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_intersects01
   16711  static int tolua_Ogre_Ogre_AxisAlignedBox_intersects01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Sphere",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Sphere* s = (  (  const Ogre::Sphere* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'intersects'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->intersects(  *s );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_intersects00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_intersects02
   16740  static int tolua_Ogre_Ogre_AxisAlignedBox_intersects02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Plane",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Plane* p = (  (  const Ogre::Plane* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'intersects'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->intersects(  *p );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_intersects01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: intersects of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_intersects03
   16769  static int tolua_Ogre_Ogre_AxisAlignedBox_intersects03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* v = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'intersects'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->intersects(  *v );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_intersects02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCenter of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_getCenter00
   16798  static int tolua_Ogre_Ogre_AxisAlignedBox_getCenter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCenter'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->getCenter(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCenter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSize of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_getSize00
   16838  static int tolua_Ogre_Ogre_AxisAlignedBox_getSize00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSize'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->getSize(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSize'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getHalfSize of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_getHalfSize00
   16878  static int tolua_Ogre_Ogre_AxisAlignedBox_getHalfSize00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getHalfSize'",  NULL );
          #endif
           {
           Ogre::Vector3 tolua_ret = (  Ogre::Vector3 ) self->getHalfSize(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::Vector3(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::Vector3 ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::Vector3" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getHalfSize'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: contains of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_contains00
   16918  static int tolua_Ogre_Ogre_AxisAlignedBox_contains00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::Vector3",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::Vector3* v = (  (  const Ogre::Vector3* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'contains'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->contains(  *v );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'contains'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: contains of class Ogre::AxisAlignedBox */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_AxisAlignedBox_contains01
   16952  static int tolua_Ogre_Ogre_AxisAlignedBox_contains01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::AxisAlignedBox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::AxisAlignedBox* self = (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::AxisAlignedBox* other = (  (  const Ogre::AxisAlignedBox* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'contains'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->contains(  *other );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_AxisAlignedBox_contains00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ZERO of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_ZERO
   16981  static int tolua_get_Ogre__ColourValue_ZERO(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::ColourValue::ZERO,  "const Ogre::ColourValue" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Black of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_Black
   16990  static int tolua_get_Ogre__ColourValue_Black(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::ColourValue::Black,  "const Ogre::ColourValue" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: White of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_White
   16999  static int tolua_get_Ogre__ColourValue_White(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::ColourValue::White,  "const Ogre::ColourValue" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Red of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_Red
   17008  static int tolua_get_Ogre__ColourValue_Red(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::ColourValue::Red,  "const Ogre::ColourValue" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Green of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_Green
   17017  static int tolua_get_Ogre__ColourValue_Green(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::ColourValue::Green,  "const Ogre::ColourValue" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Blue of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_Blue
   17026  static int tolua_get_Ogre__ColourValue_Blue(  lua_State* tolua_S )
          {
           tolua_pushusertype(  tolua_S,  (  void* )&Ogre::ColourValue::Blue,  "const Ogre::ColourValue" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_new00
   17035  static int tolua_Ogre_Ogre_ColourValue_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  1,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float red = (  (  float ) tolua_tonumber(  tolua_S,  2,  1.0f ) );
           float green = (  (  float ) tolua_tonumber(  tolua_S,  3,  1.0f ) );
           float blue = (  (  float ) tolua_tonumber(  tolua_S,  4,  1.0f ) );
           float alpha = (  (  float ) tolua_tonumber(  tolua_S,  5,  1.0f ) );
           {
           Ogre::ColourValue* tolua_ret = (  Ogre::ColourValue* ) new Ogre::ColourValue(  red,  green,  blue,  alpha );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::ColourValue" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_new00_local
   17071  static int tolua_Ogre_Ogre_ColourValue_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  1,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  1,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  5,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           float red = (  (  float ) tolua_tonumber(  tolua_S,  2,  1.0f ) );
           float green = (  (  float ) tolua_tonumber(  tolua_S,  3,  1.0f ) );
           float blue = (  (  float ) tolua_tonumber(  tolua_S,  4,  1.0f ) );
           float alpha = (  (  float ) tolua_tonumber(  tolua_S,  5,  1.0f ) );
           {
           Ogre::ColourValue* tolua_ret = (  Ogre::ColourValue* ) new Ogre::ColourValue(  red,  green,  blue,  alpha );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ogre::ColourValue" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: r of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_r
   17107  static int tolua_get_Ogre__ColourValue_r(  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'r'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->r );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: r of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__ColourValue_r
   17120  static int tolua_set_Ogre__ColourValue_r(  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'r'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->r = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: g of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_g
   17137  static int tolua_get_Ogre__ColourValue_g(  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'g'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->g );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: g of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__ColourValue_g
   17150  static int tolua_set_Ogre__ColourValue_g(  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'g'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->g = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: b of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_b
   17167  static int tolua_get_Ogre__ColourValue_b(  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'b'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->b );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: b of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__ColourValue_b
   17180  static int tolua_set_Ogre__ColourValue_b(  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'b'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->b = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: a of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_get_Ogre__ColourValue_a
   17197  static int tolua_get_Ogre__ColourValue_a(  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'a'",  NULL );
          #endif
           tolua_pushnumber(  tolua_S,  (  lua_Number )self->a );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: a of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_set_Ogre__ColourValue_a
   17210  static int tolua_set_Ogre__ColourValue_a(  lua_State* tolua_S )
          {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'a'",  NULL );
           if (  !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->a = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAsRGBA of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_getAsRGBA00
   17227  static int tolua_Ogre_Ogre_ColourValue_getAsRGBA00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* self = (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAsRGBA'",  NULL );
          #endif
           {
           unsigned int tolua_ret = (  unsigned int ) self->getAsRGBA(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAsRGBA'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAsARGB of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_getAsARGB00
   17259  static int tolua_Ogre_Ogre_ColourValue_getAsARGB00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* self = (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAsARGB'",  NULL );
          #endif
           {
           unsigned int tolua_ret = (  unsigned int ) self->getAsARGB(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAsARGB'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAsBGRA of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_getAsBGRA00
   17291  static int tolua_Ogre_Ogre_ColourValue_getAsBGRA00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* self = (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAsBGRA'",  NULL );
          #endif
           {
           unsigned int tolua_ret = (  unsigned int ) self->getAsBGRA(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAsBGRA'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAsABGR of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_getAsABGR00
   17323  static int tolua_Ogre_Ogre_ColourValue_getAsABGR00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* self = (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAsABGR'",  NULL );
          #endif
           {
           unsigned int tolua_ret = (  unsigned int ) self->getAsABGR(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAsABGR'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAsRGBA of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_setAsRGBA00
   17355  static int tolua_Ogre_Ogre_ColourValue_setAsRGBA00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned const int val = (  (  unsigned const int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAsRGBA'",  NULL );
          #endif
           {
           self->setAsRGBA(  val );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAsRGBA'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAsARGB of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_setAsARGB00
   17388  static int tolua_Ogre_Ogre_ColourValue_setAsARGB00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned const int val = (  (  unsigned const int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAsARGB'",  NULL );
          #endif
           {
           self->setAsARGB(  val );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAsARGB'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAsBGRA of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_setAsBGRA00
   17421  static int tolua_Ogre_Ogre_ColourValue_setAsBGRA00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned const int val = (  (  unsigned const int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAsBGRA'",  NULL );
          #endif
           {
           self->setAsBGRA(  val );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAsBGRA'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAsABGR of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_setAsABGR00
   17454  static int tolua_Ogre_Ogre_ColourValue_setAsABGR00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned const int val = (  (  unsigned const int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAsABGR'",  NULL );
          #endif
           {
           self->setAsABGR(  val );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAsABGR'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: saturate of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_saturate00
   17487  static int tolua_Ogre_Ogre_ColourValue_saturate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'saturate'",  NULL );
          #endif
           {
           self->saturate(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'saturate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: saturateCopy of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_saturateCopy00
   17518  static int tolua_Ogre_Ogre_ColourValue_saturateCopy00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* self = (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'saturateCopy'",  NULL );
          #endif
           {
           Ogre::ColourValue tolua_ret = (  Ogre::ColourValue ) self->saturateCopy(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ColourValue(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ColourValue ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'saturateCopy'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator+ of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue__add00
   17558  static int tolua_Ogre_Ogre_ColourValue__add00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* self = (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::ColourValue* rkVector = (  (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator+'",  NULL );
          #endif
           {
           Ogre::ColourValue tolua_ret = (  Ogre::ColourValue ) self->operator+(  *rkVector );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ColourValue(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ColourValue ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.add'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator- of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue__sub00
   17600  static int tolua_Ogre_Ogre_ColourValue__sub00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* self = (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::ColourValue* rkVector = (  (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator-'",  NULL );
          #endif
           {
           Ogre::ColourValue tolua_ret = (  Ogre::ColourValue ) self->operator-(  *rkVector );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ColourValue(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ColourValue ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.sub'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator/ of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue__div00
   17642  static int tolua_Ogre_Ogre_ColourValue__div00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::ColourValue* self = (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::ColourValue* rhs = (  (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator/'",  NULL );
          #endif
           {
           Ogre::ColourValue tolua_ret = (  Ogre::ColourValue ) self->operator/(  *rhs );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ColourValue(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ColourValue ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.div'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator/ of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue__div01
   17684  static int tolua_Ogre_Ogre_ColourValue__div01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Ogre::ColourValue* self = (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           const float fScalar = (  (  const float ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator/'",  NULL );
          #endif
           {
           Ogre::ColourValue tolua_ret = (  Ogre::ColourValue ) self->operator/(  fScalar );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Ogre::ColourValue(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Ogre::ColourValue ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Ogre::ColourValue" );
          #endif
           }
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Ogre_Ogre_ColourValue__div00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setHSB of class Ogre::ColourValue */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_ColourValue_setHSB00
   17721  static int tolua_Ogre_Ogre_ColourValue_setHSB00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::ColourValue* self = (  Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  1,  0 );
           float hue = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           float saturation = (  (  float ) tolua_tonumber(  tolua_S,  3,  0 ) );
           float brightness = (  (  float ) tolua_tonumber(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setHSB'",  NULL );
          #endif
           {
           self->setHSB(  hue,  saturation,  brightness );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setHSB'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: saveConfig of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_saveConfig00
   17758  static int tolua_Ogre_Ogre_Root_saveConfig00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'saveConfig'",  NULL );
          #endif
           {
           self->saveConfig(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'saveConfig'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: restoreConfig of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_restoreConfig00
   17789  static int tolua_Ogre_Ogre_Root_restoreConfig00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'restoreConfig'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->restoreConfig(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'restoreConfig'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: showConfigDialog of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_showConfigDialog00
   17821  static int tolua_Ogre_Ogre_Root_showConfigDialog00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'showConfigDialog'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->showConfigDialog(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'showConfigDialog'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isInitialised of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_isInitialised00
   17853  static int tolua_Ogre_Ogre_Root_isInitialised00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Root* self = (  const Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isInitialised'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isInitialised(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isInitialised'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getTextureManager of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_getTextureManager00
   17885  static int tolua_Ogre_Ogre_Root_getTextureManager00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getTextureManager'",  NULL );
          #endif
           {
           Ogre::TextureManager* tolua_ret = (  Ogre::TextureManager* ) self->getTextureManager(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::TextureManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getTextureManager'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMeshManager of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_getMeshManager00
   17917  static int tolua_Ogre_Ogre_Root_getMeshManager00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMeshManager'",  NULL );
          #endif
           {
           Ogre::MeshManager* tolua_ret = (  Ogre::MeshManager* ) self->getMeshManager(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::MeshManager" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMeshManager'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getErrorDescription of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_getErrorDescription00
   17949  static int tolua_Ogre_Ogre_Root_getErrorDescription00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
           long errorNumber = (  (  long ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getErrorDescription'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->getErrorDescription(  errorNumber );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getErrorDescription'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addFrameListener of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_addFrameListener00
   17983  static int tolua_Ogre_Ogre_Root_addFrameListener00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::FrameListener",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::FrameListener* newListener = (  (  Ogre::FrameListener* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addFrameListener'",  NULL );
          #endif
           {
           self->addFrameListener(  newListener );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addFrameListener'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeFrameListener of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_removeFrameListener00
   18016  static int tolua_Ogre_Ogre_Root_removeFrameListener00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ogre::FrameListener",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ogre::FrameListener* oldListener = (  (  Ogre::FrameListener* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeFrameListener'",  NULL );
          #endif
           {
           self->removeFrameListener(  oldListener );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeFrameListener'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: convertColourValue of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_convertColourValue00
   18049  static int tolua_Ogre_Ogre_Root_convertColourValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Ogre::ColourValue",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Ogre::ColourValue* colour = (  (  const Ogre::ColourValue* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           unsigned int pDest = (  (  unsigned int ) tolua_tonumber(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'convertColourValue'",  NULL );
          #endif
           {
           self->convertColourValue(  *colour,  &pDest );
           tolua_pushnumber(  tolua_S,  (  lua_Number )pDest );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'convertColourValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getTimer of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_getTimer00
   18085  static int tolua_Ogre_Ogre_Root_getTimer00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ogre::Root* self = (  Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getTimer'",  NULL );
          #endif
           {
           Ogre::Timer* tolua_ret = (  Ogre::Timer* ) self->getTimer(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ogre::Timer" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getTimer'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCurrentFrameNumber of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_getCurrentFrameNumber00
   18117  static int tolua_Ogre_Ogre_Root_getCurrentFrameNumber00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ogre::Root* self = (  const Ogre::Root* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCurrentFrameNumber'",  NULL );
          #endif
           {
           unsigned long tolua_ret = (  unsigned long ) self->getCurrentFrameNumber(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCurrentFrameNumber'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class Ogre::Root */
          #ifndef TOLUA_DISABLE_tolua_Ogre_Ogre_Root_getSingleton00
   18149  static int tolua_Ogre_Ogre_Root_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ogre::Root",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ogre::Root& tolua_ret = (  Ogre::Root& ) Ogre::Root::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Ogre::Root" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* Open function */
   18176  TOLUA_API int tolua_Ogre_open (  lua_State* tolua_S )
          {
           tolua_open(  tolua_S );
           tolua_reg_types(  tolua_S );
           tolua_module(  tolua_S,  NULL,  0 );
           tolua_beginmodule(  tolua_S,  NULL );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "RenderTarget",  "Ogre::RenderTarget",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "RenderTarget" );
           tolua_constant(  tolua_S,  "SF_NONE",  Ogre::RenderTarget::SF_NONE );
           tolua_constant(  tolua_S,  "SF_FPS",  Ogre::RenderTarget::SF_FPS );
           tolua_constant(  tolua_S,  "SF_AVG_FPS",  Ogre::RenderTarget::SF_AVG_FPS );
           tolua_constant(  tolua_S,  "SF_BEST_FPS",  Ogre::RenderTarget::SF_BEST_FPS );
           tolua_constant(  tolua_S,  "SF_WORST_FPS",  Ogre::RenderTarget::SF_WORST_FPS );
           tolua_constant(  tolua_S,  "SF_TRIANGLE_COUNT",  Ogre::RenderTarget::SF_TRIANGLE_COUNT );
           tolua_constant(  tolua_S,  "SF_ALL",  Ogre::RenderTarget::SF_ALL );
           tolua_cclass(  tolua_S,  "FrameStats",  "Ogre::RenderTarget::FrameStats",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "FrameStats" );
           tolua_variable(  tolua_S,  "lastFPS",  tolua_get_Ogre__RenderTarget__FrameStats_lastFPS,  tolua_set_Ogre__RenderTarget__FrameStats_lastFPS );
           tolua_variable(  tolua_S,  "avgFPS",  tolua_get_Ogre__RenderTarget__FrameStats_avgFPS,  tolua_set_Ogre__RenderTarget__FrameStats_avgFPS );
           tolua_variable(  tolua_S,  "bestFPS",  tolua_get_Ogre__RenderTarget__FrameStats_bestFPS,  tolua_set_Ogre__RenderTarget__FrameStats_bestFPS );
           tolua_variable(  tolua_S,  "worstFPS",  tolua_get_Ogre__RenderTarget__FrameStats_worstFPS,  tolua_set_Ogre__RenderTarget__FrameStats_worstFPS );
           tolua_variable(  tolua_S,  "bestFrameTime",  tolua_get_Ogre__RenderTarget__FrameStats_unsigned_bestFrameTime,  tolua_set_Ogre__RenderTarget__FrameStats_unsigned_bestFrameTime );
           tolua_variable(  tolua_S,  "worstFrameTime",  tolua_get_Ogre__RenderTarget__FrameStats_unsigned_worstFrameTime,  tolua_set_Ogre__RenderTarget__FrameStats_unsigned_worstFrameTime );
           tolua_variable(  tolua_S,  "triangleCount",  tolua_get_Ogre__RenderTarget__FrameStats_unsigned_triangleCount,  tolua_set_Ogre__RenderTarget__FrameStats_unsigned_triangleCount );
           tolua_endmodule(  tolua_S );
           tolua_function(  tolua_S,  "getStatistics",  tolua_Ogre_Ogre_RenderTarget_getStatistics00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "RenderWindow",  "Ogre::RenderWindow",  "Ogre::RenderTarget",  NULL );
           tolua_beginmodule(  tolua_S,  "RenderWindow" );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "MapIterator_Ogre__ResourceManager__ResourceHandleMap_",  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>",  "",  tolua_collect_Ogre__MapIterator_Ogre__ResourceManager__ResourceHandleMap_ );
           #else
           tolua_cclass(  tolua_S,  "MapIterator_Ogre__ResourceManager__ResourceHandleMap_",  "Ogre::MapIterator<Ogre::ResourceManager::ResourceHandleMap>",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "MapIterator_Ogre__ResourceManager__ResourceHandleMap_" );
           tolua_function(  tolua_S,  "hasMoreElements",  tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__hasMoreElements00 );
           tolua_function(  tolua_S,  "getNext",  tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__getNext00 );
           tolua_function(  tolua_S,  "peekNextValue",  tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__peekNextValue00 );
           tolua_function(  tolua_S,  "peekNextKey",  tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__peekNextKey00 );
           tolua_function(  tolua_S,  "moveNext",  tolua_Ogre_Ogre_MapIterator_Ogre__ResourceManager__ResourceHandleMap__moveNext00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "Resource",  "Ogre::Resource",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Resource" );
           tolua_function(  tolua_S,  "load",  tolua_Ogre_Ogre_Resource_load00 );
           tolua_function(  tolua_S,  "reload",  tolua_Ogre_Ogre_Resource_reload00 );
           tolua_function(  tolua_S,  "isManuallyLoaded",  tolua_Ogre_Ogre_Resource_isManuallyLoaded00 );
           tolua_function(  tolua_S,  "unload",  tolua_Ogre_Ogre_Resource_unload00 );
           tolua_function(  tolua_S,  "getSize",  tolua_Ogre_Ogre_Resource_getSize00 );
           tolua_function(  tolua_S,  "touch",  tolua_Ogre_Ogre_Resource_touch00 );
           tolua_function(  tolua_S,  "getName",  tolua_Ogre_Ogre_Resource_getName00 );
           tolua_function(  tolua_S,  "isLoaded",  tolua_Ogre_Ogre_Resource_isLoaded00 );
           tolua_function(  tolua_S,  "getGroup",  tolua_Ogre_Ogre_Resource_getGroup00 );
           tolua_function(  tolua_S,  "getOrigin",  tolua_Ogre_Ogre_Resource_getOrigin00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "ResourceManager",  "Ogre::ResourceManager",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ResourceManager" );
           tolua_function(  tolua_S,  "create",  tolua_Ogre_Ogre_ResourceManager_create00 );
           tolua_function(  tolua_S,  "reloadAll",  tolua_Ogre_Ogre_ResourceManager_reloadAll00 );
           tolua_function(  tolua_S,  "remove",  tolua_Ogre_Ogre_ResourceManager_remove00 );
           tolua_function(  tolua_S,  "remove",  tolua_Ogre_Ogre_ResourceManager_remove01 );
           tolua_function(  tolua_S,  "getByName",  tolua_Ogre_Ogre_ResourceManager_getByName00 );
           tolua_function(  tolua_S,  "resourceExists",  tolua_Ogre_Ogre_ResourceManager_resourceExists00 );
           tolua_function(  tolua_S,  "getResourceIterator",  tolua_Ogre_Ogre_ResourceManager_getResourceIterator00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "MaterialManager",  "Ogre::MaterialManager",  "Ogre::ResourceManager",  NULL );
           tolua_beginmodule(  tolua_S,  "MaterialManager" );
           tolua_function(  tolua_S,  "getSingleton",  tolua_Ogre_Ogre_MaterialManager_getSingleton00 );
           tolua_function(  tolua_S,  "load",  tolua_Ogre_Ogre_MaterialManager_load00 );
           tolua_function(  tolua_S,  "getByName",  tolua_Ogre_Ogre_MaterialManager_getByName00 );
           tolua_function(  tolua_S,  "create",  tolua_Ogre_Ogre_MaterialManager_create00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "Material",  "Ogre::Material",  "Ogre::Resource",  NULL );
           tolua_beginmodule(  tolua_S,  "Material" );
           tolua_function(  tolua_S,  "isTransparent",  tolua_Ogre_Ogre_Material_isTransparent00 );
           tolua_function(  tolua_S,  "setReceiveShadows",  tolua_Ogre_Ogre_Material_setReceiveShadows00 );
           tolua_function(  tolua_S,  "getReceiveShadows",  tolua_Ogre_Ogre_Material_getReceiveShadows00 );
           tolua_function(  tolua_S,  "setTransparencyCastsShadows",  tolua_Ogre_Ogre_Material_setTransparencyCastsShadows00 );
           tolua_function(  tolua_S,  "getTransparencyCastsShadows",  tolua_Ogre_Ogre_Material_getTransparencyCastsShadows00 );
           tolua_function(  tolua_S,  "getNumTechniques",  tolua_Ogre_Ogre_Material_getNumTechniques00 );
           tolua_function(  tolua_S,  "touch",  tolua_Ogre_Ogre_Material_touch00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "MaterialPtr",  "Ogre::MaterialPtr",  "",  tolua_collect_Ogre__MaterialPtr );
           #else
           tolua_cclass(  tolua_S,  "MaterialPtr",  "Ogre::MaterialPtr",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "MaterialPtr" );
           tolua_function(  tolua_S,  "get",  tolua_Ogre_Ogre_MaterialPtr_get00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "SubEntity",  "Ogre::SubEntity",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "SubEntity" );
           tolua_function(  tolua_S,  "getMaterialName",  tolua_Ogre_Ogre_SubEntity_getMaterialName00 );
           tolua_function(  tolua_S,  "setMaterialName",  tolua_Ogre_Ogre_SubEntity_setMaterialName00 );
           tolua_function(  tolua_S,  "setVisible",  tolua_Ogre_Ogre_SubEntity_setVisible00 );
           tolua_function(  tolua_S,  "isVisible",  tolua_Ogre_Ogre_SubEntity_isVisible00 );
           tolua_function(  tolua_S,  "getMaterial",  tolua_Ogre_Ogre_SubEntity_getMaterial00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "MeshManager",  "Ogre::MeshManager",  "Ogre::ResourceManager",  NULL );
           tolua_beginmodule(  tolua_S,  "MeshManager" );
           tolua_function(  tolua_S,  "getSingleton",  tolua_Ogre_Ogre_MeshManager_getSingleton00 );
           tolua_function(  tolua_S,  "load",  tolua_Ogre_Ogre_MeshManager_load00 );
           tolua_function(  tolua_S,  "getByName",  tolua_Ogre_Ogre_MeshManager_getByName00 );
           tolua_function(  tolua_S,  "create",  tolua_Ogre_Ogre_MeshManager_create00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "Mesh",  "Ogre::Mesh",  "Ogre::Resource",  NULL );
           tolua_beginmodule(  tolua_S,  "Mesh" );
           tolua_function(  tolua_S,  "getNumSubMeshes",  tolua_Ogre_Ogre_Mesh_getNumSubMeshes00 );
           tolua_function(  tolua_S,  "getSubMesh",  tolua_Ogre_Ogre_Mesh_getSubMesh00 );
           tolua_function(  tolua_S,  "getBounds",  tolua_Ogre_Ogre_Mesh_getBounds00 );
           tolua_function(  tolua_S,  "hasSkeleton",  tolua_Ogre_Ogre_Mesh_hasSkeleton00 );
           tolua_function(  tolua_S,  "getSkeletonName",  tolua_Ogre_Ogre_Mesh_getSkeletonName00 );
           tolua_function(  tolua_S,  "getNumLodLevels",  tolua_Ogre_Ogre_Mesh_getNumLodLevels00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "MeshPtr",  "Ogre::MeshPtr",  "",  tolua_collect_Ogre__MeshPtr );
           #else
           tolua_cclass(  tolua_S,  "MeshPtr",  "Ogre::MeshPtr",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "MeshPtr" );
           tolua_function(  tolua_S,  "get",  tolua_Ogre_Ogre_MeshPtr_get00 );
           tolua_function(  tolua_S,  "get",  tolua_Ogre_Ogre_MeshPtr_get01 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "SubMesh",  "Ogre::SubMesh",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "SubMesh" );
           tolua_variable(  tolua_S,  "useSharedVertices",  tolua_get_Ogre__SubMesh_useSharedVertices,  tolua_set_Ogre__SubMesh_useSharedVertices );
           tolua_variable(  tolua_S,  "parent",  tolua_get_Ogre__SubMesh_parent_ptr,  tolua_set_Ogre__SubMesh_parent_ptr );
           tolua_function(  tolua_S,  "setMaterialName",  tolua_Ogre_Ogre_SubMesh_setMaterialName00 );
           tolua_function(  tolua_S,  "getMaterialName",  tolua_Ogre_Ogre_SubMesh_getMaterialName00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Vector3",  "Ogre::Vector3",  "",  tolua_collect_Ogre__Vector3 );
           #else
           tolua_cclass(  tolua_S,  "Vector3",  "Ogre::Vector3",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Vector3" );
           tolua_variable(  tolua_S,  "x",  tolua_get_Ogre__Vector3_x,  tolua_set_Ogre__Vector3_x );
           tolua_variable(  tolua_S,  "y",  tolua_get_Ogre__Vector3_y,  tolua_set_Ogre__Vector3_y );
           tolua_variable(  tolua_S,  "z",  tolua_get_Ogre__Vector3_z,  tolua_set_Ogre__Vector3_z );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Vector3_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Vector3_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Vector3_new00_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Vector3_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Vector3_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Vector3_new01_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Vector3_new02 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Vector3_new02_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Vector3_new02_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Vector3_new03 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Vector3_new03_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Vector3_new03_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Vector3_new04 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Vector3_new04_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Vector3_new04_local );
           tolua_function(  tolua_S,  ".geti",  tolua_Ogre_Ogre_Vector3__geti00 );
           tolua_function(  tolua_S,  ".seti",  tolua_Ogre_Ogre_Vector3__seti00 );
           tolua_function(  tolua_S,  ".geti",  tolua_Ogre_Ogre_Vector3__geti01 );
           tolua_function(  tolua_S,  ".eq",  tolua_Ogre_Ogre_Vector3__eq00 );
           tolua_function(  tolua_S,  ".add",  tolua_Ogre_Ogre_Vector3__add00 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Vector3__sub00 );
           tolua_function(  tolua_S,  ".mul",  tolua_Ogre_Ogre_Vector3__mul00 );
           tolua_function(  tolua_S,  ".mul",  tolua_Ogre_Ogre_Vector3__mul01 );
           tolua_function(  tolua_S,  ".div",  tolua_Ogre_Ogre_Vector3__div00 );
           tolua_function(  tolua_S,  ".div",  tolua_Ogre_Ogre_Vector3__div01 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Vector3__sub01 );
           tolua_function(  tolua_S,  "length",  tolua_Ogre_Ogre_Vector3_length00 );
           tolua_function(  tolua_S,  "squaredLength",  tolua_Ogre_Ogre_Vector3_squaredLength00 );
           tolua_function(  tolua_S,  "dotProduct",  tolua_Ogre_Ogre_Vector3_dotProduct00 );
           tolua_function(  tolua_S,  "normalise",  tolua_Ogre_Ogre_Vector3_normalise00 );
           tolua_function(  tolua_S,  "crossProduct",  tolua_Ogre_Ogre_Vector3_crossProduct00 );
           tolua_function(  tolua_S,  "midPoint",  tolua_Ogre_Ogre_Vector3_midPoint00 );
           tolua_function(  tolua_S,  ".lt",  tolua_Ogre_Ogre_Vector3__lt00 );
           tolua_function(  tolua_S,  "makeFloor",  tolua_Ogre_Ogre_Vector3_makeFloor00 );
           tolua_function(  tolua_S,  "makeCeil",  tolua_Ogre_Ogre_Vector3_makeCeil00 );
           tolua_function(  tolua_S,  "perpendicular",  tolua_Ogre_Ogre_Vector3_perpendicular00 );
           tolua_function(  tolua_S,  "randomDeviant",  tolua_Ogre_Ogre_Vector3_randomDeviant00 );
           tolua_function(  tolua_S,  "getRotationTo",  tolua_Ogre_Ogre_Vector3_getRotationTo00 );
           tolua_function(  tolua_S,  "isZeroLength",  tolua_Ogre_Ogre_Vector3_isZeroLength00 );
           tolua_function(  tolua_S,  "normalisedCopy",  tolua_Ogre_Ogre_Vector3_normalisedCopy00 );
           tolua_function(  tolua_S,  "reflect",  tolua_Ogre_Ogre_Vector3_reflect00 );
           tolua_function(  tolua_S,  "positionEquals",  tolua_Ogre_Ogre_Vector3_positionEquals00 );
           tolua_function(  tolua_S,  "directionEquals",  tolua_Ogre_Ogre_Vector3_directionEquals00 );
           tolua_variable(  tolua_S,  "ZERO",  tolua_get_Ogre__Vector3_ZERO,  NULL );
           tolua_variable(  tolua_S,  "UNIT_X",  tolua_get_Ogre__Vector3_UNIT_X,  NULL );
           tolua_variable(  tolua_S,  "UNIT_Y",  tolua_get_Ogre__Vector3_UNIT_Y,  NULL );
           tolua_variable(  tolua_S,  "UNIT_Z",  tolua_get_Ogre__Vector3_UNIT_Z,  NULL );
           tolua_variable(  tolua_S,  "NEGATIVE_UNIT_X",  tolua_get_Ogre__Vector3_NEGATIVE_UNIT_X,  NULL );
           tolua_variable(  tolua_S,  "NEGATIVE_UNIT_Y",  tolua_get_Ogre__Vector3_NEGATIVE_UNIT_Y,  NULL );
           tolua_variable(  tolua_S,  "NEGATIVE_UNIT_Z",  tolua_get_Ogre__Vector3_NEGATIVE_UNIT_Z,  NULL );
           tolua_variable(  tolua_S,  "UNIT_SCALE",  tolua_get_Ogre__Vector3_UNIT_SCALE,  NULL );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Quaternion",  "Ogre::Quaternion",  "",  tolua_collect_Ogre__Quaternion );
           #else
           tolua_cclass(  tolua_S,  "Quaternion",  "Ogre::Quaternion",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Quaternion" );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Quaternion_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Quaternion_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Quaternion_new00_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Quaternion_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Quaternion_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Quaternion_new01_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Quaternion_new02 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Quaternion_new02_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Quaternion_new02_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Quaternion_new03 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Quaternion_new03_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Quaternion_new03_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Quaternion_new04 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Quaternion_new04_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Quaternion_new04_local );
           tolua_function(  tolua_S,  "FromRotationMatrix",  tolua_Ogre_Ogre_Quaternion_FromRotationMatrix00 );
           tolua_function(  tolua_S,  "ToRotationMatrix",  tolua_Ogre_Ogre_Quaternion_ToRotationMatrix00 );
           tolua_function(  tolua_S,  "FromAngleAxis",  tolua_Ogre_Ogre_Quaternion_FromAngleAxis00 );
           tolua_function(  tolua_S,  "ToAngleAxis",  tolua_Ogre_Ogre_Quaternion_ToAngleAxis00 );
           tolua_function(  tolua_S,  "ToAngleAxis",  tolua_Ogre_Ogre_Quaternion_ToAngleAxis01 );
           tolua_function(  tolua_S,  "FromAxes",  tolua_Ogre_Ogre_Quaternion_FromAxes00 );
           tolua_function(  tolua_S,  "FromAxes",  tolua_Ogre_Ogre_Quaternion_FromAxes01 );
           tolua_function(  tolua_S,  "ToAxes",  tolua_Ogre_Ogre_Quaternion_ToAxes00 );
           tolua_function(  tolua_S,  "ToAxes",  tolua_Ogre_Ogre_Quaternion_ToAxes01 );
           tolua_function(  tolua_S,  "xAxis",  tolua_Ogre_Ogre_Quaternion_xAxis00 );
           tolua_function(  tolua_S,  "yAxis",  tolua_Ogre_Ogre_Quaternion_yAxis00 );
           tolua_function(  tolua_S,  "zAxis",  tolua_Ogre_Ogre_Quaternion_zAxis00 );
           tolua_function(  tolua_S,  ".add",  tolua_Ogre_Ogre_Quaternion__add00 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Quaternion__sub00 );
           tolua_function(  tolua_S,  ".mul",  tolua_Ogre_Ogre_Quaternion__mul00 );
           tolua_function(  tolua_S,  ".mul",  tolua_Ogre_Ogre_Quaternion__mul01 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Quaternion__sub01 );
           tolua_function(  tolua_S,  ".eq",  tolua_Ogre_Ogre_Quaternion__eq00 );
           tolua_function(  tolua_S,  "Dot",  tolua_Ogre_Ogre_Quaternion_Dot00 );
           tolua_function(  tolua_S,  "Norm",  tolua_Ogre_Ogre_Quaternion_Norm00 );
           tolua_function(  tolua_S,  "normalise",  tolua_Ogre_Ogre_Quaternion_normalise00 );
           tolua_function(  tolua_S,  "Inverse",  tolua_Ogre_Ogre_Quaternion_Inverse00 );
           tolua_function(  tolua_S,  "UnitInverse",  tolua_Ogre_Ogre_Quaternion_UnitInverse00 );
           tolua_function(  tolua_S,  "Exp",  tolua_Ogre_Ogre_Quaternion_Exp00 );
           tolua_function(  tolua_S,  "Log",  tolua_Ogre_Ogre_Quaternion_Log00 );
           tolua_function(  tolua_S,  ".mul",  tolua_Ogre_Ogre_Quaternion__mul02 );
           tolua_function(  tolua_S,  "getRoll",  tolua_Ogre_Ogre_Quaternion_getRoll00 );
           tolua_function(  tolua_S,  "getPitch",  tolua_Ogre_Ogre_Quaternion_getPitch00 );
           tolua_function(  tolua_S,  "getYaw",  tolua_Ogre_Ogre_Quaternion_getYaw00 );
           tolua_function(  tolua_S,  "equals",  tolua_Ogre_Ogre_Quaternion_equals00 );
           tolua_function(  tolua_S,  "Slerp",  tolua_Ogre_Ogre_Quaternion_Slerp00 );
           tolua_function(  tolua_S,  "SlerpExtraSpins",  tolua_Ogre_Ogre_Quaternion_SlerpExtraSpins00 );
           tolua_function(  tolua_S,  "Intermediate",  tolua_Ogre_Ogre_Quaternion_Intermediate00 );
           tolua_function(  tolua_S,  "Squad",  tolua_Ogre_Ogre_Quaternion_Squad00 );
           tolua_function(  tolua_S,  "nlerp",  tolua_Ogre_Ogre_Quaternion_nlerp00 );
           tolua_variable(  tolua_S,  "ms_fEpsilon",  tolua_get_Ogre__Quaternion_ms_fEpsilon,  NULL );
           tolua_variable(  tolua_S,  "ZERO",  tolua_get_Ogre__Quaternion_ZERO,  NULL );
           tolua_variable(  tolua_S,  "IDENTITY",  tolua_get_Ogre__Quaternion_IDENTITY,  NULL );
           tolua_variable(  tolua_S,  "w",  tolua_get_Ogre__Quaternion_w,  tolua_set_Ogre__Quaternion_w );
           tolua_variable(  tolua_S,  "x",  tolua_get_Ogre__Quaternion_x,  tolua_set_Ogre__Quaternion_x );
           tolua_variable(  tolua_S,  "y",  tolua_get_Ogre__Quaternion_y,  tolua_set_Ogre__Quaternion_y );
           tolua_variable(  tolua_S,  "z",  tolua_get_Ogre__Quaternion_z,  tolua_set_Ogre__Quaternion_z );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Radian",  "Ogre::Radian",  "",  tolua_collect_Ogre__Radian );
           #else
           tolua_cclass(  tolua_S,  "Radian",  "Ogre::Radian",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Radian" );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Radian_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Radian_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Radian_new00_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Radian_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Radian_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Radian_new01_local );
           tolua_function(  tolua_S,  "valueDegrees",  tolua_Ogre_Ogre_Radian_valueDegrees00 );
           tolua_function(  tolua_S,  "valueRadians",  tolua_Ogre_Ogre_Radian_valueRadians00 );
           tolua_function(  tolua_S,  "valueAngleUnits",  tolua_Ogre_Ogre_Radian_valueAngleUnits00 );
           tolua_function(  tolua_S,  ".add",  tolua_Ogre_Ogre_Radian__add00 );
           tolua_function(  tolua_S,  ".add",  tolua_Ogre_Ogre_Radian__add01 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Radian__sub00 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Radian__sub01 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Radian__sub02 );
           tolua_function(  tolua_S,  ".mul",  tolua_Ogre_Ogre_Radian__mul00 );
           tolua_function(  tolua_S,  ".mul",  tolua_Ogre_Ogre_Radian__mul01 );
           tolua_function(  tolua_S,  ".div",  tolua_Ogre_Ogre_Radian__div00 );
           tolua_function(  tolua_S,  ".lt",  tolua_Ogre_Ogre_Radian__lt00 );
           tolua_function(  tolua_S,  ".le",  tolua_Ogre_Ogre_Radian__le00 );
           tolua_function(  tolua_S,  ".eq",  tolua_Ogre_Ogre_Radian__eq00 );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Radian_new02 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Radian_new02_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Radian_new02_local );
           tolua_function(  tolua_S,  ".add",  tolua_Ogre_Ogre_Radian__add02 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Radian__sub03 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Degree",  "Ogre::Degree",  "",  tolua_collect_Ogre__Degree );
           #else
           tolua_cclass(  tolua_S,  "Degree",  "Ogre::Degree",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Degree" );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Degree_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Degree_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Degree_new00_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Degree_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Degree_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Degree_new01_local );
           tolua_function(  tolua_S,  "valueDegrees",  tolua_Ogre_Ogre_Degree_valueDegrees00 );
           tolua_function(  tolua_S,  "valueRadians",  tolua_Ogre_Ogre_Degree_valueRadians00 );
           tolua_function(  tolua_S,  "valueAngleUnits",  tolua_Ogre_Ogre_Degree_valueAngleUnits00 );
           tolua_function(  tolua_S,  ".add",  tolua_Ogre_Ogre_Degree__add00 );
           tolua_function(  tolua_S,  ".add",  tolua_Ogre_Ogre_Degree__add01 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Degree__sub00 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Degree__sub01 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_Degree__sub02 );
           tolua_function(  tolua_S,  ".mul",  tolua_Ogre_Ogre_Degree__mul00 );
           tolua_function(  tolua_S,  ".mul",  tolua_Ogre_Ogre_Degree__mul01 );
           tolua_function(  tolua_S,  ".div",  tolua_Ogre_Ogre_Degree__div00 );
           tolua_function(  tolua_S,  ".lt",  tolua_Ogre_Ogre_Degree__lt00 );
           tolua_function(  tolua_S,  ".le",  tolua_Ogre_Ogre_Degree__le00 );
           tolua_function(  tolua_S,  ".eq",  tolua_Ogre_Ogre_Degree__eq00 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Math",  "Ogre::Math",  "",  tolua_collect_Ogre__Math );
           #else
           tolua_cclass(  tolua_S,  "Math",  "Ogre::Math",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Math" );
           tolua_constant(  tolua_S,  "AU_DEGREE",  Ogre::Math::AU_DEGREE );
           tolua_constant(  tolua_S,  "AU_RADIAN",  Ogre::Math::AU_RADIAN );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_Math_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_Math_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_Math_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_Ogre_Ogre_Math_delete00 );
           tolua_function(  tolua_S,  "IAbs",  tolua_Ogre_Ogre_Math_IAbs00 );
           tolua_function(  tolua_S,  "ICeil",  tolua_Ogre_Ogre_Math_ICeil00 );
           tolua_function(  tolua_S,  "IFloor",  tolua_Ogre_Ogre_Math_IFloor00 );
           tolua_function(  tolua_S,  "ISign",  tolua_Ogre_Ogre_Math_ISign00 );
           tolua_function(  tolua_S,  "Abs",  tolua_Ogre_Ogre_Math_Abs00 );
           tolua_function(  tolua_S,  "Abs",  tolua_Ogre_Ogre_Math_Abs01 );
           tolua_function(  tolua_S,  "Abs",  tolua_Ogre_Ogre_Math_Abs02 );
           tolua_function(  tolua_S,  "ACos",  tolua_Ogre_Ogre_Math_ACos00 );
           tolua_function(  tolua_S,  "ASin",  tolua_Ogre_Ogre_Math_ASin00 );
           tolua_function(  tolua_S,  "ATan",  tolua_Ogre_Ogre_Math_ATan00 );
           tolua_function(  tolua_S,  "ATan2",  tolua_Ogre_Ogre_Math_ATan200 );
           tolua_function(  tolua_S,  "Ceil",  tolua_Ogre_Ogre_Math_Ceil00 );
           tolua_function(  tolua_S,  "Cos",  tolua_Ogre_Ogre_Math_Cos00 );
           tolua_function(  tolua_S,  "Cos",  tolua_Ogre_Ogre_Math_Cos01 );
           tolua_function(  tolua_S,  "Exp",  tolua_Ogre_Ogre_Math_Exp00 );
           tolua_function(  tolua_S,  "Floor",  tolua_Ogre_Ogre_Math_Floor00 );
           tolua_function(  tolua_S,  "Log",  tolua_Ogre_Ogre_Math_Log00 );
           tolua_function(  tolua_S,  "Pow",  tolua_Ogre_Ogre_Math_Pow00 );
           tolua_function(  tolua_S,  "Sign",  tolua_Ogre_Ogre_Math_Sign00 );
           tolua_function(  tolua_S,  "Sign",  tolua_Ogre_Ogre_Math_Sign01 );
           tolua_function(  tolua_S,  "Sign",  tolua_Ogre_Ogre_Math_Sign02 );
           tolua_function(  tolua_S,  "Sin",  tolua_Ogre_Ogre_Math_Sin00 );
           tolua_function(  tolua_S,  "Sin",  tolua_Ogre_Ogre_Math_Sin01 );
           tolua_function(  tolua_S,  "Sqr",  tolua_Ogre_Ogre_Math_Sqr00 );
           tolua_function(  tolua_S,  "Sqrt",  tolua_Ogre_Ogre_Math_Sqrt00 );
           tolua_function(  tolua_S,  "Sqrt",  tolua_Ogre_Ogre_Math_Sqrt01 );
           tolua_function(  tolua_S,  "Sqrt",  tolua_Ogre_Ogre_Math_Sqrt02 );
           tolua_function(  tolua_S,  "InvSqrt",  tolua_Ogre_Ogre_Math_InvSqrt00 );
           tolua_function(  tolua_S,  "UnitRandom",  tolua_Ogre_Ogre_Math_UnitRandom00 );
           tolua_function(  tolua_S,  "RangeRandom",  tolua_Ogre_Ogre_Math_RangeRandom00 );
           tolua_function(  tolua_S,  "SymmetricRandom",  tolua_Ogre_Ogre_Math_SymmetricRandom00 );
           tolua_function(  tolua_S,  "Tan",  tolua_Ogre_Ogre_Math_Tan00 );
           tolua_function(  tolua_S,  "Tan",  tolua_Ogre_Ogre_Math_Tan01 );
           tolua_function(  tolua_S,  "DegreesToRadians",  tolua_Ogre_Ogre_Math_DegreesToRadians00 );
           tolua_function(  tolua_S,  "RadiansToDegrees",  tolua_Ogre_Ogre_Math_RadiansToDegrees00 );
           tolua_function(  tolua_S,  "setAngleUnit",  tolua_Ogre_Ogre_Math_setAngleUnit00 );
           tolua_function(  tolua_S,  "getAngleUnit",  tolua_Ogre_Ogre_Math_getAngleUnit00 );
           tolua_function(  tolua_S,  "AngleUnitsToRadians",  tolua_Ogre_Ogre_Math_AngleUnitsToRadians00 );
           tolua_function(  tolua_S,  "RadiansToAngleUnits",  tolua_Ogre_Ogre_Math_RadiansToAngleUnits00 );
           tolua_function(  tolua_S,  "AngleUnitsToDegrees",  tolua_Ogre_Ogre_Math_AngleUnitsToDegrees00 );
           tolua_function(  tolua_S,  "DegreesToAngleUnits",  tolua_Ogre_Ogre_Math_DegreesToAngleUnits00 );
           tolua_function(  tolua_S,  "pointInTri2D",  tolua_Ogre_Ogre_Math_pointInTri2D00 );
           tolua_function(  tolua_S,  "pointInTri3D",  tolua_Ogre_Ogre_Math_pointInTri3D00 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects00 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects01 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects02 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects03 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects04 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects05 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects06 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects07 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects08 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects09 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_Math_intersects10 );
           tolua_function(  tolua_S,  "RealEqual",  tolua_Ogre_Ogre_Math_RealEqual00 );
           tolua_function(  tolua_S,  "RealEqual",  tolua_Ogre_Ogre_Math_RealEqual01 );
           tolua_function(  tolua_S,  "calculateTangentSpaceVector",  tolua_Ogre_Ogre_Math_calculateTangentSpaceVector00 );
           tolua_function(  tolua_S,  "buildReflectionMatrix",  tolua_Ogre_Ogre_Math_buildReflectionMatrix00 );
           tolua_function(  tolua_S,  "calculateFaceNormal",  tolua_Ogre_Ogre_Math_calculateFaceNormal00 );
           tolua_function(  tolua_S,  "calculateBasicFaceNormal",  tolua_Ogre_Ogre_Math_calculateBasicFaceNormal00 );
           tolua_function(  tolua_S,  "calculateFaceNormalWithoutNormalize",  tolua_Ogre_Ogre_Math_calculateFaceNormalWithoutNormalize00 );
           tolua_function(  tolua_S,  "calculateBasicFaceNormalWithoutNormalize",  tolua_Ogre_Ogre_Math_calculateBasicFaceNormalWithoutNormalize00 );
           tolua_function(  tolua_S,  "gaussianDistribution",  tolua_Ogre_Ogre_Math_gaussianDistribution00 );
           tolua_variable(  tolua_S,  "POS_INFINITY",  tolua_get_Ogre__Math_POS_INFINITY,  NULL );
           tolua_variable(  tolua_S,  "NEG_INFINITY",  tolua_get_Ogre__Math_NEG_INFINITY,  NULL );
           tolua_variable(  tolua_S,  "PI",  tolua_get_Ogre__Math_PI,  NULL );
           tolua_variable(  tolua_S,  "TWO_PI",  tolua_get_Ogre__Math_TWO_PI,  NULL );
           tolua_variable(  tolua_S,  "HALF_PI",  tolua_get_Ogre__Math_HALF_PI,  NULL );
           tolua_variable(  tolua_S,  "fDeg2Rad",  tolua_get_Ogre__Math_fDeg2Rad,  NULL );
           tolua_variable(  tolua_S,  "fRad2Deg",  tolua_get_Ogre__Math_fRad2Deg,  NULL );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "Entity",  "Ogre::Entity",  "Ogre::MovableObject",  NULL );
           tolua_beginmodule(  tolua_S,  "Entity" );
           tolua_function(  tolua_S,  "getMesh",  tolua_Ogre_Ogre_Entity_getMesh00 );
           tolua_function(  tolua_S,  "getSubEntity",  tolua_Ogre_Ogre_Entity_getSubEntity00 );
           tolua_function(  tolua_S,  "getSubEntity",  tolua_Ogre_Ogre_Entity_getSubEntity01 );
           tolua_function(  tolua_S,  "getNumSubEntities",  tolua_Ogre_Ogre_Entity_getNumSubEntities00 );
           tolua_function(  tolua_S,  "clone",  tolua_Ogre_Ogre_Entity_clone00 );
           tolua_function(  tolua_S,  "setMaterialName",  tolua_Ogre_Ogre_Entity_setMaterialName00 );
           tolua_function(  tolua_S,  "setRenderQueueGroup",  tolua_Ogre_Ogre_Entity_setRenderQueueGroup00 );
           tolua_function(  tolua_S,  "getBoundingBox",  tolua_Ogre_Ogre_Entity_getBoundingBox00 );
           tolua_function(  tolua_S,  "getChildObjectsBoundingBox",  tolua_Ogre_Ogre_Entity_getChildObjectsBoundingBox00 );
           tolua_function(  tolua_S,  "getMovableType",  tolua_Ogre_Ogre_Entity_getMovableType00 );
           tolua_function(  tolua_S,  "getAnimationState",  tolua_Ogre_Ogre_Entity_getAnimationState00 );
           tolua_function(  tolua_S,  "getAllAnimationStates",  tolua_Ogre_Ogre_Entity_getAllAnimationStates00 );
           tolua_function(  tolua_S,  "setDisplaySkeleton",  tolua_Ogre_Ogre_Entity_setDisplaySkeleton00 );
           tolua_function(  tolua_S,  "getDisplaySkeleton",  tolua_Ogre_Ogre_Entity_getDisplaySkeleton00 );
           tolua_function(  tolua_S,  "getManualLodLevel",  tolua_Ogre_Ogre_Entity_getManualLodLevel00 );
           tolua_function(  tolua_S,  "getNumManualLodLevels",  tolua_Ogre_Ogre_Entity_getNumManualLodLevels00 );
           tolua_function(  tolua_S,  "setMeshLodBias",  tolua_Ogre_Ogre_Entity_setMeshLodBias00 );
           tolua_function(  tolua_S,  "setMaterialLodBias",  tolua_Ogre_Ogre_Entity_setMaterialLodBias00 );
           tolua_function(  tolua_S,  "setPolygonModeOverrideable",  tolua_Ogre_Ogre_Entity_setPolygonModeOverrideable00 );
           tolua_function(  tolua_S,  "attachObjectToBone",  tolua_Ogre_Ogre_Entity_attachObjectToBone00 );
           tolua_function(  tolua_S,  "attachObjectToBone",  tolua_Ogre_Ogre_Entity_attachObjectToBone01 );
           tolua_function(  tolua_S,  "attachObjectToBone",  tolua_Ogre_Ogre_Entity_attachObjectToBone02 );
           tolua_function(  tolua_S,  "detachObjectFromBone",  tolua_Ogre_Ogre_Entity_detachObjectFromBone00 );
           tolua_function(  tolua_S,  "detachObjectFromBone",  tolua_Ogre_Ogre_Entity_detachObjectFromBone01 );
           tolua_function(  tolua_S,  "detachAllObjectsFromBone",  tolua_Ogre_Ogre_Entity_detachAllObjectsFromBone00 );
           tolua_function(  tolua_S,  "getAttachedObjectIterator",  tolua_Ogre_Ogre_Entity_getAttachedObjectIterator00 );
           tolua_function(  tolua_S,  "getBoundingRadius",  tolua_Ogre_Ogre_Entity_getBoundingRadius00 );
           tolua_function(  tolua_S,  "getWorldBoundingBox",  tolua_Ogre_Ogre_Entity_getWorldBoundingBox00 );
           tolua_function(  tolua_S,  "getWorldBoundingSphere",  tolua_Ogre_Ogre_Entity_getWorldBoundingSphere00 );
           tolua_function(  tolua_S,  "setNormaliseNormals",  tolua_Ogre_Ogre_Entity_setNormaliseNormals00 );
           tolua_function(  tolua_S,  "getNormaliseNormals",  tolua_Ogre_Ogre_Entity_getNormaliseNormals00 );
           tolua_function(  tolua_S,  "hasSkeleton",  tolua_Ogre_Ogre_Entity_hasSkeleton00 );
           tolua_function(  tolua_S,  "getSkeleton",  tolua_Ogre_Ogre_Entity_getSkeleton00 );
           tolua_function(  tolua_S,  "isHardwareAnimationEnabled",  tolua_Ogre_Ogre_Entity_isHardwareAnimationEnabled00 );
           tolua_function(  tolua_S,  "getSoftwareAnimationRequests",  tolua_Ogre_Ogre_Entity_getSoftwareAnimationRequests00 );
           tolua_function(  tolua_S,  "getSoftwareAnimationNormalsRequests",  tolua_Ogre_Ogre_Entity_getSoftwareAnimationNormalsRequests00 );
           tolua_function(  tolua_S,  "addSoftwareAnimationRequest",  tolua_Ogre_Ogre_Entity_addSoftwareAnimationRequest00 );
           tolua_function(  tolua_S,  "removeSoftwareAnimationRequest",  tolua_Ogre_Ogre_Entity_removeSoftwareAnimationRequest00 );
           tolua_function(  tolua_S,  "shareSkeletonInstanceWith",  tolua_Ogre_Ogre_Entity_shareSkeletonInstanceWith00 );
           tolua_function(  tolua_S,  "hasVertexAnimation",  tolua_Ogre_Ogre_Entity_hasVertexAnimation00 );
           tolua_function(  tolua_S,  "stopSharingSkeletonInstance",  tolua_Ogre_Ogre_Entity_stopSharingSkeletonInstance00 );
           tolua_function(  tolua_S,  "sharesSkeletonInstance",  tolua_Ogre_Ogre_Entity_sharesSkeletonInstance00 );
           tolua_function(  tolua_S,  "getSkeletonInstanceSharingSet",  tolua_Ogre_Ogre_Entity_getSkeletonInstanceSharingSet00 );
           tolua_function(  tolua_S,  "refreshAvailableAnimationState",  tolua_Ogre_Ogre_Entity_refreshAvailableAnimationState00 );
           tolua_function(  tolua_S,  "_updateAnimation",  tolua_Ogre_Ogre_Entity__updateAnimation00 );
           tolua_function(  tolua_S,  "_isAnimated",  tolua_Ogre_Ogre_Entity__isAnimated00 );
           tolua_function(  tolua_S,  "_isSkeletonAnimated",  tolua_Ogre_Ogre_Entity__isSkeletonAnimated00 );
           tolua_function(  tolua_S,  "getTypeFlags",  tolua_Ogre_Ogre_Entity_getTypeFlags00 );
           tolua_constant(  tolua_S,  "BIND_ORIGINAL",  Ogre::Entity::BIND_ORIGINAL );
           tolua_constant(  tolua_S,  "BIND_SOFTWARE_SKELETAL",  Ogre::Entity::BIND_SOFTWARE_SKELETAL );
           tolua_constant(  tolua_S,  "BIND_SOFTWARE_MORPH",  Ogre::Entity::BIND_SOFTWARE_MORPH );
           tolua_constant(  tolua_S,  "BIND_HARDWARE_MORPH",  Ogre::Entity::BIND_HARDWARE_MORPH );
           tolua_function(  tolua_S,  "chooseVertexDataForBinding",  tolua_Ogre_Ogre_Entity_chooseVertexDataForBinding00 );
           tolua_function(  tolua_S,  "_getBuffersMarkedForAnimation",  tolua_Ogre_Ogre_Entity__getBuffersMarkedForAnimation00 );
           tolua_function(  tolua_S,  "_markBuffersUsedForAnimation",  tolua_Ogre_Ogre_Entity__markBuffersUsedForAnimation00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "Node",  "Ogre::Node",  "Renderable",  NULL );
           tolua_beginmodule(  tolua_S,  "Node" );
           tolua_constant(  tolua_S,  "TS_LOCAL",  Ogre::Node::TS_LOCAL );
           tolua_constant(  tolua_S,  "TS_PARENT",  Ogre::Node::TS_PARENT );
           tolua_constant(  tolua_S,  "TS_WORLD",  Ogre::Node::TS_WORLD );
           tolua_function(  tolua_S,  "getName",  tolua_Ogre_Ogre_Node_getName00 );
           tolua_function(  tolua_S,  "getParent",  tolua_Ogre_Ogre_Node_getParent00 );
           tolua_function(  tolua_S,  "getOrientation",  tolua_Ogre_Ogre_Node_getOrientation00 );
           tolua_function(  tolua_S,  "setOrientation",  tolua_Ogre_Ogre_Node_setOrientation00 );
           tolua_function(  tolua_S,  "setOrientation",  tolua_Ogre_Ogre_Node_setOrientation01 );
           tolua_function(  tolua_S,  "resetOrientation",  tolua_Ogre_Ogre_Node_resetOrientation00 );
           tolua_function(  tolua_S,  "setPosition",  tolua_Ogre_Ogre_Node_setPosition00 );
           tolua_function(  tolua_S,  "setPosition",  tolua_Ogre_Ogre_Node_setPosition01 );
           tolua_function(  tolua_S,  "getPosition",  tolua_Ogre_Ogre_Node_getPosition00 );
           tolua_function(  tolua_S,  "setScale",  tolua_Ogre_Ogre_Node_setScale00 );
           tolua_function(  tolua_S,  "setScale",  tolua_Ogre_Ogre_Node_setScale01 );
           tolua_function(  tolua_S,  "getScale",  tolua_Ogre_Ogre_Node_getScale00 );
           tolua_function(  tolua_S,  "setInheritOrientation",  tolua_Ogre_Ogre_Node_setInheritOrientation00 );
           tolua_function(  tolua_S,  "getInheritOrientation",  tolua_Ogre_Ogre_Node_getInheritOrientation00 );
           tolua_function(  tolua_S,  "setInheritScale",  tolua_Ogre_Ogre_Node_setInheritScale00 );
           tolua_function(  tolua_S,  "getInheritScale",  tolua_Ogre_Ogre_Node_getInheritScale00 );
           tolua_function(  tolua_S,  "scale",  tolua_Ogre_Ogre_Node_scale00 );
           tolua_function(  tolua_S,  "scale",  tolua_Ogre_Ogre_Node_scale01 );
           tolua_function(  tolua_S,  "translate",  tolua_Ogre_Ogre_Node_translate00 );
           tolua_function(  tolua_S,  "translate",  tolua_Ogre_Ogre_Node_translate01 );
           tolua_function(  tolua_S,  "translate",  tolua_Ogre_Ogre_Node_translate02 );
           tolua_function(  tolua_S,  "roll",  tolua_Ogre_Ogre_Node_roll00 );
           tolua_function(  tolua_S,  "pitch",  tolua_Ogre_Ogre_Node_pitch00 );
           tolua_function(  tolua_S,  "yaw",  tolua_Ogre_Ogre_Node_yaw00 );
           tolua_function(  tolua_S,  "rotate",  tolua_Ogre_Ogre_Node_rotate00 );
           tolua_function(  tolua_S,  "rotate",  tolua_Ogre_Ogre_Node_rotate01 );
           tolua_function(  tolua_S,  "getLocalAxes",  tolua_Ogre_Ogre_Node_getLocalAxes00 );
           tolua_function(  tolua_S,  "createChild",  tolua_Ogre_Ogre_Node_createChild00 );
           tolua_function(  tolua_S,  "createChild",  tolua_Ogre_Ogre_Node_createChild01 );
           tolua_function(  tolua_S,  "createChild",  tolua_Ogre_Ogre_Node_createChild02 );
           tolua_function(  tolua_S,  "createChild",  tolua_Ogre_Ogre_Node_createChild03 );
           tolua_function(  tolua_S,  "createChild",  tolua_Ogre_Ogre_Node_createChild04 );
           tolua_function(  tolua_S,  "createChild",  tolua_Ogre_Ogre_Node_createChild05 );
           tolua_function(  tolua_S,  "addChild",  tolua_Ogre_Ogre_Node_addChild00 );
           tolua_function(  tolua_S,  "numChildren",  tolua_Ogre_Ogre_Node_numChildren00 );
           tolua_function(  tolua_S,  "getChildByIndex",  tolua_Ogre_Ogre_Node_getChildByIndex00 );
           tolua_function(  tolua_S,  "getChild",  tolua_Ogre_Ogre_Node_getChild00 );
           tolua_function(  tolua_S,  "removeChild",  tolua_Ogre_Ogre_Node_removeChild00 );
           tolua_function(  tolua_S,  "removeChild",  tolua_Ogre_Ogre_Node_removeChild01 );
           tolua_function(  tolua_S,  "removeChild",  tolua_Ogre_Ogre_Node_removeChild02 );
           tolua_function(  tolua_S,  "removeAllChildren",  tolua_Ogre_Ogre_Node_removeAllChildren00 );
           tolua_function(  tolua_S,  "_getDerivedOrientation",  tolua_Ogre_Ogre_Node__getDerivedOrientation00 );
           tolua_function(  tolua_S,  "_getDerivedPosition",  tolua_Ogre_Ogre_Node__getDerivedPosition00 );
           tolua_function(  tolua_S,  "_getDerivedScale",  tolua_Ogre_Ogre_Node__getDerivedScale00 );
           tolua_function(  tolua_S,  "_getFullTransform",  tolua_Ogre_Ogre_Node__getFullTransform00 );
           tolua_function(  tolua_S,  "_update",  tolua_Ogre_Ogre_Node__update00 );
           tolua_function(  tolua_S,  "getMaterial",  tolua_Ogre_Ogre_Node_getMaterial00 );
           tolua_function(  tolua_S,  "getWorldTransforms",  tolua_Ogre_Ogre_Node_getWorldTransforms00 );
           tolua_function(  tolua_S,  "getWorldOrientation",  tolua_Ogre_Ogre_Node_getWorldOrientation00 );
           tolua_function(  tolua_S,  "getWorldPosition",  tolua_Ogre_Ogre_Node_getWorldPosition00 );
           tolua_function(  tolua_S,  "setInitialState",  tolua_Ogre_Ogre_Node_setInitialState00 );
           tolua_function(  tolua_S,  "resetToInitialState",  tolua_Ogre_Ogre_Node_resetToInitialState00 );
           tolua_function(  tolua_S,  "getInitialPosition",  tolua_Ogre_Ogre_Node_getInitialPosition00 );
           tolua_function(  tolua_S,  "getInitialOrientation",  tolua_Ogre_Ogre_Node_getInitialOrientation00 );
           tolua_function(  tolua_S,  "getInitialScale",  tolua_Ogre_Ogre_Node_getInitialScale00 );
           tolua_function(  tolua_S,  "getSquaredViewDepth",  tolua_Ogre_Ogre_Node_getSquaredViewDepth00 );
           tolua_function(  tolua_S,  "needUpdate",  tolua_Ogre_Ogre_Node_needUpdate00 );
           tolua_function(  tolua_S,  "requestUpdate",  tolua_Ogre_Ogre_Node_requestUpdate00 );
           tolua_function(  tolua_S,  "cancelUpdate",  tolua_Ogre_Ogre_Node_cancelUpdate00 );
           tolua_function(  tolua_S,  "queueNeedUpdate",  tolua_Ogre_Ogre_Node_queueNeedUpdate00 );
           tolua_function(  tolua_S,  "processQueuedUpdates",  tolua_Ogre_Ogre_Node_processQueuedUpdates00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "VisibleObjectsBoundsInfo",  "Ogre::VisibleObjectsBoundsInfo",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "VisibleObjectsBoundsInfo" );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "SceneNode",  "Ogre::SceneNode",  "Ogre::Node",  NULL );
           tolua_beginmodule(  tolua_S,  "SceneNode" );
           tolua_function(  tolua_S,  "attachObject",  tolua_Ogre_Ogre_SceneNode_attachObject00 );
           tolua_function(  tolua_S,  "numAttachedObjects",  tolua_Ogre_Ogre_SceneNode_numAttachedObjects00 );
           tolua_function(  tolua_S,  "getAttachedObject",  tolua_Ogre_Ogre_SceneNode_getAttachedObject00 );
           tolua_function(  tolua_S,  "getAttachedObject",  tolua_Ogre_Ogre_SceneNode_getAttachedObject01 );
           tolua_function(  tolua_S,  "detachObject",  tolua_Ogre_Ogre_SceneNode_detachObject00 );
           tolua_function(  tolua_S,  "detachObject",  tolua_Ogre_Ogre_SceneNode_detachObject01 );
           tolua_function(  tolua_S,  "detachObject",  tolua_Ogre_Ogre_SceneNode_detachObject02 );
           tolua_function(  tolua_S,  "detachAllObjects",  tolua_Ogre_Ogre_SceneNode_detachAllObjects00 );
           tolua_function(  tolua_S,  "isInSceneGraph",  tolua_Ogre_Ogre_SceneNode_isInSceneGraph00 );
           tolua_function(  tolua_S,  "_notifyRootNode",  tolua_Ogre_Ogre_SceneNode__notifyRootNode00 );
           tolua_function(  tolua_S,  "_update",  tolua_Ogre_Ogre_SceneNode__update00 );
           tolua_function(  tolua_S,  "_updateBounds",  tolua_Ogre_Ogre_SceneNode__updateBounds00 );
           tolua_function(  tolua_S,  "_getWorldAABB",  tolua_Ogre_Ogre_SceneNode__getWorldAABB00 );
           tolua_function(  tolua_S,  "getCreator",  tolua_Ogre_Ogre_SceneNode_getCreator00 );
           tolua_function(  tolua_S,  "removeAndDestroyChild",  tolua_Ogre_Ogre_SceneNode_removeAndDestroyChild00 );
           tolua_function(  tolua_S,  "removeAndDestroyChild",  tolua_Ogre_Ogre_SceneNode_removeAndDestroyChild01 );
           tolua_function(  tolua_S,  "removeAndDestroyAllChildren",  tolua_Ogre_Ogre_SceneNode_removeAndDestroyAllChildren00 );
           tolua_function(  tolua_S,  "showBoundingBox",  tolua_Ogre_Ogre_SceneNode_showBoundingBox00 );
           tolua_function(  tolua_S,  "getShowBoundingBox",  tolua_Ogre_Ogre_SceneNode_getShowBoundingBox00 );
           tolua_function(  tolua_S,  "createChildSceneNode",  tolua_Ogre_Ogre_SceneNode_createChildSceneNode00 );
           tolua_function(  tolua_S,  "createChildSceneNode",  tolua_Ogre_Ogre_SceneNode_createChildSceneNode01 );
           tolua_function(  tolua_S,  "createChildSceneNode",  tolua_Ogre_Ogre_SceneNode_createChildSceneNode02 );
           tolua_function(  tolua_S,  "createChildSceneNode",  tolua_Ogre_Ogre_SceneNode_createChildSceneNode03 );
           tolua_function(  tolua_S,  "createChildSceneNode",  tolua_Ogre_Ogre_SceneNode_createChildSceneNode04 );
           tolua_function(  tolua_S,  "createChildSceneNode",  tolua_Ogre_Ogre_SceneNode_createChildSceneNode05 );
           tolua_function(  tolua_S,  "setFixedYawAxis",  tolua_Ogre_Ogre_SceneNode_setFixedYawAxis00 );
           tolua_function(  tolua_S,  "setFixedYawAxis",  tolua_Ogre_Ogre_SceneNode_setFixedYawAxis01 );
           tolua_function(  tolua_S,  "yaw",  tolua_Ogre_Ogre_SceneNode_yaw00 );
           tolua_function(  tolua_S,  "setDirection",  tolua_Ogre_Ogre_SceneNode_setDirection00 );
           tolua_function(  tolua_S,  "setDirection",  tolua_Ogre_Ogre_SceneNode_setDirection01 );
           tolua_function(  tolua_S,  "setDirection",  tolua_Ogre_Ogre_SceneNode_setDirection02 );
           tolua_function(  tolua_S,  "setDirection",  tolua_Ogre_Ogre_SceneNode_setDirection03 );
           tolua_function(  tolua_S,  "lookAt",  tolua_Ogre_Ogre_SceneNode_lookAt00 );
           tolua_function(  tolua_S,  "lookAt",  tolua_Ogre_Ogre_SceneNode_lookAt01 );
           tolua_function(  tolua_S,  "setAutoTracking",  tolua_Ogre_Ogre_SceneNode_setAutoTracking00 );
           tolua_function(  tolua_S,  "setAutoTracking",  tolua_Ogre_Ogre_SceneNode_setAutoTracking01 );
           tolua_function(  tolua_S,  "setAutoTracking",  tolua_Ogre_Ogre_SceneNode_setAutoTracking02 );
           tolua_function(  tolua_S,  "getAutoTrackTarget",  tolua_Ogre_Ogre_SceneNode_getAutoTrackTarget00 );
           tolua_function(  tolua_S,  "getAutoTrackOffset",  tolua_Ogre_Ogre_SceneNode_getAutoTrackOffset00 );
           tolua_function(  tolua_S,  "getAutoTrackLocalDirection",  tolua_Ogre_Ogre_SceneNode_getAutoTrackLocalDirection00 );
           tolua_function(  tolua_S,  "getParentSceneNode",  tolua_Ogre_Ogre_SceneNode_getParentSceneNode00 );
           tolua_function(  tolua_S,  "setVisible",  tolua_Ogre_Ogre_SceneNode_setVisible00 );
           tolua_function(  tolua_S,  "flipVisibility",  tolua_Ogre_Ogre_SceneNode_flipVisibility00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_constant(  tolua_S,  "TU_STATIC",  Ogre::TU_STATIC );
           tolua_constant(  tolua_S,  "TU_DYNAMIC",  Ogre::TU_DYNAMIC );
           tolua_constant(  tolua_S,  "TU_WRITE_ONLY",  Ogre::TU_WRITE_ONLY );
           tolua_constant(  tolua_S,  "TU_STATIC_WRITE_ONLY",  Ogre::TU_STATIC_WRITE_ONLY );
           tolua_constant(  tolua_S,  "TU_DYNAMIC_WRITE_ONLY",  Ogre::TU_DYNAMIC_WRITE_ONLY );
           tolua_constant(  tolua_S,  "TU_DYNAMIC_WRITE_ONLY_DISCARDABLE",  Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE );
           tolua_constant(  tolua_S,  "TU_AUTOMIPMAP",  Ogre::TU_AUTOMIPMAP );
           tolua_constant(  tolua_S,  "TU_RENDERTARGET",  Ogre::TU_RENDERTARGET );
           tolua_constant(  tolua_S,  "TU_DEFAULT",  Ogre::TU_DEFAULT );
           tolua_constant(  tolua_S,  "TEX_TYPE_1D",  Ogre::TEX_TYPE_1D );
           tolua_constant(  tolua_S,  "TEX_TYPE_2D",  Ogre::TEX_TYPE_2D );
           tolua_constant(  tolua_S,  "TEX_TYPE_3D",  Ogre::TEX_TYPE_3D );
           tolua_constant(  tolua_S,  "TEX_TYPE_CUBE_MAP",  Ogre::TEX_TYPE_CUBE_MAP );
           tolua_constant(  tolua_S,  "MIP_UNLIMITED",  Ogre::MIP_UNLIMITED );
           tolua_constant(  tolua_S,  "MIP_DEFAULT",  Ogre::MIP_DEFAULT );
           tolua_cclass(  tolua_S,  "TexturePtr",  "Ogre::TexturePtr",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "TexturePtr" );
           tolua_function(  tolua_S,  "get",  tolua_Ogre_Ogre_TexturePtr_get00 );
           tolua_endmodule(  tolua_S );
           tolua_cclass(  tolua_S,  "Texture",  "Ogre::Texture",  "Ogre::Resource",  NULL );
           tolua_beginmodule(  tolua_S,  "Texture" );
           tolua_function(  tolua_S,  "setTextureType",  tolua_Ogre_Ogre_Texture_setTextureType00 );
           tolua_function(  tolua_S,  "getTextureType",  tolua_Ogre_Ogre_Texture_getTextureType00 );
           tolua_function(  tolua_S,  "getNumMipmaps",  tolua_Ogre_Ogre_Texture_getNumMipmaps00 );
           tolua_function(  tolua_S,  "setNumMipmaps",  tolua_Ogre_Ogre_Texture_setNumMipmaps00 );
           tolua_function(  tolua_S,  "getMipmapsHardwareGenerated",  tolua_Ogre_Ogre_Texture_getMipmapsHardwareGenerated00 );
           tolua_function(  tolua_S,  "getGamma",  tolua_Ogre_Ogre_Texture_getGamma00 );
           tolua_function(  tolua_S,  "setGamma",  tolua_Ogre_Ogre_Texture_setGamma00 );
           tolua_function(  tolua_S,  "getHeight",  tolua_Ogre_Ogre_Texture_getHeight00 );
           tolua_function(  tolua_S,  "getWidth",  tolua_Ogre_Ogre_Texture_getWidth00 );
           tolua_function(  tolua_S,  "getDepth",  tolua_Ogre_Ogre_Texture_getDepth00 );
           tolua_function(  tolua_S,  "getSrcHeight",  tolua_Ogre_Ogre_Texture_getSrcHeight00 );
           tolua_function(  tolua_S,  "getSrcWidth",  tolua_Ogre_Ogre_Texture_getSrcWidth00 );
           tolua_function(  tolua_S,  "getSrcDepth",  tolua_Ogre_Ogre_Texture_getSrcDepth00 );
           tolua_function(  tolua_S,  "setHeight",  tolua_Ogre_Ogre_Texture_setHeight00 );
           tolua_function(  tolua_S,  "setWidth",  tolua_Ogre_Ogre_Texture_setWidth00 );
           tolua_function(  tolua_S,  "setDepth",  tolua_Ogre_Ogre_Texture_setDepth00 );
           tolua_function(  tolua_S,  "getUsage",  tolua_Ogre_Ogre_Texture_getUsage00 );
           tolua_function(  tolua_S,  "setUsage",  tolua_Ogre_Ogre_Texture_setUsage00 );
           tolua_function(  tolua_S,  "copyToTexture",  tolua_Ogre_Ogre_Texture_copyToTexture00 );
           tolua_function(  tolua_S,  "loadImage",  tolua_Ogre_Ogre_Texture_loadImage00 );
           tolua_function(  tolua_S,  "hasAlpha",  tolua_Ogre_Ogre_Texture_hasAlpha00 );
           tolua_function(  tolua_S,  "setDesiredIntegerBitDepth",  tolua_Ogre_Ogre_Texture_setDesiredIntegerBitDepth00 );
           tolua_function(  tolua_S,  "getDesiredIntegerBitDepth",  tolua_Ogre_Ogre_Texture_getDesiredIntegerBitDepth00 );
           tolua_function(  tolua_S,  "setDesiredFloatBitDepth",  tolua_Ogre_Ogre_Texture_setDesiredFloatBitDepth00 );
           tolua_function(  tolua_S,  "getDesiredFloatBitDepth",  tolua_Ogre_Ogre_Texture_getDesiredFloatBitDepth00 );
           tolua_function(  tolua_S,  "setDesiredBitDepths",  tolua_Ogre_Ogre_Texture_setDesiredBitDepths00 );
           tolua_function(  tolua_S,  "setTreatLuminanceAsAlpha",  tolua_Ogre_Ogre_Texture_setTreatLuminanceAsAlpha00 );
           tolua_function(  tolua_S,  "getTreatLuminanceAsAlpha",  tolua_Ogre_Ogre_Texture_getTreatLuminanceAsAlpha00 );
           tolua_function(  tolua_S,  "getNumFaces",  tolua_Ogre_Ogre_Texture_getNumFaces00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "TextureManager",  "Ogre::TextureManager",  "Ogre::ResourceManager",  NULL );
           tolua_beginmodule(  tolua_S,  "TextureManager" );
           tolua_function(  tolua_S,  "setDefaultNumMipmaps",  tolua_Ogre_Ogre_TextureManager_setDefaultNumMipmaps00 );
           tolua_function(  tolua_S,  "getDefaultNumMipmaps",  tolua_Ogre_Ogre_TextureManager_getDefaultNumMipmaps00 );
           tolua_function(  tolua_S,  "getSingleton",  tolua_Ogre_Ogre_TextureManager_getSingleton00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "AxisAlignedBox",  "Ogre::AxisAlignedBox",  "",  tolua_collect_Ogre__AxisAlignedBox );
           #else
           tolua_cclass(  tolua_S,  "AxisAlignedBox",  "Ogre::AxisAlignedBox",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "AxisAlignedBox" );
           tolua_constant(  tolua_S,  "FAR_LEFT_BOTTOM",  Ogre::AxisAlignedBox::FAR_LEFT_BOTTOM );
           tolua_constant(  tolua_S,  "FAR_LEFT_TOP",  Ogre::AxisAlignedBox::FAR_LEFT_TOP );
           tolua_constant(  tolua_S,  "FAR_RIGHT_TOP",  Ogre::AxisAlignedBox::FAR_RIGHT_TOP );
           tolua_constant(  tolua_S,  "FAR_RIGHT_BOTTOM",  Ogre::AxisAlignedBox::FAR_RIGHT_BOTTOM );
           tolua_constant(  tolua_S,  "NEAR_RIGHT_BOTTOM",  Ogre::AxisAlignedBox::NEAR_RIGHT_BOTTOM );
           tolua_constant(  tolua_S,  "NEAR_LEFT_BOTTOM",  Ogre::AxisAlignedBox::NEAR_LEFT_BOTTOM );
           tolua_constant(  tolua_S,  "NEAR_LEFT_TOP",  Ogre::AxisAlignedBox::NEAR_LEFT_TOP );
           tolua_constant(  tolua_S,  "NEAR_RIGHT_TOP",  Ogre::AxisAlignedBox::NEAR_RIGHT_TOP );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_AxisAlignedBox_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_AxisAlignedBox_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_AxisAlignedBox_new00_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_AxisAlignedBox_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_AxisAlignedBox_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_AxisAlignedBox_new01_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_AxisAlignedBox_new02 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_AxisAlignedBox_new02_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_AxisAlignedBox_new02_local );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_AxisAlignedBox_new03 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_AxisAlignedBox_new03_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_AxisAlignedBox_new03_local );
           tolua_function(  tolua_S,  "delete",  tolua_Ogre_Ogre_AxisAlignedBox_delete00 );
           tolua_function(  tolua_S,  "getMinimum",  tolua_Ogre_Ogre_AxisAlignedBox_getMinimum00 );
           tolua_function(  tolua_S,  "getMinimum",  tolua_Ogre_Ogre_AxisAlignedBox_getMinimum01 );
           tolua_function(  tolua_S,  "getMaximum",  tolua_Ogre_Ogre_AxisAlignedBox_getMaximum00 );
           tolua_function(  tolua_S,  "getMaximum",  tolua_Ogre_Ogre_AxisAlignedBox_getMaximum01 );
           tolua_function(  tolua_S,  "setMinimum",  tolua_Ogre_Ogre_AxisAlignedBox_setMinimum00 );
           tolua_function(  tolua_S,  "setMinimum",  tolua_Ogre_Ogre_AxisAlignedBox_setMinimum01 );
           tolua_function(  tolua_S,  "setMinimumX",  tolua_Ogre_Ogre_AxisAlignedBox_setMinimumX00 );
           tolua_function(  tolua_S,  "setMinimumY",  tolua_Ogre_Ogre_AxisAlignedBox_setMinimumY00 );
           tolua_function(  tolua_S,  "setMinimumZ",  tolua_Ogre_Ogre_AxisAlignedBox_setMinimumZ00 );
           tolua_function(  tolua_S,  "setMaximum",  tolua_Ogre_Ogre_AxisAlignedBox_setMaximum00 );
           tolua_function(  tolua_S,  "setMaximum",  tolua_Ogre_Ogre_AxisAlignedBox_setMaximum01 );
           tolua_function(  tolua_S,  "setMaximumX",  tolua_Ogre_Ogre_AxisAlignedBox_setMaximumX00 );
           tolua_function(  tolua_S,  "setMaximumY",  tolua_Ogre_Ogre_AxisAlignedBox_setMaximumY00 );
           tolua_function(  tolua_S,  "setMaximumZ",  tolua_Ogre_Ogre_AxisAlignedBox_setMaximumZ00 );
           tolua_function(  tolua_S,  "setExtents",  tolua_Ogre_Ogre_AxisAlignedBox_setExtents00 );
           tolua_function(  tolua_S,  "setExtents",  tolua_Ogre_Ogre_AxisAlignedBox_setExtents01 );
           tolua_function(  tolua_S,  "getCorner",  tolua_Ogre_Ogre_AxisAlignedBox_getCorner00 );
           tolua_function(  tolua_S,  "merge",  tolua_Ogre_Ogre_AxisAlignedBox_merge00 );
           tolua_function(  tolua_S,  "merge",  tolua_Ogre_Ogre_AxisAlignedBox_merge01 );
           tolua_function(  tolua_S,  "transform",  tolua_Ogre_Ogre_AxisAlignedBox_transform00 );
           tolua_function(  tolua_S,  "transformAffine",  tolua_Ogre_Ogre_AxisAlignedBox_transformAffine00 );
           tolua_function(  tolua_S,  "setNull",  tolua_Ogre_Ogre_AxisAlignedBox_setNull00 );
           tolua_function(  tolua_S,  "isNull",  tolua_Ogre_Ogre_AxisAlignedBox_isNull00 );
           tolua_function(  tolua_S,  "isFinite",  tolua_Ogre_Ogre_AxisAlignedBox_isFinite00 );
           tolua_function(  tolua_S,  "setInfinite",  tolua_Ogre_Ogre_AxisAlignedBox_setInfinite00 );
           tolua_function(  tolua_S,  "isInfinite",  tolua_Ogre_Ogre_AxisAlignedBox_isInfinite00 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_AxisAlignedBox_intersects00 );
           tolua_function(  tolua_S,  "intersection",  tolua_Ogre_Ogre_AxisAlignedBox_intersection00 );
           tolua_function(  tolua_S,  "volume",  tolua_Ogre_Ogre_AxisAlignedBox_volume00 );
           tolua_function(  tolua_S,  "scale",  tolua_Ogre_Ogre_AxisAlignedBox_scale00 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_AxisAlignedBox_intersects01 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_AxisAlignedBox_intersects02 );
           tolua_function(  tolua_S,  "intersects",  tolua_Ogre_Ogre_AxisAlignedBox_intersects03 );
           tolua_function(  tolua_S,  "getCenter",  tolua_Ogre_Ogre_AxisAlignedBox_getCenter00 );
           tolua_function(  tolua_S,  "getSize",  tolua_Ogre_Ogre_AxisAlignedBox_getSize00 );
           tolua_function(  tolua_S,  "getHalfSize",  tolua_Ogre_Ogre_AxisAlignedBox_getHalfSize00 );
           tolua_function(  tolua_S,  "contains",  tolua_Ogre_Ogre_AxisAlignedBox_contains00 );
           tolua_function(  tolua_S,  "contains",  tolua_Ogre_Ogre_AxisAlignedBox_contains01 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "ColourValue",  "Ogre::ColourValue",  "",  tolua_collect_Ogre__ColourValue );
           #else
           tolua_cclass(  tolua_S,  "ColourValue",  "Ogre::ColourValue",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "ColourValue" );
           tolua_variable(  tolua_S,  "ZERO",  tolua_get_Ogre__ColourValue_ZERO,  NULL );
           tolua_variable(  tolua_S,  "Black",  tolua_get_Ogre__ColourValue_Black,  NULL );
           tolua_variable(  tolua_S,  "White",  tolua_get_Ogre__ColourValue_White,  NULL );
           tolua_variable(  tolua_S,  "Red",  tolua_get_Ogre__ColourValue_Red,  NULL );
           tolua_variable(  tolua_S,  "Green",  tolua_get_Ogre__ColourValue_Green,  NULL );
           tolua_variable(  tolua_S,  "Blue",  tolua_get_Ogre__ColourValue_Blue,  NULL );
           tolua_function(  tolua_S,  "new",  tolua_Ogre_Ogre_ColourValue_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Ogre_Ogre_ColourValue_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Ogre_Ogre_ColourValue_new00_local );
           tolua_variable(  tolua_S,  "r",  tolua_get_Ogre__ColourValue_r,  tolua_set_Ogre__ColourValue_r );
           tolua_variable(  tolua_S,  "g",  tolua_get_Ogre__ColourValue_g,  tolua_set_Ogre__ColourValue_g );
           tolua_variable(  tolua_S,  "b",  tolua_get_Ogre__ColourValue_b,  tolua_set_Ogre__ColourValue_b );
           tolua_variable(  tolua_S,  "a",  tolua_get_Ogre__ColourValue_a,  tolua_set_Ogre__ColourValue_a );
           tolua_function(  tolua_S,  "getAsRGBA",  tolua_Ogre_Ogre_ColourValue_getAsRGBA00 );
           tolua_function(  tolua_S,  "getAsARGB",  tolua_Ogre_Ogre_ColourValue_getAsARGB00 );
           tolua_function(  tolua_S,  "getAsBGRA",  tolua_Ogre_Ogre_ColourValue_getAsBGRA00 );
           tolua_function(  tolua_S,  "getAsABGR",  tolua_Ogre_Ogre_ColourValue_getAsABGR00 );
           tolua_function(  tolua_S,  "setAsRGBA",  tolua_Ogre_Ogre_ColourValue_setAsRGBA00 );
           tolua_function(  tolua_S,  "setAsARGB",  tolua_Ogre_Ogre_ColourValue_setAsARGB00 );
           tolua_function(  tolua_S,  "setAsBGRA",  tolua_Ogre_Ogre_ColourValue_setAsBGRA00 );
           tolua_function(  tolua_S,  "setAsABGR",  tolua_Ogre_Ogre_ColourValue_setAsABGR00 );
           tolua_function(  tolua_S,  "saturate",  tolua_Ogre_Ogre_ColourValue_saturate00 );
           tolua_function(  tolua_S,  "saturateCopy",  tolua_Ogre_Ogre_ColourValue_saturateCopy00 );
           tolua_function(  tolua_S,  ".add",  tolua_Ogre_Ogre_ColourValue__add00 );
           tolua_function(  tolua_S,  ".sub",  tolua_Ogre_Ogre_ColourValue__sub00 );
           tolua_function(  tolua_S,  ".div",  tolua_Ogre_Ogre_ColourValue__div00 );
           tolua_function(  tolua_S,  ".div",  tolua_Ogre_Ogre_ColourValue__div01 );
           tolua_function(  tolua_S,  "setHSB",  tolua_Ogre_Ogre_ColourValue_setHSB00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ogre",  0 );
           tolua_beginmodule(  tolua_S,  "Ogre" );
           tolua_cclass(  tolua_S,  "Root",  "Ogre::Root",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Root" );
           tolua_function(  tolua_S,  "saveConfig",  tolua_Ogre_Ogre_Root_saveConfig00 );
           tolua_function(  tolua_S,  "restoreConfig",  tolua_Ogre_Ogre_Root_restoreConfig00 );
           tolua_function(  tolua_S,  "showConfigDialog",  tolua_Ogre_Ogre_Root_showConfigDialog00 );
           tolua_function(  tolua_S,  "isInitialised",  tolua_Ogre_Ogre_Root_isInitialised00 );
           tolua_function(  tolua_S,  "getTextureManager",  tolua_Ogre_Ogre_Root_getTextureManager00 );
           tolua_function(  tolua_S,  "getMeshManager",  tolua_Ogre_Ogre_Root_getMeshManager00 );
           tolua_function(  tolua_S,  "getErrorDescription",  tolua_Ogre_Ogre_Root_getErrorDescription00 );
           tolua_function(  tolua_S,  "addFrameListener",  tolua_Ogre_Ogre_Root_addFrameListener00 );
           tolua_function(  tolua_S,  "removeFrameListener",  tolua_Ogre_Ogre_Root_removeFrameListener00 );
           tolua_function(  tolua_S,  "convertColourValue",  tolua_Ogre_Ogre_Root_convertColourValue00 );
           tolua_function(  tolua_S,  "getTimer",  tolua_Ogre_Ogre_Root_getTimer00 );
           tolua_function(  tolua_S,  "getCurrentFrameNumber",  tolua_Ogre_Ogre_Root_getCurrentFrameNumber00 );
           tolua_function(  tolua_S,  "getSingleton",  tolua_Ogre_Ogre_Root_getSingleton00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           return 1;
          }
          
          
          #if defined(  LUA_VERSION_NUM ) && LUA_VERSION_NUM >= 501
   18993   TOLUA_API int luaopen_Ogre (  lua_State* tolua_S ) {
           return tolua_Ogre_open(  tolua_S );
          };
          #endif
          

./components/ogre/scripting/bindings/lua/ogre/required.h

       1  #include "../../../../OgreIncludes.h"
          #include <OgreResourceManager.h>
          
          #define ushort unsigned short
          #define uint unsigned int

./components/ogre/scripting/bindings/lua/required.h

       1  #include <SDL.h>
          
          #include <sigc++/sigc++.h>
          
          // #include <Eris/View.h>
          
          #include "components/ogre/AvatarController.h"
          #include "components/ogre/Avatar.h"
          #include "components/ogre/AvatarCamera.h"
          #include "components/ogre/EmberOgre.h"
          
          #include "components/ogre/EmberEntityFactory.h"
          
          #include "components/ogre/EmberEntity.h"
          #include "components/ogre/EmberPhysicalEntity.h"
          // #include "components/ogre/PersonEmberEntity.h"
          #include "components/ogre/AvatarEmberEntity.h"
          #include "components/ogre/WorldEmberEntity.h"
          
          #include "components/ogre/environment/Environment.h"
          
          #include "components/ogre/MousePicker.h"
          
          #include "components/ogre/MotionManager.h"
          #include "components/ogre/GUIManager.h"
          #include "components/ogre/terrain/TerrainGenerator.h"
          #include "components/ogre/terrain/TerrainEditor.h"
          #include "components/ogre/terrain/TerrainArea.h"
          
          #include "components/ogre/model/Model.h"
          #include "components/ogre/model/SubModel.h"
          
          #include "components/ogre/widgets/Widget.h"
          
          #include "components/ogre/input/Input.h"
          
          #include "components/ogre/jesus/Jesus.h"
          
          #include "components/ogre/MathConverter.h"
          
          #include "components/ogre/widgets/MovableObjectRenderer.h"
          #include "components/ogre/widgets/OgreEntityRenderer.h"
          #include "components/ogre/widgets/ModelRenderer.h"
          #include "components/ogre/widgets/ListHolder.h"
          #include "components/ogre/widgets/Vector3Adapter.h"
          #include "components/ogre/widgets/QuaternionAdapter.h"
          #include "components/ogre/widgets/EntityEditor.h"
          #include "components/ogre/widgets/StackableContainer.h"
          #include "components/ogre/widgets/ConsoleAdapter.h"
          #include "components/ogre/widgets/ColouredListItem.h"
          #include "components/ogre/widgets/adapters/atlas/MapAdapter.h"
          
          #include "components/ogre/widgets/IconBar.h"
          #include "components/ogre/widgets/IconBase.h"
          //#include "components/ogre/widgets/MaterialPicker.h"
          
          #include "components/ogre/model/Model.h"
          #include "components/ogre/model/ModelDefinition.h"
          #include "components/ogre/model/ModelDefinitionManager.h"
          
          #include "components/ogre/IWorldPickListener.h"
          #include "components/ogre/EntityWorldPickListener.h"
          
          #include "components/ogre/manipulation/EntityMoveManager.h"
          
          #include "components/ogre/OgreInfo.h"
          
          #include "components/ogre/widgets/icons/Icon.h"
          #include "components/ogre/widgets/icons/IconManager.h"
          
          #include "components/ogre/widgets/EntityIconSlot.h"
          #include "components/ogre/widgets/EntityIcon.h"
          #include "components/ogre/widgets/EntityIconManager.h"
          #include "components/ogre/widgets/EntityIconDragDropTarget.h"
          
          #include "components/ogre/AttributeObserver.h"
          
          //#include "components/ogre/scripting/LuaConnector.h"
          //#include "LuaConnector.h"
          
          // Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->EventChangedConfigItem.connect(  sigc::mem_fun(  *this,   &AvatarCamera::ConfigService_EventChangedConfigItem ) );

./components/ogre/sound/OgreSoundProvider.cpp

       1  //
          // C++ Implementation: OgreSoundScriptingProvider
          //
          // Description:
          //
          //
          // Author: Miguel Guzman <aglanor@gmail.com>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "../EmberOgrePrerequisites.h"
          
          #include <OgreString.h>
          
          #include "framework/Exception.h"
          
          #include "OgreSoundProvider.h"
          
          namespace EmberOgre {
          
      33  OgreSoundProvider::OgreSoundProvider(   )
          {
          
          }
          
          
      39  OgreSoundProvider::~OgreSoundProvider(   )
          {
          }
          
      43  void OgreSoundProvider::loadSound(  const std::string& soundName )
          {
           S_LOG_INFO(  "Loading sound" )
          }
          
      48  bool OgreSoundProvider::willLoadSound(  const std::string& soundName )
          {
           return false;
          }
          
      53  const std::string& OgreSoundProvider::getName(   ) const
          {
           static std::string name = "OgreSoundProvider";
           return name;
          }
          
      59  void OgreSoundProvider::_registerWithService(  Ember::SoundService* service )
          {
           this->service = service;
          }
          
          }

./components/ogre/sound/OgreSoundProvider.h

       1  //
          // C++ Interface: OgreSoundProvider
          //
          // Description:
          //
          //
          // Author: Miguel Guzman <aglanor@gmail.com>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRESOUNDPROVIDER_H
          #define EMBEROGRESOUNDPROVIDER_H
          
          #include "framework/ISoundProvider.h"
          
          namespace Ember
          {
      30   class SoundService;
          }
          
          namespace EmberOgre {
          
          /**
          @author Miguel Guzman
          */
      38  class OgreSoundProvider : public Ember::ISoundProvider
          {
          public:
      41   OgreSoundProvider(   );
          
      43   ~OgreSoundProvider(   );
          
           /**
           * Loads the script.
           * @param soundName
           */
      49   virtual void loadSound(  const std::string& scriptName );
          
           /**
           * Returns true if the provider will load the supplied script name. This is in most cases decided from the filename suffix.
           * @param scriptName
           * @return
           */
          
      57   virtual bool willLoadSound(  const std::string& scriptName );
          
          
           /**
           * Gets the unique name of the sound provider.
           * @return
           */
      64   virtual const std::string& getName(   ) const;
          
           /**
           * Register with a service to allow for callbacks etc.
           * @param service
           */
      70   virtual void _registerWithService(  Ember::SoundService* service );
          
           // TODO: here go non-interface methods
          
          private:
          
      76   Ember::SoundService* service;
          
          
          
          };
          
          }
          
          #endif

./components/ogre/terrain/ISceneManagerAdapter.h

       1  //
          // C++ Interface: ISceneManagerAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          namespace Ogre
          {
      26  class SceneManager;
      27  class Camera;
          }
          
          namespace EmberOgre {
          namespace Terrain {
          
      33  class ISceneManagerAdapter
          {
          public:
          
      37   virtual ~ISceneManagerAdapter(   ) {}
          
      39   virtual int getPageSize(   ) = 0;
      40   virtual Ogre::Real getHeightAt(  const Ogre::Real x,   const Ogre::Real z ) = 0;
          
      42   virtual void setWorldPagesDimensions(  int numberOfPagesHeight,   int numberOfPagesWidth,   int heightOffsetInPages,   int widthOffsetInPages ) = 0;
          
      44   virtual void setCamera(  Ogre::Camera* camera ) = 0;
      45   virtual void setResourceGroupName(  const std::string& groupName ) = 0;
      46   virtual void loadOptions(  const std::string& filePath ) = 0;
      47   virtual void resize(  Ogre::AxisAlignedBox newSize,   int levels ) = 0;
      48   virtual void loadScene(   ) = 0;
          
      50   virtual void setOption(  const std::string& strKey,   const void* pValue ) = 0;
      51   virtual void getOption(  const std::string& strKey,   void* pDestValue ) = 0;
          
      53   virtual Ogre::SceneManager* getSceneManager(   ) const = 0;
          
      55   virtual void reloadAllPages(   ) = 0;
      56   virtual void reloadPage(  unsigned int x,   unsigned int z ) = 0;
          };
          }
          }

./components/ogre/terrain/TerrainArea.cpp

       1  //
          // C++ Implementation: TerrainArea
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "TerrainArea.h"
          
          #include "../EmberEntity.h"
          #include <Mercator/Area.h>
          
          namespace EmberOgre {
          namespace Terrain {
          
      31  TerrainArea::TerrainArea(  EmberEntity* entity ) : mArea(  0 ),   mEntity(  entity )
          {
          }
          
          
      36  TerrainArea::~TerrainArea(   )
          {
          }
          
      40  bool TerrainArea::init(   ) {
          
           // _fpreset(   );
           //_controlfp(  _PC_64,   _MCW_PC );
           //_controlfp(  _RC_NEAR ,   _MCW_RC );
          
           observeEntity(   );
           return parseArea(   );
          
          }
          
      51  bool TerrainArea::parseArea(   )
          {
           if (  !mEntity->hasAttr(  "area" ) ) {
           S_LOG_FAILURE(  "AreaModel defined on entity with no area attribute" );
           return false;
           }
          
           const Atlas::Message::MapType& areaData(  mEntity->valueOfAttr(  "area" ).asMap(   ) );
           Atlas::Message::MapType::const_iterator it = areaData.find(  "points" );
           if (  (  it == areaData.end(   ) ) || !it->second.isList(   ) ) {
           S_LOG_FAILURE(  "malformed area attribute on entity,   no points data" );
           return false;
           }
          
           const Atlas::Message::ListType& pointsData(  it->second.asList(   ) );
           it = areaData.find(  "layer" );
           if (  (  it == areaData.end(   ) ) || !it->second.isInt(   ) ) {
           S_LOG_FAILURE(  "malformed area attribute on entity,   no layer data" );
           return false;
           }
          
           int layer = it->second.asInt(   );
           if (  !mArea ) {
           mArea = new Mercator::Area(  layer,   false );
           }
          
           WFMath::Polygon<2> poly;
           for (  size_t p=0; p<pointsData.size(   ); ++p ) {
           if (  !pointsData[p].isList(   ) ) {
           S_LOG_FAILURE(  "skipped malformed point in area" );
           continue;
           }
          
           const Atlas::Message::ListType& point(  pointsData[p].asList(   ) );
           if (  (  point.size(   ) < 2 ) || !point[0].isNum(   ) || !point[1].isNum(   ) ) {
           S_LOG_FAILURE(  "skipped malformed point in area" );
           continue;
           }
          
           WFMath::Point<2> wpt(  point[0].asNum(   ),   point[1].asNum(   ) );
           poly.addCorner(  poly.numCorners(   ),   wpt );
           }
           // transform polygon into terrain coords
           WFMath::Vector<3> xVec = WFMath::Vector<3>(  1.0,   0.0,   0.0 ).rotate(  mEntity->getOrientation(   ) );
           double theta = atan2(  xVec.y(   ),   xVec.x(   ) ); // rotation about Z
          
           WFMath::RotMatrix<2> rm;
           poly.rotatePoint(  rm.rotation(  theta ),   WFMath::Point<2>(  0,  0 ) );
           poly.shift(  WFMath::Vector<2>(  mEntity->getPosition(   ).x(   ),   mEntity->getPosition(   ).y(   ) ) );
          
           //poly.shift(  WFMath::Vector<2>(  -10,  -10 ) );
          
          /* for (  int i = 0; i < poly.numCorners(   );++i ) {
           WFMath::Point<2> wpt = poly.getCorner(  i );
           int j = 0;
           }*/
          
           if (  poly.numCorners(   ) ) {
           mArea->setShape(  poly );
           }
          
           return true;
          }
          
     115  void TerrainArea::attributeChanged(  const Atlas::Message::Element& attributeValue )
          {
           if (  parseArea(   ) ) {
           EventAreaChanged(  this );
           }
          }
          
     122  void TerrainArea::entity_Moved(   )
          {
           if (  parseArea(   ) ) {
           EventAreaChanged(  this );
           }
          }
          
     129  void TerrainArea::observeEntity(   )
          {
           mAttrChangedSlot.disconnect(   );
           if (  mEntity ) {
           mAttrChangedSlot = sigc::mem_fun(  *this,   &TerrainArea::attributeChanged );
           mEntity->observe(  "area",   mAttrChangedSlot );
           mEntity->Moved.connect(  sigc::mem_fun(  *this,   &TerrainArea::entity_Moved ) );
           }
          }
          
          }
          }

./components/ogre/terrain/TerrainArea.h

       1  //
          // C++ Interface: TerrainArea
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRETERRAINAREA_H
          #define EMBEROGRETERRAINAREA_H
          
          #include <sigc++/signal.h>
          #include <Eris/Entity.h>
          
          namespace Mercator
          {
      31   class Area;
          }
          
          namespace EmberOgre {
          
      36  class EmberEntity;
          
          namespace Terrain {
          
          /**
          @author Erik Hjortsberg
          */
      43  class TerrainArea
          {
          public:
      46   TerrainArea(  EmberEntity* entity );
          
      48   ~TerrainArea(   );
      49   bool init(   );
          
      51   inline Mercator::Area* getArea(   ) const;
      52   inline void setArea(  Mercator::Area* area );
          
      54   sigc::signal<void,   TerrainArea*> EventAreaChanged;
          
          protected:
          
      58   Mercator::Area* mArea;
      59   EmberEntity* mEntity;
      60   Eris::Entity::AttrChangedSlot mAttrChangedSlot;
          
      62   void attributeChanged(  const Atlas::Message::Element& attributeValue );
      63   void entity_Moved(   );
      64   void observeEntity(   );
      65   bool parseArea(   );
          
          };
          
      69  Mercator::Area* TerrainArea::getArea(   ) const { return mArea; }
      70  void TerrainArea::setArea(  Mercator::Area* area ) { mArea = area; }
          
          }
          };
          
          #endif

./components/ogre/terrain/TerrainEditor.cpp

          //
          // C++ Implementation: TerrainEditor
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "TerrainEditor.h"
          #include "../EmberOgrePrerequisites.h"
          #include "../EmberOgre.h"
          #include "../Avatar.h"
          #include "TerrainGenerator.h"
          #include "../AvatarCamera.h"
          #include "../GUIManager.h"
          
          #include <Atlas/Objects/Entity.h>
          #include <Atlas/Objects/Operation.h>
          
          #include <Eris/Connection.h>
          
          #include "../EmberEntity.h"
          #include "../WorldEmberEntity.h"
          #include "../EmberPhysicalEntity.h"
          #include "../AvatarEmberEntity.h"
          
          #include "../EmberEntityFactory.h"
          
          
          #include "services/EmberServices.h"
          #include "services/server/ServerService.h"
          #include "ISceneManagerAdapter.h"
          
          #include "../MousePicker.h"
          
          
          namespace EmberOgre {
          namespace Terrain {
          
      54  const std::string BasePointUserObject::s_TypeName(  "BasePointMarker" );
          
          
      57  BasePointUserObject::BasePointUserObject(  const TerrainPosition terrainPosition,  const Mercator::BasePoint& basePoint,   Ogre::SceneNode* basePointMarkerNode ) : mBasePoint(  basePoint ),   mBasePointMarkerNode(  basePointMarkerNode ),   mPosition(  terrainPosition )
          {
          }
          
      61  const Ogre::String & BasePointUserObject::getTypeName (  void ) const
          {
           return s_TypeName;
          }
          
      66  const Mercator::BasePoint& BasePointUserObject::getBasePoint(   ) const
          {
           return mBasePoint;
          }
          
      71  Ogre::SceneNode* BasePointUserObject::getBasePointMarkerNode(   ) const
          {
           return mBasePointMarkerNode;
          }
          
      76  const TerrainPosition& BasePointUserObject::getPosition(   ) const
          {
           return mPosition;
          }
          
      81  float BasePointUserObject::getHeight(   ) const
          {
           return getBasePointMarkerNode(   )->getPosition(   ).y;
          }
          
      86  void BasePointUserObject::translate(  Ogre::Real verticalMovement )
          {
           getBasePointMarkerNode(   )->translate(  Ogre::Vector3(  0,  verticalMovement,  0 ) );
           markAsMoved(   );
           EventUpdatedPosition(   );
          }
          
      93  void BasePointUserObject::setHeight(  Ogre::Real height )
          {
           Ogre::Vector3 position = getBasePointMarkerNode(   )->getPosition(   );
           getBasePointMarkerNode(   )->setPosition(  position.x,   height,   position.z );
           markAsMoved(   );
           EventUpdatedPosition(   );
          }
          
     101  void BasePointUserObject::markAsMoved(   )
          {
           Ogre::Entity* entity = static_cast<Ogre::Entity*>(  getBasePointMarkerNode(   )->getAttachedObject(  0 ) );
           entity->setMaterialName(  "BasePointMarkerMovedMaterial" );
          }
          
     107  void BasePointUserObject::resetMarking(   )
          {
           Ogre::Entity* entity = static_cast<Ogre::Entity*>(  getBasePointMarkerNode(   )->getAttachedObject(  0 ) );
           entity->setMaterialName(  "BasePointMarkerMaterial" );
          }
          
     113  BasePointPickListener::BasePointPickListener(  TerrainEditor* terrainEditor )
          : mTerrainEditor(  terrainEditor ),   mPickedUserObject(  0 )
          {
          
          }
          
     119  void BasePointPickListener::processPickResult(  bool& continuePicking,   Ogre::RaySceneQueryResultEntry& entry,   Ogre::Ray& cameraRay,   const MousePickerArgs& mousePickerArgs )
          {
           if (  entry.movable ) {
           Ogre::MovableObject* pickedMovable = entry.movable;
           if (  pickedMovable->isVisible(   ) && pickedMovable->getUserObject(   ) != 0 && pickedMovable->getUserObject(   )->getTypeName(   ) == BasePointUserObject::s_TypeName ) {
           mPickedUserObject = static_cast<BasePointUserObject*>(  pickedMovable->getUserObject(   ) );
           continuePicking = false;
           }
           }
          }
          
     130  void BasePointPickListener::initializePickingContext(   )
          {
           mPickedUserObject = 0;
          }
          
     135  void BasePointPickListener::endPickingContext(  const MousePickerArgs& mousePickerArgs )
          {
           if (  mPickedUserObject ) {
           mTerrainEditor->pickedBasePoint(  mPickedUserObject );
           }
          }
          
          
     143  TerrainEditBasePointMovement::TerrainEditBasePointMovement(  Ogre::Real verticalMovement,   TerrainPosition position )
          : mVerticalMovement(  verticalMovement ),   mPosition(  position )
          {
          }
          
     148  Ogre::Real TerrainEditBasePointMovement::getVerticalMovement(   ) const
          {
           return mVerticalMovement;
          }
          
     153  const TerrainPosition& TerrainEditBasePointMovement::getPosition(   ) const
          {
           return mPosition;
          
          }
          
          
     160  TerrainEditor::TerrainEditor(   ) : mPickListener(  this ),   mCurrentUserObject(  0 ),  mOverlayNode(  0 ),   mVisible(  false )
          {
           ///create a material which will be used for base points (  this will be blue )
           if (  !Ogre::MaterialManager::getSingleton(   ).resourceExists(  "BasePointMarkerMaterial" ) ) {
           Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton(   ).create(  "BasePointMarkerMaterial",   "General" ) );
          
           material->setDiffuse(  0,  0,  1,  1 );
           material->setAmbient(  0,  0,  1 );
           material->setSelfIllumination(  0,  0,  1 );
           //material->setLightingEnabled(  false );
           material->setFog(  true );
           }
           ///create a material which will be used for base points that have been moved (  this will be red )
           if (  !Ogre::MaterialManager::getSingleton(   ).resourceExists(  "BasePointMarkerMovedMaterial" ) ) {
           Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton(   ).create(  "BasePointMarkerMovedMaterial",   "General" ) );
          
           material->setDiffuse(  1,  0,  0,  1 );
           material->setAmbient(  1,  0,  0 );
           material->setSelfIllumination(  1,  0,  0 );
           //material->setLightingEnabled(  false );
           material->setFog(  true );
           }
          // createOverlay(   );
           //hideOverlay(   );
          }
          
          
     187  TerrainEditor::~TerrainEditor(   )
          {
          }
          
     191  void TerrainEditor::showOverlay(   )
          {
           mVisible = true;
           if (  mOverlayNode ) {
           mOverlayNode->setVisible(  true,   true );
           }
          
          }
          
     200  void TerrainEditor::hideOverlay(   )
          {
           mVisible = false;
           if (  mOverlayNode ) {
           mOverlayNode->setVisible(  false,   true );
           }
          }
          
     208  bool TerrainEditor::isOverlayShown(   ) const
          {
          
           return mOverlayNode != 0 && mVisible;
          }
          
     214  void TerrainEditor::createOverlay(   )
          {
           if (  !mOverlayNode ) {
          
           mOverlayNode = EmberOgre::getSingleton(   ).getWorldSceneNode(   )->createChildSceneNode(   );
          
           const Mercator::Terrain& terrain = EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getTerrain(   );
           const Mercator::Terrain::Pointstore &points = terrain.getPoints(   );
           int x,   y;
           for (  Mercator::Terrain::Pointstore::const_iterator I = points.begin(   ); I != points.end(   ); ++I ) {
           x = I->first;
           for (  Mercator::Terrain::Pointcolumn::const_iterator J = I->second.begin(   ); J != I->second.end(   ); ++J ) {
           y = J->first;
           const Mercator::BasePoint& basepoint = J->second;
           Ogre::SceneNode* basepointNode = mOverlayNode->createChildSceneNode(   );
           TerrainPosition tPos(  x*64,  y*64 );
           Ogre::Vector3 ogrePos = Atlas2Ogre(  tPos );
           ogrePos.y = basepoint.height(   );
           basepointNode->setPosition(  ogrePos );
           std::stringstream ss;
           ss << "basepointmarker" << x << "_" << y;
           Ogre::Entity* entity = EmberOgre::getSingleton(   ).getSceneManager(   )->createEntity(  ss.str(   ),   "fireball.mesh" );
           ///start out with a normal material
           entity->setMaterialName(  "BasePointMarkerMaterial" );
           entity->setRenderingDistance(  300 );
           entity->setQueryFlags(  MousePicker::CM_UNDEFINED );
           basepointNode->attachObject(  entity );
           BasePointUserObject* userObject = new BasePointUserObject(  TerrainPosition(  x,  y ),   basepoint,   basepointNode );
           entity->setUserObject(  userObject );
          
          
           ///store the base point user object
           std::stringstream ss_;
           ss_ << x << "_" << y;
           mBasePointUserObjects[ss_.str(   )] = userObject;
           }
           }
           ///register the pick listener
           EmberOgre::getSingleton(   ).getMainCamera(   )->pushWorldPickListener(  &mPickListener );
           }
          }
          
     256  BasePointUserObject* TerrainEditor::getUserObject(  const TerrainPosition& terrainIndex )
          {
           std::stringstream ss;
           ss << terrainIndex.x(   ) << "_" << terrainIndex.y(   );
           BasePointUserObjectStore::iterator I = mBasePointUserObjects.find(  ss.str(   ) );
           if (  I != mBasePointUserObjects.end(   ) ) {
           return I->second;
           }
           return 0;
          
          }
          
     268  BasePointUserObject* TerrainEditor::getCurrentBasePointUserObject(   ) const
          {
           return mCurrentUserObject;
          }
          
          
     274  void TerrainEditor::pickedBasePoint(  BasePointUserObject* userObject )
          {
           assert(  userObject );
           mCurrentUserObject = userObject;
           catchInput(   );
           EventPickedBasePoint.emit(  userObject );
          }
          
          
     283  bool TerrainEditor::injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse )
          {
           assert(  mCurrentUserObject );
           mCurrentUserObject->translate(  motion.yRelativeMovement * 15 );
          
           EventSelectedBasePointUpdatedPosition.emit(  mCurrentUserObject );
          
           ///we don't want to move the cursor
           freezeMouse = true;
           return false;
          }
          
     295  bool TerrainEditor::injectMouseButtonUp(  const Input::MouseButton& button )
          {
           if (  button == Input::MouseButtonLeft ) {
           releaseInput(   );
           }
           return true;
          }
          
     303  bool TerrainEditor::injectMouseButtonDown(  const Input::MouseButton& button )
          {
           return true;
          }
          
     308  bool TerrainEditor::injectChar(  char character )
          {
           return true;
          }
          
     313  bool TerrainEditor::injectKeyDown(  const SDLKey& key )
          {
           return true;
          }
          
     318  bool TerrainEditor::injectKeyUp(  const SDLKey& key )
          {
           return true;
          }
          
     323  void TerrainEditor::catchInput(   )
          {
           GUIManager::getSingleton(   ).getInput(   ).addAdapter(  this );
          }
          
     328  void TerrainEditor::releaseInput(   )
          {
           GUIManager::getSingleton(   ).getInput(   ).removeAdapter(  this );
          
           ///react on the movement
           createAction(  true );
          
          }
          
     337  void TerrainEditor::createAction(  bool alsoCommit )
          {
           if (  mCurrentUserObject ) {
           ///lets get how much it moved
           float distance = mCurrentUserObject->getBasePointMarkerNode(   )->getPosition(   ).y - mCurrentUserObject->getBasePoint(   ).height(   );
           ///only register an action if it has been moved
           if (  distance != 0 ) {
           TerrainEditBasePointMovement movement(  distance,   mCurrentUserObject->getPosition(   ) );
           TerrainEditAction action;
           action.getMovements(   ).push_back(  movement );
          
           mActions.push_back(  action );
          
           ///when a new action is created the undo list must be emptied
           mUndoneActions.clear(   );
          
          
           EventActionCreated(  &action );
          
           if (  alsoCommit )
           {
           commitAction(  action );
           }
           }
           }
          }
          
     364  void TerrainEditor::sendChangesToServer(   )
          {
          
           try {
           std::map<std::string,   TerrainPosition> positions;
           for (  ActionStore::iterator I = mActions.begin(   ); I != mActions.end(   ); ++I ) {
           for(  TerrainEditAction::MovementStore::const_iterator J = I->getMovements(   ).begin(   ); J != I->getMovements(   ).end(   ); ++J )
           {
           std::stringstream key;
           key << J->getPosition(   ).x(   ) << "x" << J->getPosition(   ).y(   );
           positions[key.str(   )] = J->getPosition(   );
           }
           }
          
           Atlas::Objects::Operation::Set s;
          
           Atlas::Message::MapType sarg;
           sarg["id"] = "0";
          
           Atlas::Message::MapType & terrain = (  sarg["terrain"] = Atlas::Message::MapType(   ) ).asMap(   );
          
           Atlas::Message::MapType & pointMap = (  terrain["points"] = Atlas::Message::MapType(   ) ).asMap(   );
          
           for (  std::map<std::string,   TerrainPosition>::iterator I = positions.begin(   ); I != positions.end(   ); ++I ) {
          
           Mercator::BasePoint bp;
           WFMath::CoordType basepointX = I->second.x(   );
           WFMath::CoordType basepointY = I->second.y(   );
           EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getTerrain(   ).getBasePoint(  static_cast<int>(  basepointX ),  static_cast<int>(  basepointY ),   bp );
          
           Atlas::Message::ListType & point =
           (  pointMap[I->first] = Atlas::Message::ListType(  3 ) ).asList(   );
           point[0] = (  Atlas::Message::FloatType )(  I->second.x(   ) );
           point[1] = (  Atlas::Message::FloatType )(  I->second.y(   ) );
           point[2] = (  Atlas::Message::FloatType )(  bp.height(   ) );
          
          
           }
          
          
           Atlas::Message::ListType sargsList(  1,   sarg );
           s->setArgsAsList(  sargsList );
           s->setFrom(  EmberOgre::getSingleton(   ).getAvatar(   )->getAvatarEmberEntity(   )->getId(   ) );
          
           Ember::EmberServices::getSingleton(   ).getServerService(   )->getConnection(   )->send(  s );
           S_LOG_INFO(  "Sent updated terrain to server (  " << positions.size(   ) << " base points updated )." );
          
           ///also reset the marking for the base points
           for (  std::map<std::string,   TerrainPosition>::iterator I = positions.begin(   ); I != positions.end(   ); ++I ) {
           BasePointUserObject* userObject = getUserObject(  I->second );
           if (  userObject ) {
           userObject->resetMarking(   );
           }
           }
           ///clear all actions
           mActions.clear(   );
           }catch (  const Atlas::Exception& ex )
           {
           S_LOG_FAILURE(  "Could not send terrain to server. Message: " << ex.what(   ) );
           }catch (  const std::exception& ex )
           {
           S_LOG_FAILURE(  "Could not send terrain to server. Message: " << ex.what(   ) );
           }
          
          }
          
     430  bool TerrainEditor::undoLastAction(   )
          {
           if (  mActions.size(   ) > 0 ) {
           TerrainEditAction action = mActions.back(   );
           ///remove the last action from the list of active actions
           mActions.pop_back(   );
           ///add the action to the list of undone actions
           mUndoneActions.push_front(  action );
           ///actually undo the action
           commitAction(  action,   true );
           return true;
           }
           return false;
          
          }
          
     446  bool TerrainEditor::redoAction(   )
          {
           if (  mUndoneActions.size(   ) ) {
           TerrainEditAction action = mUndoneActions.front(   );
           mUndoneActions.pop_front(   );
           mActions.push_back(  action );
           commitAction(  action );
           }
           return false;
          }
          
          
     458  void TerrainEditor::commitAction(  const TerrainEditAction& action,   bool reverse )
          {
           TerrainGenerator::TerrainDefPointStore pointStore;
          
          // std::set<Ogre::PagingLandScapeTile*> tilesToUpdate;
           std::set<TerrainPage*> pagesToUpdate;
          // EmberPagingSceneManager* sceneMgr = EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getEmberSceneManager(   );
           TerrainGenerator* terrainGenerator = EmberOgre::getSingleton(   ).getTerrainGenerator(   );
           for(  TerrainEditAction::MovementStore::const_iterator I = action.getMovements(   ).begin(   ); I != action.getMovements(   ).end(   ); ++I )
           {
           Mercator::BasePoint bp;
           int basepointX = static_cast<int>(  I->getPosition(   ).x(   ) );
           int basepointY = static_cast<int>(  I->getPosition(   ).y(   ) );
           EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getTerrain(   ).getBasePoint(  basepointX,  basepointY,   bp );
           ///check if we should do a reverse action (  which is done when an action is undone )
           bp.height(   ) = bp.height(   ) + (  reverse ? -I->getVerticalMovement(   ) : I->getVerticalMovement(   ) );
           //EmberOgre::getSingleton(   ).getTerrainGenerator(   )->getTerrain(   ).setBasePoint(  basepointX,   basepointY,   bp );
          
           TerrainDefPoint defPoint(  basepointX,   basepointY,  bp.height(   ) );
           pointStore.push_back(  defPoint );
          
          
          // Ogre::Vector3 markerPos = Atlas2Ogre(  I->getPosition(   ) );
          //
          // markerPos *= 64;
          // Ogre::PagingLandScapeTile* tile;
          // for (  int i = -1; i < 2; i += 2 ) {
          // for (  int j = -1; j < 2; j += 2 ) {
          // tile = sceneMgr->getPageManager(   )->getTile(  markerPos.x + i,   markerPos.z + j,   false );
          // if (  tile ) {
          // tilesToUpdate.insert(  tile );
          // }
          // }
          // }
          
           TerrainPosition worldPosition(  I->getPosition(   ).x(   ) * 64,   I->getPosition(   ).y(   ) * 64 );
           TerrainPage* page;
           ///make sure we sample pages from all four points around the base point,   in case the base point is on a page border
           for (  int i = -65; i < 66; i += 64 ) {
           for (  int j = -65; j < 66; j += 64 ) {
           TerrainPosition position(  worldPosition.x(   ) + i,   worldPosition.y(   ) + j );
           page = terrainGenerator->getTerrainPage(  position );
           if (  page ) {
           pagesToUpdate.insert(  page );
           }
           }
           }
          
           ///make sure the marker node is updated
           BasePointUserObject* userObject = getUserObject(  I->getPosition(   ) );
           if (  userObject ) {
           userObject->setHeight(  bp.height(   ) );
           }
          
           }
          
          // for (  TerrainGenerator::TerrainPagestore::const_iterator I = terrainGenerator->getTerrainPages(   ).begin(   );I != terrainGenerator->getTerrainPages(   ).end(   ); ++I ) {
          // for (  TerrainGenerator::TerrainPagecolumn::const_iterator J = I->second.begin(   );J != I->second.end(   ); ++J ) {
          // pagesToUpdate.insert(  J->second );
          // }
          // }
           EmberOgre::getSingleton(   ).getTerrainGenerator(   )->updateTerrain(  pointStore );
          
          
           ///reload all shader textures of the affected pages
          // for (  std::set<TerrainPage*>::iterator I = pagesToUpdate.begin(   ); I != pagesToUpdate.end(   ); ++I ) {
          // (  *I )->update(   );
          // (  *I )->updateAllShaderTextures(   );
          // }
          
          
          
          // std::set<Ogre::PagingLandScapeData2D*> dataStore;
          // ///reload all affected tiles
          // for (  std::set<Ogre::PagingLandScapeTile*>::iterator I = tilesToUpdate.begin(   ); I != tilesToUpdate.end(   ); ++I ) {
          // // (  *I )->updateTerrain(   );
          //
          // Ogre::PagingLandScapeData2D *data = sceneMgr->getData2DManager(   )->getData2D(  (  *I )->getInfo(   )->pageX,   (  *I )->getInfo(   )->pageZ );
          // // dataStore.insert(  data );
          // uint x,   z;
          // data->getCoordinates(  x,   z );
          // sceneMgr->getData2DManager(   )->reload(  x,  z );
          //
          // (  *I )->unload(   );
          // (  *I )->load(   );
          //
          // }
          //
          // ///also update the data
          // for (  std::set<Ogre::PagingLandScapeData2D*>::iterator I = dataStore.begin(   ); I != dataStore.end(   ); ++I ) {
          // uint x,   z;
          // (  *I )->getCoordinates(  x,   z );
          // sceneMgr->getData2DManager(   )->reload(  x,  z );
          // }
          // Ogre::Vector2 targetPage (  X,   Z );
          // sceneMgr->setOption(  "PageUpdate",   &targetPage );
          
           ///TODO: this shouldn't be necessary
           //sceneMgr->getPageManager(   )->load(   );
          // terrainGenerator->getAdapter(   )->reloadAllPages(   );
          
          
          // updateEntityPositions(  pagesToUpdate );
          
          
          }
          
          
          
          
          
          
          }
          }

./components/ogre/terrain/TerrainEditor.h

       1  //
          // C++ Interface: TerrainEditor
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRETERRAINEDITOR_H
          #define EMBEROGRETERRAINEDITOR_H
          
          #include "../EmberOgrePrerequisites.h"
          #include "../IWorldPickListener.h"
          #include "../input/IInputAdapter.h"
          #include "TerrainPage.h"
          
          
          namespace Mercator {
          
      34  class BasePoint;
          
          }
          
          namespace EmberOgre {
          
      40  class EmberEntity;
          
          namespace Terrain {
      43  class TerrainEditor;
      44  class TerrainEditBasePointMovement;
      45  class BasePointUserObject;
          
          /**
          Allows the user to pick base points.
          */
      50  class BasePointPickListener : public IWorldPickListener
          {
          public:
      53   BasePointPickListener(  TerrainEditor* terrainEditor );
      54   virtual void processPickResult(  bool& continuePicking,   Ogre::RaySceneQueryResultEntry& entry,   Ogre::Ray& cameraRay,   const MousePickerArgs& mousePickerArgs );
          
      56   virtual void initializePickingContext(   );
          
      58   virtual void endPickingContext(  const MousePickerArgs& mousePickerArgs );
          
          
          private:
      62   TerrainEditor* mTerrainEditor;
      63   BasePointUserObject* mPickedUserObject;
          };
          
      66  class BasePointUserObject : public Ogre::UserDefinedObject
          {
          public:
           /**
           The type of UserDefinedObject
           */
      72   static const std::string s_TypeName;
          
          
      75   BasePointUserObject(  const TerrainPosition terrainPosition,   const Mercator::BasePoint& basePoint,   Ogre::SceneNode* basePointMarkerNode );
           /**
           * Overloaded method for getting the type name of this instance.
           * @param
           * @return
           */
      81   virtual const Ogre::String & getTypeName (  void ) const;
          
          
           /**
           * Accesses the base point
           * @return
           */
      88   const Mercator::BasePoint& getBasePoint(   ) const;
          
           /**
           * Gets the current height of the base point.
           * @return
           */
      94   float getHeight(   ) const;
          
          
           /**
           * Sets a new height.
           * @param height
           */
     101   void setHeight(  Ogre::Real height );
          
     103   Ogre::SceneNode* getBasePointMarkerNode(   ) const;
          
     105   const TerrainPosition& getPosition(   ) const;
          
           /**
           * Updated the vertical position of the base point.
           * @param verticalMovement
           */
     111   void translate(  Ogre::Real verticalMovement );
          
           /**
           Emitted when the position of the base point has been updated
           */
     116   sigc::signal<void> EventUpdatedPosition;
          
           /**
           * Marks the entity as "moved"
           */
     121   void markAsMoved(   );
          
           /**
           * Resets the marking of the entity to the normal material (  instead of the "moved" marking )
           */
     126   void resetMarking(   );
          
          
          private:
     130   const Mercator::BasePoint& mBasePoint;
     131   Ogre::SceneNode* mBasePointMarkerNode;
     132   const TerrainPosition mPosition;
          
          };
          
          // class TerrainEditorInputAdapter : public IInputAdapter
          // {
          // public:
          //
          // /**
          // ---------Methods implemented from IInputAdapter
          // @see IInputAdapter
          // */
          // virtual bool injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse );
          // virtual bool injectMouseButtonUp(  const Input::MouseButton& button );
          // virtual bool injectMouseButtonDown(  const Input::MouseButton& button );
          // virtual bool injectChar(  char character );
          // virtual bool injectKeyDown(  const SDLKey& key );
          // virtual bool injectKeyUp(  const SDLKey& key );
          // private:
          //
          // };
          
          /**
          A single editing action. This can affect one or many base points,   and can be reversed (  uncommitted ).
          */
     157  class TerrainEditAction
          {
          public:
          
          typedef std::vector<TerrainEditBasePointMovement> MovementStore;
          
          /**
           * Gets all movements contained by this action.
           * @return
           */
     167  inline const MovementStore& getMovements(   ) const;
          
          /**
           * Gets all movements contained by this action.
           * @return
           */
     173  inline MovementStore& getMovements(   );
          
          private:
          
          /**
           *Internal store of all movements contained by this action.
           */
     180  MovementStore mMovements;
          
          };
          
     184  const TerrainEditAction::MovementStore& TerrainEditAction::getMovements(   ) const { return mMovements;}
     185  TerrainEditAction::MovementStore& TerrainEditAction::getMovements(   ) {return mMovements;}
          
          /**
           *A single height movement of a base point.
           */
     190  class TerrainEditBasePointMovement
          {
          public:
          
          /**
           *Default ctor.
           @param the vertical movement in meters
           @param the affected position
           */
     199  TerrainEditBasePointMovement(  Ogre::Real verticalMovement,   TerrainPosition position );
          
          /**
           * Gets the vertical movement in meters.
           */
     204  Ogre::Real getVerticalMovement(   ) const;
          
          /**
           * Gets the affected position.
           */
     209  const TerrainPosition& getPosition(   ) const;
          
          private:
     212  Ogre::Real mVerticalMovement;
     213  TerrainPosition mPosition;
          };
          
          /**
           Provides terrain editing capabilities. Through this class base points in the terrain can be changed,   and the changes sent to the server. The editor supports undo and redo functionality.
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
     220  class TerrainEditor : public IInputAdapter
          {
          public:
     223   TerrainEditor(   );
          
     225   ~TerrainEditor(   );
          
           /**
           * Shows the overlay.
           */
     230   void showOverlay(   );
           /**
           * Hides the overlay.
           */
     234   void hideOverlay(   );
          
           /**
           * Creates the overlay.
           */
     239   void createOverlay(   );
          
           /**
           * Returns true if the overlay is currently shown.
           * @return
           */
     245   bool isOverlayShown(   ) const;
          
     247   void pickedBasePoint(  BasePointUserObject* userObject );
          
          
           /**
           * Performs the suppied action on the client terrain. Note that no updates are sent to the server at this point.
           * Undo operations are carried out by calls to this method,   with the second parameter set to true.
           * @param the action to commit
           * @param if true,   the action will be undone
           * @return
           */
     257   void commitAction(  const TerrainEditAction& action,   bool reverse = false );
          
           /**
           * Emitted when a base point has been picked by the mouse.
           * @param The UserObject of the picked base point.
           */
     263   sigc::signal<void,   BasePointUserObject*> EventPickedBasePoint;
          
           /**
           * Emitted when an TerrainEditAction has been created.
           * @param The newly created TerrainEditAction
           */
     269   sigc::signal<void,   const TerrainEditAction*> EventActionCreated;
          
           /**
           Emitted when the position of the selected base point has been updated
           */
     274   sigc::signal<void,   BasePointUserObject*> EventSelectedBasePointUpdatedPosition;
          
          
           /**
           * returns the currently selected base point user object,   if any
           * @return
           */
     281   BasePointUserObject* getCurrentBasePointUserObject(   ) const;
          
           /**
           * Sends all changes to the server.
           */
     286   void sendChangesToServer(   );
          
           /**
           * Creates a new action from the current movement. Will only create an action if actual movement has occurred.
           * @param alsoCommit if true,   the action will also be committed
           */
     292   void createAction(  bool alsoCommit );
          
           /**
           * Gets the user object at the specified terrain position. If no UserObject can be found,   null is returned.
           * @param The position in the terrain to get the BasePointUserObject for.
           * @returns A valid BasePointUserObject or null if none found.
           */
     299   BasePointUserObject* getUserObject(  const TerrainPosition& terrainIndex );
          
           /**
           * Undoes the last action,   if there are any.
           * @return true if there was an action to undo,   false if else
           */
     305   bool undoLastAction(   );
          
           /**
           * Redoes an action that was undone.
           * @return true if there was an already undone action that could be redone,   else false
           */
     311   bool redoAction(   );
          
          /**
          ---------Methods implemented from IInputAdapter
          @see IInputAdapter
          */
     317   virtual bool injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse );
     318   virtual bool injectMouseButtonUp(  const Input::MouseButton& button );
     319   virtual bool injectMouseButtonDown(  const Input::MouseButton& button );
     320   virtual bool injectChar(  char character );
     321   virtual bool injectKeyDown(  const SDLKey& key );
     322   virtual bool injectKeyUp(  const SDLKey& key );
          
          private:
          
           typedef std::map<std::string,   BasePointUserObject*> BasePointUserObjectStore;
          
     328   BasePointUserObjectStore mBasePointUserObjects;
          
     330   BasePointPickListener mPickListener;
          
           /**
           * When moving an entity with the mouse,   no other parts of Ember should get input.
           */
     335   void catchInput(   );
          
           /**
           * When finished moving an entity with the mouse,   normal input handling should resume.
           */
     340   void releaseInput(   );
     341   BasePointUserObject* mCurrentUserObject;
           typedef std::list<TerrainEditAction> ActionStore;
     343   ActionStore mActions;
     344   ActionStore mUndoneActions;
     345   Ogre::SceneNode* mOverlayNode;
          
     347   bool mVisible;
          
           /**
           After a piece of terrain has been updated,   the positions of the entities will need to be updated.
           */
     352   void updateEntityPositions(  const std::set<TerrainPage*>& pagesToUpdate );
          
           /**
           Updates the position of a single entity.
           */
     357   void updateEntityPosition(  EmberEntity* entity,   const std::set<TerrainPage*>& pagesToUpdate );
          
          };
          
          }
          }
          #endif

./components/ogre/terrain/TerrainGenerator.cpp

          /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "TerrainGenerator.h"
          
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/config/ConfigService.h"
          
          #include "../EmberOgre.h"
          #include "../EmberEntity.h"
          #include "../WorldEmberEntity.h"
          #include "../EmberEntityFactory.h"
          
          #include <Eris/Entity.h>
          #include <Eris/View.h>
          
          #include <OgreCodec.h>
          #include <OgreImage.h>
          #include <OgreImageCodec.h>
          #include <OgreTextureManager.h>
          #include <OgreStringConverter.h>
          #include <OgreRenderSystemCapabilities.h>
          #include "TerrainShader.h"
          #include "../environment/Foliage.h"
          #include "../environment/Forest.h"
          #include "ISceneManagerAdapter.h"
          
          
          #include "TerrainPage.h"
          #include "TerrainArea.h"
          #include <Mercator/Area.h>
          #include <Mercator/Segment.h>
          #include <Mercator/FillShader.h>
          #include <Mercator/ThresholdShader.h>
          #include <Mercator/DepthShader.h>
          #include <Mercator/GrassShader.h>
          #include <Mercator/Surface.h>
          #include <Mercator/Matrix.h>
          
          #include "TerrainLayerDefinitionManager.h"
          #include "TerrainLayerDefinition.h"
          // #include "../model/ModelDefinition.h"
          // #include "../model/ModelDefinitionManager.h"
          
          #include "../AvatarCamera.h"
          
          #include "../environment/Environment.h"
          
          #include <sigc++/object_slot.h>
          
          #ifdef WIN32
           #include <tchar.h>
           #define snprintf _snprintf
           #include <io.h> // for _access,   Win32 version of stat(   )
           #include <direct.h> // for _mkdir
          #endif
          #include "framework/ConsoleBackend.h"
          
          
          using namespace Ogre;
          namespace EmberOgre {
          namespace Terrain {
          
          
      81  TerrainGenerator::TerrainGenerator(  ISceneManagerAdapter* adapter )
          :
          UpdateShadows(  "update_shadows",   this,   "Updates shadows in the terrain." ),  
      84  mGrassShader(  0 ),  
          hasTerrainInfo(  false )
          {
          
           registerSceneManagerAdapter(   adapter );
           //new Foliage(  EmberOgre::getSingleton(   ).getSceneManager(   ) );
          
          
           loadTerrainOptions(   );
           mTerrainInfo.setPageIndicesSize(  adapter->getPageSize(   ) );
           mTerrain = new Mercator::Terrain(  Mercator::Terrain::SHADED ); //,   mOptions.pageSize - 1 );
          
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
          
          
          
          
          // mTerrainPageSource = new EmberTerrainPageSource(  this );
          // EmberOgre::getSingleton(   ).getSceneManager(   )->registerPageSource(  EmberTerrainPageSource::Name,   mTerrainPageSource );
          
          
          
           // EmberOgre::getSingleton(   ).getSceneManager(   )->setWorldGeometry(  mOptions );
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          
           configSrv->EventChangedConfigItem.connect(  sigc::mem_fun(  *this,   &TerrainGenerator::ConfigService_EventChangedConfigItem ) );
          
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  "exportterrainmaterial",  this );
          
          }
          
     115  TerrainGenerator::~TerrainGenerator(   )
          {
          
           for (  PageStore::iterator J = mPages.begin(   ); J != mPages.end(   ); ++J ) {
           delete J->second;
           }
          
           for (  ShaderStore::iterator J = mShaderMap.begin(   ); J != mShaderMap.end(   ); ++J ) {
           delete J->second;
           }
          
          
           delete mTerrain;
           //delete mTerrainPageSource;
          
          }
          
     132  Mercator::Terrain& TerrainGenerator::getTerrain(   )
          {
           return *mTerrain;
          }
          
          
     138  void TerrainGenerator::loadTerrainOptions(   )
          {
           chdir(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ).c_str(   ) );
          
           //Ogre::ConfigFile cf;
           // cf.load(  "terrain.cfg" );
          
          
           // Go through all sections & settings in the file
           //Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(   );
           //
           //std::string first;
           //std::string second;
           //std::string pair;
           //Ogre::String secName,   typeName,   archName;
           //while (  seci.hasMoreElements(   ) )
           //{
           // secName = seci.peekNextKey(   );
           // Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(   );
           // Ogre::ConfigFile::SettingsMultiMap::iterator i;
           // for (  i = settings->begin(   ); i != settings->end(   ); ++i )
           // {
           // first = i->first;
           // second = i->second;
           // pair = first + "=" + second;
           // }
           //}
          
          // Ogre::PagingLandScapeSceneManager* sceneManager = getEmberSceneManager(   );
          
          
          
          
           getAdapter(   )->setResourceGroupName(  "General"  );
          
           getAdapter(   )->loadOptions(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getSharedConfigDirectory(   ) + "/terrain.cfg" );
          
           getAdapter(   )->setCamera(   EmberOgre::getSingleton(   ).getMainCamera(   )->getCamera(   ) );
          
          
           //Ogre::PagingLandScapeOptions::getSingleton(   ).data2DFormat = "EmberHeightField";
          
          }
          
     182  ISceneManagerAdapter* TerrainGenerator::getAdapter(   ) const
          {
           return mSceneManagerAdapter;
          }
          
     187  TerrainShader* TerrainGenerator::createShader(  const TerrainLayerDefinition* layerDef,   Mercator::Shader* mercatorShader )
          {
           size_t index = mShaderMap.size(   );
           S_LOG_VERBOSE(  "Creating new shader for shader " << layerDef->getShaderName(   ) <<" with index " << index );
           TerrainShader* shader = new TerrainShader(  mTerrain,   index,   layerDef,   mercatorShader );
          
           mBaseShaders.push_back(  shader );
           mShaderMap[shader->getShader(   )] = shader;
           return shader;
          }
          
          // TerrainShader* TerrainGenerator::createShader(  Ogre::MaterialPtr material,   Mercator::Shader* mercatorShader )
          // {
          // size_t index = mShaderMap.size(   );
          // S_LOG_VERBOSE(  "Creating new shader for material " << material->getName(   ) <<" with index " << index );
          // TerrainShader* shader = new TerrainShader(  mTerrain,   index,   material,   mercatorShader );
          //
          // mBaseShaders.push_back(  shader );
          // mShaderMap[shader->getShader(   )] = shader;
          // return shader;
          // }
          
          
          
     211  void TerrainGenerator::addArea(  TerrainArea* terrainArea )
          {
          
           terrainArea->EventAreaChanged.connect(  sigc::mem_fun(  *this,   &TerrainGenerator::TerrainArea_Changed ) );
           Mercator::Area* area = terrainArea->getArea(   );
           // _fpreset(   );
           //_controlfp(  _PC_64,   _MCW_PC );
           //_controlfp(  _RC_NEAR,   _MCW_RC );
           std::stringstream ss;
           ss << area->bbox(   );
           S_LOG_VERBOSE(  "Adding area to terrain with dimensions: " << ss.str(   ) );
           mTerrain->addArea(  area );
           if (  !mAreaShaders.count(  area->getLayer(   ) ) ) {
           S_LOG_VERBOSE(  "Shader does not exists,   creating new." );
           TerrainShader* shader;
           ///try to get the materialdefinition for this kind of area
           const TerrainLayerDefinition* layerDef = TerrainLayerDefinitionManager::getSingleton(   ).getDefinitionForArea(  area->getLayer(   ) );
           if (  layerDef ) {
           shader = createShader(  layerDef,   new Mercator::AreaShader(  area->getLayer(   ) ) );
           mAreaShaders[area->getLayer(   )] = shader;
           }
           }
           if (  mAreaShaders.count(  area->getLayer(   ) ) ) {
           ///mark the shader for update
           ///we'll not update immediately,   we try to batch many area updates and then only update once per frame
           markShaderForUpdate(  mAreaShaders[area->getLayer(   )] );
           }
          }
          
     240  void TerrainGenerator::TerrainArea_Changed(  TerrainArea* terrainArea )
          {
           Mercator::Area* area = terrainArea->getArea(   );
           if (  mAreaShaders.count(  area->getLayer(   ) ) ) {
           ///mark the shader for update
           ///we'll not update immediately,   we try to batch many area updates and then only update once per frame
           markShaderForUpdate(  mAreaShaders[area->getLayer(   )] );
           }
          }
          
     250  void TerrainGenerator::markShaderForUpdate(  TerrainShader* shader )
          {
           mShadersToUpdate.insert(  shader );
          }
          
     255  bool TerrainGenerator::frameStarted(  const Ogre::FrameEvent & evt )
          {
           //PagingLandScapeCamera * cam = static_cast<PagingLandScapeCamera *>(  EmberOgre::getSingleton(   ).getMainCamera(   )->getCamera(   ) );
          
          
          /* std::stringstream ss;
           ss << "X: " << cam->mCurrentCameraPageX << " Z: " << cam->mCurrentCameraPageZ;
           GUIManager::getSingleton(   ).setDebugText(  ss.str(   ) );*/
           //update shaders that needs updating
           if (  mShadersToUpdate.size(   ) ) {
           for (  PageStore::iterator J = mPages.begin(   ); J != mPages.end(   ); ++J ) {
           J->second->populateSurfaces(   );
           }
          
           for (  ShaderSet::iterator I = mShadersToUpdate.begin(   ); I != mShadersToUpdate.end(   ); ++I ) {
           for (  PageStore::iterator J = mPages.begin(   ); J != mPages.end(   ); ++J ) {
           J->second->updateShaderTexture(  *I );
           }
           }
           }
          
           mShadersToUpdate.clear(   );
           return true;
          
          }
          
          
     282  void TerrainGenerator::prepareSegments(  long segmentXStart,   long segmentZStart,   long numberOfSegments,   bool alsoPushOntoTerrain )
          {
          //TODO: implement!
          
          
          // int i,  j;
          // for (  i = segmentXStart; i < segmentXStart + numberOfSegments; ++i ) {
          // for (  j = segmentZStart; j < segmentZStart + numberOfSegments; ++j ) {
          // if (  i >= mXmin && i <= mXmax && j >= mYmin && j <=mYmax ) {
          // mTerrain->getSegment(  i,   j )->populate(   );
          // mTerrain->getSegment(  i,   j )->populateNormals(   );
          // mTerrain->getSegment(  i,   j )->populateSurfaces(   );
          // TerrainPosition pos(  i,  j );
          // generateTerrainMaterials(  mTerrain->getSegment(  i,   j ),   pos );
          // if (  alsoPushOntoTerrain ) {
          // TerrainPosition pos(  i,   j );
          // mTerrainPageSource->pushPage(  pos );
          // }
          // }
          // }
          // }
          // // generateUnderVegetation(  0,   0,   1 );
          // // generateUnderVegetation(  segmentXStart,   segmentZStart,   numberOfSegments );
          // mTerrainPageSource->setHasTerrain(  true );
          // if (  alsoPushOntoTerrain ) {
          // mTerrainPageSource->resizeTerrain(   );
          // }
          
          }
          
     312  int TerrainGenerator::getPageSize(   )
          {
           return mSceneManagerAdapter->getPageSize(   );
          }
          
     317  int TerrainGenerator::getSegmentSize(   )
          {
           return getPageSize(   ) - 1;
          }
          
     322  void TerrainGenerator::buildHeightmap(   )
          {
           mHeightMax = 0,   mHeightMin = 0;
          
           ///initialize all terrain here,   since we need to do that in order to get the correct height for placement even though the terrain might not show up in the SceneManager yet
          
           ///note that we want to use int's here,   since a call to getSegment(  float,   float ) is very much different from a call to getSegment(  int,   int )
           int i,  j;
           const WFMath::AxisBox<2>& segmentBbox = mTerrainInfo.getWorldSizeInSegments(   );
           for (  i = static_cast<int>(  segmentBbox.lowCorner(   ).x(   ) ); i < segmentBbox.highCorner(   ).x(   ); ++i ) {
           for (  j = static_cast<int>(  segmentBbox.lowCorner(   ).y(   ) ); j < segmentBbox.highCorner(   ).y(   ); ++j ) {
           Mercator::Segment* segment = mTerrain->getSegment(  i,   j );
           if (  segment ) {
           //S_LOG_VERBOSE(  "Preparing segment at position: x=" << i << " y=" << j  );
           segment->populate(   );
           segment->populateNormals(   );
           segment->populateSurfaces(   );
           mHeightMax = std::max(  mHeightMax,   segment->getMax(   ) );
           mHeightMin = std::min(  mHeightMin,   segment->getMin(   ) );
           }
           }
           }
          }
          
          // void TerrainGenerator::createShaders(  WorldEmberEntity* worldEntity )
          // {
          // if (  worldEntity ) {
          // if (  worldEntity->hasAttr(  "surfaces" ) ) {
          //
          // }
          // }
          // }
          
          
     356  void TerrainGenerator::registerSceneManagerAdapter(  ISceneManagerAdapter* adapter )
          {
           mSceneManagerAdapter = adapter;
          }
          
          
     362  void TerrainGenerator::prepareAllSegments(   )
          {
          
           // _fpreset(   );
           //_controlfp(  _PC_64,   _MCW_PC );
           //_controlfp(  _RC_NEAR,   _MCW_RC );
          
           //buildHeightmap(   );
          
          // int mercatorSegmentsPerPage = getSegmentSize(   ) / 64;
          // int xNumberOfPages = (  int )ceil(  (  mXmax - mXmin ) / (  double )mercatorSegmentsPerPage );
          // int yNumberOfPages = (  int )ceil(  (  mYmax - mYmin ) / (  double )mercatorSegmentsPerPage );
          // int xStart = (  int )ceil(  mXmin / (  double )(  mercatorSegmentsPerPage ) );
          // int yStart = (  int )ceil(  mYmin / (  double )(  mercatorSegmentsPerPage ) );
          // for (  i = 0; i < xNumberOfPages; ++i ) {
          // for (  j = 0; j < yNumberOfPages; ++j ) {
          // TerrainPosition pos(  xStart + i,   yStart + j );
          // std::stringstream ss;
          // ss << pos;
          // TerrainPage* page = new TerrainPage(  pos,   mShaderMap,   this );
          // mPages[ss.str(   )] = page;
          // mTerrainPages[i][j] = page;
          // for (  std::list<TerrainShader*>::iterator I = mBaseShaders.begin(   ); I != mBaseShaders.end(   ); ++I ) {
          // page->addShader(  *I );
          // }
          // page->generateTerrainMaterials(   );
          // if (  showFoliage && mGrassShader ) {
          // page->createFoliage(  mGrassShader );
          // }
          // if (  alsoPushOntoTerrain ) {
          // // mTerrainPageSource->addPage(  page );
          // }
          // }
          // }
          
          
          // // Ogre::PagingLandScapeSceneManager * sceneManager = getEmberSceneManager(   );
          // Ogre::PagingLandScapeOptions* options = getEmberSceneManager(   )->getOptions(   );
          
           ///update the terrain info
          /* mTerrainInfo.worldSizeX = getMax(   ).x(   ) - getMin(   ).x(   );
           mTerrainInfo.totalNumberOfPagesX = static_cast<int>(   ceil(  mTerrainInfo.worldSizeX / (  getPageSize(   ) - 1 ) ) );*/
          // mTerrainInfo.totalNumberOfPagesX = static_cast<int>(   mTerrainInfo.worldSizeX / (  getPageSize(   ) - 1 ) );
          // mTerrainInfo.pageOffsetX = mTerrainInfo.totalNumberOfPagesX / 2;
          /* mTerrainInfo.worldSizeY = getMax(   ).y(   ) - getMin(   ).y(   );
           mTerrainInfo.totalNumberOfPagesY = static_cast<int>(   ceil(  mTerrainInfo.worldSizeY / (  getPageSize(   ) - 1 ) ) );*/
          // mTerrainInfo.totalNumberOfPagesY = static_cast<int>(   mTerrainInfo.worldSizeY / (  getPageSize(   ) - 1 ) );
          // mTerrainInfo.pageOffsetY = mTerrainInfo.totalNumberOfPagesY / 2;
          
           //if the world is in effect non-existant,   quit here
          // if (  mTerrainInfo.totalNumberOfPagesX == 0 && mTerrainInfo.totalNumberOfPagesY == 0 ) {
          // return;
          // }
          
           getAdapter(   )->setWorldPagesDimensions(   mTerrainInfo.getTotalNumberOfPagesX(   ),   mTerrainInfo.getTotalNumberOfPagesY(   ),   mTerrainInfo.getPageOffsetX(   ),   mTerrainInfo.getPageOffsetY(   ) );
          
          
          
           getAdapter(   )->loadScene(   );
           const WFMath::AxisBox<2>& worldSize = mTerrainInfo.getWorldSizeInIndices(   );
           Ogre::AxisAlignedBox worldBox(  worldSize.lowCorner(   ).x(   ),   mHeightMin,   worldSize.lowCorner(   ).y(   ),   worldSize.highCorner(   ).x(   ),   mHeightMax,   worldSize.highCorner(   ).y(   ) );
           std::stringstream ss;
           ss << worldBox;
           S_LOG_INFO(  "New size of the world: " << ss.str(   ) );
          
           getAdapter(   )->resize(  worldBox ,  16 );
          
           S_LOG_INFO(  "Pages: X: " << mTerrainInfo.getTotalNumberOfPagesX(   ) << " Y: " << mTerrainInfo.getTotalNumberOfPagesY(   ) << " Total: " << mTerrainInfo.getTotalNumberOfPagesX(   ) * mTerrainInfo.getTotalNumberOfPagesY(   ) );
           S_LOG_INFO(  "Page offset: X" << mTerrainInfo.getPageOffsetX(   ) << " Y: " << mTerrainInfo.getPageOffsetY(   ) );
          
           EmberOgre::getSingleton(   ).getEntityFactory(   )->getWorld(   )->getEnvironment(   )->getForest(   )->initialize(   );
          
          }
          
          
     437  bool TerrainGenerator::isValidTerrainAt(  const TerrainPosition& position )
          {
          // /* int x = (  int )position.x(   );
          // int y = (  int )position.y(   );*/
           Mercator::Segment* segment = mTerrain->getSegment(  position.x(   ),  position.y(   ) );
           return (  segment && segment->isValid(   ) );
          // return (  segment && segment->isValid(   ) && getMaterialForSegment(  position ) );
          }
          
          
     447  TerrainPage* TerrainGenerator::getTerrainPage(  const TerrainPosition& worldPosition )
          {
          
          
           int xRemainder = static_cast<int>(  getMin(   ).x(   ) ) % (  getPageSize(   ) - 1 );
           int yRemainder = static_cast<int>(  getMin(   ).y(   ) ) % (  getPageSize(   ) - 1 );
          
           int xIndex = static_cast<int>(  floor(  (  worldPosition.x(   ) + xRemainder )/ (  getPageSize(   ) - 1.0f ) ) );
           int yIndex = static_cast<int>(  ceil(  (  worldPosition.y(   ) + yRemainder ) / (  getPageSize(   ) - 1.0f ) ) );
          
          
           return mTerrainPages[xIndex][yIndex];
          }
          
     461  TerrainPage* TerrainGenerator::getTerrainPage(  const Ogre::Vector2& ogreIndexPosition,   bool createIfMissing )
          {
           //_fpreset(   );
           //S_LOG_INFO(  "Requesting page at ogre position x: " << ogreIndexPosition.x << " y: " << ogreIndexPosition.y );
          
           Ogre::Vector2 adjustedOgrePos(  ogreIndexPosition.x - mTerrainInfo.getPageOffsetY(   ),   ogreIndexPosition.y - mTerrainInfo.getPageOffsetX(   ) );
          
           TerrainPosition pos(  Ogre2Atlas(  adjustedOgrePos ) );
          
           int x = static_cast<int>(  pos.x(   ) );
           int y = static_cast<int>(  pos.y(   ) );
          
           if (  mTerrainPages[x][y] == 0 ) {
           if (  createIfMissing ) {
          
           //TerrainPosition adjustedPos(  pos.x(   ) - pageOffsetX,   pos.y(   ) - pageOffsetY );
          
           mTerrainPages[x][y] = createPage(  pos );
           assert(  mTerrainPages[x][y] );
           } else {
           return 0;
           }
           }
           return mTerrainPages[x][y];
          }
          
     487  TerrainPage* TerrainGenerator::createPage(  const TerrainPosition& pos )
          {
          
           bool showFoliage = isFoliageShown(   );
          
          
           ///since we initialized all terrain in initTerrain we can count on all terrain segments being created and populated already
          
          
           TerrainPage* page = new TerrainPage(  TerrainPosition(  pos ),   mShaderMap,   this );
           //mPages[ss.str(   )] = page;
          
           std::stringstream ss;
           ss << pos;
           mPages[ss.str(   )] = page;
          
           //add the base shaders,   this should probably be refactored into a server side thing in the future
           for (  std::list<TerrainShader*>::iterator I = mBaseShaders.begin(   ); I != mBaseShaders.end(   ); ++I ) {
           page->addShader(  *I );
           }
          
           page->createShadow(  EmberOgre::getSingleton(   ).getEntityFactory(   )->getWorld(   )->getEnvironment(   )->getSun(   )->getSunDirection(   ) );
           page->generateTerrainMaterials(   );
           if (  showFoliage && mGrassShader ) {
           page->showFoliage(   );
           }
          
          
          
           return page;
          
          
          }
          
     521  void TerrainGenerator::updateFoliageVisibilty(   )
          {
           bool showFoliage = isFoliageShown(   );
          
           PageStore::iterator I = mPages.begin(   );
           for(  ;I != mPages.end(   ); ++I ) {
           if (  showFoliage ) {
           I->second->showFoliage(   );
           } else {
           I->second->hideFoliage(   );
           }
           }
          }
          
     535  void TerrainGenerator::ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key )
          {
           if (  section == "graphics" ) {
           if (  key == "foliage" ) {
           updateFoliageVisibilty(   );
           }
           }
          }
          
     544  bool TerrainGenerator::isFoliageShown(   ) const
          {
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "graphics",   "foliage" ) && GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "arbvp1" ) ) {
           return static_cast<bool>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "graphics",   "foliage" ) );
           }
           return false;
          }
          
          
          
     554  float TerrainGenerator::getHeight(  const TerrainPosition& point ) const
          {
          
           float height = 0;
           WFMath::Vector<3> vector;
          
           bool success = mTerrain->getHeightAndNormal(  point.x(   ),   point.y(   ),   height,   vector );
           if (  success ) {
           return height;
           }
          
          ///make undefined ground be one meter below the water
           return -1;
          
          }
          
     570  void TerrainGenerator::updateShadows(   )
          {
           Ogre::Vector3 sunDirection = EmberOgre::getSingleton(   ).getEntityFactory(   )->getWorld(   )->getEnvironment(   )->getSun(   )->getSunDirection(   );
          
           PageStore::iterator I = mPages.begin(   );
           for(  ;I != mPages.end(   ); ++I ) {
           I->second->updateShadow(  sunDirection );
           }
          }
          
          
     581  bool TerrainGenerator::updateTerrain(  const TerrainDefPointStore& terrainPoints )
          {
           std::vector<TerrainPosition> updatedPositions;
           bool wasUpdate = false;
           for (  TerrainDefPointStore::const_iterator I = terrainPoints.begin(   ); I != terrainPoints.end(   ); ++I ) {
          
           Mercator::BasePoint bp;
           if (  mTerrain->getBasePoint(  static_cast<int>(  I->position.x(   ) ),   static_cast<int>(  I->position.y(   ) ),   bp ) && (  I->height == bp.height(   ) ) ) {
           S_LOG_VERBOSE(   "Point [" << I->position.x(   ) << ",  " << I->position.y(   ) << " unchanged" );
           continue;
           } else {
           wasUpdate = true;
           S_LOG_VERBOSE(   "Setting base point [" << I->position.x(   ) << ",  " << I->position.y(   ) << " to height " << I->height );
           }
           bp.height(   ) = I->height;
           /// FIXME Sort out roughness and falloff,   and generally
           /// verify this code is the same as that in Terrain layer
           mTerrain->setBasePoint(  static_cast<int>(  I->position.x(   ) ),   static_cast<int>(  I->position.y(   ) ),   bp );
           mTerrainInfo.setBasePoint(  I->position,   bp );
           updatedPositions.push_back(  I->position );
           }
           mSegments = &mTerrain->getTerrain(   );
          
           buildHeightmap(   );
          
           ///for some yet undetermined reason we'll get blank segments seeminly at random in the terrain if we'll load it dynamically when requested by the scene manager,   so avoid that we'll initialize everything now
           ///HACK: this is of course just a temporary fix
           for (  int i = 0; i < mTerrainInfo.getTotalNumberOfPagesX(   ); ++i ) {
           for (  int j = 0; j < mTerrainInfo.getTotalNumberOfPagesY(   ); ++j ) {
           getTerrainPage(  Ogre::Vector2(  i,   j ),   true );
           }
           }
          
           ///check if the size of the world has been changed
          // if (  Xmin != mXmin || Xmax != mXmax || Ymin != mYmin || Ymax != mYmax ) {
           EventWorldSizeChanged.emit(   );
          // }
          
           if (  !hasTerrainInfo ) {
           hasTerrainInfo = true;
           } else {
           if (  wasUpdate ) {
           ///if it's an update,   we need to reload all pages and adjust all entity positions
           reloadTerrain(  updatedPositions );
           }
           }
          
          
           return true;
          }
          
     632  void TerrainGenerator::reloadTerrain(  std::vector<TerrainPosition>& positions )
          {
           std::set<TerrainPage*> pagesToUpdate;
           for (  std::vector<TerrainPosition>::iterator I(  positions.begin(   ) ); I != positions.end(   ); ++I ) {
           TerrainPosition worldPosition(  I->x(   ) * 64,   I->y(   ) * 64 );
           TerrainPage* page;
           ///make sure we sample pages from all four points around the base point,   in case the base point is on a page border
           for (  int i = -65; i < 66; i += 64 ) {
           for (  int j = -65; j < 66; j += 64 ) {
           TerrainPosition position(  worldPosition.x(   ) + i,   worldPosition.y(   ) + j );
           page = getTerrainPage(  position );
           if (  page ) {
           pagesToUpdate.insert(  page );
           }
           }
           }
           }
          
           updateHeightMapAndShaders(  pagesToUpdate );
           updateEntityPositions(  pagesToUpdate );
          
          }
     654  void TerrainGenerator::updateHeightMapAndShaders(  const std::set<TerrainPage*>& pagesToUpdate )
          {
           const Ogre::Vector3& sunDirection = EmberOgre::getSingleton(   ).getEntityFactory(   )->getWorld(   )->getEnvironment(   )->getSun(   )->getSunDirection(   );
          
           ///reload all shader textures of the affected pages
           for (  std::set<TerrainPage*>::const_iterator I = pagesToUpdate.begin(   ); I != pagesToUpdate.end(   ); ++I ) {
           (  *I )->update(   );
           (  *I )->updateAllShaderTextures(   );
           (  *I )->updateShadow(  sunDirection );
           }
          }
          
     666  void TerrainGenerator::updateEntityPositions(  const std::set<TerrainPage*>& pagesToUpdate )
          {
           EmberEntity* entity = EmberOgre::getSingleton(   ).getEntityFactory(   )->getWorld(   );
           if (  entity ) {
           updateEntityPosition(  entity,   pagesToUpdate );
           }
          }
          
     674  void TerrainGenerator::updateEntityPosition(  EmberEntity* entity,   const std::set<TerrainPage*>& pagesToUpdate )
          {
           entity->adjustPosition(   );
           for (  unsigned int i = 0; i < entity->numContained(   ); ++i ) {
           EmberEntity* containedEntity = static_cast<EmberEntity*>(  entity->getContained(  i ) );
           updateEntityPosition(  containedEntity,   pagesToUpdate );
           }
          }
          
          // Ogre::Material* TerrainGenerator::getMaterialForSegment(  TerrainPosition& atPosition )
          // {
          // long x = (  long )atPosition.x(   );
          // long y = (  long )atPosition.y(   );
          // std::stringstream ss;
          // ss << x <<":"<<y;
          // return materialStore[ss.str(   )];
          // }
          
     692  const TerrainPosition TerrainGenerator::getMax(    ) const
          {
           return mTerrainInfo.getWorldSizeInIndices(   ).highCorner(   );
          // return TerrainPosition(  mXmax * 64,   mYmax * 64 );
          }
          
     698  const TerrainPosition TerrainGenerator::getMin(    ) const
          {
           return mTerrainInfo.getWorldSizeInIndices(   ).lowCorner(   );
          // return TerrainPosition(  mXmin * 64,   mYmin * 64 );
          }
          
     704  TerrainShader* TerrainGenerator::getFoliageShader(   ) const
          {
           return mGrassShader;
          }
          
     709  void TerrainGenerator::setFoliageShader(  TerrainShader* shader )
          {
           mGrassShader = shader;
          }
          
          
     715  void TerrainGenerator::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  command == "exportterrainmaterial" ) {
           //disable for now
           try {
           Ogre::MaterialPtr materialPtr = mTerrainPages.begin(   )->second.begin(   )->second->getMaterial(   );
           Ogre::MaterialSerializer serializer;
          
           serializer.exportMaterial(  materialPtr,   Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   ) + "/terrain.material" );
           } catch (  Ogre::Exception& ex )
           {
           S_LOG_FAILURE(  ex.getFullDescription(   ) );
           }
           } else if (  UpdateShadows == command ) {
           updateShadows(   );
           }
          }
     732  const TerrainInfo & TerrainGenerator::getTerrainInfo(    ) const
          {
           return mTerrainInfo;
          }
          
          }
          }

./components/ogre/terrain/TerrainGenerator.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          
          #ifndef TERRAINGENERATOR_H
          #define TERRAINGENERATOR_H
          
          #include "../EmberOgrePrerequisites.h"
          
          #include <wfmath/point.h>
          #include <Mercator/Terrain.h>
          
          #include <sigc++/trackable.h>
          #include <sigc++/signal.h>
          
          #include "framework/ConsoleObject.h"
          
          #include "TerrainInfo.h"
          #include "../MathConverter.h"
          namespace Ogre
          {
      37   class TerrainOptions;
          }
          
          namespace Eris
          {
      42   class Entity;
      43   class View;
          }
          
      46  namespace Mercator
          {
           class Area;
          }
          
          namespace EmberOgre {
      52  class EmberEntity;
      53  class EmberEntityFactory;
      54  class EmberPagingSceneManager;
          
          namespace Environment
          {
      58   class Environment;
          }
          
      61  namespace Terrain {
          
          class TerrainShader;
          
          class TerrainPage;
          class TerrainArea;
          class TerrainLayerDefinition;
          
          class ISceneManagerAdapter;
          
          
          
          struct TerrainDefPoint
          {
           public:
           TerrainDefPoint(  float x,   float y,   float terrainHeight ) : position(  x,  y ),   height(  terrainHeight ) {}
           TerrainPosition position;
           float height;
          };
          
          
          
          /**
           * This class takes care of generating terrain for Ogre's scenemanager.
           * This involves getting terrain from Mercator,   converting this to ogre
           * format and creating materials to make it look good.
           *
           * It works closely with EmberTerrainPageSource.
           *
           */
          class TerrainGenerator : public Ogre::FrameListener,  
          public sigc::trackable,   public Ember::ConsoleObject
          {
          public:
          
          
           typedef std::vector<TerrainDefPoint> TerrainDefPointStore;
          
           /**
           * STL map to store sparse array of TerrainPage pointers.
           *
           */
           typedef std::map<int,   TerrainPage *> TerrainPagecolumn;
          
          
          
           /**
           * STL map to store sparse array of TerrainPage pointer columns.
           */
           typedef std::map<int,   TerrainPagecolumn > TerrainPagestore;
          
          
           TerrainGenerator(  ISceneManagerAdapter* adapter );
           virtual ~TerrainGenerator(   );
          
          
           /**
           * At each frame,   we check for updates shaders and updates the terrain. This is because we want to batch together changes.
           * @param evt
           * @return
           */
           virtual bool frameStarted(  const Ogre::FrameEvent & evt );
          
           void setBasePoint(  int x,   int y,   float z ) {mTerrain->setBasePoint(  x,  y,  z );}
           void prepareSegments(  long segmentXStart,   long segmentZStart,   long numberOfSegments,   bool alsoPushOntoTerrain );
          
           /**
           * Prepares all segments aquired from Mercator. Note that this can be very,  
           * very expensive if there's a lot of terrain defined.
           */
           void prepareAllSegments(   );
          
           /**
           * Returns the height at the specified position in the world.
           * @param atPosition
           * @return
           */
           virtual float getHeight(  const TerrainPosition& atPosition ) const;
          
           bool updateTerrain(  const TerrainDefPointStore& terrainPoints );
          
           /**
           * Return true if there is a valid piece of terrain at the supplied segment indices.
           * By valid means a populated terrain-
           */
           bool isValidTerrainAt(  const TerrainPosition& pos );
          
           //const Ogre::TerrainOptions& getTerrainOptions(   ) const;
          
           /**
           * Provides access to the underlying Mercator::Terrain object.
           * @return
           */
           Mercator::Terrain& getTerrain(   );
          
           /**
           * Gets the max boundaries of the terrain.
           * @return
           */
           const TerrainPosition getMax(   ) const;
           /**
           * Gets the min boundaries of the terrain.
           * @return
           */
           const TerrainPosition getMin(   ) const;
          
           /**
           * the size of one terrain segment
           * (  note that this is different from Mercator segments,   which always are of size 64 )
           * @return
           */
           int getSegmentSize(   );
          
          
           /**
           * Adds a new Mercator::Area to the terrain.
           * @param area
           */
           void addArea(  TerrainArea* terrainArea );
          
          // TerrainPage* getTerrainPage(  uint x,   uint z );
          
           /**
           * Returns a TerrainPage.
           * If createIfMissing is true and there is no yet existing,   a new one is created.
           * @param ogrePosition
           * @return
           */
           TerrainPage* getTerrainPage(  const Ogre::Vector2& ogrePosition,   bool createIfMissing = true );
          
           /**
           * Gets the page at the specified position in the worl. If no page can be found,   a null pointer is returned.
           * @param worldPosition
           * @return
           */
           TerrainPage* getTerrainPage(  const TerrainPosition& worldPosition );
          
          
           /**
           * Gets the size of one page in world units
           * @return
           */
           int getPageSize(   ) ;
          
           /**
           * gets the shader used for determining where to place foliage
           * @return
           */
           TerrainShader* getFoliageShader(   ) const;
          
          
           /**
           * Sets the shader to be used for foliage shading. This will be used for lookup where to place foliage.
           * @param shader
           */
           void setFoliageShader(  TerrainShader* shader );
          
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
           virtual void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           * Accessor for the scene manager.
           * @return
           */
          // EmberPagingSceneManager* getEmberSceneManager(   );
           /**
           * Accessor for the scene manager.
           * @return
           */
          // const EmberPagingSceneManager* getEmberSceneManager(   ) const;
          
           /**
           * Rebuilds the height map,   effectively regenerating the terrain
           */
           void buildHeightmap(   );
          
           const TerrainInfo& getTerrainInfo(   ) const;
          
           /**
           Emitted when the size of the world has changed.
           */
           sigc::signal<void> EventWorldSizeChanged;
          
          
           void registerSceneManagerAdapter(  ISceneManagerAdapter* adapter );
           ISceneManagerAdapter* getAdapter(   ) const;
          
           inline const TerrainPagestore& getTerrainPages(   ) const;
          
          // void createDefaultShaders(   );
          
           /**
           * Create and registers a new texture shader.
           * @param textureName
           * @param mercatorShader
           * @return
           */
           TerrainShader* createShader(  const TerrainLayerDefinition* layerDef,   Mercator::Shader* mercatorShader );
          
          // TerrainShader* createShader(  Ogre::MaterialPtr material,   Mercator::Shader* mercatorShader );
          
           void updateShadows(   );
          
           const Ember::ConsoleCommandWrapper UpdateShadows;
          
          protected:
          
           /**
           Information about the world,   such as size and number of pages.
           */
           TerrainInfo mTerrainInfo;
          
           typedef std::map<int,  TerrainShader*> AreaShaderstore;
           AreaShaderstore mAreaShaders;
          
           void markShaderForUpdate(  TerrainShader* shader );
          
           typedef std::set<TerrainShader*> ShaderSet;
           ShaderSet mShadersToUpdate;
          
           typedef std::map<std::string,   TerrainPage*> PageStore;
           PageStore mPages;
          
           TerrainPagestore mTerrainPages;
          
           TerrainShader* mGrassShader;
           typedef std::map<std::string,   Ogre::Material*> MaterialStore;
           MaterialStore materialStore;
           Mercator::Terrain* mTerrain;
          
           Ogre::Real mHeightMax,   mHeightMin;
          
          
          
           //static TerrainGenerator* _instance;
          
          // float* getDataFromMercator(  Ogre::TerrainOptions * options );
          
           WFMath::Point<3> mCurrentPosition;
          
           const Mercator::Terrain::Segmentstore* mSegments;
          
           /**
           * the min and max indices for segments
           */
          // int mXmin,   mXmax,   mYmin,   mYmax;
          
           void loadTerrainOptions(   );
          
           /**
           true if we have some kind of terrain info,   i.e. if mX* and mY* are valid
           */
           bool hasTerrainInfo;
           //Ogre::TerrainOptions mOptions;
          
          
          
           /**
           * Creates a new TerrainPage and puts it in mTerrainPages
           * @param pos
           */
           TerrainPage* createPage(  const TerrainPosition& pos );
          
          
           typedef std::map<const Mercator::Shader*,   TerrainShader*> ShaderStore;
           /**
           * This holds a map of the TerrainShaders
           */
           ShaderStore mShaderMap;
          
           /**
           a list of the shaders,   which will all be used on all Pages
           */
           std::list<TerrainShader*> mBaseShaders;
          
          
           void reloadTerrain(  std::vector<TerrainPosition>& positions );
           void updateHeightMapAndShaders(  const std::set<TerrainPage*>& pagesToUpdate );
           void updateEntityPositions(  const std::set<TerrainPage*>& pagesToUpdate );
           void updateEntityPosition(  EmberEntity* entity,   const std::set<TerrainPage*>& pagesToUpdate );
          
          
           /**
           * returns whether the foliage should be shown or not
           * note that if the GPU doesn't support the required shaders,   this will return false even though it's set in the config
           * @return
           */
           bool isFoliageShown(   ) const;
          
           /**
           * Iterates through all TerrainPages and shows or hides the foliage.
           */
           void updateFoliageVisibilty(   );
          
           /**
           * catch changes to the configuration
           * @param section
           * @param key
           */
           void ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key );
          
           /**
           Listen to changes in areas.
           */
           void TerrainArea_Changed(  TerrainArea* terrainArea );
          
           ISceneManagerAdapter* mSceneManagerAdapter;
          
          };
          
          const TerrainGenerator::TerrainPagestore& TerrainGenerator::getTerrainPages(   ) const
          {
           return mTerrainPages;
          }
          
          }
          }
          
          
          #endif // TERRAINGENERATOR_H

./components/ogre/terrain/TerrainInfo.cpp

       1  //
          // C++ Implementation: TerrainInfo
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "TerrainInfo.h"
          
          namespace EmberOgre {
          namespace Terrain {
          
          
      29  TerrainInfo::TerrainInfo(   )
          : mXminBasePoint(  0 ),   mXmaxBasePoint(  0 ),   mYminBasePoint(  0 ),   mYmaxBasePoint(  0 ),  
           mXminBasePointAdjusted(  0 ),   mXmaxBasePointAdjusted(  0 ),   mYminBasePointAdjusted(  0 ),   mYmaxBasePointAdjusted(  0 )
          {
           recalculateSize(   );
          }
          
          
      37  void TerrainInfo::setBasePoint(  const WFMath::Point<2>& position,   const Mercator::BasePoint& basepoint )
          {
           mXminBasePoint = std::min<WFMath::CoordType>(  position.x(   ),   mXminBasePoint );
           mXmaxBasePoint = std::max<WFMath::CoordType>(  position.x(   ),   mXmaxBasePoint );
           mYminBasePoint = std::min<WFMath::CoordType>(  position.y(   ),   mYminBasePoint );
           mYmaxBasePoint = std::max<WFMath::CoordType>(  position.y(   ),   mYmaxBasePoint );
          
           adjustBasePointPositionDown(  mXminBasePointAdjusted,   mXminBasePoint );
           adjustBasePointPositionUp(  mXmaxBasePointAdjusted,   mXmaxBasePoint );
           adjustBasePointPositionDown(  mYminBasePointAdjusted,   mYminBasePoint );
           adjustBasePointPositionUp(  mYmaxBasePointAdjusted,   mYmaxBasePoint );
          
           recalculateSize(   );
          }
          
      52  void TerrainInfo::recalculateSize(   )
          {
           mCalculatedSize = WFMath::AxisBox<2>(  WFMath::Point<2>(  mXminBasePointAdjusted * 64,   mYminBasePointAdjusted * 64 ),   WFMath::Point<2>(  mXmaxBasePointAdjusted * 64,   mYmaxBasePointAdjusted * 64 ) );
           mCalculatedSegmentSize = WFMath::AxisBox<2>(  WFMath::Point<2>(  mXminBasePointAdjusted,   mYminBasePointAdjusted  ),   WFMath::Point<2>(  mXmaxBasePointAdjusted ,   mYmaxBasePointAdjusted  ) );
          
           int mercatorSegmentsPerOgrePage = mPageIndicesSize / 64;
           mCalculatedPageSize = WFMath::AxisBox<2>(  WFMath::Point<2>(  mXminBasePointAdjusted / mercatorSegmentsPerOgrePage,   mYminBasePointAdjusted / mercatorSegmentsPerOgrePage ),   WFMath::Point<2>(  mXmaxBasePointAdjusted / mercatorSegmentsPerOgrePage,   mYmaxBasePointAdjusted / mercatorSegmentsPerOgrePage ) );
          }
          
          
      62  void TerrainInfo::adjustBasePointPositionUp(  WFMath::CoordType& basePointPositionAdjusted,   WFMath::CoordType newBasePointPosition )
          {
           int mercatorSegmentsPerOgrePage = mPageIndicesSize / 64;
           int remainder = static_cast<int>(  newBasePointPosition ) % mercatorSegmentsPerOgrePage;
           if (  remainder != 0 ) {
           ///adjust the position
           basePointPositionAdjusted = newBasePointPosition + (  mercatorSegmentsPerOgrePage - remainder );
           }
          }
          
      72  void TerrainInfo::adjustBasePointPositionDown(  WFMath::CoordType& basePointPositionAdjusted,   WFMath::CoordType newBasePointPosition )
          {
           int mercatorSegmentsPerOgrePage = mPageIndicesSize / 64;
           int remainder = std::abs(  static_cast<int>(  newBasePointPosition ) % mercatorSegmentsPerOgrePage );
           if (  remainder != 0 ) {
           ///adjust the position
           basePointPositionAdjusted = newBasePointPosition - (  mercatorSegmentsPerOgrePage - remainder );
           }
          }
          
      82  const WFMath::AxisBox<2>& TerrainInfo::getWorldSizeInSegments(   ) const
          {
           return mCalculatedSegmentSize;
          }
          
          
      88  const WFMath::AxisBox<2>& TerrainInfo::getWorldSizeInIndices(   ) const
          {
           return mCalculatedSize;
          }
          
      93  const WFMath::AxisBox<2>& TerrainInfo::getWorldSizeInPages(   ) const
          {
           return mCalculatedPageSize;
          }
          
          
      99  double TerrainInfo::getWorldSizeX(   ) const
          {
           return mCalculatedSize.highCorner(   ).x(   ) - mCalculatedSize.lowCorner(   ).x(   );
          }
          
     104  double TerrainInfo::getWorldSizeY(   ) const
          {
           return mCalculatedSize.highCorner(   ).y(   ) - mCalculatedSize.lowCorner(   ).y(   );
          }
          
     109  int TerrainInfo::getTotalNumberOfPagesX(   ) const
          {
           return static_cast<int>(  mCalculatedPageSize.highCorner(   ).x(   ) - mCalculatedPageSize.lowCorner(   ).x(   ) );
          }
     113  int TerrainInfo::getTotalNumberOfPagesY(   ) const
          {
           return static_cast<int>(  mCalculatedPageSize.highCorner(   ).y(   ) - mCalculatedPageSize.lowCorner(   ).y(   ) );
          }
          
     118  int TerrainInfo::getPageOffsetX(   ) const
          {
           return static_cast<int>(  -mCalculatedPageSize.lowCorner(   ).x(   ) );
          }
     122  int TerrainInfo::getPageOffsetY(   ) const
          {
           return static_cast<int>(  -mCalculatedPageSize.lowCorner(   ).y(   ) );
          }
          
     127  void TerrainInfo::setPageIndicesSize(  int size )
          {
           mPageIndicesSize = size;
          }
          
          }
          }

./components/ogre/terrain/TerrainInfo.h

       1  //
          // C++ Interface: TerrainInfo
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRETERRAININFO_H
          #define EMBEROGRETERRAININFO_H
          
          #include "../EmberOgrePrerequisites.h"
          #include <Mercator/BasePoint.h>
          // #include <wfmath/wfmath.h>
          #include <wfmath/axisbox.h>
          
          
          namespace EmberOgre {
          namespace Terrain {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
           Class holding information about the terrain.
          */
      39  class TerrainInfo
          {
          public:
      42   TerrainInfo(   );
      43   double getWorldSizeX(   ) const;
      44   double getWorldSizeY(   ) const;
      45   int getTotalNumberOfPagesX(   ) const;
      46   int getTotalNumberOfPagesY(   ) const;
      47   int getPageOffsetX(   ) const;
      48   int getPageOffsetY(   ) const;
      49   void setPageIndicesSize(  int size );
          
          /* void setNewXMax(  int xMax );
           void setNewXMin(  int xMin );
           void setNewYMax(  int yMax );
           void setNewYMin(  int yMin );*/
          
      56   void setBasePoint(  const WFMath::Point<2>& position,   const Mercator::BasePoint& basepoint );
      57   const WFMath::AxisBox<2>& getWorldSizeInIndices(   ) const;
      58   const WFMath::AxisBox<2>& getWorldSizeInSegments(   ) const;
      59   const WFMath::AxisBox<2>& getWorldSizeInPages(   ) const;
          
          private:
          
      63   void adjustBasePointPositionDown(  WFMath::CoordType& basePointPositionAdjusted,   WFMath::CoordType newBasePointPosition );
          
      65   void adjustBasePointPositionUp(  WFMath::CoordType& basePointPositionAdjusted,   WFMath::CoordType newBasePointPosition );
          
      67   void recalculateSize(   );
          
           /**
           *
           */
      72   WFMath::AxisBox<2> mCalculatedSize,   mCalculatedSegmentSize,   mCalculatedPageSize;
          // int mCalculatedXMin,   mCalculatedXmax,   mCalculatedYmin,   mCalculatedYmax;
          
           /**
           * the min and max indices for segments
           */
          // int mXmin,   mXmax,   mYmin,   mYmax;
      79   WFMath::CoordType mXminBasePoint,   mXmaxBasePoint,   mYminBasePoint,   mYmaxBasePoint;
      80   WFMath::CoordType mXminBasePointAdjusted,   mXmaxBasePointAdjusted,   mYminBasePointAdjusted,   mYmaxBasePointAdjusted;
          
           int mPageIndicesSize;
          
          };
          }
          }
          
          #endif

./components/ogre/terrain/TerrainLayerDefinition.cpp

       1  //
          // C++ Implementation: TerrainLayerDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "TerrainLayerDefinition.h"
          
          namespace EmberOgre {
          
          namespace Terrain {
          
      33  TerrainLayerDefinition::TerrainLayerDefinition(   )
          : mAreaId(  0 ),   mTileSize(  1.0f )
          {
          }
          
          
      39  TerrainLayerDefinition::~TerrainLayerDefinition(   )
          {
          }
          
      43  void TerrainLayerDefinition::setAreaId(  unsigned int areaId )
          {
           mAreaId = areaId;
          }
      47  unsigned int TerrainLayerDefinition::getAreaId(   ) const
          {
           return mAreaId;
          }
          
      52  void TerrainLayerDefinition::setDiffuseTextureName(  const std::string& textureName )
          {
           mDiffuseTextureName = textureName;
          }
      56  const std::string& TerrainLayerDefinition::getDiffuseTextureName(   ) const
          {
           return mDiffuseTextureName;
          }
          
      61  void TerrainLayerDefinition::setNormalMapTextureName(  const std::string& textureName )
          {
           mNormalMapTextureName = textureName;
          }
      65  const std::string& TerrainLayerDefinition::getNormalMapTextureName(   ) const
          {
           return mNormalMapTextureName;
          }
          
      70  void TerrainLayerDefinition::setShaderName(  const std::string& shaderName )
          {
           mShaderName = shaderName;
          }
      74  const std::string& TerrainLayerDefinition::getShaderName(   ) const
          {
           return mShaderName;
          }
          
      79  void TerrainLayerDefinition::setTileSize(  float tileSize )
          {
           mTileSize = tileSize;
          }
      83  float TerrainLayerDefinition::getTileSize(   ) const
          {
           return mTileSize;
          }
          
          
          }
          
          }

./components/ogre/terrain/TerrainLayerDefinition.h

       1  //
          // C++ Interface: TerrainLayerDefinition
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_TERRAINTERRAINLAYERDEFINITION_H
          #define EMBEROGRE_TERRAINTERRAINLAYERDEFINITION_H
          #include <string>
          namespace EmberOgre {
          
          namespace Terrain {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      33  class TerrainLayerDefinition{
          public:
      35   TerrainLayerDefinition(   );
          
      37   ~TerrainLayerDefinition(   );
          
      39   void setAreaId(  unsigned int areaId );
      40   unsigned int getAreaId(   ) const;
          
      42   void setDiffuseTextureName(  const std::string& textureName );
      43   const std::string& getDiffuseTextureName(   ) const;
          
      45   void setNormalMapTextureName(  const std::string& textureName );
      46   const std::string& getNormalMapTextureName(   ) const;
          
      48   void setShaderName(  const std::string& shaderName );
      49   const std::string& getShaderName(   ) const;
          
      51   void setTileSize(  float tileSize );
      52   float getTileSize(   ) const;
          
          protected:
          
           unsigned int mAreaId;
      57   std::string mDiffuseTextureName;
      58   std::string mNormalMapTextureName;
      59   std::string mShaderName;
           float mTileSize;
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/terrain/TerrainLayerDefinitionManager.cpp

       1  //
          // C++ Implementation: TerrainLayerDefinitionManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "TerrainLayerDefinitionManager.h"
          #include "TerrainLayerDefinition.h"
          #include "XMLLayerDefinitionSerializer.h"
          namespace EmberOgre {
          
          namespace Terrain {
          
          template<> EmberOgre::Terrain::TerrainLayerDefinitionManager* Ember::Singleton<EmberOgre::Terrain::TerrainLayerDefinitionManager>::ms_Singleton = 0;
          
      36  TerrainLayerDefinitionManager::TerrainLayerDefinitionManager(   )
          {
           mLoadOrder = 310.0f;
           mResourceType = "TerrainLayerDefinition";
          
           mScriptPatterns.push_back(  "*.terrain" );
          // mScriptPatterns.push_back(  "*.modelmap.xml" );
           Ogre::ResourceGroupManager::getSingleton(   )._registerScriptLoader(  this );
          
           Ogre::ResourceGroupManager::getSingleton(   )._registerResourceManager(  mResourceType,   this );
          }
          
          
      49  TerrainLayerDefinitionManager::~TerrainLayerDefinitionManager(   )
          {
           for (  DefinitionStore::iterator I = mDefinitions.begin(   ); I != mDefinitions.end(   ); ++I ) {
           delete *I;
           }
           Ogre::ResourceGroupManager::getSingleton(   )._unregisterScriptLoader(  this );
           Ogre::ResourceGroupManager::getSingleton(   )._unregisterResourceManager(  mResourceType );
          }
          
      58  void TerrainLayerDefinitionManager::parseScript (  Ogre::DataStreamPtr &stream,   const Ogre::String &groupName )
          {
           XMLLayerDefinitionSerializer serializer(  *this );
           serializer.parseScript(  stream,   groupName );
          }
          
      64  void TerrainLayerDefinitionManager::addDefinition(  TerrainLayerDefinition* definition )
          {
           mDefinitions.push_back(  definition );
          }
          
      69  const TerrainLayerDefinitionManager::DefinitionStore& TerrainLayerDefinitionManager::getDefinitions(   ) const
          {
           return mDefinitions;
          }
          
      74  Ogre::Resource* TerrainLayerDefinitionManager::createImpl(  const Ogre::String& name,   Ogre::ResourceHandle handle,  
      75   const Ogre::String& group,   bool isManual,   Ogre::ManualResourceLoader* loader,  
      76   const Ogre::NameValuePairList* createParams )
          {
           return 0;
          }
          
      81  TerrainLayerDefinition* TerrainLayerDefinitionManager::getDefinitionForArea(  int areaIndex )
          {
           for (  DefinitionStore::iterator I = mDefinitions.begin(   ); I != mDefinitions.end(   ); ++I ) {
           if (  (  *I )->getAreaId(   ) == areaIndex ) {
           return *I;
           }
           }
           return 0;
          }
          
      91  TerrainLayerDefinition* TerrainLayerDefinitionManager::getDefinitionForShader(  const std::string& shaderType )
          {
           for (  DefinitionStore::iterator I = mDefinitions.begin(   ); I != mDefinitions.end(   ); ++I ) {
           if (  (  *I )->getShaderName(   ) == shaderType ) {
           return *I;
           }
           }
           return 0;
          }
          
          
          }
          
          }

./components/ogre/terrain/TerrainLayerDefinitionManager.h

       1  //
          // C++ Interface: TerrainLayerDefinitionManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_TERRAINTERRAINLAYERDEFINITIONMANAGER_H
          #define EMBEROGRE_TERRAINTERRAINLAYERDEFINITIONMANAGER_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          #include <OgreResourceManager.h>
          #include "framework/Singleton.h"
          
          namespace EmberOgre {
          
          namespace Terrain {
          
      35  class TerrainLayerDefinition;
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      39  class TerrainLayerDefinitionManager : public Ogre::ResourceManager,   public Ember::Singleton<TerrainLayerDefinitionManager>
          {
          public:
           typedef std::vector<TerrainLayerDefinition*> DefinitionStore;
      43   TerrainLayerDefinitionManager(   );
          
      45   virtual ~TerrainLayerDefinitionManager(   );
          
      47   virtual void parseScript(  Ogre::DataStreamPtr &stream,   const Ogre::String &groupName );
          
           /**
           Adds a definition to the manager. This definition will be deleted by the manager upon destruction.
           @param definition A valid definition.
           */
      53   void addDefinition(  TerrainLayerDefinition* definition );
          
      55   const DefinitionStore& getDefinitions(   ) const;
          
      57   TerrainLayerDefinition* getDefinitionForArea(  int areaIndex );
      58   TerrainLayerDefinition* getDefinitionForShader(  const std::string& shaderType );
          
          protected:
      61   DefinitionStore mDefinitions;
          
      63   Ogre::Resource* createImpl(  const Ogre::String& name,   Ogre::ResourceHandle handle,  
      64   const Ogre::String& group,   bool isManual,   Ogre::ManualResourceLoader* loader,  
      65   const Ogre::NameValuePairList* createParams );
          };
          
          }
          
          }
          
          #endif

./components/ogre/terrain/TerrainPage.cpp

          //
          // C++ Implementation: TerrainPage
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          
          #include "TerrainPage.h"
          
          #include <OgreStringConverter.h>
          #include <OgreRenderSystemCapabilities.h>
          #include "TerrainShader.h"
          
          #include "../EmberOgre.h"
          
          #include <OgreRenderSystemCapabilities.h>
          
          #include <OgreCodec.h>
          #include <OgreImage.h>
          #include <OgreImageCodec.h>
          #include <OgreTextureManager.h>
          #include <OgreCommon.h>
          
          #include <IL/il.h>
          #include <IL/ilu.h>
          
          #include "../environment/Foliage.h"
          #include "../environment/FoliageArea.h"
          #include "TerrainGenerator.h"
          #include "ISceneManagerAdapter.h"
          
          #include <Mercator/Segment.h>
          #include <Mercator/Shader.h>
          
          #include <OgreHardwarePixelBuffer.h>
          
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/config/ConfigService.h"
          
          #include "framework/osdir.h"
          
          #include "TerrainPageSurfaceLayer.h"
          #include "TerrainPageSurface.h"
          #include "TerrainLayerDefinition.h"
          
          //#include <fenv.h>
          
          using namespace EmberOgre::Environment;
          
          namespace EmberOgre {
          namespace Terrain {
          
      71  TerrainPage::TerrainPage(  TerrainPosition position,   const std::map<const Mercator::Shader*,   TerrainShader*> shaderMap,   TerrainGenerator* generator )
          : mFoliageArea(  0 )
          ,   mGenerator(  generator )
          ,   mPosition(  position )
          // ,   mShaderMap(  shaderMap )
          // ,   mBytesPerPixel(  4 )
          ,   mTerrainSurface(  new TerrainPageSurface(  *this ) )
      78  ,   mShadow(  *this )
          ,   mShadowTechnique(  0 )
          ,   mExtent(  WFMath::Point<2>(  mPosition.x(   ) * (  getPageSize(   ) - 1 ),   (  mPosition.y(   ) - 1 ) * (  getPageSize(   ) - 1 ) ),   WFMath::Point<2>(  (  mPosition.x(   ) + 1 ) * (  getPageSize(   ) - 1 ),   (  mPosition.y(   ) ) * (  getPageSize(   ) - 1 ) )
           )
          {
          
           S_LOG_VERBOSE(  "Creating TerrainPage at position " << position.x(   ) << ":" << position.y(   ) );
           for (  int y = 0; y < getNumberOfSegmentsPerAxis(   ); ++y ) {
           for (  int x = 0; x < getNumberOfSegmentsPerAxis(   ); ++x ) {
           Mercator::Segment* segment = getSegment(  x,  y );
           if (  segment && segment->isValid(   ) ) {
           //S_LOG_VERBOSE(  "Segment is valid." );
           PageSegment pageSegment;
           pageSegment.pos = TerrainPosition(  x,  y );
           pageSegment.segment = segment;
           mValidSegments.push_back(  pageSegment );
           }
           }
           }
           S_LOG_VERBOSE(  "Number of valid segments: " << mValidSegments.size(   ) );
           setupShadowTechnique(   );
           mTerrainSurface->setShadow(  &mShadow );
          }
          
     102  TerrainPage::~TerrainPage(   )
          {
           delete mShadowTechnique;
          }
          
     107  Mercator::Segment* TerrainPage::getSegment(  int x,   int y ) const
          {
          // const TerrainInfo& info = mGenerator->getTerrainInfo(   );
           int segmentsPerAxis = getNumberOfSegmentsPerAxis(   );
           //the mPosition is in the middle of the page,   so we have to use an offset to get the real segment position
           //int segmentOffset = static_cast<int>(  info.getWorldSizeInSegments(   ). x(   ) * 0.5 );
           int segmentOffset = segmentsPerAxis;
           int segX = (  int )(  (  mPosition.x(   ) * segmentsPerAxis ) + x );
           int segY = (  int )(  (  mPosition.y(   ) * segmentsPerAxis ) + y ) - segmentOffset;
          
           //S_LOG_VERBOSE(  "Added segment with position " << segX << ":" << segY );
          
           return mGenerator->getTerrain(   ).getSegment(  segX,   segY );
          }
          
     122  int TerrainPage::getPageSize(   ) const
          {
           return mGenerator->getPageSize(   );
          }
          
          
     128  int TerrainPage::getNumberOfSegmentsPerAxis(   ) const
          {
           return (  getPageSize(   ) -1 ) / 64;
          }
          
     133  float TerrainPage::getMaxHeight(   )
          {
           float max = 0;
           for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
           max = std::max<float>(  max,   I->segment->getMax(   ) );
           }
           return max;
          }
          
     142  float TerrainPage::getMinHeight(   )
          {
           float min = 0;
           for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
           min = std::min<float>(  min,   I->segment->getMin(   ) );
           }
           return min;
          }
          
     151  void TerrainPage::update(   )
          {
           Ogre::Vector2 targetPage = Atlas2Ogre_Vector2(  mPosition );
          
           Ogre::Vector2 adjustedOgrePos(  targetPage.x + mGenerator->getTerrainInfo(   ).getPageOffsetX(   ),   targetPage.y + mGenerator->getTerrainInfo(   ).getPageOffsetY(   ) );
          
           S_LOG_VERBOSE(  "Updating terrain page at position x: " << adjustedOgrePos.x << " y: " << adjustedOgrePos.y );
           mGenerator->getAdapter(   )->reloadPage(  static_cast<unsigned int>(  adjustedOgrePos.x ),   static_cast<unsigned int>(  adjustedOgrePos.y ) );
          
          }
          
     162  void TerrainPage::setupShadowTechnique(   )
          {
           if (  mShadowTechnique ) {
           delete mShadowTechnique;
           }
           mShadowTechnique = new SimpleTerrainPageShadowTechnique(   );
           mShadow.setShadowTechnique(  mShadowTechnique );
          }
          
     171  void TerrainPage::createShadow(  const Ogre::Vector3& lightDirection )
          {
           mShadow.setLightDirection(  lightDirection );
           mShadow.createImage(   );
          /* Ogre::Technique* technique = mMaterial->getTechnique(  0 );
           Ogre::Pass* shadowPass = technique->createPass(   );
          
           shadowPass->setSceneBlending(  Ogre::SBT_MODULATE );
           shadowPass->setLightingEnabled(  false );
           shadowPass->setFog(  false );
          
          
           Ogre::TextureUnitState * textureUnitStateSplat = shadowPass->createTextureUnitState(   );
           textureUnitStateSplat->setTextureName(  mShadow.getTexture(   )->getName(   ) );
          
           textureUnitStateSplat->setTextureCoordSet(  0 );
          // textureUnitStateSplat->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
           textureUnitStateSplat->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
           textureUnitStateSplat->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
          // textureUnitStateSplat->setAlphaOperation(  Ogre::LBX_SOURCE1,   Ogre::LBS_TEXTURE,   Ogre::LBS_TEXTURE );
          // textureUnitStateSplat->setColourOperationEx(  Ogre::LBX_BLEND_DIFFUSE_ALPHA,   Ogre::LBS_CURRENT,   Ogre::LBS_TEXTURE );*/
          
          }
          
     195  void TerrainPage::updateShadow(  const Ogre::Vector3& lightDirection )
          {
           mShadow.setLightDirection(  lightDirection );
           mShadow.updateShadow(   );
          }
          
          
     202  Ogre::MaterialPtr TerrainPage::generateTerrainMaterials(   ) {
          
           mTerrainSurface->recompileMaterial(   );
           return mTerrainSurface->getMaterial(   );
          // //Ogre::ushort numberOfTextureUnitsOnCard = Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->getNumTextureUnits(   );
          //
          // if (  mMaterial.isNull(   ) ) {
          //
          // //create a name for out material
          // S_LOG_INFO(  "Creating a material for the terrain." );
          // std::stringstream materialNameSS;
          // materialNameSS << "EmberTerrain_Segment";
          // materialNameSS << "_" << mPosition.x(   ) << "_" << mPosition.y(   );
          // mMaterialName = materialNameSS.str(   );
          //
          // //create the actual material
          // mMaterial = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton(   ).create(  mMaterialName,   "General" ) );
          // } else {
          // mMaterial->removeAllTechniques(   );
          // mMaterial->createTechnique(   );
          // }
          //
          // //we'll use at least two different techniques
          // //for modern GPU's we'll use a technique which uses fragment shaders
          // if (  (  Ogre::GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "arbfp1" ) || Ogre::GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "ps_2_0" ) ) &&
          // (  Ogre::GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "arbvp1" ) || Ogre::GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "vs_2_0" ) )
          //  ) {
          // //generateTerrainTechniqueComplexAtlas(  mMaterial->getTechnique(  0 ) );
          // S_LOG_INFO(  "Try to create a complex material." );
          // // generateTerrainTechniqueComplex(  mMaterial->getTechnique(  0 ) );
          // generateTerrainTechniqueSimple(  mMaterial->getTechnique(  0 ) );
          // } else {
          // //and as a fallback for older gfx cards we'll supply a technique which doesn't
          // S_LOG_INFO(  "Try to create a simple material." );
          // generateTerrainTechniqueSimple(  mMaterial->getTechnique(  0 ) );
          // }
          // // generateTerrainTechniqueSimple(  mMaterial->getTechnique(  0 ) );
          //
          // //and if the user so wants,   we'll add some debug materials
          // /* if (  getTerrainOptions(   ).debuglod ) {
          // generateTerrainTechniqueDebug(   );
          // }*/
          //
          // mMaterial->load(   );
          //
          // return mMaterial;
          
          }
          
     251  SegmentVector& TerrainPage::getValidSegments(   )
          {
           return mValidSegments;
          }
          
          // inline const Ogre::TerrainOptions& TerrainPage::getTerrainOptions(   ) const
          // {
          // return mGenerator->getTerrainOptions(   );
          // }
          
     261  long TerrainPage::getVerticeCount(   ) const
          {
           return (  getPageSize(   ) ) *(  getPageSize(   ) );
          }
          
     266  const TerrainPosition& TerrainPage::getWFPosition(   ) const
          {
           return mPosition;
          }
          
          
     272  Ogre::MaterialPtr TerrainPage::getMaterial(   )
          {
          // generateTerrainMaterials(   );
           return mTerrainSurface->getMaterial(   );
          }
          
     278  unsigned int TerrainPage::getAlphaMapScale(   ) const
          {
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
           if (  configSrv->itemExists(  "terrain",   "scalealphamap" ) ) {
           int value = (  int )configSrv->getValue(  "terrain",   "scalealphamap" );
           //make sure it can't go below 1
           return std::max<int>(  1,   value );
           } else {
           return 1;
           }
          }
          
          
          
     292  void TerrainPage::createHeightData(  Ogre::Real* heightData )
          {
           int pageSizeInVertices = getPageSize(   );
           int pageSizeInMeters = pageSizeInVertices - 1;
          
           ///since Ogre uses a different coord system than WF,   we have to do some conversions here
           TerrainPosition origPosition(  mPosition );
           ///start in one of the corners...
           origPosition[0] = (  mPosition[0] * (  pageSizeInMeters ) );
           origPosition[1] = (  mPosition[1] * (  pageSizeInMeters ) );
          
           S_LOG_INFO(  "Page x:" << mPosition.x(   ) << " y:" << mPosition.y(   ) << " starts at x:" << origPosition.x(   ) << " y:" << origPosition.y(   ) );
          
           TerrainPosition position(  origPosition );
          
           for (  int i = 0; i < pageSizeInVertices; ++i ) {
           position = origPosition;
           position[1] = position[1] - i;
           for (  int j = 0; j < pageSizeInVertices; ++j ) {
           Ogre::Real height = mGenerator->getHeight(  position );
           *(  heightData++ ) = height;
           position[0] = position[0] + 1;
           }
           }
          
          }
          
          
          
          // Ogre::MemoryDataStreamPtr TerrainPage::convertWFAlphaTerrainToOgreFormat(  Ogre::uchar* dataStart,   short factor ) {
          // //int width = getTerrainOptions(   ).pageSize - 1;
          // int width = 64;
          // int bufferSize = width*width*mBytesPerPixel*factor*factor;
          // Ogre::MemoryDataStream chunk(  dataStart,   65*65,   false );
          // Ogre::MemoryDataStream* finalChunk = new Ogre::MemoryDataStream(  bufferSize );
          // //finalChunk->allocate(  bufferSize );
          // Ogre::uchar* finalPtr = finalChunk->getPtr(   );
          // Ogre::uchar* chunkPtr = chunk.getPtr(   );
          // long i,  j;
          // long sizeOfOneChannel = width*width;
          //
          // Ogre::uchar* tempPtr = finalPtr + bufferSize;
          // for (  i = 0; i < width; ++i ) {
          // for (  int l = 0; l < factor; ++l ) {
          // tempPtr -= (  width * mBytesPerPixel * factor );
          // for (  j = 0; j < width; ++j ) {
          // Ogre::uchar alpha = *(  chunkPtr + j );
          // for (  int k = 0; k < factor; ++k ) {
          // *(  tempPtr++ ) = 0;
          // *(  tempPtr++ ) = 0;
          // *(  tempPtr++ ) = 0;
          // *(  tempPtr++ ) = alpha;
          // }
          //
          // }
          // tempPtr -= (  width * mBytesPerPixel * factor );
          // }
          // chunkPtr += 65;
          // //++chunkPtr;
          // }
          // /*
          // Ogre::uchar* tempPtr = finalPtr;
          // for (  i = 0; i < width; ++i ) {
          // for (  j = 0; j < width; ++j ) {
          // Ogre::uchar alpha = *(  chunkPtr++ );
          // *tempPtr++ = 0;
          // *tempPtr++ = 0;
          // *tempPtr++ = 0;
          // *tempPtr++ = alpha;
          //
          // }
          // ++chunkPtr;
          // }
          // */
          //
          // return Ogre::MemoryDataStreamPtr(  finalChunk );
          // }
          
          // Ogre::TexturePtr TerrainPage::createAlphaTexture(  Ogre::String name,   Mercator::Surface* surface ) {
          //
          //
          // //the format for our alpha texture
          // //for some reason we can't use PF_A8
          // Ogre::PixelFormat pixelFormat = Ogre::PF_B8G8R8A8;
          //
          // /*first we need to change the 8 bit mask into 32 bits
          // * because somehow Ogre doesn't like the 8 bit mask
          // *
          // */
          // Ogre::MemoryDataStreamPtr finalChunk = convertWFAlphaTerrainToOgreFormat(  surface->getData(   ),   1 );
          //
          // //printTextureToImage(  finalChunk,   name,   pixelFormat );
          // Ogre::DataStreamPtr temp(  finalChunk.get(   ) );
          // //create the new alpha texture
          // Ogre::TexturePtr splatTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->loadRawData(  name,   "General",   temp,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ),   pixelFormat );
          // // finalChunk->clear(   );
          // // delete finalChunk;
          //
          // return splatTexture;
          //
          // }
          
          // void TerrainPage::printTextureToImage(  Ogre::MemoryDataStreamPtr dataChunk,   const Ogre::String name,   Ogre::PixelFormat pixelFormat,   int height,   int width ) {
          // // DEBUG
          // //prints the bitmap to a png-image
          // //TODO: remove when finished with debugging
          //
          // std::string dir = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getHomeDirectory(   );
          // if (  !oslink::directory(  dir ).isExisting(   ) ) {
          //
          // const Ogre::String extension = "png";
          //
          // Ogre::ImageCodec::ImageData* imgData = new Ogre::ImageCodec::ImageData(   );
          // imgData->width = width;
          // imgData->height = height;
          //
          // imgData->depth = 1;
          // imgData->format = pixelFormat;
          //
          // Ogre::Codec * pCodec = Ogre::Codec::getCodec(  extension );
          // // Write out
          // Ogre::SharedPtr<Ogre::Codec::CodecData> temp(  imgData );
          //
          // pCodec->codeToFile(  dataChunk,   dir + "/" + name + "." + extension,   temp );
          // }
          //
          // }
          
          // void TerrainPage::createShadow(   )
          // {
          // Mercator::Surface* surface;
          //
          // Ogre::MemoryDataStream* shadowChunk = new Ogre::MemoryDataStream(  getAlphaTextureSize(   ) * getAlphaTextureSize(   ) * 1,   false );
          //
          // memset(   shadowChunk->getPtr(   ),   '\0',   shadowChunk->size(   ) );
          //
          // ///we need an unique name for our alpha texture
          // std::stringstream shadowTextureNameSS;
          // shadowTextureNameSS << mMaterialName << "_shadow";
          // const Ogre::String shadowTextureName(  shadowTextureNameSS.str(   ) );
          //
          // mShadow.createShadowData(  shadowChunk->getPtr(   ) );
          //
          // Ogre::DataStreamPtr dataStreamPtr(  splatChunk );
          //
          // Ogre::Image* image = new Ogre::Image(   );
          // image->loadRawData(  dataStreamPtr,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ),   Ogre::PF_A8 );
          //
          // Ogre::TexturePtr splatTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->createManual(  shadowTextureName,   "General",   Ogre::TEX_TYPE_2D,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ),   1,   Ogre::PF_A8 );
          // splatTexture->loadImage(  *image );
          //
          //
          //
          // }
          
          
          
          
          
          // void TerrainPage::fillAlphaLayer(  unsigned char* finalImagePtr,   unsigned char* wfImagePtr,   unsigned int channel,   int startX,   int startY,   unsigned short numberOfChannels ) {
          //
          // int width = 64;
          // int finalImageWidth = getAlphaTextureSize(    );
          // long i,  j;
          //
          // Ogre::uchar* start = finalImagePtr + (  numberOfChannels * finalImageWidth * (  startY - 1 ) ) + (  (  startX - 1 ) * numberOfChannels );
          // Ogre::uchar* end = start + (  width * finalImageWidth * numberOfChannels ) + (  width * numberOfChannels );
          // ///we need to do this to get the alignment correct
          // wfImagePtr += 65;
          //
          // Ogre::uchar* tempPtr = end + channel + numberOfChannels;
          // for (  i = 0; i < width; ++i ) {
          // tempPtr -= (  width * numberOfChannels );
          // for (  j = 0; j < width; ++j ) {
          // Ogre::uchar alpha = *(  wfImagePtr + j );
          // *(  tempPtr ) = alpha;
          // ///advance the number of channels
          // tempPtr += numberOfChannels;
          //
          // }
          // tempPtr -= (  finalImageWidth * numberOfChannels );
          // wfImagePtr += 65;
          // }
          // }
          
     477  void TerrainPage::showFoliage(   )
          {
           if (  !mFoliageArea ) {
           prepareFoliage(   );
           }
           if (  mFoliageArea ) {
           mFoliageArea->setVisible(  true );
           }
          }
          
     487  void TerrainPage::hideFoliage(   )
          {
           if (  !mFoliageArea ) {
           return;
           }
           mFoliageArea->setVisible(  false );
          }
          
     495  void TerrainPage::destroyFoliage(   )
          {
           if (  !mFoliageArea ) {
           return;
           }
           Foliage::getSingleton(   ).destroyArea(  mFoliageArea );
           mFoliageArea = 0;
          }
          
          
          
     506  void TerrainPage::prepareFoliage(   )
          {
           TerrainShader* grassShader = mGenerator->getFoliageShader(   );
          
           if (  !grassShader ) {
           S_LOG_FAILURE(  "Could not create foliage since there's no grass shader registered." );
           return;
           }
           std::stringstream ss;
           ss << "Extents of page at position " << mPosition << ": " << mExtent;
           S_LOG_VERBOSE(  ss.str(   ) );
           if (  !mFoliageArea ) {
           mFoliageArea = Foliage::getSingleton(   ).createArea(  mExtent );
           } else {
           return;
           }
          
           TerrainPageSurfaceLayer* grassLayer(  0 );
           for (  TerrainPageSurface::TerrainPageSurfaceLayerStore::const_iterator I = mTerrainSurface->getLayers(   ).begin(   ); I != mTerrainSurface->getLayers(   ).end(   ); ++I ) {
           if (  I->second->getSurfaceIndex(   ) == mGenerator->getFoliageShader(   )->getTerrainIndex(   ) ) {
           grassLayer = I->second;
           break;
           }
           }
          
           if (  grassLayer ) {
           mFoliageArea->init(  mExtent,   static_cast<Ogre::TexturePtr>(  Ogre::TextureManager::getSingleton(   ).getByName(  grassLayer->getCoverageTextureName(   ) ) ),   mShadow.getTexture(   ) );
           }
          // double grassSpacing = Foliage::getSingleton(   ).getGrassSpacing(   );
          
          // //for each 1 m^2,   how big chance is there of grass? [0,  1.0]
          // Ogre::Real grassChanceThreshold = 1.0 / grassSpacing;
          //
          // int pageSizeInVertices = getPageSize(   );
          // int pageSizeInMeters = pageSizeInVertices - 1;
          //
          // ///since Ogre uses a different coord system than WF,   we have to do some conversions here
          // TerrainPosition worldUnitsStartOfPage(  mPosition );
          // ///start in one of the corners...
          // worldUnitsStartOfPage[0] = (  mPosition[0] * (  pageSizeInMeters ) );
          // worldUnitsStartOfPage[1] = (  mPosition[1] * (  pageSizeInMeters ) );
          //
          //
          // //for now,   just check with the grass shader
          // for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
          // Mercator::Segment* segment = I->segment;
          // Mercator::Surface* surface = grassShader->getSurfaceForSegment(  segment );
          // if (  !surface || !surface->isValid(   ) ) {
          // //we could not find any grass surface
          // continue;
          // }
          // int segmentStartX = static_cast<int>(  worldUnitsStartOfPage.x(   ) + (  I->pos.x(   ) * 64 ) );
          // int segmentStartY = static_cast<int>(  worldUnitsStartOfPage.y(   ) + (  I->pos.y(   ) * 64 ) - pageSizeInMeters );
          // std::stringstream ss;
          // /* ss << "Adding grass to the area between x: " << segmentStartX << " to " << (  segmentStartX + 64 ) << " and y: " << segmentStartY << " to " << (  segmentStartY + 64 );
          // S_LOG_VERBOSE(  ss.str(   ) );*/
          // for (  int x = 0; x < 64; ++x ) {
          // for (  int y = 0; y < 64; ++y ) {
          // //some random offset
          // Ogre::Real x_offset = Ogre::Math::RangeRandom(  -0.5,   0.5 );
          // Ogre::Real y_offset = Ogre::Math::RangeRandom(  -0.5,   0.5 );
          // TerrainPosition position(  segmentStartX + x + x_offset,   segmentStartY + y + y_offset );
          // float height = mGenerator->getHeight(  position );
          //
          // if (  height > 0 ) {
          // bool blocked = false;
          // for (  TerrainPageSurface::TerrainPageSurfaceLayerStore::const_iterator J = mTerrainSurface->getLayers(   ).begin(   ); J != mTerrainSurface->getLayers(   ).end(   ); ++J ) {
          // if (  J->second->getShader(   ) != grassShader->getShader(   ) && J->first ) {
          // Mercator::Surface* blockingSurface = J->second->getSurfaceForSegment(  segment );
          // if (  blockingSurface && blockingSurface->isValid(   ) ) {
          // unsigned char blockingAmount = (  (  *blockingSurface )(  x,   y,   0 ) );
          // if (  blockingAmount > 10 ) {
          // blocked = true;
          // break;
          // }
          // }
          // }
          // }
          // //blocked = false;
          // if (  !blocked ) {
          //
          // //first check if this is a good spot for grass (  the more "green",   the greater chance of grass
          // //then check with grassChanceThreshold if we should do grass
          // unsigned char cover = (  *surface )(  x,   y,   0 );
          // unsigned char coverChance = static_cast<unsigned char>(   Ogre::Math::RangeRandom(  0,   260 ) );
          // if (  cover > coverChance ) {
          // Ogre::Real grassChance = Ogre::Math::UnitRandom(   );
          // if (  grassChanceThreshold > grassChance ) {
          // const Ogre::Vector3 scale(  1,   Ogre::Math::RangeRandom(  0.5,   0.8 ),   1 );
          //
          // // std::string type(  "placeholder" );
          // std::string type(  "bittergrass" );
          // Ogre::Vector3 ogrePosition = Atlas2Ogre(  position );
          // ogrePosition.y = height;
          // if (  Ogre::Math::UnitRandom(   ) > 0.95 ) {
          // type = "heartblood";
          // }
          // if (  height > 1000 || height < -1000 ) {
          // S_LOG_WARNING(  "Incorrect height (  " << height << " ) set for foliage position x: " << position.x(   ) << " y: " << position.y(   ) );
          // } else {
          // mFoliageArea->placeGrass(  type,   ogrePosition,   scale );
          // }
          // }
          // }
          // }
          // }
          // }
          // }
          // }
          // mFoliageArea->build(   );
          // mFoliageArea->setVisible(  false );
           return;
          
          }
          
     621  void TerrainPage::addShader(  TerrainShader* shader )
          {
           TerrainPageSurfaceLayer* layer = mTerrainSurface->createSurfaceLayer(  shader->getTerrainIndex(   ),   shader->getShader(   ) );
           layer->setDiffuseTextureName(  shader->getLayerDefinition(   )->getDiffuseTextureName(   ) );
           layer->setNormalTextureName(  shader->getLayerDefinition(   )->getNormalMapTextureName(   ) );
           ///get the scale by dividing the total size of the page with the size of each tile
           float scale = getAlphaTextureSize(   ) / shader->getLayerDefinition(   )->getTileSize(   );
           layer->setScale(  scale );
           layer->updateCoverageImage(   );
          
          /* mUsedShaders.push_back(  shader );
           ///if the material already has been created,   add the shader instantly,   else wait until the generateTerrainMaterials method is called
          
           if (  !mMaterial.isNull(   ) ) {
          // populateSurfaces(   );
           addShaderToSimpleTechnique(  mMaterial->getTechnique(  0 ),   shader );
           }*/
          }
          
          
          
          // void TerrainPage::generateTerrainTechniqueComplexAtlas(   Ogre::Technique* technique )
          // {
          //
          // Ogre::Pass* pass = technique->getPass(  0 );
          // //pass->setLightingEnabled(  false );
          // //pass->setFragmentProgram(  "splat3arb" );
          // pass->setFragmentProgram(  "splatatlas_cg" );
          //
          //
          // //pass->setSceneBlending(  Ogre::SBT_TRANSPARENT_ALPHA );
          //
          // Ogre::TextureUnitState * alphaTextureUnitState = pass->createTextureUnitState(   );
          //
          //
          // //use this iterator to iterate over all shaders we will use. The first shader will be used as a base (  i.e. with no alpha map ),   so make sure that it's something like rock or dirt (  upon which one would want to put some grass etc. )
          // std::list<TerrainShader*>::iterator shadersIterator = mUsedShaders.begin(   );
          //
          // //we'll start by getting a the first surface of the first segment,   since we're only interested in the name of the texture used for the backdrop (  we won't be needing any alpha texture )
          // Mercator::Segment* aValidSegment = 0;
          //
          // if (  mValidSegments.begin(   ) == mValidSegments.end(   ) ) {
          // return;
          // }
          // aValidSegment = mValidSegments.begin(   )->segment;
          //
          // Mercator::Surface* surface = (  *shadersIterator )->getSurfaceForSegment(  aValidSegment );
          //
          //
          // //we need an unique name for our alpha texture
          // std::stringstream splatTextureNameSS;
          // splatTextureNameSS << mMaterialName;
          // Ogre::String splatTextureName(  splatTextureNameSS.str(   ) );
          //
          // //the format for our alpha texture
          // Ogre::PixelFormat pixelFormat = Ogre::PF_B8G8R8A8;
          //
          // // //let's create our map image
          // // ILuint mapImageName;
          // // ilGenImages(   1,   &mapImageName  );
          // // ilBindImage(   mapImageName  );
          // // ilTexImage(  getAlphaTextureSize(   ) ,   getAlphaTextureSize(   ),   1,   3,   IL_RGB,   IL_UNSIGNED_BYTE,   0  );
          // // unsigned char * mapImagePointer = ilGetData(   );
          //
          //
          //
          //
          // ILuint ImageName;
          // ilGenImages(   1,   &ImageName  );
          // ilBindImage(   ImageName  );
          // ilTexImage(  getAlphaTextureSize(   ) ,   getAlphaTextureSize(   ),   1,   mBytesPerPixel,   IL_BGRA,   IL_UNSIGNED_BYTE,   0  );
          // unsigned char * imagePointer = ilGetData(   );
          //
          // //clear the image
          // memset (  imagePointer,   0,   getAlphaTextureSize(   ) * getAlphaTextureSize(   ) * mBytesPerPixel );
          //
          // Ogre::MemoryDataStream* finalChunk = new Ogre::MemoryDataStream(  imagePointer,   getAlphaTextureSize(   ) * getAlphaTextureSize(   ) * mBytesPerPixel,   false );
          //
          //
          //
          //
          //
          // //now loop over all the remaining surfaces,   and for each surface create a common alpha image from the different segments
          //
          // /* int numberOfSegmentsToDo = aValidSegment->getSurfaces(   ).size(   ) - 1; //we've already done the base
          // for (  int i = 0; i < numberOfSegmentsToDo; ++i ) {*/
          //
          // // size_t numberOfbaseTextureUnits = pass->getNumTextureUnitStates(   );
          // int splattextureChannel = 0;
          // ++shadersIterator;
          // for (  ; shadersIterator != mUsedShaders.end(   ) ; ++shadersIterator ) {
          //
          // // TerrainShader* shader;
          //
          // //check if at least one surface instersects,   else continue
          // bool intersects = false;
          // // for(  std::vector<std::list<Mercator::Surface*>::iterator>::iterator I = surfaceListIterators.begin(   ); I != surfaceListIterators.end(   ); ++I ) {
          // for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
          // if (  (  *shadersIterator )->getShader(   )->checkIntersect(  *I->segment ) ) {
          // intersects = true;
          // }
          // }
          //
          // /* if (  !intersects ) {
          // continue;
          // }*/
          //
          //
          // for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
          // Mercator::Segment* segment = I->segment;
          // if (  segment && segment->isValid(   ) && splattextureChannel < 4 ) {
          //
          // surface = (  *shadersIterator )->getSurfaceForSegment(  segment );
          // if (  surface && surface->isValid(   ) ) {
          //
          // fillAlphaLayer(  finalChunk->getPtr(   ),   surface->getData(   ),   splattextureChannel,   (  int )I->pos.x(   ) * 64,   (  getNumberOfSegmentsPerAxis(   ) - (  int )I->pos.y(   ) - 1 ) * 64,   4 );
          // }
          // }
          // }
          // ++splattextureChannel;
          // }
          // Ogre::TextureUnitState * splatTextureUnitState = pass->createTextureUnitState(   );
          // splatTextureUnitState->setTextureName(  "atlassplat.png" );
          // splatTextureUnitState->setTextureCoordSet(  1 );
          // splatTextureUnitState->setTextureScale(  0.025,   0.025 );
          // splatTextureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
          //
          //
          // ilBindImage(  ImageName );
          // /* char name[100];
          // strcpy(  name,   (  std::string(  "/home/erik/" ) + splatTextureName + std::string(  ".png" ) ).c_str(   ) );
          // ilSaveImage(  name );*/
          //
          // if (  getAlphaMapScale(   ) > 1 ) {
          //
          // //smooth out the terrain
          // //do this by enlarging the image and apply a blur filter to it
          //
          // //use filter to smooth everything out
          // iluImageParameter(  ILU_FILTER,   ILU_SCALE_BSPLINE );
          // iluScale(  getAlphaTextureSize(   ) * getAlphaMapScale(   ),   getAlphaTextureSize(   ) * getAlphaMapScale(   ),   1 );
          // imagePointer = ilGetData(   );
          // //wrap the image data in a Datachunk
          // delete finalChunk;
          // finalChunk = new Ogre::MemoryDataStream(  imagePointer,   getAlphaTextureSize(   ) * getAlphaTextureSize(   ) * mBytesPerPixel * (  getAlphaMapScale(   ) * getAlphaMapScale(   ) ) ,   false );
          // }
          //
          // Ogre::DataStreamPtr dataStreamPtr(  finalChunk );
          //
          //
          //
          // Ogre::TexturePtr splatTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->loadRawData(  splatTextureName,   "General",   dataStreamPtr,   getAlphaTextureSize(   ) * getAlphaMapScale(   ),   getAlphaTextureSize(   ) * getAlphaMapScale(   ),   pixelFormat );
          // /* temp.setNull(   );
          // splatTexture.setNull(   );*/
          // if (  getAlphaMapScale(   ) > 1 ) {
          // ilDeleteImages(  1,   &ImageName );
          // }
          // alphaTextureUnitState->setTextureName(  splatTextureName );
          // alphaTextureUnitState->setTextureCoordSet(  0 );
          // alphaTextureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
          //
          //
          //
          //
          // }
          //
          
          
          // void TerrainPage::generateTerrainTechniqueComplex(   Ogre::Technique* technique )
          // {
          //
          // S_LOG_VERBOSE(  "Entered generateTerrainTechniqueComplex." );
          // Ogre::Pass* pass = technique->getPass(  0 );
          // //pass->setLightingEnabled(  false );
          //
          // try {
          // //add fragment shader for splatting
          // pass->setFragmentProgram(  "splat_cg" );
          //
          // Ogre::GpuProgramParametersSharedPtr fpParams = Ogre::GpuProgramManager::getSingleton(   ).createParameters(   );
          // // fpParams->setAutoAddParamName(  true );
          // //set how much the texture should tile,   perhaps this shouldn't be placed here...
          // fpParams->setNamedConstant(  "tile",   50 );
          // pass->setFragmentProgramParameters(  fpParams );
          //
          //
          // //add vertex shader for fog
          // pass->setVertexProgram(  "fog_linear_vp" );
          // } catch (  const Ogre::Exception& ) {
          // //if there was some kind of error,   go with the simple technique
          // S_LOG_INFO(  "Falling back to simple technique." );
          // generateTerrainTechniqueSimple(  technique );
          // return;
          // }
          //
          // //pass->setSceneBlending(  Ogre::SBT_TRANSPARENT_ALPHA );
          //
          // Ogre::TextureUnitState * alphaTextureUnitState = pass->createTextureUnitState(    );
          //
          //
          // //use this iterator to iterate over all shaders we will use. The first shader will be used as a base (  i.e. with no alpha map ),   so make sure that it's something like rock or dirt (  upon which one would want to put some grass etc. )
          // std::list<TerrainShader*>::iterator shadersIterator = mUsedShaders.begin(   );
          //
          // //we'll start by getting a the first surface of the first segment,   since we're only interested in the name of the texture used for the backdrop (  we won't be needing any alpha texture )
          // Mercator::Segment* aValidSegment = 0;
          //
          // if (  mValidSegments.begin(   ) == mValidSegments.end(   ) ) {
          // return;
          // }
          // aValidSegment = mValidSegments.begin(   )->segment;
          //
          // Mercator::Surface* surface = (  *shadersIterator )->getSurfaceForSegment(  aValidSegment );
          //
          // // pass->setShininess(  20 );
          // // pass->setSpecular(  1,  1,  1,  1 );
          //
          // //granite layer
          // Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState(   );
          // {
          // textureUnitState->setTextureName(  (  *shadersIterator )->getTextureName(   ) );
          // // textureUnitState->setTextureName(  "splat3d.dds" );
          // //textureUnitState->setTextureScale(  0.01,   0.01 );
          // textureUnitState->setTextureCoordSet(  0 );
          // textureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
          // }
          //
          //
          // //we need an unique name for our alpha texture
          // std::stringstream splatTextureNameSS;
          // splatTextureNameSS << mMaterialName;
          // Ogre::String splatTextureName(  splatTextureNameSS.str(   ) );
          //
          // //the format for our alpha texture
          // Ogre::PixelFormat pixelFormat = Ogre::PF_B8G8R8A8;
          //
          // // //let's create our map image
          // // ILuint mapImageName;
          // // ilGenImages(   1,   &mapImageName  );
          // // ilBindImage(   mapImageName  );
          // // ilTexImage(  getAlphaTextureSize(   ) ,   getAlphaTextureSize(   ),   1,   3,   IL_RGB,   IL_UNSIGNED_BYTE,   0  );
          // // unsigned char * mapImagePointer = ilGetData(   );
          //
          //
          //
          //
          // ILuint ImageName;
          // ilGenImages(   1,   &ImageName  );
          // ilBindImage(   ImageName  );
          // ilTexImage(  getAlphaTextureSize(   ) ,   getAlphaTextureSize(   ),   1,   mBytesPerPixel,   IL_BGRA,   IL_UNSIGNED_BYTE,   0  );
          // unsigned char * imagePointer = ilGetData(   );
          //
          // //clear the image
          // memset (  imagePointer,   0,   getAlphaTextureSize(   ) * getAlphaTextureSize(   ) * mBytesPerPixel );
          //
          // Ogre::MemoryDataStream* finalChunk = new Ogre::MemoryDataStream(  imagePointer,   getAlphaTextureSize(   ) * getAlphaTextureSize(   ) * mBytesPerPixel,   false );
          //
          //
          //
          //
          // //now loop over all the remaining surfaces,   and for each surface create a common alpha image from the different segments
          //
          // /* int numberOfSegmentsToDo = aValidSegment->getSurfaces(   ).size(   ) - 1; //we've already done the base
          // for (  int i = 0; i < numberOfSegmentsToDo; ++i ) {*/
          //
          // size_t numberOfbaseTextureUnits = pass->getNumTextureUnitStates(   );
          // ++shadersIterator;
          // for (  ; shadersIterator != mUsedShaders.end(   ) ; ++shadersIterator ) {
          //
          // // TerrainShader* shader;
          //
          // //check if at least one surface instersects,   else continue
          // bool intersects = false;
          // // for(  std::vector<std::list<Mercator::Surface*>::iterator>::iterator I = surfaceListIterators.begin(   ); I != surfaceListIterators.end(   ); ++I ) {
          // for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
          // if (  (  *shadersIterator )->getShader(   )->checkIntersect(  *I->segment ) ) {
          // intersects = true;
          // }
          // }
          //
          // /* if (  !intersects ) {
          // continue;
          // }*/
          //
          //
          // for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
          // Mercator::Segment* segment = I->segment;
          // if (  segment && segment->isValid(   ) && pass->getNumTextureUnitStates(   ) < 4 ) {
          //
          // surface = (  *shadersIterator )->getSurfaceForSegment(  segment );
          // if (  surface && surface->isValid(   ) ) {
          // //use four channels
          // fillAlphaLayer(  finalChunk->getPtr(   ),   surface->getData(   ),   pass->getNumTextureUnitStates(   ) - numberOfbaseTextureUnits,   (  (  int )I->pos.x(   ) * 64 ),   (  getNumberOfSegmentsPerAxis(   ) - (  int )I->pos.y(   ) - 1 ) * 64,   4 );
          // }
          // }
          // }
          // //TODO: make it not hard coded to 4
          // if (  pass->getNumTextureUnitStates(   ) < 4 ) {
          // Ogre::TextureUnitState * splatTextureUnitState = pass->createTextureUnitState(   );
          // splatTextureUnitState->setTextureName(  (  *shadersIterator )->getTextureName(   ) );
          // splatTextureUnitState->setTextureCoordSet(  0 );
          // //splatTextureUnitState->setTextureScale(  0.01,   0.01 );
          // splatTextureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
          // }
          //
          //
          // }
          //
          //
          // //printTextureToImage(  Ogre::MemoryDataStreamPtr(  new Ogre::MemoryDataStream(  *finalChunk,   true ) ),   splatTextureName,   pixelFormat,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ) );
          //
          // ilBindImage(  ImageName );
          // /* char name[100];
          // strcpy(  name,   (  std::string(  "/home/erik/" ) + splatTextureName + std::string(  ".png" ) ).c_str(   ) );
          // ilSaveImage(  name );*/
          //
          // if (  getAlphaMapScale(   ) > 1 ) {
          //
          // //smooth out the terrain
          // //do this by enlarging the image and apply a blur filter to it
          //
          // //use filter to smooth everything out
          // iluImageParameter(  ILU_FILTER,   ILU_SCALE_BSPLINE );
          // iluScale(  getAlphaTextureSize(   ) * getAlphaMapScale(   ),   getAlphaTextureSize(   ) * getAlphaMapScale(   ),   1 );
          // imagePointer = ilGetData(   );
          // //wrap the image data in a Datachunk
          // delete finalChunk;
          // finalChunk = new Ogre::MemoryDataStream(  imagePointer,   getAlphaTextureSize(   ) * getAlphaTextureSize(   ) * mBytesPerPixel * (  getAlphaMapScale(   ) * getAlphaMapScale(   ) ) ,   false );
          // }
          //
          // Ogre::DataStreamPtr dataStreamPtr(  finalChunk );
          //
          //
          //
          //
          // Ogre::TexturePtr splatTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->loadRawData(  splatTextureName,   "General",   dataStreamPtr,   getAlphaTextureSize(   ) * getAlphaMapScale(   ),   getAlphaTextureSize(   ) * getAlphaMapScale(   ),   pixelFormat );
          // /* temp.setNull(   );
          // splatTexture.setNull(   );*/
          // if (  getAlphaMapScale(   ) > 1 ) {
          // ilDeleteImages(  1,   &ImageName );
          // }
          // alphaTextureUnitState->setTextureName(  splatTextureName );
          // alphaTextureUnitState->setTextureCoordSet(  0 );
          // alphaTextureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
          //
          //
          //
          //
          // }
          //
          // void TerrainPage::generateTerrainTechniqueDebug(   )
          // {
          // for (  int i = 1; i < 5; ++i ) {
          // Ogre::Technique *tech = mMaterial->createTechnique(   );
          // tech->setLodIndex(  i );
          //
          // Ogre::TextureUnitState *textureUnitState = tech->createPass(   )->createTextureUnitState(   );
          // std::stringstream ss;
          // ss << "lod" << i << ".png";
          // textureUnitState->setTextureName(  ss.str(   ) );
          // textureUnitState->setTextureCoordSet(  0 );
          //
          // }
          // }
          //
          // void TerrainPage::generateTerrainTechniqueSimple(   Ogre::Technique* technique )
          // {
          // S_LOG_VERBOSE(  "Entered generateTerrainTechniqueSimple." );
          //
          // Mercator::Segment* segment = mGenerator->getTerrain(   ).getSegment(  (  int )mPosition.x(   ),   (  int )mPosition.y(   ) );
          //
          // // Ogre::ushort numberOfTextureUnitsOnCard = Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->getNumTextureUnits(   );
          //
          //
          // std::list<TerrainShader*>::iterator shadersIterator = mUsedShaders.begin(   );
          //
          //
          //
          // //we'll start by getting a the first surface of the first segment,   since we're only interested in the name of the texture used for the backdrop (  we won't be needing any alpha texture )
          // Mercator::Segment* aValidSegment = 0;
          //
          // if (  mValidSegments.begin(   ) == mValidSegments.end(   ) ) {
          // return;
          // }
          // aValidSegment = mValidSegments.begin(   )->segment;
          //
          // // Mercator::Surface* surface = (  *shadersIterator )->getSurfaceForSegment(  aValidSegment );
          // // Mercator::Surface* surface = *aValidSegment->getSurfaces(   ).begin(   );
          //
          // Ogre::Pass* pass = technique->getPass(  0 );
          // //pass->setSelfIllumination(  Ogre::ColourValue(  0.5f,  0.5f,  0.5f ) );
          // //pass->setLightingEnabled(  false );
          // //pass->setSceneBlending(  Ogre::SBT_TRANSPARENT_ALPHA );
          //
          //
          // const Mercator::Segment::Surfacestore & surfaces = segment->getSurfaces(   );
          // Mercator::Segment::Surfacestore::const_iterator I = surfaces.begin(   );
          //
          // // pass->setShininess(  20 );
          // // pass->setSpecular(  1,  1,  1,  1 );
          // ///add the first layer of the terrain,   no alpha or anything
          // Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState(   );
          // textureUnitState->setTextureScale(  0.025,   0.025 );
          // textureUnitState->setTextureName(  (  *shadersIterator )->getTextureName(   ) );
          // textureUnitState->setTextureCoordSet(  0 );
          //
          //
          //
          //
          //
          // //now loop over all the remaining surfaces,   and for each surface create a common alpha image from the different segments
          //
          // // int numberOfSurfacesToDo = aValidSegment->getSurfaces(   ).size(   ) - 1; //we've already done the base
          // // for (  int i = 0; i < numberOfSurfacesToDo; ++i ) {
          // ++shadersIterator;
          // for (  ; shadersIterator != mUsedShaders.end(   ) ; ++shadersIterator ) {
          // addShaderToSimpleTechnique(  technique,   *shadersIterator );
          // }
          //
          //
          //
          // }
          
          
    1044  void TerrainPage::populateSurfaces(   )
          {
           // _fpreset(   );
           //_controlfp(  _PC_64,   _MCW_PC );
           //_controlfp(  _RC_NEAR,   _MCW_RC );
          
          
           for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
           I->segment->populateSurfaces(   );
           }
          // fesetround(  FE_DOWNWARD );
          }
          
    1057  void TerrainPage::updateAllShaderTextures(   )
          {
           TerrainPageSurface::TerrainPageSurfaceLayerStore::const_iterator I = mTerrainSurface->getLayers(   ).begin(   );
          
           ///skip the first texture,   since it's the ground,   and doesn't have an alpha texture
           ++I;
           for (  ; I != mTerrainSurface->getLayers(   ).end(   ); ++I ) {
           mTerrainSurface->updateLayer(  I->first );
           }
          }
          
    1068  void TerrainPage::updateShaderTexture(  TerrainShader* shader )
          {
          
           if (  mTerrainSurface->getLayers(   ).find(  shader->getTerrainIndex(   ) ) == mTerrainSurface->getLayers(   ).end(   ) ) {
           addShader(  shader );
           mTerrainSurface->recompileMaterial(   );
           } else {
           mTerrainSurface->updateLayer(  shader->getTerrainIndex(   ) );
           mTerrainSurface->recompileMaterial(   );
           }
          
           ///check if at least one surface intersects,   else continue
          // bool intersects = false;
          // for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
          // if (  shader->getShader(   )->checkIntersect(  *I->segment ) ) {
          // intersects = true;
          // break;
          // }
          // }
          // if (  !intersects ) {
          // return;
          // }
          //
          // bool found = false;
          // for (  std::list<TerrainShader*>::iterator I = mUsedShaders.begin(   ); I != mUsedShaders.end(   ); ++I ) {
          // if (  *I == shader ) {
          // found = true;
          // break;
          // }
          // }
          // if (  !found ) {
          // addShader(  shader );
          // } else if (  mShaderTextures.find(  shader ) == mShaderTextures.end(   ) ) {
          // addShaderToSimpleTechnique(  mMaterial->getTechnique(  0 ),   shader );
          // } else {
          //
          //
          // //update the alpha texture
          // //we do this by first creating a new,   empty data chunk
          // //we fill this chunk with the correct alpha values through the fillAlphaLayer method
          // //from this chunk we'll then create a temporary image
          // //we'll then blit from the image directly to the hardware buffer
          // //and when we go out of scope the temporary image is deleted along with the data chunk
          //
          // Ogre::TexturePtr texture = mShaderTextures.find(  shader )->second;
          //
          // Mercator::Surface* surface;
          //
          // ///Create a new image. This image is temporary (  since it will be blitted into the hardware memory ) and destruction of it will be taken care of by the enveloping DataStreamPtr.
          // Ogre::MemoryDataStream* splatChunk = new Ogre::MemoryDataStream(  getAlphaTextureSize(   ) * getAlphaTextureSize(   ) * 1,   true );
          // Ogre::DataStreamPtr dataStreamPtr(  splatChunk );
          // Ogre::Image image; ///the image to hold the data
          //
          // ///make sure we clear the image
          // memset(   splatChunk->getPtr(   ),   '\0',   splatChunk->size(   ) );
          // for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
          // Mercator::Segment* segment = I->segment;
          // if (  shader->getShader(   )->checkIntersect(  *segment ) ) {
          // surface = shader->getSurfaceForSegment(  segment );
          // if (  surface && surface->isValid(   ) ) {
          //
          // int alphaChannel = 0;
          // //use only one channel
          // fillAlphaLayer(  splatChunk->getPtr(   ),   surface->getData(   ),   alphaChannel,   (  int )I->pos.x(   ) * 64,   (  getNumberOfSegmentsPerAxis(   ) - (  int )I->pos.y(   ) - 1 ) * 64,   1 );
          // }
          // }
          // }
          //
          // Ogre::HardwarePixelBufferSharedPtr hardwareBuffer = texture->getBuffer(   );
          //
          // image.loadRawData(  dataStreamPtr,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ),   Ogre::PF_A8 );
          // //image->save(  std::string(  "/home/erik/tempimages/" ) + texture->getName(   ) + "_temp" + std::string(  ".png" ) );
          //
          //
          // ///blit the whole image to the hardware buffer
          // Ogre::PixelBox sourceBox = image.getPixelBox(   );
          // //Ogre::Box targetBox(  0,  0,   texture->getWidth(   ),   texture->getHeight(   ) );
          // hardwareBuffer->blitFromMemory(  sourceBox );
          //
          // }
          
          }
          
          
          
          
          // void TerrainPage::addShaderToSimpleTechnique(  Ogre::Technique* technique,   TerrainShader* shader )
          // {
          // Mercator::Surface* surface;
          //
          // ///check if at least one surface intersects,   else continue
          // bool intersects = false;
          // // for(  std::vector<std::list<Mercator::Surface*>::iterator>::iterator I = surfaceListIterators.begin(   ); I != surfaceListIterators.end(   ); ++I ) {
          // for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
          // if (  shader->getShader(   )->checkIntersect(  *I->segment ) ) {
          // intersects = true;
          // }
          // }
          // if (  !intersects ) {
          // return;
          // }
          //
          // Ogre::MemoryDataStream* splatChunk = new Ogre::MemoryDataStream(  getAlphaTextureSize(   ) * getAlphaTextureSize(   ) * 1,   false );
          //
          // memset(   splatChunk->getPtr(   ),   '\0',   splatChunk->size(   ) );
          //
          // ///we need an unique name for our alpha texture
          // std::stringstream splatTextureNameSS;
          // splatTextureNameSS << mMaterialName << "_" << shader->getTerrainIndex(   );
          // const Ogre::String splatTextureName(  splatTextureNameSS.str(   ) );
          //
          //
          // /* SegmentVector::iterator I = segmentI_begin;*/
          //
          // for (  SegmentVector::iterator I = mValidSegments.begin(   ); I != mValidSegments.end(   ); ++I ) {
          // if (  shader->getShader(   )->checkIntersect(  *I->segment ) ) {
          // surface = shader->getSurfaceForSegment(  I->segment );
          // if (  surface && surface->isValid(   ) ) {
          //
          // int alphaChannel = 0;
          // ///use only one channel
          // fillAlphaLayer(  splatChunk->getPtr(   ),   surface->getData(   ),   alphaChannel,   (  int )I->pos.x(   ) * 64,   (  getNumberOfSegmentsPerAxis(   ) - (  int )I->pos.y(   ) - 1 ) * 64,   1 );
          //
          // }
          // }
          // }
          //
          // Ogre::DataStreamPtr dataStreamPtr(  splatChunk );
          //
          // Ogre::Image* image = new Ogre::Image(   );
          // image->loadRawData(  dataStreamPtr,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ),   Ogre::PF_A8 );
          // //image->save(  std::string(  "~/tempimages/" ) + splatTextureName + "_temp" + std::string(  ".png" ) );
          //
          // // Ogre::TexturePtr splatTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->loadRawData(  splatTextureName,   "General",   dataStreamPtr,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ),   Ogre::PF_B8G8R8A8 );
          // // Ogre::TexturePtr splatTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->loadRawData(  splatTextureName,   "General",   dataStreamPtr,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ),   Ogre::PF_A8 );
          //
          // // Ogre::TexturePtr splatTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->loadRawData(  splatTextureName,   "General",   dataStreamPtr,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ),   Ogre::PF_B8G8R8A8 );
          // Ogre::TexturePtr splatTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->createManual(  splatTextureName,   "General",   Ogre::TEX_TYPE_2D,   getAlphaTextureSize(   ),   getAlphaTextureSize(   ),   1,   Ogre::PF_A8 );
          // splatTexture->loadImage(  *image );
          //
          // /* char name[100];
          // strcpy(  name,   (  std::string(  "/home/erik/tempimages/" ) + splatTextureName + "_temp" + std::string(  ".png" ) ).c_str(   ) );
          // ilSaveImage(  name ); */
          //
          // mShaderTextures[shader] = splatTexture;
          //
          // shader->addSplatToTechnique(  technique,   splatTextureName );
          /*
          * TODO: implement this in a more efficient manner
           if (  pass->getNumTextureUnitStates(   ) < numberOfTextureUnitsOnCard - 1 ) {
           //there's room for two more texture unit states
           shader->addTextureUnitsToPass(  pass,   splatTextureName );
           } else {
           //we need to use a new pass,   else we would run out of texture units
           pass = shader->addPassToTechnique(  material->getTechnique(  0 ),   splatTextureName );
           }
          */
          
          
          
          
          
          // }
          }
          }

./components/ogre/terrain/TerrainPage.h

       1  //
          // C++ Interface: TerrainPage
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRETERRAINPAGE_H
          #define EMBEROGRETERRAINPAGE_H
          
          #include "../EmberOgrePrerequisites.h"
          
          #include <Mercator/Terrain.h>
          #include <Mercator/Segment.h>
          #include <Mercator/Surface.h>
          #include "../MathConverter.h"
          
          namespace EmberOgre {
          
          struct PageSegment
          {
           TerrainPosition pos;
           Mercator::Segment* segment;
          };
          
          typedef std::vector<PageSegment> SegmentVector;
          }
          
          #include "TerrainPageShadow.h"
          
          namespace Ogre
          {
      48   class TerrainOptions;
          }
          
      51  namespace EmberOgre {
          namespace Environment {
          class FoliageArea;
          }
          namespace Terrain {
          class TerrainShader;
          class TerrainGenerator;
          class TerrainPageSurface;
          
          
          // TYPEDEF_STL_VECTOR(  Mercator::Segment*,   SegmentVector );
          TYPEDEF_STL_MAP(  const Mercator::Shader*,   TerrainShader*,   ShaderMap );
          
          
          
          /**
          
          This is a bridge class between one Ogre::TerrainPage instance and one or many Mercator::Segment.
          
          
          @author Erik Hjortsberg
          */
          class TerrainPage{
          friend class TerrainPageShadow;
          friend class ITerrainPageShadowTechnique;
          public:
           TerrainPage(  TerrainPosition position,   const std::map<const Mercator::Shader*,   TerrainShader*> shaderMap,   TerrainGenerator* generator );
          
           ~TerrainPage(   );
          
          
           /**
           * The number of Mercator::Segments for each axis. I.e. the root of the total number of segments.
           * Mainly used to check if it's 1,   in which case everything becomes much easier.
           * @return
           */
           int getNumberOfSegmentsPerAxis(   ) const;
          
          
           /**
           * The max height of this page
           * @return
           */
           float getMaxHeight(   );
          
           /**
           * The minimum height of this page
           * @return
           */
           float getMinHeight(   );
          
          
           /**
           * Generates the terrain materials needed.
           * @return
           */
           Ogre::MaterialPtr generateTerrainMaterials(   );
          
           /**
           * Fills the supplied data buffer with height data. Make sure that the supplied buffer can take getVerticeCount(   ) number of elements.
           * @param heightData
           */
           void createHeightData(  Ogre::Real* heightData );
          
           /**
           * The total number of vertices used for this page
           * @return
           */
           long getVerticeCount(   ) const;
          
           /**
           * The position of the page in Worldforge space
           * @return
           */
           const TerrainPosition& getWFPosition(   ) const;
          
          
           /**
           * The material used for the page
           * @return
           */
           Ogre::MaterialPtr getMaterial(   );
          
           /**
           * creates a new foliage for this page,   but does not show it yet
           */
           void prepareFoliage(   );
          
           /**
           * shows the foliage for this page,   if no foliage exists it's created
           */
           void showFoliage(   );
          
          
           /**
           * hides the foliage for this page,   but does not destroy it
           */
           void hideFoliage(   );
          
          
           /**
           * destroys the foliage for this page
           */
           void destroyFoliage(   );
          
           /**
           * this adds a shader to the page,   meaning that it will be used in rendering
           * @param shader
           */
           void addShader(  TerrainShader* shader );
          
           /**
           * Updates the shader texture for the specific shader
           * @param shader
           */
           void updateShaderTexture(  TerrainShader* shader );
          
           /**
           * Updates all the shader textures of the page.
           * You should usually call this after you've made a change to the terrain and already have called populateSurfaces(   )
           */
           void updateAllShaderTextures(   );
          
           void populateSurfaces(   );
          
           int getPageSize(   ) const ;
          
           void update(   );
          
           void createShadow(  const Ogre::Vector3& lightDirection );
          
           void updateShadow(  const Ogre::Vector3& lightDirection );
          
           /**
           * The size in pixels of one side of the AlphaTexture. This is in sizes of 64.
           * @return
           */
           inline int getAlphaTextureSize(   ) const;
          
           SegmentVector& getValidSegments(   );
          
           /**
           * Gets the extent of this page in meters,   in worldforge space.
           * @return
           */
           const WFMath::AxisBox<2> getExtent(   ) const;
          
          private:
          
           SegmentVector mValidSegments;
          
          
           ::EmberOgre::Environment::FoliageArea* mFoliageArea;
          
           /**
           this holds a map of the area,   to be used in a map widget etc.
           */
           Ogre::TexturePtr mMap;
          
          
           TerrainGenerator* mGenerator;
          
           /**
           Internal position
           */
           TerrainPosition mPosition;
          
          
           /**
           * gets a segment for the x and y position in the page
           * @param x
           * @param y
           * @return
           */
           Mercator::Segment* getSegment(  int x,   int y ) const;
          
          
          
          
           /**
           * How much to scale the alpha map. This is done to avoid pixelated terrain (  a blur filter is applied ).
           This value is taken from the config file.
           */
           unsigned int getAlphaMapScale(   ) const;
          
           std::auto_ptr<TerrainPageSurface> mTerrainSurface;
           TerrainPageShadow mShadow;
           ITerrainPageShadowTechnique* mShadowTechnique;
           void setupShadowTechnique(   );
          
           /**
           The extent of this page in meters,   in WF space.
           */
           const WFMath::AxisBox<2> mExtent;
          // void updateShadow(   );
          //
          // void createShadow(   );
          
          
          };
          
          inline int TerrainPage::getAlphaTextureSize(    ) const
          {
           return (  getPageSize(   ) - 1 );
          
          }
          }
          };
          
          #endif

./components/ogre/terrain/TerrainPageGeometry.cpp

       1  //
          // C++ Implementation: TerrainPageGeometry
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "TerrainPageGeometry.h"
          
          namespace EmberOgre {
          namespace Terrain {
          
      32  TerrainPageGeometry::TerrainPageGeometry(   )
          {
          }
          
          
      37  TerrainPageGeometry::~TerrainPageGeometry(   )
          {
          }
          
          }
          }

./components/ogre/terrain/TerrainPageGeometry.h

       1  //
          // C++ Interface: TerrainPageGeometry
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRETERRAINPAGEGEOMETRY_H
          #define EMBEROGRETERRAINPAGEGEOMETRY_H
          
          namespace EmberOgre {
          namespace Terrain {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      32  class TerrainPageGeometry{
          public:
      34   TerrainPageGeometry(   );
          
      36   ~TerrainPageGeometry(   );
          
          };
          }
          }
          
          #endif

./components/ogre/terrain/TerrainPageShadow.cpp

       1  //
          // C++ Implementation: TerrainPageShadow
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "TerrainPageShadow.h"
          #include "TerrainPage.h"
          #include "TerrainGenerator.h"
          #include "../EmberOgrePrerequisites.h"
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include <wfmath/stream.h>
          
          namespace EmberOgre {
          namespace Terrain {
          
          
      39  void SimpleTerrainPageShadowTechnique::createShadowData(  TerrainPage& page,   TerrainGenerator* generator,   unsigned char* data,   const Ogre::Vector3& lightDirection,   const Ogre::ColourValue& lightColour )
          {
          
           int pageSizeInVertices = page.getPageSize(   );
           int pageSizeInMeters = pageSizeInVertices - 1;
          
           ///since Ogre uses a different coord system than WF,   we have to do some conversions here
           TerrainPosition origPosition(  page.getWFPosition(   ) );
           ///start in one of the corners...
           origPosition[0] = (  page.getWFPosition(   )[0] * (  pageSizeInMeters ) );
           origPosition[1] = (  page.getWFPosition(   )[1] * (  pageSizeInMeters ) );
          
           WFMath::Vector<3> wfLightDirection = Ogre2Atlas_Vector3(  lightDirection );
           wfLightDirection = wfLightDirection.normalize(  1 );
          
          
           TerrainPosition position(  origPosition );
          
           for (  int i = 0; i < pageSizeInMeters; ++i ) {
           position = origPosition;
           position[1] = position[1] - i;
           for (  int j = 0; j < pageSizeInMeters; ++j ) {
           float height;
           WFMath::Vector<3> normal;
           if (  generator->getTerrain(   ).getHeightAndNormal(  position.x(   ),   position.y(   ),   height,   normal ) ) {
           float dotProduct = WFMath::Dot(  normal,   wfLightDirection );
          
          //correct
          // if (  dotProduct > 0 ) {
          // *data = (  1 - dotProduct ) * 255 * bias;
          // } else {
          // *data = 255;
          // }
          
           /// if the dotProduct is > 0,   the face is looking away from the sun
           *data = (  1.0f - (  (  dotProduct + 1.0f ) * 0.5f ) ) * 255;
          
          
           } else {
           *data = 0;
           }
           data++;
           position[0] = position[0] + 1;
           }
           }
          
          }
          
          
          
      89  TerrainPageShadow::TerrainPageShadow(  TerrainPage& terrainPage )
          : mTerrainPage(  terrainPage )
          {
           ///we need an unique name for our alpha texture
           std::stringstream shadowTextureNameSS;
           shadowTextureNameSS << mTerrainPage.getMaterial(   )->getName(   ) << "_shadow";
           const Ogre::String shadowTextureName(  shadowTextureNameSS.str(   ) );
          
           mTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->createManual(  shadowTextureName,   "General",   Ogre::TEX_TYPE_2D,   mTerrainPage.getAlphaTextureSize(   ),   mTerrainPage.getAlphaTextureSize(   ),   1,   Ogre::PF_L8 );
          }
          
          
     101  TerrainPageShadow::~TerrainPageShadow(   )
          {
          }
          
     105  void TerrainPageShadow::setLightDirection(  const Ogre::Vector3& lightDirection )
          {
           mLightDirection = lightDirection;
          }
          
     110  void TerrainPageShadow::createShadowData(  unsigned char* data )
          {
           if (  !mShadowTechnique ) {
           S_LOG_WARNING(  "Trying to create shadow data without have a technique set." );
           } else {
           mShadowTechnique->createShadowData(  mTerrainPage,   mTerrainPage.mGenerator,   data,   mLightDirection,   Ogre::ColourValue(  1,  1,  1 ) );
           }
          }
          
     119  void TerrainPageShadow::updateShadow(   )
          {
           mShadowChunk = new Ogre::MemoryDataStream(  mTerrainPage.getAlphaTextureSize(   ) * mTerrainPage.getAlphaTextureSize(   ) * 1,   false );
           ///Create a new image. This image is temporary (  since it will be blitted into the hardware memory ) and destruction of it will be taken care of by the enveloping DataStreamPtr.
           Ogre::DataStreamPtr dataStreamPtr(  mShadowChunk );
           Ogre::Image image; ///the image to hold the data
          
           createShadowData(  mShadowChunk->getPtr(   ) );
          
          
           Ogre::HardwarePixelBufferSharedPtr hardwareBuffer = mTexture->getBuffer(   );
          
           image.loadRawData(  dataStreamPtr,   mTerrainPage.getAlphaTextureSize(   ),   mTerrainPage.getAlphaTextureSize(   ),   Ogre::PF_L8 );
          
           ///blit the whole image to the hardware buffer
           Ogre::PixelBox sourceBox = image.getPixelBox(   );
           hardwareBuffer->blitFromMemory(  sourceBox );
          }
          
          
     139  void TerrainPageShadow::createImage(   )
          {
           mShadowChunk = new Ogre::MemoryDataStream(  mTerrainPage.getAlphaTextureSize(   ) * mTerrainPage.getAlphaTextureSize(   ) * 1,   false );
          
           memset(   mShadowChunk->getPtr(   ),   '\0',   mShadowChunk->size(   ) );
          
          
           createShadowData(  mShadowChunk->getPtr(   ) );
          
           Ogre::DataStreamPtr dataStreamPtr(  mShadowChunk );
          
           mImage = new Ogre::Image(   );
           mImage->loadRawData(  dataStreamPtr,   mTerrainPage.getAlphaTextureSize(   ),   mTerrainPage.getAlphaTextureSize(   ),   Ogre::PF_L8 );
          
           mTexture->loadImage(  *mImage );
          }
          
     156  Ogre::TexturePtr TerrainPageShadow::getTexture(   )
          {
           return mTexture;
          }
          
     161  void TerrainPageShadow::setShadowTechnique(  ITerrainPageShadowTechnique* shadowTechnique )
          {
           mShadowTechnique = shadowTechnique;
          }
          
          
          }
          }

./components/ogre/terrain/TerrainPageShadow.h

       1  //
          // C++ Interface: TerrainPageShadow
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRETERRAINPAGESHADOW_H
          #define EMBEROGRETERRAINPAGESHADOW_H
          #include "../EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          namespace Terrain {
          
      30  class TerrainPage;
      31  class TerrainGenerator;
          
      33  class ITerrainPageShadowTechnique
          {
          public:
      36   virtual void createShadowData(  TerrainPage& page,   TerrainGenerator* generator,   unsigned char* data,   const Ogre::Vector3& lightDirection,   const Ogre::ColourValue& lightColour ) = 0;
          
          protected:
          };
          
      41  class SimpleTerrainPageShadowTechnique : public ITerrainPageShadowTechnique
          {
          public:
      44   virtual void createShadowData(  TerrainPage& page,   TerrainGenerator* generator,   unsigned char* data,   const Ogre::Vector3& lightDirection,   const Ogre::ColourValue& lightColour );
          
          protected:
          };
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      52  class TerrainPageShadow
          {
          public:
      55   TerrainPageShadow(  TerrainPage& terrainPage );
          
      57   virtual ~TerrainPageShadow(   );
          
      59   void setShadowTechnique(  ITerrainPageShadowTechnique* shadowTechnique );
          
      61   void setLightDirection(  const Ogre::Vector3& lightDirection );
          
      63   void createShadowData(  unsigned char* data );
          
      65   Ogre::TexturePtr getTexture(   );
      66   void updateShadow(   );
      67   void createImage(   );
          
          protected:
      70   TerrainPage& mTerrainPage;
      71   Ogre::Vector3 mLightDirection;
      72   Ogre::Image* mImage;
      73   Ogre::TexturePtr mTexture;
      74   Ogre::MemoryDataStream* mShadowChunk;
          
      76   ITerrainPageShadowTechnique* mShadowTechnique;
          
          };
          
          }
          }
          
          #endif

./components/ogre/terrain/TerrainPageSurface.cpp

       1  //
          // C++ Implementation: TerrainPageSurface
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "TerrainPageSurface.h"
          #include "TerrainPageShadow.h"
          #include "TerrainPageSurfaceLayer.h"
          #include "TerrainPageSurfaceCompiler.h"
          
          namespace EmberOgre {
          namespace Terrain {
          
      35  TerrainPageSurface::TerrainPageSurface(  TerrainPage& terrainPage )
          : mTerrainPage(  terrainPage ),   mSurfaceCompiler(  new TerrainPageSurfaceCompiler(   ) )
          {
           ///create a name for out material
          // S_LOG_INFO(  "Creating a material for the terrain." );
           std::stringstream materialNameSS;
           materialNameSS << "EmberTerrain_Segment";
           materialNameSS << "_" << terrainPage.getWFPosition(   ).x(   ) << "_" << terrainPage.getWFPosition(   ).y(   );
          
           ///create the actual material
           mMaterial = static_cast<Ogre::MaterialPtr>(  Ogre::MaterialManager::getSingleton(   ).create(  materialNameSS.str(   ),   "General" ) );
          
          
          }
          
          
      51  TerrainPageSurface::~TerrainPageSurface(   )
          {
          }
          
      55  const TerrainPageSurface::TerrainPageSurfaceLayerStore& TerrainPageSurface::getLayers(   ) const
          {
           return mLayers;
          }
          
      60  void TerrainPageSurface::updateLayer(  int layerIndex )
          {
           TerrainPageSurfaceLayerStore::iterator I = mLayers.find(  layerIndex );
           if (  I != mLayers.end(   ) ) {
           I->second->updateCoverageImage(   );
           }
          }
          
          
      69  const TerrainPosition& TerrainPageSurface::getWFPosition(   ) const
          {
           return mTerrainPage.getWFPosition(   );
          }
          
          
      75  SegmentVector& TerrainPageSurface::getValidSegments(   )
          {
           return mTerrainPage.getValidSegments(   );
          }
          
          
      81  int TerrainPageSurface::getNumberOfSegmentsPerAxis(   ) const
          {
           return mTerrainPage.getNumberOfSegmentsPerAxis(   );
          }
          
      86  unsigned int TerrainPageSurface::getPixelWidth(   ) const
          {
           return mTerrainPage.getAlphaTextureSize(   );
          }
          
      91  Ogre::MaterialPtr TerrainPageSurface::getMaterial(   )
          {
           return mMaterial;
          }
          
      96  void TerrainPageSurface::recompileMaterial(   )
          {
           mSurfaceCompiler->compileMaterial(  mMaterial,   mLayers,   mShadow,   mTerrainPage );
           mMaterial->load(   );
           updateSceneManagersAfterMaterialsChange(   );
          }
          
     103  void TerrainPageSurface::setShadow(  TerrainPageShadow* shadow )
          {
           mShadow = shadow;
          }
          
     108  TerrainPageSurfaceLayer* TerrainPageSurface::createSurfaceLayer(  int surfaceIndex,   Mercator::Shader* shader )
          {
           TerrainPageSurfaceLayer* terrainSurface = new TerrainPageSurfaceLayer(  *this,   surfaceIndex,   shader );
           mLayers.insert(  TerrainPageSurfaceLayerStore::value_type(  surfaceIndex,   terrainSurface ) );
           return terrainSurface;
          }
          
     115  void TerrainPageSurface::updateSceneManagersAfterMaterialsChange(   )
          {
           if(  Ogre::Pass::getDirtyHashList(   ).size(   )!=0 || Ogre::Pass::getPassGraveyard(   ).size(   )!=0 )
           {
           Ogre::SceneManagerEnumerator::SceneManagerIterator scenesIter = Ogre::Root::getSingleton(   ).getSceneManagerIterator(   );
          
           while(  scenesIter.hasMoreElements(   ) )
           {
           Ogre::SceneManager* pScene = scenesIter.getNext(   );
           if(  pScene )
           {
           Ogre::RenderQueue* pQueue = pScene->getRenderQueue(   );
           if(  pQueue )
           {
           Ogre::RenderQueue::QueueGroupIterator groupIter = pQueue->_getQueueGroupIterator(   );
           while(  groupIter.hasMoreElements(   ) )
           {
           Ogre::RenderQueueGroup* pGroup = groupIter.getNext(   );
           if(  pGroup )
           pGroup->clear(  false );
           }//end_while(  groupIter.hasMoreElements(   ) )
           }//end_if(  pScene )
           }//end_if(  pScene )
           }//end_while(  scenesIter.hasMoreElements(   ) )
          
           // Now trigger the pending pass updates
           Ogre::Pass::processPendingPassUpdates(   );
          
           }//end_if(  m_Root..
          }
          }
          
          }

./components/ogre/terrain/TerrainPageSurface.h

       1  //
          // C++ Interface: TerrainPageSurface
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRETERRAINPAGESURFACE_H
          #define EMBEROGRETERRAINPAGESURFACE_H
          
          #include <list>
          #include "../EmberOgrePrerequisites.h"
          #include "../MathConverter.h"
          #include "TerrainPage.h"
          
          namespace Mercator
          {
      33  class Shader;
      34  class Surface;
      35  class Segment;
          }
          
          namespace EmberOgre {
          namespace Terrain {
          
      41  class TerrainPageSurfaceLayer;
      42  class TerrainPage;
      43  class TerrainPageSurfaceCompiler;
      44  class TerrainPageShadow;
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      48  class TerrainPageSurface{
          public:
           typedef std::map<int,   TerrainPageSurfaceLayer*> TerrainPageSurfaceLayerStore;
      51   TerrainPageSurface(  TerrainPage& terrainPage );
          
      53   virtual ~TerrainPageSurface(   );
          
      55   unsigned int getPixelWidth(   ) const;
          
           /**
           * The position of the page in Worldforge space
           * @return
           */
      61   const TerrainPosition& getWFPosition(   ) const;
          
      63   SegmentVector& getValidSegments(   );
          
           /**
           * The number of Mercator::Segments for each axis. I.e. the root of the total number of segments.
           * @return
           */
      69   int getNumberOfSegmentsPerAxis(   ) const;
          
      71   TerrainPageSurfaceLayer* createSurfaceLayer(  int surfaceIndex,   Mercator::Shader* shader );
          
      73   Ogre::MaterialPtr getMaterial(   );
          
      75   void recompileMaterial(   );
          
      77   void setShadow(  TerrainPageShadow* shadow );
          
      79   const TerrainPageSurfaceLayerStore& getLayers(   ) const;
          
      81   void updateLayer(  int layerIndex );
          
          protected:
          
      85   void updateSceneManagersAfterMaterialsChange(   );
          
      87   Ogre::MaterialPtr mMaterial;
      88   TerrainPage& mTerrainPage;
      89   TerrainPageSurfaceLayerStore mLayers;
      90   std::auto_ptr<TerrainPageSurfaceCompiler> mSurfaceCompiler;
      91   TerrainPageShadow* mShadow;
          };
          
          }
          }
          #endif

./components/ogre/terrain/TerrainPageSurfaceCompiler.cpp

       1  //
          // C++ Implementation: TerrainPageSurfaceCompiler
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "TerrainPageSurfaceCompiler.h"
          #include "TerrainPageShadow.h"
          #include "TerrainPageSurfaceLayer.h"
          #include "TerrainPageSurfaceCompilerTechniqueShader.h"
          #include "TerrainPageSurfaceCompilerTechniqueSimple.h"
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include <Ogre.h>
          
          namespace EmberOgre {
          namespace Terrain {
          
      40  TerrainPageSurfaceCompiler::TerrainPageSurfaceCompiler(   )
          {
           selectTechnique(   );
          }
          
          
      46  TerrainPageSurfaceCompiler::~TerrainPageSurfaceCompiler(   )
          {
          }
          
      50  void TerrainPageSurfaceCompiler::compileMaterial(  Ogre::MaterialPtr material,   std::map<int,   TerrainPageSurfaceLayer*>& terrainPageSurfaces,   TerrainPageShadow* terrainPageShadow,   TerrainPage& page )
          {
           bool result = true;
           try {
           mTechnique->setPage(  &page );
           result = mTechnique->compileMaterial(  material,   terrainPageSurfaces,   terrainPageShadow );
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when creating terrain material,   falling back to safe technique. Error message: " << ex.what(   ) );
           fallback(  material,   terrainPageSurfaces,   terrainPageShadow,   page );
           }
           if (  !result ) {
           S_LOG_FAILURE(  "Error when creating terrain material,   falling back to safe technique." );
           fallback(  material,   terrainPageSurfaces,   terrainPageShadow,   page );
           }
          }
          
      66  void TerrainPageSurfaceCompiler::fallback(  Ogre::MaterialPtr material,   std::map<int,   TerrainPageSurfaceLayer*>& terrainPageSurfaces,   TerrainPageShadow* terrainPageShadow,   TerrainPage& page )
          {
           mTechnique = std::auto_ptr<TerrainPageSurfaceCompilerTechnique>(  new TerrainPageSurfaceCompilerTechniqueSimple(   ) );
           mTechnique->setPage(  &page );
           mTechnique->compileMaterial(  material,   terrainPageSurfaces,   terrainPageShadow );
          }
          
      73  void TerrainPageSurfaceCompiler::selectTechnique(   )
          {
           std::string preferredTech(  "" );
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "terrain",   "preferredtechnique" ) ) {
           preferredTech = static_cast<std::string>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "terrain",   "preferredtechnique" ) );
           }
          
           bool shaderSupport = false;
           const Ogre::RenderSystemCapabilities* caps = Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   );
           if (  caps->hasCapability(  Ogre::RSC_VERTEX_PROGRAM ) && (  caps->hasCapability(  Ogre::RSC_FRAGMENT_PROGRAM ) ) )
           {
           if (  (  Ogre::GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "ps_2_0" ) &&
           Ogre::GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "vs_2_0" ) ) ||
           (  Ogre::GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "arbfp1" ) &&
           Ogre::GpuProgramManager::getSingleton(   ).isSyntaxSupported(  "arbvp1" ) )
            )
           {
           shaderSupport = true;
           }
           }
          
           if (  preferredTech == "ShaderNormalMapped" && shaderSupport ) {
           mTechnique = std::auto_ptr<TerrainPageSurfaceCompilerTechnique>(  new TerrainPageSurfaceCompilerTechniqueShaderNormalMapped(   ) );
           } else if (  preferredTech == "Shader" && shaderSupport ) {
           mTechnique = std::auto_ptr<TerrainPageSurfaceCompilerTechnique>(  new TerrainPageSurfaceCompilerTechniqueShader(   ) );
           } else {
           mTechnique = std::auto_ptr<TerrainPageSurfaceCompilerTechnique>(  new TerrainPageSurfaceCompilerTechniqueSimple(   ) );
           }
          //
          
          // mTechnique = std::auto_ptr<TerrainPageSurfaceCompilerTechnique>(  new TerrainPageSurfaceCompilerTechniqueSimple(   ) );
          }
          
          
          
          }
          }

./components/ogre/terrain/TerrainPageSurfaceCompiler.h

       1  //
          // C++ Interface: TerrainPageSurfaceCompiler
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRETERRAINPAGESURFACECOMPILER_H
          #define EMBEROGRETERRAINPAGESURFACECOMPILER_H
          
          #include "../EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          namespace Terrain {
          
      31  class TerrainPageSurfaceLayer;
      32  class TerrainPageShadow;
      33  class TerrainPage;
          
      35  class TerrainPageSurfaceCompilerTechnique
          {
          public:
      38   virtual ~TerrainPageSurfaceCompilerTechnique(   ) {}
      39   virtual bool compileMaterial(  Ogre::MaterialPtr material,   std::map<int,   TerrainPageSurfaceLayer*>& terrainPageSurfaces,   TerrainPageShadow* terrainPageShadow ) = 0;
      40   virtual void setPage(  TerrainPage* page ) = 0;
          
          protected:
          };
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      48  class TerrainPageSurfaceCompiler{
          public:
      50   TerrainPageSurfaceCompiler(   );
          
      52   virtual ~TerrainPageSurfaceCompiler(   );
          
      54   void compileMaterial(  Ogre::MaterialPtr material,   std::map<int,   TerrainPageSurfaceLayer*>& terrainPageSurfaces,   TerrainPageShadow* terrainPageShadow,   TerrainPage& page );
          
          private:
          
      58   void selectTechnique(   );
      59   void fallback(  Ogre::MaterialPtr material,   std::map<int,   TerrainPageSurfaceLayer*>& terrainPageSurfaces,   TerrainPageShadow* terrainPageShadow,   TerrainPage& page );
      60   std::auto_ptr<TerrainPageSurfaceCompilerTechnique> mTechnique;
          
          };
          
          }
          }
          
          #endif

./components/ogre/terrain/TerrainPageSurfaceCompilerTechniqueShader.cpp

          //
          // C++ Implementation: TerrainPageSurfaceCompilerTechniqueShader
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "TerrainPageSurfaceCompilerTechniqueShader.h"
          #include "TerrainPageSurfaceLayer.h"
          
          namespace EmberOgre {
          
          namespace Terrain {
          
      34  TerrainPageSurfaceCompilerShaderPassCoverageBatch::TerrainPageSurfaceCompilerShaderPassCoverageBatch(  TerrainPageSurfaceCompilerShaderPass& shaderPass,   Ogre::TexturePtr combinedCoverageTexture )
          : mShaderPass(  shaderPass )
          ,   mCombinedCoverageTexture(  combinedCoverageTexture )
          ,   mCombinedCoverageImage(  new Ogre::Image(   ) )
      38  ,   mCombinedCoverageDataStream(  new Ogre::MemoryDataStream(  combinedCoverageTexture->getWidth(   ) * combinedCoverageTexture->getWidth(   ) * 4,   false ) )
          ,   mCombinedCoverageDataStreamPtr(  mCombinedCoverageDataStream )
          {
           ///reset the coverage image
           memset(  mCombinedCoverageDataStream->getPtr(   ),   '\0',   mCombinedCoverageDataStream->size(   ) );
          }
      44  TerrainPageSurfaceCompilerShaderPassCoverageBatch::~TerrainPageSurfaceCompilerShaderPassCoverageBatch(   )
          {
          }
          
      48  void TerrainPageSurfaceCompilerShaderPassCoverageBatch::addLayer(  TerrainPageSurfaceLayer* layer )
          {
           addCoverage(  layer->getCoverageImage(   ),   mLayers.size(   ),   4 );
           mLayers.push_back(  layer );
          }
          
      54  void TerrainPageSurfaceCompilerShaderPassCoverageBatch::addCoverage(  Ogre::Image* coverage,   unsigned int channel,   unsigned short numberOfChannels ) {
           mCombinedCoverageDataStream->seek(  0 );
           unsigned char * coverageData = coverage->getData(   );
           unsigned char * combinedCoverageData = mCombinedCoverageDataStream->getPtr(   );
           combinedCoverageData += channel;
           for (  unsigned int i = 0; i <= coverage->getSize(   ); ++i ) {
           *combinedCoverageData = *coverageData;
           combinedCoverageData += numberOfChannels;
           coverageData++;
           }
          }
          
      66  std::vector<TerrainPageSurfaceLayer*>& TerrainPageSurfaceCompilerShaderPassCoverageBatch::getLayers(   )
          {
           return mLayers;
          }
          
      71  void TerrainPageSurfaceCompilerShaderPassCoverageBatch::assignCombinedCoverageTexture(   ) {
           mCombinedCoverageDataStreamPtr->seek(  0 );
           mCombinedCoverageImage->loadRawData(  mCombinedCoverageDataStreamPtr,   mShaderPass.getCoveragePixelWidth(   ),   mShaderPass.getCoveragePixelWidth(   ),   Ogre::PF_B8G8R8A8 );
           mCombinedCoverageTexture->loadImage(  *mCombinedCoverageImage );
          
           Ogre::HardwarePixelBufferSharedPtr hardwareBuffer = mCombinedCoverageTexture->getBuffer(   );
           ///blit the whole image to the hardware buffer
           Ogre::PixelBox sourceBox = mCombinedCoverageImage->getPixelBox(   );
           hardwareBuffer->blitFromMemory(  sourceBox );
          
          }
          
      83  Ogre::TexturePtr TerrainPageSurfaceCompilerShaderPassCoverageBatch::getCombinedCoverageTexture(   )
          {
           return mCombinedCoverageTexture;
          }
      87  void TerrainPageSurfaceCompilerShaderPassCoverageBatch::finalize(   )
          {
           ///add our coverage textures first
           assignCombinedCoverageTexture(   );
           Ogre::TextureUnitState * coverageTUS = mShaderPass.mPass->createTextureUnitState(   );
           coverageTUS->setTextureScale(  1,   1 );
           coverageTUS->setTextureName(  getCombinedCoverageTexture(   )->getName(   ) );
           coverageTUS->setTextureCoordSet(  0 );
           coverageTUS->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
          
           for (  LayerStore::iterator I = mLayers.begin(   ); I != mLayers.end(   ); ++I ) {
           TerrainPageSurfaceLayer* layer(  *I );
           ///add the layer textures
           S_LOG_VERBOSE(  "Adding new layer with diffuse texture " << layer->getDiffuseTextureName(   ) );
           ///add the first layer of the terrain,   no alpha or anything
           Ogre::TextureUnitState * diffuseTUS = mShaderPass.mPass->createTextureUnitState(   );
           //textureUnitState->setTextureScale(  0.025,   0.025 );
           diffuseTUS->setTextureName(  layer->getDiffuseTextureName(   ) );
           diffuseTUS->setTextureCoordSet(  0 );
           diffuseTUS->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
           }
          }
          
          
          
          
          
          
          
          
          
     118  TerrainPageSurfaceCompilerTechniqueShader::TerrainPageSurfaceCompilerTechniqueShader(   )
          {
          }
          
          
     123  TerrainPageSurfaceCompilerTechniqueShader::~TerrainPageSurfaceCompilerTechniqueShader(   )
          {
           for (  PassStore::iterator I = mPasses.begin(   ); I != mPasses.end(   ); ++I ) {
           delete *I;
           }
          }
          
     130  Ogre::Pass* TerrainPageSurfaceCompilerShaderPass::getPass(   )
          {
           return mPass;
          }
          
          
     136  Ogre::TexturePtr TerrainPageSurfaceCompilerShaderPass::getCombinedCoverageTexture(  size_t passIndex,   size_t batchIndex )
          {
           ///we need an unique name for our alpha texture
           std::stringstream combinedCoverageTextureNameSS;
           combinedCoverageTextureNameSS << "terrain_" << mPage.getWFPosition(   ).x(   ) << "_" << mPage.getWFPosition(   ).y(   ) << "_combinedCoverage_"<< passIndex << "_" << batchIndex;
           const Ogre::String combinedCoverageName(  combinedCoverageTextureNameSS.str(   ) );
           Ogre::TexturePtr combinedCoverageTexture;
           if (  Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->resourceExists(  combinedCoverageName ) ) {
           S_LOG_VERBOSE(  "Using already created texture " << combinedCoverageName );
           combinedCoverageTexture = static_cast<Ogre::TexturePtr>(  Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->getByName(  combinedCoverageName ) );
           } else {
           S_LOG_VERBOSE(  "Creating new texture " << combinedCoverageName );
           combinedCoverageTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->createManual(  combinedCoverageName,   "General",   Ogre::TEX_TYPE_2D,   mPage.getAlphaTextureSize(   ),   mPage.getAlphaTextureSize(   ),   4,   Ogre::PF_B8G8R8A8 );
           }
           return combinedCoverageTexture;
          }
          
     153  void TerrainPageSurfaceCompilerTechniqueShader::reset(   )
          {
           for (  PassStore::iterator I = mPasses.begin(   ); I != mPasses.end(   ); ++I ) {
           delete *I;
           }
           mPasses.clear(   );
          }
          
          
     162  bool TerrainPageSurfaceCompilerTechniqueShader::compileMaterial(  Ogre::MaterialPtr material,   std::map<int,   TerrainPageSurfaceLayer*>& terrainPageSurfaces,   TerrainPageShadow* terrainPageShadow )
          {
           reset(   );
           material->removeAllTechniques(   );
           Ogre::Technique* technique = material->createTechnique(   );
           TerrainPageSurfaceCompilerShaderPass* shaderPass = addPass(  technique );
           if (  shaderPass ) {
           shaderPass->addShadowLayer(  terrainPageShadow );
           for (  std::map<int,   TerrainPageSurfaceLayer*>::iterator I = terrainPageSurfaces.begin(   ); I != terrainPageSurfaces.end(   ); ++I ) {
           TerrainPageSurfaceLayer* surfaceLayer = I->second;
           if (  shaderPass->hasRoomForLayer(  surfaceLayer ) ) {
           if (  I == terrainPageSurfaces.begin(   ) ) {
           shaderPass->setBaseLayer(  surfaceLayer );
           } else {
           if (  surfaceLayer->intersects(   ) ) {
           shaderPass->addLayer(  surfaceLayer );
           }
           }
           } else {
           //handle new pass
           }
           }
           if (  !shaderPass->finalize(   ) )
           {
           return false;
           }
           }
           return true;
          // if (  terrainPageShadow ) {
          // addShadow(  technique,   terrainPageShadow );
          // }
          }
          
          
     196  TerrainPageSurfaceCompilerShaderPass::TerrainPageSurfaceCompilerShaderPass(  Ogre::Pass* pass,   TerrainPage& page )
          :
          mPass(  pass )
          // ,   mCurrentLayerIndex(  0 )
          ,   mBaseLayer(  0 )
          ,   mPage(  page )
          {
          }
          
     205  TerrainPageSurfaceCompilerShaderPass::~TerrainPageSurfaceCompilerShaderPass(   )
          {
           for (  CoverageBatchStore::iterator I = mCoverageBatches.begin(   ); I != mCoverageBatches.end(   ); ++I ) {
           delete *I;
           }
          }
          
          
     213  void TerrainPageSurfaceCompilerShaderPass::setBaseLayer(  TerrainPageSurfaceLayer* layer )
          {
           mLayers.push_back(  layer );
           mBaseLayer = layer;
           mScales[0] = layer->getScale(   );
          }
          
     220  TerrainPageSurfaceCompilerShaderPassCoverageBatch* TerrainPageSurfaceCompilerShaderPass::getCurrentBatch(   )
          {
           CoverageBatchStore::reverse_iterator I = mCoverageBatches.rbegin(   );
           if (  !mCoverageBatches.size(   ) || (  *I )->getLayers(   ).size(   ) == 4 ) {
           TerrainPageSurfaceCompilerShaderPassCoverageBatch* batch = createNewBatch(   );
           mCoverageBatches.push_back(  batch );
           return batch;
           } else {
           return *I;
           }
          }
          
     232  TerrainPageSurfaceCompilerShaderPassCoverageBatch* TerrainPageSurfaceCompilerShaderPass::createNewBatch(   )
          {
           TerrainPageSurfaceCompilerShaderPassCoverageBatch* batch = new TerrainPageSurfaceCompilerShaderPassCoverageBatch(  *this,   getCombinedCoverageTexture(  mPass->getIndex(   ),   mCoverageBatches.size(   ) ) );
           return batch;
          }
          
          
     239  void TerrainPageSurfaceCompilerShaderPass::addLayer(  TerrainPageSurfaceLayer* layer )
          {
          // Ogre::ushort numberOfTextureUnitsOnCard = Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->getNumTextureUnits(   );
          // // if (  mCurrentLayerIndex < std::min<unsigned short>(  numberOfTextureUnitsOnCard - 1,   4 ) ) {
          // S_LOG_VERBOSE(  "Adding new layer with diffuse texture " << layer->getDiffuseTextureName(   ) << " and scale " << layer->getScale(   ) << " at index "<< (  mCurrentLayerIndex + 1 ) <<" (  " << numberOfTextureUnitsOnCard << " texture units supported )" );
          // Ogre::TextureUnitState * textureUnitState = mPass->createTextureUnitState(   );
          // // textureUnitState->setTextureScale(  0.025,   0.025 );
          // textureUnitState->setTextureName(  layer->getDiffuseTextureName(   ) );
          // textureUnitState->setTextureCoordSet(  0 );
          // textureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
          
           getCurrentBatch(   )->addLayer(  layer );
          
          // mCurrentLayerIndex++;
           mScales[mLayers.size(   )] = layer->getScale(   );
           mLayers.push_back(  layer );
          // }
          }
          
          
          
          
     261  LayerStore& TerrainPageSurfaceCompilerShaderPass::getLayers(   )
          {
           return mLayers;
          }
          
     266  bool TerrainPageSurfaceCompilerShaderPass::finalize(   )
          {
           //TODO: add shadow here
          
           ///should we use a base pass?
           if (  mBaseLayer ) {
           Ogre::ushort numberOfTextureUnitsOnCard = Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->getNumTextureUnits(   );
           S_LOG_VERBOSE(  "Adding new base layer with diffuse texture " << mBaseLayer->getDiffuseTextureName(   ) << " (  " << numberOfTextureUnitsOnCard << " texture units supported )" );
           ///add the first layer of the terrain,   no alpha or anything
           Ogre::TextureUnitState * textureUnitState = mPass->createTextureUnitState(   );
           textureUnitState->setTextureName(  mBaseLayer->getDiffuseTextureName(   ) );
           textureUnitState->setTextureCoordSet(  0 );
           textureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
           }
          
           ///add our coverage textures first
           for (  CoverageBatchStore::iterator I = mCoverageBatches.begin(   ); I != mCoverageBatches.end(   ); ++I ) {
           TerrainPageSurfaceCompilerShaderPassCoverageBatch* batch = *I;
           batch->finalize(   );
           }
          
          
          
          
           std::stringstream ss;
           ss << "splatting_fragment_" << mLayers.size(   );
           std::string fragmentProgramName(  ss.str(   ) );
          
           mPass->setLightingEnabled(  false );
           mPass->setFog(  true,   Ogre::FOG_NONE );
          
          
           ///add fragment shader for splatting
           mPass->setFragmentProgram(  "splatting_fragment_dynamic" );
          // mPass->setFragmentProgram(  fragmentProgramName );
           try {
           Ogre::GpuProgramParametersSharedPtr fpParams = mPass->getFragmentProgramParameters(   );
           fpParams->setNamedAutoConstant(  "iFogColour",   Ogre::GpuProgramParameters::ACT_FOG_COLOUR );
           fpParams->setNamedConstant(  "iNumberOfLayers",   (  float )mLayers.size(   ) ); //4*4=16
           ///set how much the texture should tile
           fpParams->setNamedConstant(  "iScales",   mScales,   4 ); //4*4=16
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_WARNING(  "Error when setting fragment program parameters. Message:\n" << ex.what(   ) );
           return false;
           }
          
           ///add vertex shader for fog
           mPass->setVertexProgram(  "fog_linear_vp" );
           try {
           Ogre::GpuProgramParametersSharedPtr fpParams = mPass->getVertexProgramParameters(   );
           fpParams->setNamedAutoConstant(  "iFogParams",   Ogre::GpuProgramParameters::ACT_FOG_PARAMS );
           fpParams->setNamedAutoConstant(  "iWorldViewProj",   Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX  );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_WARNING(  "Error when setting fragment program parameters. Message:\n" << ex.what(   ) );
           return false;
           }
           return true;
          }
          
     325  bool TerrainPageSurfaceCompilerShaderPass::hasRoomForLayer(  TerrainPageSurfaceLayer* layer )
          {
          
           Ogre::ushort numberOfTextureUnitsOnCard = Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->getNumTextureUnits(   );
           int takenUnits = 0;
           if (  mBaseLayer ) {
           takenUnits += 1;
           }
           takenUnits += mLayers.size(   ) * 1;
           takenUnits += 3; //shadow texture and two coverage textures
           return (  numberOfTextureUnitsOnCard - takenUnits ) >= 1;
          }
          
          
          
     340  void TerrainPageSurfaceCompilerShaderPass::addShadowLayer(  TerrainPageShadow* terrainPageShadow )
          {
           S_LOG_VERBOSE(  "Adding shadow layer." );
           Ogre::TextureUnitState * textureUnitState = mPass->createTextureUnitState(   );
           //textureUnitState->setTextureScale(  0.025,   0.025 );
           textureUnitState->setTextureName(  terrainPageShadow->getTexture(   )->getName(   ) );
           textureUnitState->setTextureCoordSet(  0 );
           textureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
           textureUnitState->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
           textureUnitState->setTextureAnisotropy(  2 );
          
          }
          
     353  unsigned int TerrainPageSurfaceCompilerShaderPass::getCoveragePixelWidth(   ) const
          {
           return 512;
          }
          
     358  void TerrainPageSurfaceCompilerTechniqueShader::setPage(  TerrainPage* page )
          {
           mPage = page;
          }
          
     363  TerrainPageSurfaceCompilerShaderPass* TerrainPageSurfaceCompilerTechniqueShader::addPass(  Ogre::Technique* technique )
          {
           Ogre::Pass* pass = technique->createPass(   );
           TerrainPageSurfaceCompilerShaderPass* shaderPass = new TerrainPageSurfaceCompilerShaderPass(  pass,   *mPage );
           return shaderPass;
          }
          
          
          
          
          
          
          
          
          
          
          
     380   TerrainPageSurfaceCompilerShaderNormalMappedPassCoverageBatch::TerrainPageSurfaceCompilerShaderNormalMappedPassCoverageBatch(  TerrainPageSurfaceCompilerShaderPass& shaderPass,   Ogre::TexturePtr combinedCoverageTexture ) : TerrainPageSurfaceCompilerShaderPassCoverageBatch(  shaderPass,   combinedCoverageTexture )
          {
          }
          
     384  void TerrainPageSurfaceCompilerShaderNormalMappedPassCoverageBatch::finalize(   )
          {
           ///add our coverage textures first
           assignCombinedCoverageTexture(   );
           Ogre::TextureUnitState * coverageTUS = mShaderPass.getPass(   )->createTextureUnitState(   );
           coverageTUS->setTextureScale(  1,   1 );
           coverageTUS->setTextureName(  getCombinedCoverageTexture(   )->getName(   ) );
           coverageTUS->setTextureCoordSet(  0 );
           coverageTUS->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
          
           for (  LayerStore::iterator I = mLayers.begin(   ); I != mLayers.end(   ); ++I ) {
           TerrainPageSurfaceLayer* layer(  *I );
           ///add the layer textures
           S_LOG_VERBOSE(  "Adding new layer with diffuse texture " << layer->getDiffuseTextureName(   ) << " and normal map texture "<< layer->getNormalTextureName(   )  );
           ///add the first layer of the terrain,   no alpha or anything
           Ogre::TextureUnitState * diffuseTextureUnitState = mShaderPass.getPass(   )->createTextureUnitState(   );
           //textureUnitState->setTextureScale(  0.025,   0.025 );
           diffuseTextureUnitState->setTextureName(  layer->getDiffuseTextureName(   ) );
           diffuseTextureUnitState->setTextureCoordSet(  0 );
           diffuseTextureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
           Ogre::TextureUnitState * normalMapTextureUnitState = mShaderPass.getPass(   )->createTextureUnitState(   );
           normalMapTextureUnitState->setTextureName(  layer->getNormalTextureName(   ) );
           normalMapTextureUnitState->setTextureCoordSet(  0 );
           normalMapTextureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
           }
          }
          
          
     412  TerrainPageSurfaceCompilerShaderNormalMappedPass::TerrainPageSurfaceCompilerShaderNormalMappedPass(  Ogre::Pass* pass,   TerrainPage& page ) : TerrainPageSurfaceCompilerShaderPass(  pass,   page )
          {
          }
          
          
          
     418  TerrainPageSurfaceCompilerShaderPassCoverageBatch* TerrainPageSurfaceCompilerShaderNormalMappedPass::createNewBatch(   )
          {
           TerrainPageSurfaceCompilerShaderPassCoverageBatch* batch = new TerrainPageSurfaceCompilerShaderNormalMappedPassCoverageBatch(  *this,   getCombinedCoverageTexture(  mPass->getIndex(   ),   mCoverageBatches.size(   ) ) );
           return batch;
          }
          
     424  bool TerrainPageSurfaceCompilerShaderNormalMappedPass::hasRoomForLayer(  TerrainPageSurfaceLayer* layer )
          {
          
           Ogre::ushort numberOfTextureUnitsOnCard = Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->getNumTextureUnits(   );
           int takenUnits = 0;
           if (  mBaseLayer ) {
           takenUnits += 2;
           }
           takenUnits += mLayers.size(   ) * 2;
           takenUnits += 3; //shadow texture and two coverage textures
           return (  numberOfTextureUnitsOnCard - takenUnits ) >= 2;
          }
          
     437  bool TerrainPageSurfaceCompilerShaderNormalMappedPass::finalize(   )
          {
           //TODO: add shadow here
          
           ///should we use a base pass?
           if (  mBaseLayer ) {
           Ogre::ushort numberOfTextureUnitsOnCard = Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->getNumTextureUnits(   );
           S_LOG_VERBOSE(  "Adding new base layer with diffuse texture " << mBaseLayer->getDiffuseTextureName(   ) << " and normal map texture "<< mBaseLayer->getNormalTextureName(   ) <<" (  " << numberOfTextureUnitsOnCard << " texture units supported )" );
           ///add the first layer of the terrain,   no alpha or anything
           Ogre::TextureUnitState * diffuseTextureUnitState = mPass->createTextureUnitState(   );
           diffuseTextureUnitState->setTextureName(  mBaseLayer->getDiffuseTextureName(   ) );
           diffuseTextureUnitState->setTextureCoordSet(  0 );
           diffuseTextureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
           Ogre::TextureUnitState * normalMapTextureUnitState = mPass->createTextureUnitState(   );
           normalMapTextureUnitState->setTextureName(  mBaseLayer->getNormalTextureName(   ) );
           normalMapTextureUnitState->setTextureCoordSet(  0 );
           normalMapTextureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
           }
          
           ///add our coverage textures first
           for (  CoverageBatchStore::iterator I = mCoverageBatches.begin(   ); I != mCoverageBatches.end(   ); ++I ) {
           TerrainPageSurfaceCompilerShaderPassCoverageBatch* batch = *I;
           batch->finalize(   );
           }
          
           std::stringstream ss;
           ss << "splatting_fragment_normalmapped_" << mLayers.size(   );
           std::string fragmentProgramName(  ss.str(   ) );
          
           mPass->setLightingEnabled(  false );
           mPass->setFog(  true,   Ogre::FOG_NONE );
          
           ///add fragment shader for splatting
           mPass->setFragmentProgram(  "splatting_fragment_normalmapped_dynamic" );
          // mPass->setFragmentProgram(  fragmentProgramName );
           try {
           Ogre::GpuProgramParametersSharedPtr fpParams = mPass->getFragmentProgramParameters(   );
           fpParams->setNamedAutoConstant(  "lightDiffuse",   Ogre::GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR );
           fpParams->setNamedAutoConstant(  "lightAmbient",   Ogre::GpuProgramParameters::ACT_AMBIENT_LIGHT_COLOUR );
           fpParams->setNamedAutoConstant(  "iFogColour",   Ogre::GpuProgramParameters::ACT_FOG_COLOUR );
           float theValues[4] = {0.04,   -0.02,   1,   0};
           fpParams->setNamedConstant(  "scaleBias",   theValues,   4 ); //4*4=16
           fpParams->setNamedConstant(  "iNumberOfLayers",   (  float )mLayers.size(   ) ); //4*4=16
           ///set how much the texture should tile
           fpParams->setNamedConstant(  "iScales",   mScales,   4 ); //4*4=16
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_WARNING(  "Error when setting fragment program parameters. Message:\n" << ex.what(   ) );
           return false;
           }
          
           ///add vertex shader for fog
           mPass->setVertexProgram(  "splatting_vertex_normalmapped" );
           try {
           Ogre::GpuProgramParametersSharedPtr fpParams = mPass->getVertexProgramParameters(   );
           fpParams->setNamedAutoConstant(  "lightPosition",   Ogre::GpuProgramParameters::ACT_LIGHT_POSITION_OBJECT_SPACE );
           fpParams->setNamedAutoConstant(  "eyePosition",   Ogre::GpuProgramParameters::ACT_CAMERA_POSITION_OBJECT_SPACE );
           fpParams->setNamedAutoConstant(  "iFogParams",   Ogre::GpuProgramParameters::ACT_FOG_PARAMS );
           fpParams->setNamedAutoConstant(  "worldViewProj",   Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX  );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_WARNING(  "Error when setting fragment program parameters. Message:\n" << ex.what(   ) );
           return false;
           }
           return true;
          }
          
     502  TerrainPageSurfaceCompilerShaderPass* TerrainPageSurfaceCompilerTechniqueShaderNormalMapped::addPass(  Ogre::Technique* technique )
          {
           Ogre::Pass* pass = technique->createPass(   );
           TerrainPageSurfaceCompilerShaderPass* shaderPass = new TerrainPageSurfaceCompilerShaderNormalMappedPass(  pass,   *mPage );
           return shaderPass;
          }
          
          }
          
          }

./components/ogre/terrain/TerrainPageSurfaceCompilerTechniqueShader.h

       1  //
          // C++ Interface: TerrainPageSurfaceCompilerTechniqueShader
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_TERRAINTERRAINPAGESURFACECOMPILERTECHNIQUESHADER_H
          #define EMBEROGRE_TERRAINTERRAINPAGESURFACECOMPILERTECHNIQUESHADER_H
          
          #include "../EmberOgrePrerequisites.h"
          #include "TerrainPageSurfaceCompiler.h"
          #include "TerrainPage.h"
          
          
          namespace EmberOgre {
          
          namespace Terrain {
          
      35  class TerrainPageSurfaceLayer;
      36  class TerrainPageShadow;
      37  class TerrainPageSurfaceCompilerShaderPass;
          
          typedef std::vector<TerrainPageSurfaceLayer*> LayerStore;
          
      41  class TerrainPageSurfaceCompilerShaderPassCoverageBatch
          {
          public:
      44   TerrainPageSurfaceCompilerShaderPassCoverageBatch(  TerrainPageSurfaceCompilerShaderPass& shaderPass,   Ogre::TexturePtr combinedCoverageTexture );
      45   virtual ~TerrainPageSurfaceCompilerShaderPassCoverageBatch(   );
          
      47   void addLayer(  TerrainPageSurfaceLayer* layer );
          
      49   std::vector<TerrainPageSurfaceLayer*>& getLayers(   );
      50   Ogre::TexturePtr getCombinedCoverageTexture(   );
          
      52   virtual void finalize(   );
          
          protected:
      55   TerrainPageSurfaceCompilerShaderPass& mShaderPass;
          
      57   Ogre::TexturePtr mCombinedCoverageTexture;
      58   Ogre::Image* mCombinedCoverageImage;
      59   Ogre::MemoryDataStream* mCombinedCoverageDataStream;
      60   Ogre::DataStreamPtr mCombinedCoverageDataStreamPtr;
      61   LayerStore mLayers;
          
      63   void assignCombinedCoverageTexture(   );
      64   void addCoverage(  Ogre::Image* coverage,   unsigned int channel,   unsigned short numberOfChannels );
          
          };
          
          
      69  class TerrainPageSurfaceCompilerShaderPass
          {
          public:
      72  friend class TerrainPageSurfaceCompilerShaderPassCoverageBatch;
      73   TerrainPageSurfaceCompilerShaderPass(  Ogre::Pass* pass,   TerrainPage& page );
      74   virtual ~TerrainPageSurfaceCompilerShaderPass(   );
          
      76   virtual void addLayer(  TerrainPageSurfaceLayer* layer );
      77   virtual void setBaseLayer(  TerrainPageSurfaceLayer* layer );
      78   void addShadowLayer(  TerrainPageShadow* terrainPageShadow );
          
      80   virtual bool hasRoomForLayer(  TerrainPageSurfaceLayer* layer );
          
          
           /**
           * Creates the combined final coverage textures and sets the shader params. Be sure to call this before you load the material.
           */
      86   virtual bool finalize(   );
          
      88   LayerStore& getLayers(   );
          
      90   Ogre::Pass* getPass(   );
          
          protected:
           typedef std::vector<TerrainPageSurfaceCompilerShaderPassCoverageBatch*> CoverageBatchStore;
          
      95   Ogre::Pass* mPass;
          // unsigned int mCurrentLayerIndex;
          
      98   void assignCombinedCoverageTexture(   );
      99   TerrainPageSurfaceCompilerShaderPassCoverageBatch* getCurrentBatch(   );
     100   virtual TerrainPageSurfaceCompilerShaderPassCoverageBatch* createNewBatch(   );
          
     102   unsigned int getCoveragePixelWidth(   ) const;
           float mScales[16];
     104   Ogre::TexturePtr getCombinedCoverageTexture(  size_t passIndex,   size_t batchIndex );
     105   CoverageBatchStore mCoverageBatches;
     106   LayerStore mLayers;
     107   TerrainPageSurfaceLayer* mBaseLayer;
     108   TerrainPage& mPage;
          };
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
     114  class TerrainPageSurfaceCompilerTechniqueShader : public TerrainPageSurfaceCompilerTechnique
          {
          public:
     117   TerrainPageSurfaceCompilerTechniqueShader(   );
     118   virtual ~TerrainPageSurfaceCompilerTechniqueShader(   );
          
     120   virtual bool compileMaterial(  Ogre::MaterialPtr material,   std::map<int,   TerrainPageSurfaceLayer*>& terrainPageSurfaces,   TerrainPageShadow* terrainPageShadow );
          
     122   virtual void setPage(  TerrainPage* page );
          
          protected:
           typedef std::vector<TerrainPageSurfaceCompilerShaderPass*> PassStore;
          
     127   TerrainPage* mPage;
     128   virtual TerrainPageSurfaceCompilerShaderPass* addPass(  Ogre::Technique* technique );
     129   PassStore mPasses;
          
     131   void addBaseLayer(  Ogre::Pass* pass,   TerrainPageSurfaceLayer* layer );
     132   void addLayer(  Ogre::Pass* pass,   TerrainPageSurfaceLayer* layer );
          
     134   void reset(   );
          
          };
          
          
     139  class TerrainPageSurfaceCompilerShaderNormalMappedPassCoverageBatch : public TerrainPageSurfaceCompilerShaderPassCoverageBatch
          {
          public:
     142   TerrainPageSurfaceCompilerShaderNormalMappedPassCoverageBatch(  TerrainPageSurfaceCompilerShaderPass& shaderPass,   Ogre::TexturePtr combinedCoverageTexture );
     143   virtual ~TerrainPageSurfaceCompilerShaderNormalMappedPassCoverageBatch(   ) {}
          
     145   virtual void finalize(   );
          
          protected:
          
          };
          
     151  class TerrainPageSurfaceCompilerShaderNormalMappedPass : public TerrainPageSurfaceCompilerShaderPass
          {
          public:
     154   TerrainPageSurfaceCompilerShaderNormalMappedPass(  Ogre::Pass* pass,   TerrainPage& page );
     155   virtual ~TerrainPageSurfaceCompilerShaderNormalMappedPass(   ) {}
          
          // virtual void addLayer(  TerrainPageSurfaceLayer* layer );
          // virtual void setBaseLayer(  TerrainPageSurfaceLayer* layer );
          
     160   virtual bool hasRoomForLayer(  TerrainPageSurfaceLayer* layer );
          
          
           /**
           * Creates the combined final coverage textures and sets the shader params. Be sure to call this before you load the material.
           */
     166   virtual bool finalize(   );
          
          
          protected:
     170   virtual TerrainPageSurfaceCompilerShaderPassCoverageBatch* createNewBatch(   );
          
          };
          
     174  class TerrainPageSurfaceCompilerTechniqueShaderNormalMapped : public TerrainPageSurfaceCompilerTechniqueShader
          {
          public:
          protected:
     178   virtual TerrainPageSurfaceCompilerShaderPass* addPass(  Ogre::Technique* technique );
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/terrain/TerrainPageSurfaceCompilerTechniqueSimple.cpp

       1  //
          // C++ Implementation: TerrainPageSurfaceCompilerTechniqueSimple
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "TerrainPageSurfaceCompilerTechniqueSimple.h"
          #include "TerrainPageSurfaceLayer.h"
          
          namespace EmberOgre {
          
          namespace Terrain {
          
      34  bool TerrainPageSurfaceCompilerTechniqueSimple::compileMaterial(  Ogre::MaterialPtr material,   std::map<int,   TerrainPageSurfaceLayer*>& terrainPageSurfaces,   TerrainPageShadow* terrainPageShadow )
          {
           material->removeAllTechniques(   );
           Ogre::Technique* technique = material->createTechnique(   );
           for (  std::map<int,   TerrainPageSurfaceLayer*>::iterator I = terrainPageSurfaces.begin(   ); I != terrainPageSurfaces.end(   ); ++I ) {
           TerrainPageSurfaceLayer* surfaceLayer = I->second;
           if (  I == terrainPageSurfaces.begin(   ) ) {
           Ogre::Pass* pass = technique->createPass(   );
           pass->setLightingEnabled(  false );
           ///add the first layer of the terrain,   no alpha or anything
           Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState(   );
           textureUnitState->setTextureScale(  1.0f / surfaceLayer->getScale(   ),   1.0f / surfaceLayer->getScale(   ) );
           textureUnitState->setTextureName(  surfaceLayer->getDiffuseTextureName(   ) );
           textureUnitState->setTextureCoordSet(  0 );
           } else {
           if (  surfaceLayer->intersects(   ) ) {
           addPassToTechnique(  technique,   surfaceLayer );
           }
           }
           }
           if (  terrainPageShadow ) {
           addShadow(  technique,   terrainPageShadow );
           }
           return true;
          }
          
      60  void TerrainPageSurfaceCompilerTechniqueSimple::addShadow(  Ogre::Technique* technique,   TerrainPageShadow* terrainPageShadow )
          {
           Ogre::Pass* shadowPass = technique->createPass(   );
          
           shadowPass->setSceneBlending(  Ogre::SBT_MODULATE );
           shadowPass->setLightingEnabled(  false );
           shadowPass->setFog(  false );
          
          
           Ogre::TextureUnitState * textureUnitStateSplat = shadowPass->createTextureUnitState(   );
           textureUnitStateSplat->setTextureName(  terrainPageShadow->getTexture(   )->getName(   ) );
          
           textureUnitStateSplat->setTextureCoordSet(  0 );
           textureUnitStateSplat->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
           textureUnitStateSplat->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
          }
          
      77  void TerrainPageSurfaceCompilerTechniqueSimple::setPage(  TerrainPage* page )
          {
           mPage = page;
          }
          
          
          // void TerrainPageSurfaceCompiler::addTextureUnitsToPass(  Ogre::Pass* pass,   const Ogre::String& splatTextureName ) {
          //
          // if (  getMaxTextureUnits(   ) - pass->getNumTextureUnitStates(   ) < 2 || pass->getParent(   )->getNumPasses(   ) > 1 ) {
          // addPassToTechnique(  pass->getParent(   ),   splatTextureName );
          // // S_LOG_WARNING(  "Trying to add texture units to pass with too few available texture unit states." );
          // return;
          // }
          //
          // S_LOG_VERBOSE(  "Adding new texture unit (  detailtexture: " << mTextureName << " alphatexture: " << splatTextureName << " ) to pass nr " << pass->getIndex(   ) << " in technique for material " << pass->getParent(   )->getParent(   )->getName(   ) );
          //
          // /* pass->setSelfIllumination(  Ogre::ColourValue(  1,  1,  1 ) );
          // pass->setAmbient(  Ogre::ColourValue(  1,  1,  1 ) );
          // pass->setDiffuse(  Ogre::ColourValue(  1,  1,  1 ) );
          // pass->setLightingEnabled(  true );*/
          // Ogre::TextureUnitState * textureUnitStateSplat = pass->createTextureUnitState(   );
          // textureUnitStateSplat->setTextureName(  splatTextureName );
          //
          // textureUnitStateSplat->setTextureCoordSet(  0 );
          // textureUnitStateSplat->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
          // textureUnitStateSplat->setAlphaOperation(  Ogre::LBX_SOURCE1,   Ogre::LBS_TEXTURE,   Ogre::LBS_TEXTURE );
          // textureUnitStateSplat->setColourOperationEx(  Ogre::LBX_SOURCE1,   Ogre::LBS_CURRENT,   Ogre::LBS_CURRENT );
          // textureUnitStateSplat->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
          // // textureUnitStateSplat->setColourOperationEx(  Ogre::LBX_BLEND_DIFFUSE_ALPHA,   Ogre::LBS_CURRENT,   Ogre::LBS_TEXTURE );
          // // textureUnitStateSplat->setColourOperationEx(  Ogre::LBX_BLEND_TEXTURE_ALPHA,   Ogre::LBS_CURRENT,   Ogre::LBS_TEXTURE );
          //
          // Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState(   );
          // textureUnitState->setTextureName(  mTextureName );
          // textureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
          // /* textureUnitState->setTextureCoordSet(  0 );*/
          // textureUnitState->setTextureScale(  0.025,   0.025 );
          // textureUnitState->setColourOperationEx(  Ogre::LBX_BLEND_CURRENT_ALPHA,   Ogre::LBS_TEXTURE,   Ogre::LBS_CURRENT );
          //
          // /* Ogre::TextureUnitState * alphaTextureState= pass->createTextureUnitState(   );
          // alphaTextureState->setTextureName(  mTextureName );
          // // alphaTextureState->setTextureName(  splatTextureName );
          // alphaTextureState->setTextureCoordSet(  0 );
          // alphaTextureState->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
          // alphaTextureState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
          // alphaTextureState->setColourOperationEx(  Ogre::LBX_BLEND_DIFFUSE_ALPHA,   Ogre::LBS_CURRENT,   Ogre::LBS_TEXTURE );
          //
          //
          //
          // // detailTextureState->setAlphaOperation(  Ogre::LBX_SOURCE1,   Ogre::LBS_TEXTURE,   Ogre::LBS_TEXTURE );
          // // detailTextureState->setColourOperationEx(  Ogre::LBX_SOURCE1,   Ogre::LBS_CURRENT,   Ogre::LBS_CURRENT );
          //
          // Ogre::TextureUnitState * detailTextureState = pass->createTextureUnitState(   );
          // detailTextureState ->setTextureName(  splatTextureName );
          // // detailTextureState ->setTextureName(  mTextureName );
          // detailTextureState ->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
          // detailTextureState ->setTextureCoordSet(  0 );
          // detailTextureState ->setTextureScale(  0.01,   0.01 );
          // //detailTextureState ->setColourOperationEx(  Ogre::LBX_BLEND_CURRENT_ALPHA,   Ogre::LBS_TEXTURE,   Ogre::LBS_CURRENT );*/
          //
          // }
          //
     138  Ogre::Pass* TerrainPageSurfaceCompilerTechniqueSimple::addPassToTechnique(  Ogre::Technique* technique,   TerrainPageSurfaceLayer* layer ) {
           ///check if we instead can reuse the existing pass
          // if (  technique->getNumPasses(   ) != 0 ) {
          // Ogre::Pass* pass = technique->getPass(  technique->getNumPasses(   ) - 1 );
          // if (  4 - pass->getNumTextureUnitStates(   ) >= 2 ) {
          // ///there's more than two texture units available,   use those instead of creating a new pass
          // S_LOG_VERBOSE(  "Reusing existing pass. (  "<< pass->getNumTextureUnitStates(   ) << " of "<< mNumberOfTextureUnitsOnCard << " texture unit used )" );
          // addTextureUnitsToPass(  pass,   splatTextureName );
          // return pass;
          // }
          //
          // }
          
          
           Ogre::Pass* pass = technique->createPass(   );
          
          // S_LOG_VERBOSE(  "Adding new pass (  " << mTextureName << " ) to technique for material " << technique->getParent(   )->getName(   ) << ". Number of passes in this technique: " << technique->getNumPasses(   ) );
          
           pass->setSceneBlending(  Ogre::SBT_TRANSPARENT_ALPHA );
           pass->setLightingEnabled(  false );
          
          
           Ogre::TextureUnitState * textureUnitStateSplat = pass->createTextureUnitState(   );
           textureUnitStateSplat->setTextureName(  layer->getCoverageTextureName(   ) );
          
           textureUnitStateSplat->setTextureCoordSet(  0 );
          // textureUnitStateSplat->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
           textureUnitStateSplat->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
           textureUnitStateSplat->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
          // textureUnitStateSplat->setAlphaOperation(  Ogre::LBX_SOURCE1,   Ogre::LBS_TEXTURE,   Ogre::LBS_TEXTURE );
           textureUnitStateSplat->setColourOperationEx(  Ogre::LBX_BLEND_DIFFUSE_ALPHA,   Ogre::LBS_CURRENT,   Ogre::LBS_TEXTURE );
          
           Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState(   );
           textureUnitState->setTextureName(  layer->getDiffuseTextureName(   ) );
           textureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
           textureUnitState->setTextureCoordSet(  0 );
           textureUnitState->setTextureScale(  1.0f / layer->getScale(   ),   1.0f / layer->getScale(   ) );
          
          
           return pass;
          // textureUnitState->setColourOperationEx(  LBX_BLEND_CURRENT_ALPHA,   LBS_TEXTURE,   LBS_CURRENT );
          
          }
          
          
          }
          
          }

./components/ogre/terrain/TerrainPageSurfaceCompilerTechniqueSimple.h

       1  //
          // C++ Interface: TerrainPageSurfaceCompilerTechniqueSimple
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_TERRAINTERRAINPAGESURFACECOMPILERTECHNIQUESIMPLE_H
          #define EMBEROGRE_TERRAINTERRAINPAGESURFACECOMPILERTECHNIQUESIMPLE_H
          
          #include "../EmberOgrePrerequisites.h"
          #include "TerrainPageSurfaceCompiler.h"
          #include "TerrainPage.h"
          
          namespace EmberOgre {
          
          namespace Terrain {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      37  class TerrainPageSurfaceCompilerTechniqueSimple : public TerrainPageSurfaceCompilerTechnique
          {
          public:
          
      41   virtual bool compileMaterial(  Ogre::MaterialPtr material,   std::map<int,   TerrainPageSurfaceLayer*>& terrainPageSurfaces,   TerrainPageShadow* terrainPageShadow );
      42   virtual void setPage(  TerrainPage* page );
          
          
          protected:
      46   TerrainPage* mPage;
          
      48   Ogre::Pass* addPassToTechnique(  Ogre::Technique* technique,   TerrainPageSurfaceLayer* layer );
      49   void addShadow(  Ogre::Technique* technique,   TerrainPageShadow* terrainPageShadow );
          
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/terrain/TerrainPageSurfaceLayer.cpp

          //
          // C++ Implementation: TerrainPageSurfaceLayer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "TerrainPage.h"
          #include "TerrainPageSurfaceLayer.h"
          #include "TerrainPageSurface.h"
          #include <Mercator/Surface.h>
          #include <Mercator/Segment.h>
          #include <Mercator/Shader.h>
          
          namespace EmberOgre {
          namespace Terrain {
          
      37  TerrainPageSurfaceLayer::TerrainPageSurfaceLayer(  TerrainPageSurface& terrainPageSurface,   int surfaceIndex,   Mercator::Shader* shader )
          : mTerrainPageSurface(  terrainPageSurface )
          ,   mShader(  shader )
          ,   mCoverageImage(  new Ogre::Image(   ) )
      41  ,   mCoverageDataStream(  new Ogre::MemoryDataStream(  terrainPageSurface.getPixelWidth(   ) * terrainPageSurface.getPixelWidth(   ) * 1,   false ) )
          ,   mCoverageDataStreamPtr(  mCoverageDataStream )
          ,   mSurfaceIndex(  surfaceIndex )
          {
           ///we need an unique name for our alpha texture
           std::stringstream splatTextureNameSS;
           splatTextureNameSS << "terrain_" << terrainPageSurface.getWFPosition(   ).x(   ) << "_" << terrainPageSurface.getWFPosition(   ).y(   ) << "_" << surfaceIndex;
           const Ogre::String splatTextureName(  splatTextureNameSS.str(   ) );
          
           mTexture = Ogre::Root::getSingletonPtr(   )->getTextureManager(   )->createManual(  splatTextureName,   "General",   Ogre::TEX_TYPE_2D,   getPixelWidth(   ),   getPixelWidth(   ),   1,   Ogre::PF_L8 );
          
          }
          
          
      55  TerrainPageSurfaceLayer::~TerrainPageSurfaceLayer(   )
          {
          }
          
      59  bool TerrainPageSurfaceLayer::intersects(   )
          {
           ///check if at least one surface intersects
           for (  SegmentVector::iterator I = mTerrainPageSurface.getValidSegments(   ).begin(   ); I != mTerrainPageSurface.getValidSegments(   ).end(   ); ++I ) {
           if (  mShader->checkIntersect(  *I->segment ) ) {
           return true;
           }
           }
           return false;
          }
          
      70  void TerrainPageSurfaceLayer::fillAlphaLayer(  unsigned char* finalImagePtr,   unsigned char* wfImagePtr,   unsigned int channel,   int startX,   int startY,   unsigned short numberOfChannels ) {
          
           int width = 64;
           int finalImageWidth = getPixelWidth(   );
           long i,  j;
          
           Ogre::uchar* start = finalImagePtr + (  numberOfChannels * finalImageWidth * (  startY - 1 ) ) + (  (  startX - 1 ) * numberOfChannels );
           Ogre::uchar* end = start + (  width * finalImageWidth * numberOfChannels ) + (  width * numberOfChannels );
           ///we need to do this to get the alignment correct
           wfImagePtr += 65;
          
           Ogre::uchar* tempPtr = end + channel + numberOfChannels;
           for (  i = 0; i < width; ++i ) {
           tempPtr -= (  width * numberOfChannels );
           for (  j = 0; j < width; ++j ) {
           Ogre::uchar alpha = *(  wfImagePtr + j );
           *(  tempPtr ) = alpha;
           ///advance the number of channels
           tempPtr += numberOfChannels;
          
           }
           tempPtr -= (  finalImageWidth * numberOfChannels );
           wfImagePtr += 65;
           }
          }
          
          
      97  unsigned int TerrainPageSurfaceLayer::getPixelWidth(   ) const
          {
           return mTerrainPageSurface.getPixelWidth(   );
          }
          
     102  float TerrainPageSurfaceLayer::getScale(   ) const
          {
           return mScale;
          }
          
     107  void TerrainPageSurfaceLayer::setScale(  float scale )
          {
           mScale = scale;
          }
          
          
          
     114  void TerrainPageSurfaceLayer::updateCoverageImage(   )
          {
          /* mCoverageDataStream = new Ogre::MemoryDataStream(  mTerrainPageSurface.getPixelWidth(   ) * mTerrainPageSurface.getPixelWidth(   ) * 1,   false );
           mCoverageDataStreamPtr = Ogre::DataStreamPtr(  mCoverageDataStream );*/
           mCoverageDataStream->seek(  0 );
          
           ///reset the coverage image
           memset(  mCoverageDataStream->getPtr(   ),   '\0',   mCoverageDataStream->size(   ) );
          
           for (  SegmentVector::iterator I = mTerrainPageSurface.getValidSegments(   ).begin(   ); I != mTerrainPageSurface.getValidSegments(   ).end(   ); ++I ) {
           if (  mShader->checkIntersect(  *I->segment ) ) {
           Mercator::Surface* surface = getSurfaceForSegment(  I->segment );
           if (  surface && surface->isValid(   ) ) {
          
           int alphaChannel = 0;
           ///use only one channel
           fillAlphaLayer(  mCoverageDataStream->getPtr(   ),   surface->getData(   ),   alphaChannel,   (  int )I->pos.x(   ) * 64,   (  mTerrainPageSurface.getNumberOfSegmentsPerAxis(   ) - (  int )I->pos.y(   ) - 1 ) * 64,   1 );
          
           }
           }
           }
          
           mCoverageImage->loadRawData(  mCoverageDataStreamPtr,   getPixelWidth(   ),   getPixelWidth(   ),   Ogre::PF_L8 );
           mTexture->loadImage(  *mCoverageImage );
          
           ///if it's alreay loaded we need to blit directly to the hardware buffer to make sure it's updated
          // if (  mTexture->isLoaded(   ) ) {
           Ogre::HardwarePixelBufferSharedPtr hardwareBuffer = mTexture->getBuffer(   );
          
           ///blit the whole image to the hardware buffer
           Ogre::PixelBox sourceBox = mCoverageImage->getPixelBox(   );
           //Ogre::Box targetBox(  0,  0,   texture->getWidth(   ),   texture->getHeight(   ) );
           hardwareBuffer->blitFromMemory(  sourceBox );
          // }
          
          
          
          }
          
     153  Mercator::Surface* TerrainPageSurfaceLayer::getSurfaceForSegment(  Mercator::Segment* segment ) const
          {
           Mercator::Segment::Surfacestore::const_iterator I = segment->getSurfaces(   ).find(  mSurfaceIndex );
           if (  I == segment->getSurfaces(   ).end(   ) ) {
           return 0;
           }
           return I->second;
          }
          
     162  const std::string& TerrainPageSurfaceLayer::getCoverageTextureName(   ) const
          {
           return mTexture->getName(   );
          }
          
     167  const std::string& TerrainPageSurfaceLayer::getDiffuseTextureName(   ) const
          {
           return mDiffuseTextureName;
          }
     171  void TerrainPageSurfaceLayer::setDiffuseTextureName(  const std::string& textureName )
          {
           mDiffuseTextureName = textureName;
          }
     175  const std::string& TerrainPageSurfaceLayer::getSpecularTextureName(   ) const
          {
           return mSpecularTextureName;
          }
     179  void TerrainPageSurfaceLayer::setSpecularTextureName(  const std::string& textureName )
          {
           mSpecularTextureName = textureName;
          }
     183  const std::string& TerrainPageSurfaceLayer::getNormalTextureName(   ) const
          {
           return mNormalTextureName;
          }
     187  void TerrainPageSurfaceLayer::setNormalTextureName(  const std::string& textureName )
          {
           mNormalTextureName = textureName;
          }
          
     192  Mercator::Shader* TerrainPageSurfaceLayer::getShader(   )
          {
           return mShader;
          }
     196  int TerrainPageSurfaceLayer::getSurfaceIndex(   )
          {
           return mSurfaceIndex;
          }
          }
          
          }

./components/ogre/terrain/TerrainPageSurfaceLayer.h

       1  //
          // C++ Interface: TerrainPageSurfaceLayer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRETERRAINPAGESURFACELAYER_H
          #define EMBEROGRETERRAINPAGESURFACELAYER_H
          
          #include "../EmberOgrePrerequisites.h"
          namespace Mercator
          {
      29  class Shader;
      30  class Surface;
      31  class Segment;
          }
          
          namespace Ogre
          {
      36  class Image;
          }
          
          
          
      41  namespace EmberOgre {
          namespace Terrain {
          
          class TerrainPageSurface;
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
          class TerrainPageSurfaceLayer{
          public:
           TerrainPageSurfaceLayer(  TerrainPageSurface& terrainPageSurface,   int surfaceIndex,   Mercator::Shader* shader );
          
           virtual ~TerrainPageSurfaceLayer(   );
          
           void updateCoverageImage(   );
          
           inline Ogre::Image* getCoverageImage(   );
           const std::string& getCoverageTextureName(   ) const;
          
           const std::string& getDiffuseTextureName(   ) const;
           void setDiffuseTextureName(  const std::string& textureName );
           const std::string& getSpecularTextureName(   ) const;
           void setSpecularTextureName(  const std::string& textureName );
           const std::string& getNormalTextureName(   ) const;
           void setNormalTextureName(  const std::string& textureName );
          
           unsigned int getPixelWidth(   ) const;
          
           bool intersects(   );
          
           Mercator::Shader* getShader(   );
           int getSurfaceIndex(   );
           Mercator::Surface* getSurfaceForSegment(  Mercator::Segment* segment ) const;
          
           float getScale(   ) const;
           void setScale(  float scale );
          
          protected:
           TerrainPageSurface& mTerrainPageSurface;
           Mercator::Shader* mShader;
           Ogre::Image* mCoverageImage;
           Ogre::TexturePtr mTexture;
          
           std::string mDiffuseTextureName;
           std::string mSpecularTextureName;
           std::string mNormalTextureName;
          
           Ogre::MemoryDataStream* mCoverageDataStream;
           Ogre::DataStreamPtr mCoverageDataStreamPtr;
           int mSurfaceIndex;
          
           float mScale;
          
          
           void fillAlphaLayer(  unsigned char* finalImagePtr,   unsigned char* wfImagePtr,   unsigned int channel,   int startX,   int startY,   unsigned short numberOfChannels );
          
          };
          
          Ogre::Image* TerrainPageSurfaceLayer::getCoverageImage(   )
          {
           return mCoverageImage;
          }
          
          }
          }
          
          #endif

./components/ogre/terrain/TerrainShader.cpp

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "TerrainShader.h"
          #include <OgreIteratorWrappers.h>
          #include "TerrainLayerDefinition.h"
          namespace EmberOgre {
          namespace Terrain {
          
      25  TerrainShader::TerrainShader(  Mercator::Terrain* terrain,   int terrainIndex,   const TerrainLayerDefinition* layerDef,   Mercator::Shader* shader )
          : mLayerDef(  layerDef )
          ,   mShader(  shader )
          ,   mTerrain(  terrain )
          ,   mTerrainIndex(  terrainIndex )
          // ,   mMaterial(  0 )
          // ,   mScale(  32 )
          {
          
           mTerrain->addShader(  shader,   mTerrainIndex );
          
          }
          
          /*
          TerrainShader::TerrainShader(  Mercator::Terrain* terrain,   int terrainIndex,   Ogre::MaterialPtr material,   Mercator::Shader* shader )
          : mTextureName(  "" )
          ,   mShader(  shader )
          ,   mTerrain(  terrain )
          ,   mTerrainIndex(  terrainIndex )
          ,   mMaterial(  material )
          {
          
           mTerrain->addShader(  shader,   mTerrainIndex );
          }*/
          
      50  TerrainShader::~TerrainShader(   )
          {
           ///not available yet
           //mTerrain->removeShader(  mShader )
          }
          
      56  Ogre::ushort TerrainShader::getMaxTextureUnits(   ) const
          {
           return std::min<unsigned short>(  4,   Ogre::Root::getSingleton(   ).getRenderSystem(   )->getCapabilities(   )->getNumTextureUnits(   ) );
          }
          
      61  Mercator::Shader* TerrainShader::getShader(   ) const
          {
           return mShader;
          }
          
          // const Ogre::String& TerrainShader::getTextureName(   ) const
          // {
          // return mTextureName;
          // }
          
      71  const TerrainLayerDefinition* TerrainShader::getLayerDefinition(   ) const
          {
           return mLayerDef;
          }
          
          
      77  void TerrainShader::addTextureUnitsToPass(  Ogre::Pass* pass,   const Ogre::String& splatTextureName ) {
          
          /* if (  getMaxTextureUnits(   ) - pass->getNumTextureUnitStates(   ) < 2 || pass->getParent(   )->getNumPasses(   ) > 1 ) {
           addPassToTechnique(  pass->getParent(   ),   splatTextureName );
          // S_LOG_WARNING(  "Trying to add texture units to pass with too few available texture unit states." );
           return;
           }
          
           S_LOG_VERBOSE(  "Adding new texture unit (  detailtexture: " << mTextureName << " alphatexture: " << splatTextureName << " ) to pass nr " << pass->getIndex(   ) << " in technique for material " << pass->getParent(   )->getParent(   )->getName(   ) );*/
          
          /* pass->setSelfIllumination(  Ogre::ColourValue(  1,  1,  1 ) );
           pass->setAmbient(  Ogre::ColourValue(  1,  1,  1 ) );
           pass->setDiffuse(  Ogre::ColourValue(  1,  1,  1 ) );
           pass->setLightingEnabled(  true );*/
          /* Ogre::TextureUnitState * textureUnitStateSplat = pass->createTextureUnitState(   );
           textureUnitStateSplat->setTextureName(  splatTextureName );
          
           textureUnitStateSplat->setTextureCoordSet(  0 );
           textureUnitStateSplat->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
           textureUnitStateSplat->setAlphaOperation(  Ogre::LBX_SOURCE1,   Ogre::LBS_TEXTURE,   Ogre::LBS_TEXTURE );
           textureUnitStateSplat->setColourOperationEx(  Ogre::LBX_SOURCE1,   Ogre::LBS_CURRENT,   Ogre::LBS_CURRENT );
           textureUnitStateSplat->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );*/
          // textureUnitStateSplat->setColourOperationEx(  Ogre::LBX_BLEND_DIFFUSE_ALPHA,   Ogre::LBS_CURRENT,   Ogre::LBS_TEXTURE );
          // textureUnitStateSplat->setColourOperationEx(  Ogre::LBX_BLEND_TEXTURE_ALPHA,   Ogre::LBS_CURRENT,   Ogre::LBS_TEXTURE );
          
          /* Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState(   );
           textureUnitState->setTextureName(  mTextureName );
           textureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );*/
          /* textureUnitState->setTextureCoordSet(  0 );*/
          /* textureUnitState->setTextureScale(  0.025,   0.025 );
           textureUnitState->setColourOperationEx(  Ogre::LBX_BLEND_CURRENT_ALPHA,   Ogre::LBS_TEXTURE,   Ogre::LBS_CURRENT );*/
          
          /* Ogre::TextureUnitState * alphaTextureState= pass->createTextureUnitState(   );
           alphaTextureState->setTextureName(  mTextureName );
          // alphaTextureState->setTextureName(  splatTextureName );
           alphaTextureState->setTextureCoordSet(  0 );
           alphaTextureState->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
           alphaTextureState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
           alphaTextureState->setColourOperationEx(  Ogre::LBX_BLEND_DIFFUSE_ALPHA,   Ogre::LBS_CURRENT,   Ogre::LBS_TEXTURE );
          
          
          
          // detailTextureState->setAlphaOperation(  Ogre::LBX_SOURCE1,   Ogre::LBS_TEXTURE,   Ogre::LBS_TEXTURE );
          // detailTextureState->setColourOperationEx(  Ogre::LBX_SOURCE1,   Ogre::LBS_CURRENT,   Ogre::LBS_CURRENT );
          
           Ogre::TextureUnitState * detailTextureState = pass->createTextureUnitState(   );
           detailTextureState ->setTextureName(  splatTextureName );
          // detailTextureState ->setTextureName(  mTextureName );
           detailTextureState ->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
           detailTextureState ->setTextureCoordSet(  0 );
           detailTextureState ->setTextureScale(  0.01,   0.01 );
           //detailTextureState ->setColourOperationEx(  Ogre::LBX_BLEND_CURRENT_ALPHA,   Ogre::LBS_TEXTURE,   Ogre::LBS_CURRENT );*/
          
          }
          
     132  Ogre::Pass* TerrainShader::addPassToTechnique(  Ogre::Technique* technique,   const Ogre::String& splatTextureName ) {
           return 0;
           ///check if we instead can reuse the existing pass
          // if (  technique->getNumPasses(   ) != 0 ) {
          // Ogre::Pass* pass = technique->getPass(  technique->getNumPasses(   ) - 1 );
          // if (  4 - pass->getNumTextureUnitStates(   ) >= 2 ) {
          // ///there's more than two texture units available,   use those instead of creating a new pass
          // S_LOG_VERBOSE(  "Reusing existing pass. (  "<< pass->getNumTextureUnitStates(   ) << " of "<< mNumberOfTextureUnitsOnCard << " texture unit used )" );
          // addTextureUnitsToPass(  pass,   splatTextureName );
          // return pass;
          // }
          //
          // }
          
          
          // Ogre::Pass* pass = technique->createPass(   );
          //
          // S_LOG_VERBOSE(  "Adding new pass (  " << mTextureName << " ) to technique for material " << technique->getParent(   )->getName(   ) << ". Number of passes in this technique: " << technique->getNumPasses(   ) );
          //
          // pass->setSceneBlending(  Ogre::SBT_TRANSPARENT_ALPHA );
          // pass->setLightingEnabled(  false );
          //
          //
          // Ogre::TextureUnitState * textureUnitStateSplat = pass->createTextureUnitState(   );
          // textureUnitStateSplat->setTextureName(  splatTextureName );
          //
          // textureUnitStateSplat->setTextureCoordSet(  0 );
          // // textureUnitStateSplat->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
          // textureUnitStateSplat->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_CLAMP );
          // textureUnitStateSplat->setTextureFiltering(  Ogre::TFO_ANISOTROPIC );
          // // textureUnitStateSplat->setAlphaOperation(  Ogre::LBX_SOURCE1,   Ogre::LBS_TEXTURE,   Ogre::LBS_TEXTURE );
          // textureUnitStateSplat->setColourOperationEx(  Ogre::LBX_BLEND_DIFFUSE_ALPHA,   Ogre::LBS_CURRENT,   Ogre::LBS_TEXTURE );
          //
          // Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState(   );
          // textureUnitState->setTextureName(  mTextureName );
          // textureUnitState->setTextureAddressingMode(  Ogre::TextureUnitState::TAM_WRAP );
          // textureUnitState->setTextureCoordSet(  0 );
          // textureUnitState->setTextureScale(  0.025,   0.025 );
          //
          //
          // return pass;
          // textureUnitState->setColourOperationEx(  LBX_BLEND_CURRENT_ALPHA,   LBS_TEXTURE,   LBS_CURRENT );
          
          }
          
     177  void TerrainShader::addMaterialToTechnique(  Ogre::Technique* technique,   const Ogre::String& splatTextureName ) {
          
          // if (  !mMaterial->getNumSupportedTechniques(   ) ) {
          // return;
          // }
          //
          // Ogre::Technique* sourceTech = mMaterial->getSupportedTechnique(  0 );
          // Ogre::Technique::PassIterator I = sourceTech->getPassIterator(   );
          // bool isFirstPass = true;
          // while (  I.hasMoreElements(   ) ) {
          // Ogre::Pass* sourcePass = I.getNext(   );
          //
          //
          // ///if there's only one pass,   check if we can fit that into the existing pass
          // if (  isFirstPass && technique->getNumPasses(   ) == 1 ) {
          // isFirstPass = false;
          // if (  technique->getNumPasses(   ) != 0 ) {
          // Ogre::Pass* existingPass = technique->getPass(  technique->getNumPasses(   ) - 1 );
          // if (  getMaxTextureUnits(   ) - existingPass->getNumTextureUnitStates(   ) >= sourcePass->getNumTextureUnitStates(   ) ) {
          // ///there's more than two texture units available,   use those instead of creating a new pass
          // ///now iterate through all textures,   copy the texture units to the existing splat and look for the splat
          // Ogre::Pass::TextureUnitStateIterator J = sourcePass->getTextureUnitStateIterator(   );
          // while (  J.hasMoreElements(   ) ) {
          // Ogre::TextureUnitState* newTexUnitState = new Ogre::TextureUnitState(  existingPass,   *J.getNext(   ) );
          // //Ogre::TextureUnitState* texUnitState = J.getNext(   );
          // ///clone the texture unit state
          // //*newTexUnitState = *texUnitState;
          // if (  newTexUnitState->getTextureName(   ) == "splat" ) {
          // newTexUnitState->setTextureName(  splatTextureName );
          // }
          //
          // }
          // continue;
          // }
          // }
          // }
          //
          // Ogre::Pass* destPass = technique->createPass(   );
          //
          // //just make a copy of the source pass
          // *destPass = *sourcePass;
          // destPass->setName(  "" );
          //
          // S_LOG_VERBOSE(  "Added new pass from template material(  " << mMaterial->getName(   )<< " ) to technique for material " << technique->getParent(   )->getName(   ) << ". Number of passes in this technique: " << technique->getNumPasses(   ) );
          //
          // //now iterate through all textures and look for the splat
          // Ogre::Pass::TextureUnitStateIterator J = destPass->getTextureUnitStateIterator(   );
          // while (  J.hasMoreElements(   ) ) {
          // Ogre::TextureUnitState* texUnitState = J.getNext(   );
          // texUnitState->setName(  "" );
          // if (  texUnitState->getTextureName(   ) == "splat" ) {
          // texUnitState->setTextureName(  splatTextureName );
          // }
          // }
          // }
          }
          
     234  void TerrainShader::addSplatToTechnique(  Ogre::Technique* technique,   const Ogre::String& splatTextureName ) {
          /* if (  !mMaterial.isNull(   ) ) {
           addMaterialToTechnique(  technique,   splatTextureName );
           } else {
           addTextureUnitsToPass(  technique->getPass(  technique->getNumPasses(   ) - 1 ) ,   splatTextureName );
          // Ogre::Pass* pass = addPassToTechnique(  technique,   splatTextureName );
           //pass->setLightingEnabled(  false );
           //pass->setSelfIllumination(  Ogre::ColourValue(  1,  1,  1 ) );
           }*/
          }
          
          
     246  Mercator::Surface* TerrainShader::getSurfaceForSegment(  Mercator::Segment* segment ) const
          {
          
           Mercator::Surface* surface = 0;
           if (  segment->getSurfaces(   ).find(  getTerrainIndex(   ) ) != segment->getSurfaces(   ).end(   ) ) {
           surface = segment->getSurfaces(   ).find(  getTerrainIndex(   ) )->second;
           }
           return surface;
          }
          
          }
          }

./components/ogre/terrain/TerrainShader.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef TERRAINSHADER_H
          #define TERRAINSHADER_H
          
          #include "../EmberOgrePrerequisites.h"
          #include <Mercator/Shader.h>
          #include <Mercator/Terrain.h>
          #include <Mercator/Segment.h>
          #include <Mercator/AreaShader.h>
          
          
          
          namespace EmberOgre {
          namespace Terrain {
      32  class TerrainLayerDefinition;
      33  class TerrainShader{
          public:
          
      36   TerrainShader(  Mercator::Terrain* terrain,   int terrainIndex,   const TerrainLayerDefinition* layerDef,   Mercator::Shader* shader );
          // TerrainShader(  Mercator::Terrain* terrain,   int terrainIndex,   Ogre::MaterialPtr material,   Mercator::Shader* shader );
      38   virtual ~TerrainShader(   );
          
      40   Mercator::Shader* getShader(   ) const;
          // const Ogre::String& getTextureName(   ) const;
          
           /*
           * Adds a texture unit with a splatting alpha texture to the supplied pass.
           * Use this when you're using many texture units in the same pass
           */
      47   void addTextureUnitsToPass(  Ogre::Pass* pass,   const Ogre::String& splatTextureName );
          
           /*
           * Adds a pass with a splatting alpha texture to the supplied technique.
           * Use this when you're using many passes. This is more expensive than
           * addTextureUnitsToPass(  ... ) but works on card with a low number of
           * TextureUnits.
           */
      55   Ogre::Pass* addPassToTechnique(  Ogre::Technique* technique,   const Ogre::String& splatTextureName );
          
      57   inline int getTerrainIndex(   ) const { return mTerrainIndex;}
          
      59   void addMaterialToTechnique(  Ogre::Technique* technique,   const Ogre::String& splatTextureName );
      60   void addSplatToTechnique(  Ogre::Technique* technique,   const Ogre::String& splatTextureName );
          
          
           /**
           * returns the Surface for the given segment
           * @param segment
           * @return a surface,   or null if no could be found
           */
      68   Mercator::Surface* getSurfaceForSegment(  Mercator::Segment* segment ) const;
          
          /* inline float getScale(   ) const;
           inline void setScale(  float scale );*/
          
      73   const TerrainLayerDefinition* getLayerDefinition(   ) const;
          
          protected:
      76   const TerrainLayerDefinition* mLayerDef;
          // const Ogre::String mTextureName;
      78   Mercator::Shader* mShader;
      79   Mercator::Terrain* mTerrain;
           int mTerrainIndex;
          // Ogre::MaterialPtr mMaterial;
          
      83   Ogre::ushort getMaxTextureUnits(   ) const;
          // float mScale;
          
           //const Model::ModelDefinition::AreaDefinition& mAreaDefinition;
          };
          
          // float TerrainShader::getScale(   ) const
          // {
          // return mScale;
          // }
          // void TerrainShader::setScale(  float scale )
          // {
          // mScale = scale;
          // }
          
          }
          }
          
          #endif // TERRAINSHADER_H

./components/ogre/terrain/XMLLayerDefinitionSerializer.cpp

       1  //
          // C++ Implementation: XMLLayerDefinitionSerializer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "XMLLayerDefinitionSerializer.h"
          #include "framework/tinyxml/tinyxml.h"
          #include "components/ogre/XMLHelper.h"
          #include "TerrainLayerDefinitionManager.h"
          #include "TerrainLayerDefinition.h"
          
          namespace EmberOgre {
          
          namespace Terrain {
          
      37  XMLLayerDefinitionSerializer::XMLLayerDefinitionSerializer(  TerrainLayerDefinitionManager& manager )
          : mManager(  manager )
          {
          }
          
          
      43  XMLLayerDefinitionSerializer::~XMLLayerDefinitionSerializer(   )
          {
          }
          
      47  void XMLLayerDefinitionSerializer::parseScript(  Ogre::DataStreamPtr& stream,   const Ogre::String& groupName )
          {
           Ember::TiXmlDocument xmlDoc;
           XMLHelper xmlHelper;
           if (  !xmlHelper.Load(  xmlDoc,   stream ) ) {
           return;
           }
          
           Ember::TiXmlElement* rootElem = xmlDoc.RootElement(   );
           Ember::TiXmlElement* layersElem = rootElem->FirstChildElement(  "layers" );
           if (  layersElem ) {
          
           for (  Ember::TiXmlElement* smElem = layersElem->FirstChildElement(  "layer" );
           smElem != 0; smElem = smElem->NextSiblingElement(  "layer" ) )
           {
           const char* tmp = smElem->Attribute(  "shadername" );
           std::string shadername;
           int areaId(  0 );
           if (  tmp ) {
           shadername = tmp;
           } else {
           smElem->QueryIntAttribute(  "areaindex",   &areaId );
           }
          
           if (  shadername != "" || areaId != 0 ) {
           S_LOG_VERBOSE(  "Adding terrain layer definition for shader '" << shadername << "' and area index '"<< areaId << "'." );
           try {
           TerrainLayerDefinition* definition = new TerrainLayerDefinition(   );
           definition->setShaderName(  shadername );
           definition->setAreaId(  static_cast<unsigned int>(  areaId ) );
          
           definition->setDiffuseTextureName(  smElem->Attribute(  "diffusetexture" ) );
           definition->setNormalMapTextureName(  smElem->Attribute(  "normalmaptexture" ) );
           float tileSize;
           if (  smElem->QueryFloatAttribute(  "tilesize",   &tileSize ) == Ember::TIXML_SUCCESS ) {
           definition->setTileSize(  tileSize );
           }
          
           mManager.addDefinition(  definition );
           } catch (  std::exception ex ) {
           S_LOG_FAILURE(  ex.what(   ) );
           } catch (  ... ) {
           S_LOG_FAILURE(  "Error when reading terrain layer definition." );
           }
           }
           }
           }
          }
          }
          
          }

./components/ogre/terrain/XMLLayerDefinitionSerializer.h

       1  //
          // C++ Interface: XMLLayerDefinitionSerializer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_TERRAINXMLLAYERDEFINITIONSERIALIZER_H
          #define EMBEROGRE_TERRAINXMLLAYERDEFINITIONSERIALIZER_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          
          namespace Terrain {
          
      32  class TerrainLayerDefinitionManager;
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      36  class XMLLayerDefinitionSerializer
          {
          public:
      39   XMLLayerDefinitionSerializer(  TerrainLayerDefinitionManager& manager );
          
      41   ~XMLLayerDefinitionSerializer(   );
          
      43   void parseScript(  Ogre::DataStreamPtr& stream,   const Ogre::String& groupName );
          
          protected:
      46   TerrainLayerDefinitionManager& mManager;
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/AssetsManager.cpp

       1  //
          // C++ Implementation: AssetsManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AssetsManager.h"
          #include <OgreCEGUIRenderer.h>
          #include <OgreCEGUITexture.h>
          #include "../EmberOgrePrerequisites.h"
          
          #include <CEGUIImagesetManager.h>
          #include <CEGUIImageset.h>
          
          #include "../EmberOgre.h"
          #include "../GUIManager.h"
          
          #include "framework/Exception.h"
          // #include <OgreBitwise.h>
          
          
          namespace EmberOgre {
          
          namespace Gui {
          
      42  AssetsManager::AssetsManager(   )
          : mOgreCEGUITexture(  0 ),   mTextureImage(  0 ),   mTextureImageset(  0 )
          {
          // createTextureImage(   );
          }
          
          
      49  AssetsManager::~AssetsManager(   )
          {
          }
          
      53  bool AssetsManager::showTexture(  const std::string textureName )
          {
          // if (  !mOgreCEGUITexture ) {
          // S_LOG_WARNING(  "You must first create a valid OgreCEGUITexture instance." );
          // return;
          // }
           if (  Ogre::TextureManager::getSingleton(   ).resourceExists(  textureName ) ) {
           Ogre::TexturePtr texturePtr = static_cast<Ogre::TexturePtr>(  Ogre::TextureManager::getSingleton(   ).getByName(  textureName ) );
           if (  !texturePtr.isNull(   ) ) {
           try {
           texturePtr->load(   );
           } catch (  ... ) {
           S_LOG_WARNING(  "Error when loading " << textureName << ". This texture will not be shown." );
           return false;
           }
           createTextureImage(  texturePtr );
           return true;
          // mOgreCEGUITexture->setOgreTexture(  texturePtr );
           }
           }
           return false;
          
          }
          
          
      78  void AssetsManager::createTextureImage(  Ogre::TexturePtr texturePtr )
          {
           std::string textureName (  texturePtr->getName(   ) );
          // if (  mOgreCEGUITexture ) {
          // GUIManager::getSingleton(   ).getGuiRenderer(   )->destroyTexture(  mOgreCEGUITexture );
          // mOgreCEGUITexture = 0;
          // }
          
           std::string imageSetName(  textureName + "_AssetsManager" );
          
           if (  CEGUI::ImagesetManager::getSingleton(   ).isImagesetPresent(  imageSetName ) ) {
           mTextureImageset = CEGUI::ImagesetManager::getSingleton(   ).getImageset(  imageSetName );
           } else {
           ///create a CEGUI texture from our Ogre texture
           S_LOG_VERBOSE(  "Creating new CEGUI texture from Ogre texture." );
           mOgreCEGUITexture = GUIManager::getSingleton(   ).getGuiRenderer(   )->createTexture(  texturePtr );
          
           ///we need a imageset in order to create GUI elements from the ceguiTexture
           S_LOG_VERBOSE(  "Creating new CEGUI imageset with name " << imageSetName );
           mTextureImageset = CEGUI::ImagesetManager::getSingleton(   ).createImageset(  imageSetName ,   mOgreCEGUITexture );
          
           ///we only want one element: the whole texture
           mTextureImageset->defineImage(  "full_image",   CEGUI::Rect(  0,   0,   texturePtr->getWidth(   ),   texturePtr->getHeight(   ) ),   CEGUI::Point(  0,  0 ) );
           }
           ///assign our image element to the StaticImage widget
           mTextureImage = &mTextureImageset->getImage(  "full_image" );
          
          }
          
     107  const CEGUI::Image* AssetsManager::getCEGUIImage(   )
          {
           return mTextureImage;
          }
          
          // bool AssetsManager::exportTexture(  Ogre::TexturePtr texturePtr )
          // {
          // getRenderTarget(   )->writeContentsToFile(   );
          // }
          
          
          }
          
          }

./components/ogre/widgets/AssetsManager.h

       1  //
          // C++ Interface: AssetsManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUIASSETSMANAGER_H
          #define EMBEROGRE_GUIASSETSMANAGER_H
          
          #include <string>
          #include <OgreTexture.h>
          
          namespace CEGUI
          {
      31  class OgreCEGUITexture;
      32  class Imageset;
      33  class Image;
      34  class Texture;
          }
          
          namespace EmberOgre {
          
          namespace Gui {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      44  class AssetsManager{
          public:
      46   AssetsManager(   );
          
      48   ~AssetsManager(   );
          
      50   const CEGUI::Image* getCEGUIImage(   );
          
      52   bool showTexture(  const std::string textureName );
          
          private:
          
      56   void createTextureImage(  Ogre::TexturePtr texturePtr );
          
      58   CEGUI::Texture* mOgreCEGUITexture;
      59   const CEGUI::Image* mTextureImage;
      60   CEGUI::Imageset* mTextureImageset;
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/ColouredListItem.cpp

       1  //
          // C++ Implementation: ColouredListItem
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ColouredListItem.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
      29  ColouredListItem::ColouredListItem(  const CEGUI::String& text ) : ListboxTextItem(  text )
          {
           setColours(   );
          }
          
      34  ColouredListItem::ColouredListItem(  const CEGUI::String& text,   unsigned int item_id ) : ListboxTextItem(  text,   item_id )
          {
           setColours(   );
          }
          
      39  ColouredListItem::ColouredListItem(  const CEGUI::String& text,   unsigned int item_id,   void *item_data ) : ListboxTextItem(  text,   item_id,   item_data )
          {
           setColours(   );
          }
          
      44  void ColouredListItem::setColours(   )
          {
           setSelectionColours(  CEGUI::colour(  50,  50,  50 ) );
           setTextColours(  CEGUI::colour(  0,  0,  0 ) );
           try {
           setSelectionBrushImage(  "EmberLook",   "MultiListSelectionBrush" );
           } catch (  ... ) {}
          
          }
          
      54  CEGUI::ListboxItem* ColouredListItem::createColouredListItem(  const CEGUI::String& text )
          {
           return new ColouredListItem(  text );
          }
          
      59  CEGUI::ListboxItem* ColouredListItem::createColouredListItem(  const CEGUI::String& text,   unsigned int item_id )
          {
           return new ColouredListItem(  text,   item_id );
          }
          
      64  CEGUI::ListboxItem* ColouredListItem::createColouredListItem(  const CEGUI::String& text,   unsigned int item_id,   void *item_data )
          {
           return new ColouredListItem(  text,   item_id,   item_data );
          }
          
          
          }
          
          }

./components/ogre/widgets/ColouredListItem.h

       1  //
          // C++ Interface: ColouredListItem
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUICOLOREDLISTITEM_H
          #define EMBEROGRE_GUICOLOREDLISTITEM_H
          
          #include <elements/CEGUIListboxTextItem.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
          /**
           A standard ListboxTextItem,   with the exeption that the selection will be colored.
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      36  class ColouredListItem : public CEGUI::ListboxTextItem
          {
          public:
      39   ColouredListItem(  const CEGUI::String& text );
      40   ColouredListItem(  const CEGUI::String& text,   unsigned int item_id );
      41   ColouredListItem(  const CEGUI::String& text,   unsigned int item_id,   void *item_data );
          
      43   static CEGUI::ListboxItem* createColouredListItem(  const CEGUI::String& text );
      44   static CEGUI::ListboxItem* createColouredListItem(  const CEGUI::String& text,   unsigned int item_id );
      45   static CEGUI::ListboxItem* createColouredListItem(  const CEGUI::String& text,   unsigned int item_id,   void *item_data );
          
          private:
      48   void setColours(   );
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/ConsoleAdapter.cpp

       1  //
          // C++ Implementation: ConsoleAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ConsoleAdapter.h"
          #include "framework/ConsoleBackend.h"
          #include <elements/CEGUIEditbox.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
      31  ConsoleAdapter::ConsoleAdapter(  CEGUI::Editbox* inputBox )
          : mInputBox(  inputBox ),   mReturnKeyDown(  false )
          {
           mBackend = Ember::ConsoleBackend::getMainConsole(   );
           mInputBox->subscribeEvent(  CEGUI::Editbox::EventKeyUp,   CEGUI::Event::Subscriber(  &ConsoleAdapter::consoleInputBox_KeyUp,   this ) );
           mInputBox->subscribeEvent(  CEGUI::Editbox::EventKeyDown,   CEGUI::Event::Subscriber(  &ConsoleAdapter::consoleInputBox_KeyDown,   this ) );
          }
          
          
      40  ConsoleAdapter::~ConsoleAdapter(   )
          {
          }
          
      44  bool ConsoleAdapter::consoleInputBox_KeyDown(  const CEGUI::EventArgs& args )
          {
           const CEGUI::KeyEventArgs& keyargs = static_cast<const CEGUI::KeyEventArgs&>(  args );
           if (  keyargs.scancode == CEGUI::Key::Return || keyargs.scancode == CEGUI::Key::NumpadEnter ) {
           mReturnKeyDown = true;
           }
           return true;
          }
          
      53  bool ConsoleAdapter::consoleInputBox_KeyUp(  const CEGUI::EventArgs& args )
          {
           const CEGUI::KeyEventArgs& keyargs = static_cast<const CEGUI::KeyEventArgs&>(  args );
          // fprintf(  stderr,   (  std::string(  "CEGUI - KEY UP:" ) + keyargs.scancode + "\n" ).c_str(   ) );
          
           if(  keyargs.scancode != CEGUI::Key::Tab )
           {
           mTabPressed = false;
           }
           switch(  keyargs.scancode )
           {
           case CEGUI::Key::ArrowUp:
           {
           if(  mBackend->getHistoryPosition(   ) == 0 )
           {
           mCommandLine = mInputBox->getText(   ).c_str(   );
           }
           else
           {
           // we are not at the command line but in the history
           // => write back the editing
           mBackend->changeHistory(  mBackend->getHistoryPosition(   ),   mInputBox->getText(   ).c_str(   ) );
           }
           mBackend->moveBackwards(   );
           if(  mBackend->getHistoryPosition(   ) != 0 )
           {
           mInputBox->setText(  mBackend->getHistoryString(   ) );
           }
          
           break;
           }
           case CEGUI::Key::ArrowDown:
           {
           if(  mBackend->getHistoryPosition(   ) > 0 )
           {
           mBackend->changeHistory(  mBackend->getHistoryPosition(   ),   mInputBox->getText(   ).c_str(   ) );
           mBackend->moveForwards(   );
           if(  mBackend->getHistoryPosition(   ) == 0 )
           {
           mInputBox->setText(  mCommandLine );
           }
           else
           {
           mInputBox->setText(  mBackend->getHistoryString(   ) );
           }
           }
          
           break;
           }
           case CEGUI::Key::Tab:
           {
           std::string sCommand(  mInputBox->getText(   ).c_str(   ) );
          
           // only process commands
           if(  sCommand[0] != '/' )
           {
           break;
           }
           sCommand = sCommand.substr(  1,   mInputBox->getCaratIndex(   ) - 1 );
           if(  mTabPressed == true )
           {
           const std::set< std::string > commands(  mBackend->getPrefixes(  sCommand ) );
          
           //std::cout << sCommand << std::endl;
           if(  commands.size(   ) > 0 )
           {
           std::set< std::string >::const_iterator iCommand(  commands.begin(   ) );
           std::string sMessage(  "" );
          
           mSelected = (  mSelected + 1 ) % commands.size(   );
          
           int select(  0 );
          
           while(  iCommand != commands.end(   ) )
           {
           if(  select == mSelected )
           {
           std::string sCommandLine(  mInputBox->getText(   ).c_str(   ) );
          
           // compose the new command line: old text before the caret + selected command
           mInputBox->setText(  sCommandLine.substr(  0,   mInputBox->getCaratIndex(   ) ) + iCommand->substr(  mInputBox->getCaratIndex(   ) - 1 ) );
           mInputBox->setSelection(  mInputBox->getCaratIndex(   ),   0xFFFFFFFF );
           }
           sMessage += *iCommand + ' ';
           ++iCommand;
           ++select;
           }
           mBackend->pushMessage(  sMessage );
           }
           }
           else
           {
           mTabPressed = true;
           mSelected = 0;
          
           const std::set< std::string > commands(  mBackend->getPrefixes(  sCommand ) );
          
           if(  commands.size(   ) == 0 )
           {
           // TODO: Error reporting?
           }
           else
           {
           // if any command starts with the current prefix
           if(  commands.size(   ) == 1 )
           {
           mInputBox->setText(  std::string(  "/" ) + *(  commands.begin(   ) ) + ' ' );
           // this will be at the end of the text
           mInputBox->setCaratIndex(  0xFFFFFFFF );
           }
           else
           {
           std::set< std::string >::const_iterator iSelected(  commands.begin(   ) );
           std::set< std::string >::const_iterator iCommand(  commands.begin(   ) );
           std::string sCommonPrefix(  *iCommand );
           int select = 1;
          
           ++iCommand;
           while(  iCommand != commands.end(   ) )
           {
           if(  select == mSelected )
           {
           iSelected = iCommand;
           }
          
           std::string::size_type i(  0 );
          
           while(  (  i < sCommonPrefix.length(   ) ) && (  i < (  *iCommand ).length(   ) ) )
           {
           if(  sCommonPrefix[i] != (  *iCommand )[i] )
           {
           break;
           }
           ++i;
           }
           if(  i < sCommonPrefix.length(   ) )
           {
           sCommonPrefix = sCommonPrefix.substr(  0,   i );
           }
           ++select;
           ++iCommand;
           }
           mInputBox->setText(  std::string(  "/" ) + sCommonPrefix + iSelected->substr(  sCommonPrefix.length(   ) ) );
           mInputBox->setCaratIndex(  sCommonPrefix.length(   ) + 1 );
           mInputBox->setSelection(  sCommonPrefix.length(   ) + 1,   0xFFFFFFFF );
           }
           }
           }
          
           break;
           }
           case CEGUI::Key::Return:
           case CEGUI::Key::NumpadEnter:
           {
           if (  mReturnKeyDown ) {
           mReturnKeyDown = false;
           if(  mInputBox->getSelectionLength(   ) > 0 )
           {
           unsigned long ulSelectionEnd(  mInputBox->getSelectionEndIndex(   ) );
          
           mInputBox->setText(  mInputBox->getText(   ) + ' ' );
           mInputBox->setCaratIndex(  ulSelectionEnd + 1 );
           mInputBox->setSelection(  mInputBox->getCaratIndex(   ),   mInputBox->getCaratIndex(   ) );
           }
           else
           {
           const CEGUI::String consoleText(  mInputBox->getText(   ) );
          
           mInputBox->setText(  CEGUI::String(  "" ) );
           mBackend->pushMessage(  (  "> " + consoleText ).c_str(   ) );
           // run the command
           mBackend->runCommand(  consoleText.c_str(   ) );
           EventCommandExecuted.emit(  consoleText.c_str(   ) );
           }
           }
          
           break;
           }
           default:
           {
           break;
           }
           }
          
           return true;
          }
          
          
          }
          
          }

./components/ogre/widgets/ConsoleAdapter.h

       1  //
          // C++ Interface: ConsoleAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUICONSOLEADAPTER_H
          #define EMBEROGRE_GUICONSOLEADAPTER_H
          
          #include <CEGUIEventArgs.h>
          #include <sigc++/signal.h>
          
          namespace CEGUI {
      30  class Editbox;
          }
          
          namespace Ember {
      34  class ConsoleBackend;
          }
          
      37  namespace EmberOgre {
          
          namespace Gui {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
          class ConsoleAdapter{
          public:
           ConsoleAdapter(  CEGUI::Editbox* inputBox );
          
           ~ConsoleAdapter(   );
          
           /**
           Emitted when a command has executed.
           @param the command that was executed
           */
           sigc::signal<void,   const std::string&> EventCommandExecuted;
          
          protected:
           CEGUI::Editbox* mInputBox;
           Ember::ConsoleBackend* mBackend;
          
           bool consoleInputBox_KeyUp(  const CEGUI::EventArgs& args );
           bool consoleInputBox_KeyDown(  const CEGUI::EventArgs& args );
          
           // the text of the current command line saved when browsing the history
           std::string mCommandLine;
           bool mTabPressed;
           int mSelected;
           bool mReturnKeyDown;
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/EntityCEGUITexture.cpp

       1  //
          // C++ Implementation: EntityCEGUITexture
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityCEGUITexture.h"
          #include <CEGUIWindowManager.h>
          #include <CEGUIImagesetManager.h>
          #include <CEGUIImageset.h>
          
          #include "../EmberOgre.h"
          #include "../GUIManager.h"
          #include "../model/Model.h"
          #include "../SimpleRenderContext.h"
          
          #include "framework/Exception.h"
          #include <OgreBitwise.h>
          
          
          namespace EmberOgre {
          namespace Gui {
          
          
          
      42  EntityCEGUITexture::EntityCEGUITexture(  const std::string& imageSetName,   int width,   int height )
      43  : mImage(  0 ),   mImageSet(  0 ),   mWidth(  width ),   mHeight(  height ),   mRenderContext(  new SimpleRenderContext(  imageSetName,   width,   height ) ),   mCeguiTexture(  0 )
          {
           createImage(  imageSetName );
          }
          
      48  EntityCEGUITexture::~EntityCEGUITexture(   )
          {
          }
          
          
      53  const CEGUI::Image* EntityCEGUITexture::getImage(   ) const
          {
           return mImage;
          }
          
      58  void EntityCEGUITexture::createImage(  const std::string& imageSetName )
          {
           ///create a CEGUI texture from our Ogre texture
           S_LOG_VERBOSE(  "Creating new CEGUI texture from Ogre texture." );
           Ogre::TexturePtr texturePtr(  mRenderContext->getTexture(   ) );
           mCeguiTexture = GUIManager::getSingleton(   ).getGuiRenderer(   )->createTexture(  texturePtr );
          
           ///we need a imageset in order to create GUI elements from the ceguiTexture
           S_LOG_VERBOSE(  "Creating new CEGUI imageset with name " << imageSetName + "_EntityCEGUITextureImageset" );
           mImageSet = CEGUI::ImagesetManager::getSingleton(   ).createImageset(  imageSetName + "_EntityCEGUITextureImageset",   mCeguiTexture );
          
           ///we only want one element: the whole texture
           ///the width and height of the texture differs from the supplied width of this instance since it will have been adjusted to a power-of-two size
           mImageSet->defineImage(  "full_image",   CEGUI::Rect(  0,   0,   texturePtr->getWidth(   ),   texturePtr->getHeight(   ) ),   CEGUI::Point(  0,  0 ) );
          
           ///assign our image element to the StaticImage widget
           mImage = &mImageSet->getImage(  "full_image" );
          
          
          }
          
          
      80  SimpleRenderContext* EntityCEGUITexture::getRenderContext(   )
          {
           return mRenderContext.get(   );
          }
          
          
          
          
          }
          }

./components/ogre/widgets/EntityCEGUITexture.h

       1  //
          // C++ Interface: EntityCEGUITexture
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREENTITYCEGUITEXTURE_H
          #define EMBEROGREENTITYCEGUITEXTURE_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          
          namespace CEGUI
          {
      30   class Imageset;
      31   class Image;
      32   class Texture;
          }
          
          namespace EmberOgre {
          
      37  class SimpleRenderContext;
          
          namespace Model {
      40   class Model;
          }
          
      43  namespace Gui {
          
          /**
          @author Erik Hjortsberg
          
          Useful class for rendering a single scene node to a CEGUI texture.
          
          */
          class EntityCEGUITexture
          // : public RenderTargetListener
          {
          public:
          
           /**
           * Constructor.
           * @param imageSetName The name of the imageset.
           * @param width The width of the image created.
           * @param height The height of the image created.
           * @return
           */
           EntityCEGUITexture(  const std::string& imageSetName,   int width,   int height );
          
           virtual ~EntityCEGUITexture(   );
          
           /**
           * Gets the rendered image.
           * @return
           */
           const CEGUI::Image* getImage(   ) const;
          
          
           SimpleRenderContext* getRenderContext(   );
          
          private:
          
           /**
           The rendered image.
           */
           const CEGUI::Image* mImage;
          
           /**
           The main imageset,   though only one image will be defined for it.
           */
           CEGUI::Imageset* mImageSet;
          
           /**
           * Creates the imageset and image and sets up the rendering.
           * @param imageSetName
           */
           void createImage(  const std::string& imageSetName );
          
           /**
           Width and height of the image.
           */
           int mWidth,   mHeight;
          
           std::auto_ptr<SimpleRenderContext> mRenderContext;
           CEGUI::Texture* mCeguiTexture;
          };
          
          
          }
          }
          
          #endif

./components/ogre/widgets/EntityEditor.cpp

       1  //
          // C++ Implementation: EntityEditor
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityEditor.h"
          
          #include "adapters/atlas/AdapterBase.h"
          #include "adapters/atlas/MapAdapter.h"
          
          #include "services/EmberServices.h"
          #include "services/server/ServerService.h"
          #include <Atlas/Message/Element.h>
          #include <Eris/Entity.h>
          
          using namespace Atlas::Message;
          
          namespace EmberOgre {
          
          namespace Gui {
          
      39  EntityEditor::EntityEditor(  Eris::Entity* entity,   Adapters::Atlas::MapAdapter* rootAdapter )
          : mRootAdapter(  rootAdapter ),   mEntity(  entity )
          {
          }
          
          
      45  EntityEditor::~EntityEditor(   )
          {
           delete mRootAdapter;
          }
          
      50  void EntityEditor::submitChanges(   )
          {
           if (  mRootAdapter->hasChanges(   ) ) {
           Atlas::Message::Element rootElement = mRootAdapter->getSelectedChangedElements(   );
           if (  rootElement.isMap(   ) ) {
           std::map<std::string,   ::Atlas::Message::Element> attributes(  rootElement.asMap(   ) );
           if (  attributes.size(   ) ) {
           Ember::EmberServices::getSingleton(   ).getServerService(   )->setAttributes(  mEntity,   attributes );
           }
           }
           }
          }
          
      63  Atlas::Message::Element EntityEditor::createMapElement(   )
          {
           return Element(  MapType(   ) );
          }
          
      68  Atlas::Message::Element EntityEditor::createListElement(   )
          {
           return Element(  ListType(   ) );
          }
      72  Atlas::Message::Element EntityEditor::createStringElement(   )
          {
           return Element(  "" );
          }
      76  Atlas::Message::Element EntityEditor::createIntElement(   )
          {
           return Element(  0 );
          }
      80  Atlas::Message::Element EntityEditor::createFloatElement(   )
          {
           return Element(  0.0f );
          }
      84  Atlas::Message::Element EntityEditor::createPosition2dElement(   )
          {
           ListType list;
           list.push_back(  createFloatElement(   ) );
           list.push_back(  createFloatElement(   ) );
           return Element(  list );
          }
          
          
          }
          
          }

./components/ogre/widgets/EntityEditor.h

       1  //
          // C++ Interface: EntityEditor
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUIENTITYEDITOR_H
          #define EMBEROGRE_GUIENTITYEDITOR_H
          
          #include <map>
          #include <vector>
          #include <Atlas/Message/Element.h>
          
          namespace Eris
          {
      32   class Entity;
          }
          
          namespace CEGUI
          {
      37  class Window;
          }
          
      40  namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          class AdapterBase;
          class MapAdapter;
          
          }
          
          }
          
          struct AdapterWrapper
          {
           Adapters::Atlas::AdapterBase* Adapter;
           CEGUI::Window* ContainerWindow;
          };
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
          class EntityEditor{
          public:
           EntityEditor(  Eris::Entity* entity,   Adapters::Atlas::MapAdapter* rootAdapter );
          
           virtual ~EntityEditor(   );
          
           void submitChanges(   );
          
           Atlas::Message::Element createMapElement(   );
           Atlas::Message::Element createListElement(   );
           Atlas::Message::Element createStringElement(   );
           Atlas::Message::Element createIntElement(   );
           Atlas::Message::Element createFloatElement(   );
           Atlas::Message::Element createPosition2dElement(   );
          protected:
          
           Adapters::Atlas::MapAdapter* mRootAdapter;
          
           Eris::Entity* mEntity;
          
          
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/EntityIcon.cpp

          //
          // C++ Implementation: EntityIcon
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityIcon.h"
          #include "EntityIconSlot.h"
          #include <elements/CEGUIDragContainer.h>
          
          using namespace CEGUI;
          namespace EmberOgre {
          
          namespace Gui {
          
      32  EntityIcon::EntityIcon(  EntityIconManager& manager,   CEGUI::DragContainer* dragContainer,   CEGUI::Window* image,   Gui::Icons::Icon* icon,   EmberEntity* entity )
      33  : EntityIconDragDropTarget(  dragContainer ),   mManager(  manager ),   mDragContainer(  dragContainer ),   mImage(  image ),   mIcon(  icon ),   mUserData(  *this ),   mCurrentSlot(  0 ),   mEntity(  entity )
          {
           mDragContainer->setUserData(  &mUserData );
           mDragContainer->subscribeEvent(  CEGUI::DragContainer::EventDragStarted,   CEGUI::Event::Subscriber(  & EntityIcon::dragContainer_DragStarted,   this ) );
           mDragContainer->subscribeEvent(  CEGUI::DragContainer::EventDragEnded,   CEGUI::Event::Subscriber(  & EntityIcon::dragContainer_DragStopped,   this ) );
          
          }
          
      41  EntityIcon::~EntityIcon(   )
          {
           if (  mCurrentSlot ) {
           mCurrentSlot->removeEntityIcon(   );
           }
          }
          
      48  CEGUI::Window* EntityIcon::getImage(   )
          {
           return mImage;
          }
          
      53  Gui::Icons::Icon* EntityIcon::getIcon(   )
          {
           return mIcon;
          }
          
      58  CEGUI::DragContainer* EntityIcon::getDragContainer(   )
          {
           return mDragContainer;
          }
          
      63  void EntityIcon::setSlot(  EntityIconSlot* slot )
          {
           if (  mCurrentSlot ) {
           mCurrentSlot->notifyIconRemoved(   );
           }
           mCurrentSlot = slot;
          }
          
      71  EntityIconSlot* EntityIcon::getSlot(   )
          {
           return mCurrentSlot;
          }
          
      76  void EntityIcon::setTooltipText(  const std::string& text )
          {
           mDragContainer->setTooltipText(  text );
          }
          
      81  bool EntityIcon::dragContainer_DragStarted(  const CEGUI::EventArgs& args )
          {
           mManager.EventIconDragStart.emit(  this );
           return true;
          }
          
      87  bool EntityIcon::dragContainer_DragStopped(  const CEGUI::EventArgs& args )
          {
           mManager.EventIconDragStop.emit(  this );
           return true;
          }
          
      93  EmberEntity* EntityIcon::getEntity(   )
          {
           return mEntity;
          }
          
      98  bool EntityIcon::handleDragEnter(  const CEGUI::EventArgs& args,   EntityIcon* icon )
          {
           EntityIconDragDropTarget::handleDragEnter(  args,   icon );
           if (  mCurrentSlot ) {
           return mCurrentSlot->handleDragEnter(  args,   icon );
           }
           return true;
          }
     106  bool EntityIcon::handleDragLeave(  const CEGUI::EventArgs& args,   EntityIcon* icon )
          {
           EntityIconDragDropTarget::handleDragLeave(  args,   icon );
           if (  mCurrentSlot ) {
           return mCurrentSlot->handleDragLeave(  args,   icon );
           }
           return true;
          }
     114  bool EntityIcon::handleDragDropped(  const CEGUI::EventArgs& args,   EntityIcon* icon )
          {
           EntityIconDragDropTarget::handleDragDropped(  args,   icon );
           if (  mCurrentSlot ) {
           return mCurrentSlot->handleDragDropped(  args,   icon );
           }
           return true;
          
          }
          
          
     125  EntityIconUserData::EntityIconUserData(  EntityIcon& entityIcon )
          : mEntityIcon(  entityIcon )
          {
          }
          
     130  EntityIcon& EntityIconUserData::getEntityIcon(   )
          {
           return mEntityIcon;
          }
          
          
          
          }
          
          }

./components/ogre/widgets/EntityIcon.h

       1  //
          // C++ Interface: EntityIcon
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUIENTITYICON_H
          #define EMBEROGRE_GUIENTITYICON_H
          
          
          #include "icons/Icon.h"
          #include "EntityIconManager.h"
          #include "EntityIconDragDropTarget.h"
          
          namespace CEGUI {
      32  class DragContainer;
      33  class Window;
      34  class EventArgs;
          }
          
          namespace EmberOgre {
      38  class EmberEntity;
          namespace Gui {
          
      41  class EntityIconSlot;
      42  class EntityIcon;
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      47  class EntityIconUserData
          {
          public:
      50   EntityIconUserData(  EntityIcon& entityIcon );
          
      52   EntityIcon& getEntityIcon(   );
          private:
      54   EntityIcon& mEntityIcon;
          };
          
          
          
      59  class EntityIcon : public EntityIconDragDropTarget
          {
      61  friend class EntityIconManager;
          public:
          
      64   CEGUI::Window* getImage(   );
      65   CEGUI::DragContainer* getDragContainer(   );
      66   Gui::Icons::Icon* getIcon(   );
      67   void setSlot(  EntityIconSlot* slot );
      68   EntityIconSlot* getSlot(   );
      69   void setTooltipText(  const std::string& text );
      70   EmberEntity* getEntity(   );
          
      72   sigc::signal<void,   EntityIcon*> EventIconEntered;
      73   sigc::signal<void,   EntityIcon*> EventIconLeaves;
      74   sigc::signal<void,   EntityIcon*> EventIconDropped;
          protected:
      76   EntityIcon(  EntityIconManager& manager,   CEGUI::DragContainer* dragContainer,   CEGUI::Window* image,   Gui::Icons::Icon* icon,   EmberEntity* entity );
      77   virtual ~EntityIcon(   );
          
      79   EntityIconManager& mManager;
      80   CEGUI::DragContainer* mDragContainer;
      81   CEGUI::Window* mImage;
      82   Gui::Icons::Icon* mIcon;
      83   EntityIconUserData mUserData;
      84   EntityIconSlot* mCurrentSlot;
      85   EmberEntity* mEntity;
          
      87   bool dragContainer_DragStarted(  const CEGUI::EventArgs& args );
      88   bool dragContainer_DragStopped(  const CEGUI::EventArgs& args );
          
      90   virtual bool handleDragEnter(  const CEGUI::EventArgs& args,   EntityIcon* icon );
      91   virtual bool handleDragLeave(  const CEGUI::EventArgs& args,   EntityIcon* icon );
      92   virtual bool handleDragDropped(  const CEGUI::EventArgs& args,   EntityIcon* icon );
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/EntityIconDragDropTarget.cpp

       1  //
          // C++ Implementation: EntityIconDragDropTarget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityIconDragDropTarget.h"
          #include "EntityIcon.h"
          #include <elements/CEGUIDragContainer.h>
          #include <CEGUIWindow.h>
          
          using namespace CEGUI;
          
          namespace EmberOgre {
          
          namespace Gui {
          
      34  EntityIconDragDropTarget::EntityIconDragDropTarget(  CEGUI::Window* container )
          {
           container->subscribeEvent(  CEGUI::Window::EventDragDropItemEnters,   CEGUI::Event::Subscriber(  & EntityIconDragDropTarget::dragContainer_DragEnter,   this ) );
           container->subscribeEvent(  CEGUI::Window::EventDragDropItemLeaves,   CEGUI::Event::Subscriber(  & EntityIconDragDropTarget::dragContainer_DragLeave,   this ) );
           container->subscribeEvent(  CEGUI::Window::EventDragDropItemDropped,   CEGUI::Event::Subscriber(  & EntityIconDragDropTarget::dragContainer_DragDropped,   this ) );
          
          }
          
      42  EntityIconDragDropTarget::~EntityIconDragDropTarget(   )
          {
          }
          
          
      47  bool EntityIconDragDropTarget::dragContainer_DragEnter(  const CEGUI::EventArgs& args )
          {
           EntityIcon* entityIcon = parseIcon(  args );
           if (  entityIcon ) {
           return handleDragEnter(  args,   entityIcon );
           }
           return true;
          }
          
      56  bool EntityIconDragDropTarget::dragContainer_DragLeave(  const CEGUI::EventArgs& args )
          {
           EntityIcon* entityIcon = parseIcon(  args );
           if (  entityIcon ) {
           return handleDragLeave(  args,   entityIcon );
           }
           return true;
          }
          
      65  bool EntityIconDragDropTarget::dragContainer_DragDropped(  const CEGUI::EventArgs& args )
          {
           EntityIcon* entityIcon = parseIcon(  args );
           if (  entityIcon ) {
           return handleDragDropped(  args,   entityIcon );
           }
           return true;
          }
          
          
          
      76  bool EntityIconDragDropTarget::handleDragEnter(  const CEGUI::EventArgs& args,   EntityIcon* icon )
          {
           EventIconEntered.emit(  icon );
           return true;
          }
      81  bool EntityIconDragDropTarget::handleDragLeave(  const CEGUI::EventArgs& args,   EntityIcon* icon )
          {
           EventIconLeaves.emit(  icon );
           return true;
          }
      86  bool EntityIconDragDropTarget::handleDragDropped(  const CEGUI::EventArgs& args,   EntityIcon* icon )
          {
           EventIconDropped.emit(  icon );
           return true;
          }
          
      92  EntityIcon* EntityIconDragDropTarget::parseIcon(  const CEGUI::EventArgs& args )
          {
           const DragDropEventArgs& ddea = static_cast<const DragDropEventArgs&>(  args );
           DragContainer* container = ddea.dragDropItem;
           if (  container ) {
           EntityIconUserData* mUserData = static_cast<EntityIconUserData*>(  container->getUserData(   ) );
           if (  mUserData ) {
           return &mUserData->getEntityIcon(   );
           }
           }
           return 0;
          }
          
          
          
          }
          
          }

./components/ogre/widgets/EntityIconDragDropTarget.h

       1  //
          // C++ Interface: EntityIconDragDropTarget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUIENTITYICONDRAGDROPTARGET_H
          #define EMBEROGRE_GUIENTITYICONDRAGDROPTARGET_H
          
          #include <sigc++/signal.h>
          
          namespace CEGUI
          {
      30   class Window;
      31   class EventArgs;
          }
          
          namespace EmberOgre {
          
          namespace Gui {
          
      38  class EntityIcon;
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      42  class EntityIconDragDropTarget
          {
          public:
      45   EntityIconDragDropTarget(  CEGUI::Window* container );
      46   virtual ~EntityIconDragDropTarget(   );
          
      48   sigc::signal<void,   EntityIcon*> EventIconEntered;
      49   sigc::signal<void,   EntityIcon*> EventIconLeaves;
      50   sigc::signal<void,   EntityIcon*> EventIconDropped;
          protected:
      52   virtual bool handleDragEnter(  const CEGUI::EventArgs& args,   EntityIcon* icon );
      53   virtual bool handleDragLeave(  const CEGUI::EventArgs& args,   EntityIcon* icon );
      54   virtual bool handleDragDropped(  const CEGUI::EventArgs& args,   EntityIcon* icon );
          
          private:
      57   bool dragContainer_DragEnter(  const CEGUI::EventArgs& args );
      58   bool dragContainer_DragLeave(  const CEGUI::EventArgs& args );
      59   bool dragContainer_DragDropped(  const CEGUI::EventArgs& args );
          
      61   EntityIcon* parseIcon(  const CEGUI::EventArgs& args );
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/EntityIconManager.cpp

       1  //
          // C++ Implementation: EntityIconManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityIconManager.h"
          #include <string>
          #include <CEGUI.h>
          #include "../GUIManager.h"
          #include "EntityIcon.h"
          #include "EntityIconSlot.h"
          #include "icons/Icon.h"
          namespace EmberOgre {
          
          namespace Gui {
          
      34  EntityIconManager::EntityIconManager(  GUIManager& guiManager )
          : mGuiManager(  guiManager ),   mIconsCounter(  0 ),   mSlotsCounter(  0 )
          {
          }
          
          
      40  EntityIconSlot* EntityIconManager::createSlot(  unsigned int pixelSize )
          {
           std::stringstream ss;
           ss << "entityIconSlot" << mSlotsCounter++;
          
           CEGUI::Window* container = mGuiManager.createWindow(  "DefaultGUISheet",   ss.str(   ) );
           container->setSize(  CEGUI::UVector2(  CEGUI::UDim(  0,   pixelSize ),   CEGUI::UDim(  0,   pixelSize ) ) );
           EntityIconSlot* slot = new EntityIconSlot(  *this,   container );
           mSlots.push_back(  slot );
           return slot;
          }
          
      52  EntityIcon* EntityIconManager::createIcon(  Gui::Icons::Icon* icon,   EmberEntity* entity,   unsigned int pixelSize )
          {
           if (  !icon ) {
           S_LOG_WARNING(  "Trying to create an EntityIcon with an invalid Icon." );
           return 0;
           }
           std::stringstream ss;
           ss << "entityIcon" << mIconsCounter++;
          
           CEGUI::DragContainer* item = static_cast<CEGUI::DragContainer*>(  mGuiManager.createWindow(  "DragContainer",   ss.str(   ) ) );
          
           if (  item ) {
           item->setSize(  CEGUI::UVector2(  CEGUI::UDim(  0,   pixelSize ),   CEGUI::UDim(  0,   pixelSize ) ) );
           //item->setTooltipText(  name );
          
           ss << "Image" ;
           CEGUI::Window* iconWindow = mGuiManager.createWindow(  "EmberLook/StaticImage",   ss.str(   ) );
           if (  iconWindow ) {
           iconWindow->setProperty(  "BackgroundEnabled",   "false" );
           iconWindow->setProperty(  "FrameEnabled",   "false" );
           iconWindow->disable(   );
          // iconWindow->setProperty(  "FrameEnabled",   "false" );
           iconWindow->setProperty(  "Image",   CEGUI::PropertyHelper::imageToString(  icon->getImage(   ) ) );
           item->addChildWindow(  iconWindow );
          
           EntityIcon* entityIcon = new EntityIcon(  *this,   item,   iconWindow,   icon,   entity );
           mIcons.push_back(  entityIcon );
           return entityIcon;
           }
           }
           return 0;
          }
          
      85  void EntityIconManager::destroyIcon(  EntityIcon* icon )
          {
           EntityIconStore::iterator I = std::find(  mIcons.begin(   ),   mIcons.end(   ),   icon );
           if (  I != mIcons.end(   ) ) {
           mIcons.erase(  I );
           delete icon;
           }
          }
          
      94  void EntityIconManager::destroySlot(  EntityIconSlot* slot )
          {
           EntityIconSlotStore::iterator I = std::find(  mSlots.begin(   ),   mSlots.end(   ),   slot );
           if (  I != mSlots.end(   ) ) {
           mSlots.erase(  I );
           delete slot;
           }
          }
          
          }
          
          }

./components/ogre/widgets/EntityIconManager.h

       1  //
          // C++ Interface: EntityIconManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUIENTITYICONMANAGER_H
          #define EMBEROGRE_GUIENTITYICONMANAGER_H
          
          #include <sigc++/signal.h>
          #include <vector>
          
          namespace EmberOgre {
      30  class EmberEntity;
      31  class GUIManager;
          namespace Gui {
          
          namespace Icons
          {
      36  class Icon;
          }
          
      39  class EntityIconSlot;
      40  class EntityIcon;
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      45  class EntityIconManager
          {
          public:
          typedef std::vector<EntityIconSlot*> EntityIconSlotStore;
          typedef std::vector<EntityIcon*> EntityIconStore;
          
      51   EntityIconManager(  GUIManager& guiManager );
          
      53   EntityIconSlot* createSlot(  unsigned int pixelSize = 64 );
      54   void destroySlot(  EntityIconSlot* slot );
          
      56   EntityIcon* createIcon(  Gui::Icons::Icon* icon,   EmberEntity* entity,   unsigned int pixelSize = 64 );
      57   void destroyIcon(  EntityIcon* icon );
          
      59   sigc::signal<void,   EntityIcon*> EventIconDragStart;
      60   sigc::signal<void,   EntityIcon*> EventIconDragStop;
          
          protected:
      63   EntityIconSlotStore mSlots;
      64   EntityIconStore mIcons;
      65   GUIManager& mGuiManager;
           int mIconsCounter,   mSlotsCounter;
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/EntityIconSlot.cpp

       1  //
          // C++ Implementation: EntityIconSlot
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "EntityIconSlot.h"
          #include "Widget.h"
          #include <CEGUI.h>
          #include "EntityIconManager.h"
          #include "EntityIcon.h"
          
          using namespace CEGUI;
          namespace EmberOgre {
          
          namespace Gui {
          
      34  EntityIconSlot::EntityIconSlot(  EntityIconManager& manager,   CEGUI::Window* container )
          : EntityIconDragDropTarget(  container ),   mManager(  manager ),   mContainer(  container ),   mContainedIcon(  0 )
          {
          }
          
      39  EntityIconSlot::~EntityIconSlot(   )
          {
          }
          
          
      44  bool EntityIconSlot::addEntityIcon(  EntityIcon* icon )
          {
           if (  icon ) {
           if (  !mContainedIcon ) {
           mContainedIcon = icon;
           mContainer->addChildWindow(  icon->getDragContainer(   ) );
           icon->setSlot(  this );
           ///we have to notify the container that things have changed else it won't update itself when we add the entity without dragging (  cegui bug? )
           mContainer->notifyScreenAreaChanged(   );
           } else {
           S_LOG_WARNING(  "Trying to add entity icon to slot that already has one icon contained." );
           return false;
           }
           }
           return true;
          }
          
      61  EntityIcon* EntityIconSlot::removeEntityIcon(   )
          {
           if (  mContainedIcon ) {
           mContainer->removeChildWindow(  mContainedIcon->getDragContainer(   ) );
           EntityIcon* icon = mContainedIcon;
           mContainedIcon = 0;
           icon->setSlot(  0 );
           ///we have to notify the container that things have changed else it won't update itself when we remove the entity without dragging (  cegui bug? )
           mContainer->notifyScreenAreaChanged(   );
           return icon;
           } else {
           return 0;
           }
          }
          
      76  EntityIcon* EntityIconSlot::getEntityIcon(   )
          {
           return mContainedIcon;
          }
          
          
      82  void EntityIconSlot::notifyIconRemoved(   )
          {
           removeEntityIcon(   );
           mContainedIcon = 0;
          }
          
      88  CEGUI::Window* EntityIconSlot::getWindow(   )
          {
           return mContainer;
          }
          
      93  void EntityIconSlot::notifyIconDraggedOff(  EntityIcon* entityIcon )
          {
           EventIconDraggedOff.emit(  entityIcon );
          }
          
          
          // bool EntityIconSlot::handleDragEnter(  const CEGUI::EventArgs& args,   EntityIcon* icon )
          // {
          // const DragDropEventArgs& ddea = static_cast<const DragDropEventArgs&>(  args );
          // DragContainer* container = ddea.dragDropItem;
          // if (  container ) {
          // EntityIconUserData* mUserData = static_cast<EntityIconUserData*>(  container->getUserData(   ) );
          // if (  mUserData ) {
          // EventIconEntered.emit(  &mUserData->getEntityIcon(   ) );
          // }
          // }
          // return true;
          // }
          // bool EntityIconSlot::handleDragLeave(  const CEGUI::EventArgs& args,   EntityIcon* icon )
          // {
          // const DragDropEventArgs& ddea = static_cast<const DragDropEventArgs&>(  args );
          // DragContainer* container = ddea.dragDropItem;
          // if (  container ) {
          // EntityIconUserData* mUserData = static_cast<EntityIconUserData*>(  container->getUserData(   ) );
          // if (  mUserData ) {
          // EventIconLeaves.emit(  &mUserData->getEntityIcon(   ) );
          // }
          // }
          // return true;
          // }
          // bool EntityIconSlot::handleDragDropped(  const CEGUI::EventArgs& args,   EntityIcon* icon )
          // {
          // const DragDropEventArgs& ddea = static_cast<const DragDropEventArgs&>(  args );
          // DragContainer* container = ddea.dragDropItem;
          // if (  container ) {
          // EntityIconUserData* mUserData = static_cast<EntityIconUserData*>(  container->getUserData(   ) );
          // if (  mUserData ) {
          // EntityIcon& entityIcon = mUserData->getEntityIcon(   );
          // EventIconDropped.emit(  &entityIcon );
          // // addEntityIcon(  &entityIcon );
          // }
          // }
          // return true;
          // }
          
          
          }
          
          }

./components/ogre/widgets/EntityIconSlot.h

       1  //
          // C++ Interface: EntityIconSlot
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUIENTITYICONSLOT_H
          #define EMBEROGRE_GUIENTITYICONSLOT_H
          
          #include <sigc++/signal.h>
          #include "EntityIconDragDropTarget.h"
          
          namespace CEGUI {
      30  class DragContainer;
      31  class Window;
      32  class EventArgs;
          }
          
          namespace EmberOgre {
          
          namespace Gui {
          
      39  class EntityIcon;
      40  class EntityIconManager;
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      45  class EntityIconSlot : public EntityIconDragDropTarget
          {
      47  friend class EntityIconManager;
      48  friend class EntityIcon;
          public:
          
           /**
           * Adds an EntityIcon to the slot. If the slot already contains an icon,   the method will return false and an error will be logged.
           * @param icon
           * @return true if successful,   else false
           */
          
      57   bool addEntityIcon(  EntityIcon* icon );
          
           /**
           * Removes and returns the contained EntityIcon. If none is contained,   nothing will happen.
           * @return The contained EntityIcon or null if none contained.
           */
      63   EntityIcon* removeEntityIcon(   );
          
           /**
           * Gets the contained EntityIcon
           * @return
           */
      69   EntityIcon* getEntityIcon(   );
          
      71   CEGUI::Window* getWindow(   );
          
           /**
           Call this from the gui code whenever an icon is dragged away from the slot.
           */
      76   void notifyIconDraggedOff(  EntityIcon* entityIcon );
          
           /**
           Emitted when an icon has been dragged away from the slot as a result of an user action.
           */
      81   sigc::signal<void,   EntityIcon*> EventIconDraggedOff;
          
          
          
          protected:
      86   EntityIconSlot(  EntityIconManager& manager,   CEGUI::Window* container );
      87   virtual ~EntityIconSlot(   );
          
      89   EntityIconManager& mManager;
      90   CEGUI::Window* mContainer;
      91   EntityIcon* mContainedIcon;
          
           /**
           * Internal method called by the EntityIcon when it's removed from the slot.
           */
      96   void notifyIconRemoved(   );
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/Help.cpp

          //
          // C++ Implementation: Help
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Help.h"
          #include "Widget.h"
          #include "../GUIManager.h"
          #include <CEGUIImagesetManager.h>
          #include <CEGUIImageset.h>
          #include "framework/ConsoleBackend.h"
          #include <elements/CEGUIFrameWindow.h>
          #include <elements/CEGUIGUISheet.h>
          
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/config/ConfigService.h"
          
          #include "../EmberEntity.h"
          #include "../EmberPhysicalEntity.h"
          // #include "../PersonEmberEntity.h"
          #include "../AvatarEmberEntity.h"
          #include "../EmberOgre.h"
          
          #include <CEGUIWindowManager.h>
          #include <CEGUIExceptions.h>
          
          using namespace CEGUI;
          namespace EmberOgre {
          namespace Gui {
          
          
      50  Help::Help(   )
           : HelpCommand(  "help",   this,   "Display the help." )
      52   ,   mTimeUntilShowBlurb(  30 )
           ,   mTimeBlurbShown(  0 )
           ,   mTimeToShowBlurb(  10 )
           ,   mBlurb(  0 )
          {
          
          }
          
          
      61  Help::~Help(   )
          {
          }
          
          
      66  void Help::buildWidget(   )
          {
          
           loadMainSheet(  "HelpWidget.layout",   "Help/" );
          
           enableCloseButton(   );
          
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
          
           if (  configSrv->itemExists(  "general",   "startuphelp" ) && (  (  bool )configSrv->getValue(  "general",   "startuphelp" ) ) ) {
           mMainWindow->setVisible(  true );
           }
          
           //connect to the creation of the avatar,   since we want to show a help blurb about the movement
           EmberOgre::getSingleton(   ).EventCreatedAvatarEntity.connect(  sigc::mem_fun(  *this,   &Help::EmberOgre_CreatedAvatarEntity ) );
          
          }
          
          
          
      86  void Help::show(   )
          {
           if (  mMainWindow ) {
           mMainWindow->setVisible(  true );
           mMainWindow->moveToFront(   );
           }
          }
          
      94  void Help::hide(   )
          {
           if (  mMainWindow ) {
           mMainWindow->setVisible(  false );
           }
          }
          
          
     102  void Help::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  HelpCommand == command )
           {
           show(   );
           } else {
           Widget::runCommand(  command,   args );
           }
          
          }
          
     113  void Help::EmberOgre_CreatedAvatarEntity(  AvatarEmberEntity* entity )
          {
           ///Show a small helpful blurb about the gui system
           if (  !mBlurb ) {
           try {
           mBlurb = static_cast<CEGUI::GUISheet*>(  mWindowManager->createWindow(  getDefaultScheme(   ) + "/StaticText",   (  CEGUI::utf8* )"Help/Blurb" ) );
           mBlurb->setSize(  UVector2(  UDim(  0.3f,   0 ),   UDim(  0.1f,   0 ) ) );
           mBlurb->setPosition(  UVector2(  UDim(  0.35f,   0 ),   UDim(  0.3f,   0 ) ) );
          // mBlurb->setFrameEnabled(  false );
           // mBlurb->setInheritAlpha(  true );
           //mEntityName->setBackgroundEnabled(  false );
           mBlurb->setProperty(  "HorzFormatting",   "WordWrapLeftAligned" );
           mBlurb->setText(  "Click right mouse button to switch between MOVEMENT and INPUT MODE." );
          
          
           getMainSheet(   )->addChildWindow(  mBlurb );
           mBlurb->setVisible(  false );
           mTimeBlurbShown = 0;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating help blurb. Message:\n" << ex.getMessage(   ).c_str(   ) );
           }
           }
          
          }
          
     138  void Help::frameStarted(  const Ogre::FrameEvent& evt )
          {
           if (  mBlurb ) {
           if (  !mBlurb->isVisible(   ) ) {
           mTimeUntilShowBlurb -= evt.timeSinceLastFrame;
           if (  mTimeUntilShowBlurb < 0 ) {
           mBlurb->setVisible(  true );
           }
           } else {
           mTimeBlurbShown += evt.timeSinceLastFrame;
           mBlurb->setAlpha(  1.0f - (  mTimeBlurbShown / mTimeToShowBlurb ) );
          
           if (  mTimeBlurbShown > mTimeToShowBlurb ) {
           mWindowManager->destroyWindow(  mBlurb );
           mBlurb = 0;
           }
           }
           }
          }
          }
          };

./components/ogre/widgets/Help.h

       1  //
          // C++ Interface: Help
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREHELP_H
          #define EMBEROGREHELP_H
          
          #include "Widget.h"
          #include "framework/ConsoleObject.h"
          #include <elements/CEGUIGUISheet.h>
          #include <CEGUIEvent.h>
          
          namespace EmberOgre {
      32  class GUIManager;
      33  class AvatarEmberEntity;
          namespace Gui {
      35  class Widget;
          
          /**
          @author Erik Hjortsberg
          */
      40  class Help : public Widget
          {
          public:
      43   Help(   );
          
      45   virtual ~Help(   );
      46   virtual void buildWidget(   );
      47   virtual void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           * Called each frame.
           * @param evt
           */
      53   virtual void frameStarted(  const Ogre::FrameEvent& evt );
          
      55   const Ember::ConsoleCommandWrapper HelpCommand;
          
          protected:
          
      59   void show(   );
          
      61   void hide(   );
          
      63   Ogre::Real mTimeUntilShowBlurb,   mTimeBlurbShown,   mTimeToShowBlurb;
          
      65   CEGUI::GUISheet* mBlurb;
          
           /**
           * hooked to EmberOgre::EventCreatedAvatarEntity,   show a help blurb about the movement mode
           * @param entity
           */
      71   void EmberOgre_CreatedAvatarEntity(  AvatarEmberEntity* entity );
          
          };
          };
          };
          
          #endif

./components/ogre/widgets/IconBar.cpp

       1  //
          // C++ Implementation: IconBar
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "IconBar.h"
          #include <CEGUI.h>
          #include "IconBase.h"
          
          using namespace CEGUI;
          
          namespace EmberOgre {
          
          namespace Gui {
          
      33  IconBar::IconBar(  const std::string& name )
          : mIconPadding(  0 )
          {
           mWindow = WindowManager::getSingleton(   ).createWindow(  "DefaultGUISheet",   "iconbars/" + name );
          /* mWindow->setProperty(  "BackgroundEnabled",   "false" );
           mWindow->setProperty(  "FrameEnabled",   "false" );*/
          }
          
      41  IconBar::~IconBar(   )
          {
           for (  std::vector<IconBase*>::iterator I = mIconBases.begin(   ); I != mIconBases.end(   ); ++I ) {
           delete *I;
           }
           CEGUI::WindowManager::getSingleton(   ).destroyWindow(  mWindow );
          }
          
          
      50  void IconBar::addIcon(  IconBase* iconBase )
          {
           mIconBases.push_back(  iconBase );
           mWindow->addChildWindow(  iconBase->getContainer(   ) );
           repositionIcons(   );
          }
      56  void IconBar::removeIcon(  IconBase* iconBase )
          {
           IconBaseStore::iterator I = std::find(  mIconBases.begin(   ),   mIconBases.end(   ),   iconBase );
           if (  I != mIconBases.end(   ) ) {
           mWindow->removeChildWindow(  iconBase->getContainer(   ) );
           mIconBases.erase(  I );
           }
           repositionIcons(   );
          }
          
      66  CEGUI::Window* IconBar::getWindow(   )
          {
           return mWindow;
          }
          
      71  void IconBar::setIconPadding(  int iconPadding )
          {
           mIconPadding = iconPadding;
          }
          
          
      77  void IconBar::repositionIcons(   )
          {
           float accumulatedWidth(  0 );
           float maxHeight(  0 );
          
           for(  IconBaseStore::iterator I(  mIconBases.begin(   ) ); I != mIconBases.end(   ); ++I ) {
           IconBase* icon = (  *I );
           const UVector2& size = icon->getContainer(   )->getSize(   );
           float absHeight = size.d_y.asAbsolute(  0 );
           float absWidth = size.d_x.asAbsolute(  0 );
           maxHeight = std::max<float>(  maxHeight,   absHeight );
          
           icon->getContainer(   )->setPosition(  UVector2(  UDim(  0,   accumulatedWidth ),   UDim(  0,  0 ) ) );
          
           accumulatedWidth += absWidth + mIconPadding;
           }
           accumulatedWidth -= mIconPadding;
           mWindow->setSize(  UVector2(  UDim(  0,   accumulatedWidth ),   UDim(  0,  maxHeight ) ) );
          }
          
      97  float IconBar::getAbsoluteHeight(   )
          {
           return mWindow->getSize(   ).d_y.asAbsolute(  0 );
          }
          
     102  float IconBar::getAbsoluteWidth(   )
          {
           return mWindow->getSize(   ).d_x.asAbsolute(  0 );
          }
          
          
          }
          
          }

./components/ogre/widgets/IconBar.h

       1  //
          // C++ Interface: IconBar
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_WIDGETSICONBAR_H
          #define EMBEROGRE_WIDGETSICONBAR_H
          #include <string>
          #include <vector>
          
          namespace CEGUI
          {
      30  class Window;
          }
          
          namespace EmberOgre {
          
          
          namespace Gui {
      37  class IconBase;
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      42  class IconBar
          {
          public:
      45   IconBar(  const std::string& name );
      46   virtual ~IconBar(   );
          
      48   void addIcon(  IconBase* iconBase );
      49   void removeIcon(  IconBase* iconBase );
          
      51   CEGUI::Window* getWindow(   );
          
      53   void setIconPadding(  int iconPadding );
          
      55   float getAbsoluteHeight(   );
      56   float getAbsoluteWidth(   );
          
          protected:
           typedef std::vector<IconBase*> IconBaseStore;
          
      61   CEGUI::Window* mWindow;
          
      63   IconBaseStore mIconBases;
          
           /**
           Repositions all icons as they are added and removed to the list.
           */
      68   void repositionIcons(   );
          
           int mIconPadding;
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/IconBase.cpp

       1  //
          // C++ Implementation: IconBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "IconBase.h"
          
          #include <CEGUIImagesetManager.h>
          #include <CEGUIImageset.h>
          #include <elements/CEGUIFrameWindow.h>
          //#include "../EmberOgre.h"
          #include "../GUIManager.h"
          
          using namespace CEGUI;
          namespace EmberOgre {
          namespace Gui {
          
      35  IconBase::IconBase(  const std::string& name,   const Image* background,   const Image* foreground,   const Image* borderInactive,   const Image* borderActive )
          {
          
           mContainer = WindowManager::getSingleton(   ).createWindow(  "DefaultGUISheet",   "icons/" + name + "/container" );
           mContainer->setSize(  UVector2(  UDim(  0,   48 ),   UDim(  0,   48 ) ) );
           mContainer->setVisible(  true );
           mContainer->setEnabled(  true );
          // mContainer->setFrameEnabled(  false );
          // mContainer->setBackgroundEnabled(  false );
          // mContainer->setBackgroundColours(  colour(  1,  1,  1,  0 ) );
          
           mButton = static_cast<PushButton*>(  WindowManager::getSingleton(   ).createWindow(  EmberOgre::GUIManager::getSingleton(   ).getDefaultScheme(   ) + "/BorderIconButton",   "icons/" + name + "/button" ) );
           mButton->setSize(  UVector2(  UDim(  1,   0 ),   UDim(  1,   0 ) ) );
           mButton->setPosition(  UVector2(  UDim(  0,   0 ),   UDim(  0,   0 ) ) );
          
           mButton->setProperty(  "BackImage",   PropertyHelper::imageToString(  background ) );
           mButton->setProperty(  "FrontImage",   PropertyHelper::imageToString(  foreground ) );
           mButton->setProperty(  "BorderNormalImage",   PropertyHelper::imageToString(  borderInactive ) );
           mButton->setProperty(  "BorderHoverImage",   PropertyHelper::imageToString(  borderActive ) );
          
           mContainer->addChildWindow(  mButton );
          
           mButton->render(   );
          
          
          }
          
      62  IconBase::~IconBase(   )
          {
           CEGUI::WindowManager::getSingleton(   ).destroyWindow(  mButton );
           CEGUI::WindowManager::getSingleton(   ).destroyWindow(  mContainer );
          }
          
      68  Window* IconBase::getContainer(   )
          {
           return mContainer;
          }
          
      73  PushButton * IconBase::getButton(   )
          {
           return mButton;
          }
          
      78  void IconBase::setForeground(  const Image* image )
          {
           mButton->setProperty(  "FrontImage",   PropertyHelper::imageToString(  image ) );
          }
          
          
      84  const Image* IconBase::loadImageFromImageset(  const std::string & imagesetName,   const std::string & image )
          {
           Imageset* imageSet;
           if (  !ImagesetManager::getSingleton(   ).isImagesetPresent(  imagesetName ) ) {
           try {
           std::string imagesetFileName(  "cegui/datafiles/imagesets/" + imagesetName + ".imageset" );
           imageSet = ImagesetManager::getSingleton(   ).createImageset(  imagesetFileName );
           } catch (  const Ogre::Exception& ) {
           return 0;
           }
           } else {
           imageSet = ImagesetManager::getSingleton(   ).getImageset(  imagesetName );
           }
          
           return &imageSet->getImage(  image );
          
          }
          }
          
          }

./components/ogre/widgets/IconBase.h

       1  //
          // C++ Interface: IconBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREICONBASE_H
          #define EMBEROGREICONBASE_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include <CEGUI.h>
          
          namespace EmberOgre {
          namespace Gui {
          
          /**
          Use this class as base for more advanced buttons where you want a "roll over" effect.
          
          @author Erik Hjortsberg
          */
      37  class IconBase{
          public:
          
           /**
           * Default constructor.
           * @param name the name of the icon
           * @param background the image for the background,   will always be shown
           * @param foreground the image for the foreground,   will always be shown
           * @param borderInactive the image for the border when active (  i.e. rolled over ). Will only be active when rolled over.
           * @param borderActive the image for the border when inactive (  i.e. not rolled over ). Will only be active when not rolled over.
           * @return
           */
      49   IconBase(  const std::string& name,   const CEGUI::Image* background,   const CEGUI::Image* foreground,   const CEGUI::Image* borderInactive,   const CEGUI::Image* borderActive );
          
      51   ~IconBase(   );
          
           /**
           * Returns a pointer to the container which holds the button. If you want to attach to event etc. use this one.
           * @return
           */
      57   CEGUI::Window* getContainer(   );
      58   CEGUI::PushButton* getButton(   );
          
      60   void setForeground(  const CEGUI::Image* image );
          
      62   static const CEGUI::Image* loadImageFromImageset(  const std::string & imagesetName,   const std::string & image );
          
          protected:
      65   CEGUI::Window* mContainer;
      66   CEGUI::PushButton* mButton;
          };
          }
          }
          
          #endif

./components/ogre/widgets/IngameChatWidget.cpp

          //
          // C++ Implementation: IngameChatWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          
          
          #include "Widget.h"
          #include "../GUIManager.h"
          #include "../EmberEntity.h"
          
          #include <CEGUIWindowManager.h>
          #include <CEGUIExceptions.h>
          #include <CEGUIFont.h>
          #include <elements/CEGUIListbox.h>
          #include <elements/CEGUIListboxTextItem.h>
          #include <elements/CEGUIPushButton.h>
          #include <elements/CEGUIGUISheet.h>
          #include <Eris/Entity.h>
          #include <Eris/View.h>
          #include <Eris/TypeInfo.h>
          #include <Eris/TypeService.h>
          #include <Eris/Connection.h>
          #include <Eris/Avatar.h>
          #include "IngameChatWidget.h"
          
          #include "../EmberOgre.h"
          #include "../AvatarCamera.h"
          #include "../Avatar.h"
          
          #include "../EmberEntity.h"
          #include "../EmberPhysicalEntity.h"
          #include "../model/Model.h"
          #include "../AvatarEmberEntity.h"
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include "services/server/ServerService.h"
          #include <sigc++/slot.h>
          
          
          using namespace CEGUI;
          namespace EmberOgre {
          namespace Gui {
          
      64  IngameChatWidget::IngameChatWidget(   )
      65  : mTimeShown(  0 ),   mDistanceShown(  100 ),   mLabelCreator(  *this ),   mLabelPool(  mLabelCreator ),   mChatTextCreator(  *this ),   mChatTextPool(  mChatTextCreator ),   mAvatarEntityId(  "" )
          {
           mMainCamera = EmberOgre::getSingleton(   ).getMainCamera(   )->getCamera(   );
          }
          
      70  IngameChatWidget::~IngameChatWidget(   )
          {
          // Ogre::Root::getSingleton(   ).removeFrameListener(  this );
          }
          
      75  void IngameChatWidget::buildWidget(   )
          {
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
           if (  configSrv->itemExists(  "ingamechatwidget",   "timeshown" ) ) {
           mTimeShown = (  double )configSrv->getValue(  "ingamechatwidget",   "timeshown" );
           }
          
           if (  configSrv->itemExists(  "ingamechatwidget",   "distanceshown" ) ) {
           mDistanceShown = (  double )configSrv->getValue(  "ingamechatwidget",   "distanceshown" );
           }
          
           mLabelSheet = mWindowManager->createWindow(  "DefaultGUISheet",   "IngameChatWidget/LabelSheet" );
           mLabelSheet->setMousePassThroughEnabled(  true );
           mLabelSheet->setRiseOnClickEnabled(  false );
           getMainSheet(   )->addChildWindow(  mLabelSheet );
           //mMainWindow = WindowManager::getSingleton(   ).loadWindowLayout(  (  utf8* )"widgets/ChatWidget.xml",   "Chat/" );
          // mMainWindow->setAlwaysOnTop(  true );avatarEntityId
          /* mMainWindow = mWindowManager->createWindow(  (  utf8* )"DefaultGUISheet",   (  utf8* )"IngameChatWidget/MainWindow" );
           mMainWindow->setPosition(  Point(  0.0f,   0.0f ) );
           mMainWindow->setSize(  Size(  1.0f,   1.0f ) );
           mMainWindow->setVisible(  true );
           mMainWindow->setEnabled(  true );
          
          // mChatTextBox = static_cast<MultiLineEditbox*>(  WindowManager::getSingleton(   ).getWindow(  (  utf8* )"Chat/TextBox" ) );
           getMainSheet(   )->addChildWindow(  mMainWindow ); */
          
           //mGuiManager->AppendIGChatLine.connect(  sigc::mem_fun(  *this,   &IngameChatWidget::appendIGChatLine ) );
          
           mLabelPool.initializePool(  15 );
           mChatTextPool.initializePool(  5 );
           Ember::EmberServices::getSingleton(   ).getServerService(   )->GotView.connect(  sigc::mem_fun(  *this,   &IngameChatWidget::ServerService_GotView ) );
          
          // Ogre::Root::getSingleton(   ).addFrameListener(  this );
          
          }
          
     111  Window* IngameChatWidget::getLabelSheet(   )
          {
           return mLabelSheet;
          }
          
     116  void IngameChatWidget::ServerService_GotView(  Eris::View* view )
          {
           Eris::TypeService* typeService = Ember::EmberServices::getSingleton(   ).getServerService(   )->getConnection(   )->getTypeService(   ); mLabelTypes.push_back(  typeService->getTypeByName(  "character" ) );
          
           view->EntitySeen.connect(  sigc::mem_fun(  *this,   &IngameChatWidget::View_EntitySeen ) );
           mAvatarEntityId = view->getAvatar(   )->getId(   );
          }
          
          
          
     126  void IngameChatWidget::View_EntitySeen(  Eris::Entity* entity )
          {
           EmberPhysicalEntity* physEntity = dynamic_cast<EmberPhysicalEntity*>(  entity );
           if (  physEntity ) {
           for (  TypeInfoStore::iterator I = mLabelTypes.begin(   ); I != mLabelTypes.end(   ); ++I ) {
           if (  entity->getType(   )->isA(  *I ) ) {
           if (  mAvatarEntityId != entity->getId(   ) ) {
           EntityObserver* observer = new EntityObserver(  *this,   physEntity );
           mEntityObservers.push_back(  observer );
           }
           break;
           }
           }
           }
          }
          
     142  void IngameChatWidget::removeEntityObserver(  EntityObserver* observer )
          {
           EntityObserverStore::iterator I = std::find(  mEntityObservers.begin(   ),   mEntityObservers.end(   ),   observer );
           if (  I != mEntityObservers.end(   ) ) {
           mEntityObservers.erase(  I );
           }
           delete observer;
          }
          
     151  WidgetPool<IngameChatWidget::Label>& IngameChatWidget::getLabelPool(   )
          {
           return mLabelPool;
          }
     155  WidgetPool<IngameChatWidget::ChatText>& IngameChatWidget::getChatTextPool(   )
          {
           return mChatTextPool;
          }
          
          
     161  void IngameChatWidget::appendIGChatLine(  const std::string& line,   EmberEntity* entity )
          {
          // //don't show anything if it's the avatar
          // AvatarEmberEntity* avatarEntity = getSingleton(   ).getAvatar(   )->getAvatarEmberEntity(   );
          // if (  avatarEntity == entity ) {
          // return;
          // }
          //
          //
          // Window* chatWindow;
          // LabelMap::iterator I = mLabels.find(  entity->getId(   ) );
          // if (  I == mLabels.end(   ) ) {
          // Ogre::Vector3 entityWorldCoords = entity->getWorldBoundingBox(  true ).getCenter(   );
          // Ogre::Vector3 cameraCoords = getSingletonPtr(   )->getMainCamera(   )->getCamera(   )->getDerivedPosition(   );
          // Ogre::Vector3 diff = entityWorldCoords - cameraCoords;
          //
          // if (  diff.length(   ) <= distanceShown ) {
          //
          // //there is no chat window for this entity,   let's create one
          // chatWindow = WindowManager::getSingleton(   ).loadWindowLayout(  mGuiManager->getLayoutDir(   )+"IngameChatWidget.xml",   std::string(  "IngameChatWidget/" ) + entity->getId(   ) + "/" );
          // getMainSheet(   )->addChildWindow(  chatWindow );
          //
          // Label* activeWindow = new Label(  chatWindow,   entity,   mWindowManager,   *this );
          //
          // mLabels[entity->getId(   )] = activeWindow;
          //
          // mLabels[entity->getId(   )]->updateText(  line );
          // }
          // } else {
          // I->second->updateText(  line );
          // }
          
          }
          
          // void IngameChatWidget::initializePool(   )
          // {
          // for (  int i = 0; i < 15; ++i ) {
          // Label* label = createLabel(   );
          // mLabelPool.push_back(  label );
          // mUnusedLabels.push(  label );
          // }
          // }
          
          // IngameChatWidget::Label* IngameChatWidget::createLabel(   )
          // {
          // Window* chatWindow;
          // //there is no chat window for this entity,   let's create one
          // std::stringstream ss;
          // ss << "Label/" << mLabelPool.size(   ) << "/";
          // chatWindow = WindowManager::getSingleton(   ).loadWindowLayout(  mGuiManager->getLayoutDir(   )+"Label.layout",   ss.str(   ) );
          //
          // Label* label = new Label(  chatWindow,   mWindowManager,   *this,   ss.str(   ) );
          // return label;
          // }
          
          // IngameChatWidget::Label* IngameChatWidget::getLabel(   )
          // {
          // Label* label(  0 );
          // if (  !mUnusedLabels.size(   ) ) {
          // label = createLabel(   );
          // mLabelPool.push_back(  label );
          // } else {
          // label = mUnusedLabels.top(   );
          // mUnusedLabels.pop(   );
          // }
          // mUsedLabels.push_back(  label );
          // return label;
          // }
          //
          // void IngameChatWidget::returnLabel(  Label* label )
          // {
          // mUnusedLabels.push(  label );
          // LabelStore::iterator I = std::find(  mUsedLabels.begin(   ),   mUsedLabels.end(   ),   label );
          // if (  I != mUsedLabels.end(   ) ) {
          // mUsedLabels.erase(  I );
          // }
          // }
          
          
          
          
          
          
          
     245  void IngameChatWidget::frameStarted(   const Ogre::FrameEvent & event  )
          {
           for (  WidgetPool<Label>::WidgetStore::iterator I = mLabelPool.getUsedWidgets(   ).begin(   ); I != mLabelPool.getUsedWidgets(   ).end(   ); ++I ) {
           (  *I )->frameStarted(  event );
           }
          /* Ogre::Camera* camera = getSingletonPtr(   )->getMainCamera(   )->getCamera(   );
           LabelMap::iterator I = mLabels.begin(   );
           LabelMap::iterator I_end = mLabels.end(   );
           std::vector<std::string> windowsToRemove;
          
           for (  ;I != I_end; ++I ) {
           Label* window = I->second;
           window->frameStarted(  event  );
          
          
           Ogre::Vector3 entityWorldCoords = window->getEntity(   )->getWorldBoundingBox(  true ).getCenter(   );
          
           //Ogre::Vector3 entityWorldCoords = window->getEntity(   )->getSceneNode(   )->_getWorldAABB(   ).getCenter(   );
           Ogre::Vector3 cameraCoords = camera->getDerivedPosition(   );
           Ogre::Vector3 diff = entityWorldCoords - cameraCoords;
          
           ///remove the window if it's either too far away or not shown in the camera
           if (  diff.length(   ) > distanceShown || !camera->isVisible(  entityWorldCoords ) ) {
           windowsToRemove.push_back(  I->first );
           } else {
          
           //unless timeShown is 0 windows will fade over time
           if (  timeShown != 0 ) {
           //make the windows fade over time
           window->getWindow(   )->setAlpha(  1 - (  window->getElapsedTimeSinceLastUpdate(   ) / timeShown ) );
           if (  window->getElapsedTimeSinceLastUpdate(   ) >= timeShown ) {
           windowsToRemove.push_back(  I->first );
           }
           }
           }
           }
          
           std::vector<std::string>::iterator J = windowsToRemove.begin(   );
           std::vector<std::string>::iterator J_end = windowsToRemove.end(   );
           for (  ;J != J_end; ++J ) {
          // mWindowManager->destroyWindow(  mLabels[*J].window );
           removeWidget(  *J );
           } */
          
          }
          
     291  void IngameChatWidget::removeWidget(  const std::string& windowName )
          {
          /* delete mLabels[windowName];
           mLabels.erase(  windowName );*/
          }
          
          // void IngameChatWidget::removeWidget(  Label* window )
          // {
          // delete mLabels[window];
          // mLabels.erase(  window );
          // }
          
          
          
          
          
     307  IngameChatWidget::MovableObjectListener::MovableObjectListener(  EntityObserver& entityObserver,   EmberPhysicalEntity* entity )
          : mEntityObserver(  entityObserver ),   mEntity(  entity ),   mIsObserving(  false )
          {
          }
          
     312  IngameChatWidget::MovableObjectListener::~MovableObjectListener(   )
          {
           setObserving(  false );
          }
          
     317  void IngameChatWidget::MovableObjectListener::setObserving(  bool isObserving )
          {
           if (  isObserving ) {
           ///TODO: make sure that this doesn't interfere with other listeners
           mEntity->getModel(   )->setListener(  this );
           } else {
           mEntity->getModel(   )->setListener(  0 );
           }
          }
          
          
     328  bool IngameChatWidget::MovableObjectListener::objectRendering (  const Ogre::MovableObject * movableObject,   const Ogre::Camera * camera )
          {
           mEntityObserver.updateLabel(  camera );
           return true;
          }
          
          
          
     336  IngameChatWidget::EntityObserver::EntityObserver(  IngameChatWidget& chatWidget,   EmberPhysicalEntity* entity )
          : mChatWidget(  chatWidget ),   mEntity(  entity ),   mLabel(  0 ),   mMovableObjectListener(  *this,   entity )
          {
           entity->VisibilityChanged.connect(  sigc::mem_fun(  *this,   &EntityObserver::entity_VisibilityChanged ) );
           entity->BeingDeleted.connect(  sigc::mem_fun(  *this,   &EntityObserver::entity_BeingDeleted ) );
           entity->Say.connect(  sigc::mem_fun(  *this,   &EntityObserver::entity_Say ) );
          
           mExternalSlot = sigc::mem_fun(  *this,   &IngameChatWidget::EntityObserver::entity_attributeChanged );
           entity->observe(  "external",   mExternalSlot );
           entity->observe(  "name",   mExternalSlot );
          }
          
          IngameChatWidget::EntityObserver::~EntityObserver(   )
          {
           hideLabel(   );
          }
          
          void IngameChatWidget::EntityObserver::entity_VisibilityChanged(  bool visible )
          {
           if (  visible ) {
           showLabel(   );
           } else {
           hideLabel(   );
           }
          }
          
          void IngameChatWidget::EntityObserver::entity_BeingDeleted(   )
          {
           mChatWidget.removeEntityObserver(  this );
          }
          
          void IngameChatWidget::EntityObserver::entity_Say(  const Atlas::Objects::Root& talk )
          {
           if (  mLabel ) {
          
           if (  !talk->hasAttr(  "say" ) ) {
           return;
           }
           const std::string& msg = talk->getAttr(  "say" ).asString(   );
          
           mLabel->updateText(  msg );
           }
          
          }
          
          void IngameChatWidget::EntityObserver::entity_attributeChanged(  const Atlas::Message::Element& attributeValue )
          {
           if (  mLabel ) {
           mLabel->updateEntityName(   );
           }
          }
          
          
          
          void IngameChatWidget::EntityObserver::updateLabel(  const Ogre::Camera * camera )
          {
           ///only update when being rendered by the main camera
           if (  camera == mChatWidget.mMainCamera ) {
           // const Ogre::Vector3& entityWorldCoords = mEntity->getDerivedPosition(   );
           // Ogre::Vector3 entityWorldCoords = mEntity->getWorldBoundingBox(  true ).getCenter(   );
           // Ogre::Vector3 entityWorldCoords = window->getEntity(   )->getSceneNode(   )->_getWorldAABB(   ).getCenter(   );
           // const Ogre::Vector3& cameraCoords = camera->getDerivedPosition(   );
           ///getWorldPosition is faster than getting the center of the boundingbox...
           Ogre::Vector3 diff = mEntity->getSceneNode(   )->getWorldPosition(   ) - camera->getWorldPosition(   );
          
           ///remove the window if it's either too far away
           if (  diff.length(   ) > mChatWidget.mDistanceShown ) {
           // mLabel->setActive(  false );
           } else {
           mLabel->markForRender(   );
           mLabel->placeWindowOnEntity(   );
           /* mLabel->setActive(  true );
           mLabel->placeWindowOnEntity(   );*/
           }
           }
          
          }
          
          void IngameChatWidget::EntityObserver::showLabel(   )
          {
           if (  !mLabel ) {
           mLabel = mChatWidget.getLabelPool(   ).checkoutWidget(   );
           mLabel->setEntity(  mEntity );
           }
           mMovableObjectListener.setObserving(  true );
          }
          void IngameChatWidget::EntityObserver::hideLabel(   )
          {
           if (  mLabel ) {
           mLabel->setActive(  false );
           mChatWidget.getLabelPool(   ).returnWidget(  mLabel );
           mLabel = 0;
           }
           mMovableObjectListener.setObserving(  false );
          }
          
          
          
          
          
          
          
          
          IngameChatWidget::Label::Label(   Window * window,   WindowManager * windowManager,   IngameChatWidget& containerWidget,   const std::string& prefix )
           : mWindow(  window ),  
           mEntity(  0 ),  
           mWindowManager(  windowManager ),  
           mContainerWidget(  containerWidget ),  
           mActive(  false ),  
           mPrefix(  prefix ),  
           mRenderNextFrame(  false ),  
           mChatText(  0 )
          {
          // mNameWidget = mWindow->getChild(  mPrefix + "EntityName" );
          }
          
          IngameChatWidget::Label::~Label(   )
          {
           mWindowManager->destroyWindow(  mWindow );
          }
          
          void IngameChatWidget::Label::markForRender(   )
          {
           mRenderNextFrame = true;
           setActive(  true );
          }
          
          void IngameChatWidget::Label::placeWindowOnEntity(   )
          {
           //make sure that the window stays on the entity
           Ogre::Vector3 screenCoords;
          
           bool result = false;
           Ogre::Vector3 entityWorldCoords = getEntity(   )->getWorldBoundingSphere(  true ).getCenter(   );
           entityWorldCoords.y = getEntity(   )->getWorldBoundingBox(  true ).getMaximum(   ).y;
           //check what the new position is in screen coords
           result = EmberOgre::getSingletonPtr(   )->getMainCamera(   )->worldToScreen(  entityWorldCoords,   screenCoords );
          
           if (  result ) {
           mWindow->setVisible(  true );
           mWindow->setPosition(  UVector2(  UDim(  screenCoords.x,   -(  mWindow->getWidth(   ).asAbsolute(  0 ) * 0.5 ) ),   UDim(  screenCoords.y,   -(  mWindow->getHeight(   ).asAbsolute(  0 ) * 0.5 ) ) ) );
           } else {
           mWindow->setVisible(  false );
           }
          }
          
          void IngameChatWidget::Label::frameStarted(   const Ogre::FrameEvent & event  )
          {
           if (  mRenderNextFrame ) {
           mRenderNextFrame = false;
           if (  mChatText ) {
           bool keep = mChatText->frameStarted(  event );
           if (  !keep ) {
           mChatText->attachToLabel(  0 );
           mContainerWidget.getChatTextPool(   ).returnWidget(  mChatText );
           mChatText = 0;
           }
           }
          // placeWindowOnEntity(   );
          
          // increaseElapsedTime(  event.timeSinceLastFrame );
           } else {
           setActive(  false );
           }
          }
          
          void IngameChatWidget::Label::setEntity(  EmberEntity* entity )
          {
           mEntity = entity;
           try {
           updateEntityName(   );
           } catch (  const Exception& ex ) {
           S_LOG_FAILURE(  "Could not get widget EntityName. Exception: " << ex.getMessage(   ).c_str(   ) );
           }
          }
          
          void IngameChatWidget::Label::updateEntityName(   )
          {
           std::string entityName(  mEntity->getName(   ) );
          // Window* nameWidget = static_cast<Window*>(  mWindow->getChild(  mPrefix + "EntityName" ) );
           ///if the entity is controlled by a player,   mark that
           if (  mEntity->hasAttr(  "external" ) ) {
           const Atlas::Message::Element& externalAttr = mEntity->valueOfAttr(  "external" );
           if (  externalAttr.isNum(   ) && externalAttr.asNum(   ) == 1 ) {
           entityName = "!" + mEntity->getName(   ) + "!";
           }
           }
           mWindow->setText(  entityName );
          }
          
          
          EmberEntity * IngameChatWidget::Label::getEntity(    )
          {
           return mEntity;
          }
          
          void IngameChatWidget::Label::setActive(  bool active )
          {
           if (  active ) {
           if (  !mActive ) {
           mContainerWidget.getLabelSheet(   )->addChildWindow(  mWindow );
           mActive = active;
           }
           } else {
           if (  mActive ) {
           mContainerWidget.getLabelSheet(   )->removeChildWindow(  mWindow );
           mActive = active;
           }
           }
          }
          
          Window * IngameChatWidget::Label::getWindow(    )
          {
           return mWindow;
          }
          
          bool IngameChatWidget::Label::buttonResponse_Click(  const EventArgs& args )
          {
           const MouseEventArgs *mouseArgs = static_cast<const MouseEventArgs*>(  &args );
           if (  mouseArgs ) {
           ///each button contains a static text window,   which is the one containg the actual text
           const String text = mouseArgs->window->getChild(  0 )->getText(   );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->say(  std::string(  text.c_str(   ) ) );
           }
          // removeMenu(   );
           return true;
          }
          
          void IngameChatWidget::Label::updateText(   const std::string & line  )
          {
           if (  !mChatText ) {
           mChatText = mContainerWidget.getChatTextPool(   ).checkoutWidget(   );
           mChatText->attachToLabel(  this );
           }
           mChatText->updateText(  line );
           //mWindow->moveToFront(   );
          
          }
          
          IngameChatWidget::LabelCreator::LabelCreator(  IngameChatWidget& ingameChatWidget )
          : mIngameChatWidget(  ingameChatWidget )
          {
          }
          
          IngameChatWidget::Label* IngameChatWidget::LabelCreator::createWidget(  unsigned int currentPoolSize )
          {
           ///there is no chat window for this entity,   let's create one
           std::stringstream ss;
           ss << "Label/" << currentPoolSize << "/";
           Window* window = WindowManager::getSingleton(   ).loadWindowLayout(  GUIManager::getSingleton(   ).getLayoutDir(   )+"Label.layout",   ss.str(   ) );
          
           Label* label = new Label(  window,   CEGUI::WindowManager::getSingletonPtr(   ),   mIngameChatWidget,   ss.str(   ) );
           return label;
          }
          
          
          IngameChatWidget::ChatText::ChatText(  CEGUI::Window* window,   const std::string& prefix )
          : mLabel(  0 ),   mWindow(  window ),   mTextWidget(  0 ),   mResponseWidget(  0 ),   mElapsedTimeSinceLastUpdate(  0.0f ),   mPrefix(  prefix )
          {
           mTextWidget = WindowManager::getSingleton(   ).getWindow(  prefix + "Text" );
           mResponseWidget = WindowManager::getSingleton(   ).getWindow(  prefix + "ResponseList" );
          }
          
          bool IngameChatWidget::ChatText::frameStarted(   const Ogre::FrameEvent & event  )
          {
           increaseElapsedTime(  event.timeSinceLastFrame );
           //unless timeShown is 0 windows will fade over time
           float timeShown = mLabel->getIngameChatWidget(   ).getTimeShown(   );
           if (  timeShown != 0 ) {
           //make the windows fade over time
           mWindow->setAlpha(  1 - (  getElapsedTimeSinceLastUpdate(   ) / timeShown ) );
           if (  getElapsedTimeSinceLastUpdate(   ) >= timeShown ) {
           return false;
           //windowsToRemove.push_back(  I->first );
           }
           }
           return true;
          
          }
          
          void IngameChatWidget::ChatText::increaseElapsedTime(   float timeSlice  )
          {
           mElapsedTimeSinceLastUpdate += timeSlice;
          }
          
          void IngameChatWidget::ChatText::updateText(  const std::string & line )
          {
          // GUISheet* textWidget = static_cast<GUISheet*>(  mWindow->getChild(  mPrefix + "Text" ) );
           mTextWidget->setText(  line );
           mElapsedTimeSinceLastUpdate = 0;
          
           if (  mLabel->getEntity(   )->hasSuggestedResponses(   ) )
           {
          // Window* responseWidget = static_cast<Window*>(  mWindow->getChild(  mPrefix + "ResponseList" ) );
          
          
           //remove all existing response windows
           std::vector<Window*>::const_iterator responses_I = mResponseTextWidgets.begin(   );
           std::vector<Window*>::const_iterator responses_I_end = mResponseTextWidgets.end(   );
           for (  ; responses_I != responses_I_end; ++responses_I )
           {
           WindowManager::getSingleton(   ).destroyWindow(  *responses_I );
           }
           mResponseTextWidgets.clear(   );
          
          
           //for each response,   create a button
           const std::vector<std::string>& responses = mLabel->getEntity(   )->getSuggestedResponses(   );
           std::vector<std::string>::const_iterator I = responses.begin(   );
           std::vector<std::string>::const_iterator I_end = responses.end(   );
           int i = 0;
           std::stringstream ss;
          
           float heightSize = 1.0f;
           if (  responses.size(   ) > 0 ) {
           heightSize = 1.0f / responses.size(   );
           }
          
           for (  ;I != I_end; ++I )
           {
           std::stringstream ss_;
           ss_ << i;
           PushButton* responseTextButton = static_cast<PushButton*>(  WindowManager::getSingleton(   ).createWindow(  GUIManager::getSingleton(   ).getDefaultScheme(   ) + "/Button",   mPrefix + "Response/" + ss_.str(   ) ) );
           GUISheet* responseText = static_cast<GUISheet*>(  WindowManager::getSingleton(   ).createWindow(  GUIManager::getSingleton(   ).getDefaultScheme(   ) + "/StaticText",   mPrefix + "ResponseText/" + ss_.str(   ) ) );
          
          
          
           BIND_CEGUI_EVENT(  responseTextButton,   ButtonBase::EventMouseClick,  IngameChatWidget::ChatText::buttonResponse_Click  );
           responseText->setText(  *I );
           responseText->setSize(  UVector2(  UDim(  0.8f,   0 ),   UDim(  0.9f,   0 ) ) );
           responseText->setPosition(  UVector2(  UDim(  0.1f,   0 ),   UDim(  0.05f,   0 ) ) );
           responseText->setProperty(  "HorzFormatting",   "WordWrapLeftAligned" );
           responseText->setProperty(  "FrameEnabled",   "false" );
           responseText->setProperty(  "BackgroundEnabled",   "false" );
           responseText->setProperty(  "Font",   "Vera-Sans-Bold-8" );
           responseText->setProperty(  "TextColours",   "tl:FFFFFFFF tr:FFFFFFFF bl:FFffc990 br:FFffc990" );
          
          
           responseText->setInheritsAlpha(  true );
           ///we need to disable and deactivate it so it won't recieve any input (  input should go to the button instead )
           responseText->deactivate(   );
           responseText->disable(   );
          
          
           responseTextButton->setSize(  UVector2(  UDim(  1.0f,   0 ),   UDim(  heightSize,   0.0f ) ) );
           responseTextButton->setPosition(  UVector2(  UDim(  0.0f,   0 ),  UDim(  i * heightSize,   0.0f ) ) );
           responseTextButton->setInheritsAlpha(  true );
           ///hide the button
           //responseTextButton->setAlpha(  0.0f );
           responseTextButton->addChildWindow(  responseText );
           responseTextButton->setTooltipText(  *I );
           mResponseWidget->addChildWindow(  responseTextButton );
           mResponseTextWidgets.push_back(  responseTextButton );
          
           ++i;
          
          // ss << *I << "\n";
           }
           //responseWidget->setText(  ss.str(   ) );
          
           }
          
          
          }
          
          bool IngameChatWidget::ChatText::buttonResponse_Click(  const CEGUI::EventArgs& args )
          {
           const MouseEventArgs *mouseArgs = static_cast<const MouseEventArgs*>(  &args );
           if (  mouseArgs ) {
           ///each button contains a static text window,   which is the one containg the actual text
           const String text = mouseArgs->window->getChild(  0 )->getText(   );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->say(  std::string(  text.c_str(   ) ) );
           }
           return true;
          }
          
          void IngameChatWidget::ChatText::attachToLabel(  Label* label )
          {
           mLabel = label;
           if (  label ) {
           mLabel->getWindow(   )->addChildWindow(  mWindow );
           } else {
           if (  mWindow->getParent(   ) ) {
           mWindow->getParent(   )->removeChildWindow(  mWindow );
           }
           }
          }
          
          IngameChatWidget::ChatText* IngameChatWidget::ChatTextCreator::createWidget(  unsigned int currentPoolSize )
          {
           ///there is no chat window for this entity,   let's create one
           std::stringstream ss;
           ss << "ChatText/" << currentPoolSize << "/";
           Window* window = WindowManager::getSingleton(   ).loadWindowLayout(  GUIManager::getSingleton(   ).getLayoutDir(   )+"IngameChatWidget.layout",   ss.str(   ) );
          
           ChatText* widget = new ChatText(  window,   ss.str(   ) );
           return widget;
          }
          
          };
          };

./components/ogre/widgets/IngameChatWidget.h

       1  //
          // C++ Interface: IntegratedChatWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREINTEGRATEDCHATWIDGET_H
          #define EMBEROGREINTEGRATEDCHATWIDGET_H
          
          #include "WidgetPool.h"
          #include <Eris/Entity.h>
          
          namespace EmberOgre {
          
      31  class GUIManager;
      32  class Widget;
      33  class EmberPhysicalEntity;
      34  class EmberEntity;
          
          namespace Gui {
          
          
          
          /**
          
          Shows chat bubbles over npc's heads when they say something.
          The bubbles will disappear after a while (  actually fade out ) or when the player moves away. This can be set in the config file.
          
          If the npc has a list of suggested responses these will be shown in a list of clickable buttons to the right.
          
          @author Erik Hjortsberg
          */
      49  class IngameChatWidget : public Widget {
          
          
          
          
      54   class EntityObserver;
      55   class Label;
      56   class MovableObjectListener : public Ogre::MovableObject::Listener
           {
           public:
      59   MovableObjectListener(  EntityObserver& entityObserver,   EmberPhysicalEntity* entity );
      60   virtual ~MovableObjectListener(   );
          
      62   virtual bool objectRendering (  const Ogre::MovableObject * movableObject,   const Ogre::Camera * camera );
      63   void setObserving(  bool isObserving );
          
           private:
      66   EntityObserver& mEntityObserver;
      67   EmberPhysicalEntity* mEntity;
      68   bool mIsObserving;
           };
          
      71   class EntityObserver : public virtual sigc::trackable
           {
           public:
      74   EntityObserver(  IngameChatWidget& chatWidget,   EmberPhysicalEntity* entity );
      75   virtual ~EntityObserver(   );
      76   void updateLabel(  const Ogre::Camera * camera );
          
           protected:
      79   IngameChatWidget& mChatWidget;
      80   EmberPhysicalEntity* mEntity;
      81   Label* mLabel;
      82   MovableObjectListener mMovableObjectListener;
      83   Eris::Entity::AttrChangedSlot mExternalSlot; //,   mNameSlot;
          
      85   void showLabel(   );
      86   void hideLabel(   );
          
      88   void entity_VisibilityChanged(  bool visible );
      89   void entity_BeingDeleted(   );
      90   void entity_Say(  const Atlas::Objects::Root& talk );
      91   void entity_attributeChanged(  const Atlas::Message::Element& attributeValue );
          
          
           };
          
      96   class ChatText;
           /**
           Holds the actual chat window and keeps track of fading,   catching clicks etc.
           */
     100   class Label : public sigc::trackable
           {
           public:
           /**
          
           */
     106   Label(  CEGUI::Window* window,   CEGUI::WindowManager* windowManager,   IngameChatWidget& containerWidget,   const std::string& prefix );
          
     108   virtual ~Label(   );
          
           /**
          
           */
     113   void updateText(  const std::string& line );
          
          
           /**
           gets the entity the window belongs to
           */
     119   EmberEntity* getEntity(   );
          
     121   void setEntity(  EmberEntity* entity );
          
     123   void setActive(  bool active );
     124   bool getActive(   ) const;
     125   void markForRender(   );
          
     127   CEGUI::Window* getWindow(   );
           /**
           call this each frame to update the window
           */
     131   void frameStarted(   const Ogre::FrameEvent & event  );
          
           /**
           positions the window on top of the entity
           */
     136   void placeWindowOnEntity(   );
          
     138   IngameChatWidget& getIngameChatWidget(   ) { return mContainerWidget;}
          
     140   void updateEntityName(   );
          
           protected:
          
     144   CEGUI::Window* mWindow;
     145   EmberEntity* mEntity;
     146   std::vector<CEGUI::Window*> mResponseTextWidgets;
     147   CEGUI::WindowManager* mWindowManager;
     148   IngameChatWidget& mContainerWidget;
          
     150   bool buttonResponse_Click(  const CEGUI::EventArgs& args );
          
     152   bool mActive;
     153   const std::string mPrefix;
     154   bool mRenderNextFrame;
     155   ChatText* mChatText;
          // CEGUI::Window* mNameWidget;
          
           };
          
     160   class LabelCreator : public WidgetPool<IngameChatWidget::Label>::WidgetCreator
           {
           public:
     163   LabelCreator(  IngameChatWidget& ingameChatWidget );
     164   virtual ~LabelCreator(   ) {}
     165   virtual IngameChatWidget::Label* createWidget(  unsigned int currentPoolSize );
           protected:
     167   IngameChatWidget& mIngameChatWidget;
           };
          
     170   class ChatText : public sigc::trackable
           {
           public:
     173   ChatText(  CEGUI::Window* window,   const std::string& prefix );
     174   virtual ~ChatText(   ) {}
          
     176   void updateText(   const std::string & line );
          
           /**
           call this each frame to update the window
           */
     181   bool frameStarted(   const Ogre::FrameEvent & event  );
          
     183   inline float getElapsedTimeSinceLastUpdate(   ) { return mElapsedTimeSinceLastUpdate;}
          
           /**
           increases the elapsed time with the supplied amount
           */
     188   void increaseElapsedTime(  float timeSlice );
          
     190   void attachToLabel(  Label* label );
          
           protected:
     193   std::vector<CEGUI::Window*> mResponseTextWidgets;
     194   Label* mLabel;
     195   CEGUI::Window* mWindow;
     196   CEGUI::Window* mTextWidget;
     197   CEGUI::Window* mResponseWidget;
           float mElapsedTimeSinceLastUpdate;
     199   std::string mPrefix;
          
     201   bool buttonResponse_Click(  const CEGUI::EventArgs& args );
           };
          
     204   class ChatTextCreator : public WidgetPool<IngameChatWidget::ChatText>::WidgetCreator
           {
           public:
     207   ChatTextCreator(  IngameChatWidget& ingameChatWidget ) : mIngameChatWidget(  ingameChatWidget ) {}
     208   virtual ~ChatTextCreator(   ) {}
     209   virtual IngameChatWidget::ChatText* createWidget(  unsigned int currentPoolSize );
           protected:
     211   IngameChatWidget& mIngameChatWidget;
           };
          
          typedef std::map<std::string,   Label*> LabelMap;
          typedef std::vector<Label*> LabelStore;
          typedef std::stack<Label*> LabelStack;
          typedef std::vector<EntityObserver*> EntityObserverStore;
          typedef std::vector<Eris::TypeInfo*> TypeInfoStore;
     219  friend class IngameChatWidget::EntityObserver;
          public:
     221   IngameChatWidget(   );
     222   virtual ~IngameChatWidget(   );
     223   void buildWidget(   );
     224   virtual void frameStarted(  const Ogre::FrameEvent & event );
          
     226   void removeWidget(  const std::string& windowName );
          
          // Label* getLabel(   );
          // void returnLabel(  Label* label );
          
     231   void removeEntityObserver(  EntityObserver* observer );
          
     233   WidgetPool<Label>& getLabelPool(   );
     234   WidgetPool<ChatText>& getChatTextPool(   );
          
     236   float getTimeShown(   ) {return mTimeShown;}
          
     238   CEGUI::Window* getLabelSheet(   );
          
          protected:
     241   void appendIGChatLine(  const std::string& line,   EmberEntity* entity );
           //void placeWindowOnEntity(   CEGUI::Window* window,   EmberPhysicalEntity* entity );
          
          // void initializePool(   );
          
          // Label* createLabel(   );
          
     248   void View_EntitySeen(  Eris::Entity* entity );
     249   void ServerService_GotView(  Eris::View* view );
          
          
          // LabelStore mUsedLabels;
          //
          // LabelStore mLabelPool;
          // LabelStack mUnusedLabels;
          
     257   EntityObserverStore mEntityObservers;
          
     259   TypeInfoStore mLabelTypes;
          
           //the length in seconds a window should be shown after it has been activated
           float mTimeShown;
          
           //how far away,   in meters,   the window should be visible
           float mDistanceShown;
          
     267   LabelCreator mLabelCreator;
     268   WidgetPool<Label> mLabelPool;
          
     270   ChatTextCreator mChatTextCreator;
     271   WidgetPool<ChatText> mChatTextPool;
          
     273   CEGUI::Window* mLabelSheet;
          
     275   std::string mAvatarEntityId;
          
     277   Ogre::Camera* mMainCamera;
          
          };
          };
          };
          
          #endif

./components/ogre/widgets/IngameEventsWidget.cpp

       1  #include "Widget.h"
          #include "IngameEventsWidget.h"
          namespace EmberOgre {
          
       5  IngameEventsWidget::~IngameEventsWidget(   )
          {}
          
          }

./components/ogre/widgets/IngameEventsWidget.h

       1  #ifndef INGAMEEVENTSWIDGET_H
          #define INGAMEEVENTSWIDGET_H
          
          namespace EmberOgre {
          
       6  class IngameEventsWidget
       7  : public Widget
          {
          public:
          
      11   virtual ~IngameEventsWidget(   );
          };
          
          }
          
          #endif // INGAMEEVENTSWIDGET_H

./components/ogre/widgets/InspectWidget.cpp

          //
          // C++ Implementation: InspectWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Widget.h"
          #include "ColouredListItem.h"
          #include "../GUIManager.h"
          #include "../EmberEntity.h"
          
          
          #include "InspectWidget.h"
          #include "../EmberOgre.h"
          
          #include <CEGUIWindowManager.h>
          #include <elements/CEGUIListbox.h>
          #include <elements/CEGUIListboxTextItem.h>
          #include <elements/CEGUIGUISheet.h>
          
          #include <Eris/TypeInfo.h>
          #include <Eris/View.h>
          #include <elements/CEGUIPushButton.h>
          #include <Atlas/Codecs/Bach.h>
          #include <Atlas/Message/DecoderBase.h>
          #include <Atlas/Objects/Encoder.h>
          #include "services/EmberServices.h"
          #include "services/server/ServerService.h"
          #include "framework/Tokeniser.h"
          #include "framework/ConsoleBackend.h"
          
          namespace EmberOgre {
          namespace Gui {
          
          
      52  class Decoder : public Atlas::Message::DecoderBase {
           private:
      54   virtual void messageArrived(  const Atlas::Message::MapType& obj ) {
           m_check = true;
           m_obj = obj;
           }
      58   bool m_check;
      59   Atlas::Message::MapType m_obj;
           public:
      61   Decoder(   ) : m_check (  false ) { }
      62   bool check(   ) const { return m_check; }
      63   const Atlas::Message::MapType & get(   ) {
           m_check = false; return m_obj;
           }
          };
          
          
          
          
      71  InspectWidget::InspectWidget(   ) :
          Inspect(  "inspect",   this,   "Inspect an entity." ),  
      73  mCurrentEntity(  0 )
          {
          
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->GotView.connect(  sigc::mem_fun(  *this,   &InspectWidget::Server_GotView ) );
          }
      78  InspectWidget::~InspectWidget(   )
          {
          }
          
      82  void InspectWidget::Server_GotView(  Eris::View* view )
          {
          // view->EntityDeleted.connect(  sigc::mem_fun(  *this,   &InspectWidget::View_EntityDeleted ) );
          }
          
      87  void InspectWidget::entity_BeingDeleted(   )
          {
           disconnectFromEntity(   );
           mCurrentEntity = 0;
          }
          
      93  void InspectWidget::buildWidget(   )
          {
          
          
           loadMainSheet(  "InspectWidget.layout",   "InspectWidget/" );
           mMainWindow->setVisible(  false );
          // mMainWindow->setAlwaysOnTop(  true );
          
           mChildList = static_cast<CEGUI::Listbox*>(  getWindow(  "ChildList" ) );
           mInfo = static_cast<CEGUI::GUISheet*>(  getWindow(  "EntityInfo" ) );
          
          
           mGuiManager->EventEntityAction.connect(  sigc::mem_fun(  *this,   &InspectWidget::handleAction ) );
           enableCloseButton(   );
          
           if (  CEGUI::PushButton* button = static_cast<CEGUI::PushButton*>(  getWindow(  "ShowOgreBoundingBox" ) ) ) {
           BIND_CEGUI_EVENT(  button,   CEGUI::ButtonBase::EventMouseClick,   InspectWidget::ShowOgreBoundingBox_Click );
           }
          
           if (  CEGUI::PushButton* button = static_cast<CEGUI::PushButton*>(  getWindow(  "ShowErisBoundingBox" ) ) ) {
           BIND_CEGUI_EVENT(  button,   CEGUI::ButtonBase::EventMouseClick,   InspectWidget::ShowErisBoundingBox_Click );
           }
          
           if (  CEGUI::PushButton* button = static_cast<CEGUI::PushButton*>(  getWindow(  "ShowCollision" ) ) ) {
           BIND_CEGUI_EVENT(  button,   CEGUI::ButtonBase::EventMouseClick,   InspectWidget::ShowCollision_Click );
           }
          
          }
          
     122  void InspectWidget::updateAttributeString(   )
          {
           AttributeTextBuilder builder;
           mAttributesString = builder.parseAttributes(  mCurrentEntity->getAttributes(   ) );
          
          }
          
     129  void InspectWidget::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  Inspect == command )
           {
           //the first argument must be a valid entity id
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string entityId = tokeniser.nextToken(   );
           if (  entityId != "" ) {
           EmberEntity* entity = EmberOgre::getSingleton(   ).getEntity(  entityId );
           if (  entity != 0 ) {
           startInspecting(  entity );
           }
           } else {
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  "You must specifify a valid entity id to inspect." );
           }
          
           } else {
           Widget::runCommand(  command,   args );
           }
          
          }
          
     152  void InspectWidget::disconnectFromEntity(   )
          {
           mChangedConnection.disconnect(   );
           mChildAddedConnection.disconnect(   );
           mChildRemovedConnection.disconnect(   );
          }
          
     159  void InspectWidget::handleAction(  const std::string& action,   EmberEntity* entity ) {
          
           if (  action == "inspect" ) {
           startInspecting(  entity );
           }
          }
          
     166  void InspectWidget::startInspecting(  EmberEntity* entity )
          {
           disconnectFromEntity(   );
          
           mMainWindow->setVisible(  true );
           mCurrentEntity = entity;
           showEntityInfo(  entity );
          
           mChangedConnection = entity->Changed.connect(  sigc::mem_fun(  *this,   &InspectWidget::entity_Changed ) );
           mChildAddedConnection = entity->ChildAdded.connect(  sigc::mem_fun(  *this,   &InspectWidget::entity_ChildAdded ) );
           mChildRemovedConnection = entity->ChildRemoved.connect(  sigc::mem_fun(  *this,   &InspectWidget::entity_ChildRemoved ) );
           mBeingDeletedConnection = entity->BeingDeleted.connect(  sigc::mem_fun(  *this,   &InspectWidget::entity_BeingDeleted ) );
          
           updateAttributeString(   );
          
           fillChildrenList(   );
          
          }
          
     185  void InspectWidget::frameStarted(  const Ogre::FrameEvent & evt )
          {
           if (  mMainWindow->isVisible(   ) && mCurrentEntity ) {
           showEntityInfo(  mCurrentEntity );
           }
          }
          
     192  void InspectWidget::showEntityInfo(  EmberEntity* entity )
          {
          
           //TODO: restructure this so it won't be done all over each frame,   instead cache the values and only update upon changes to the entity
           Eris::Entity* parent = entity->getLocation(   );
           std::stringstream ss;
           ss.precision(  4 );
          
           ss << "Name: " << entity->getName(   ) << "\n";
           ss << "Id: " << entity->getId(   ) << "\n";
           ss << "Parent: ";
           if (  parent ) {
           ss << parent->getName(   ) << " (  Id: " << parent->getId(   ) << " )";
           } else {
           ss << "none";
           }
           ss << "\n";
          
           if (  entity->getPredictedPos(   ).isValid(   ) ) {
           ss << "PredPosition: " << entity->getPredictedPos(   ) << "\n";
           }
           if (  entity->getPosition(   ).isValid(   ) ) {
           ss << "Position: " << entity->getPosition(   ) << "\n";
           }
           WFMath::Vector<3> velocity = entity->getPredictedVelocity(   );
           if (  velocity.isValid(   ) ) {
           ss << "Velocity: " << velocity << ": " << sqrt(  velocity.sqrMag(   ) ) << "\n";
           }
          
           if (  entity->getOrientation(   ).isValid(   ) ) {
           ss << "Orientation: " << entity->getOrientation(   ) << "\n";
           }
           if (  entity->getBBox(   ).isValid(   ) ) {
           ss << "Boundingbox: " << entity->getBBox(   ) << "\n";
           }
          
          /* std::set<std::string> parents = entity->getInherits(   );
          
           ss << "Inherits:\n";
           std::set<std::string>::iterator I = parents.begin(   );
           std::set<std::string>::iterator I_end = parents.end(   );
          
           for (  ; I != I_end; ++I ) {
           ss << " " << *I;
           }*/
          
           ss << "Type: " << entity->getType(   )->getName(   ) << "\n";
          
           ss << "Attributes:\n";
          
           ss << mAttributesString;
          
          // const Eris::Entity::AttrMap& attributes = entity->getAttributes(   );
          // for(  Eris::Entity::AttrMap::const_iterator I = attributes.begin(   ); I != attributes.end(   ); ++I ) {
          // if (  I->second.isString(   ) ) {
          // ss << I->first << ": " << I->second.asString(   ) << "\n";
          // } else if (  I->second.isNum(   ) ) {
          // ss << I->first << ": " << I->second.asNum(   ) << "\n";
          // } else if (  I->second.isMap(   ) ) {
          // ss << I->first << " (  map with "<< I->second.asMap(   ).size(   ) << " entries ):\n";
          // } else if (  I->second.isList(   ) ) {
          // ss << I->first << " (  list with "<< I->second.asList(   ).size(   ) << " entries ):\n";
          // }
          // }
          
          
          // Decoder bridge;
          // Atlas::Codecs::Bach codec(  ss,   bridge );
          // Atlas::Objects::ObjectsEncoder enc(  codec );
          //
          // const Eris::Entity::AttrMap attributes = entity->getAttributes(   );
          // for(  Eris::Entity::AttrMap::const_iterator I = attributes.begin(   ); I != attributes.end(   ); ++I ) {
          // codec.streamBegin(   );
          //
          // I->second.sendContents(  bridge );
          // //enc.streamObjectsMessage(  I->second );
          // codec.streamEnd(   );
          // }
          
          
          
           mInfo->setText(  ss.str(   ) );
          
          
          }
          
     278  void InspectWidget::fillChildrenList(   )
          {
           unsigned int numberOfChildren = mCurrentEntity->numContained(   );
           mChildList->resetList(   );
          
           for (  unsigned int i = 0; i < numberOfChildren; ++i ) {
           Eris::Entity* child = mCurrentEntity->getContained(  i );
           addChildToList(  child );
           }
          
          }
          
     290  void InspectWidget::addChildToList(  Eris::Entity* child )
          {
           CEGUI::String name(  child->getType(   )->getName(   ) + " (  "+ child->getId(   ) +" : "+child->getName(   )+" )" );
           CEGUI::ListboxItem* item = Gui::ColouredListItem::createColouredListItem(  name );
           item->setUserData(  child );
           mChildList->addItem(  item );
          }
          
     298  void InspectWidget::entity_ChildAdded(  Eris::Entity* entity )
          {
           addChildToList(  entity );
          }
          
     303  void InspectWidget::entity_ChildRemoved(  Eris::Entity* entity )
          {
           for (  unsigned int i = 0; i < mChildList->getItemCount(   ); ++i ) {
           CEGUI::ListboxItem* item = mChildList->getListboxItemFromIndex(  i );
           if (  item->getUserData(   ) == entity ) {
           mChildList->removeItem(  item );
           break;
           }
           }
          }
          
          
          
     316  void InspectWidget::entity_Changed(  const Eris::StringSet& attributes )
          {
           updateAttributeString(   );
          }
          
          
     322  bool InspectWidget::ShowCollision_Click(  const CEGUI::EventArgs& args )
          {
           if (  mCurrentEntity ) {
           mCurrentEntity->setVisualize(  "CollisionObject",   !mCurrentEntity->getVisualize(  "CollisionObject" ) );
           }
           return true;
          }
          
          
     331  bool InspectWidget::ShowOgreBoundingBox_Click(  const CEGUI::EventArgs& args )
          {
           if (  mCurrentEntity ) {
           mCurrentEntity->showOgreBoundingBox(  !mCurrentEntity->getShowOgreBoundingBox(   ) );
           }
           return true;
          }
          
     339  bool InspectWidget::ShowErisBoundingBox_Click(  const CEGUI::EventArgs& args )
          {
           if (  mCurrentEntity ) {
           mCurrentEntity->showErisBoundingBox(  !mCurrentEntity->getShowErisBoundingBox(   ) );
           }
           return true;
          }
          
          
          
          
          
          
     352  AttributeTextBuilder::AttributeTextBuilder(   ): mLevel(  0 )
          {
           mMainText.precision(  4 );
          }
          
     357  std::string AttributeTextBuilder::parseAttributes(  const Eris::Entity::AttrMap& map )
          {
           for (  Atlas::Message::MapType::const_iterator I = map.begin(   ); I != map.end(   ); ++I ) {
           parseElement(  I->first,   I->second );
           }
           return mMainText.str(   );
          }
          
     365  const std::stringstream& AttributeTextBuilder::getText(   ) const
          {
           return mMainText;
          }
          
     370  void AttributeTextBuilder::pad(   )
          {
           for(  int i = 0; i <= mLevel; ++i ) {
           mMainText << " ";
           }
          }
          
     377  void AttributeTextBuilder::parseElement(  const Atlas::Message::Element& element )
          {
           if (  element.isString(   ) ) {
           parseString(  element.asString(   ) );
           } else if (  element.isNum(   ) ) {
           parseNumber(  element.asNum(   ) );
           } else if (  element.isMap(   ) ) {
           parseMap(  "",   element.asMap(   ) );
           } else if (  element.isList(   ) ) {
           parseList(  "",   element.asList(   ) );
           }
          }
          
     390  void AttributeTextBuilder::parseString(  const std::string& text )
          {
           mMainText << ",   " << text;
          }
          
     395  void AttributeTextBuilder::parseNumber(  float number )
          {
           mMainText << ",   " << number;
          
          }
          
          
     402  void AttributeTextBuilder::parseElement(  const std::string& key,   const Atlas::Message::Element& element )
          {
           if (  key == "" ) {
           parseElement(  element );
           } else {
           if (  element.isString(   ) ) {
           parseString(  key,   element.asString(   ) );
           } else if (  element.isNum(   ) ) {
           parseNumber(  key,   element.asNum(   ) );
           } else if (  element.isMap(   ) ) {
           parseMap(  key,   element.asMap(   ) );
           } else if (  element.isList(   ) ) {
           parseList(  key,   element.asList(   ) );
           }
           }
          
          }
          
     420  void AttributeTextBuilder::parseString(  const std::string& key,   const std::string& text )
          {
           pad(   );
           mMainText << key << ": " << text << "\n";
          }
          
     426  void AttributeTextBuilder::parseNumber(  const std::string& key,   float number )
          {
           pad(   );
           mMainText << key << ": " << number << "\n";
          }
          
     432  void AttributeTextBuilder::parseList(  const std::string& key,   const Atlas::Message::ListType& list )
          {
           pad(   );
           if (  key != "" ) {
           mMainText << key << ":\n";
           }
           mLevel++;
           for (  Atlas::Message::ListType::const_iterator I = list.begin(   ); I != list.end(   ); ++I ) {
           parseElement(  *I );
           }
           mMainText << "\n";
           mLevel--;
          }
          
     446  void AttributeTextBuilder::parseMap(  const std::string& key,   const Atlas::Message::MapType& map )
          {
           pad(   );
           if (  key != "" ) {
           mMainText << key << ":\n";
           }
           mLevel++;
           for (  Atlas::Message::MapType::const_iterator I = map.begin(   ); I != map.end(   ); ++I ) {
           parseElement(  I->first,   I->second );
           }
           mLevel--;
          }
          
          
          
          
          }
          };

./components/ogre/widgets/InspectWidget.h

       1  //
          // C++ Interface: InspectWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef DIMEOGREINSPECTWIDGET_H
          #define DIMEOGREINSPECTWIDGET_H
          
          #include <Eris/Entity.h>
          
          namespace EmberOgre {
      29  class EmberEntity;
      30  class GUIManager;
          namespace Gui {
          
      33  class Widget;
          /**
          @author Erik Hjortsberg
          */
      37  class InspectWidget : public Widget
          {
          public:
          
      41   InspectWidget(   );
      42   virtual ~InspectWidget(   );
      43   void buildWidget(   );
      44   virtual void frameStarted(  const Ogre::FrameEvent & evt );
          
      46   const Ember::ConsoleCommandWrapper Inspect;
          
          
           /**
           * reimplement ConsoleObject::runCommand to catch the "inspect $entityid" command
           * @param command
           * @param args
           */
      54   virtual void runCommand(  const std::string &command,   const std::string &args );
          
          protected:
          
          
      59   void fillChildrenList(   );
      60   void entity_ChildAdded(  Eris::Entity* entity );
      61   void entity_ChildRemoved(  Eris::Entity* entity );
      62   void addChildToList(  Eris::Entity* child );
          
      64   void disconnectFromEntity(   );
          
           /**
           * Starts inspecting an entity
           * @param entity
           */
      70   void startInspecting(  EmberEntity* entity );
          
      72   CEGUI::Listbox* mChildList;
      73   CEGUI::GUISheet* mInfo;
          
           /**
           * Updated the entity information text
           * @param entity
           */
      79   void showEntityInfo(  EmberEntity* entity );
          
      81   void handleAction(  const std::string& action,   EmberEntity* entity );
      82   bool ShowOgreBoundingBox_Click(  const CEGUI::EventArgs& args );
      83   bool ShowErisBoundingBox_Click(  const CEGUI::EventArgs& args );
      84   bool ShowCollision_Click(  const CEGUI::EventArgs& args );
          
      86   EmberEntity* mCurrentEntity;
          
      88   void Server_GotView(  Eris::View* view );
      89   void entity_BeingDeleted(   );
          
      91   std::string mAttributeString;
          
      93   void updateAttributeString(   );
          
      95   void entity_Changed(  const Eris::StringSet& attributes );
          
      97   std::string mAttributesString;
          
      99   sigc::connection mChangedConnection;
     100   sigc::connection mChildAddedConnection;
     101   sigc::connection mChildRemovedConnection;
     102   sigc::connection mBeingDeletedConnection;
          
          };
          
     106  class AttributeTextBuilder
          {
          public:
          
     110   AttributeTextBuilder(   );
          
     112   std::string parseAttributes(  const Eris::Entity::AttrMap& map );
          
     114   const std::stringstream& getText(   ) const;
          
          private:
     117   EmberEntity* mEntity;
          
     119   std::stringstream mMainText;
           int mLevel;
          
     122   void parseElement(  const std::string& key,   const Atlas::Message::Element& element );
     123   void parseElement(  const Atlas::Message::Element& element );
          
     125   void parseString(  const std::string& text );
     126   void parseNumber(  float number );
          
     128   void parseString(  const std::string& key,   const std::string& text );
     129   void parseNumber(  const std::string& key,   float number );
     130   void parseList(  const std::string& key,   const Atlas::Message::ListType& list );
     131   void parseMap(  const std::string& key,   const Atlas::Message::MapType& map );
          
     133   void pad(   );
          };
          
     136  class IAttributeTextHandler
          {
          public:
     139   void handle(  const Eris::Entity::AttrMap& attrMap );
          };
          };
          };
          
          #endif

./components/ogre/widgets/InventoryWidget.cpp

       1  //
          // C++ Implementation: InventoryWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "InventoryWidget.h"
          
          #include "services/server/ServerService.h"
          #include "services/EmberServices.h"
          
          #include "ColouredListItem.h"
          
          #include "../EmberEntity.h"
          #include "../EmberPhysicalEntity.h"
          // #include "../PersonEmberEntity.h"
          #include "../AvatarEmberEntity.h"
          #include "../EmberEntityFactory.h"
          #include "../EmberOgre.h"
          #include "../Avatar.h"
          #include "../MathConverter.h"
          #include "../GUIManager.h"
          #include <Eris/TypeInfo.h>
          
          #include <elements/CEGUIPushButton.h>
          #include <elements/CEGUIDragContainer.h>
          #include <CEGUIPropertyHelper.h>
          #include "EntityIconManager.h"
          #include "EntityIcon.h"
          #include "EntityIconSlot.h"
          
          using namespace CEGUI;
          namespace EmberOgre {
          namespace Gui {
          
          
          
          // template<> WidgetLoader WidgetLoaderHolder<InventoryWidget>::loader(  "InventoryWidget",   &createWidgetInstance );
          
      57  InventoryWidget::InventoryWidget(   )
          : mIconsUsed(  0 ),   mEntityIconManager(  0 ),   mIconSize(  64 )
          {
          }
          
      62  InventoryWidget::~InventoryWidget(   )
          {
          }
          
      66  void InventoryWidget::buildWidget(   )
          {
          
          
           loadMainSheet(  "InventoryWidget.layout",   "Inventory/" );
           mMainWindow->setVisible(  false );
          
           mListBox = static_cast<CEGUI::Listbox*>(  getWindow(  "ListBox" ) );
          
           EmberOgre::getSingleton(   ).EventCreatedAvatarEntity.connect(  sigc::mem_fun(  *this,   &InventoryWidget::createdAvatarEmberEntity ) );
          
           CEGUI::PushButton* dropButton = static_cast<CEGUI::PushButton*>(  getWindow(  "Drop" ) );
           BIND_CEGUI_EVENT(  dropButton,   CEGUI::ButtonBase::EventMouseClick,   InventoryWidget::Drop_Click )
          
           CEGUI::PushButton* wieldButton = static_cast<CEGUI::PushButton*>(  getWindow(  "Wield" ) );
           BIND_CEGUI_EVENT(  wieldButton,   CEGUI::ButtonBase::EventMouseClick,   InventoryWidget::Wield_Click )
          
           enableCloseButton(   );
          
           mIconManager = mGuiManager->getIconManager(   );
           mEntityIconManager = new EntityIconManager(  *mGuiManager );
          
           for (  int i = 0; i < 8; ++i ) {
           addSlot(   );
           }
          
          }
          
      94  void InventoryWidget::createdAvatarEmberEntity(  AvatarEmberEntity* entity )
          {
           EmberOgre::getSingleton(   ).getAvatar(   )->EventAddedEntityToInventory.connect(  sigc::mem_fun(  *this,   &InventoryWidget::addedEntity ) );
           EmberOgre::getSingleton(   ).getAvatar(   )->EventRemovedEntityFromInventory.connect(  sigc::mem_fun(  *this,   &InventoryWidget::removedEntity ) );
           registerConsoleVisibilityToggleCommand(  "inventory" );
          
          ///only show the inventory by default if we're not an admin
           if (  !entity->getAvatar(   )->isAdmin(   ) ) {
           mMainWindow->setVisible(  true );
           }
          
          }
          
     107  EntityIconSlot* InventoryWidget::addSlot(   )
          {
           CEGUI::Window* container = getWindow(  "IconContainer" );
           if (  container ) {
           int yPosition = mSlots.size(   ) / 4;
           int xPosition = mSlots.size(   ) % 4;
          
           EntityIconSlot* slot = mEntityIconManager->createSlot(   );
           slot->getWindow(   )->setPosition(  CEGUI::UVector2(  CEGUI::UDim(  0,   mIconSize * xPosition ),   CEGUI::UDim(  0,   mIconSize * yPosition ) ) );
           container->addChildWindow(  slot->getWindow(   ) );
           mSlots.push_back(  slot );
           return slot;
           }
           return 0;
          }
          
     123  void InventoryWidget::addedEntity(  EmberEntity* entity ) {
           static int iconSize(  64 );
           std::string name(  entity->getType(   )->getName(   ) + " (  "+ entity->getId(   ) +" : "+entity->getName(   )+" )" );
          // CEGUI::ListboxItem* item = new Gui::ColouredListItem(  name,   atoi(  entity->getId(   ).c_str(   ) ),   entity );
          // mListBoxMap.insert(  std::map<EmberEntity*,   CEGUI::ListboxItem*>::value_type(  entity,   item ) );
          // mListBox->addItem(  item );
           CEGUI::Window* container = getWindow(  "IconContainer" );
           if (  container ) {
          
           Gui::Icons::Icon* icon = mIconManager->getIcon(  iconSize,   entity->getType(   ) );
           if (  icon ) {
           EntityIconSlot* slot = addSlot(   );
          
           EntityIcon* entityIcon = mEntityIconManager->createIcon(  icon,   entity );
           mIcons.push_back(  entityIcon );
           entityIcon->setTooltipText(  name );
           slot->addEntityIcon(  entityIcon );
          
          /* CEGUI::Window* iconContainer = createWindow(  "DefaultGUISheet",   ss3.str(   ) );
           if (  iconContainer ) {
          
           iconContainer->setSize(  CEGUI::UVector2(  CEGUI::UDim(  0,   iconSize ),   CEGUI::UDim(  0,   iconSize ) ) );
           iconContainer->setPosition(  CEGUI::UVector2(  CEGUI::UDim(  0,   iconSize * xPosition ),   CEGUI::UDim(  0,   iconSize * yPosition ) ) );
           container->addChildWindow(  iconContainer );
          
          
           std::stringstream ss1;
           ss1 << "inventoryDraggableContainer_" << mIcons.size(   );
           CEGUI::DragContainer* item = static_cast<CEGUI::DragContainer*>(  createWindow(  "DragContainer",   ss1.str(   ) ) );
          
           if (  item ) {
           item->setSize(  CEGUI::UVector2(  CEGUI::UDim(  0,   iconSize ),   CEGUI::UDim(  0,   iconSize ) ) );
           item->setTooltipText(  name );
           iconContainer->addChildWindow(  item );
          
           std::stringstream ss2;
           ss2 << "inventoryIcon_" << mIcons.size(   );
           CEGUI::Window* iconWindow = createWindow(  "EmberLook/StaticImage",   ss2.str(   ) );
           if (  iconWindow ) {
           iconWindow->setProperty(  "BackgroundEnabled",   "false" );
           iconWindow->disable(   );
           // iconWindow->setProperty(  "FrameEnabled",   "false" );
           item->addChildWindow(  iconWindow );
           EntityIcon entityIcon(  iconWindow,   icon );
           mIcons.push_back(  entityIcon );
           iconWindow->setProperty(  "Image",   CEGUI::PropertyHelper::imageToString(  icon->getImage(   ) ) );
           }
           }
           }*/
           }
           }
          
          
          }
     177  void InventoryWidget::removedEntity(  EmberEntity* entity ) {
          // CEGUI::ListboxItem* item = mListBox->getListboxItemFromIndex(  atoi(  dimeEntity->getId(   ).c_str(   ) ) );
          // CEGUI::ListboxItem* item = mListBoxMap[entity];
          // if (  item ) {
          // mListBox->removeItem(  item );
          // mListBoxMap.erase(  mListBoxMap.find(  entity ) );
          // }
          }
          
     186  bool InventoryWidget::Drop_Click(  const CEGUI::EventArgs& args )
          {
           CEGUI::ListboxItem* item = mListBox->getFirstSelectedItem(   );
           if (  item ) {
           //drop if one meter in front of the avatar
           Ogre::Vector3 o_vector(  1,  0,  0 );
           Ogre::Vector3 o_pos = EmberOgre::getSingleton(   ).getAvatar(   )->getAvatarEmberEntity(   )->getSceneNode(   )->getOrientation(   ) * o_vector;
          
           EmberEntity* entity = static_cast<EmberEntity*>(  item->getUserData(   ) );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->drop(  entity,   Ogre2Atlas_Vector3(  o_pos ) );
           }
           return true;
          }
          
     200  bool InventoryWidget::Wield_Click(  const CEGUI::EventArgs& args )
          {
           CEGUI::ListboxItem* item = mListBox->getFirstSelectedItem(   );
           if (  item ) {
           EmberEntity* entity = static_cast<EmberEntity*>(  item->getUserData(   ) );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->wield(  entity );
           }
           return true;
          }
          
          
          
          
          
          
          
          
          
          
          
          
          
          }
          
          };

./components/ogre/widgets/InventoryWidget.h

       1  //
          // C++ Interface: InventoryWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef DIMEOGREINVENTORYWIDGET_H
          #define DIMEOGREINVENTORYWIDGET_H
          
          #include "Widget.h"
          
          #include <elements/CEGUIListbox.h>
          #include <elements/CEGUIListboxItem.h>
          #include <elements/CEGUIListboxTextItem.h>
          #include <Eris/Entity.h>
          
          #include <sigc++/slot.h>
          #include "icons/Icon.h"
          #include "icons/IconManager.h"
          
          namespace CEGUI {
      38  class DragContainer;
          }
          
          
          namespace EmberOgre {
      43  class EmberEntity;
      44  class AvatarEmberEntity;
      45  class Widget;
      46  class GUIManager;
      47  class EmberEntityFactory;
          
          namespace Gui {
          
      51  class EntityIconManager;
      52  class EntityIconSlot;
      53  class EntityIcon;
      54  class EntityIconUserData;
          
          
          
          
          
          
          /**
          @author Erik Hjortsberg
          */
      64  class InventoryWidget : public Widget
          {
          public:
      67   InventoryWidget(   );
      68   virtual ~InventoryWidget(   );
      69   void buildWidget(   );
          
          
          protected:
      73   CEGUI::Listbox* mListBox;
      74   std::map<EmberEntity*,   CEGUI::ListboxItem*> mListBoxMap;
           typedef std::vector<EntityIconSlot*> IconSlotStore;
           typedef std::vector<EntityIcon*> IconStore;
          
      78   void removedEntity(  EmberEntity* emberEntity );
      79   void addedEntity(  EmberEntity* emberEntity );
      80   void createdAvatarEmberEntity(  AvatarEmberEntity* entity );
      81   bool Drop_Click(  const CEGUI::EventArgs& args );
      82   bool Wield_Click(  const CEGUI::EventArgs& args );
          
      84   EntityIconSlot* addSlot(   );
          
          
      87   Gui::Icons::IconManager* mIconManager;
           int mIconsUsed;
          
      90   IconSlotStore mSlots;
      91   IconStore mIcons;
      92   EntityIconManager* mEntityIconManager;
          
           int mIconSize;
          
          };
          };
          };
          
          #endif

./components/ogre/widgets/JesusEdit.cpp

       1  //
          // C++ Implementation: JesusEdit
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "JesusEdit.h"
          #include "ColouredListItem.h"
          
          #include "../jesus/Jesus.h"
          #include <elements/CEGUIPushButton.h>
          #include <elements/CEGUIGUISheet.h>
          #include <elements/CEGUISlider.h>
          #include "../GUIManager.h"
          #include "../carpenter/Carpenter.h"
          #include "../carpenter/BluePrint.h"
          
          #include <CEGUIWindowManager.h>
          #include <CEGUIImagesetManager.h>
          #include <CEGUIImageset.h>
          #include <elements/CEGUIListbox.h>
          #include <elements/CEGUIListboxItem.h>
          #include <elements/CEGUIListboxTextItem.h>
          #include <elements/CEGUIEditbox.h>
          
          #include "../EmberOgre.h"
          #include "../AvatarCamera.h"
          #include "../Avatar.h"
          #include "../EmberEntity.h"
          #include "../EmberPhysicalEntity.h"
          // #include "../PersonEmberEntity.h"
          #include "../AvatarEmberEntity.h"
          #include "../model/Model.h"
          #include "framework/ConsoleBackend.h"
          #include "../jesus/XMLJesusSerializer.h"
          
          #include "EntityCEGUITexture.h"
          #include "../SimpleRenderContext.h"
          
          namespace EmberOgre {
          namespace Gui {
          
          
          
      61  JesusEdit::JesusEdit(   )
           : Widget(   ),   mJesus(  0 ),   mInJesusMode(  false ),   mCurrentConstruction(  0 ),   mCurrentlySelectedBlock(  0 ),   mCurrentlySelectedAttachPointNode(  0 ),   mPreview(  0 ),   mFile(  0 )
          {
          
          
          }
          
          
      69  JesusEdit::~JesusEdit(   )
          {
          }
          
          
      74  void JesusEdit::buildWidget(   )
          {
          
           loadMainSheet(  "JesusEdit.layout",   "JesusEdit/" );
           mMainWindow->setVisible(  false );
          
          
          
          
           //bind buttons
           CEGUI::PushButton* switchButton = static_cast<CEGUI::PushButton*>(  getWindow(  "SwitchMode" ) );
           BIND_CEGUI_EVENT(  switchButton,   CEGUI::ButtonBase::EventMouseClick,   JesusEdit::SwitchMode_Click )
          
           CEGUI::PushButton* fileButton = static_cast<CEGUI::PushButton*>(  getWindow(  "File" ) );
           BIND_CEGUI_EVENT(  fileButton,   CEGUI::ButtonBase::EventMouseClick,   JesusEdit::File_Click )
          
           mCreateNew = static_cast<CEGUI::PushButton*>(  getWindow(  "CreateNew" ) );
           BIND_CEGUI_EVENT(  mCreateNew,   CEGUI::ButtonBase::EventMouseClick,   JesusEdit::CreateNew_Click )
          
           mCreate = static_cast<CEGUI::PushButton*>(  getWindow(  "Create" ) );
           BIND_CEGUI_EVENT(  mCreate,   CEGUI::ButtonBase::EventMouseClick,   JesusEdit::Create_Click )
          
           mBind = static_cast<CEGUI::PushButton*>(  getWindow(  "Bind" ) );
           BIND_CEGUI_EVENT(  mBind,   CEGUI::ButtonBase::EventMouseClick,   JesusEdit::Bind_Click )
          
           mRemove = static_cast<CEGUI::PushButton*>(  getWindow(  "Remove" ) );
           BIND_CEGUI_EVENT(  mRemove,   CEGUI::ButtonBase::EventMouseClick,   JesusEdit::Remove_Click )
          
          
          
           mNewName = static_cast<CEGUI::Editbox*>(  getWindow(  "NewName" ) );
          
          
          
           //bind lists
           mCurrentBlocksList = static_cast<CEGUI::Listbox*>(  getWindow(  "CurrentBlocks" ) );
           BIND_CEGUI_EVENT(  mCurrentBlocksList,   CEGUI::Listbox::EventSelectionChanged,   JesusEdit::CurrentBlocksList_SelectionChanged )
           BIND_CEGUI_EVENT(  mCurrentBlocksList,   CEGUI::Listbox::EventListContentsChanged,   JesusEdit::CurrentBlocksList_SelectionChanged )
          
          
           mCurrentPointsList = static_cast<CEGUI::Listbox*>(  getWindow(  "CurrentPoints" ) );
           BIND_CEGUI_EVENT(  mCurrentPointsList,   CEGUI::Listbox::EventSelectionChanged,   JesusEdit::CurrentPointsList_SelectionChanged )
           BIND_CEGUI_EVENT(  mCurrentPointsList,   CEGUI::Listbox::EventListContentsChanged,   JesusEdit::CurrentPointsList_SelectionChanged )
          
           mAvailableBlocksList = static_cast<CEGUI::Listbox*>(  getWindow(  "AvailableBlocks" ) );
           BIND_CEGUI_EVENT(  mAvailableBlocksList,   CEGUI::Listbox::EventSelectionChanged,   JesusEdit::AvailableBlocksList_SelectionChanged )
           BIND_CEGUI_EVENT(  mAvailableBlocksList,   CEGUI::Listbox::EventListContentsChanged,   JesusEdit::AvailableBlocksList_SelectionChanged )
          
           mNewPointsList = static_cast<CEGUI::Listbox*>(  getWindow(  "NewBlockPoints" ) );
           BIND_CEGUI_EVENT(  mNewPointsList,   CEGUI::Listbox::EventSelectionChanged,   JesusEdit::NewPointsList_SelectionChanged )
           BIND_CEGUI_EVENT(  mNewPointsList,   CEGUI::Listbox::EventListContentsChanged,   JesusEdit::NewPointsList_SelectionChanged )
          
          
          
           //bind external events
           mMousePicker.EventPickedModelBlock.connect(  sigc::mem_fun(  *this,   &JesusEdit::pickedModelBlock ) );
           mMousePicker.EventPickedAttachPointNode.connect(  sigc::mem_fun(  *this,   &JesusEdit::pickedAttachPointNode ) );
           EmberOgre::getSingleton(   ).EventCreatedJesus.connect(  sigc::mem_fun(  *this,   &JesusEdit::createdJesus ) );
          
           getMainSheet(   )->addChildWindow(  mMainWindow );
          // getMainSheet(   )->addChildWindow(  mPreviewWindow );
          
           //make sure the buttons are disabled by default
           updateBindingButton(   );
           updateCreateButton(   );
          
           registerConsoleVisibilityToggleCommand(  "builder" );
           enableCloseButton(   );
          
          }
          
          
          
     147  void JesusEdit::show(   )
          {
           if (  mJesus )
           {
           if (  mMainWindow )
           mMainWindow->setVisible(  true );
           if (  mPreview )
           mPreview->setVisible(  true );
           S_LOG_VERBOSE(  "Showing builder window." );
           } else {
           S_LOG_FAILURE(  "Can't show builder window before the main Jesus object is loaded." );
           }
          }
     160  void JesusEdit::hide(   )
          {
           S_LOG_VERBOSE(  "Hiding builder window." );
           if (  mMainWindow )
           mMainWindow->setVisible(  false );
           if (  mPreview )
           mPreview->setVisible(  false );
           if (  mFile )
           mFile->hide(   );
          }
          
     171  bool JesusEdit::SwitchMode_Click(  const CEGUI::EventArgs& args )
          {
          //TODO: this should use a IWorldPickListener instead
          
          /* if (  !mInJesusMode ) {
           mGuiManager->pushMousePicker(  &mMousePicker );
           } else {
           mGuiManager->popMousePicker(   );
           }*/
           mInJesusMode = !mInJesusMode;
           return true;
          }
          
     184  void JesusEdit::pickedModelBlock(  ModelBlock* modelBlock,   const MousePickerArgs& )
          {
           if (  mCurrentConstruction != modelBlock->getConstruction(   ) ) {
           loadConstruction(  modelBlock->getConstruction(   ) );
           }
          
           //use the lookup map to see what ListBoxItem corresponds to the picked ModleBlock
           std::map<ModelBlock*,   CEGUI::ListboxItem*>::iterator I = mCurrentBlocksListLookup.find(  modelBlock );
           if (  I != mCurrentBlocksListLookup.end(   ) ) {
           CEGUI::ListboxItem* item = I->second;
           mCurrentBlocksList->ensureItemIsVisible(  item );
           mCurrentBlocksList->setItemSelectState(  item,   true );
           }
          
          }
          
     200  void JesusEdit::loadConstruction(  Construction* construction )
          {
           mCurrentConstruction = construction;
           mCurrentBlocksList->resetList(   );
           mCurrentBlocksList->clearAllSelections(   );
           mCurrentBlocksListLookup.clear(   );
           std::vector<ModelBlock*> blocks = construction->getModelBlocks(   );
          
           for (  std::vector<ModelBlock*>::iterator I = blocks.begin(   ); I != blocks.end(   ); ++I )
           {
           CEGUI::String name(  (  *I )->getBuildingBlock(   )->getName(   ) );
           CEGUI::ListboxItem* item = new Gui::ColouredListItem(  name,   0,   *I );
           mCurrentBlocksList->addItem(  item );
           //add to the lookup map
           mCurrentBlocksListLookup.insert(  std::map<ModelBlock*,   CEGUI::ListboxItem*>::value_type(  *I,   item ) );
           }
          
           //loadFromJesus(  construction->getJesus(   ) );
          
          }
          
     221  void JesusEdit::createdJesus(  Jesus* jesus )
          {
           loadFromJesus(  jesus );
           mPreview = new JesusEditPreview(  mGuiManager,   jesus );
           mFile = new JesusEditFile(  mGuiManager,   this,   jesus );
           mFile->hide(   );
          
          }
          
     230  void JesusEdit::loadFromJesus(  Jesus* jesus )
          {
           mJesus = jesus;
           mAvailableBlocksList->resetList(   );
           mAvailableBlocksList->clearAllSelections(   );
           const std::map<const std::string ,   Carpenter::BuildingBlockSpec >* bblockSpecs = jesus->getCarpenter(   )->getBuildingBlockSpecs(   );
           for (  std::map<const std::string ,   Carpenter::BuildingBlockSpec >::const_iterator I = bblockSpecs->begin(   ); I != bblockSpecs->end(   ); ++I )
           {
           ConstWrapper<const Carpenter::BuildingBlockSpec*>* holder = new ConstWrapper<const Carpenter::BuildingBlockSpec*>(  &I->second );
           CEGUI::String name(  I->second.getName(   ) );
           CEGUI::ListboxItem* item = new Gui::ColouredListItem(  name,   0,   holder );
           mAvailableBlocksList->addItem(  item );
           }
          }
          
          
     246  void JesusEdit::pickedAttachPointNode(  AttachPointNode* pointNode,   const MousePickerArgs& )
          {
           CEGUI::ListboxItem* item = mCurrentPointsListLookup.find(  pointNode )->second;
           mCurrentPointsList->ensureItemIsVisible(  item );
           mCurrentPointsList->setItemSelectState(  item,   true );
          
          }
          
     254  bool JesusEdit::CurrentBlocksList_SelectionChanged(   const CEGUI::EventArgs & args  )
          {
           if (  mCurrentlySelectedBlock ) {
           mCurrentlySelectedBlock->deselect(   );
           mCurrentlySelectedBlock = 0;
           }
           CEGUI::ListboxItem* item = mCurrentBlocksList->getFirstSelectedItem(   );
           if (  item ) {
           ModelBlock* block = static_cast<ModelBlock*>(  item->getUserData(   ) );
           block->select(   );
           mCurrentlySelectedBlock = block;
          
           fillAttachPointList(  block );
           } else {
           mCurrentPointsList->resetList(   );
           mCurrentPointsList->clearAllSelections(   );
           }
           updateRemoveButton(   );
          
           return true;
          
          }
          
     277  bool JesusEdit::AvailableBlocksList_SelectionChanged(   const CEGUI::EventArgs & args  )
          {
           const Carpenter::BuildingBlockSpec* bblockSpec = getNewBuildingBlockSpec(    );
           removeBindings(   );
           if (  bblockSpec ) {
           fillNewAttachPointList(  bblockSpec->getBlockSpec(   ) );
          
          
           mPreview->showBuildingBlock(  bblockSpec->getName(   ) );
          
          /* mPreview->clearAndDestroyModel(   );
           Model* model = EmberOgre::getSingleton(   ).getJesus(   )->createModelForBlockType(  bblockSpec->getName(   ),  "JesusEditPreviewModel" );
           if (  model ) {
           mPreview->setModel(  model );
           }*/
           } else {
           mNewPointsList->resetList(   );
           mNewPointsList->clearAllSelections(   );
          
           }
           updateCreateButton(   );
           return true;
          
          }
          
     302  void JesusEdit::removeBindings(   )
          {
          
           mBindings.clear(   );
          }
          
     308  void JesusEdit::fillNewAttachPointList(  const Carpenter::BlockSpec * blockspec  )
          {
           mNewPointsList->resetList(   );
           mNewPointsList->clearAllSelections(   );
          
           const std::vector<const Carpenter::AttachPoint*> nodes = blockspec->getAllPoints(   );
           for (  std::vector<const Carpenter::AttachPoint*>::const_iterator I = nodes.begin(   ); I != nodes.end(   ); ++I )
           {
           CEGUI::String name(  (  *I )->getAttachPair(   )->getName(   ) + "/" + (  *I )->getName(   ) + " (  "+(  *I )->getAttachPair(   )->getType(   ) +" )" );
           ConstWrapper<const Carpenter::AttachPoint*>* holder = new ConstWrapper<const Carpenter::AttachPoint*>(  *I );
           CEGUI::ListboxItem* item = new Gui::ColouredListItem(  name,   0,   holder );
           mNewPointsList->addItem(  item );
          
           }
          
          }
          
          
     326  void JesusEdit::fillAttachPointList(  ModelBlock* block )
          {
           mCurrentPointsList->resetList(   );
           mCurrentPointsList->clearAllSelections(   );
          
           std::vector<AttachPointNode*> nodes = block->getAttachPointNodes(   );
           for (  std::vector<AttachPointNode*>::iterator I = nodes.begin(   ); I != nodes.end(   ); ++I )
           {
           CEGUI::String name(  (  *I )->getAttachPoint(   )->getAttachPair(   )->getName(   ) + "/" + (  *I )->getAttachPoint(   )->getName(   )+ " (  "+(  *I )->getAttachPoint(   )->getAttachPair(   )->getType(   ) +" )" );
           CEGUI::ListboxItem* item = new Gui::ColouredListItem(  name,   0,   *I );
           mCurrentPointsList->addItem(  item );
           mCurrentPointsListLookup.insert(  std::map<AttachPointNode*,   CEGUI::ListboxItem*>::value_type(  *I,   item ) );
          
           }
          
          }
          
          
          
          
          // AttachPointHolder::AttachPointHolder(  const Carpenter::AttachPoint* attachPoint )
          // : mAttachPoint(  attachPoint )
          // {
          // }
          
          
          
          
     354  bool JesusEdit::CurrentPointsList_SelectionChanged(   const CEGUI::EventArgs & args  )
          {
           if (  mCurrentlySelectedAttachPointNode ) {
           mCurrentlySelectedAttachPointNode->deselect(   );
           mCurrentlySelectedAttachPointNode = 0;
           }
           CEGUI::ListboxItem* item = mCurrentPointsList->getFirstSelectedItem(   );
           if (  item ) {
           AttachPointNode* pointNode = static_cast<AttachPointNode*>(  item->getUserData(   ) );
           mCurrentlySelectedAttachPointNode = pointNode;
          
           pointNode->select(   );
           }
           updateBindingButton(    );
           return true;
          
          }
          
          
          
     374  bool JesusEdit::NewPointsList_SelectionChanged(   const CEGUI::EventArgs & args  )
          {
           CEGUI::ListboxItem* item = mNewPointsList->getFirstSelectedItem(   );
           if (  item ) {
           const Carpenter::AttachPoint* point = getSelectedPointForNewBlock(   );
           mPreview->selectAttachPoint(  point );
           }
          
           updateBindingButton(    );
           return true;
          }
          
          
          
          
     389  void JesusEdit::updateCreateButton(    )
          {
           if (  mBindings.size(   ) > 1 ) {
           mCreate->setEnabled(  true );
           } else {
           mCreate->setEnabled(  false );
           }
          }
          
     398  void JesusEdit::updateRemoveButton(    )
          {
           bool enable = getSelectedBlock(   ) != 0 && mCurrentConstruction->getBluePrint(   )->isRemovable(  getSelectedBlock(   )->getBuildingBlock(   ) );
           mRemove->setEnabled(  enable );
          }
          
          
     405  void JesusEdit::updateBindingButton(    )
          {
           const Carpenter::AttachPoint * currentPoint = getSelectedPointForCurrentBlock(   );
           const Carpenter::AttachPoint * newPoint = getSelectedPointForNewBlock(   );
           bool enableButton = false;
           if (  currentPoint && newPoint )
           {
           //make sure both point are of the same type,   and have inverted normals
           if (  currentPoint->getAttachPair(   )->getType(   ) == newPoint->getAttachPair(   )->getType(   ) ) {
           enableButton = true;
           //TODO: check the normals
          /* if (  currentPoint->getNormal(   ).inverse(   ) == newPoint->getNormal(   ) )
           {
           enableButton = true;
           }*/
           }
           }
           mBind->setEnabled(  enableButton );
          
          }
          
     426  const Carpenter::AttachPoint * JesusEdit::getSelectedPointForCurrentBlock(    ) const
          {
           if (  mCurrentlySelectedAttachPointNode ) {
           return mCurrentlySelectedAttachPointNode->getAttachPoint(   );
           }
           return 0;
          }
          
     434  const Carpenter::AttachPoint * JesusEdit::getSelectedPointForNewBlock(    ) const
          {
           CEGUI::ListboxItem* item = mNewPointsList->getFirstSelectedItem(   );
           if (  item ) {
           ConstWrapper<const Carpenter::AttachPoint*>* holder = static_cast< ConstWrapper<const Carpenter::AttachPoint*>* >(  item->getUserData(   ) );
           const Carpenter::AttachPoint* point = holder->mValue;
           return point;
           } else {
           return 0;
           }
          
          }
          
     447  bool JesusEdit::Create_Click(   const CEGUI::EventArgs & args  )
          {
           Carpenter::BuildingBlockDefinition definition;
           definition.mName = mNewName->getText(   ).c_str(   );
           if (  definition.mName == "" ) {
           std::stringstream ss;
           ss << mCurrentConstruction->getModelBlocks(   ).size(   );
           definition.mName = std::string(  "_buildingBlock" ) + ss.str(   );
           }
           definition.mBuildingBlockSpec = getNewBuildingBlockSpec(   )->getName(   );
          
           Carpenter::BuildingBlock* bblock = mCurrentConstruction->getBluePrint(   )->createBuildingBlock(  definition );
          
           std::vector< Carpenter::BuildingBlockBinding* > bindings = createBindingsForNewBlock(  bblock );
           mCurrentConstruction->getBluePrint(   )->placeBindings(  bblock,   createBindingsForNewBlock(  bblock ) );
           if (  bblock->isAttached(   ) ) {
           mCurrentConstruction->createModelBlock(  bblock,   true );
           }
           removeBindings(   );
           loadConstruction(  mCurrentConstruction );
           return true;
          }
          
     470  bool JesusEdit::Remove_Click(   const CEGUI::EventArgs & args  )
          {
           if (  mCurrentlySelectedBlock != 0 ) {
           mCurrentConstruction->remove(  getSelectedBlock(   ) );
           mCurrentlySelectedBlock = 0;
           removeBindings(   );
           loadConstruction(  mCurrentConstruction );
           }
           return true;
          }
          
     481  const Carpenter::BuildingBlockSpec * JesusEdit::getNewBuildingBlockSpec(    ) const
          {
           CEGUI::ListboxItem* item = mAvailableBlocksList->getFirstSelectedItem(   );
           if (  item ) {
           ConstWrapper<const Carpenter::BuildingBlockSpec*>* holder = static_cast< ConstWrapper<const Carpenter::BuildingBlockSpec*>* >(  item->getUserData(   ) );
           const Carpenter::BuildingBlockSpec* bblockSpec = holder->mValue;
           return bblockSpec;
           } else {
           return 0;
           }
          
          
          }
          
     495  std::vector< Carpenter::BuildingBlockBinding* > JesusEdit::createBindingsForNewBlock(   Carpenter::BuildingBlock * newBlock  )
          {
           std::vector< Carpenter::BuildingBlockBinding* > blockBindings;
           std::map<AttachPointNode*,   const Carpenter::AttachPoint*>::iterator I = mBindings.begin(   );
           std::map<AttachPointNode*,   const Carpenter::AttachPoint*>::iterator I_end = mBindings.end(   );
          
           for (  ;I != I_end; ++I )
           {
           Carpenter::BuildingBlockBindingDefinition def;
           Carpenter::BuildingBlockBinding* binding = mCurrentConstruction->getBluePrint(   )->addBinding(  getSelectedBlock(   )->getBuildingBlock(   ),   I->first->getAttachPoint(   ),   newBlock,   I->second );
           if (  binding ) {
           blockBindings.push_back(  binding );
           }
           }
           return blockBindings;
          }
          
     512  bool JesusEdit::Bind_Click(   const CEGUI::EventArgs & args  )
          {
           if (  mCurrentlySelectedAttachPointNode && getSelectedPointForNewBlock(   ) ) {
           mBindings.insert(  std::map<AttachPointNode*,   const Carpenter::AttachPoint*>::value_type(  mCurrentlySelectedAttachPointNode,   getSelectedPointForNewBlock(   ) ) );
           }
           CEGUI::ListboxItem* item;
           item = mNewPointsList->getFirstSelectedItem(   );
           std::stringstream ss;
           ss << mBindings.size(   );
           item->setText(  item->getText(   ) + " (  " + ss.str(   ) + " )" );
           item = mCurrentPointsList->getFirstSelectedItem(   );
           item->setText(  item->getText(   ) + " (  " + ss.str(   ) + " )" );
          
           updateCreateButton(   );
           return true;
          }
          
     529  Construction* JesusEdit::createNewConstructionFromBlueprint(  Carpenter::BluePrint* blueprint )
          {
           AvatarCamera* camera = EmberOgre::getSingleton(   ).getMainCamera(   );
          
           //create a new node on the same "level" as the avatar
           Ogre::SceneNode* node = EmberOgre::getSingleton(   ).getSceneManager(   )->getRootSceneNode(   )->createChildSceneNode(   );
          
           Construction* construction = new Construction(  blueprint,   mJesus,   node );
           construction->buildFromBluePrint(  true );
          
           //place the node in front of the avatar
           Ogre::Vector3 o_vector(  0,  0,  -5 );
           Ogre::Vector3 o_pos = camera->getPosition(   ) + (  camera->getOrientation(  false ) * o_vector );
           node->setPosition(  o_pos );
          
           //for now,   don't rotate the construction,   there are some bugs
           //node->setOrientation(  camera->getOrientation(   ) );
          
           return construction;
          
          }
          
     551  JesusEditPreview::JesusEditPreview(  GUIManager* guiManager,   Jesus* jesus )
          :
          mJesus(  jesus ),  
          mConstruction(  0 ),  
          mGuiManager(  guiManager ),  
          mBlueprint(  0 ),  
          mMinCameraDistance(  0.5 ),  
          mMaxCameraDistance(  40 ),  
          mSelectedAttachPointNode(  0 )
          {
           mPreviewWindow = CEGUI::WindowManager::getSingleton(   ).loadWindowLayout(  mGuiManager->getLayoutDir(   ) + "JesusEditPreview.layout",   "JesusEditPreview/" );
          
           guiManager->getMainSheet(   )->addChildWindow(  mPreviewWindow );
           createPreviewTexture(   );
           setVisible(  false );
          }
          
     568  JesusEditPreview::~JesusEditPreview(   )
          {
           delete mBlueprint;
           delete mConstruction;
          }
          
     574  void JesusEditPreview::setVisible(  bool visible )
          {
           mPreviewWindow->setVisible(  visible );
           mTexture->getRenderContext(   )->setActive(  visible );
          }
          
     580  void JesusEditPreview::showBuildingBlock(  const std::string & spec )
          {
          
          //make sure to delete the old blueprint and construction
          //it's a bit of resource waste,   but it's ok
           delete mBlueprint;
           delete mConstruction;
           mSelectedAttachPointNode = 0;
           //delete mModelBlock;
          
           mBlueprint = new Carpenter::BluePrint(  "preview",   mJesus->getCarpenter(   ) );
           mConstruction = new Construction(  mBlueprint,   mJesus,   mTexture->getRenderContext(   )->getSceneNode(   ) );
          
           Carpenter::BuildingBlockDefinition def;
           def.mName = "preview";
           def.mBuildingBlockSpec = spec;
           mBlock = mBlueprint->createBuildingBlock(  def );
          
           mModelBlock = mConstruction->createModelBlock(  mBlock,   true );
           mModelBlock->select(   );
          
           mTexture->getRenderContext(   )->repositionCamera(   );
           mTexture->getRenderContext(   )->showFull(  mModelBlock->getModel(   ) );
          
          
          }
          
     607  void JesusEditPreview::setZoom(  float value )
          {
           mTexture->getRenderContext(   )->setCameraDistance(  mTexture->getRenderContext(   )->getDefaultCameraDistance(   ) * value );
          /* Ogre::Real newDistance = (  mMaxCameraDistance * mMinCameraDistance ) * value;
           Ogre::Vector3 position = mTexture->getCamera(   )->getPosition(   );
           position.z = -newDistance;
           mTexture->getCamera(   )->setPosition(  position );*/
          }
          
     616  bool JesusEditPreview::Zoom_ValueChanged(  const CEGUI::EventArgs& args )
          {
           setZoom(  mZoomSlider->getCurrentValue(   ) );
           return true;
          }
          
          
     623  void JesusEditPreview::selectAttachPoint(  const Carpenter::AttachPoint* point )
          {
           if (  mSelectedAttachPointNode ) {
           mSelectedAttachPointNode->deselect(   );
           mSelectedAttachPointNode = 0;
           }
          
           std::vector<AttachPointNode*> nodes = mModelBlock->getAttachPointNodes(   );
           for (  std::vector<AttachPointNode*>::iterator I = nodes.begin(   ); I != nodes.end(   ); ++I )
           {
           if (  (  *I )->getAttachPoint(   ) == point ) {
           mSelectedAttachPointNode = (  *I );
           break;
           }
           }
           if (  mSelectedAttachPointNode )
           {
           mSelectedAttachPointNode->select(   );
           }
          
          }
          
     645  void JesusEditPreview::createPreviewTexture(   )
          {
           CEGUI::GUISheet* imageWidget = static_cast<CEGUI::GUISheet*>(  CEGUI::WindowManager::getSingleton(   ).getWindow(  (  CEGUI::utf8* )"JesusEditPreview/Image" ) );
           mTexture = new EntityCEGUITexture(  imageWidget->getName(   ).c_str(   ),   256,   256 );
           imageWidget->setProperty(  "image",   "set:" + mTexture->getImage(   )->getImagesetName(   ) + " image:" + mTexture->getImage(   )->getName(   ) );
          
          
           mZoomSlider = static_cast<CEGUI::Slider*>(  CEGUI::WindowManager::getSingleton(   ).getWindow(  (  CEGUI::utf8* )"JesusEditPreview/Zoom" ) );
           BIND_CEGUI_EVENT(  mZoomSlider,   CEGUI::Slider::EventValueChanged,   JesusEditPreview::Zoom_ValueChanged );
          
          }
          
          
     658  JesusEditFile::JesusEditFile(  GUIManager* guiManager,   JesusEdit* jesusEdit,   Jesus* jesus ) : mJesusEdit(  jesusEdit ),   mJesus(  jesus )
          {
           mWindow = CEGUI::WindowManager::getSingleton(   ).loadWindowLayout(  guiManager->getLayoutDir(   ) + "JesusEditFile.layout",   "JesusEditFile/" );
          
           mBluePrintList = static_cast<CEGUI::Listbox*>(  CEGUI::WindowManager::getSingleton(   ).getWindow(  (  CEGUI::utf8* )"JesusEditFile/Blueprints" ) );
          /* BIND_CEGUI_EVENT(  mBluePrintList,   CEGUI::Listbox::EventSelectionChanged,   JesusEditFile::BluePrintList_SelectionChanged )
           BIND_CEGUI_EVENT(  mBluePrintList,   CEGUI::Listbox::EventListContentsChanged,   JesusEditFile::BluePrintList_SelectionChanged )*/
          
          
           mLoadButton = static_cast<CEGUI::PushButton*>(  CEGUI::WindowManager::getSingleton(   ).getWindow(  (  CEGUI::utf8* )"JesusEditFile/Load" ) );
           BIND_CEGUI_EVENT(  mLoadButton,   CEGUI::ButtonBase::EventMouseClick,   JesusEditFile::Load_Click )
           mSaveButton = static_cast<CEGUI::PushButton*>(  CEGUI::WindowManager::getSingleton(   ).getWindow(  (  CEGUI::utf8* )"JesusEditFile/Save" ) );
           BIND_CEGUI_EVENT(  mSaveButton,   CEGUI::ButtonBase::EventMouseClick,   JesusEditFile::Save_Click )
          
           mNewNameEditBox = static_cast<CEGUI::Editbox*>(  CEGUI::WindowManager::getSingleton(   ).getWindow(  (  CEGUI::utf8* )"JesusEditFile/NewName" ) );
          
           guiManager->getMainSheet(   )->addChildWindow(  mWindow );
          
           fillBluePrintList(   );
          
          }
          
     680  void JesusEditFile::fillBluePrintList(   )
          {
           mBluePrintList->resetList(   );
          
           const std::map<std::string,   Carpenter::BluePrint* >* blueprintMap = mJesus->getAllBluePrints(   );
          
           std::map<std::string,   Carpenter::BluePrint* >::const_iterator I = blueprintMap->begin(   );
           std::map<std::string,   Carpenter::BluePrint* >::const_iterator I_end = blueprintMap->end(   );
          
           for (  ; I != I_end; ++I )
           {
           CEGUI::String name(  I->first );
           CEGUI::ListboxItem* item = new Gui::ColouredListItem(  name,   0,   0 );
           mBluePrintList->addItem(  item );
          
           }
          
          
          
          }
          
     701  bool JesusEditFile::Load_Click(   const CEGUI::EventArgs & args  )
          {
           CEGUI::ListboxItem* item = mBluePrintList->getFirstSelectedItem(   );
           if (  item ) {
           std::string name(  item->getText(   ).c_str(   ) );
          
           Carpenter::BluePrint* blueprint = mJesus->getBluePrint(  name );
           if (  blueprint ) {
           Construction* construction = mJesusEdit->createNewConstructionFromBlueprint(  blueprint );
           //load the construction in jesusEdit
           mJesusEdit->loadConstruction(  construction );
          
           }
           }
          
           return true;
          }
          
          
     720  bool JesusEditFile::Save_Click(   const CEGUI::EventArgs & args  )
          {
          
           std::string name(  mNewNameEditBox->getText(   ).c_str(   ) );
          
           //check that there is a name
           if (  name != "" ) {
           saveBluePrint(  name,   mJesusEdit->getConstruction(   )->getBluePrint(   ) );
          /* //check if there's already a blueprint saved with that name
           if (  mJesus->getAllBluePrints(   )->find(  name ) == mJesus->getAllBluePrints(   ).end(   ) ) {
           } else {
           //there is a blueprint already,   but check if this is defined in the home dir
           }*/
          
           }
          
           return true;
          }
          
     739  bool JesusEditFile::saveBluePrint(  const std::string& name,   Carpenter::BluePrint* blueprint  )
          {
           XMLJesusSerializer serializer(  mJesus );
           serializer.saveBlueprintToFile(  blueprint,   name + ".blueprint.xml",   name );
           return true;
          }
          
     746  void JesusEditFile::show(   )
          {
           mWindow->setVisible(  true );
           mWindow->moveToFront (   );
          }
          
     752  void JesusEditFile::hide(   )
          {
           mWindow->setVisible(  false );
          }
          
     757  void JesusEditFile::switchVisibility(   )
          {
           if (  mWindow->isVisible(   ) ) {
           hide(   );
           } else {
           show(   );
           }
          }
          
          
          
     768  bool JesusEdit::CreateNew_Click(   const CEGUI::EventArgs & args  )
          {
          
           Carpenter::BluePrint* blueprint = new Carpenter::BluePrint(  "blueprint",   mJesus->getCarpenter(   ) );
          
           Carpenter::BuildingBlockDefinition definition;
           definition.mName = mNewName->getText(   ).c_str(   );
           if (  definition.mName == "" ) {
           definition.mName = "startingblock";
           }
           definition.mBuildingBlockSpec = getNewBuildingBlockSpec(   )->getName(   );
          
          
          // Carpenter::BuildingBlock* bblock =
           blueprint->createBuildingBlock(  definition );
           blueprint->setStartingBlock(  definition.mName );
           blueprint->compile(   );
          
           Construction* construction = createNewConstructionFromBlueprint(  blueprint );
          // construction->createModelBlock(  bblock,   true );
           removeBindings(   );
          
          
           //load the construction in jesusEdit
           loadConstruction(  construction );
          
          
           return true;
          }
          
     798  bool JesusEdit::File_Click(  const CEGUI::EventArgs& args )
          {
           if (  mFile )
           {
           mFile->switchVisibility(   );
           }
           return true;
          }
          
          }
          }

./components/ogre/widgets/JesusEdit.h

       1  //
          // C++ Interface: JesusEdit
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREJESUSEDIT_H
          #define EMBEROGREJESUSEDIT_H
          
          #include "Widget.h"
          #include "../jesus/JesusMousePicker.h"
          
          // #include <elements/CEGUIListbox.h>
          // #include <elements/CEGUIListboxItem.h>
          // #include <elements/CEGUIListboxTextItem.h>
          // #include <elements/CEGUIEditbox.h>
          #include <CEGUIMouseCursor.h>
          
          #include "../GUIManager.h"
          #include "framework/ConsoleObject.h"
          
          
          
          
          namespace Carpenter
          {
      43  class AttachPair;
      44  class AttachPoint;
      45  class BlockSpec;
      46  class BuildingBlock;
      47  class BuildingBlockSpec;
      48  class BuildingBlockSpecDefinition;
      49  class BuildingBlockBinding;
      50  class BuildingBlockBindingDefinition;
      51  class BuildingBlockDefinition;
      52  class BluePrint;
      53  class Carpenter;
          
          };
          
          namespace EmberOgre {
          
          namespace Model {
      60   class Model;
          }
          
      63  class JesusMousePicker;
      64  class ModelBlock;
      65  class AttachPointNode;
      66  class Construction;
      67  class Jesus;
          namespace Gui {
          
      70  class JesusEdit;
          
      72  class EntityCEGUITexture;
          
          /**
          @author Erik Hjortsberg
          */
          
          
      79  class JesusEditPreview
          {
          public:
      82   JesusEditPreview(  GUIManager* guiManager,   Jesus* jesus );
      83   virtual ~JesusEditPreview(   );
          
           /**
           * shows a preview of the BuildingBlockSpec
           * @param spec
           */
      89   void showBuildingBlock(  const std::string & spec );
          
          
           /**
           * selects the attach point (  makes it begin to blink etc. )
           * @param point
           */
      96   void selectAttachPoint(  const Carpenter::AttachPoint* point );
          
          
           /**
           * zooms the camera to the specified value
           * @param value a value between 0.0 and 1.0
           */
     103   void setZoom(  float value );
          
     105   void setVisible(  bool visible );
          
          
          protected:
     109   CEGUI::Window* mPreviewWindow;
     110   Jesus* mJesus;
     111   Construction* mConstruction;
     112   GUIManager* mGuiManager;
     113   void createPreviewTexture(   );
     114   void createCamera(   );
     115   Ogre::SceneNode* mCameraNode;
     116   Ogre::SceneNode* mEntityNode;
     117   Ogre::Camera* mCamera;
           //Model* mModel;
     119   Carpenter::BluePrint* mBlueprint;
          
     121   Carpenter::BuildingBlock* mBlock;
     122   ModelBlock* mModelBlock;
          
     124   bool Zoom_ValueChanged(  const CEGUI::EventArgs& args );
          
     126   CEGUI::Slider* mZoomSlider;
          
           /**
           the minimum and maximum camera distance,   as used by zoom(   )
           */
     131   Ogre::Real mMinCameraDistance,   mMaxCameraDistance;
          
          
           /**
           The currently selected AttachPointNode
           */
     137   AttachPointNode* mSelectedAttachPointNode;
          
     139   Ogre::RenderTexture* mRenderTexture;
          
     141   EntityCEGUITexture* mTexture;
          };
          
     144  class JesusEditFile
          {
          public:
     147   JesusEditFile(  GUIManager* guiManager,   JesusEdit* jesusEdit,   Jesus* jesus );
     148   ~JesusEditFile(   );
          
     150   void show(   );
     151   void hide(   );
     152   void switchVisibility(   );
          
          protected:
     155   CEGUI::Window* mWindow;
     156   JesusEdit* mJesusEdit;
     157   Jesus* mJesus;
          
     159   bool Load_Click(  const CEGUI::EventArgs& args );
     160   bool Save_Click(  const CEGUI::EventArgs& args );
          
     162   CEGUI::PushButton* mLoadButton;
     163   CEGUI::PushButton* mSaveButton;
     164   CEGUI::Listbox* mBluePrintList;
     165   CEGUI::Editbox* mNewNameEditBox;
          
     167   void fillBluePrintList(   );
          
     169   bool saveBluePrint(  const std::string& name,   Carpenter::BluePrint* blueprint  );
          
          
          
          };
          
          
          
     177  class JesusEdit : public Widget
          {
          public:
     180   JesusEdit(   );
          
     182   virtual ~JesusEdit(   );
          
     184   Jesus* mJesus;
          
     186   virtual void buildWidget(   );
          
          
     189   inline Construction* getConstruction(   ) const {return mCurrentConstruction;}
          
           /**
           * loads the supplied construction
           * @param construction
           */
     195   void loadConstruction(  Construction* construction );
          
          
           /**
           * creates a new construction from the blueprint and adds it to the world
           * @param blueprint
           * @return
           */
     203   Construction* createNewConstructionFromBlueprint(  Carpenter::BluePrint* blueprint );
          
          
     206   virtual void show(   );
     207   virtual void hide(   );
          
          
          
          protected:
          
           /**
           if set to true,   we're in edit mode
           */
     216   bool mInJesusMode;
          
           /**
           mouse picker which picks building blocks
           */
     221   JesusMousePicker mMousePicker;
          
          
           /**
           * method bound to EmberOgre::EventCreatedJesus
           *
           * @param jesus
           */
     229   void createdJesus(  Jesus* jesus );
          
          
           /**
           * set up the whole system from a Jesus instance
           * @param jesus
           */
     236   void loadFromJesus(  Jesus* jesus );
          
          
          
           ///---------start CEGUI callback methods
          
           /**
           * switches between normal gui mode and JesusEdit mode
           * @param args
           * @return
           */
     247   bool SwitchMode_Click(  const CEGUI::EventArgs& args );
          
          
           /**
           * tries to bind two attach points
           * @param args
           * @return
           */
     255   bool Bind_Click(  const CEGUI::EventArgs& args );
          
          
           /**
           * tries to create a new bblock
           * @param args
           * @return
           */
     263   bool Create_Click(  const CEGUI::EventArgs& args );
          
          
           /**
           * creates a new Construction
           * @param args
           * @return
           */
     271   bool CreateNew_Click(  const CEGUI::EventArgs& args );
          
           /**
           * removes a BuildingBlock
           * @param args
           * @return
           */
     278   bool Remove_Click(  const CEGUI::EventArgs& args );
          
          
          
     282   bool File_Click(  const CEGUI::EventArgs& args );
          
          
     285   bool AvailableBlocksList_SelectionChanged(  const CEGUI::EventArgs& args );
     286   bool CurrentBlocksList_SelectionChanged(  const CEGUI::EventArgs& args );
     287   bool CurrentPointsList_SelectionChanged(  const CEGUI::EventArgs& args );
     288   bool NewPointsList_SelectionChanged(  const CEGUI::EventArgs& args );
          
           ///-----------end CEGUI callback methods
          
          
           /**
           * checks whether the Bind button should be enabled
           */
     296   void updateBindingButton(   );
           /**
           * checks whether the Create button should be enabled
           */
     300   void updateCreateButton(   );
          
           /**
           * checks whether the Remove button should be enabled
           */
     305   void updateRemoveButton(    );
          
           /**
           * gets the selected AttachPoint for the current block
           * @return null if no block selected
           */
     311   const Carpenter::AttachPoint* getSelectedPointForCurrentBlock(   ) const;
           /**
           * gets the selected AttachPoint for the new
           * @return null if no block selected
           */
     316   const Carpenter::AttachPoint* getSelectedPointForNewBlock(   ) const;
          
          
           /**
           * bound to JesusMousePicker::EventPickedModelBlock
           * @param modelBlock
           * @param
           */
     324   void pickedModelBlock(  ModelBlock* modelBlock,   const MousePickerArgs& );
          
           /**
           * bound to JesusMousePicker::EventPickedAttachPointNode
           * @param pointNode
           * @param
           */
     331   void pickedAttachPointNode(  AttachPointNode* pointNode,   const MousePickerArgs& );
          
          
           /**
           * fill the attach point list with values taken from the supplied ModelBlock
           * @param block
           */
     338   void fillAttachPointList(  ModelBlock* block );
          
          
           /**
           * fill the "new attach point" list with values from the supplied BlockSpec
           * @param blockspec
           */
     345   void fillNewAttachPointList(  const Carpenter::BlockSpec* blockspec );
          
          
          
          
           ///---------start CEGUI elements
     351   CEGUI::PushButton* mBind;
     352   CEGUI::PushButton* mCreate;
     353   CEGUI::PushButton* mCreateNew;
     354   CEGUI::PushButton* mRemove;
          
     356   CEGUI::Editbox* mNewName;
          
     358   CEGUI::Listbox* mAvailableBlocksList;
     359   CEGUI::Listbox* mCurrentBlocksList;
     360   CEGUI::Listbox* mCurrentPointsList;
     361   CEGUI::Listbox* mNewPointsList;
          
           ///----------end CEGUI elements
          
          
           /**
           * creates and returns a vector of BuildingBlockBinding for the supplied BuildingBlock
           * @param newBlock
           * @return
           */
     371   std::vector<Carpenter::BuildingBlockBinding*> createBindingsForNewBlock(  Carpenter::BuildingBlock* newBlock );
          
           /**
           * removes all current bindings
           */
     376   void removeBindings(   );
          
          
     379   Construction* mCurrentConstruction;
     380   inline ModelBlock* getSelectedBlock(   ) { return mCurrentlySelectedBlock;};
     381   ModelBlock* mCurrentlySelectedBlock;
          // const Carpenter::BuildingBlockSpec* mCurrentlySelectedBuildingBlockSpec;
          
           /**
           The selected attach point node of the existing building block.
           */
     387   AttachPointNode* mCurrentlySelectedAttachPointNode;
          
          // Carpenter::BlockSpec* getNewBlockSpec(   );
     390   const Carpenter::BuildingBlockSpec* getNewBuildingBlockSpec(   ) const;
           /**
           used for lookups of ListboxItems from ModelBlocks
           */
     394   std::map<ModelBlock*,   CEGUI::ListboxItem*> mCurrentBlocksListLookup;
          
           /**
           used for lookups of ListboxItems from AttachPoints
           */
     399   std::map<AttachPointNode*,   CEGUI::ListboxItem*> mCurrentPointsListLookup;
          
          
     402   std::map<AttachPointNode*,   const Carpenter::AttachPoint*> mBindings;
          
          // void createPreviewTexture(   );
     405   JesusEditPreview* mPreview;
     406   JesusEditFile* mFile;
          };
          
          
          
          
          // class AttachPointHolder
          // {
          // public:
          // AttachPointHolder(  const Carpenter::AttachPoint* attachPoint );
          // const Carpenter::AttachPoint* mAttachPoint;
          // };
          }
          }
          
          #endif

./components/ogre/widgets/ListHolder.cpp

       1  //
          // C++ Implementation: ListHolder
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ListHolder.h"
          
          #include <elements/CEGUIListbox.h>
          #include <elements/CEGUIListboxItem.h>
          #include <elements/CEGUIEditbox.h>
          
          #include "framework/Exception.h"
          
          
          namespace EmberOgre {
          namespace Gui {
          
      35  ListHolder::ListHolder(  CEGUI::Listbox* listbox,   CEGUI::Editbox* filterEditbox )
          : mListbox(  listbox ),   mFilterEditbox(  filterEditbox )
          {
           if (  filterEditbox ) {
           BIND_CEGUI_EVENT(  filterEditbox,   CEGUI::Window::EventTextChanged,   ListHolder::filterEditbox_TextChanged  );
           }
          // BIND_CEGUI_EVENT(  listbox,   CEGUI::Listbox::EventListContentsChanged,   ListHolder::listbox_ListContentsChanged  );
          
          
          
          }
          
          
      48  ListHolder::~ListHolder(   )
          {
          }
          
          
      53  void ListHolder::addItem(  CEGUI::ListboxItem* item )
          {
           if (  mListbox ) {
           item->setAutoDeleted(  false );
           mItems.push_back(  item );
           if (  isItemAllowed(  item ) ) {
           mListbox->addItem(  item );
           }
           }
          }
          
      64  void ListHolder::insertItem(  CEGUI::ListboxItem* item,   const CEGUI::ListboxItem* position )
          {
           ///not yet supported
           throw Ember::Exception(  "insertItem is not yet supported." );
          /* ListItemStore::iterator pos = std::find(  mItems.begin(   ),   mItems.end(   ),   position );
           mItems.insert(  pos,   item );*/
          
          }
          
      73  void ListHolder::removeItem(  const CEGUI::ListboxItem* item )
          {
           if (  mListbox ) {
           ListItemStore::iterator pos = std::find(  mItems.begin(   ),   mItems.end(   ),   item );
           if (  pos != mItems.end(   ) ) {
           mItems.erase(  pos );
           }
           mListbox->removeItem(  item );
           }
          }
          
      84  bool ListHolder::isItemAllowed(  CEGUI::ListboxItem* item )
          {
           if (  mFilterEditbox ) {
           if (  mFilterEditbox->getText(   ) == "" ) {
           return true;
           }
           return item->getText(   ).find(  mFilterEditbox->getText(   ) ) != CEGUI::String::npos;
           }
           return true;
          }
          
      95  void ListHolder::updateItems(   )
          {
           if (  mListbox ) {
           mListbox->resetList(   );
           for(  ListItemStore::iterator I = mItems.begin(   ); I != mItems.end(   ); ++I )
           {
           if (  isItemAllowed(  *I ) ) {
           mListbox->addItem(  *I );
           }
           }
           }
          }
          
          
          ///we can't do the decorator pattern,   since the ContentChanged event gives to little information
          ///One approach would be if it was possible to hide a ListItem,   then we could just keep all items in the Listbox
          ///But it's not,   so we would have to have an internal "correct" list,   and a filtered one in the Listbox.
          ///And then removing and inserting wouldn't work,   because you can't remove an item from the Listbox if it's not there.
          // bool ListHolder::listbox_ListContentsChanged(  const CEGUI::EventArgs& args )
          // {
          // CEGUI::ListboxItem* item = 0;
          // ///first we need to find which item changed
          // if (  mListbox->getItemCount(   ) == 0 mShownItems.size(   ) ) {
          // ///something has been removed
          //
          // int i = 0;
          // for(  ListItemStore::iterator I = mShownItems.begin(   ); I != mShownItems.end(   ); ++I,  ++i )
          // {
          // if (  *I != mShownItems->getListboxItemFromIndex(  i ) ) {
          // item = *I;
          // mShownItems.erase(  I );
          // mItems.erase(  mItems.find(  *I ) );
          // delete *I;
          // break;
          // }
          // }
          // } else {
          // int i = 0;
          // ///insert is not supported,   so lets just get the last item
          // for(  ListItemStore::iterator I = mShownItems.begin(   ); I != mShownItems.end(   ); ++I,  ++i )
          // {
          // if (  *I != mListbox->getListboxItemFromIndex(  i ) ) {
          // item = mListbox->getListboxItemFromIndex(  i );
          // item->setAutoDeleted(  false );
          // mItems.pushBack(  item );
          // break;
          // }
          // }
          // }
          // return true;
          // }
          
     147  bool ListHolder::filterEditbox_TextChanged(  const CEGUI::EventArgs& args )
          {
           updateItems(   );
           return true;
          }
     152  void ListHolder::resetList(   )
          {
           if (  mListbox ) {
           mListbox->resetList(   );
           }
           for (  ListItemStore::iterator I = mItems.begin(   ); I != mItems.end(   ); ++I )
           {
           delete *I;
           }
           mItems.clear(   );
          }
          
          }
          }

./components/ogre/widgets/ListHolder.h

       1  //
          // C++ Interface: ListHolder
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRELISTHOLDER_H
          #define EMBEROGRELISTHOLDER_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "Widget.h"
          
          namespace CEGUI
          {
      31   class ListboxItem;
      32   class Listbox;
      33   class Editbox;
          }
          
          namespace EmberOgre {
          namespace Gui {
          
          /**
          
          A facade class for providing filtering to a listbox control.
          This is done by calling the facade methods of this class instead of directly calling the methods of the Listbox.
          
          @author Erik Hjortsberg
          */
      46  class ListHolder{
          public:
           /**
           * Ctor.
           * @param listbox A valid Listbox control. This is the list which will be filtered.
           * @param filterEditbox A valid Editbox. This is where the user enters the filtering text.
           * @return
           */
      54   ListHolder(  CEGUI::Listbox* listbox,   CEGUI::Editbox* filterEditbox );
          
      56   virtual ~ListHolder(   );
          
          
           /**
           * Facade for CEGUI::Listbox::addItem(  ... )
           * @param item
           */
      63   void addItem(  CEGUI::ListboxItem* item );
           /**
           * Facade for CEGUI::Listbox::insertItem(  ... )
           * Not implemented yet. Calling this will throw an exception.
           * @param item
           */
      69   void insertItem(  CEGUI::ListboxItem* item,   const CEGUI::ListboxItem* position );
           /**
           * Facade for CEGUI::Listbox::removeItem(  ... )
           * @param item
           */
      74   void removeItem(  const CEGUI::ListboxItem* item );
           /**
           * Filters and updates the items in the listbox. This will normally be called automatically.
           * @param item
           */
      79   void updateItems(   );
          
           /**
           * Facade for CEGUI::Listbox::resetList(  ... )
           * @param item
           */
      85   void resetList(   );
          protected:
          
           typedef std::list<CEGUI::ListboxItem*> ListItemStore;
           /**
           All items in the listbox,   unfiltered.
           */
      92   ListItemStore mItems;
           //const std::string& getFilterString(   ) const;
           /**
           The listbox which should be filtered.
           */
      97   CEGUI::Listbox* mListbox;
           /**
           The editbox which contains the filter.
           */
     101   CEGUI::Editbox* mFilterEditbox;
          
           /**
           * Checks whether an item is allowed to be shown in the Listbox.
           * @param item
           * @return
           */
     108   bool isItemAllowed(  CEGUI::ListboxItem* item );
          
     110   bool filterEditbox_TextChanged(  const CEGUI::EventArgs& args );
          // bool listbox_ListContentsChanged(  const CEGUI::EventArgs& args );
          
          
          };
          }
          }
          
          #endif

./components/ogre/widgets/LoadingBar.cpp

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2005 The OGRE Team
          Also see acknowledgements in Readme.html
          
          You may use this sample code for anything you like,   it is not covered by the
          LGPL like the rest of the engine.
          -----------------------------------------------------------------------------
          */
          /*
          -----------------------------------------------------------------------------
          Filename: ExampleLoadingBar.h
          Description: Defines an example loading progress bar which you can use during
          startup,   level changes etc to display loading progress.
          IMPORTANT: Note that this progress bar relies on you having the OgreCore.zip
          package already added to a resource group called 'Bootstrap' - this provides
          the basic resources required for the progress bar and will be loaded automatically.
          */
          #include "LoadingBar.h"
          
          #include "services/EmberServices.h"
          #include "services/wfut/WfutService.h"
          
          using namespace Ogre;
          namespace EmberOgre {
          namespace Gui {
          
          /** Defines an example loading progress bar which you can use during
           startup,   level changes etc to display loading progress.
          @remarks
           Basically you just need to create an instance of this class,   call start(   )
           before loading and finish(   ) afterwards. You may also need to stop areas of
           your scene rendering in between since this method will call
           RenderWindow::update(   ) to update the display of the bar - we advise using
           SceneManager's 'special case render queues' for this,   see
           SceneManager::addSpecialCaseRenderQueue for details.
          @note
           This progress bar relies on you having the OgreCore.zip and EmberCore.zip package already
           added to a resource group called 'Bootstrap' - this provides the basic
           resources required for the progress bar and will be loaded automatically.
          */
      46   LoadingBar::LoadingBar(   ) :
           mProgress(  0 ) ,  
           mWindow(  0 ),  
           mLoadOverlay(  0 ),  
           mProgressBarScriptSize(  0 ),  
           mLoadingBarElement(  0 ),  
           mLoadingDescriptionElement(  0 ),  
           mLoadingCommentElement(  0 ),  
           mVersionElement(  0 )
           {}
          
      57   LoadingBar::~LoadingBar(   ){}
          
           /** Show the loading bar and start listening.
           @param window The window to update
           @param numGroupsInit The number of groups you're going to be initialising
           @param numGroupsLoad The number of groups you're going to be loading
           @param initProportion The proportion of the progress which will be taken
           up by initialisation (  ie script parsing etc ). Defaults to 0.7 since
           script parsing can often take the majority of the time.
           */
      67   void LoadingBar::start(  RenderWindow* window )
           {
           mWindow = window;
           // We need to pre-initialise the 'Bootstrap' group so we can use
           // the basic contents in the loading screen
           ResourceGroupManager::getSingleton(   ).initialiseResourceGroup(  "Bootstrap" );
          
           try {
           OverlayManager& omgr = OverlayManager::getSingleton(   );
           mLoadOverlay = (  Overlay* )omgr.getByName(  "EmberCore/LoadOverlay" );
           if (  !mLoadOverlay )
           {
           OGRE_EXCEPT(  Exception::ERR_ITEM_NOT_FOUND,  
           "Cannot find loading overlay",   "LoadingBar::start" );
           }
           mLoadOverlay->show(   );
          
           // Save links to the bar and to the loading text,   for updates as we go
           mLoadingBarElement = omgr.getOverlayElement(  "EmberCore/LoadPanel/Bar/Progress" );
           mLoadingCommentElement = omgr.getOverlayElement(  "EmberCore/LoadPanel/Comment" );
           mLoadingDescriptionElement = omgr.getOverlayElement(  "EmberCore/LoadPanel/Description" );
           mVersionElement = omgr.getOverlayElement(  "EmberCore/Splash/VersionInfo" );
          
           //OverlayElement* barContainer = omgr.getOverlayElement(  "EmberCore/LoadPanel/Bar" );
           mProgressBarMaxSize = mLoadingBarElement->getWidth(   );
           mProgressBarMaxLeft = mLoadingBarElement->getLeft(   );
          
           //mLoadingBarElement->setWidth(  300 );
          
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating loading bar. Message: \n" << ex.getFullDescription(   ) );
           }
          
          
           }
          
           /** Hide the loading bar and stop listening.
           */
     105   void LoadingBar::finish(  void )
           {
           if (  mLoadOverlay ) {
           /// hide loading screen
           mLoadOverlay->hide(   );
           }
          
           ///we won't be needing the bootstrap resources for some while,   so unload them
           ResourceGroupManager::getSingleton(   ).unloadResourceGroup(  "Bootstrap" );
          
           }
          
          
          
          
     120   void LoadingBar::addSection(  LoadingBarSection* section )
           {
           mSections.push_back(  section );
           }
          
     125   void LoadingBar::activateSection(  LoadingBarSection* section )
           {
           SectionStore::iterator I = std::find(  mSections.begin(   ),   mSections.end(   ),   section );
           if (  I != mSections.end(   ) ) {
           mCurrentSection = I;
           SectionStore::iterator J = I;
           float totalSize = 0;
           for (  ;J != mSections.begin(   ); --J ) {
           totalSize += (  *J )->getSize(   );
           }
           setProgress(  totalSize );
           }
           }
          
     139   void LoadingBar::setProgress(  float progress )
           {
           if (  mLoadingBarElement ) {
           ///make the black blocking block a little bit smaller and move it to the right
           mLoadingBarElement->setWidth(  mProgressBarMaxSize * (  1 - progress ) );
           mLoadingBarElement->setLeft(  mProgressBarMaxLeft + (  mProgressBarMaxSize * progress ) );
           mWindow->update(   );
           }
           mProgress = progress;
           }
          
     150   void LoadingBar::increase(  float amount )
           {
           setProgress(  mProgress + amount );
           }
          
     155   void LoadingBar::setCaption(  const std::string& caption )
           {
           if (  mLoadingCommentElement ) {
           mLoadingCommentElement->setCaption(  caption );
           mWindow->update(   );
           }
           }
          
     163   void LoadingBar::setVersionText(  const std::string& versionText )
           {
           if (  mVersionElement ) {
           mVersionElement->setCaption(  versionText );
           mWindow->update(   );
           }
           }
          
          
          
          
          
     175   LoadingBarSection::LoadingBarSection(  LoadingBar& loadingBar,   float size,   const std::string& name )
           : mSize(  size ),   mLoadingBar(  loadingBar ),   mAccumulatedSize(  0 ),   mName(  name ),   mActive(  false )
           {
           }
     179   LoadingBarSection::~LoadingBarSection(   )
           {
           }
          
     183   const std::string& LoadingBarSection::getName(   ) const
           {
           return mName;
           }
          
     188   void LoadingBarSection::setCaption(  const std::string& caption )
           {
           mLoadingBar.setCaption(  caption );
           }
          
     193   float LoadingBarSection::getSize(   ) const
           {
           return mSize;
           }
          
     198   void LoadingBarSection::tick(  float tickSize )
           {
           if (  mAccumulatedSize < 1.0 ) {
           mLoadingBar.increase(  mSize * tickSize );
           mAccumulatedSize += tickSize;
           }
           }
          
     206   void LoadingBarSection::deactivate(   )
           {
           mActive = false;
           }
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
     233   ResourceGroupLoadingBarSection::ResourceGroupLoadingBarSection(  LoadingBarSection& section,  
     234   unsigned short numGroupsInit,  
     235   unsigned short numGroupsLoad,  
     236   Ogre::Real initProportion )
           : mInitProportion(  initProportion ),   mNumGroupsInit(  numGroupsInit ),   mNumGroupsLoad(  numGroupsLoad ),   mSection(  section ),   mProgressBarInc(  0 )
           {
           // self is listener
           ResourceGroupManager::getSingleton(   ).addResourceGroupListener(  this );
           }
          
     243   ResourceGroupLoadingBarSection::~ResourceGroupLoadingBarSection(   )
           {
           ResourceGroupManager::getSingleton(   ).removeResourceGroupListener(  this );
           }
          
           /// ResourceGroupListener callbacks
     249   void ResourceGroupLoadingBarSection::resourceGroupScriptingStarted(  const String& groupName,   size_t scriptCount )
           {
           if (  mNumGroupsInit == 0 ) {
           return; ///avoid divide-by-zero
           }
           if (  mNumGroupsLoad != 0 ) {
           mProgressBarInc = mInitProportion / mNumGroupsInit;
           } else {
           mProgressBarInc = 1.0 / mNumGroupsInit;
           }
          
           if (  scriptCount == 0 ) {
           ///no scripts will be loaded,   so we'll have to conclude this group here and now
           mSection.tick(  mProgressBarInc );
           }
          
           mProgressBarInc /= (  Real )scriptCount;
           mSection.setCaption(  "Parsing scripts..." );
           }
     268   void ResourceGroupLoadingBarSection::scriptParseStarted(  const String& scriptName )
           {
           mSection.setCaption(  scriptName );
           }
     272   void ResourceGroupLoadingBarSection::scriptParseEnded(  const Ogre::String& scriptName )
           {
           ///make the black blocking block a little bit smaller and move it to the right
           mSection.tick(  mProgressBarInc );
           }
     277   void ResourceGroupLoadingBarSection::resourceGroupLoadStarted(  const String& groupName,   size_t resourceCount )
           {
           if (  mNumGroupsLoad == 0 ) {
           return; ///avoid divide-by-zero
           }
           if (  mNumGroupsInit ) {
           mProgressBarInc = (  1.0-mInitProportion ) /
           mNumGroupsLoad;
           } else {
           mProgressBarInc = 1.0 / mNumGroupsLoad;
           }
          
           if (  resourceCount == 0 ) {
           ///no resources will be loaded,   so we'll have to conclude this group here and now
           mSection.tick(  mProgressBarInc );
           }
          
           mProgressBarInc /= (  Real )resourceCount;
           mSection.setCaption(  "Loading resources..." );
           }
     297   void ResourceGroupLoadingBarSection::resourceLoadStarted(  const ResourcePtr& resource )
           {
           mSection.setCaption(  resource->getName(   ) );
           }
     301   void ResourceGroupLoadingBarSection::resourceLoadEnded(  void )
           {
           mSection.tick(  mProgressBarInc );
           }
          /* void ResourceGroupLoadingBarSection::worldGeometryStageStarted(  const String& description )
           {
           mSection.setCaption(  description );
           }*/
     309   void ResourceGroupLoadingBarSection::resourceGroupLoadEnded(  const String& groupName )
           {
           }
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
     328   WfutLoadingBarSection::WfutLoadingBarSection(  LoadingBarSection& section )
           : mSection(  section ),   mNumberOfFilesToUpdate(  0 ),   mDownloadedSoFar(  0 )
           {
           Ember::WfutService* wfutSrv = Ember::EmberServices::getSingleton(   ).getWfutService(   );
           wfutSrv->DownloadComplete.connect(  sigc::mem_fun(  *this,   &WfutLoadingBarSection::wfutService_DownloadComplete ) );
           wfutSrv->DownloadFailed.connect(  sigc::mem_fun(  *this,   &WfutLoadingBarSection::wfutService_DownloadFailed ) );
           wfutSrv->AllDownloadsComplete.connect(  sigc::mem_fun(  *this,   &WfutLoadingBarSection::wfutService_AllDownloadsComplete ) );
           wfutSrv->DownloadingServerList.connect(  sigc::mem_fun(  *this,   &WfutLoadingBarSection::wfutService_DownloadingServerList ) );
           wfutSrv->UpdatesCalculated.connect(  sigc::mem_fun(  *this,   &WfutLoadingBarSection::wfutService_UpdatesCalculated ) );
           }
     338   WfutLoadingBarSection::~WfutLoadingBarSection(   )
           {}
          
     341   void WfutLoadingBarSection::wfutService_DownloadComplete(  const std::string& url,   const std::string& filename )
           {
           mDownloadedSoFar++;
           std::stringstream ss;
           ss << "Downloaded " << filename << " (  " <<mDownloadedSoFar << " of "<< mNumberOfFilesToUpdate << " )";
           mSection.setCaption(  ss.str(   ) );
           if (  mNumberOfFilesToUpdate ) {
           mSection.tick(  1.0 / mNumberOfFilesToUpdate );
           }
           }
          
     352   void WfutLoadingBarSection::wfutService_DownloadFailed(  const std::string& url,   const std::string& filename,   const std::string& reason )
           {
           mDownloadedSoFar++;
           std::stringstream ss;
           ss << "Failed to download " << filename << " (  " << mDownloadedSoFar << " of " << mNumberOfFilesToUpdate << " )";
           mSection.setCaption(  ss.str(   ) );
           if (  mNumberOfFilesToUpdate ) {
           mSection.tick(  1.0 / mNumberOfFilesToUpdate );
           }
           }
          
     363   void WfutLoadingBarSection::wfutService_AllDownloadsComplete(   )
           {
           }
          
     367   void WfutLoadingBarSection::wfutService_DownloadingServerList(  const std::string& url )
           {
           mSection.setCaption(  "Getting server list from " + url );
           }
          
     372   void WfutLoadingBarSection::wfutService_UpdatesCalculated(  unsigned int numberOfFilesToUpdate )
           {
           mNumberOfFilesToUpdate = numberOfFilesToUpdate;
           }
          
          }
          }
          

./components/ogre/widgets/LoadingBar.h

       1  /*
          -----------------------------------------------------------------------------
          This source file is part of OGRE
          (  Object-oriented Graphics Rendering Engine )
          For the latest info,   see http://www.ogre3d.org/
          
          Copyright (  c ) 2000-2005 The OGRE Team
          Also see acknowledgements in Readme.html
          
          You may use this sample code for anything you like,   it is not covered by the
          LGPL like the rest of the engine.
          -----------------------------------------------------------------------------
          */
          /*
          -----------------------------------------------------------------------------
          Filename: ExampleLoadingBar.h
          Description: Defines an example loading progress bar which you can use during
          startup,   level changes etc to display loading progress.
          IMPORTANT: Note that this progress bar relies on you having the OgreCore.zip
          package already added to a resource group called 'Bootstrap' - this provides
          the basic resources required for the progress bar and will be loaded automatically.
          */
          
          #ifndef EMBEROGRELOADERBAR_H
          #define EMBEROGRELOADERBAR_H
          
          #include "../EmberOgrePrerequisites.h"
          
          namespace EmberOgre {
          namespace Gui {
          
      32  class LoadingBar;
          
      34  class LoadingBarSection
          {
      36  friend class LoadingBar;
          public:
      38   LoadingBarSection(  LoadingBar& loadingBar,   float size,   const std::string& name );
      39   virtual ~LoadingBarSection(   );
          
      41   void activate(  int steps );
      42   float getSize(   ) const;
      43   const std::string& getName(   ) const;
      44   void tick(  float tickSize );
      45   void setCaption(  const std::string& caption );
          
          private:
      48   void deactivate(   );
           float mSize;
      50   LoadingBar& mLoadingBar;
           float mAccumulatedSize;
      52   std::string mName;
      53   bool mActive;
          };
          
      56  class WfutLoadingBarSection : public sigc::trackable
          {
          public:
      59   WfutLoadingBarSection(  LoadingBarSection& section );
      60   virtual ~WfutLoadingBarSection(   );
          private:
          
      63   void wfutService_DownloadComplete(  const std::string& url,   const std::string& filename );
          
      65   void wfutService_DownloadFailed(  const std::string& url,   const std::string& filename,   const std::string& reason );
          
      67   void wfutService_AllDownloadsComplete(   );
          
      69   void wfutService_DownloadingServerList(  const std::string& url );
          
      71   void wfutService_UpdatesCalculated(  unsigned int numberOfFilesToUpdate );
          
          
      74   LoadingBarSection& mSection;
           unsigned int mNumberOfFilesToUpdate,   mDownloadedSoFar;
          };
          
      78  class ResourceGroupLoadingBarSection : public Ogre::ResourceGroupListener
          {
          public:
      81   ResourceGroupLoadingBarSection(  LoadingBarSection& section,   unsigned short numGroupsInit = 1,  
           unsigned short numGroupsLoad = 1,  
           Ogre::Real initProportion = 0.70f );
      84   virtual ~ResourceGroupLoadingBarSection(   );
          
           // ResourceGroupListener callbacks
      87   void resourceGroupScriptingStarted(  const Ogre::String & groupName,   size_t scriptCount );
      88   void scriptParseStarted(  const Ogre::String & scriptName );
      89   void scriptParseEnded(  const Ogre::String& scriptName );
      90   void resourceGroupScriptingEnded(  const Ogre::String & groupName ) {}
      91   void resourceGroupLoadStarted(  const Ogre::String & groupName,   size_t resourceCount );
      92   void resourceLoadStarted(  const Ogre::ResourcePtr& resource );
      93   void resourceLoadEnded(  void );
      94   void worldGeometryStageStarted(  const Ogre::String & description ) {}
      95   void worldGeometryStageEnded(  void ) {}
      96   void resourceGroupLoadEnded(  const Ogre::String & groupName );
          
          private:
      99   Ogre::Real mInitProportion;
     100   unsigned short mNumGroupsInit;
     101   unsigned short mNumGroupsLoad;
     102   LoadingBarSection& mSection;
     103   Ogre::Real mProgressBarInc;
          
          };
          
          
          /** Defines an example loading progress bar which you can use during
           startup,   level changes etc to display loading progress.
          @remarks
           Basically you just need to create an instance of this class,   call start(   )
           before loading and finish(   ) afterwards. You may also need to stop areas of
           your scene rendering in between since this method will call
           RenderWindow::update(   ) to update the display of the bar - we advise using
           SceneManager's 'special case render queues' for this,   see
           SceneManager::addSpecialCaseRenderQueue for details.
          @note
           This progress bar relies on you having the OgreCore.zip package already
           added to a resource group called 'Bootstrap' - this provides the basic
           resources required for the progress bar and will be loaded automatically.
          */
     122  class LoadingBar
          {
          protected:
           typedef std::vector<LoadingBarSection*> SectionStore;
     126   SectionStore mSections;
     127   SectionStore::iterator mCurrentSection;
           float mProgress;
     129   Ogre::Real mProgressBarMaxSize,   mProgressBarMaxLeft;
          
     131   Ogre::RenderWindow* mWindow;
     132   Ogre::Overlay* mLoadOverlay;
     133   Ogre::Real mProgressBarScriptSize;
     134   Ogre::OverlayElement* mLoadingBarElement;
     135   Ogre::OverlayElement* mLoadingDescriptionElement;
     136   Ogre::OverlayElement* mLoadingCommentElement;
     137   Ogre::OverlayElement* mVersionElement;
          
          public:
     140   LoadingBar(   );
     141   virtual ~LoadingBar(   );
          
           /** Show the loading bar and start listening.
           @param window The window to update
           @param numGroupsInit The number of groups you're going to be initialising
           @param numGroupsLoad The number of groups you're going to be loading
           @param initProportion The proportion of the progress which will be taken
           up by initialisation (  ie script parsing etc ). Defaults to 0.7 since
           script parsing can often take the majority of the time.
           */
     151   virtual void start(  Ogre::RenderWindow* window );
          
           /** Hide the loading bar and stop listening.
           */
     155   virtual void finish(  void );
          
     157   void addSection(  LoadingBarSection* section );
          
     159   void activateSection(  LoadingBarSection* section );
     160   void increase(  float amount );
     161   void setProgress(  float progress );
     162   void setDescription(  const std::string& description );
     163   void setCaption(  const std::string& caption );
     164   void setVersionText(  const std::string& versionText );
          
          
          };
          }
          }
          
          #endif

./components/ogre/widgets/MakeEntityWidget.cpp

          //
          // C++ Implementation: MakeEntityWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "MakeEntityWidget.h"
          #include "ColouredListItem.h"
          
          #include <Eris/TypeService.h>
          #include <Eris/Connection.h>
          #include <Eris/TypeInfo.h>
          #include <Eris/Avatar.h>
          #include <Eris/View.h>
          
          #include "services/EmberServices.h"
          #include "services/server/ServerService.h"
          #include <Atlas/Objects/Operation.h>
          #include <Atlas/Message/Element.h>
          #include <wfmath/atlasconv.h>
          
          #include "../EmberOgre.h"
          #include "services/logging/LoggingService.h"
          #include "../Avatar.h"
          
          
          
          #include "../EmberEntity.h"
          #include "../EmberPhysicalEntity.h"
          // #include "../PersonEmberEntity.h"
          #include "../AvatarEmberEntity.h"
          
          #include "ModelRenderer.h"
          
          #include <CEGUIWindow.h>
          #include <elements/CEGUIListbox.h>
          #include <elements/CEGUIListboxItem.h>
          #include <elements/CEGUIListboxTextItem.h>
          #include <elements/CEGUIEditbox.h>
          #include <elements/CEGUIPushButton.h>
          #include <elements/CEGUIGUISheet.h>
          #include "framework/ConsoleBackend.h"
          
          #include "../terrain/TerrainGenerator.h"
          #include <Mercator/Area.h>
          
          namespace EmberOgre {
          namespace Gui {
          
          /*template<> WidgetLoader WidgetLoaderHolder<MakeEntityWidget>::loader(  "MakeEntityWidget",   &createWidgetInstance );*/
          //WidgetLoader Widget::loader(  "MakeEntityWidget",   &createWidgetInstance<MakeEntityWidget> );
          
      70  MakeEntityWidget::MakeEntityWidget(   )
      71   : Widget(   ),   CreateEntity(  "createentity",   this,   "Create an entity." ),   Make(  "make",   this,   "Create an entity." ),   mIsReady(  false ),   mModelPreviewRenderer(  0 )
          {
          
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  "testarea",  this );
          
          }
          
          
      79  MakeEntityWidget::~MakeEntityWidget(   )
          {
          }
          
      83  void MakeEntityWidget::buildWidget(   )
          {
          
           loadMainSheet(  "MakeEntityWidget.layout",   "MakeEntity/" );
          
           mTypeList = static_cast<CEGUI::Listbox*>(  getWindow(  "TypeList" ) );
           mName = static_cast<CEGUI::Editbox*>(  getWindow(  "Name" ) );
          
           CEGUI::PushButton* button = static_cast<CEGUI::PushButton*>(  getWindow(  "CreateButton" ) );
          
           BIND_CEGUI_EVENT(  button,   CEGUI::ButtonBase::EventMouseClick,  MakeEntityWidget::createButton_Click  );
           BIND_CEGUI_EVENT(  mTypeList,   CEGUI::Listbox::EventSelectionChanged ,  MakeEntityWidget::typeList_ItemSelectionChanged  );
          
          
          
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->GotConnection.connect(  sigc::mem_fun(  *this,   &MakeEntityWidget::connectedToServer ) );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->GotAvatar.connect(  sigc::mem_fun(  *this,   &MakeEntityWidget::gotAvatar ) );
          
          
           createPreviewTexture(   );
          
           registerConsoleVisibilityToggleCommand(  "entitycreator" );
           enableCloseButton(   );
          
          }
          
          
          
          
     112  void MakeEntityWidget::show(   )
          {
           if (  mIsReady )
           {
           if (  mMainWindow ) {
           Widget::show(   );
           }
           S_LOG_INFO(  "Showing entity creator window." );
           } else {
           S_LOG_FAILURE(  "Can't show entity creator window before we have taken an avatar." );
           }
          }
          
          
          
     127  void MakeEntityWidget::gotAvatar(  Eris::Avatar* avatar )
          {
          // loadAllTypes(   );
           mIsReady = true;
          }
          
          
          
          
          
     137  void MakeEntityWidget::loadAllTypes(   )
          {
           Eris::TypeService* typeservice = mConn->getTypeService(   );
           Eris::TypeInfo* typeInfo = typeservice->getTypeByName(  "game_entity" );
           addToList(  typeInfo,   0 );
          
          }
          
     145  void MakeEntityWidget::connectedToServer(  Eris::Connection* conn )
          {
           mConn = conn;
           Eris::TypeService* typeservice = conn->getTypeService(   );
           typeservice->BoundType.connect(  sigc::mem_fun(  *this,   &MakeEntityWidget::boundAType ) );
          
          }
          
     153  void MakeEntityWidget::addToList(  Eris::TypeInfo* typeInfo,   int level )
          {
           std::stringstream levelindicator;
           for (  int i = 0; i < level; ++i ) {
           levelindicator << "-";
           }
           CEGUI::ListboxTextItem* item = new CEGUI::ListboxTextItem(  levelindicator.str(   ) + typeInfo->getName(   ) );
           item->setSelectionBrushImage(  getDefaultScheme(   ),   (  CEGUI::utf8* )"MultiListSelectionBrush" );
           item->setUserData(  typeInfo );
           mTypeList->addItem(  item );
          
           if (  typeInfo->hasUnresolvedChildren(   ) )
           typeInfo->resolveChildren(   );
          
           const Eris::TypeInfoSet children = typeInfo->getChildren(   );
           Eris::TypeInfoSet::const_iterator I = children.begin(   );
           Eris::TypeInfoSet::const_iterator I_end = children.end(   );
          
           for (  ;I != I_end; ++I )
           {
           addToList(  *I,   level+1 );
           }
          
          }
          
     178  void MakeEntityWidget::boundAType(  Eris::TypeInfo* typeInfo )
          {
           //make sure only entities inheriting from game_entity are shown
           static Eris::TypeInfo* gameEntityType = 0;
           if (  typeInfo->getName(   ) == "game_entity" ) {
           gameEntityType = typeInfo;
           if (  typeInfo->hasUnresolvedChildren(   ) )
           typeInfo->resolveChildren(   );
           return;
           }
          
           if (  gameEntityType != 0 && typeInfo->isA(  gameEntityType ) ) {
           std::stringstream levelindicator;
           Eris::TypeInfo* parentType;
           if (  typeInfo->getParents(   ).size(   ) ) {
           parentType = *typeInfo->getParents(   ).begin(   );
           while (  parentType ) {
           //break before we hit the game_entity parent
           if (  parentType == gameEntityType ) {
           break;
           }
           levelindicator << "-";
           if (  parentType->getParents(   ).size(   ) ) {
           parentType = *parentType->getParents(   ).begin(   );
           } else {
           parentType = 0;
           }
           }
           }
          
           CEGUI::ListboxTextItem* item = new Gui::ColouredListItem(  levelindicator.str(   ) + typeInfo->getName(   ) );
           item->setUserData(  typeInfo );
           mTypes[typeInfo] = item;
          
           if (  mTypes.size(   ) == 0 ) {
           mTypeList->addItem(  item );
           } else {
           CEGUI::ListboxItem* parentListItem = mTypes[*typeInfo->getParents(   ).begin(   )];
           mTypeList->insertItem(  item,   parentListItem );
           }
           if (  typeInfo->hasUnresolvedChildren(   ) )
           typeInfo->resolveChildren(   );
           }
          
           //item->setSelectionBrushImage(  (  CEGUI::utf8* )"EmberLook",   (  CEGUI::utf8* )"MultiListSelectionBrush" );
          
          }
          
     226  void MakeEntityWidget::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  CreateEntity == command || Make == command )
           {
           Eris::TypeService* typeService = mConn->getTypeService(   );
           Eris::TypeInfo* typeinfo = typeService->getTypeByName(  args );
           if (  typeinfo ) {
           createEntityOfType(  typeinfo );
           }
          // } else if (  command == "testarea" ) {
          // Mercator::Area* area = new Mercator::Area(  7,   false );
          // WFMath::Polygon<2> poly;
          //
          // float points[] = { -26,  -62,   -36,  -31,   -26,  -14,   2,  -1,   22,   40,   132,  122,   140,  127,   144.5,   146.5,   169,   153,   169,  155,   142.5,  148.5,   138,  129,   130,  124,   18,  40,   -2,   0,   -28,  -12,   -38,  -29,   -29,  -62 };
          // // float points[] = { -26,  -62,   -36,  -31,   -26,  -14,   2,  -1,   22,   40 };
          // for (  int i = 0; i < 36; i += 2 ) {
          // WFMath::Point<2> wpt(  points[i],   points[i + 1] );
          // poly.addCorner(  poly.numCorners(   ),   wpt );
          // }
          // if (  poly.numCorners(   ) ) {
          // area->setShape(  poly );
          //
          // }
          //
          // EmberOgre::getSingleton(   ).getTerrainGenerator(   )->addArea(  area );
          
           } else {
           Widget::runCommand(  command,   args );
           }
          
          }
          
     258  void MakeEntityWidget::updatePreview(   )
          {
           if (  mModelPreviewRenderer ) {
           Eris::TypeInfo* typeInfo = getSelectedTypeInfo(   );
           if (  typeInfo ) {
           ///update the model preview window
           mModelPreviewRenderer->showModel(  typeInfo->getName(   ) );
           //mModelPreviewRenderer->showFull(   );
           ///we want to zoom in a little
           mModelPreviewRenderer->setCameraDistance(  0.7 );
           } else {
           mModelPreviewRenderer->showModel(  "" );
           }
           }
          }
          
     274  bool MakeEntityWidget::typeList_ItemSelectionChanged(  const CEGUI::EventArgs& args )
          {
           updatePreview(   );
           return true;
          }
          
     280  bool MakeEntityWidget::createButton_Click(  const CEGUI::EventArgs& args )
          {
          
           Eris::TypeInfo* typeInfo = getSelectedTypeInfo(   );
           if (  typeInfo ) {
           createEntityOfType(  typeInfo );
           }
           return true;
          }
          
     290  Eris::TypeInfo* MakeEntityWidget::getSelectedTypeInfo(   )
          {
           CEGUI::ListboxItem* item = mTypeList->getFirstSelectedItem(   );
           if (  item ) {
           Eris::TypeInfo* typeinfo = static_cast<Eris::TypeInfo*>(  item->getUserData(   ) );
           return typeinfo;
           }
           return 0;
          }
          
     300  void MakeEntityWidget::createPreviewTexture(   )
          {
           CEGUI::GUISheet* imageWidget = static_cast<CEGUI::GUISheet*>(  getWindow(  "ModelPreviewImage" ) );
           if (  !imageWidget ) {
           S_LOG_FAILURE(  "Could not find ModelPreviewImage,   aborting creation of preview texture." );
           } else {
           mModelPreviewRenderer = new ModelRenderer(  imageWidget );
           }
          
          }
          
          
     312  void MakeEntityWidget::createEntityOfType(  Eris::TypeInfo* typeinfo )
          {
           Atlas::Objects::Operation::Create c;
           AvatarEmberEntity* avatar = EmberOgre::getSingleton(   ).getAvatar(   )->getAvatarEmberEntity(   );
           c->setFrom(  avatar->getId(   ) );
           ///if the avatar is a "creator",   i.e. and admin,   we will set the TO property
           ///this will bypass all of the server's filtering,   allowing us to create any entity and have it have a working mind too
           if (  avatar->getType(   )->isA(  mConn->getTypeService(   )->getTypeByName(  "creator" ) ) ) {
           c->setTo(  avatar->getId(   ) );
           }
          
           Atlas::Message::MapType msg;
           msg["loc"] = avatar->getLocation(   )->getId(   );
          
           Ogre::Vector3 o_vector(  2,  0,  0 );
           Ogre::Vector3 o_pos = avatar->getSceneNode(   )->getPosition(   ) + (  avatar->getSceneNode(   )->getOrientation(   ) * o_vector );
          
          // WFMath::Vector<3> vector(  0,  2,  0 );
          // WFMath::Point<3> pos = avatar->getPosition(   ) + (  avatar->getOrientation(   ) * vector );
           WFMath::Point<3> pos = Ogre2Atlas(  o_pos );
           WFMath::Quaternion orientation = avatar->getOrientation(   );
          
           msg["pos"] = pos.toAtlas(   );
           if (  mName->getText(   ).length(   ) > 0 ) {
           msg["name"] = mName->getText(   ).c_str(   );
           } else {
           msg["name"] = typeinfo->getName(   );
           }
           msg["parents"] = Atlas::Message::ListType(  1,   typeinfo->getName(   ) );
           msg["orientation"] = orientation.toAtlas(   );
          
           c->setArgsAsList(  Atlas::Message::ListType(  1,   msg ) );
           mConn->send(  c );
           std::stringstream ss;
           ss << pos;
           S_LOG_INFO(  "Try to create entity of type " << typeinfo->getName(   ) << " at position " << ss.str(   )  );
          
          }
          }
          
          };

./components/ogre/widgets/MakeEntityWidget.h

       1  //
          // C++ Interface: MakeEntityWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef DIMEOGREMAKEENTITYWIDGET_H
          #define DIMEOGREMAKEENTITYWIDGET_H
          
          #include "Widget.h"
          
          
          
          namespace Eris
          {
      32   class TypeInfo;
      33   class Connection;
      34   class Avatar;
          }
          
          namespace EmberOgre {
          
      39  class AvatarEmberEntity;
          namespace Gui {
          
      42  class ModelRenderer;
          /**
          @author Erik Hjortsberg
          */
      46  class MakeEntityWidget : public Widget
          {
          public:
          
      50   MakeEntityWidget(   );
      51   virtual ~MakeEntityWidget(   );
      52   virtual void buildWidget(   );
          
          
      55   virtual void show(   );
          
      57   const Ember::ConsoleCommandWrapper CreateEntity;
      58   const Ember::ConsoleCommandWrapper Make;
          
      60   virtual void runCommand(  const std::string &command,   const std::string &args );
          
          protected:
          
           /**
           flag for showing when the widget is ready to be shown
           */
      67   bool mIsReady;
          
      69   std::map<Eris::TypeInfo*,   CEGUI::ListboxItem*> mTypes;
          // std::set<Eris::TypeInfo*> mTypes;
          
      72   CEGUI::Listbox* mTypeList;
      73   CEGUI::Editbox* mName;
          
      75   Eris::Connection* mConn;
          
      77   void gotAvatar(  Eris::Avatar* avatar );
      78   void connectedToServer(  Eris::Connection* conn );
      79   void boundAType(  Eris::TypeInfo* typeInfo );
          
      81   bool createButton_Click(  const CEGUI::EventArgs& args );
          
      83   bool typeList_ItemSelectionChanged(  const CEGUI::EventArgs& args );
          
      85   Eris::TypeInfo* getSelectedTypeInfo(   );
          
          
           /**
           Loads all types into the list
           */
      91   void loadAllTypes(   );
          
      93   void addToList(  Eris::TypeInfo* typeInfo,   int level );
          
      95   void createEntityOfType(  Eris::TypeInfo* typeinfo );
          
           /**
           A preview renderer for creating new models.
           */
     100   ModelRenderer* mModelPreviewRenderer;
          
     102   void createPreviewTexture(   );
     103   void updatePreview(   );
          
          };
          };
          };
          
          #endif

./components/ogre/widgets/MeshPreview.cpp

          //
          // C++ Implementation: MeshPreview
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "MeshPreview.h"
          #include "framework/Tokeniser.h"
          #include "ColouredListItem.h"
          
          #include "framework/ConsoleBackend.h"
          #include "../EmberOgre.h"
          #include "../AvatarCamera.h"
          
          
          #include <elements/CEGUIListbox.h>
          #include <elements/CEGUIListboxItem.h>
          #include <elements/CEGUIListboxTextItem.h>
          #include <elements/CEGUIEditbox.h>
          #include <elements/CEGUIPushButton.h>
          #include <elements/CEGUISlider.h>
          
          #include "framework/Exception.h"
          
          namespace EmberOgre {
          namespace Gui {
          
          
      45  MeshPreviewHandler::MeshPreviewHandler(   ) : mEntityCounter(  0 )
          {
          }
          
      49  size_t MeshPreviewHandler::createInstance(  const std::string& meshName )
          {
           Ogre::Entity* entity = 0;
           try {
           entity = EmberOgre::getSingleton(   ).getSceneManager(   )->createEntity(  std::string(  "meshPreview_" + mEntityCounter++  ),   meshName );
           } catch (  const Ogre::Exception& ) {
           return 0;
           }
           if (  !entity ) {
           return 0;
           }
          
          
           Ogre::SceneNode* node = EmberOgre::getSingleton(   ).getWorldSceneNode(   )->createChildSceneNode(   );
          
           //place it five meters in front of the camera
           Ogre::Vector3 o_vector(  0,  0,  -5 );
           Ogre::Camera* camera = EmberOgre::getSingleton(   ).getMainCamera(   )->getCamera(   );
           Ogre::Vector3 o_pos = camera->getDerivedPosition(   ) + (  camera->getDerivedOrientation(   ) * o_vector );
           node->setPosition(  o_pos );
          
           node->attachObject(  entity );
           MeshPreviewMeshInstance instance(  entity );
           mInstances.push_back(  instance );
           //mEntities.push_back(  entity );
           //createdNewEntity(  entity,   node );
           EventCreatedInstance.emit(  mInstances.size(   ) - 1 );
           return mInstances.size(   );
          
          
          
          }
          
      82  void MeshPreviewHandler::removeInstance(  size_t index )
          {
           if (  index > mInstances.size(   ) - 1 ) {
           return;
           }
           EventRemoveInstance.emit(  index );
           MeshPreviewMeshInstance instance = getInstance(  index );
           Ogre::Entity* entity = instance.getEntity(   );
           Ogre::SceneNode* node = entity->getParentSceneNode(   );
           node->detachObject(  entity->getName(   ) );
           EmberOgre::getSingleton(   ).getSceneManager(   )->destroySceneNode(  node->getName(   ) );
           EmberOgre::getSingleton(   ).getSceneManager(   )->destroyEntity(  entity );
           InstanceStore::iterator I = mInstances.begin(   );
           for (  size_t i = 0; i < index; ++i ) {
           ++I;
           }
           mInstances.erase(  I );
          
          
          }
          
     103  void MeshPreviewHandler::updateAnimation(  Ogre::Real elapsedTime )
          {
           InstanceStore::iterator I = mInstances.begin(   );
           for (  ;I != mInstances.end(   ); ++I ) {
           I->updateAnimation(  elapsedTime );
           }
          }
          
          
     112  MeshPreviewMeshInstance& MeshPreviewHandler::getInstance(  size_t position )
          {
           if (  mInstances.size(   ) < position ) {
           throw Ember::Exception(  "Not that many instances in the store." );
           }
           return mInstances[position];
          }
          
          
          
     122  MeshPreviewMeshInstance::MeshPreviewMeshInstance(  Ogre::Entity* entity ): mEntity(  entity )
          {
          }
          
     126  void MeshPreviewMeshInstance::startAnimation(  const std::string& name )
          {
           Ogre::AnimationState* state = mEntity->getAnimationState(  name );
           state->setLoop(  true );
           if (  state == 0 ) {
           return;
           }
           state->setEnabled(  true );
           mActiveAnimations.insert(  AnimationStore::value_type(  name,   state ) );
          
          }
          
     138  void MeshPreviewMeshInstance::stopAnimation(  const std::string& name )
          {
           AnimationStore::iterator I = mActiveAnimations.find(  name );
           if (  I == mActiveAnimations.end(   ) ) {
           return;
           }
           mActiveAnimations.erase(  I );
          
          }
          
     148  void MeshPreviewMeshInstance::toggleAnimation(  const std::string& name )
          {
           if (  mActiveAnimations.find(  name ) != mActiveAnimations.end(   ) ) {
           stopAnimation(  name );
           } else {
           startAnimation(  name );
           }
          }
          
     157  void MeshPreviewMeshInstance::resetAnimations(   )
          {
           Ogre::AnimationStateSet* states = getEntity(   )->getAllAnimationStates(   );
           if (  states != 0 ) {
           Ogre::AnimationStateIterator I = states->getAnimationStateIterator (   );
           while (  I.hasMoreElements(   ) ) {
           I.getNext(   )->setEnabled(  false );
           }
           }
          
           mActiveAnimations.clear(   );
           getEntity(   )->getSkeleton(   )->reset(   );
          
          }
          
     172  void MeshPreviewMeshInstance::updateAnimation(  Ogre::Real elapsedTime )
          {
          // S_LOG_INFO(  "Updating animations. Size: " << mActiveAnimations.size(   ) );
           AnimationStore::iterator I = mActiveAnimations.begin(   );
           for (  ;I != mActiveAnimations.end(   ); ++I ) {
          // S_LOG_INFO(  "Updating " << I->second->getAnimationName(   ) << " with: " << elapsedTime );
           I->second->addTime(  elapsedTime );
           }
          }
          
     182  bool MeshPreviewMeshInstance::isAnimationPlaying(  const std::string& name )
          {
           return mActiveAnimations.find(  name ) != mActiveAnimations.end(   );
          }
          
     187  bool MeshPreviewMeshInstance::isAnimationEnabled(  const std::string& name )
          {
           Ogre::AnimationState* state = mEntity->getAnimationState(  name );
           if (  state == 0 ) {
           return false;
           }
           return state->getEnabled(   );
          
          }
          
     197  Ogre::Entity* MeshPreviewMeshInstance::getEntity(   ) const
          {
           return mEntity;
          }
          
     202  Ogre::SceneNode* MeshPreviewMeshInstance::getSceneNode(   ) const
          {
           return getEntity(   )->getParentSceneNode(   );
          }
          
          
          
     209  MeshPreview::MeshPreview(   ) : CreateMesh(  "createmesh",   this,   "Create a mesh." )
          {
     211   mHandler.EventCreatedInstance.connect(  sigc::mem_fun(  *this,   &MeshPreview::createdNewEntity ) );
     212   mHandler.EventRemoveInstance.connect(  sigc::mem_fun(  *this,   &MeshPreview::removedEntity ) );
          
          }
          
          
     217  MeshPreview::~MeshPreview(   )
          {
          }
          
     221  void MeshPreview::buildWidget(   )
          {
          
           loadMainSheet(  "MeshPreview.layout",   "MeshPreview/" );
           registerConsoleVisibilityToggleCommand(  "meshpreview" );
           enableCloseButton(   );
          
          
           //bind buttons
           CEGUI::PushButton* button;
           button = static_cast<CEGUI::PushButton*>(  getWindow(  "Create" ) );
           BIND_CEGUI_EVENT(  button,   CEGUI::ButtonBase::EventMouseClick,   MeshPreview::createButton_Click );
          
           button = static_cast<CEGUI::PushButton*>(  getWindow(  "Remove" ) );
           BIND_CEGUI_EVENT(  button,   CEGUI::ButtonBase::EventMouseClick,   MeshPreview::removeButton_Click );
          
           CEGUI::Window* meshNameBox = getWindow(  "MeshName" );
           BIND_CEGUI_EVENT(  meshNameBox,   CEGUI::Editbox::EventTextAccepted,   MeshPreview::createButton_Click )
          
          
          
           mScaleSlider = static_cast<CEGUI::Slider*>(  getWindow(  "Scale" ) );
           BIND_CEGUI_EVENT(  mScaleSlider,   CEGUI::Slider::EventValueChanged,   MeshPreview::Scale_ValueChanged );
          
          
           mNameOfMesh = static_cast<CEGUI::Editbox*>(  getWindow(  "MeshName" ) );
           mCreatedMeshes = static_cast<CEGUI::Listbox*>(  getWindow(  "CreatedMeshes" ) );
           BIND_CEGUI_EVENT(  mCreatedMeshes,   CEGUI::Listbox::EventSelectionChanged,   MeshPreview::createdMeshes_EventSelectionChanged );
          
           mAnimations = static_cast<CEGUI::Listbox*>(  getWindow(  "Animations" ) );
          
           mPlayAnimation = static_cast<CEGUI::PushButton*>(  getWindow(  "PlayAnimation" ) );
           BIND_CEGUI_EVENT(  mPlayAnimation,   CEGUI::ButtonBase::EventMouseClick,   MeshPreview::playAnimation_MouseClick );
          
           CEGUI::Window* resetButton = getWindow(  "ResetAnimation" );
           BIND_CEGUI_EVENT(  resetButton,   CEGUI::ButtonBase::EventMouseClick,   MeshPreview::resetAnimation_MouseClick );
          
          
           hide(   );
          // loadAllAvailableMeshes(   );
          
          
          
          }
          
     266  void MeshPreview::frameStarted(  const Ogre::FrameEvent& evt )
          {
           mHandler.updateAnimation(  evt.timeSinceLastFrame );
          }
          
          
     272  bool MeshPreview::createButton_Click(  const CEGUI::EventArgs& args )
          {
           if (  mNameOfMesh->getText(   ) != "" ) {
           mHandler.createInstance(  mNameOfMesh->getText(   ).c_str(   ) );
           }
           return true;
          }
          
     280  bool MeshPreview::removeButton_Click(  const CEGUI::EventArgs& args )
          {
           CEGUI::ListboxItem* item = mCreatedMeshes->getFirstSelectedItem(   );
           if (  item ) {
           size_t index = mCreatedMeshes->getItemIndex(  item );
           mHandler.removeInstance(  index );
           }
           return true;
          }
          
          
     291  bool MeshPreview::playAnimation_MouseClick(  const CEGUI::EventArgs& args )
          {
           try {
           MeshPreviewMeshInstance& instance = getActiveInstance(   );
           CEGUI::ListboxItem* item = mAnimations->getFirstSelectedItem(   );
           if (  item ) {
           std::string animationName = mAnimationNames[item->getID(   )];
           instance.toggleAnimation(  animationName );
           }
           fillAnimationList(  instance );
           } catch (  const Ember::Exception& ) {
           return true;
           }
           return true;
          }
          
     307  bool MeshPreview::resetAnimation_MouseClick(  const CEGUI::EventArgs& args )
          {
           try {
           MeshPreviewMeshInstance& instance = getActiveInstance(   );
           instance.resetAnimations(   );
           fillAnimationList(  instance );
           } catch (  const Ember::Exception& ) {
           return true;
           }
          
           return true;
          }
          
          
          
          
     323  void MeshPreview::createdNewEntity(  size_t index )
          {
           try {
           MeshPreviewMeshInstance instance = mHandler.getInstance(  index );
           Ogre::Entity* entity = instance.getEntity(   );
           CEGUI::String name(  entity->getMesh(   )->getName(   ) );
           // CEGUI::ListboxItem* item = new ColouredListItem(  name,   0,   index );
           CEGUI::ListboxItem* item = new Gui::ColouredListItem(  name,   index );
           mCreatedMeshes->addItem(  item );
          
           } catch (  const Ember::Exception& )
           {
           return;
           }
          
          }
          
     340  void MeshPreview::removedEntity(  size_t index )
          {
          // MeshPreviewMeshInstance instance = mHandler.getInstance(  index );
           CEGUI::ListboxItem* item = mCreatedMeshes->getListboxItemFromIndex(  index );
           if (  item ) {
           mCreatedMeshes->removeItem(  item );
           }
          
          }
          
     350  void MeshPreview::fillAnimationList(  MeshPreviewMeshInstance& instance  )
          {
           mAnimations->resetList(   );
           mAnimationNames.clear(   );
           Ogre::AnimationStateSet* states = instance.getEntity(   )->getAllAnimationStates(   );
           if (  states != 0 ) {
           uint i = 0;
           Ogre::AnimationStateIterator I = states->getAnimationStateIterator (   );
           while (  I.hasMoreElements(   ) ) {
           Ogre::AnimationState* state = I.getNext(   );
           mAnimationNames.push_back(  state->getAnimationName(   ) );
           std::string name(  state->getAnimationName(   ) );
           if (  instance.isAnimationPlaying(  state->getAnimationName(   ) ) ) {
           name += " (  playing )";
           } else if (  instance.isAnimationEnabled(  state->getAnimationName(   ) ) ) {
           name += " (  paused )";
           }
           CEGUI::ListboxItem* item = new Gui::ColouredListItem(  name,   i++ );
           mAnimations->addItem(  item );
          // instance.startAnimation(  I->first );
           }
           }
          }
          
     374  void MeshPreview::runCommand(  const std::string &command,   const std::string &args )
          {
           if (  CreateMesh == command ) {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string meshName = tokeniser.nextToken(   );
           if (  meshName != "" ) {
           mHandler.createInstance(  meshName );
           }
          
           } else {
           Widget::runCommand(  command,   args );
           }
          }
          
     389  bool MeshPreview::Scale_ValueChanged(  const CEGUI::EventArgs& args )
          {
           Ogre::SceneNode* node = getActiveSceneNode(   );
           if (  node ) {
           float newScale = mScaleSlider->getCurrentValue(   );
           node->setScale(  newScale,   newScale,   newScale );
           }
           return true;
          }
          
     399  Ogre::SceneNode* MeshPreview::getActiveSceneNode(   )
          {
           CEGUI::ListboxItem* item = mCreatedMeshes->getFirstSelectedItem(   );
           if (  item ) {
           size_t index = mCreatedMeshes->getItemIndex(  item );
          /* size_t index = item->getUserData(   ); */
           try {
           const MeshPreviewMeshInstance instance = mHandler.getInstance(  index );
           return instance.getSceneNode(   );
           } catch (  const Ember::Exception& ) {
           return 0;
           }
           }
           return 0;
          }
          
     415  MeshPreviewMeshInstance& MeshPreview::getActiveInstance(   )
          {
           CEGUI::ListboxItem* item = mCreatedMeshes->getFirstSelectedItem(   );
           if (  item ) {
           size_t index = mCreatedMeshes->getItemIndex(  item );
          /* size_t index = item->getUserData(   ); */
          
           return mHandler.getInstance(  index );
           }
           throw Ember::Exception(  "No selected item." );
          }
          
     427  bool MeshPreview::createdMeshes_EventSelectionChanged(  const CEGUI::EventArgs& args )
          {
           try {
           MeshPreviewMeshInstance& instance = getActiveInstance(   );
           fillAnimationList(  instance );
           } catch (  const Ember::Exception& ) {
           }
           return true;
          
          }
          }
          
          }

./components/ogre/widgets/MeshPreview.h

       1  //
          // C++ Interface: MeshPreview
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREMESHPREVIEW_H
          #define EMBEROGREMESHPREVIEW_H
          
          #include "Widget.h"
          
          #include <sigc++/signal.h>
          
          namespace EmberOgre {
          namespace Gui {
          
          typedef std::vector<Ogre::Entity*> EntityStore;
          
          
      36  class MeshPreviewHandler;
      37  class MeshPreviewMeshInstance;
          
          typedef std::vector<MeshPreviewMeshInstance> InstanceStore;
          
          /**
          Class for handling the preview of meshes. This will keep track of all the meshes that are previewed.
          */
      44  class MeshPreviewHandler
          {
          public:
      47   MeshPreviewHandler(   );
          
          
           /**
           * removes an instance of MeshPreviewMeshInstance
           * @param index
           */
      54   void removeInstance(  size_t index );
          
           /**
           * creates a new instance of MeshPreviewMeshInstance,   return the internal position of it. Use getInstance(  size_t ) to access it.
           * @param meshName a valid name of a mesh
           * @return the index of the new instance,   to be used with getInstance(  size_t )
           */
      61   size_t createInstance(  const std::string& meshName );
          
          
           /**
           * gets the MeshPreviewMeshInstance at the specified position
           * If there is no instance at the position,   an Ember::Exception will be thrown.
           * @param position
           * @return
           */
      70   MeshPreviewMeshInstance& getInstance(  size_t position );
          
           /**
           Emitted when an instance has been created.
           */
      75   sigc::signal<void,   size_t> EventCreatedInstance;
          
           /**
           Emitted when an instance has been removed.
           */
      80   sigc::signal<void,   size_t> EventRemoveInstance;
          
           /**
           Call this each fram to update the animations of all meshes.
           */
      85   void updateAnimation(  Ogre::Real elapsedTime );
          
          private:
           /**
           When creating new entities,   they need an unique name,   hence this counter.
           */
      91   size_t mEntityCounter;
          
           /**
           A store of all instances.
           */
      96   InstanceStore mInstances;
          };
          
          
          typedef std::map<std::string,   Ogre::AnimationState*> AnimationStore;
          
          /**
          Basically a container for an Ogre::Entity with some nice methods.
          */
     105  class MeshPreviewMeshInstance
          {
          public:
     108   MeshPreviewMeshInstance(  Ogre::Entity* entity );
          
          
           /**
           * Accessor for the Entity.
           * @return
           */
     115   Ogre::Entity* getEntity(   ) const;
          
           /**
           * Accessor for the SceneNode.
           * @return
           */
     121   Ogre::SceneNode* getSceneNode(   ) const;
          
           /**
           * start the animation with the given name
           * @param name
           */
     127   void startAnimation(  const std::string& name );
          
          
           /**
           * stops the animation with the given name
           * @param name
           */
     134   void stopAnimation(  const std::string& name );
          
          
           /**
           * Toggles the status of the animation with the given name on and off.
           * @param name
           */
     141   void toggleAnimation(  const std::string& name );
          
          
           /**
           * Resets all animations and return the Entity to the initial state.
           */
     147   void resetAnimations(   );
          
           /**
           * returns true if the animation with the given name is currently playing
           * @param name
           * @return
           */
     154   bool isAnimationPlaying(  const std::string& name );
          
          
           /**
           * returns true if the animation with the given name is enabled
           * @param name
           * @return
           */
     162   bool isAnimationEnabled(  const std::string& name );
          
          
           /**
           * Call this method each frame to update the animations.
           * @param elapsedTime
           */
     169   void updateAnimation(  Ogre::Real elapsedTime );
          private:
          
     172   Ogre::Entity* mEntity;
     173   AnimationStore mActiveAnimations;
           //Ogre::SceneNode* sceneNode;
          
          };
          
          
          typedef std::vector<std::string> StringStore;
          
          /**
          @author Erik Hjortsberg
          */
     184  class MeshPreview : public Widget {
          public:
     186   MeshPreview(   );
          
     188   virtual ~MeshPreview(   );
          
     190   virtual void buildWidget(   );
          
     192   const Ember::ConsoleCommandWrapper CreateMesh;
          
     194   virtual void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           * Called each frame.
           * @param evt
           */
     200   virtual void frameStarted(  const Ogre::FrameEvent& evt );
          
          private:
          
          
          
          
     207   EntityStore mEntities;
          
     209   CEGUI::Editbox* mNameOfMesh;
     210   CEGUI::Listbox* mCreatedMeshes;
     211   CEGUI::Listbox* mAnimations;
          
     213   CEGUI::Slider* mScaleSlider;
          
     215   CEGUI::PushButton* mPlayAnimation;
          
          // void loadAllAvailableMeshes(   );
          
     219   void createdNewEntity(  size_t index );
     220   void removedEntity(  size_t index );
          
     222   bool createButton_Click(  const CEGUI::EventArgs& args );
     223   bool removeButton_Click(  const CEGUI::EventArgs& args );
     224   bool playAnimation_MouseClick(  const CEGUI::EventArgs& args );
     225   bool resetAnimation_MouseClick(  const CEGUI::EventArgs& args );
          
          // void addMeshToAvailableMeshesList(  const std::string& name );
          
     229   bool createdMeshes_EventSelectionChanged(  const CEGUI::EventArgs& args );
          
     231   bool Scale_ValueChanged(  const CEGUI::EventArgs& args );
          
     233   Ogre::SceneNode* getActiveSceneNode(   );
     234   MeshPreviewMeshInstance& getActiveInstance(   );
          
     236   MeshPreviewHandler mHandler;
          
     238   void fillAnimationList(  MeshPreviewMeshInstance& instance  );
          
          // const std::string getAnimationNameAtPosition(   );
     241   StringStore mAnimationNames;
          
          };
          }
          }
          
          #endif

./components/ogre/widgets/ModelRenderer.cpp

       1  //
          // C++ Implementation: ModelRenderer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ModelRenderer.h"
          
          #include "EntityCEGUITexture.h"
          #include "../SimpleRenderContext.h"
          
          #include <elements/CEGUIGUISheet.h>
          
          #include "components/ogre/model/Model.h"
          #include "framework/Exception.h"
          
          // #include "Widget.h"
          // #include "../GUIManager.h"
          
          
          namespace EmberOgre {
          namespace Gui {
          
      40  ModelRenderer::ModelRenderer(  CEGUI::Window* image )
          : MovableObjectRenderer(  image ),   mModel(  0 )
          {
          
          }
          
          
      47  ModelRenderer::~ModelRenderer(   )
          {
          
          }
          
      52  void ModelRenderer::setModel(  Model::Model* model )
          {
           Ogre::SceneNode* node = mTexture->getRenderContext(   )->getSceneNode(   );
          
           node->detachAllObjects(   );
           if (  model ) {
           node->attachObject(  model );
           mTexture->getRenderContext(   )->repositionCamera(   );
           if (  mAutoShowFull ) {
           showFull(   );
           }
           }
          
          }
          
      67  Model::Model* ModelRenderer::getModel(   )
          {
           return mModel;
          }
          
      72  void ModelRenderer::showModel(  const std::string& modelName )
          {
           if (  mModel ) {
           mModel->_getManager(   )->destroyMovableObject(  mModel );
           //delete mModel;
           }
           if (  modelName != "" ) {
           mModel = Model::Model::createModel(  mTexture->getRenderContext(   )->getSceneManager(   ),   modelName );
          // mModel->create(  modelName );
           ///override the rendering distance from the model; we want to always show it in the preview
           mModel->setRenderingDistance(  0 );
           setModel(  mModel );
           mTexture->getRenderContext(   )->setActive(  true );
           } else {
           setModel(  0 );
           mTexture->getRenderContext(   )->setActive(  false );
           }
          }
          
          
      92  Ogre::MovableObject* ModelRenderer::getMovableObject(   )
          {
           return mModel;
          }
          }
          }

./components/ogre/widgets/ModelRenderer.h

       1  //
          // C++ Interface: ModelRenderer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREMODELRENDERER_H
          #define EMBEROGREMODELRENDERER_H
          
          
          #include "MovableObjectRenderer.h"
          
          namespace CEGUI
          {
      31   class GUISheet;
          
          }
          
          namespace EmberOgre {
          
          namespace Model {
      38   class Model;
          }
          
      41  namespace Gui {
          
          /**
          
          Renders a single Model to a CEGUI texture. Useful for stuff like inventory or preview of models.
          
          @author Erik Hjortsberg
          */
          class ModelRenderer : public MovableObjectRenderer
          {
          public:
          
           /**
           * Creates a one shot image. This is rather inexpensive,   since there's no need for rendering each frame,   but it disallows updates to the image.
           * @param image
           */
           //static void OneShotRender(  CEGUI::Window* image );
          
           /**
           * Constructir
           * @param image A valid CEGUI::StaticImage,   to which the Model will be rendered.
           * @return
           */
           ModelRenderer(  CEGUI::Window* image );
          
           virtual ~ModelRenderer(   );
          
           /**
           * Renders the submitted Model.
           * @param modelName A valid Model
           */
           void showModel(  const std::string& modelName );
          
           /**
           * Returns the current rendered Model,   or null if none is set.
           * @return
           */
           Model::Model* getModel(   );
          
          
          
          
          
          protected:
          
           /**
           * Sets the Model which should be rendered.
           * @param model
           * @return
           */
           void setModel(  Model::Model* model );
          
           Model::Model* mModel;
          
           virtual Ogre::MovableObject* getMovableObject(   );
          
          };
          }
          }
          
          #endif

./components/ogre/widgets/MovableObjectRenderer.cpp

       1  //
          // C++ Implementation: MovableObjectRenderer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "MovableObjectRenderer.h"
          
          #include "EntityCEGUITexture.h"
          #include "../SimpleRenderContext.h"
          
          #include <elements/CEGUIGUISheet.h>
          #include <CEGUIPropertyHelper.h>
          
          #include "framework/Exception.h"
          
          #include "Widget.h"
          #include "../GUIManager.h"
          
          namespace EmberOgre {
          namespace Gui {
          
      39  MovableObjectRenderer::MovableObjectRenderer(  CEGUI::Window* image )
          : mTexture(  0 ),   mIsInputCatchingAllowed(  true ),   mAutoShowFull(  true ),   mImage(  image ),   mActive(  true )
          {
           std::string name(  image->getName(   ).c_str(   ) );
           int width = static_cast<int>(  image->getPixelRect(   ).getWidth(   ) );
           int height = static_cast<int>(  image->getPixelRect(   ).getHeight(   ) );
           if (  width != 0 && height != 0 ) {
           mTexture = new EntityCEGUITexture(  name,   width,   height );
           ///most models are rotated away from the camera,   so as a convenience we'll rotate the node
           //mTexture->getSceneNode(   )->rotate(  Ogre::Vector3::UNIT_Y,  (  Ogre::Degree )180 );
          
           mImage->setProperty(  "Image",   CEGUI::PropertyHelper::imageToString(  mTexture->getImage(   ) ) );
           //mImage->setImageColours(  CEGUI::colour(  1.0f,   1.0f,   1.0f ) );
           BIND_CEGUI_EVENT(  mImage,   CEGUI::Window::EventMouseButtonDown,   MovableObjectRenderer::image_MouseButtonDown );
           BIND_CEGUI_EVENT(  mImage,   CEGUI::Window::EventMouseWheel,   MovableObjectRenderer::image_MouseWheel );
          
          
           /// Register this as a frame listener
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
           } else {
           throw Ember::Exception(  "Image dimension cannot be 0." );
           }
          }
          
          
      64  MovableObjectRenderer::~MovableObjectRenderer(   )
          {
           if (  mTexture ) {
           delete mTexture;
           }
           /// Register this as a frame listener
           Ogre::Root::getSingleton(   ).removeFrameListener(  this );
          
          }
          
      74  bool MovableObjectRenderer::injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse )
          {
           ///rotate the modelnode
           if (  GUIManager::getSingleton(   ).getInput(   ).isKeyDown(  SDLK_RCTRL ) || GUIManager::getSingleton(   ).getInput(   ).isKeyDown(  SDLK_LCTRL ) ) {
           mTexture->getRenderContext(   )->roll(  Ogre::Degree(  motion.xRelativeMovement * 180 ) );
           } else {
           mTexture->getRenderContext(   )->yaw(  Ogre::Degree(  motion.xRelativeMovement * 180 ) );
           mTexture->getRenderContext(   )->pitch(  Ogre::Degree(  motion.yRelativeMovement * 180 ) );
           }
           ///we don't want to move the cursor
           freezeMouse = true;
           return false;
          }
          
      88  Ogre::Quaternion MovableObjectRenderer::getEntityRotation(   )
          {
           return mTexture->getRenderContext(   )->getEntityRotation(   );
          }
          
      93  void MovableObjectRenderer::resetCameraOrientation(   )
          {
           mTexture->getRenderContext(   )->resetCameraOrientation(   );
          }
          
      98  void MovableObjectRenderer::pitch(  Ogre::Degree degrees )
          {
           mTexture->getRenderContext(   )->pitch(  degrees );
          }
          
     103  void MovableObjectRenderer::yaw(  Ogre::Degree degrees )
          {
           mTexture->getRenderContext(   )->yaw(  degrees );
          }
          
     108  void MovableObjectRenderer::roll(  Ogre::Degree degrees )
          {
           mTexture->getRenderContext(   )->roll(  degrees );
          }
          
          
     114  bool MovableObjectRenderer::injectMouseButtonUp(  const Input::MouseButton& button )
          {
           if (  button == Input::MouseButtonLeft ) {
           releaseInput(   );
           }
           return true;
          }
          
     122  bool MovableObjectRenderer::injectMouseButtonDown(  const Input::MouseButton& button )
          {
           return true;
          }
          
     127  bool MovableObjectRenderer::injectChar(  char character )
          {
           return true;
          }
          
     132  bool MovableObjectRenderer::injectKeyDown(  const SDLKey& key )
          {
           return true;
          }
          
     137  bool MovableObjectRenderer::injectKeyUp(  const SDLKey& key )
          {
           return true;
          }
          
     142  bool MovableObjectRenderer::getIsInputCatchingAllowed(   ) const
          {
           return mIsInputCatchingAllowed;
          }
          
     147  void MovableObjectRenderer::setIsInputCatchingAllowed(  bool allowed )
          {
           mIsInputCatchingAllowed = allowed;
          }
          
     152  bool MovableObjectRenderer::getAutoShowFull(   ) const
          {
           return mAutoShowFull;
          }
          
     157  void MovableObjectRenderer::setAutoShowFull(  bool showFull )
          {
           mAutoShowFull = showFull;
          }
          
     162  void MovableObjectRenderer::showFull(   )
          {
          // if (  mModel ) {
           mTexture->getRenderContext(   )->showFull(  getMovableObject(   ) );
          // }
          }
          
     169  void MovableObjectRenderer::setCameraDistance(  float distance )
          {
          
           mTexture->getRenderContext(   )->setCameraDistance(  mTexture->getRenderContext(   )->getDefaultCameraDistance(   ) * distance );
          /* Ogre::Vector3 position = mTexture->getDefaultCameraPosition(   );
           position.z *= distance;
           mTexture->getCamera(   )->setPosition(  position );*/
          }
          
     178  float MovableObjectRenderer::getCameraDistance(   )
          {
           return mTexture->getRenderContext(   )->getCameraDistance(   );
          }
          
     183  float MovableObjectRenderer::getAbsoluteCameraDistance(   )
          {
           return mTexture->getRenderContext(   )->getAbsoluteCameraDistance(   );
          }
          
     188  void MovableObjectRenderer::catchInput(   )
          {
           GUIManager::getSingleton(   ).getInput(   ).addAdapter(  this );
          }
          
     193  void MovableObjectRenderer::releaseInput(   )
          {
           GUIManager::getSingleton(   ).getInput(   ).removeAdapter(  this );
          }
          
     198  bool MovableObjectRenderer::image_MouseWheel(  const CEGUI::EventArgs& args )
          {
           const CEGUI::MouseEventArgs& mouseArgs = static_cast<const CEGUI::MouseEventArgs&>(  args );
          
           if (  mTexture ) {
           if (  mouseArgs.wheelChange != 0.0f ) {
           float distance = mTexture->getRenderContext(   )->getCameraDistance(   );
           distance += (  mouseArgs.wheelChange * 0.1 );
           setCameraDistance(  distance );
           }
           }
          
           return true;
          }
          
          
     214  bool MovableObjectRenderer::image_MouseButtonDown(  const CEGUI::EventArgs& args )
          {
           const CEGUI::MouseEventArgs& mouseArgs = static_cast<const CEGUI::MouseEventArgs&>(  args );
           if (  mouseArgs.button == CEGUI::LeftButton ) {
           ///only catch input if it's allowed
           if (  getIsInputCatchingAllowed(   ) ) {
           catchInput(   );
           }
           }
           return true;
          }
          
     226  bool MovableObjectRenderer::frameStarted(  const Ogre::FrameEvent& event )
          {
          // S_LOG_VERBOSE(  mImage->getName(   ).c_str(   ) << " visible: " << (  mActive && mImage->isVisible(   ) ) );
           ///if the window isn't shown,   don't update the render texture
           mTexture->getRenderContext(   )->setActive(  mActive && mImage->isVisible(   ) );
           if (  mActive && mImage->isVisible(   ) ) {
           mTexture->getRenderContext(   )->getRenderTexture(   )->update(   );
           }
           return true;
          }
          
     237  void MovableObjectRenderer::updateRender(   )
          {
           mTexture->getRenderContext(   )->getRenderTexture(   )->update(   );
          }
          
     242  void MovableObjectRenderer::setBackgroundColour(  const Ogre::ColourValue& colour )
          {
           mTexture->getRenderContext(   )->setBackgroundColour(  colour );
          }
          
     247  void MovableObjectRenderer::setBackgroundColour(  float red,   float green,   float blue,   float alpha )
          {
           mTexture->getRenderContext(   )->setBackgroundColour(  red,   green,   blue,   alpha );
          }
          
          
          }
          }

./components/ogre/widgets/MovableObjectRenderer.h

       1  //
          // C++ Interface: MovableObjectRenderer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREMOVABLEOBJECTRENDERER_H
          #define EMBEROGREMOVABLEOBJECTRENDERER_H
          
          #include <CEGUIEvent.h>
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "../input/IInputAdapter.h"
          
          namespace CEGUI
          {
      33  class GUISheet;
          }
          
          namespace EmberOgre {
          namespace Gui {
          
      39  class EntityCEGUITexture;
          
          /**
          Class used for rendering a single Ogre::MovableObject to a EntityCEGUITexture
          
          @author Erik Hjortsberg
          */
      46  class MovableObjectRenderer : public IInputAdapter,   public Ogre::FrameListener
          {
          public:
      49   MovableObjectRenderer(  CEGUI::Window* image );
          
      51   virtual ~MovableObjectRenderer(   );
          
           /**
           * Adapts the position of the camera so that the whole scene is shown.
           */
      56   void showFull(   );
          
           /**
           * Sets the distance of the camera from the Model.
           * @param distance
           */
      62   void setCameraDistance(  float distance );
          
           /**
           * Gets the distance of the camera from the Model in reltive terms with 1.0 being the optimal distance to show the full model.
           * @return
           */
      68   float getCameraDistance(   );
          
           /**
           * Gets the distance of the camera from the model in world units.
           * @return
           */
      74   float getAbsoluteCameraDistance(   );
          
          
          
          
           /**
           * Returns whether input catching (  and also rotation of the model ) is allowed.
           * Defaults to true.
           * @return
           */
      84   bool getIsInputCatchingAllowed(   ) const;
          
           /**
           * Sets whether input catching (  and also rotation of the model ) is allowed.
           * @param allowed
           */
      90   void setIsInputCatchingAllowed(  bool allowed );
          
           /**
           * Gets whether the camera should be repositioned so that the full scene is shown each time the content of the scene node updates
           * Defaults to true.
           * @return
           */
      97   void setAutoShowFull(  bool showFull );
          
           /**
           * Sets whether the camera should be repositioned so that the full scene is shown each time the content of the scene node updates
           * @return
           */
     103   bool getAutoShowFull(   ) const;
          
     105   bool getActive(   ) const {return mActive;}
     106   void setActive(  bool isActive ) {mActive = isActive;}
          
          /**
          ---------Methods implemented from IInputAdapter
          @see IInputAdapter
          */
     112   virtual bool injectMouseMove(  const MouseMotion& motion,   bool& freezeMouse );
     113   virtual bool injectMouseButtonUp(  const Input::MouseButton& button );
     114   virtual bool injectMouseButtonDown(  const Input::MouseButton& button );
     115   virtual bool injectChar(  char character );
     116   virtual bool injectKeyDown(  const SDLKey& key );
     117   virtual bool injectKeyUp(  const SDLKey& key );
          
          
           /**
           * Methods from Ogre::FrameListener
           */
     123   virtual bool frameStarted(  const Ogre::FrameEvent& event );
          
          
           /**
           * Gets the rotation of the entity.
           * @return
           */
     130   Ogre::Quaternion getEntityRotation(   );
          
          
           /**
           * Resets the orientation of the camera.
           */
     136   void resetCameraOrientation(   );
          
           /**
           * Pitches the camera.
           * @param degrees The amount of degrees to pitch.
           */
     142   void pitch(  Ogre::Degree degrees );
          
           /**
           * Yaws the camera.
           * @param degrees The amount of degree to yaw.
           */
     148   void yaw(  Ogre::Degree degrees );
          
           /**
           * Rolls the camera.
           * @param degrees The amount of degree to roll.
           */
     154   void roll(  Ogre::Degree degrees );
          
           /**
           * Updates the texture by rendering one frame manually.
           */
     159   void updateRender(   );
          
           /**
           * Sets the background colour.
           * @param colour
           */
     165   void setBackgroundColour(  const Ogre::ColourValue& colour );
           /**
           * Sets the background colour.
           * @param red
           * @param green
           * @param blue
           * @param
           */
     173   void setBackgroundColour(  float red,   float green,   float blue,   float alpha );
          
          
          protected:
          
           /**
           * Catches input and allows for rotation of the Model
           * @see releaseInput
           */
     182   void catchInput(   );
          
           /**
           * Releases input caught with catchInput
           * @see catchInput
           */
     188   void releaseInput(   );
          
          
           /**CEGUI::StaticImage* image
           * When the mouse button is pressed over the image,   catch input and allow for rotation of the model. When the mouse button is releases,   also release input.
           * @param args
           * @return
           */
     196   bool image_MouseButtonDown(  const CEGUI::EventArgs& args );
          
          
           /**
           * Mouse wheel movements will zoom in and out.
           * @param args
           * @return
           */
     204   bool image_MouseWheel(  const CEGUI::EventArgs& args );
          
     206   EntityCEGUITexture* mTexture;
           /**
           If true,   the input will be caught when the user clicks on the image,   allowing for rotation of the model.
           */
     210   bool mIsInputCatchingAllowed;
          
           /**
           used to decide if the camera should be repositioned so that the full scene is shown each time the content of the scene node updates
           */
     215   bool mAutoShowFull;
          
     217   CEGUI::Window* mImage;
          
     219   virtual Ogre::MovableObject* getMovableObject(   ) = 0;
          
     221   bool mActive;
          
          };
          }
          }
          
          #endif

./components/ogre/widgets/OgreEntityRenderer.cpp

       1  //
          // C++ Implementation: OgreEntityRenderer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OgreEntityRenderer.h"
          #include "EntityCEGUITexture.h"
          #include "../SimpleRenderContext.h"
          
          #include <elements/CEGUIGUISheet.h>
          
          namespace EmberOgre {
          namespace Gui {
          
      32  OgreEntityRenderer::OgreEntityRenderer(  CEGUI::Window* image ) : MovableObjectRenderer(  image ),   mEntity(  0 )
          {
          }
          
          
      37  OgreEntityRenderer::~OgreEntityRenderer(   )
          {
          }
          
      41  Ogre::Entity* OgreEntityRenderer::getEntity(   )
          {
           return mEntity;
          }
          
      46  void OgreEntityRenderer::showEntity(  const std::string& mesh )
          {
           if (  mEntity ) {
           mTexture->getRenderContext(   )->getSceneNode(   )->getCreator(   )->destroyEntity(  mEntity );
           }
           std::string meshName(  mTexture->getImage(   )->getName(   ).c_str(   ) );
           meshName += "_entity";
           try {
           mEntity = mTexture->getRenderContext(   )->getSceneNode(   )->getCreator(   )->createEntity(  meshName ,   mesh );
           setEntity(  mEntity );
           mTexture->getRenderContext(   )->setActive(  true );
           } catch (  const Ogre::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating entity. Message: " << ex.getFullDescription(   ) );
           }
          }
          
          
      63  Ogre::MovableObject* OgreEntityRenderer::getMovableObject(   )
          {
           return mEntity;
          }
          
      68  void OgreEntityRenderer::setEntity(  Ogre::Entity* entity )
          {
           Ogre::SceneNode* node = mTexture->getRenderContext(   )->getSceneNode(   );
          
           node->detachAllObjects(   );
           node->attachObject(  entity );
           mTexture->getRenderContext(   )->repositionCamera(   );
           if (  mAutoShowFull ) {
           showFull(   );
           }
          
          }
          }
          }

./components/ogre/widgets/OgreEntityRenderer.h

       1  //
          // C++ Interface: OgreEntityRenderer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREOGREENTITYRENDERER_H
          #define EMBEROGREOGREENTITYRENDERER_H
          
          #include "MovableObjectRenderer.h"
          
          namespace EmberOgre {
          namespace Gui {
          
          /**
          Renders a single Ogre::Entity to a EntityCEGUITexture.
          
          @author Erik Hjortsberg
          */
      36  class OgreEntityRenderer : public MovableObjectRenderer
          {
          public:
      39   OgreEntityRenderer(  CEGUI::Window* image );
          
      41   virtual ~OgreEntityRenderer(   );
          
           /**
           * Renders the submitted Entity.
           * @param modelName a mesh namel
           */
      47   void showEntity(  const std::string& mesh );
          
           /**
           * Returns the current rendered Entity,   or null if none is set.
           * @return
           */
      53   Ogre::Entity* getEntity(   );
          
          protected:
          
      57   Ogre::Entity* mEntity;
          
      59   virtual Ogre::MovableObject* getMovableObject(   );
      60   void setEntity(  Ogre::Entity* entity );
          
          
          };
          }
          }
          
          #endif

./components/ogre/widgets/QuaternionAdapter.cpp

       1  //
          // C++ Implementation: QuaternionAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "QuaternionAdapter.h"
          #include "Widget.h"
          
          #include <CEGUIWindow.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
      32  QuaternionAdapter::QuaternionAdapter(  CEGUI::Window *degreeWindow,   CEGUI::Window *xWindow,   CEGUI::Window *yWindow,   CEGUI::Window *zWindow,   const Ogre::Quaternion& quaternion )
          : mQuaternion(  quaternion ),   mOriginalQuaternion(  quaternion ),   mVectorAdapter(  xWindow,   yWindow,   zWindow ),   mDegreeWindow(  degreeWindow ),   mSelfUpdate(  false )
          {
           if (  degreeWindow ) {
           BIND_CEGUI_EVENT(  degreeWindow,   CEGUI::Window::EventTextChanged,   QuaternionAdapter::window_TextChanged );
           }
           mVectorAdapter.EventValueChanged.connect(  sigc::mem_fun(  *this,   &QuaternionAdapter::vectorAdapter_ValueChanged ) );
          
          }
          
      42  QuaternionAdapter::~QuaternionAdapter(   )
          {
          }
          
      46  void QuaternionAdapter::setValue(  const Ogre::Quaternion& quaternion )
          {
           updateGui(  quaternion );
           EventValueChanged.emit(   );
          }
          
          
      53  const Ogre::Quaternion& QuaternionAdapter::getValue(   ) const
          {
           const Ogre::Vector3& axis = mVectorAdapter.getValue(   );
           float degrees = 0;
           if (  mDegreeWindow ) {
           degrees = Ogre::StringConverter::parseReal(   mDegreeWindow->getText(   ).c_str(   ) );
           }
          
           mQuaternion.FromAngleAxis(  Ogre::Degree(  degrees ),   axis );
           return mQuaternion;
          }
          
      65  const Ogre::Quaternion& QuaternionAdapter::getOriginalValue(   ) const
          {
           return mOriginalQuaternion;
          }
          
      70  void QuaternionAdapter::updateGui(  const Ogre::Quaternion& quaternion )
          {
           mSelfUpdate = true;
          
           if (  &quaternion ) {
           Ogre::Vector3 axis;
           Ogre::Degree angle;
           quaternion.ToAngleAxis(   angle,   axis );
           mVectorAdapter.updateGui(  axis );
           if (  mDegreeWindow ) {
           mDegreeWindow->setText(  Ogre::StringConverter::toString(  angle.valueDegrees(   ) ) );
           }
           } else {
           mVectorAdapter.updateGui(  Ogre::Vector3::ZERO );
           if (  mDegreeWindow ) {
           mDegreeWindow->setText(  "" );
           }
           }
           mSelfUpdate = false;
          }
          
      91  bool QuaternionAdapter::window_TextChanged(  const CEGUI::EventArgs& e )
          {
           if (  !mSelfUpdate ) {
           EventValueChanged.emit(   );
           }
           return true;
          }
          
      99  void QuaternionAdapter::vectorAdapter_ValueChanged(   )
          {
           if (  !mSelfUpdate ) {
           EventValueChanged.emit(   );
           }
          }
          
          }
          
          }

./components/ogre/widgets/QuaternionAdapter.h

          //
          // C++ Interface: QuaternionAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_CEGUIQUATERNIONADAPTER_H
          #define EMBEROGRE_CEGUIQUATERNIONADAPTER_H
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include "Vector3Adapter.h"
          
          namespace CEGUI
          {
      30   class Window;
      31   class EventArgs;
          
          }
          
          
          namespace EmberOgre {
          
          namespace Gui {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      43  class QuaternionAdapter{
          public:
      45   QuaternionAdapter(  CEGUI::Window *degreeWindow,   CEGUI::Window *xWindow,   CEGUI::Window *yWindow,   CEGUI::Window *zWindow,   const Ogre::Quaternion& quaternion = Ogre::Quaternion::ZERO );
          
      47   ~QuaternionAdapter(   );
          
          
      50   const Ogre::Quaternion& getValue(   ) const;
      51   const Ogre::Quaternion& getOriginalValue(   ) const;
          
          
           /**
           Sets the value,   thus also updating the gui.
           */
      57   void setValue(  const Ogre::Quaternion& quaternion );
          
           /**
           Updates the gui with new values.
           */
      62   void updateGui(  const Ogre::Quaternion& vector );
          
           /**
           Emitted when the value has been changed from a gui update.
           */
      67   sigc::signal<void> EventValueChanged;
          
          private:
          
           mutable Ogre::Quaternion mQuaternion;
           Ogre::Quaternion mOriginalQuaternion;
          
           /**
           A Vector3Adapter which takes care of the vector part.
           */
           Vector3Adapter mVectorAdapter;
           //CEGUI::Window mXWindow,   m
          
           /**
           The window which holds the degree value.
           */
           CEGUI::Window *mDegreeWindow;
          
      85   bool window_TextChanged(  const CEGUI::EventArgs& e );
          
           bool mSelfUpdate;
          
      89   void vectorAdapter_ValueChanged(   );
          
          };
          }
          
          }
          
          #endif

./components/ogre/widgets/Quit.cpp

          //
          // C++ Implementation: Quit
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Quit.h"
          // #include "../EmberOgre.h"
          #include "main/Application.h"
          #include <elements/CEGUIPushButton.h>
          
          #include "framework/ConsoleBackend.h"
          #include "../GUIManager.h"
          #include "../input/Input.h"
          
          namespace EmberOgre {
          namespace Gui {
          
      35  Quit::Quit(   ) : SoftQuit(  "softquit",   this,   "Display a quit confirmation window." )
          {
          }
          
          
      40  Quit::~Quit(   )
          {
          }
          
      44  void Quit::buildWidget(   )
          {
          
           loadMainSheet(  "Quit.layout",   "Quit/" );
          
           Ember::Application::getSingleton(   ).EventRequestQuit.connect(  sigc::mem_fun(  *this,   &Quit::EmberOgre_RequestQuit ) );
          
           CEGUI::PushButton* yesButton = static_cast<CEGUI::PushButton*>(  getWindow(  "YesButton" ) );
           CEGUI::PushButton* noButton = static_cast<CEGUI::PushButton*>(  getWindow(  "NoButton" ) );
          
           if (  yesButton ) {
           BIND_CEGUI_EVENT(  noButton,   CEGUI::ButtonBase::EventMouseClick,  Quit::No_Click  );
           }
           if (  noButton ) {
           BIND_CEGUI_EVENT(  yesButton,   CEGUI::ButtonBase::EventMouseClick,  Quit::Yes_Click  );
           }
          
           registerConsoleVisibilityToggleCommand(  "quit" );
           enableCloseButton(   );
          
           mMainWindow->setVisible(  false );
          }
          
      67  bool Quit::Yes_Click(  const CEGUI::EventArgs& args )
          {
           Ember::Application::getSingleton(   ).quit(   );
           return true;
          }
          
      73  bool Quit::No_Click(  const CEGUI::EventArgs& args )
          {
           mMainWindow->setVisible(  false );
           return true;
          }
          
          
      80  void Quit::EmberOgre_RequestQuit(  bool& handled )
          {
           handled = true;
           //if the window system twice requests a quit,   do it
           if (  mMainWindow->isVisible(   ) ) {
           Ember::Application::getSingleton(   ).quit(   );
           } else {
           softquit(   );
           }
          }
          
      91  void Quit::softquit(   )
          {
           mMainWindow->activate(   );
           mMainWindow->moveToFront(   );
           mMainWindow->setVisible(  true );
          
           mGuiManager->getInput(   ).setInputMode(  Input::IM_GUI );
           //mMainWindow->setModalState(  true );
          }
          
     101  void Quit::hide(   )
          {
           //mMainWindow->setModalState(  false );
          }
          
          
     107  void Quit::runCommand(  const std::string &command,   const std::string &args )
          {
           if(  SoftQuit == command )
           {
           softquit(   );
           } else {
           Widget::runCommand(  command,   args );
           }
          
          }
          }
          };

./components/ogre/widgets/Quit.h

       1  //
          // C++ Interface: Quit
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREQUIT_H
          #define EMBEROGREQUIT_H
          
          #include "Widget.h"
          
          namespace EmberOgre {
          namespace Gui {
          
          /**
          @author Erik Hjortsberg
          */
      34  class Quit : public Widget
          {
          public:
      37   Quit(   );
          
      39   virtual ~Quit(   );
          
      41   virtual void buildWidget(   );
      42   virtual void runCommand(  const std::string &command,   const std::string &args );
          
      44   const Ember::ConsoleCommandWrapper SoftQuit;
          
          
           /**
           * overloaded to remove the modal state
           */
      50   virtual void hide(   );
          
          protected:
          
      54   bool Yes_Click(  const CEGUI::EventArgs& args );
      55   bool No_Click(  const CEGUI::EventArgs& args );
          
      57   void EmberOgre_RequestQuit(  bool& handled );
          
      59   void softquit(   );
          
          };
          };
          };
          
          #endif

./components/ogre/widgets/ServerWidget.cpp

       1  //
          // C++ Implementation: ServerWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "services/server/ServerService.h"
          #include <Eris/Metaserver.h>
          #include <Eris/ServerInfo.h>
          #include <Eris/Connection.h>
          #include <Eris/TypeInfo.h>
          #include <Eris/TypeService.h>
          #include "services/EmberServices.h"
          
          #include "Widget.h"
          #include "ColouredListItem.h"
          #include "../GUIManager.h"
          
          #include "ServerWidget.h"
          
          #include <elements/CEGUIListbox.h>
          #include <elements/CEGUIListboxItem.h>
          #include <elements/CEGUIListboxTextItem.h>
          #include <elements/CEGUIPushButton.h>
          #include <elements/CEGUIEditbox.h>
          #include <elements/CEGUIMultiLineEditbox.h>
          #include <elements/CEGUIRadioButton.h>
          #include <elements/CEGUIComboDropList.h>
          #include <elements/CEGUICombobox.h>
          #include <elements/CEGUITabControl.h>
          #include <elements/CEGUIGUISheet.h>
          
          #include "ModelRenderer.h"
          
          #include "components/ogre/model/mapping/ModelMappingManager.h"
          #include "components/ogre/model/mapping/ModelMapping.h"
          #include "components/ogre/model/mapping/Definitions/ModelMappingDefinition.h"
          #include "components/ogre/model/mapping/Definitions/MatchDefinition.h"
          #include "components/ogre/model/mapping/Definitions/CaseDefinition.h"
          #include "components/ogre/model/mapping/Definitions/ActionDefinition.h"
          #include "components/ogre/model/mapping/EmberModelMappingManager.h"
          
          
          using namespace CEGUI;
          namespace EmberOgre {
          namespace Gui {
          
          
          
          /*template<> WidgetLoader WidgetLoaderHolder<ServerWidget>::loader(  "ServerWidget",   &createWidgetInstance );*/
          //WidgetLoader Widget::loader(  "ServerWidget",   &createWidgetInstance<ServerWidget> );
          
      70  ServerWidget::ServerWidget(   ) : mModelPreviewRenderer(  0 )
          {
          }
          
          
      75  ServerWidget::~ServerWidget(   )
          {
           delete mModelPreviewRenderer;
          }
          
      80  void ServerWidget::buildWidget(   )
          {
          
          
           loadMainSheet(  "ServerWidget.layout",   "Server/" );
           mMainWindow->setVisible(  false );
          
           CEGUI::PushButton* login = static_cast<CEGUI::PushButton*>(  getWindow(  "LoginPanel/Login" ) );
           BIND_CEGUI_EVENT(  login,   CEGUI::ButtonBase::EventMouseClick,   ServerWidget::Login_Click );
           CEGUI::PushButton* createAcc = static_cast<CEGUI::PushButton*>(  getWindow(  "LoginPanel/CreateAcc" ) );
           BIND_CEGUI_EVENT(  createAcc,   CEGUI::ButtonBase::EventMouseClick,   ServerWidget::CreateAcc_Click );
          
           mCharacterList = static_cast<CEGUI::Listbox*>(  getWindow(  "ChooseCharacterPanel/CharacterList" ) );
           CEGUI::PushButton* chooseChar = static_cast<CEGUI::PushButton*>(  getWindow(  "ChooseCharacterPanel/Choose" ) );
           mUseCreator = static_cast<CEGUI::PushButton*>(  getWindow(  "UseCreator" ) );
           mCreateChar = static_cast<CEGUI::PushButton*>(  getWindow(  "CreateCharacterPanel/CreateButton" ) );
          
           BIND_CEGUI_EVENT(  chooseChar,   CEGUI::ButtonBase::EventMouseClick,   ServerWidget::Choose_Click );
           BIND_CEGUI_EVENT(  mUseCreator,   CEGUI::ButtonBase::EventMouseClick,   ServerWidget::UseCreator_Click );
           BIND_CEGUI_EVENT(  mCreateChar,   CEGUI::ButtonBase::EventMouseClick,   ServerWidget::CreateChar_Click );
           BIND_CEGUI_EVENT(  mCharacterList,   CEGUI::ButtonBase::EventMouseDoubleClick,   ServerWidget::Choose_Click );
          
           mNewCharName = static_cast<CEGUI::Editbox*>(  getWindow(  "CreateCharacterPanel/NameEdit" ) );
           mNewCharDescription = static_cast<CEGUI::MultiLineEditbox*>(  getWindow(  "CreateCharacterPanel/Description" ) );
           mTypesList = static_cast<CEGUI::Combobox*>(  getWindow(  "CreateCharacterPanel/Type" ) );
          
           mGenderRadioButton = static_cast<CEGUI::RadioButton*>(  getWindow(  "CreateCharacterPanel/Gender/Male" ) );
           CEGUI::RadioButton* femaleRadioButton = static_cast<CEGUI::RadioButton*>(  getWindow(  "CreateCharacterPanel/Gender/Female" ) );
          
           BIND_CEGUI_EVENT(  mNewCharName,   CEGUI::Editbox::EventTextChanged,   ServerWidget::Name_TextChanged );
           BIND_CEGUI_EVENT(  mNewCharDescription,   CEGUI::Editbox::EventTextChanged,   ServerWidget::Description_TextChanged );
           BIND_CEGUI_EVENT(  mTypesList,   CEGUI::Combobox::EventListSelectionChanged,   ServerWidget::TypesList_SelectionChanged );
           BIND_CEGUI_EVENT(  mGenderRadioButton,   CEGUI::RadioButton::EventSelectStateChanged,   ServerWidget::Gender_SelectionChanged );
           BIND_CEGUI_EVENT(  femaleRadioButton,   CEGUI::RadioButton::EventSelectStateChanged,   ServerWidget::Gender_SelectionChanged );
          
          
           updateNewCharacter(   );
          
           CEGUI::Window* nameBox = getWindow(  "LoginPanel/NameEdit" );
           CEGUI::Window* passwordBox = getWindow(  "LoginPanel/PasswordEdit" );
           BIND_CEGUI_EVENT(  nameBox,   CEGUI::Window::EventTextChanged,   ServerWidget::nameBox_TextChanged );
           BIND_CEGUI_EVENT(  passwordBox,   CEGUI::Window::EventTextChanged,   ServerWidget::passwordBox_TextChanged );
          
          
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->GotConnection.connect(  sigc::mem_fun(  *this,   &ServerWidget::connection_GotConnection ) );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->GotAccount.connect(  sigc::mem_fun(  *this,   &ServerWidget::createdAccount ) );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->LoginSuccess.connect(  sigc::mem_fun(  *this,   &ServerWidget::loginSuccess ) );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->GotAvatar.connect(  sigc::mem_fun(  *this,   &ServerWidget::gotAvatar ) );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->GotAllCharacters.connect(  sigc::mem_fun(  *this,   &ServerWidget::gotAllCharacters ) );
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->LoginFailure.connect(  sigc::mem_fun(  *this,   &ServerWidget::showLoginFailure ) );
          
           addTabbableWindow(  getWindow(  "LoginPanel/NameEdit" ) );
           addTabbableWindow(  getWindow(  "LoginPanel/PasswordEdit" ) );
           addEnterButton(  login );
          /* addTabbableWindow(  login );
           addTabbableWindow(  createAcc );*/
           closeTabGroup(   );
          
           addTabbableWindow(  mNewCharName );
          // addTabbableWindow(  mTypesList );
          /* addTabbableWindow(  mGenderRadioButton );
           addTabbableWindow(  femaleRadioButton );*/
           addTabbableWindow(  mNewCharDescription );
           addEnterButton(  mCreateChar );
           closeTabGroup(   );
          
           hide(   );
          
           createPreviewTexture(   );
          // getMainSheet(   )->addChildWindow(  mMainWindow );
          
          }
          
     153  void ServerWidget::connection_GotServerInfo(   )
          {
           showServerInfo(   );
          }
          
     158  void ServerWidget::connection_GotConnection(  Eris::Connection* connection )
          {
           connection->GotServerInfo.connect(  sigc::mem_fun(  *this,   &ServerWidget::connection_GotServerInfo ) );
           connection->refreshServerInfo(   );
          }
          
          
     165  void ServerWidget::createdAccount(  Eris::Account* account )
          {
          
           mAccount = account;
           show(   );
           mMainWindow->moveToFront(   );
          }
          
     173  void ServerWidget::showServerInfo(   )
          {
           try {
           CEGUI::Window* info = getWindow(  "Info" );
           assert(  mAccount );
           Eris::ServerInfo sInfo;
           mAccount->getConnection(   )->getServerInfo(  sInfo );
           std::stringstream ss;
           ss << "Server name: " << sInfo.getServername(   ) << "\n";
           ss << "Ruleset: " << sInfo.getRuleset(   ) << "\n";
           ss << "Server type: " << sInfo.getServer(   ) << " (  v. "<< sInfo.getVersion(   ) << " )\n";
           ss << "Ping: " << sInfo.getPing(   ) << "\n";
           ss << "Uptime: " << static_cast<int>(  sInfo.getUptime(   ) / (  60*60*24 ) ) << " days\n";
           ss << "Number of clients: " << sInfo.getNumClients(   ) << "\n";
           info->setText(  ss.str(   ) );
           } catch (  ... ) {
           S_LOG_WARNING(  "Error when getting the server info window." );
           return;
           }
          }
          
     194  void ServerWidget::loginSuccess(  Eris::Account* account )
          {
           getWindow(  "LoginPanel" )->setVisible(  false );
           getWindow(  "CharacterTabControl" )->setVisible(  true );
           account->refreshCharacterInfo(   );
           fillAllowedCharacterTypes(  account );
          
          }
          
     203  void ServerWidget::showLoginFailure(  Eris::Account* account,   std::string msg )
          {
           CEGUI::GUISheet* helpText = static_cast<CEGUI::GUISheet*>(  getWindow(  "LoginPanel/HelpText" ) );
           helpText->setYPosition(  UDim(  0.6,   0 ) );
          
           CEGUI::GUISheet* loginFailure = static_cast<CEGUI::GUISheet*>(  getWindow(  "LoginPanel/LoginFailure" ) );
           loginFailure->setText(  msg );
           loginFailure->setVisible(  true );
          }
          
     213  bool ServerWidget::hideLoginFailure(   )
          {
           CEGUI::GUISheet* helpText = static_cast<CEGUI::GUISheet*>(  getWindow(  "LoginPanel/HelpText" ) );
           helpText->setYPosition(  UDim(  0.55,   0 ) );
          
           CEGUI::GUISheet* loginFailure = static_cast<CEGUI::GUISheet*>(  getWindow(  "LoginPanel/LoginFailure" ) );
           loginFailure->setVisible(  false );
          
           return true;
          }
          
     224  bool ServerWidget::passwordBox_TextChanged(  const CEGUI::EventArgs& args )
          {
           hideLoginFailure(   );
          
           return true;
          }
          
     231  bool ServerWidget::nameBox_TextChanged(  const CEGUI::EventArgs& args )
          {
           hideLoginFailure(   );
          
           return true;
          }
          
     238  void ServerWidget::fillAllowedCharacterTypes(  Eris::Account* account )
          {
           const std::vector< std::string >& characters = account->getCharacterTypes(   );
          
           for(  std::vector< std::string >::const_iterator I = characters.begin(   ); I != characters.end(   ); ++I ) {
          
           ///if the user has access to the "creator" character,   he/she can log in as this to get admin privileges
           ///thus we active our special "admin button"
           if (  *I == "creator" ) {
           mUseCreator->setVisible(  true );
           mUseCreator->setEnabled(  true );
           }
          
           CEGUI::ListboxItem* item = new Gui::ColouredListItem(  *I,   0,   0 );
           mTypesList->addItem(  item );
           }
          }
          
     256  void ServerWidget::gotAllCharacters(  Eris::Account* account )
          {
           Eris::CharacterMap cm = account->getCharacters(   );
           Eris::CharacterMap::iterator I = cm.begin(   );
           Eris::CharacterMap::iterator I_end = cm.end(   );
          
           if (  I == I_end ) {
           //if the user has no previous characters,   show the create character tab
          
           CEGUI::TabControl* tabControl = static_cast<CEGUI::TabControl*>(  getWindow(  "CharacterTabControl" ) );
           if (  tabControl ) {
           //try {
           tabControl->setSelectedTab(  getPrefix(   ) + "CreateCharacterPanel" );
           //} catch (  ... ) {};
           }
           } else {
          
           for(  ;I != I_end; ++I ) {
           const Atlas::Objects::Entity::RootEntity& entity = (  *I ).second;
          
           std::string itemText(  "" );
           if (  entity->hasAttr(  "name" ) ) {
           const Atlas::Message::Element& nameElement = entity->getAttr(  "name" );
           if (  nameElement.isString(   ) ) {
           itemText += nameElement.asString(   );
           }
           }
           Gui::ColouredListItem* item = new Gui::ColouredListItem(  itemText );
           std::string* id = new std::string(  entity->getId(   ) );
           item->setUserData(  id );
           mCharacterList->addItem(  item );
           }
           }
          
          }
          
     292  bool ServerWidget::Choose_Click(  const CEGUI::EventArgs& args )
          {
           CEGUI::ListboxItem* item = mCharacterList->getFirstSelectedItem(   );
           if (  item ) {
          /* const Atlas::Objects::Entity::GameEntity & entity = static_cast<const Atlas::Objects::Entity::GameEntity &>(  item->getUserData(   ) );*/
          
           std::string* id = static_cast<std::string*>(  item->getUserData(   ) );
          
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->takeCharacter(  *id );
           }
           return true;
          }
          
     305  bool ServerWidget::UseCreator_Click(  const CEGUI::EventArgs& args )
          {
           ///create a new admin character
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->createCharacter(  "Lordi",   "female",   "creator",   "Almighty" );
           return true;
          }
          
          
     313  bool ServerWidget::CreateChar_Click(  const CEGUI::EventArgs& args )
          {
          
           Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->createCharacter(  mNewChar.name,   mNewChar.gender,   mNewChar.type,   mNewChar.description );
           return true;
          }
          
     320  bool ServerWidget::TypesList_SelectionChanged(  const CEGUI::EventArgs& args )
          {
           CEGUI::ListboxItem* item = mTypesList->getSelectedItem(   );
           if (  item ) {
          
           std::string type = item->getText(   ).c_str(   );
           mNewChar.type = type;
          
           if (  mModelPreviewRenderer ) {
          
           ///we need to get the model mapping definition for this type
           ///once we have that,   we will check for the first action of the first case of the first match (  since that's guaranteed to be a show-model action
           Eris::TypeService* typeService = Ember::EmberServices::getSingletonPtr(   )->getServerService(   )->getConnection(   )->getTypeService(   );
           Eris::TypeInfo* erisType = typeService->getTypeByName(  type );
           if (  erisType ) {
           const Model::Mapping::Definitions::ModelMappingDefinition* definition = Model::Mapping::EmberModelMappingManager::getSingleton(   ).getManager(   ).getDefinitionForType(  erisType );
           if (  definition ) {
           Model::Mapping::Definitions::MatchDefinition::CaseStore::const_iterator first = definition->getRoot(   ).getCases(   ).begin(   );
           if (  first != definition->getRoot(   ).getCases(   ).end(   ) ) {
           const Model::Mapping::Definitions::CaseDefinition& firstCase = *first;
           if (  firstCase.getActions(   ).begin(   ) != firstCase.getActions(   ).end(   ) ) {
           const Model::Mapping::Definitions::ActionDefinition& firstAction = *firstCase.getActions(   ).begin(   );
           if (  firstAction.getType(   ) == "display-model" ) {
           ///update the model preview window
           mModelPreviewRenderer->showModel(  firstAction.getValue(   ) );
           //mModelPreviewRenderer->showFull(   );
           ///we want to zoom in a little
           mModelPreviewRenderer->setCameraDistance(  0.7 );
           }
           }
           }
           }
           }
           }
           }
           updateNewCharacter(   );
           return true;
          }
     358  bool ServerWidget::Gender_SelectionChanged(  const CEGUI::EventArgs& args )
          {
           CEGUI::RadioButton* selected = mGenderRadioButton->getSelectedButtonInGroup(   );
           mNewChar.gender = selected->getText(   ).c_str(   );
          
           updateNewCharacter(   );
           return true;
          }
     366  bool ServerWidget::Name_TextChanged(  const CEGUI::EventArgs& args )
          {
           std::string name = mNewCharName->getText(   ).c_str(   );
           mNewChar.name = name;
           updateNewCharacter(   );
          
           return true;
          }
     374  bool ServerWidget::Description_TextChanged(  const CEGUI::EventArgs& args )
          {
           std::string description = mNewCharDescription->getText(   ).c_str(   );
           mNewChar.description = description;
           updateNewCharacter(   );
           return true;
          }
          
     382  void ServerWidget::updateNewCharacter(   )
          {
           mCreateChar->setEnabled(  mNewChar.isValid(   ) );
          }
          
          
          
          
     390  bool ServerWidget::Login_Click(  const CEGUI::EventArgs& args )
          {
           CEGUI::Window* nameBox = getWindow(  "LoginPanel/NameEdit" );
           CEGUI::Window* passwordBox = getWindow(  "LoginPanel/PasswordEdit" );
          
           CEGUI::String name = nameBox->getText(   );
           CEGUI::String password = passwordBox->getText(   );
          
           mAccount->login(  std::string(  name.c_str(   ) ),   std::string(  password.c_str(   ) ) );
          
           return true;
          }
          
     403  bool ServerWidget::CreateAcc_Click(  const CEGUI::EventArgs& args )
          {
           CEGUI::Window* nameBox = getWindow(  "LoginPanel/NameEdit" );
           CEGUI::Window* passwordBox = getWindow(  "LoginPanel/PasswordEdit" );
          
           CEGUI::String name = nameBox->getText(   );
           CEGUI::String password = passwordBox->getText(   );
          
           mAccount->createAccount(  std::string(  name.c_str(   ) ),  std::string(  name.c_str(   ) ),  std::string(  password.c_str(   ) ) );
           return true;
          }
          
     415  void ServerWidget::gotAvatar(  Eris::Avatar* avatar )
          {
           hide(   );
          /* mGuiManager->removeWidget(  this );
           delete this;*/
          }
          
     422  void ServerWidget::createPreviewTexture(   )
          {
           CEGUI::GUISheet* imageWidget = static_cast<CEGUI::GUISheet*>(  getWindow(  "CreateCharacterPanel/Image" ) );
           if (  !imageWidget ) {
           S_LOG_FAILURE(  "Could not find CreateCharacterPanel/Image,   aborting creation of preview texture." );
           } else {
           mModelPreviewRenderer = new ModelRenderer(  imageWidget );
           }
          
          }
          
     433  bool NewCharacter::isValid(    ) const
          {
           return name != "" && gender != "" && type != "";
          }
          
          
          };
          };
          
          

./components/ogre/widgets/ServerWidget.h

       1  //
          // C++ Interface: ServerWidget
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2004
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef DIMEOGRESERVERWIDGET_H
          #define DIMEOGRESERVERWIDGET_H
          
          #include <Eris/ServerInfo.h>
          #include <Eris/Connection.h>
          #include <Eris/Avatar.h>
          #include <Eris/Account.h>
          
          #include <Atlas/Objects/Entity.h>
          #include <Atlas/Message/Element.h>
          
          #include "Widget.h"
          
          
          namespace EmberOgre {
          
          
      40  class GUIManager;
          namespace Gui {
          
      43  class NewCharacter
          {
          public:
      46   std::string name;
      47   std::string description;
      48   std::string gender;
      49   std::string type;
          
      51   bool isValid(   ) const;
          
          };
          
          
      56  class Widget;
      57  class ModelRenderer;
          /**
          @author Erik Hjortsberg
          */
      61  class ServerWidget : public Widget
          {
          public:
          
      65   ServerWidget(   );
      66   virtual ~ServerWidget(   );
      67   virtual void buildWidget(   );
          
          protected:
          
      71   Eris::Account* mAccount;
      72   CEGUI::Listbox* mCharacterList;
          
      74   void createdAccount(  Eris::Account* account );
      75   void gotAvatar(  Eris::Avatar* avatar );
          
      77   bool Login_Click(  const CEGUI::EventArgs& args );
      78   bool Choose_Click(  const CEGUI::EventArgs& args );
      79   bool UseCreator_Click(  const CEGUI::EventArgs& args );
      80   bool CreateChar_Click(  const CEGUI::EventArgs& args );
      81   bool CreateAcc_Click(  const CEGUI::EventArgs& args );
          
      83   void loginSuccess(  Eris::Account* account );
          
           /**
           * Shows the error message sent from Eris if the login does not succeed.
           */
      88   void showLoginFailure(  Eris::Account* account,   std::string msg );
          
           /**
           * Hides the login error message and moves the HelpText to it's original position.
           */
      93   bool hideLoginFailure(   );
          
           /**
           * This function is a slot reacting on a ChangeEvent in the user name box.
           */
      98   bool nameBox_TextChanged(  const CEGUI::EventArgs& args );
          
           /**
           * This function is a slot reacting on a ChangeEvent in the password box.
           */
     103   bool passwordBox_TextChanged(  const CEGUI::EventArgs& args );
     104   void gotAllCharacters(  Eris::Account* account );
          
     106   NewCharacter mNewChar;
          
     108   CEGUI::PushButton* mCreateChar;
     109   CEGUI::PushButton* mUseCreator;
     110   CEGUI::Editbox* mNewCharName;
     111   CEGUI::MultiLineEditbox* mNewCharDescription;
     112   CEGUI::Combobox* mTypesList;
     113   CEGUI::RadioButton* mGenderRadioButton;
          
     115   bool TypesList_SelectionChanged(  const CEGUI::EventArgs& args );
     116   bool Gender_SelectionChanged(  const CEGUI::EventArgs& args );
     117   bool Name_TextChanged(  const CEGUI::EventArgs& args );
     118   bool Description_TextChanged(  const CEGUI::EventArgs& args );
          
     120   void updateNewCharacter(   );
          
          
           /**
           * Fills the drop down list with available character types from the server.
           * @param account
           */
     127   void fillAllowedCharacterTypes(  Eris::Account* account );
          
           /**
           A preview renderer for creating new characters
           */
     132   ModelRenderer* mModelPreviewRenderer;
          
           /**
           * Set up the preview renderer.
           */
     137   void createPreviewTexture(   );
          
           /**
           * Consume Eris::Connection::GotServerInfo signals.
           */
     142   void connection_GotServerInfo(   );
          
     144   void connection_GotConnection(  Eris::Connection* connection );
          
           /**
           * Shows server info.
           */
     149   void showServerInfo(   );
          
          };
          };
          };
          
          #endif

./components/ogre/widgets/StackableContainer.cpp

       1  //
          // C++ Implementation: StackableContainer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "StackableContainer.h"
          
          using namespace CEGUI;
          
          namespace EmberOgre {
          
          namespace Gui {
          
      31  StackableContainer::StackableContainer(  CEGUI::Window* window )
          : mWindow(  window ),   mInnerContainerWindow(  0 ),   mPadding(  0 ),   mFlowDirection(  Vertical )
          {
           if (  mWindow ) {
           mChildAddedConnection = mWindow->subscribeEvent(  CEGUI::Window::EventChildAdded,   CEGUI::Event::Subscriber(  &StackableContainer::window_ChildAdded,   this ) );
           }
          }
          
          
      40  StackableContainer::~StackableContainer(   )
          {
           cleanup(   );
           if (  mWindowDestructionConnection.isValid(   ) ) {
           mWindowDestructionConnection->disconnect(   );
           mWindowDestructionConnection = CEGUI::Event::Connection(   );
           }
          }
          
      49  void StackableContainer::cleanup(   )
          {
           for (  ConnectorStore::iterator I = mChildConnections.begin(   ); I != mChildConnections.end(   ); ++I ) {
           I->second->disconnect(   );
           }
           mChildConnections.clear(   );
           if (  mChildRemovedConnection.isValid(   ) ) {
           mChildRemovedConnection->disconnect(   );
           mChildRemovedConnection = CEGUI::Event::Connection(   );
           }
           if (  mChildAddedConnection.isValid(   ) ) {
           mChildAddedConnection->disconnect(   );
           mChildAddedConnection = CEGUI::Event::Connection(   );
           }
          }
          
      65  CEGUI::Window* StackableContainer::getWindow(   )
          {
           return mWindow;
          }
          
      70  void StackableContainer::setPadding(  int padding )
          {
           mPadding = padding;
          }
          
      75  int StackableContainer::getPadding(   ) const
          {
           return mPadding;
          }
          
          
      81  void StackableContainer::repositionWindows(   )
          {
           if (  mInnerContainerWindow ) {
           float accumulatedWidth(  0 );
           float accumulatedHeight(  0 );
           float maxHeight(  0 );
           float maxWidth(  0 );
          
           ///iterate over all child window and rearrange them
           size_t childCount = mInnerContainerWindow->getChildCount(   );
           for(  size_t i = 0; i < childCount; ++i ) {
           CEGUI::Window* childWindow = mInnerContainerWindow->getChildAtIdx(  i );
           ///only use those windows that are visible
           if (  childWindow->isVisible(   ) ) {
           float absHeight = childWindow->getHeight(   ).asAbsolute(  1 );
           float absWidth = childWindow->getWidth(   ).asAbsolute(  1 );
           if (  mFlowDirection == Horizontal ) {
           maxHeight = std::max<float>(  maxHeight,   absHeight );
           childWindow->setPosition(  UVector2(  UDim(  0,   accumulatedWidth ),   UDim(  0,  0 ) ) );
           accumulatedWidth += absWidth + mPadding;
           } else {
           maxWidth= std::max<float>(  maxWidth,   absWidth );
           childWindow->setPosition(  UVector2(  UDim(  0,   0 ),   UDim(  0,  accumulatedHeight ) ) );
           accumulatedHeight += absHeight + mPadding;
           }
           }
           }
           if (  mFlowDirection == Horizontal ) {
           accumulatedWidth -= mPadding;
           if (  mInnerContainerWindow->getWidth(   ).asRelative(  0 ) != 1 ) {
           mInnerContainerWindow->setWidth(  UDim(  0,   accumulatedWidth ) );
           }
           } else {
           accumulatedHeight -= mPadding;
           if (  mInnerContainerWindow->getHeight(   ).asRelative(  0 ) != 1 ) {
           mInnerContainerWindow->setHeight(  UDim(  0,  accumulatedHeight ) );
           }
           }
           if (  mInnerContainerWindow->getParent(   ) ) {
           mInnerContainerWindow->getParent(   )->performChildWindowLayout(   );
           }
           }
          }
          
     125  float StackableContainer::getAbsoluteHeight(   )
          {
           return mWindow->getSize(   ).d_y.asAbsolute(  0 );
          }
          
     130  float StackableContainer::getAbsoluteWidth(   )
          {
           return mWindow->getSize(   ).d_x.asAbsolute(  0 );
          }
          
     135  void StackableContainer::setFlowDirection(  StackableContainer::FlowDirection flowDirection )
          {
           mFlowDirection = flowDirection;
          }
          
     140  StackableContainer::FlowDirection StackableContainer::getFlowDirection(   ) const
          {
           return mFlowDirection;
          }
          
     145  void StackableContainer::setInnerContainerWindow(  CEGUI::Window* window )
          {
           mInnerContainerWindow = window;
           mChildRemovedConnection = mInnerContainerWindow->subscribeEvent(  CEGUI::Window::EventChildRemoved,   CEGUI::Event::Subscriber(  &StackableContainer::window_ChildRemoved,   this ) );
           mWindowDestructionConnection = mInnerContainerWindow->subscribeEvent(  CEGUI::Window::EventDestructionStarted,   CEGUI::Event::Subscriber(  &StackableContainer::window_DestructionStarted,   this ) );
          
           size_t childCount = mInnerContainerWindow->getChildCount(   );
           for(  size_t i = 0; i < childCount; ++i ) {
           CEGUI::Window* childWindow = mInnerContainerWindow->getChildAtIdx(  i );
           mChildConnections.insert(  ConnectorStore::value_type(  childWindow,   childWindow->subscribeEvent(  CEGUI::Window::EventSized,   CEGUI::Event::Subscriber(  &StackableContainer::childwindow_Sized,   this ) ) ) );
           }
          }
          
          
     159  bool StackableContainer::window_ChildAdded(  const CEGUI::EventArgs& e )
          {
           const WindowEventArgs& windowEventArg = static_cast<const WindowEventArgs&>(  e );
           if (  !mInnerContainerWindow ) {
           setInnerContainerWindow(  windowEventArg.window->getParent(   ) );
           } else {
           ///if we've called setInnerContainerWindow we would already have connected the new child window
           mChildConnections.insert(  ConnectorStore::value_type(  windowEventArg.window,   windowEventArg.window->subscribeEvent(  CEGUI::Window::EventSized,   CEGUI::Event::Subscriber(  &StackableContainer::childwindow_Sized,   this ) ) ) );
           }
           repositionWindows(   );
           return true;
          }
          
     172  bool StackableContainer::window_ChildRemoved(  const CEGUI::EventArgs& e )
          {
           const WindowEventArgs& windowEventArg = static_cast<const WindowEventArgs&>(  e );
           ConnectorStore::iterator I = mChildConnections.find(  windowEventArg.window );
           if (  I != mChildConnections.end(   ) ) {
           I->second->disconnect(   );
           mChildConnections.erase(  I );
           }
          
           repositionWindows(   );
           return true;
          }
          
     185  bool StackableContainer::childwindow_Sized(  const CEGUI::EventArgs& e )
          {
           repositionWindows(   );
           return true;
          }
          
     191  bool StackableContainer::window_DestructionStarted(  const CEGUI::EventArgs& e )
          {
           cleanup(   );
           return true;
          }
          
     197  void StackableContainer::disconnect(   )
          {
           cleanup(   );
          }
          
          
          }
          
          }

./components/ogre/widgets/StackableContainer.h

       1  //
          // C++ Interface: StackableContainer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUISTACKABLECONTAINER_H
          #define EMBEROGRE_GUISTACKABLECONTAINER_H
          
          #include <CEGUI.h>
          #include <list>
          
          namespace CEGUI {
      30  class Window;
          }
          
          namespace EmberOgre {
          
          namespace Gui {
          
          /**
           Use this class with CEGUI windows to allow for automatic layout of child window.
           An instance of this will attach itself to a window and listen for children being added and removed,   as well as resized.
           It will rearrange these child windows so that they are stacked,   either vertically or horizontally.
          
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      44  class StackableContainer{
          public:
           /**
           The flow direction of the child window.
           */
           enum FlowDirection {
           Horizontal = 0,  
           Vertical = 1
           };
          
           /**
           Default constructor.
           @param A valid window,   which will have its children automatically arranged.
           */
      58   StackableContainer(  CEGUI::Window* window );
          
      60   virtual ~StackableContainer(   );
          
           /**
           Manually sets the inner container window. In some cases,   such as with a ScrollablePane,   this will differ from the main window.
           */
      65   void setInnerContainerWindow(  CEGUI::Window* window );
          
           /**
           Gets the window that this instance listens to.
           */
      70   CEGUI::Window* getWindow(   );
          
           /**
           Sets how much to pad between each child,   in pixels.
           */
      75   void setPadding(  int padding );
           /**
           Gets how much to pad between each child,   in pixels.
           */
      79   int getPadding(   ) const;
          
           /**
           Utility method for getting the absolute height of the window.
           */
      84   float getAbsoluteHeight(   );
           /**
           Utility method for getting the absolute width of the window.
           */
      88   float getAbsoluteWidth(   );
          
           /**
           Sets the direction that children will flow.
           */
      93   void setFlowDirection(  FlowDirection flowDirection );
           /**
           Gets the direction that children will flow.
           */
      97   FlowDirection getFlowDirection(   ) const;
          
           /**
           Repositions all windows as they are added and removed to the list.
           */
     102   void repositionWindows(   );
          
           /**
           Disconnects the listener,   in effect deactivating the instance.
           */
     107   void disconnect(   );
          
          protected:
          
           /**
           Hold references to all event bindings,   so we can properly clean them up.
           */
           typedef std::map<CEGUI::Window*,   CEGUI::Event::Connection> ConnectorStore;
     115   CEGUI::Event::Connection mChildRemovedConnection,   mChildAddedConnection,   mWindowDestructionConnection;
     116   ConnectorStore mChildConnections;
          
           /**
           We keep a reference to both the mainwindow and an inner container window. In most cases these will be the same,   but when for example using the ScrollablePane,   they might be different.
           */
     121   CEGUI::Window* mWindow;
     122   CEGUI::Window* mInnerContainerWindow;
          
          
           /**
           In pixels,   how much to pad between each window.
           */
           int mPadding;
          
           /**
           The direction the windows will flow.
           */
           FlowDirection mFlowDirection;
          
     135   bool window_ChildAdded(  const CEGUI::EventArgs& e );
     136   bool window_ChildRemoved(  const CEGUI::EventArgs& e );
     137   bool childwindow_Sized(  const CEGUI::EventArgs& e );
     138   bool window_DestructionStarted(  const CEGUI::EventArgs& e );
          
           /**
           Clean up all bindings.
           */
     143   void cleanup(   );
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/StatusIconBar.cpp

       1  //
          // C++ Implementation: StatusIconBar
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "StatusIconBar.h"
          
          #include "../GUIManager.h"
          #include <CEGUIImagesetManager.h>
          #include <CEGUIImageset.h>
          #include "framework/ConsoleBackend.h"
          #include <elements/CEGUIFrameWindow.h>
          #include "../EmberOgre.h"
          #include "../input/Input.h"
          
          #include "IconBase.h"
          
          using namespace CEGUI;
          namespace EmberOgre {
          namespace Gui {
          
      39  StatusIconBar::StatusIconBar(   ) : mOriginalCursorImage(  0 ),   mIconBar(  "statusIcons" )
          {
          }
          
          
      44  StatusIconBar::~StatusIconBar(   )
          {
          }
          
          
      49  void StatusIconBar::buildWidget(   )
          {
          
           getMainSheet(   )->addChildWindow(  mIconBar.getWindow(   ) );
          
           const Image* background = IconBase::loadImageFromImageset(  "iconset_standard",   "background_A" );
           const Image* borderactive = IconBase::loadImageFromImageset(  "iconset_standard",   "ring_over" );
           const Image* borderinactive = IconBase::loadImageFromImageset(  "iconset_standard",   "ring" );
           const Image* foreground;
           IconBase* helpIconBase;
          
           foreground = IconBase::loadImageFromImageset(  "iconset_standard",   "close2" );
           helpIconBase = new IconBase(  "close2",   background,   foreground,   borderinactive,   borderactive );
           mIconBar.addIcon(  helpIconBase );
           helpIconBase->getButton(   )->setTooltipText(  "Click here to exit Ember." );
          
           BIND_CEGUI_EVENT(  helpIconBase->getButton(   ),   ButtonBase::EventMouseClick,   StatusIconBar::close_MouseClick );
          
           foreground = IconBase::loadImageFromImageset(  "iconset_standard",   "question" );
           helpIconBase = new IconBase(  "help",   background,   foreground,   borderinactive,   borderactive );
           mIconBar.addIcon(  helpIconBase );
           helpIconBase->getButton(   )->setTooltipText(  "Click here to access the help." );
          
           BIND_CEGUI_EVENT(  helpIconBase->getButton(   ),   ButtonBase::EventMouseClick,   StatusIconBar::help_MouseClick );
          
          
           //load all of the movement status images
           mMovementImage_walk = IconBase::loadImageFromImageset(  "iconset_standard",   "walk" );
           mMovementImage_run = IconBase::loadImageFromImageset(  "iconset_standard",   "run" );
           mMovementImage_gui = IconBase::loadImageFromImageset(  "iconset_standard",   "abc" );
          
           mMovementModeIcon = new IconBase(  "movementmode",   background,   mMovementImage_gui,   borderinactive,   borderactive );
           mIconBar.addIcon(  mMovementModeIcon );
           mMovementModeIcon->getButton(   )->setTooltipText(  "This shows your current input mode.\nUse the right mouse button for movement mode.\nDouble click also switches modes. Press and hold shift to run." );
           ///start out with the movement mode icon hidden,   only show it when the user has an avatar
           mMovementModeIcon->getContainer(   )->setVisible(  false );
          
           BIND_CEGUI_EVENT(  mMovementModeIcon->getButton(   ),   ButtonBase::EventMouseClick,   StatusIconBar::movement_MouseClick );
          
           Input::getSingleton(   ).EventChangedInputMode.connect(  sigc::mem_fun(  *this,   &StatusIconBar::Input_InputModeChanged ) );
           EmberOgre::getSingleton(   ).getAvatarController(   )->EventMovementModeChanged.connect(  sigc::mem_fun(  *this,   &StatusIconBar::AvatarController_MovementModeChanged ) );
          
           float height = mIconBar.getAbsoluteHeight(   );
           mIconBar.getWindow(   )->setPosition(  UVector2(  UDim(  0,  0 ),   UDim(  1,   -height ) ) );
          
          
           EmberOgre::getSingleton(   ).EventCreatedAvatarEntity.connect(  sigc::mem_fun(  *this,   &StatusIconBar::EmberOgre_createdAvatarEmberEntity ) );
          
          /*
           foreground = IconBase::loadImageFromFile(  "attack.png" );
           helpIconBase = new IconBase(  "attack",   background,   foreground,   borderinactive,   borderactive );
           getMainSheet(   )->addChildWindow(  helpIconBase->getContainer(   ) );
           helpIconBase->getContainer(   )->setPosition(  Absolute,   Point(  350,   700 ) );
          
           foreground = IconBase::loadImageFromFile(  "defend.png" );
           helpIconBase = new IconBase(  "defend",   background,   foreground,   borderinactive,   borderactive );
           getMainSheet(   )->addChildWindow(  helpIconBase->getContainer(   ) );
           helpIconBase->getContainer(   )->setPosition(  Absolute,   Point(  400,   700 ) );
          
           foreground = IconBase::loadImageFromFile(  "spell.png" );
           helpIconBase = new IconBase(  "spell",   background,   foreground,   borderinactive,   borderactive );
           getMainSheet(   )->addChildWindow(  helpIconBase->getContainer(   ) );
           helpIconBase->getContainer(   )->setPosition(  Absolute,   Point(  450,   700 ) );*/
          
          
          }
          
     116  bool StatusIconBar::help_MouseClick(  const EventArgs& args )
          {
           Ember::ConsoleBackend::getMainConsole(   )->runCommand(  "/help" );
           return true;
          }
          
     122  bool StatusIconBar::close_MouseClick(  const EventArgs& args )
          {
           Ember::ConsoleBackend::getMainConsole(   )->runCommand(  "/softquit" );
           return true;
          }
          
     128  bool StatusIconBar::movement_MouseClick(  const EventArgs& args )
          {
           mGuiManager->getInput(   ).toggleInputMode(   );
           return true;
          }
          
     134  void StatusIconBar::Input_InputModeChanged(  Input::InputMode mode ) {
           mCurrentMode = mode;
           if (  mode == Input::IM_GUI ) {
           mMovementModeIcon->setForeground(  mMovementImage_gui );
           if (  mOriginalCursorImage ) {
           MouseCursor::getSingleton(   ).setImage(  mOriginalCursorImage );
           mOriginalCursorImage = 0;
           }
           } else {
           checkMovementMode(   );
           }
          
          
          }
          
     149  void StatusIconBar::AvatarController_MovementModeChanged(  AvatarMovementMode::Mode mode )
          {
           if (  mCurrentMode == Input::IM_MOVEMENT ) {
           checkMovementMode(   );
           }
          
          }
          
     157  void StatusIconBar::checkMovementMode(   )
          {
           if (  mOriginalCursorImage == 0 ) {
           mOriginalCursorImage = MouseCursor::getSingleton(   ).getImage(   );
           }
          
           if (  EmberOgre::getSingleton(   ).getAvatarController(   )->getCurrentMovement(   ).mode == AvatarMovementMode::MM_RUN ) {
           mMovementModeIcon->setForeground(  mMovementImage_run );
           MouseCursor::getSingleton(   ).setImage(  mMovementImage_run );
           } else {
           mMovementModeIcon->setForeground(  mMovementImage_walk );
           MouseCursor::getSingleton(   ).setImage(  mMovementImage_walk );
           }
          }
          
     172  void StatusIconBar::EmberOgre_createdAvatarEmberEntity(  AvatarEmberEntity* entity )
          {
           mMovementModeIcon->getContainer(   )->setVisible(  true );
          }
          
          }
          }

./components/ogre/widgets/StatusIconBar.h

       1  //
          // C++ Interface: StatusIconBar
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRESTATUSICONBAR_H
          #define EMBEROGRESTATUSICONBAR_H
          
          #include "Widget.h"
          #include "IconBar.h"
          #include "../GUIManager.h"
          #include "../input/Input.h"
          #include "../AvatarController.h"
          
          namespace EmberOgre {
          namespace Gui {
          
      35  class IconBase;
      36  class IconBar;
          
          /**
          @author Erik Hjortsberg
          */
      41  class StatusIconBar : public Widget {
          public:
      43   StatusIconBar(   );
          
      45   virtual ~StatusIconBar(   );
          
      47   virtual void buildWidget(   );
          
          protected:
          
      51   bool help_MouseClick(  const CEGUI::EventArgs& args );
      52   bool close_MouseClick(  const CEGUI::EventArgs& args );
      53   bool movement_MouseClick(  const CEGUI::EventArgs& args );
          
      55   IconBase* mMovementModeIcon;
      56   const CEGUI::Image* mMovementImage_walk;
      57   const CEGUI::Image* mMovementImage_run;
      58   const CEGUI::Image* mMovementImage_gui;
          
      60   void Input_InputModeChanged(  Input::InputMode mode );
      61   void AvatarController_MovementModeChanged(  AvatarMovementMode::Mode mode );
          
           Input::InputMode mCurrentMode;
          
      65   void checkMovementMode(   );
          
      67   const CEGUI::Image* mOriginalCursorImage;
          
      69   IconBar mIconBar;
          
      71   void EmberOgre_createdAvatarEmberEntity(  AvatarEmberEntity* entity );
          
          };
          }
          }
          
          #endif

./components/ogre/widgets/Vector3Adapter.cpp

       1  //
          // C++ Implementation: Vector3Adapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Vector3Adapter.h"
          #include "Widget.h"
          
          #include <CEGUIWindow.h>
          
          
          namespace EmberOgre {
          
          namespace Gui {
          
      33  Vector3Adapter::Vector3Adapter(  CEGUI::Window *xWindow,   CEGUI::Window *yWindow,   CEGUI::Window *zWindow,   const Ogre::Vector3& vector )
          : mVector(  vector ),   mOriginalVector(  vector ),   mXWindow(  xWindow ),   mYWindow(  yWindow ),   mZWindow(  zWindow ),   mSelfUpdate(  false )
          
          {
           if (  xWindow ) {
           BIND_CEGUI_EVENT(  xWindow,   CEGUI::Window::EventTextChanged,   Vector3Adapter::window_TextChanged );
           }
           if (  yWindow ) {
           BIND_CEGUI_EVENT(  yWindow,   CEGUI::Window::EventTextChanged,   Vector3Adapter::window_TextChanged );
           }
           if (  zWindow ) {
           BIND_CEGUI_EVENT(  zWindow,   CEGUI::Window::EventTextChanged,   Vector3Adapter::window_TextChanged );
           }
          }
          
          
      49  Vector3Adapter::~Vector3Adapter(   )
          {
          }
          
      53  void Vector3Adapter::setValue(  const Ogre::Vector3& vector )
          {
           updateGui(  vector );
           EventValueChanged.emit(   );
          }
          
      59  const Ogre::Vector3& Vector3Adapter::getValue(   ) const
          {
           if (  mXWindow ) {
           mVector.x = Ogre::StringConverter::parseReal(   mXWindow->getText(   ).c_str(   ) );
           }
           if (  mXWindow ) {
           mVector.y = Ogre::StringConverter::parseReal(   mYWindow->getText(   ).c_str(   ) );
           }
           if (  mZWindow ) {
           mVector.z = Ogre::StringConverter::parseReal(   mZWindow->getText(   ).c_str(   ) );
           }
           return mVector;
          }
          
      73  const Ogre::Vector3& Vector3Adapter::getOriginalValue(   ) const
          {
           return mOriginalVector;
          }
          
      78  void Vector3Adapter::updateGui(  const Ogre::Vector3& vector )
          {
           mSelfUpdate = true;
           if (  &vector ) {
           if (  mXWindow ) {
           mXWindow->setText(  Ogre::StringConverter::toString(  vector.x ) );
           }
           if (  mYWindow ) {
           mYWindow->setText(  Ogre::StringConverter::toString(  vector.y ) );
           }
           if (  mZWindow ) {
           mZWindow->setText(  Ogre::StringConverter::toString(  vector.z ) );
           }
           } else {
           if (  mXWindow ) {
           mXWindow->setText(  "" );
           }
           if (  mYWindow ) {
           mYWindow->setText(  "" );
           }
           if (  mZWindow ) {
           mZWindow->setText(  "" );
           }
           }
           mSelfUpdate = false;
          }
          
     105  bool Vector3Adapter::window_TextChanged(  const CEGUI::EventArgs& e )
          {
           if (  !mSelfUpdate ) {
           EventValueChanged.emit(   );
           }
           return true;
          }
          
          }
          
          }

./components/ogre/widgets/Vector3Adapter.h

          //
          // C++ Interface: Vector3Adapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_CEGUIVECTOR3ADAPTER_H
          #define EMBEROGRE_CEGUIVECTOR3ADAPTER_H
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include <sigc++/signal.h>
          
          namespace CEGUI
          {
      30   class Window;
      31   class EventArgs;
          
          }
          
          namespace EmberOgre {
          
          namespace Gui {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      42  class Vector3Adapter {
          public:
      44   Vector3Adapter(  CEGUI::Window *xWindow,   CEGUI::Window *yWindow,   CEGUI::Window *zWindow,   const Ogre::Vector3& vector = Ogre::Vector3::ZERO );
          
      46   ~Vector3Adapter(   );
          
      48   const Ogre::Vector3& getValue(   ) const;
      49   const Ogre::Vector3& getOriginalValue(   ) const;
          
           /**
           Sets the value,   thus also updating the gui.
           */
      54   void setValue(  const Ogre::Vector3& vector );
          
           /**
           Updates the gui with new values.
           */
      59   void updateGui(  const Ogre::Vector3& vector );
          
           /**
           Emitted when the value has been changed from a gui update.
           */
      64   sigc::signal<void> EventValueChanged;
          protected:
          
           mutable Ogre::Vector3 mVector;
           Ogre::Vector3 mOriginalVector;
          
           /**
           The windows which holds the values.
           */
           CEGUI::Window *mXWindow,   *mYWindow,   *mZWindow;
          
      75   bool window_TextChanged(  const CEGUI::EventArgs& e );
          
           bool mSelfUpdate;
          
          };
          
          }
          
          }
          
          #endif

./components/ogre/widgets/Widget.cpp

       1  #include "Widget.h"
          
          #include "../GUIManager.h"
          #include "../input/Input.h"
          #include "../EmberOgre.h"
          
          #include <CEGUIWindow.h>
          #include <CEGUIExceptions.h>
          #include <CEGUIWindowManager.h>
          #include <elements/CEGUIFrameWindow.h>
          #include <elements/CEGUIPushButton.h>
          
          #include "framework/ConsoleBackend.h"
          
          using namespace CEGUI;
          namespace EmberOgre {
          namespace Gui {
          
      19   const std::string Widget::DEFAULT_TAB_GROUP(  "default" );
          
      21   Widget::Widget(   ) : mCommandSuffix(  "" ),   mMainWindow(  0 ),   mActiveWindowIsOpaque(  true ),   mFirstTabWindow(  0 ),   mLastTabWindow(  0 )
           {
           }
          
      25   void Widget::init(  GUIManager* guiManager )
           {
           mGuiManager = guiManager;
           mWindowManager = &CEGUI::WindowManager::getSingleton(   );
           }
          
          
      32   Widget::~Widget(   )
           {
           if (  mCommandSuffix != "" ) {
           Ember::ConsoleBackend::getMainConsole(   )->deregisterCommand(  "show_" + mCommandSuffix );
           }
           if (  mMainWindow ) {
           CEGUI::WindowManager::getSingleton(   ).destroyWindow(  mMainWindow );
           }
           //mGuiManager->removeWidget(  this );
           }
          
      43   void Widget::frameStarted(  const Ogre::FrameEvent& evt )
           {
           EventFrameStarted.emit(  evt.timeSinceLastFrame );
           }
          
      48   void Widget::buildWidget(   )
           {}
          
          
          
      53   CEGUI::Window* Widget::getMainSheet(   ) {
           return mGuiManager->getMainSheet(   );
           }
          
          
      58   CEGUI::Window* Widget::loadMainSheet(  const std::string& filename,   const std::string& prefix ) {
           assert(  mWindowManager && "You must call init(   ) before you can call any other methods." );
           mPrefix = prefix;
           std::string finalFileName(  mGuiManager->getLayoutDir(   ) + filename );
           try {
           mMainWindow = mWindowManager->loadWindowLayout(  finalFileName,   prefix );
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when loading from " << filename << ".\nMessage: " << ex.getMessage(   ).c_str(   ) );
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading from " << filename << ".\nMessage: " << ex.what(   ) );
           } catch (  ... ) {
           S_LOG_FAILURE(  "Unknown error when loading from " << filename << "." );
           }
           if (  mMainWindow ) {
           mOriginalWindowAlpha = mMainWindow->getAlpha(   );
           getMainSheet(   )->addChildWindow(  mMainWindow );
           BIND_CEGUI_EVENT(  mMainWindow,   CEGUI::FrameWindow::EventActivated,   Widget::MainWindow_Activated );
           BIND_CEGUI_EVENT(  mMainWindow,   CEGUI::FrameWindow::EventDeactivated,   Widget::MainWindow_Deactivated );
           ///we want to catch all click events,   so we'll listen for the mouse button down event
           BIND_CEGUI_EVENT(  mMainWindow,   CEGUI::Window::EventMouseButtonDown,   Widget::MainWindow_MouseButtonDown );
          
           }
           return mMainWindow;
           }
          
      83   CEGUI::Window* Widget::getWindow(  const std::string& windowName )
           {
           try {
           assert(  mWindowManager && "You must call init(   ) before you can call any other methods." );
           if (  !mMainWindow ) {
           S_LOG_WARNING(  "Trying to get a window (  "+ windowName +" ) on widget that has no main sheet loaded (  " << mPrefix << " )." );
           return 0;
           }
           assert(  mMainWindow && "You must call loadMainSheet(  ... ) before you can call this method." );
           CEGUI::Window* window = mWindowManager->getWindow(  mPrefix + windowName );
           if (  !window ) {
           S_LOG_WARNING(  "The window with id " << mPrefix << windowName << " does not exist." );
           }
           return window;
           } catch (  const CEGUI::Exception& ) {
           S_LOG_WARNING(  "The window " << windowName << " doesn't exist." );
           return 0;
           }
          
           }
          
     104   CEGUI::Window* Widget::createWindow(  const std::string& windowType )
           {
           return mGuiManager->createWindow(  windowType );
           }
          
     109   CEGUI::Window* Widget::createWindow(  const std::string& windowType,   const std::string& windowName )
           {
           return mGuiManager->createWindow(  windowType,   windowName );
           }
          
          
          
     116   Widget* WidgetLoader::createWidget(  const std::string& name ) {
          
           if (  GetFactories(   ).find(  name ) == GetFactories(   ).end(   ) ) {
           return 0;
           }
          
           Widget* widget = GetFactories(   )[name](   );
           return widget;
           }
          
     126   WidgetLoader::WidgetLoader(  const std::string& name,   FactoryFunc functor )
           {
           GetFactories(   ).insert(  WidgetFactoryMap::value_type(  name,   functor ) );
          
           }
          
     132   WidgetFactoryMap& WidgetLoader::GetFactories(   )
           {
           static WidgetFactoryMap* factoryMap = new WidgetFactoryMap(   );
           return *factoryMap;
           }
          
     138   void WidgetLoader::registerWidget(  const std::string& name,   FactoryFunc functor )
           {
           GetFactories(   ).insert(  WidgetFactoryMap::value_type(  name,   functor ) );
          
           }
          
     144   void Widget::registerConsoleVisibilityToggleCommand(  const std::string & commandSuffix )
           {
           mCommandSuffix = commandSuffix;
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  "show_" + commandSuffix,   this,   std::string(  "Shows the " ) + mCommandSuffix + " window." );
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  "hide_" + commandSuffix,   this,   std::string(  "Hides the " ) + mCommandSuffix + " window." );
          
           }
          
     152   void Widget::runCommand(  const std::string &command,   const std::string &args )
           {
           if(  command == "show_" + mCommandSuffix )
           {
           show(   );
           }
           else if(  command == "hide_" + mCommandSuffix )
           {
           hide(   );
           }
           }
          
     164   void Widget::show(   )
           {
           ///removing and attaching the window is probably more efficient when it's hidden (  i.e. it won't get any events at all and so on )
           if (  mMainWindow ) {
           getMainSheet(   )->addChildWindow(  mMainWindow );
           mMainWindow->setVisible(  true );
           }
           }
          
     173   void Widget::hide(   )
           {
           ///see comment in show(   )
           if (  mMainWindow ) {
           getMainSheet(   )->removeChildWindow(  mMainWindow );
           mMainWindow->setVisible(  false );
           }
           }
          
     182   bool Widget::MainWindow_CloseClick(  const CEGUI::EventArgs& args )
           {
           hide(   );
           return true;
           }
          
     188   void Widget::enableCloseButton(   )
           {
           assert(  mMainWindow );
           BIND_CEGUI_EVENT(  mMainWindow,   CEGUI::FrameWindow::EventCloseClicked,   Widget::MainWindow_CloseClick );
           }
          
     194   CEGUI::Window* Widget::getMainWindow(   )
           {
           return mMainWindow;
           }
          
     199   bool Widget::MainWindow_MouseButtonDown(  const CEGUI::EventArgs& args )
           {
           ///we'll return true here to prevent the event from propagating to other windows
           return true;
           }
          
     205   bool Widget::MainWindow_Activated(  const CEGUI::EventArgs& args )
           {
           if (  mMainWindow && mActiveWindowIsOpaque ) {
           mMainWindow->setAlpha(  1.0 );
          
           }
           return true;
           }
          
     214   bool Widget::MainWindow_Deactivated(  const CEGUI::EventArgs& args )
           {
           if (  mMainWindow && mActiveWindowIsOpaque ) {
           mMainWindow->setAlpha(  mOriginalWindowAlpha );
           }
           return true;
           }
          
     222   bool Widget::getIsActiveWindowOpaque(   ) const
           {
           return mActiveWindowIsOpaque;
           }
          
     227   void Widget::setIsActiveWindowOpaque(  bool isOpaque )
           {
           mActiveWindowIsOpaque = isOpaque;
           }
          
     232   const std::string& Widget::getDefaultScheme(   ) const
           {
           return mGuiManager->getDefaultScheme(   );
           }
          
          
          
     239   bool Widget::TabbableWindow_KeyDown(  const CEGUI::EventArgs& args )
           {
           const CEGUI::KeyEventArgs& keyEventArgs = static_cast<const CEGUI::KeyEventArgs&>(  args );
           if (  keyEventArgs.scancode == CEGUI::Key::Tab )
           {
           ///find the window in the list of tabbable windows
           CEGUI::Window* activeWindow = mMainWindow->getActiveChild(   );
           if (  activeWindow ) {
          // WindowMap::iterator I = std::find(  mTabOrder.begin(   ),   mTabOrder.end(   ),   activeWindow );
           WindowMap::iterator I = mTabOrder.find(  activeWindow );
           if (  I != mTabOrder.end(   ) ) {
           I->second->activate(   );
           ///we don't want to process the event any more,   in case something else will try to interpret the tab event to also change the focus
           Input::getSingleton(   ).suppressFurtherHandlingOfCurrentEvent(   );
           return true;
           }
           }
           } else if (  keyEventArgs.scancode == CEGUI::Key::Return )
           {
           ///iterate through all enter buttons,   and if anyone is visible,   activate it
           for (  WindowStore::iterator I = mEnterButtons.begin(   ); I != mEnterButtons.end(   ); ++I ) {
           if (  (  *I )->isVisible(   ) ) {
           CEGUI::Window* window = *I;
           WindowEventArgs args(  window );
           window->fireEvent(  ButtonBase::EventMouseClick,   args,   PushButton::EventNamespace );
           break;
           }
           }
           }
           return true;
           }
          
     271   void Widget::addTabbableWindow(  CEGUI::Window* window )
           {
           if (  !mFirstTabWindow ) {
           mFirstTabWindow = window;
           }
           if (  mLastTabWindow ) {
           mTabOrder.insert(  WindowMap::value_type(  mLastTabWindow,   window ) );
           }
           mLastTabWindow = window;
           BIND_CEGUI_EVENT(  window,   CEGUI::Window::EventKeyDown,   Widget::TabbableWindow_KeyDown );
           }
          
     283   void Widget::addEnterButton(  CEGUI::Window* window )
           {
           mEnterButtons.push_back(  window );
           }
          
     288   void Widget::closeTabGroup(   )
           {
           if (  mLastTabWindow && mFirstTabWindow ) {
           mTabOrder.insert(  WindowMap::value_type(  mLastTabWindow,   mFirstTabWindow ) );
           }
           mFirstTabWindow = 0;
           mLastTabWindow = 0;
           }
          
          // void addTabbableWindow(  CEGUI::Window* window,   const std::string& tabGroup )
          // {
          // WindowStore* store;
          // WindowStoreMap::iterator I = mTabOrders.find(  tabGroup );
          // if (  I == mTabOrders.end(   ) ) {
          // /could not find group,   lets create it
          // store = new WindowStore(   );
          // mTabOrders.insert(  WindowStoreMap::value_type(  tabGroup,   store ) );
          // } else {
          // store = I->second;
          // }
          // store->push_back(  window );
          // BIND_CEGUI_EVENT(  window,   CEGUI::Window::EventKeyUp,   Widget::TabbableWindow_KeyUp );
          // }
          
          
          }
          }

./components/ogre/widgets/Widget.h

          #ifndef WIDGET_H
          #define WIDGET_H
          
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include <elements/CEGUIListboxTextItem.h>
          
          
          #include <sigc++/trackable.h>
          #include <sigc++/signal.h>
          
          #include "framework/ConsoleObject.h"
          
          namespace CEGUI
          {
      16   class WindowManager;
      17   class Listbox;
      18   class ListboxItem;
      19   class ListboxTextItem;
      20   class Slider;
      21   class Editbox;
      22   class PushButton;
      23   class MultiLineEditbox;
      24   class Combobox;
      25   class RadioButton;
          
          }
          
          namespace EmberOgre {
          
          /**
          Utility define for binding CEGUI elements to methods.
          */
          #define BIND_CEGUI_EVENT(  window,   event,   method ) window->subscribeEvent(  event,   CEGUI::Event::Subscriber(  &method,   this ) );
          
          
      37  class GUIManager;
          namespace Gui {
          
      40  class WidgetLoader;
      41  class Widget;
          
          /**se this template to register a widget in the global widget factory map
          This is done by:
          template<> WidgetLoader WidgetLoaderHolder<ASubClassOfWidget>::loader(  "associatedName",   &createWidgetInstance );
          */
          // template <typename T> class WidgetLoaderHolder
          // {
          // protected:
          //
          // static WidgetLoader loader;
          // static Widget* createWidgetInstance(   ) { return new T; }
          // };
          
          
          
          /**
          Because CEGUI::Listbox can't hold const objects in its
          */
      60  template<typename T> class ConstWrapper
          {
          public:
      63   ConstWrapper(  T value ) : mValue(  value ) {}
      64   T mValue;
          };
          
          
          /**
          
          Base class for all widgets.
          Put all widget set up code in the buildWidget(   ) method.
          
          
          NOTE: Perhaps we should provide another base class for widgets that have a single movable window?
          
          
          When creating a new Widget class,   make sure you also add it to WidgetDefinitions.
          @see WidgetDefinitions
          
          */
      81  class Widget :
      82  public sigc::trackable,  
      83  public Ember::ConsoleObject
          {
          public:
          
           friend class ::EmberOgre::GUIManager;
      88   friend class WidgetLoader;
          
           static const std::string DEFAULT_TAB_GROUP;
          
          
          
          
           /**
           * Sets up the widget,   called upon creation.
           * @param guiManager
           */
      99   void init(  GUIManager* guiManager );
          
          
           /**
           * Called each frame.
           * @param evt
           */
     106   virtual void frameStarted(  const Ogre::FrameEvent& evt );
          
          
           /**
           * Called by the GUIManager to tell the widget to create all needed GUI elements.
           * Override this in your subclass.
           * Remember to call getMainSheet(   )->addChildWindow(  mMainWindow ); to add the main window to the gui system,   else it won't be shown.
           */
           virtual void buildWidget(   );
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
           virtual void runCommand(  const std::string &command,   const std::string &args );
          
          
           /**
           * Show the widget.
           */
           virtual void show(   );
          
           /**
           * Hides the widget.
           */
           virtual void hide(   );
          
           /**
           * Get's the window with the supplied name from the WindowManager. Note that you shouldn't supply the prefix (  as defined in loadMainSheet ) since that will be added by the method.
           * @param windowName The name of the window,   without the suffix.
           * @return A valid Window pointer of 0.
           */
           CEGUI::Window* getWindow(  const std::string& windowName );
          
           /**
           Creates a new window of the supplied type,   giving it an autogenerated,   unique name.
           */
           CEGUI::Window* createWindow(  const std::string& windowType );
          
           /**
           Creates a new window of the supplied type with the supplied name.
           */
           CEGUI::Window* createWindow(  const std::string& windowType,   const std::string& windowName );
          
          
           /**
           * Call this method upon creation of the widget (  for example in buildWidget ) to enable the close button and wire it to the correct methods.
           */
           void enableCloseButton(   );
          
           /**
           * Call this method upon creation of the widget (  for example in buildWidget ) to register show and hide commands with the console.
           * The command you choose will be prefixed by "show_" and "hide_". So if you have a widget which shows a map and you call this method with the
           * parameter "map" the commands "show_map" and "hide_map" will be registered with the console.
           * @param commandSuffix a string to be prefixed by "show_" and "hide_"
           */
           void registerConsoleVisibilityToggleCommand(  const std::string & commandSuffix );
          
           /**
           accessor to the main sheet of the gui system
           */
           CEGUI::Window* getMainSheet(   );
          
           /**
           * Accessor to the main window of the widget.
           * @return
           */
           CEGUI::Window* getMainWindow(   );
          
           /**
           * Loads a widget definition from a file and sets the main sheet
           * @param filename The name of the file to load
           * @param prefix The prefix to use
           * @return
           */
           CEGUI::Window* loadMainSheet(  const std::string& filename,   const std::string& prefix );
          
           /**
           * Gets the prefix used in the widget definition
           * @return
           */
           inline const std::string& getPrefix(   ) const { return mPrefix;}
          
           /**
           * Gets whether the window when being activated should become fully opaque,   to return to it's preset alpha value when being deactivated.
           Defaults to true.
           * @return
           */
           bool getIsActiveWindowOpaque(   ) const;
           /**
           * Sets whether the window when being activated should become fully opaque,   to return to it's preset alpha value when being deactivated.
           Defaults to true.
           * @param isOpaque
           */
           void setIsActiveWindowOpaque(  bool isOpaque );
          
           /**
           * Gets the name of the default scheme used (  such as "EmberLook" or "EmberLook" )
           * @return
           */
           const std::string& getDefaultScheme(   ) const;
          
          
           /**
           * Adds a window to the tab order. Remember to call closeTabGroup(   ) to close the tab group.
           * @param window
           */
           void addTabbableWindow(  CEGUI::Window* window );
          
           /**
           * Adds a window to the "enter" list. If the "Enter" key is pressed within any of the tabbable windows,   any "enter" window that is visible will have a MouseClick event sent to it. Use this to enable default enter behaviour in forms.
           */
           void addEnterButton(  CEGUI::Window* window );
          
          
           /**
           * Closes the current tab so that the last window connects to the first window.
           */
           void closeTabGroup(   );
          
           /**
           * Emitted each time a frame is started.
           */
           sigc::signal<void,   float> EventFrameStarted;
          
          protected:
          
           Widget(   );
           virtual ~Widget(   );
          
           bool MainWindow_CloseClick(  const CEGUI::EventArgs& args );
          
           bool MainWindow_Activated(  const CEGUI::EventArgs& args );
           bool MainWindow_Deactivated(  const CEGUI::EventArgs& args );
           bool MainWindow_MouseButtonDown(  const CEGUI::EventArgs& args );
          
           /**
           * The suffixed used by registerConsoleVisibilityToggleCommand
           * @see registerConsoleVisibilityToggleCommand
           */
           std::string mCommandSuffix;
          
          
          
           /**
           * The main window for the widget.
           */
           CEGUI::Window* mMainWindow;
          
           GUIManager* mGuiManager;
          
          
           CEGUI::WindowManager* mWindowManager;
          
           /**
           The original alpha value of the window.
           */
           float mOriginalWindowAlpha;
          
           /**
           If true,   when activated the window will become fully opaque.
           */
           bool mActiveWindowIsOpaque;
          
           typedef std::map<CEGUI::Window*,   CEGUI::Window*> WindowMap;
           typedef std::vector<CEGUI::Window*> WindowStore;
           WindowMap mTabOrder;
           WindowStore mEnterButtons;
           CEGUI::Window *mFirstTabWindow,   *mLastTabWindow;
          
           bool TabbableWindow_KeyDown(  const CEGUI::EventArgs& args );
          
          
          private:
           std::string mPrefix;
          
          };
          
          
          typedef Widget* (  *FactoryFunc )(   );
          TYPEDEF_STL_MAP(  std::string,   FactoryFunc,   WidgetFactoryMap );
          
          /**
          Utility class for associating Widgets to strings.
          See WidgetLoaderHolder on how to register Widgets.
          
          Use createWidget(  "someName" ) to create widgets.
          */
          class WidgetLoader
          {
          public:
          
          
           /**
           upon creation,   an entry will be added to the internal WidgetFactoryMap
           */
           WidgetLoader(  const std::string& name,   FactoryFunc functor );
          
           /**
           map of all factories,   we have to use a static function to avoid static initialization order fiasco
           */
           static WidgetFactoryMap& GetFactories(   );
          
           /**creates and returns a widget associated to the submitted string
           if no widget can be found,   a null pointer is returned
           */
           static Widget* createWidget(  const std::string& name );
          
           /**
           * Registers a widget (  which functor points at ) with a string. The widget can later be loaded through the createWidget method and the same string.
           * @param name The name of the widget,   which can later be used in createWidget
           * @param functor A functor to a Widget,   for example "&WidgetLoader::createWidgetInstance<Help>"
           */
           static void registerWidget(  const std::string& name,   FactoryFunc functor  );
          
          
           /**
           * Use this together with registerWidget,   which requires a functor to a widget as a parameter.
           * @return A functor to a Widget.
           */
           template <typename T> static Widget* createWidgetInstance(   ) { return new T; }
          
          };
          
          }
          
          }
          
          
          
          #endif // WIDGET_H

./components/ogre/widgets/WidgetDefinitions.cpp

       1  //
          // C++ Implementation: WidgetDefinitions
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "WidgetDefinitions.h"
          
          #include "ServerWidget.h"
          // #include "InventoryWidget.h"
          #include "InspectWidget.h"
          #include "MakeEntityWidget.h"
          #include "IngameChatWidget.h"
          //#include "ConsoleWidget.h"
          #include "JesusEdit.h"
          #include "Help.h"
          #include "Quit.h"
          #include "StatusIconBar.h"
          #include "MeshPreview.h"
          
          
          #include "Widget.h"
          namespace EmberOgre
          {
          namespace Gui {
          
      44  WidgetDefinitions::WidgetDefinitions(   )
          {
           WidgetLoader::registerWidget(  "Widget",   &WidgetLoader::createWidgetInstance<Widget> );
           WidgetLoader::registerWidget(  "ServerWidget",   &WidgetLoader::createWidgetInstance<ServerWidget> );
          // WidgetLoader::registerWidget(  "InventoryWidget",   &WidgetLoader::createWidgetInstance<Gui::InventoryWidget> );
           WidgetLoader::registerWidget(  "InspectWidget",   &WidgetLoader::createWidgetInstance<InspectWidget> );
           WidgetLoader::registerWidget(  "MakeEntityWidget",   &WidgetLoader::createWidgetInstance<MakeEntityWidget> );
           WidgetLoader::registerWidget(  "IngameChatWidget",   &WidgetLoader::createWidgetInstance<Gui::IngameChatWidget> );
           //WidgetLoader::registerWidget(  "ConsoleWidget",   &WidgetLoader::createWidgetInstance<ConsoleWidget> );
           WidgetLoader::registerWidget(  "JesusEdit",   &WidgetLoader::createWidgetInstance<JesusEdit> );
           WidgetLoader::registerWidget(  "Help",   &WidgetLoader::createWidgetInstance<Help> );
           WidgetLoader::registerWidget(  "Quit",   &WidgetLoader::createWidgetInstance<Quit> );
           WidgetLoader::registerWidget(  "StatusIconBar",   &WidgetLoader::createWidgetInstance<StatusIconBar> );
           WidgetLoader::registerWidget(  "MeshPreview",   &WidgetLoader::createWidgetInstance<MeshPreview> );
          
          
          
          }
          
          
      64  WidgetDefinitions::~WidgetDefinitions(   )
          {
          }
          
          }
          }

./components/ogre/widgets/WidgetDefinitions.h

       1  //
          // C++ Interface: WidgetDefinitions
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef WIDGETDEFINITIONS_H
          #define WIDGETDEFINITIONS_H
          
          namespace EmberOgre {
          namespace Gui {
          
      29  class Widget;
          typedef Widget* (  *FactoryFunc )(   );
          
          /**
          @author Erik Hjortsberg
          
          Utility class for registering Widgets.
          If you create a new widget,   make sure you add it to this class,   else it won't be linked and you cannot create it dynamically.
          */
      38  class WidgetDefinitions{
          public:
      40   WidgetDefinitions(   );
          
      42   ~WidgetDefinitions(   );
          
          
          
          };
          }
          }
          
          #endif

./components/ogre/widgets/WidgetPool.cpp

       1  //
          // C++ Implementation: WidgetPool
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "WidgetPool.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          
          }
          
          }

./components/ogre/widgets/WidgetPool.h

       1  //
          // C++ Interface: WidgetPool
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUIWIDGETPOOL_H
          #define EMBEROGRE_GUIWIDGETPOOL_H
          
          #include "components/ogre/EmberOgrePrerequisites.h"
          #include <vector>
          #include <stack>
          namespace EmberOgre {
          
          namespace Gui {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
          template <typename T>
      37  class WidgetPool
          {
           public:
           typedef std::vector<T*> WidgetStore;
           typedef std::stack<T*> WidgetStack;
      42   class WidgetCreator
           {
           public:
      45   virtual ~WidgetCreator(   ) {}
      46   virtual T* createWidget(  unsigned int currentPoolSize ) = 0;
           };
      48   WidgetPool(  WidgetCreator& creator ) : mCreator(  creator ) {}
      49   virtual ~WidgetPool(   );
      50   T* checkoutWidget(   );
      51   void returnWidget(  T* widget );
          
      53   void initializePool(  unsigned int initialSize );
          
      55   std::vector<T*>& getUsedWidgets(   );
      56   std::vector<T*>& getWidgetPool(   );
      57   std::stack<T*>& getUnusedWidgets(   );
          
           protected:
      60   WidgetCreator& mCreator;
          
      62   WidgetStore mUsedWidgets;
          
      64   WidgetStore mWidgetsPool;
      65   WidgetStack mUnusedWidgets;
          };
          
          template <typename T>
      69  WidgetPool<T>::~WidgetPool(   )
          {
           for (  typename std::vector<T*>::iterator I = mWidgetsPool.begin(   ); I != mWidgetsPool.end(   ); ++I ) {
           delete *I;
           }
          }
          
          
          template <typename T>
      78  T* WidgetPool<T>::checkoutWidget(   )
          {
           T* widget(  0 );
           if (  !mUnusedWidgets.size(   ) ) {
           widget = mCreator.createWidget(  mWidgetsPool.size(   ) );
           mWidgetsPool.push_back(  widget );
           } else {
           widget = mUnusedWidgets.top(   );
           mUnusedWidgets.pop(   );
           }
           mUsedWidgets.push_back(  widget );
           return widget;class WidgetPool{
          public:
           WidgetPool(   );
          
           ~WidgetPool(   );
          
          };
          
          }
          
          template <typename T>
     100  void WidgetPool<T>::returnWidget(  T* widget )
          {
           mUnusedWidgets.push(  widget );
           typename std::vector<T*>::iterator I = std::find(  mUsedWidgets.begin(   ),   mUsedWidgets.end(   ),   widget );
           if (  I != mUsedWidgets.end(   ) ) {
           mUsedWidgets.erase(  I );
           }
          }
          
          template <typename T>
     110  void WidgetPool<T>::initializePool(  unsigned int initialSize )
          {
           for (  unsigned int i = 0; i < initialSize; ++i ) {
           T* widget = mCreator.createWidget(  mWidgetsPool.size(   ) );
           mWidgetsPool.push_back(  widget );
           mUnusedWidgets.push(  widget );
           }
          }
          
          template <class T>
     120  std::vector<T*>& WidgetPool<T>::getUsedWidgets(   )
          {
           return mUsedWidgets;
          }
          template <typename T>
     125  std::vector<T*>& WidgetPool<T>::getWidgetPool(   )
          {
           return mWidgetsPool;
          }
          template <typename T>
     130  std::stack<T*>& WidgetPool<T>::getUnusedWidgets(   )
          {
           return mUnusedWidgets;
          }
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/AdapterBase.cpp

          //
          // C++ Implementation: AdapterBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AdapterBase.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          
          
      35  AdapterBase::AdapterBase(  const ::Atlas::Message::Element& element )
          : mOriginalElement(  element ),   mEditedElement(  element ),   mRemoved(  false )
          {
          }
          
          
      41  AdapterBase::~AdapterBase(   )
          {
          }
          
      45  void AdapterBase::setValue(  ::Atlas::Message::Element& element )
          {
           updateGui(  element );
           EventValueChanged.emit(   );
          }
          
      51  ::Atlas::Message::Element& AdapterBase::getValue(   )
          {
           fillElementFromGui(   );
           return mEditedElement;
          }
          
      57  const ::Atlas::Message::Element& AdapterBase::getOriginalValue(   ) const
          {
           return mOriginalElement;
          }
          
      62  bool AdapterBase::hasChanges(   )
          {
           if (  mRemoved ) {
           return true;
           }
           return _hasChanges(   );
          }
          
      70  ::Atlas::Message::Element AdapterBase::getChangedElement(   )
          {
           if (  mRemoved ) {
           return ::Atlas::Message::Element(   );
           }
           return _getChangedElement(   );
          }
          
      78  ::Atlas::Message::Element AdapterBase::_getChangedElement(   )
          {
           return getValue(   );
          }
          
      83  void AdapterBase::remove(   )
          {
           mRemoved = true;
          }
          
      88  bool AdapterBase::isRemoved(   ) const
          {
           return mRemoved;
          }
          
      93  void AdapterBase::addSuggestion(  const std::string& suggestedValue )
          {
          }
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/AdapterBase.h

       1  //
          // C++ Interface: AdapterBase
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASADAPTERBASE_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASADAPTERBASE_H
          
          #include <CEGUI.h>
          #include <Atlas/Message/Element.h>
          #include <sigc++/signal.h>
          // namespace CEGUI
          // {
          // class Window;
          // }
          
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      43  static std::string toString(  float number )
          {
           std::stringstream ss;
           ss << number;
           return ss.str(   );
          }
          
      50  class AdapterBase;
          
          struct AdapterWrapper
          {
           AdapterBase* Adapter;
           CEGUI::Window* ContainerWindow;
          };
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      61  class AdapterBase
          {
          public:
      64   AdapterBase(  const ::Atlas::Message::Element& element );
          
      66   virtual ~AdapterBase(   );
          
          
           /**
           Sets the value,   thus also updating the gui.
           */
      72   void setValue(  ::Atlas::Message::Element& element );
          
           ::Atlas::Message::Element& getValue(   );
           const ::Atlas::Message::Element& getOriginalValue(   ) const;
          
           /**
           Emitted when the value has been changed from a gui update.
           */
           sigc::signal<void> EventValueChanged;
          
           /**
           Updates the gui with new values.
           */
           virtual void updateGui(  const ::Atlas::Message::Element& element ) = 0;
          
           bool hasChanges(   );
           ::Atlas::Message::Element getChangedElement(   );
          
           void remove(   );
          
           bool isRemoved(   ) const;
          
           virtual void addSuggestion(  const std::string& suggestedValue );
          
          protected:
          
           const ::Atlas::Message::Element& mOriginalElement;
           ::Atlas::Message::Element mEditedElement;
          
           bool mSelfUpdate;
           bool mRemoved;
          
           virtual void fillElementFromGui(   ) = 0;
           virtual bool _hasChanges(   ) = 0;
           virtual ::Atlas::Message::Element _getChangedElement(   );
          
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/AdapterFactory.cpp

       1  //
          // C++ Implementation: AdapterFactory
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "AdapterFactory.h"
          #include "StringAdapter.h"
          #include "NumberAdapter.h"
          #include "SizeAdapter.h"
          #include "MapAdapter.h"
          #include "ListAdapter.h"
          #include "PositionAdapter.h"
          #include "Position2DAdapter.h"
          #include "OrientationAdapter.h"
          #include "StaticAdapter.h"
          #include <CEGUI.h>
          #include "components/ogre/GUIManager.h"
          #include "services/logging/LoggingService.h"
          #include <Eris/Entity.h>
          
          using namespace CEGUI;
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          unsigned long AdapterFactory::msAutoGenId = 0;
          
      50  AdapterFactory::AdapterFactory(  const std::string prefix )
          : mPrefix(  prefix )
          {
          }
          
          
      56  AdapterFactory::~AdapterFactory(   )
          {
          }
          
      60  StringAdapter* AdapterFactory::createStringAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element )
          {
           if (  !container ) {
           S_LOG_FAILURE(  "No container sent to AdapterFactory::createStringAdapter." );
           return 0;
           }
          
           if (  !element.isString(   ) ) {
           S_LOG_FAILURE(  "Incorrect element type." );
           return 0;
           }
          
           try {
           loadLayoutIntoContainer(  container,   adapterPrefix,   "adapters/atlas/StringAdapter.layout" );
           WindowManager& windowMgr = WindowManager::getSingleton(   );
           Combobox* stringWindow = static_cast<Combobox*>(  windowMgr.getWindow(  mCurrentPrefix + "String" ) );
           StringAdapter* adapter = new StringAdapter(  element,   stringWindow );
          
           return adapter;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating StringAdapter. " << ex.getMessage (   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading StringAdapter. " << ex.what(   ) );
           return 0;
           }
          
          }
          
      89  NumberAdapter* AdapterFactory::createNumberAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element )
          {
           if (  !container ) {
           S_LOG_FAILURE(  "No container sent to AdapterFactory::createNumberAdapter." );
           return 0;
           }
          
           if (  !element.isNum(   ) ) {
           S_LOG_FAILURE(  "Incorrect element type." );
           return 0;
           }
          
           try {
          
           loadLayoutIntoContainer(  container,   adapterPrefix,   "adapters/atlas/NumberAdapter.layout" );
           WindowManager& windowMgr = WindowManager::getSingleton(   );
           Combobox* numberWindow = static_cast<Combobox*>(  windowMgr.getWindow(  mCurrentPrefix + "Number" ) );
           NumberAdapter* adapter = new NumberAdapter(  element,   numberWindow );
          
           return adapter;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating NumberAdapter. " << ex.getMessage (   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading NumberAdapter. " << ex.what(   ) );
           return 0;
           }
          
          }
          
     119  SizeAdapter* AdapterFactory::createSizeAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element )
          {
           if (  !container ) {
           S_LOG_FAILURE(  "No container sent to AdapterFactory::createSizeAdapter." );
           return 0;
           }
          
           if (  !element.isList(   ) ) {
           S_LOG_FAILURE(  "Incorrect element type." );
           return 0;
           }
          
           try {
           loadLayoutIntoContainer(  container,   adapterPrefix,   "adapters/atlas/SizeAdapter.layout" );
           WindowManager& windowMgr = WindowManager::getSingleton(   );
           Window* lowerX = windowMgr.getWindow(  mCurrentPrefix + "lowerX" );
           Window* lowerY = windowMgr.getWindow(  mCurrentPrefix + "lowerY" );
           Window* lowerZ = windowMgr.getWindow(  mCurrentPrefix + "lowerZ" );
           Window* upperX = windowMgr.getWindow(  mCurrentPrefix + "upperX" );
           Window* upperY = windowMgr.getWindow(  mCurrentPrefix + "upperY" );
           Window* upperZ = windowMgr.getWindow(  mCurrentPrefix + "upperZ" );
           Slider* scaler = static_cast<Slider*>(  windowMgr.getWindow(  mCurrentPrefix + "scaler" ) );
           Window* info = windowMgr.getWindow(  mCurrentPrefix + "info" );
           SizeAdapter* adapter = new SizeAdapter(  element,   lowerX,   lowerY,   lowerZ,   upperX,   upperY,   upperZ,   scaler,   info );
          
           return adapter;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating SizeAdapter. " << ex.getMessage (   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading SizeAdapter. " << ex.what(   ) );
           return 0;
           }
          }
          
     154  OrientationAdapter* AdapterFactory::createOrientationAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element )
          {
           if (  !container ) {
           S_LOG_FAILURE(  "No container sent to AdapterFactory::createOrientationAdapter." );
           return 0;
           }
          
           if (  !element.isList(   ) ) {
           S_LOG_FAILURE(  "Incorrect element type." );
           return 0;
           }
          
           try {
           loadLayoutIntoContainer(  container,   adapterPrefix,   "adapters/atlas/OrientationAdapter.layout" );
           WindowManager& windowMgr = WindowManager::getSingleton(   );
           Window* x = windowMgr.getWindow(  mCurrentPrefix + "x" );
           Window* y = windowMgr.getWindow(  mCurrentPrefix + "y" );
           Window* z = windowMgr.getWindow(  mCurrentPrefix + "z" );
           Window* scalar = windowMgr.getWindow(  mCurrentPrefix + "scalar" );
           OrientationAdapter* adapter = new OrientationAdapter(  element,   x,   y,   z,   scalar );
          
           return adapter;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating OrientationAdapter. " << ex.getMessage (   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading OrientationAdapter. " << ex.what(   ) );
           return 0;
           }
          }
          
     185  PositionAdapter* AdapterFactory::createPositionAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element )
          {
           if (  !container ) {
           S_LOG_FAILURE(  "No container sent to AdapterFactory::createPositionAdapter." );
           return 0;
           }
          
           if (  !element.isList(   ) ) {
           S_LOG_FAILURE(  "Incorrect element type." );
           return 0;
           }
          
           try {
           loadLayoutIntoContainer(  container,   adapterPrefix,   "adapters/atlas/PositionAdapter.layout" );
           WindowManager& windowMgr = WindowManager::getSingleton(   );
           Window* x = windowMgr.getWindow(  mCurrentPrefix + "x" );
           Window* y = windowMgr.getWindow(  mCurrentPrefix + "y" );
           Window* z = windowMgr.getWindow(  mCurrentPrefix + "z" );
           PositionAdapter* adapter = new PositionAdapter(  element,   x,   y,   z );
          
           return adapter;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating PositionAdapter. " << ex.getMessage (   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading PositionAdapter. " << ex.what(   ) );
           return 0;
           }
          }
          
     215  Position2DAdapter* AdapterFactory::createPosition2DAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element )
          {
           if (  !container ) {
           S_LOG_FAILURE(  "No container sent to AdapterFactory::createPosition2DAdapter." );
           return 0;
           }
          
           if (  !element.isList(   ) ) {
           S_LOG_FAILURE(  "Incorrect element type." );
           return 0;
           }
          
           try {
           loadLayoutIntoContainer(  container,   adapterPrefix,   "adapters/atlas/Position2DAdapter.layout" );
           WindowManager& windowMgr = WindowManager::getSingleton(   );
           Window* x = windowMgr.getWindow(  mCurrentPrefix + "x" );
           Window* y = windowMgr.getWindow(  mCurrentPrefix + "y" );
           Position2DAdapter* adapter = new Position2DAdapter(  element,   x,   y );
          
           return adapter;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when creating Position2DAdapter. " << ex.getMessage (   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading Position2DAdapter. " << ex.what(   ) );
           return 0;
           }
          }
          
     244  MapAdapter* AdapterFactory::createMapAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   Eris::Entity* entity )
          {
           return createMapAdapter(  container,   adapterPrefix,   entity->getAttributes(   ) );
          }
          
     249  MapAdapter* AdapterFactory::createMapAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const std::map<std::string,   ::Atlas::Message::Element> attributes )
          {
           return createMapAdapter(  container,   adapterPrefix,   ::Atlas::Message::Element(  attributes ) );
          }
          
     254  MapAdapter* AdapterFactory::createMapAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element )
          {
           if (  !container ) {
           S_LOG_FAILURE(  "No container sent to AdapterFactory::createMapAdapter." );
           return 0;
           }
          
           if (  !element.isMap(   ) ) {
           S_LOG_FAILURE(  "Incorrect element type." );
           return 0;
           }
          
          
           try {
           Window* window = loadLayoutIntoContainer(  container,   adapterPrefix,   "adapters/atlas/MapAdapter.layout" );
           MapAdapter* adapter = new MapAdapter(  element,   window );
          
           return adapter;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when loading MapAdapter. " << ex.getMessage(   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading MapAdapter. " << ex.what(   ) );
           return 0;
           }
          }
          
     281  ListAdapter* AdapterFactory::createListAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element )
          {
           if (  !container ) {
           S_LOG_FAILURE(  "No container sent to AdapterFactory::createListAdapter." );
           return 0;
           }
          
           if (  !element.isList(   ) ) {
           S_LOG_FAILURE(  "Incorrect element type." );
           return 0;
           }
          
           try {
           Window* window = loadLayoutIntoContainer(  container,   adapterPrefix,   "adapters/atlas/ListAdapter.layout" );
           ListAdapter* adapter = new ListAdapter(  element,   window );
          
           return adapter;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when loading ListAdapter. " << ex.getMessage(   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading ListAdapter. " << ex.what(   ) );
           return 0;
           }
          }
          
     307  StaticAdapter* AdapterFactory::createStaticAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element )
          {
           if (  !container ) {
           S_LOG_FAILURE(  "No container sent to AdapterFactory::createStaticAdapter." );
           return 0;
           }
          
           if (  !(  element.isString(   ) || element.isNum(   ) ) ) {
           S_LOG_FAILURE(  "Incorrect element type." );
           return 0;
           }
          
           try {
           Window* window = loadLayoutIntoContainer(  container,   adapterPrefix,   "adapters/atlas/StaticAdapter.layout" );
           StaticAdapter* adapter = new StaticAdapter(  element,   window );
          
           return adapter;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when loading StaticAdapter. " << ex.getMessage(   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_FAILURE(  "Error when loading StaticAdapter. " << ex.what(   ) );
           return 0;
           }
          }
          
     333  CEGUI::Window* AdapterFactory::loadLayoutIntoContainer(  CEGUI::Window* container,   const std::string& adapterPrefix,   const std::string& layoutfile )
          {
           try {
           CEGUI::WindowManager& windowManager = CEGUI::WindowManager::getSingleton(   );
          
           std::string finalFileName(  GUIManager::getSingleton(   ).getLayoutDir(   ) + layoutfile );
           std::stringstream ss;
           ss << mPrefix << adapterPrefix << (  msAutoGenId++ );
           mCurrentPrefix = ss.str(   );
           CEGUI::Window* window = windowManager.loadWindowLayout(  finalFileName,   mCurrentPrefix );
           container->addChildWindow(  window );
           container->setHeight(  window->getHeight(   ) );
           container->setWidth(  window->getWidth(   ) );
           return window;
           } catch (  const CEGUI::Exception& ex ) {
           S_LOG_FAILURE(  "Error when loading" << layoutfile <<": " << ex.getMessage(   ).c_str(   ) );
           return 0;
           } catch (  const std::exception& ex ) {
           S_LOG_WARNING(  "Error when loading " << layoutfile <<": " << ex.what(   ) );
           return 0;
           }
          }
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/AdapterFactory.h

       1  //
          // C++ Interface: AdapterFactory
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASADAPTERFACTORY_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASADAPTERFACTORY_H
          #include <Atlas/Message/Element.h>
          
          namespace CEGUI
          {
      29  class Window;
          }
          
          namespace Eris
          {
      34  class Entity;
          }
          
      37  namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          class StringAdapter;
          class NumberAdapter;
          class SizeAdapter;
          class MapAdapter;
          class ListAdapter;
          class PositionAdapter;
          class Position2DAdapter;
          class OrientationAdapter;
          class StaticAdapter;
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
          class AdapterFactory{
          public:
           AdapterFactory(  const std::string prefix );
          
           ~AdapterFactory(   );
          
           StringAdapter* createStringAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element );
           NumberAdapter* createNumberAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element );
           SizeAdapter* createSizeAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element );
           PositionAdapter* createPositionAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element );
           Position2DAdapter* createPosition2DAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element );
           MapAdapter* createMapAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element );
           MapAdapter* createMapAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::MapType attributes );
           MapAdapter* createMapAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   Eris::Entity* entity );
           OrientationAdapter* createOrientationAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element );
           ListAdapter* createListAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element );
           StaticAdapter* createStaticAdapter(  CEGUI::Window* container,   const std::string& adapterPrefix,   const ::Atlas::Message::Element& element );
          
           CEGUI::Window* loadLayoutIntoContainer(  CEGUI::Window* container,   const std::string& adapterPrefix,   const std::string& layoutfile );
          
           inline const std::string& getCurrentPrefix(   ) const;
          
          protected:
          
          
           static unsigned long msAutoGenId;
           std::string mPrefix;
           std::string mCurrentPrefix;
          
          };
          
          const std::string& AdapterFactory::getCurrentPrefix(   ) const
          {
           return mCurrentPrefix;
          }
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/CustomAdapter.cpp

       1  //
          // C++ Implementation: CustomAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "CustomAdapter.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      33  CustomAdapter::CustomAdapter(  const ::Atlas::Message::Element& element )
          : AdapterBase(  element )
          {
          }
          
          
      39  CustomAdapter::~CustomAdapter(   )
          {
          }
          
      43  void CustomAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
           QueryUpdateGui(  &element );
          }
          
      48  void CustomAdapter::fillElementFromGui(   )
          {
           Element element;
           QueryFillElementFromGui(  &element );
          }
      53  bool CustomAdapter::_hasChanges(   )
          {
           bool hasChanges;
           QueryHasChanges(  hasChanges );
           return hasChanges;
          }
      59  ::Atlas::Message::Element CustomAdapter::_getChangedElement(   )
          {
           Element element;
           QueryGetChangedElement(  &element );
           return element;
          }
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/CustomAdapter.h

       1  //
          // C++ Interface: CustomAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASCUSTOMADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASCUSTOMADAPTER_H
          
          #include "AdapterBase.h"
          
          using Atlas::Message::Element;
          using Atlas::Message::ListType;
          using Atlas::Message::MapType;
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      43  class CustomAdapter : public AdapterBase,   public sigc::trackable
          {
          public:
      46   CustomAdapter(  const ::Atlas::Message::Element& element );
          
      48   virtual ~CustomAdapter(   );
          
           /**
           Updates the gui with new values.
           */
      53   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
      55   sigc::signal<void,   bool&> QueryHasChanges;
      56   sigc::signal<void,   const ::Atlas::Message::Element*> QueryUpdateGui;
      57   sigc::signal<void,   ::Atlas::Message::Element*> QueryFillElementFromGui;
      58   sigc::signal<void,   ::Atlas::Message::Element*> QueryGetChangedElement;
          
          protected:
          
      62   virtual void fillElementFromGui(   );
      63   virtual bool _hasChanges(   );
           virtual ::Atlas::Message::Element _getChangedElement(   );
          
          
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/ListAdapter.cpp

       1  //
          // C++ Implementation: ListAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ListAdapter.h"
          
          using Atlas::Message::Element;
          using Atlas::Message::ListType;
          using Atlas::Message::MapType;
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      37  ListAdapter::ListAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* childContainer )
          : AdapterBase(  element ),   mChildContainer(  childContainer ),   mAttributes(  element.asList(   ) )
          {
          }
          
          
      43  ListAdapter::~ListAdapter(   )
          {
           removeAdapters(   );
          }
          
      48  size_t ListAdapter::getSize(   )
          {
           return mAttributes.size(   );
          }
          
          
      54  const ::Atlas::Message::Element& ListAdapter::valueOfAttr(  size_t index ) const
          {
           static Element emptyElement;
           if (  index > mAttributes.size(   ) )
           {
           return emptyElement;
           } else {
           return mAttributes[index];
           }
          }
          
          
      66  void ListAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
          }
          
          
      71  void ListAdapter::fillElementFromGui(   )
          {
          
          }
          
      76  bool ListAdapter::_hasChanges(   )
          {
           bool hasChanges = false;
           for (  AdapterStore::iterator I = mAdapters.begin(   ); I != mAdapters.end(   ); ++I ) {
           hasChanges = hasChanges || I->Adapter->hasChanges(   );
           }
           return hasChanges;
          }
          
          
      86  void ListAdapter::addAttributeAdapter(  Adapters::Atlas::AdapterBase* adapter,   CEGUI::Window* containerWindow )
          {
           AdapterWrapper wrapper;
           wrapper.Adapter = adapter;
           wrapper.ContainerWindow = containerWindow;
           mAdapters.push_back(  wrapper );
          }
          
      94  void ListAdapter::removeAdapters(   )
          {
           for (  AdapterStore::iterator I = mAdapters.begin(   ); I != mAdapters.end(   ); ++I ) {
           delete I->Adapter;
          // I->second.ContainerWindow->getParent(   )->removeChildWindow(  I->second.ContainerWindow );
           CEGUI::WindowManager::getSingleton(   ).destroyWindow(  I->ContainerWindow );
           }
           mAdapters.clear(   );
          }
          
     104  ::Atlas::Message::Element ListAdapter::_getChangedElement(   )
          {
           ///if one adapter has changes,   we have to send all
           ::Atlas::Message::ListType attributes;
           for (  AdapterStore::iterator I = mAdapters.begin(   ); I != mAdapters.end(   ); ++I ) {
           Adapters::Atlas::AdapterBase* adapter = I->Adapter;
           if (  !adapter->isRemoved(   ) ) {
           attributes.push_back(  adapter->getChangedElement(   ) );
           }
           }
           return Element(  attributes );
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/ListAdapter.h

          //
          // C++ Interface: ListAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASLISTADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASLISTADAPTER_H
          
          #include "AdapterBase.h"
          // #include "components/ogre/widgets/StackableContainer.h"
          
          
          namespace CEGUI {
      31   class Window;
          }
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      45  class ListAdapter : public AdapterBase
          {
          public:
      48   ListAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* childContainer );
          
      50   virtual ~ListAdapter(   );
          
          
      53   size_t getSize(   );
      54   const ::Atlas::Message::Element& valueOfAttr(  size_t index ) const;
          
           /**
           Updates the gui with new values.
           */
      59   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
          // void addAttributeAdapter(  int index,   Adapters::Atlas::AdapterBase* adapter,   CEGUI::Window* containerWindow );
      62   void addAttributeAdapter(  Adapters::Atlas::AdapterBase* adapter,   CEGUI::Window* containerWindow );
      63   void removeAdapters(   );
          
          protected:
           typedef std::vector<AdapterWrapper> AdapterStore;
          
           CEGUI::Window* mChildContainer;
          // StackableContainer mStackableContainer;
      70   const ::Atlas::Message::ListType& mAttributes;
          
           AdapterStore mAdapters;
          
      74   virtual void fillElementFromGui(   );
      75   virtual bool _hasChanges(   );
           virtual ::Atlas::Message::Element _getChangedElement(   );
          
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/MapAdapter.cpp

          //
          // C++ Implementation: MapAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "MapAdapter.h"
          
          using Atlas::Message::Element;
          using Atlas::Message::ListType;
          using Atlas::Message::MapType;
          
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          
      39  MapAdapter::MapAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* childContainer )
          : AdapterBase(  element ),   mChildContainer(  childContainer ),  
          mAttributes(  element.asMap(   ) )
          {
          }
          
          
      46  MapAdapter::~MapAdapter(   )
          {
           removeAdapters(   );
          }
          
      51  const ::Atlas::Message::Element& MapAdapter::valueOfAttr(  const std::string& attr ) const
          {
           static Element emptyElement;
           ::Atlas::Message::MapType::const_iterator A = mAttributes.find(  attr );
           if (  A == mAttributes.end(   ) )
           {
           return emptyElement;
           } else {
           return A->second;
           }
          }
          
      63  bool MapAdapter::hasAttr(  const std::string& attr ) const
          {
           return mAttributes.count(  attr ) > 0;
          }
          
      68  void MapAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
          }
          
          
      73  void MapAdapter::fillElementFromGui(   )
          {
          
          }
          
      78  bool MapAdapter::_hasChanges(   )
          {
           bool hasChanges = false;
           for (  AdapterStore::iterator I = mAdapters.begin(   ); I != mAdapters.end(   ); ++I ) {
           hasChanges = hasChanges || I->second.Adapter->hasChanges(   );
           }
           return hasChanges;
          }
          
      87  std::vector<std::string> MapAdapter::getAttributeNames(   )
          {
           std::vector<std::string> attributeNames;
           for (  ::Atlas::Message::MapType::const_iterator I = mAttributes.begin(   ); I != mAttributes.end(   ); ++I ) {
           attributeNames.push_back(  I->first );
           }
           return attributeNames;
          }
          
      96  void MapAdapter::addAttributeAdapter(  const std::string& attributeName,   Adapters::Atlas::AdapterBase* adapter,   CEGUI::Window* containerWindow )
          {
           AdapterWrapper wrapper;
           wrapper.Adapter = adapter;
           wrapper.ContainerWindow = containerWindow;
           mAdapters.insert(  AdapterStore::value_type(  attributeName,   wrapper ) );
          }
          
     104  void MapAdapter::removeAdapters(   )
          {
           for (  AdapterStore::iterator I = mAdapters.begin(   ); I != mAdapters.end(   ); ++I ) {
           delete I->second.Adapter;
          // I->second.ContainerWindow->getParent(   )->removeChildWindow(  I->second.ContainerWindow );
           CEGUI::WindowManager::getSingleton(   ).destroyWindow(  I->second.ContainerWindow );
           }
           mAdapters.clear(   );
          }
          
     114  ::Atlas::Message::Element MapAdapter::_getChangedElement(   )
          {
           ::Atlas::Message::MapType attributes;
           for (  AdapterStore::iterator I = mAdapters.begin(   ); I != mAdapters.end(   ); ++I ) {
           Adapters::Atlas::AdapterBase* adapter = I->second.Adapter;
           if (  !adapter->isRemoved(   ) ) {
           attributes.insert(  std::map<std::string,   ::Atlas::Message::Element>::value_type(  I->first,   adapter->getChangedElement(   ) ) );
           }
           }
           return Element(  attributes );
          }
          
     126  ::Atlas::Message::Element MapAdapter::getSelectedChangedElements(   )
          {
           ::Atlas::Message::MapType attributes;
           for (  AdapterStore::iterator I = mAdapters.begin(   ); I != mAdapters.end(   ); ++I ) {
           Adapters::Atlas::AdapterBase* adapter = I->second.Adapter;
           if (  adapter->hasChanges(   ) && !adapter->isRemoved(   ) ) {
           attributes.insert(  std::map<std::string,   ::Atlas::Message::Element>::value_type(  I->first,   adapter->getChangedElement(   ) ) );
           }
           }
           return Element(  attributes );
          }
          
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/MapAdapter.h

          //
          // C++ Interface: MapAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASMAPADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASMAPADAPTER_H
          
          #include "AdapterBase.h"
          #include "components/ogre/widgets/StackableContainer.h"
          
          
          namespace CEGUI {
      31   class Window;
          }
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          
          
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      48  class MapAdapter : public AdapterBase
          {
          public:
          
      52   MapAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* childContainer );
          
      54   virtual ~MapAdapter(   );
          
      56   std::vector<std::string> getAttributeNames(   );
          
      58   const ::Atlas::Message::Element& valueOfAttr(  const std::string& attr ) const;
      59   bool hasAttr(  const std::string& attr ) const;
          
           /**
           Updates the gui with new values.
           */
      64   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
      66   void addAttributeAdapter(  const std::string& attributeName,   Adapters::Atlas::AdapterBase* adapter,   CEGUI::Window* containerWindow );
      67   void removeAdapters(   );
          
      69   ::Atlas::Message::Element getSelectedChangedElements(   );
          
          protected:
           typedef std::map<std::string,   AdapterWrapper> AdapterStore;
          
           CEGUI::Window* mChildContainer;
          // StackableContainer mStackableContainer;
      76   const ::Atlas::Message::MapType& mAttributes;
          
           AdapterStore mAdapters;
          
      80   virtual void fillElementFromGui(   );
           virtual bool _hasChanges(   );
           virtual ::Atlas::Message::Element _getChangedElement(   );
          
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/NumberAdapter.cpp

       1  //
          // C++ Implementation: NumberAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NumberAdapter.h"
          #include "../../ColouredListItem.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      34  NumberAdapter::NumberAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Combobox* textWindow )
          : AdapterBase(  element )
          ,   mTextWindow(  textWindow )
          {
           if (  textWindow ) {
           textWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &NumberAdapter::window_TextChanged,   this ) );
           }
           updateGui(  mOriginalElement );
           mTextWindow->getPushButton(   )->setVisible(  false );
          
          }
          
          
      47  NumberAdapter::~NumberAdapter(   )
          {
          }
          
      51  void NumberAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
           mSelfUpdate = true;
           if (  mTextWindow ) {
           std::stringstream ss;
           ss << element.asNum(   );
           mTextWindow->setText(  ss.str(   ) );
           }
           mSelfUpdate = false;
          }
          
      62  bool NumberAdapter::window_TextChanged(  const CEGUI::EventArgs& e )
          {
           if (  !mSelfUpdate ) {
           EventValueChanged.emit(   );
           }
           return true;
          }
          
          
          
      72  void NumberAdapter::fillElementFromGui(   )
          {
           if (  mOriginalElement.isInt(   ) ) {
           mEditedElement = ::Atlas::Message::Element(  atoi(  mTextWindow->getText(   ).c_str(   ) ) );
           } else {
           mEditedElement = ::Atlas::Message::Element(  atof(  mTextWindow->getText(   ).c_str(   ) ) );
           }
          }
          
      81  bool NumberAdapter::_hasChanges(   )
          {
           return mOriginalElement.asNum(   ) != getValue(   ).asNum(   );
          }
          
      86  void NumberAdapter::addSuggestion(  const std::string& suggestedValue )
          {
           mTextWindow->addItem(  new ColouredListItem(  suggestedValue ) );
           mTextWindow->getPushButton(   )->setVisible(  true );
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/NumberAdapter.h

       1  //
          // C++ Interface: NumberAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASNUMBERADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASNUMBERADAPTER_H
          
          #include "AdapterBase.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      39  class NumberAdapter : AdapterBase
          {
          public:
      42   NumberAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Combobox* textWindow );
          
      44   virtual ~NumberAdapter(   );
          
           /**
           Updates the gui with new values.
           */
      49   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
      51   virtual void addSuggestion(  const std::string& suggestedValue );
          
          protected:
      54   CEGUI::Combobox* mTextWindow;
      55   bool window_TextChanged(  const CEGUI::EventArgs& e );
          
      57   virtual void fillElementFromGui(   );
      58   virtual bool _hasChanges(   );
          
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/OrientationAdapter.cpp

       1  //
          // C++ Implementation: OrientationAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "OrientationAdapter.h"
          #include <wfmath/quaternion.h>
          #include <wfmath/atlasconv.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      35  OrientationAdapter::OrientationAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* xWindow,   CEGUI::Window* yWindow,   CEGUI::Window* zWindow,   CEGUI::Window* scalarWindow )
          : AdapterBase(  element ),   mXWindow(  xWindow ),   mYWindow(  yWindow ),   mZWindow(  zWindow ),   mScalarWindow(  scalarWindow )
          {
           if (  mXWindow ) {
           mXWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &OrientationAdapter::window_TextChanged,   this ) );
           }
           if (  mYWindow ) {
           mYWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &OrientationAdapter::window_TextChanged,   this ) );
           }
           if (  mZWindow ) {
           mZWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &OrientationAdapter::window_TextChanged,   this ) );
           }
           if (  mScalarWindow ) {
           mScalarWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &OrientationAdapter::window_TextChanged,   this ) );
           }
          
          
           updateGui(  mOriginalElement );
          }
          
          
      56  OrientationAdapter::~OrientationAdapter(   )
          {
          }
          
      60  void OrientationAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
           mSelfUpdate = true;
           WFMath::Quaternion orientation(  element );
          // axisBox.fromAtlas(  element.asList(   ) );
           if (  mXWindow ) {
           mXWindow->setText(  toString(  orientation.vector(   ).x(   ) ) );
           }
           if (  mYWindow ) {
           mYWindow->setText(  toString(  orientation.vector(   ).y(   ) ) );
           }
           if (  mZWindow ) {
           mZWindow->setText(  toString(  orientation.vector(   ).z(   ) ) );
           }
           if (  mScalarWindow ) {
           mScalarWindow->setText(  toString(  orientation.scalar(   ) ) );
           }
          
           mSelfUpdate = false;
          }
          
      81  bool OrientationAdapter::window_TextChanged(  const CEGUI::EventArgs& e )
          {
           if (  !mSelfUpdate ) {
           EventValueChanged.emit(   );
           }
           return true;
          }
          
      89  void OrientationAdapter::fillElementFromGui(   )
          {
           float x(  0 ),   y(  0 ),   z(  0 ),   scalar(  0 );
           if (  mXWindow ) {
           x = atof(  mXWindow->getText(   ).c_str(   ) );
           }
           if (  mYWindow ) {
           y = atof(  mYWindow->getText(   ).c_str(   ) );
           }
           if (  mZWindow ) {
           z = atof(  mZWindow->getText(   ).c_str(   ) );
           }
           if (  mScalarWindow ) {
           scalar = atof(  mScalarWindow->getText(   ).c_str(   ) );
           }
           WFMath::Quaternion orientation(  scalar,   x,   y,   z );
           mEditedElement = orientation.toAtlas(   );
          }
          
     108  bool OrientationAdapter::_hasChanges(   )
          {
           WFMath::Quaternion originalOrientation(  mOriginalElement );
           WFMath::Quaternion newOrientation(  getValue(   ) );
           return originalOrientation != newOrientation;
          }
          
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/OrientationAdapter.h

       1  //
          // C++ Interface: OrientationAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASORIENTATIONADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASORIENTATIONADAPTER_H
          
          #include "AdapterBase.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      39  class OrientationAdapter : public AdapterBase
          {
          public:
      42   OrientationAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* xWindow,   CEGUI::Window* yWindow,   CEGUI::Window* zWindow,   CEGUI::Window* scalarWindow );
          
      44   virtual ~OrientationAdapter(   );
          
           /**
           Updates the gui with new values.
           */
      49   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
          protected:
      52   CEGUI::Window* mXWindow;
      53   CEGUI::Window* mYWindow;
      54   CEGUI::Window* mZWindow;
      55   CEGUI::Window* mScalarWindow;
          
      57   bool window_TextChanged(  const CEGUI::EventArgs& e );
          
      59   virtual void fillElementFromGui(   );
      60   virtual bool _hasChanges(   );
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/Position2DAdapter.cpp

       1  //
          // C++ Implementation: Position2DAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Position2DAdapter.h"
          #include <wfmath/vector.h>
          #include <wfmath/atlasconv.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      35  Position2DAdapter::Position2DAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* xWindow,   CEGUI::Window* yWindow )
          : AdapterBase(  element ),   mXWindow(  xWindow ),   mYWindow(  yWindow )
          {
           if (  mXWindow ) {
           mXWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &Position2DAdapter::window_TextChanged,   this ) );
           }
           if (  mYWindow ) {
           mYWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &Position2DAdapter::window_TextChanged,   this ) );
           }
           updateGui(  mOriginalElement );
          }
          
          
      48  Position2DAdapter::~Position2DAdapter(   )
          {
          }
          
      52  void Position2DAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
           mSelfUpdate = true;
           WFMath::Vector<2> vector(  element );
          // axisBox.fromAtlas(  element.asList(   ) );
           if (  mXWindow ) {
           mXWindow->setText(  toString(  vector.x(   ) ) );
           }
           if (  mYWindow ) {
           mYWindow->setText(  toString(  vector.y(   ) ) );
           }
           mSelfUpdate = false;
          }
          
      66  bool Position2DAdapter::window_TextChanged(  const CEGUI::EventArgs& e )
          {
           if (  !mSelfUpdate ) {
           EventValueChanged.emit(   );
           }
           return true;
          }
          
      74  void Position2DAdapter::fillElementFromGui(   )
          {
           WFMath::Vector<2> vector;
           if (  mXWindow ) {
           vector.x(   ) = atof(  mXWindow->getText(   ).c_str(   ) );
           }
           if (  mYWindow ) {
           vector.y(   ) = atof(  mYWindow->getText(   ).c_str(   ) );
           }
           mEditedElement = vector.toAtlas(   );
          }
          
      86  bool Position2DAdapter::_hasChanges(   )
          {
           WFMath::Vector<2> originalValue;
           originalValue.fromAtlas(  mOriginalElement );
           WFMath::Vector<2> newValue;
           newValue.fromAtlas(  getValue(   ) );
           return originalValue != newValue;
          }
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/Position2DAdapter.h

       1  //
          // C++ Interface: Position2DAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASPOSITION2DADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASPOSITION2DADAPTER_H
          
          #include "AdapterBase.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      39  class Position2DAdapter : public AdapterBase
          {
          public:
      42   Position2DAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* xWindow,   CEGUI::Window* yWindow );
          
      44   virtual ~Position2DAdapter(   );
          
           /**
           Updates the gui with new values.
           */
      49   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
          protected:
          
      53   CEGUI::Window* mXWindow;
      54   CEGUI::Window* mYWindow;
          
      56   bool window_TextChanged(  const CEGUI::EventArgs& e );
          
      58   virtual void fillElementFromGui(   );
      59   virtual bool _hasChanges(   );
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/PositionAdapter.cpp

       1  //
          // C++ Implementation: PositionAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "PositionAdapter.h"
          #include <wfmath/vector.h>
          #include <wfmath/atlasconv.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      35  PositionAdapter::PositionAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* xWindow,   CEGUI::Window* yWindow,   CEGUI::Window* zWindow )
          : AdapterBase(  element ),   mXWindow(  xWindow ),   mYWindow(  yWindow ),   mZWindow(  zWindow )
          {
           if (  mXWindow ) {
           mXWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &PositionAdapter::window_TextChanged,   this ) );
           }
           if (  mYWindow ) {
           mYWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &PositionAdapter::window_TextChanged,   this ) );
           }
           if (  mZWindow ) {
           mZWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &PositionAdapter::window_TextChanged,   this ) );
           }
          
           updateGui(  mOriginalElement );
          }
          
          
      52  PositionAdapter::~PositionAdapter(   )
          {
          }
          
      56  void PositionAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
           mSelfUpdate = true;
           WFMath::Vector<3> vector(  element );
          // axisBox.fromAtlas(  element.asList(   ) );
           if (  mXWindow ) {
           mXWindow->setText(  toString(  vector.x(   ) ) );
           }
           if (  mYWindow ) {
           mYWindow->setText(  toString(  vector.y(   ) ) );
           }
           if (  mZWindow ) {
           mZWindow->setText(  toString(  vector.z(   ) ) );
           }
           mSelfUpdate = false;
          }
          
      73  bool PositionAdapter::window_TextChanged(  const CEGUI::EventArgs& e )
          {
           if (  !mSelfUpdate ) {
           EventValueChanged.emit(   );
           }
           return true;
          }
          
      81  void PositionAdapter::fillElementFromGui(   )
          {
           WFMath::Vector<3> vector;
           if (  mXWindow ) {
           vector.x(   ) = atof(  mXWindow->getText(   ).c_str(   ) );
           }
           if (  mYWindow ) {
           vector.y(   ) = atof(  mYWindow->getText(   ).c_str(   ) );
           }
           if (  mZWindow ) {
           vector.z(   ) = atof(  mZWindow->getText(   ).c_str(   ) );
           }
           mEditedElement = vector.toAtlas(   );
          }
          
      96  bool PositionAdapter::_hasChanges(   )
          {
           WFMath::Vector<3> originalValue;
           originalValue.fromAtlas(  mOriginalElement );
           WFMath::Vector<3> newValue;
           newValue.fromAtlas(  getValue(   ) );
           return originalValue != newValue;
          }
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/PositionAdapter.h

       1  //
          // C++ Interface: PositionAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASPOSITIONADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASPOSITIONADAPTER_H
          
          #include "AdapterBase.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      39  class PositionAdapter : public AdapterBase
          {
          public:
      42   PositionAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* xWindow,   CEGUI::Window* yWindow,   CEGUI::Window* zWindow );
          
      44   virtual ~PositionAdapter(   );
          
           /**
           Updates the gui with new values.
           */
      49   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
          protected:
          
      53   CEGUI::Window* mXWindow;
      54   CEGUI::Window* mYWindow;
      55   CEGUI::Window* mZWindow;
          
      57   bool window_TextChanged(  const CEGUI::EventArgs& e );
          
      59   virtual void fillElementFromGui(   );
      60   virtual bool _hasChanges(   );
          
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/SizeAdapter.cpp

       1  //
          // C++ Implementation: SizeAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "SizeAdapter.h"
          #include <wfmath/axisbox.h>
          #include <wfmath/atlasconv.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      35  SizeAdapter::SizeAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* lowerXWindow,   CEGUI::Window* lowerYWindow,   CEGUI::Window* lowerZWindow,   CEGUI::Window* upperXWindow,   CEGUI::Window* upperYWindow,   CEGUI::Window* upperZWindow,   CEGUI::Slider* scaler,   CEGUI::Window* infoWindow )
          : AdapterBase(  element ),   mLowerXWindow(  lowerXWindow ),   mLowerYWindow(  lowerYWindow ),   mLowerZWindow(  lowerZWindow ),   mUpperXWindow(  upperXWindow ),   mUpperYWindow(  upperYWindow ),   mUpperZWindow(  upperZWindow ),   mScaler(  scaler ),   mInfoWindow(  infoWindow )
          {
           if (  mLowerXWindow ) {
           mLowerXWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &SizeAdapter::window_TextChanged,   this ) );
           }
           if (  mLowerYWindow ) {
           mLowerYWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &SizeAdapter::window_TextChanged,   this ) );
           }
           if (  mLowerZWindow ) {
           mLowerZWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &SizeAdapter::window_TextChanged,   this ) );
           }
           if (  mUpperXWindow ) {
           mUpperXWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &SizeAdapter::window_TextChanged,   this ) );
           }
           if (  mUpperYWindow ) {
           mUpperYWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &SizeAdapter::window_TextChanged,   this ) );
           }
           if (  mUpperZWindow ) {
           mUpperZWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &SizeAdapter::window_TextChanged,   this ) );
           }
           if (  mScaler ) {
           mScaler->subscribeEvent(  CEGUI::Slider::EventValueChanged,   CEGUI::Event::Subscriber(  &SizeAdapter::slider_ValueChanged,   this ) );
           }
          
          
           updateGui(  mOriginalElement );
          }
          
          
      65  SizeAdapter::~SizeAdapter(   )
          {
          }
          
      69  void SizeAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
           mSelfUpdate = true;
           WFMath::AxisBox<3> axisBox(  element );
          // axisBox.fromAtlas(  element.asList(   ) );
           if (  mLowerXWindow ) {
           mLowerXWindow->setText(  toString(  axisBox.lowCorner(   ).x(   ) ) );
           }
           if (  mLowerYWindow ) {
           mLowerYWindow->setText(  toString(  axisBox.lowCorner(   ).y(   ) ) );
           }
           if (  mLowerZWindow ) {
           mLowerZWindow->setText(  toString(  axisBox.lowCorner(   ).z(   ) ) );
           }
           if (  mUpperXWindow ) {
           mUpperXWindow->setText(  toString(  axisBox.highCorner(   ).x(   ) ) );
           }
           if (  mUpperYWindow ) {
           mUpperYWindow->setText(  toString(  axisBox.highCorner(   ).y(   ) ) );
           }
           if (  mUpperZWindow ) {
           mUpperZWindow->setText(  toString(  axisBox.highCorner(   ).z(   ) ) );
           }
          
           updateInfo(   );
          
           mSelfUpdate = false;
          }
          
      98  bool SizeAdapter::window_TextChanged(  const CEGUI::EventArgs& e )
          {
           if (  !mSelfUpdate ) {
           EventValueChanged.emit(   );
           }
           updateInfo(   );
           return true;
          }
          
     107  void SizeAdapter::updateInfo(   )
          {
           WFMath::AxisBox<3> newBox;
           newBox.fromAtlas(  getValue(   ) );
          
           std::stringstream ss;
           ss.precision(  4 );
           ss << "w: " << (  newBox.highCorner(   ).x(   ) - newBox.lowCorner(   ).x(   ) ) << " d: " << (  newBox.highCorner(   ).y(   ) - newBox.lowCorner(   ).y(   ) ) << " h: " << (  newBox.highCorner(   ).z(   ) - newBox.lowCorner(   ).z(   ) );
           mInfoWindow->setText(  ss.str(   ) );
          }
          
     118  bool SizeAdapter::slider_ValueChanged(  const CEGUI::EventArgs& e )
          {
           float value = mScaler->getCurrentValue(   );
           WFMath::AxisBox<3> newBox;
           newBox.fromAtlas(  mOriginalElement );
           WFMath::Point<3> lowerPoint = newBox.lowCorner(   );
           WFMath::Point<3> upperPoint = newBox.highCorner(   );
           lowerPoint.x(   ) *= value;
           lowerPoint.y(   ) *= value;
           lowerPoint.z(   ) *= value;
           upperPoint.x(   ) *= value;
           upperPoint.y(   ) *= value;
           upperPoint.z(   ) *= value;
           newBox.setCorners(  lowerPoint,   upperPoint );
          // newBox *= value;
           updateGui(  newBox.toAtlas(   ) );
           return true;
          }
          
          
     138  void SizeAdapter::fillElementFromGui(   )
          {
           WFMath::AxisBox<3> axisBox;
           WFMath::Point<3> lowerPoint = axisBox.lowCorner(   );
           WFMath::Point<3> upperPoint = axisBox.highCorner(   );
           if (  mLowerXWindow ) {
           lowerPoint.x(   ) = atof(  mLowerXWindow->getText(   ).c_str(   ) );
           }
           if (  mLowerYWindow ) {
           lowerPoint.y(   ) = atof(  mLowerYWindow->getText(   ).c_str(   ) );
           }
           if (  mLowerZWindow ) {
           lowerPoint.z(   ) = atof(  mLowerZWindow->getText(   ).c_str(   ) );
           }
           if (  mUpperXWindow ) {
           upperPoint.x(   ) = atof(  mUpperXWindow->getText(   ).c_str(   ) );
           }
           if (  mUpperYWindow ) {
           upperPoint.y(   ) = atof(  mUpperYWindow->getText(   ).c_str(   ) );
           }
           if (  mUpperZWindow ) {
           upperPoint.z(   ) = atof(  mUpperZWindow->getText(   ).c_str(   ) );
           }
           axisBox.setCorners(  lowerPoint,   upperPoint );
           mEditedElement = axisBox.toAtlas(   );
          }
          
     165  bool SizeAdapter::_hasChanges(   )
          {
           WFMath::AxisBox<3> originalBox;
           originalBox.fromAtlas(  mOriginalElement );
           WFMath::AxisBox<3> newBox;
           newBox.fromAtlas(  getValue(   ) );
           return originalBox != newBox;
          }
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/SizeAdapter.h

       1  //
          // C++ Interface: SizeAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASSIZEADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASSIZEADAPTER_H
          
          #include "AdapterBase.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      39  class SizeAdapter : public AdapterBase
          {
          public:
      42   SizeAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* lowerXWindow,   CEGUI::Window* lowerYWindow,   CEGUI::Window* lowerZWindow,   CEGUI::Window* upperXWindow,   CEGUI::Window* upperYWindow,   CEGUI::Window* upperZWindow,   CEGUI::Slider* scaler,   CEGUI::Window* infoWindow );
          
      44   virtual ~SizeAdapter(   );
          
           /**
           Updates the gui with new values.
           */
      49   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
          protected:
      52   CEGUI::Window* mLowerXWindow;
      53   CEGUI::Window* mLowerYWindow;
      54   CEGUI::Window* mLowerZWindow;
      55   CEGUI::Window* mUpperXWindow;
      56   CEGUI::Window* mUpperYWindow;
      57   CEGUI::Window* mUpperZWindow;
      58   CEGUI::Slider* mScaler;
      59   CEGUI::Window* mInfoWindow;
          
           /**
           Updates the info window with measurement information.
           */
      64   void updateInfo(   );
          
      66   bool window_TextChanged(  const CEGUI::EventArgs& e );
      67   bool slider_ValueChanged(  const CEGUI::EventArgs& e );
          
      69   virtual void fillElementFromGui(   );
      70   virtual bool _hasChanges(   );
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/StaticAdapter.cpp

       1  //
          // C++ Implementation: StaticAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "StaticAdapter.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      33  StaticAdapter::StaticAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* textWindow )
          : AdapterBase(  element )
          ,   mTextWindow(  textWindow )
          {
           updateGui(  mOriginalElement );
          }
          
          
      41  StaticAdapter::~StaticAdapter(   )
          {
          }
          
      45  void StaticAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
           mSelfUpdate = true;
           if (  mTextWindow ) {
           if (  element.isString(   ) ) {
           mTextWindow->setText(  element.asString(   ) );
           } else if (  element.isNum(   ) ) {
           std::stringstream ss;
           ss << element.asNum(   );
           mTextWindow->setText(  ss.str(   ) );
           }
           }
           mSelfUpdate = false;
          }
          
      60  void StaticAdapter::fillElementFromGui(   )
          {
          }
          
      64  bool StaticAdapter::_hasChanges(   )
          {
           return false;
          }
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/StaticAdapter.h

       1  //
          // C++ Interface: StaticAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASSTATICADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASSTATICADAPTER_H
          
          #include "AdapterBase.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      39  class StaticAdapter : public AdapterBase
          {
          public:
      42   StaticAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Window* textWindow );
          
      44   virtual ~StaticAdapter(   );
          
           /**
           Updates the gui with new values.
           */
      49   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
          protected:
      52   CEGUI::Window* mTextWindow;
          
      54   virtual void fillElementFromGui(   );
      55   virtual bool _hasChanges(   );
          
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/StringAdapter.cpp

       1  //
          // C++ Implementation: StringAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "StringAdapter.h"
          #include "../../ColouredListItem.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
      34  StringAdapter::StringAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Combobox* textWindow )
          : AdapterBase(  element )
          ,   mTextWindow(  textWindow )
          {
           if (  textWindow ) {
           textWindow->subscribeEvent(  CEGUI::Window::EventTextChanged,   CEGUI::Event::Subscriber(  &StringAdapter::window_TextChanged,   this ) );
           }
           updateGui(  mOriginalElement );
           mTextWindow->getPushButton(   )->setVisible(  false );
          
          }
          
          
      47  StringAdapter::~StringAdapter(   )
          {
          }
          
      51  void StringAdapter::updateGui(  const ::Atlas::Message::Element& element )
          {
           mSelfUpdate = true;
           if (  mTextWindow ) {
           mTextWindow->setText(  element.asString(   ) );
           }
           mSelfUpdate = false;
          }
          
      60  bool StringAdapter::window_TextChanged(  const CEGUI::EventArgs& e )
          {
           if (  !mSelfUpdate ) {
           EventValueChanged.emit(   );
           }
           return true;
          }
          
          
          
      70  void StringAdapter::fillElementFromGui(   )
          {
           mEditedElement = ::Atlas::Message::Element(  mTextWindow->getText(   ).c_str(   ) );
          }
          
      75  bool StringAdapter::_hasChanges(   )
          {
           return mOriginalElement.asString(   ) != getValue(   ).asString(   );
          }
          
      80  void StringAdapter::addSuggestion(  const std::string& suggestedValue )
          {
           mTextWindow->addItem(  new ColouredListItem(  suggestedValue ) );
           mTextWindow->getPushButton(   )->setVisible(  true );
          }
          
          
          }
          
          }
          
          }
          
          }

./components/ogre/widgets/adapters/atlas/StringAdapter.h

       1  //
          // C++ Interface: StringAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ADAPTERS_ATLASSTRINGADAPTER_H
          #define EMBEROGRE_GUI_ADAPTERS_ATLASSTRINGADAPTER_H
          
          #include "AdapterBase.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Adapters {
          
          namespace Atlas {
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      39  class StringAdapter : AdapterBase
          {
          public:
      42   StringAdapter(  const ::Atlas::Message::Element& element,   CEGUI::Combobox* textWindow );
          
      44   virtual ~StringAdapter(   );
          
           /**
           Updates the gui with new values.
           */
      49   virtual void updateGui(  const ::Atlas::Message::Element& element );
          
      51   virtual void addSuggestion(  const std::string& suggestedValue );
          
          protected:
      54   CEGUI::Combobox* mTextWindow;
      55   bool window_TextChanged(  const CEGUI::EventArgs& e );
          
      57   virtual void fillElementFromGui(   );
      58   virtual bool _hasChanges(   );
          
          };
          
          }
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/adapters/atlas/bindings/lua/bindings.cpp

       1  /*
          ** Lua binding: atlas_adapters
          ** Generated automatically by tolua++-1.0.92 on Tue Oct 9 08:56:23 2007.
          */
          
          #ifndef __cplusplus
          #include "stdlib.h"
          #endif
          #include "string.h"
          
          #include "tolua++.h"
          
          /* Exported function */
      14  TOLUA_API int tolua_atlas_adapters_open (  lua_State* tolua_S );
          
          #include "../../AdapterBase.h"
          #include "../../AdapterFactory.h"
          #include "../../StringAdapter.h"
          #include "../../NumberAdapter.h"
          #include "../../SizeAdapter.h"
          #include "../../MapAdapter.h"
          #include "../../ListAdapter.h"
          #include "../../PositionAdapter.h"
          #include "../../Position2DAdapter.h"
          #include "../../OrientationAdapter.h"
          #include "../../StaticAdapter.h"
          
          /* function to release collected object via destructor */
          #ifdef __cplusplus
          
      31  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__AdapterBase (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      38  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__SizeAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::SizeAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::SizeAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      45  static int tolua_collect_std__vector_std__string_ (  lua_State* tolua_S )
          {
           std::vector<std::string>* self = (  std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      52  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__StaticAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::StaticAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::StaticAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      59  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__ListAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::ListAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::ListAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      66  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__OrientationAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      73  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__Position2DAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      80  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__AdapterFactory (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      87  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__PositionAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::PositionAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::PositionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      94  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__StringAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::StringAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::StringAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     101  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__NumberAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::NumberAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::NumberAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
     108  static int tolua_collect_EmberOgre__Gui__Adapters__Atlas__MapAdapter (  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          #endif
          
          
          /* function to register type */
     118  static void tolua_reg_types (  lua_State* tolua_S )
          {
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase" );
           tolua_usertype(  tolua_S,  "::Atlas::Message::Element" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::SizeAdapter" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter" );
           tolua_usertype(  tolua_S,  "Atlas::Message::MapType" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::StaticAdapter" );
           tolua_usertype(  tolua_S,  "CEGUI::Window" );
           tolua_usertype(  tolua_S,  "Eris::Entity" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::NumberAdapter" );
           tolua_usertype(  tolua_S,  "CEGUI::Combobox" );
           tolua_usertype(  tolua_S,  "std::vector<std::string>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::PositionAdapter" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::OrientationAdapter" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::Position2DAdapter" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory" );
           tolua_usertype(  tolua_S,  "sigc::signal<void>" );
           tolua_usertype(  tolua_S,  "EmberOgre::Gui::Adapters::Atlas::StringAdapter" );
           tolua_usertype(  tolua_S,  "Atlas::Message::Element" );
           tolua_usertype(  tolua_S,  "CEGUI::Slider" );
          }
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_delete00
     144  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setValue of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_setValue00
     173  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_setValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
           Atlas::Message::Element* element = (  (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setValue'",  NULL );
          #endif
           {
           self->setValue(  *element );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getValue of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_getValue00
     206  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_getValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getValue'",  NULL );
          #endif
           {
           Atlas::Message::Element& tolua_ret = (  Atlas::Message::Element& ) self->getValue(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getOriginalValue of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_getOriginalValue00
     238  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_getOriginalValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  const EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getOriginalValue'",  NULL );
          #endif
           {
           const Atlas::Message::Element& tolua_ret = (  const Atlas::Message::Element& ) self->getOriginalValue(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Atlas::Message::Element" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getOriginalValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventValueChanged of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_get_EmberOgre__Gui__Adapters__Atlas__AdapterBase_EventValueChanged
     270  static int tolua_get_EmberOgre__Gui__Adapters__Atlas__AdapterBase_EventValueChanged(  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventValueChanged'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventValueChanged,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventValueChanged of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_set_EmberOgre__Gui__Adapters__Atlas__AdapterBase_EventValueChanged
     283  static int tolua_set_EmberOgre__Gui__Adapters__Atlas__AdapterBase_EventValueChanged(  lua_State* tolua_S )
          {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventValueChanged'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventValueChanged = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: updateGui of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_updateGui00
     300  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_updateGui00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'updateGui'",  NULL );
          #endif
           {
           self->updateGui(  *element );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'updateGui'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasChanges of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_hasChanges00
     333  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_hasChanges00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasChanges'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasChanges(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasChanges'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: remove of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_remove00
     365  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_remove00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'remove'",  NULL );
          #endif
           {
           self->remove(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'remove'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isRemoved of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_isRemoved00
     396  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_isRemoved00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  const EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isRemoved'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isRemoved(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isRemoved'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addSuggestion of class EmberOgre::Gui::Adapters::Atlas::AdapterBase */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_addSuggestion00
     428  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_addSuggestion00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string suggestedValue = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addSuggestion'",  NULL );
          #endif
           {
           self->addSuggestion(  suggestedValue );
           tolua_pushcppstring(  tolua_S,  (  const char* )suggestedValue );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addSuggestion'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_new00
     462  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string prefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) new EmberOgre::Gui::Adapters::Atlas::AdapterFactory(  prefix );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_new00_local
     492  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const std::string prefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) new EmberOgre::Gui::Adapters::Atlas::AdapterFactory(  prefix );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_delete00
     522  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createStringAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createStringAdapter00
     551  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createStringAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createStringAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::StringAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::StringAdapter* ) self->createStringAdapter(  container,  adapterPrefix,  *element );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::StringAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createStringAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createNumberAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createNumberAdapter00
     590  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createNumberAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createNumberAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::NumberAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::NumberAdapter* ) self->createNumberAdapter(  container,  adapterPrefix,  *element );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::NumberAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createNumberAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createSizeAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createSizeAdapter00
     629  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createSizeAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createSizeAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::SizeAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::SizeAdapter* ) self->createSizeAdapter(  container,  adapterPrefix,  *element );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::SizeAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createSizeAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createPositionAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createPositionAdapter00
     668  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createPositionAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createPositionAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::PositionAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::PositionAdapter* ) self->createPositionAdapter(  container,  adapterPrefix,  *element );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::PositionAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createPositionAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createPosition2DAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createPosition2DAdapter00
     707  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createPosition2DAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createPosition2DAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* ) self->createPosition2DAdapter(  container,  adapterPrefix,  *element );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::Position2DAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createPosition2DAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createMapAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter00
     746  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createMapAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) self->createMapAdapter(  container,  adapterPrefix,  *element );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createMapAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createMapAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter01
     785  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::MapType attributes = *(  (  const Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createMapAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) self->createMapAdapter(  container,  adapterPrefix,  attributes );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createMapAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter02
     819  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createMapAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) self->createMapAdapter(  container,  adapterPrefix,  entity );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createListAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createListAdapter00
     853  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createListAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createListAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::ListAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::ListAdapter* ) self->createListAdapter(  container,  adapterPrefix,  *element );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createListAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createOrientationAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createOrientationAdapter00
     892  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createOrientationAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createOrientationAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* ) self->createOrientationAdapter(  container,  adapterPrefix,  *element );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::OrientationAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createOrientationAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createStaticAdapter of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createStaticAdapter00
     931  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createStaticAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createStaticAdapter'",  NULL );
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::StaticAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::StaticAdapter* ) self->createStaticAdapter(  container,  adapterPrefix,  *element );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::StaticAdapter" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createStaticAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: loadLayoutIntoContainer of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_loadLayoutIntoContainer00
     970  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_loadLayoutIntoContainer00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
           CEGUI::Window* container = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const std::string adapterPrefix = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const std::string layoutfile = (  (  const std::string ) tolua_tocppstring(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'loadLayoutIntoContainer'",  NULL );
          #endif
           {
           CEGUI::Window* tolua_ret = (  CEGUI::Window* ) self->loadLayoutIntoContainer(  container,  adapterPrefix,  layoutfile );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "CEGUI::Window" );
           tolua_pushcppstring(  tolua_S,  (  const char* )adapterPrefix );
           tolua_pushcppstring(  tolua_S,  (  const char* )layoutfile );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'loadLayoutIntoContainer'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getCurrentPrefix of class EmberOgre::Gui::Adapters::Atlas::AdapterFactory */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_getCurrentPrefix00
    1010  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_getCurrentPrefix00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Adapters::Atlas::AdapterFactory* self = (  const EmberOgre::Gui::Adapters::Atlas::AdapterFactory* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getCurrentPrefix'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getCurrentPrefix(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getCurrentPrefix'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::StringAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_new00
    1042  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::StringAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Combobox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Combobox* textWindow = (  (  CEGUI::Combobox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::StringAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::StringAdapter* ) new EmberOgre::Gui::Adapters::Atlas::StringAdapter(  *element,  textWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::StringAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::StringAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_new00_local
    1074  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::StringAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Combobox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Combobox* textWindow = (  (  CEGUI::Combobox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::StringAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::StringAdapter* ) new EmberOgre::Gui::Adapters::Atlas::StringAdapter(  *element,  textWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::StringAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::StringAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_delete00
    1106  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::StringAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::StringAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::StringAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::NumberAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_new00
    1135  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::NumberAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Combobox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Combobox* textWindow = (  (  CEGUI::Combobox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::NumberAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::NumberAdapter* ) new EmberOgre::Gui::Adapters::Atlas::NumberAdapter(  *element,  textWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::NumberAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::NumberAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_new00_local
    1167  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::NumberAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Combobox",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Combobox* textWindow = (  (  CEGUI::Combobox* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::NumberAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::NumberAdapter* ) new EmberOgre::Gui::Adapters::Atlas::NumberAdapter(  *element,  textWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::NumberAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::NumberAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_delete00
    1199  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::NumberAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::NumberAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::NumberAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::SizeAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_new00
    1228  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::SizeAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  7,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  8,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  9,  "CEGUI::Slider",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  10,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  11,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* lowerXWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* lowerYWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* lowerZWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           CEGUI::Window* upperXWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           CEGUI::Window* upperYWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  7,  0 ) );
           CEGUI::Window* upperZWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  8,  0 ) );
           CEGUI::Slider* scaler = (  (  CEGUI::Slider* ) tolua_tousertype(  tolua_S,  9,  0 ) );
           CEGUI::Window* infoWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  10,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::SizeAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::SizeAdapter* ) new EmberOgre::Gui::Adapters::Atlas::SizeAdapter(  *element,  lowerXWindow,  lowerYWindow,  lowerZWindow,  upperXWindow,  upperYWindow,  upperZWindow,  scaler,  infoWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::SizeAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::SizeAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_new00_local
    1274  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::SizeAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  7,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  8,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  9,  "CEGUI::Slider",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  10,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  11,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* lowerXWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* lowerYWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* lowerZWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           CEGUI::Window* upperXWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           CEGUI::Window* upperYWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  7,  0 ) );
           CEGUI::Window* upperZWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  8,  0 ) );
           CEGUI::Slider* scaler = (  (  CEGUI::Slider* ) tolua_tousertype(  tolua_S,  9,  0 ) );
           CEGUI::Window* infoWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  10,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::SizeAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::SizeAdapter* ) new EmberOgre::Gui::Adapters::Atlas::SizeAdapter(  *element,  lowerXWindow,  lowerYWindow,  lowerZWindow,  upperXWindow,  upperYWindow,  upperZWindow,  scaler,  infoWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::SizeAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::SizeAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_delete00
    1320  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::SizeAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::SizeAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::SizeAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::MapAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_new00
    1349  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const ::Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const ::Atlas::Message::Element* element = (  (  const ::Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* childContainer = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) new EmberOgre::Gui::Adapters::Atlas::MapAdapter(  *element,  childContainer );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::MapAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_new00_local
    1381  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const ::Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const ::Atlas::Message::Element* element = (  (  const ::Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* childContainer = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) new EmberOgre::Gui::Adapters::Atlas::MapAdapter(  *element,  childContainer );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::MapAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_delete00
    1413  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttributeNames of class EmberOgre::Gui::Adapters::Atlas::MapAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_getAttributeNames00
    1442  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_getAttributeNames00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttributeNames'",  NULL );
          #endif
           {
           std::vector<std::string> tolua_ret = (  std::vector<std::string> ) self->getAttributeNames(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::vector<std::string>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<std::string>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::vector<std::string> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<std::string>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttributeNames'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: valueOfAttr of class EmberOgre::Gui::Adapters::Atlas::MapAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_valueOfAttr00
    1482  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_valueOfAttr00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Adapters::Atlas::MapAdapter* self = (  const EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string attr = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'valueOfAttr'",  NULL );
          #endif
           {
           const Atlas::Message::Element& tolua_ret = (  const Atlas::Message::Element& ) self->valueOfAttr(  attr );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Atlas::Message::Element" );
           tolua_pushcppstring(  tolua_S,  (  const char* )attr );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'valueOfAttr'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasAttr of class EmberOgre::Gui::Adapters::Atlas::MapAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_hasAttr00
    1517  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_hasAttr00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Adapters::Atlas::MapAdapter* self = (  const EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string attr = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasAttr'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasAttr(  attr );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )attr );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasAttr'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addAttributeAdapter of class EmberOgre::Gui::Adapters::Atlas::MapAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_addAttributeAdapter00
    1552  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_addAttributeAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string attributeName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* adapter = (  (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* containerWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addAttributeAdapter'",  NULL );
          #endif
           {
           self->addAttributeAdapter(  attributeName,  adapter,  containerWindow );
           tolua_pushcppstring(  tolua_S,  (  const char* )attributeName );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addAttributeAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeAdapters of class EmberOgre::Gui::Adapters::Atlas::MapAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_removeAdapters00
    1590  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_removeAdapters00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::MapAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::MapAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeAdapters'",  NULL );
          #endif
           {
           self->removeAdapters(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeAdapters'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::ListAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_new00
    1621  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* childContainer = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::ListAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::ListAdapter* ) new EmberOgre::Gui::Adapters::Atlas::ListAdapter(  *element,  childContainer );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::ListAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_new00_local
    1653  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* childContainer = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::ListAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::ListAdapter* ) new EmberOgre::Gui::Adapters::Atlas::ListAdapter(  *element,  childContainer );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::ListAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_delete00
    1685  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::ListAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::ListAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSize of class EmberOgre::Gui::Adapters::Atlas::ListAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_getSize00
    1714  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_getSize00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::ListAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::ListAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSize'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->getSize(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSize'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: valueOfAttr of class EmberOgre::Gui::Adapters::Atlas::ListAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_valueOfAttr00
    1746  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_valueOfAttr00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const EmberOgre::Gui::Adapters::Atlas::ListAdapter",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const EmberOgre::Gui::Adapters::Atlas::ListAdapter* self = (  const EmberOgre::Gui::Adapters::Atlas::ListAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           int index = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'valueOfAttr'",  NULL );
          #endif
           {
           const Atlas::Message::Element& tolua_ret = (  const Atlas::Message::Element& ) self->valueOfAttr(  index );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Atlas::Message::Element" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'valueOfAttr'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: addAttributeAdapter of class EmberOgre::Gui::Adapters::Atlas::ListAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_addAttributeAdapter00
    1780  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_addAttributeAdapter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::ListAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::ListAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
           EmberOgre::Gui::Adapters::Atlas::AdapterBase* adapter = (  (  EmberOgre::Gui::Adapters::Atlas::AdapterBase* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* containerWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'addAttributeAdapter'",  NULL );
          #endif
           {
           self->addAttributeAdapter(  adapter,  containerWindow );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'addAttributeAdapter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: removeAdapters of class EmberOgre::Gui::Adapters::Atlas::ListAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_removeAdapters00
    1815  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_removeAdapters00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::ListAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::ListAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::ListAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'removeAdapters'",  NULL );
          #endif
           {
           self->removeAdapters(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'removeAdapters'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::PositionAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_new00
    1846  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::PositionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const ::Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const ::Atlas::Message::Element* element = (  (  const ::Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::PositionAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::PositionAdapter* ) new EmberOgre::Gui::Adapters::Atlas::PositionAdapter(  *element,  xWindow,  yWindow,  zWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::PositionAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::PositionAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_new00_local
    1882  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::PositionAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const ::Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const ::Atlas::Message::Element* element = (  (  const ::Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::PositionAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::PositionAdapter* ) new EmberOgre::Gui::Adapters::Atlas::PositionAdapter(  *element,  xWindow,  yWindow,  zWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::PositionAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::PositionAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_delete00
    1918  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::PositionAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::PositionAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::PositionAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::Position2DAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_new00
    1947  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::Position2DAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const ::Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const ::Atlas::Message::Element* element = (  (  const ::Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* ) new EmberOgre::Gui::Adapters::Atlas::Position2DAdapter(  *element,  xWindow,  yWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::Position2DAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::Position2DAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_new00_local
    1981  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::Position2DAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const ::Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const ::Atlas::Message::Element* element = (  (  const ::Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* ) new EmberOgre::Gui::Adapters::Atlas::Position2DAdapter(  *element,  xWindow,  yWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::Position2DAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::Position2DAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_delete00
    2015  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::Position2DAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::Position2DAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::OrientationAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_new00
    2044  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::OrientationAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           CEGUI::Window* scalarWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* ) new EmberOgre::Gui::Adapters::Atlas::OrientationAdapter(  *element,  xWindow,  yWindow,  zWindow,  scalarWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::OrientationAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::OrientationAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_new00_local
    2082  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::OrientationAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  5,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  6,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  7,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* element = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* xWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           CEGUI::Window* yWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  4,  0 ) );
           CEGUI::Window* zWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  5,  0 ) );
           CEGUI::Window* scalarWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  6,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* ) new EmberOgre::Gui::Adapters::Atlas::OrientationAdapter(  *element,  xWindow,  yWindow,  zWindow,  scalarWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::OrientationAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::OrientationAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_delete00
    2120  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::OrientationAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::OrientationAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class EmberOgre::Gui::Adapters::Atlas::StaticAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_new00
    2149  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::StaticAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const ::Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const ::Atlas::Message::Element* element = (  (  const ::Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* textWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::StaticAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::StaticAdapter* ) new EmberOgre::Gui::Adapters::Atlas::StaticAdapter(  *element,  textWindow );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::StaticAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class EmberOgre::Gui::Adapters::Atlas::StaticAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_new00_local
    2181  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::StaticAdapter",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const ::Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "CEGUI::Window",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const ::Atlas::Message::Element* element = (  (  const ::Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           CEGUI::Window* textWindow = (  (  CEGUI::Window* ) tolua_tousertype(  tolua_S,  3,  0 ) );
           {
           EmberOgre::Gui::Adapters::Atlas::StaticAdapter* tolua_ret = (  EmberOgre::Gui::Adapters::Atlas::StaticAdapter* ) new EmberOgre::Gui::Adapters::Atlas::StaticAdapter(  *element,  textWindow );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "EmberOgre::Gui::Adapters::Atlas::StaticAdapter" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class EmberOgre::Gui::Adapters::Atlas::StaticAdapter */
          #ifndef TOLUA_DISABLE_tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_delete00
    2213  static int tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "EmberOgre::Gui::Adapters::Atlas::StaticAdapter",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           EmberOgre::Gui::Adapters::Atlas::StaticAdapter* self = (  EmberOgre::Gui::Adapters::Atlas::StaticAdapter* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* Open function */
    2241  TOLUA_API int tolua_atlas_adapters_open (  lua_State* tolua_S )
          {
           tolua_open(  tolua_S );
           tolua_reg_types(  tolua_S );
           tolua_module(  tolua_S,  NULL,  0 );
           tolua_beginmodule(  tolua_S,  NULL );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "AdapterBase",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  "",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__AdapterBase );
           #else
           tolua_cclass(  tolua_S,  "AdapterBase",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "AdapterBase" );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_delete00 );
           tolua_function(  tolua_S,  "setValue",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_setValue00 );
           tolua_function(  tolua_S,  "getValue",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_getValue00 );
           tolua_function(  tolua_S,  "getOriginalValue",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_getOriginalValue00 );
           tolua_variable(  tolua_S,  "EventValueChanged",  tolua_get_EmberOgre__Gui__Adapters__Atlas__AdapterBase_EventValueChanged,  tolua_set_EmberOgre__Gui__Adapters__Atlas__AdapterBase_EventValueChanged );
           tolua_function(  tolua_S,  "updateGui",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_updateGui00 );
           tolua_function(  tolua_S,  "hasChanges",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_hasChanges00 );
           tolua_function(  tolua_S,  "remove",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_remove00 );
           tolua_function(  tolua_S,  "isRemoved",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_isRemoved00 );
           tolua_function(  tolua_S,  "addSuggestion",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterBase_addSuggestion00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "AdapterFactory",  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  "",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__AdapterFactory );
           #else
           tolua_cclass(  tolua_S,  "AdapterFactory",  "EmberOgre::Gui::Adapters::Atlas::AdapterFactory",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "AdapterFactory" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_delete00 );
           tolua_function(  tolua_S,  "createStringAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createStringAdapter00 );
           tolua_function(  tolua_S,  "createNumberAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createNumberAdapter00 );
           tolua_function(  tolua_S,  "createSizeAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createSizeAdapter00 );
           tolua_function(  tolua_S,  "createPositionAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createPositionAdapter00 );
           tolua_function(  tolua_S,  "createPosition2DAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createPosition2DAdapter00 );
           tolua_function(  tolua_S,  "createMapAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter00 );
           tolua_function(  tolua_S,  "createMapAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter01 );
           tolua_function(  tolua_S,  "createMapAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createMapAdapter02 );
           tolua_function(  tolua_S,  "createListAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createListAdapter00 );
           tolua_function(  tolua_S,  "createOrientationAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createOrientationAdapter00 );
           tolua_function(  tolua_S,  "createStaticAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_createStaticAdapter00 );
           tolua_function(  tolua_S,  "loadLayoutIntoContainer",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_loadLayoutIntoContainer00 );
           tolua_function(  tolua_S,  "getCurrentPrefix",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_AdapterFactory_getCurrentPrefix00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "StringAdapter",  "EmberOgre::Gui::Adapters::Atlas::StringAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__StringAdapter );
           #else
           tolua_cclass(  tolua_S,  "StringAdapter",  "EmberOgre::Gui::Adapters::Atlas::StringAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "StringAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StringAdapter_delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "NumberAdapter",  "EmberOgre::Gui::Adapters::Atlas::NumberAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__NumberAdapter );
           #else
           tolua_cclass(  tolua_S,  "NumberAdapter",  "EmberOgre::Gui::Adapters::Atlas::NumberAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "NumberAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_NumberAdapter_delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "SizeAdapter",  "EmberOgre::Gui::Adapters::Atlas::SizeAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__SizeAdapter );
           #else
           tolua_cclass(  tolua_S,  "SizeAdapter",  "EmberOgre::Gui::Adapters::Atlas::SizeAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "SizeAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_SizeAdapter_delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "MapAdapter",  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__MapAdapter );
           #else
           tolua_cclass(  tolua_S,  "MapAdapter",  "EmberOgre::Gui::Adapters::Atlas::MapAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "MapAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_delete00 );
           tolua_function(  tolua_S,  "getAttributeNames",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_getAttributeNames00 );
           tolua_function(  tolua_S,  "valueOfAttr",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_valueOfAttr00 );
           tolua_function(  tolua_S,  "hasAttr",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_hasAttr00 );
           tolua_function(  tolua_S,  "addAttributeAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_addAttributeAdapter00 );
           tolua_function(  tolua_S,  "removeAdapters",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_MapAdapter_removeAdapters00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "ListAdapter",  "EmberOgre::Gui::Adapters::Atlas::ListAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__ListAdapter );
           #else
           tolua_cclass(  tolua_S,  "ListAdapter",  "EmberOgre::Gui::Adapters::Atlas::ListAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "ListAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_delete00 );
           tolua_function(  tolua_S,  "getSize",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_getSize00 );
           tolua_function(  tolua_S,  "valueOfAttr",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_valueOfAttr00 );
           tolua_function(  tolua_S,  "addAttributeAdapter",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_addAttributeAdapter00 );
           tolua_function(  tolua_S,  "removeAdapters",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_ListAdapter_removeAdapters00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "PositionAdapter",  "EmberOgre::Gui::Adapters::Atlas::PositionAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__PositionAdapter );
           #else
           tolua_cclass(  tolua_S,  "PositionAdapter",  "EmberOgre::Gui::Adapters::Atlas::PositionAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "PositionAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_PositionAdapter_delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Position2DAdapter",  "EmberOgre::Gui::Adapters::Atlas::Position2DAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__Position2DAdapter );
           #else
           tolua_cclass(  tolua_S,  "Position2DAdapter",  "EmberOgre::Gui::Adapters::Atlas::Position2DAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Position2DAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_Position2DAdapter_delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "OrientationAdapter",  "EmberOgre::Gui::Adapters::Atlas::OrientationAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__OrientationAdapter );
           #else
           tolua_cclass(  tolua_S,  "OrientationAdapter",  "EmberOgre::Gui::Adapters::Atlas::OrientationAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "OrientationAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_OrientationAdapter_delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "EmberOgre",  0 );
           tolua_beginmodule(  tolua_S,  "EmberOgre" );
           tolua_module(  tolua_S,  "Gui",  0 );
           tolua_beginmodule(  tolua_S,  "Gui" );
           tolua_module(  tolua_S,  "Adapters",  0 );
           tolua_beginmodule(  tolua_S,  "Adapters" );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "StaticAdapter",  "EmberOgre::Gui::Adapters::Atlas::StaticAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  tolua_collect_EmberOgre__Gui__Adapters__Atlas__StaticAdapter );
           #else
           tolua_cclass(  tolua_S,  "StaticAdapter",  "EmberOgre::Gui::Adapters::Atlas::StaticAdapter",  "EmberOgre::Gui::Adapters::Atlas::AdapterBase",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "StaticAdapter" );
           tolua_function(  tolua_S,  "new",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_atlas_adapters_EmberOgre_Gui_Adapters_Atlas_StaticAdapter_delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           return 1;
          }
          
          
          #if defined(  LUA_VERSION_NUM ) && LUA_VERSION_NUM >= 501
    2534   TOLUA_API int luaopen_atlas_adapters (  lua_State* tolua_S ) {
           return tolua_atlas_adapters_open(  tolua_S );
          };
          #endif
          

./components/ogre/widgets/icons/Icon.cpp

       1  //
          // C++ Implementation: Icon
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "Icon.h"
          #include "IconImageStore.h"
          #include <CEGUI.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Icons {
          
      33  Icon::Icon(  const std::string& key,   IconImageStoreEntry* imageStoreEntry )
          : mImageStoreEntry(  imageStoreEntry ),   mKey(  key )
          {
          }
          
          
      39  Icon::~Icon(   )
          {
          }
          
      43  IconImageStoreEntry* Icon::getImageStoreEntry(   )
          {
           return mImageStoreEntry;
          }
          
      48  const CEGUI::Image* Icon::getImage(   )
          {
           return mImageStoreEntry->getImage(   );
          }
          
      53  const CEGUI::Image* Icon::getImage(   ) const
          {
           return mImageStoreEntry->getImage(   );
          }
          
          
          }
          
          }
          
          }

./components/ogre/widgets/icons/Icon.h

       1  //
          // C++ Interface: Icon
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ICONSICON_H
          #define EMBEROGRE_GUI_ICONSICON_H
          
          #include <string>
          
          namespace CEGUI {
      29   class Imageset;
      30   class Image;
          }
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Icons {
          
      39  class IconImageStoreEntry;
      40  class IconStore;
      41  class IconRenderer;
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      46  class Icon
          {
          public:
      49   friend class IconStore;
      50   friend class IconRenderer;
          
      52   const CEGUI::Image* getImage(   );
      53   const CEGUI::Image* getImage(   ) const;
          
          
          private:
      57   Icon(  const std::string& key,   IconImageStoreEntry* imageStoreEntry );
      58   virtual ~Icon(   );
          
      60   IconImageStoreEntry* getImageStoreEntry(   );
          
      62   IconImageStoreEntry* mImageStoreEntry;
          
      64   std::string mKey;
          
          };
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/icons/IconImageStore.cpp

          //
          // C++ Implementation: IconImageStore
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "IconImageStore.h"
          #include <CEGUI.h>
          #include <Ogre.h>
          #include "services/logging/LoggingService.h"
          #include "components/ogre/GUIManager.h"
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Icons {
          
      35  IconImageStoreEntry::IconImageStoreEntry(  IconImageStore& iconImageStore,   const PixelPos& pixelPosInImageset )
          : mImage(  0 ),   mIconImageStore(  iconImageStore ),   mPixelPosInImageset(  pixelPosInImageset )
          {
           createImage(   );
          }
          
      41  void IconImageStoreEntry::createImage(   )
          {
           std::stringstream ss;
           ss << mPixelPosInImageset.first << "_" << mPixelPosInImageset.second;
           mImageName = ss.str(   );
           mIconImageStore.mImageset->defineImage(  mImageName,   CEGUI::Rect(  mPixelPosInImageset.first,   mPixelPosInImageset.second,   mPixelPosInImageset.first + mIconImageStore.mIconSize,   mPixelPosInImageset.second + mIconImageStore.mIconSize ),   CEGUI::Point(  0,  0 ) );
          
           mImage = &mIconImageStore.mImageset->getImage(  mImageName );
          
          }
          
      52  const CEGUI::Image* IconImageStoreEntry::getImage(   )
          {
           return mImage;
          }
          
      57  const CEGUI::Image* IconImageStoreEntry::getImage(   ) const
          {
           return mImage;
          }
          
          
      63  const std::string& IconImageStoreEntry::getImageName(   )
          {
           return mImageName;
          }
          
      68  const std::string& IconImageStoreEntry::getImageName(   ) const
          {
           return mImageName;
          }
          
      73  Ogre::TexturePtr IconImageStoreEntry::getTexture(   )
          {
           return mIconImageStore.mTexPtr;
          }
          
      78  Ogre::PixelBox IconImageStoreEntry::getImagePixelBox(   )
          {
           return mIconImageStore.getImage(   ).getPixelBox(   ).getSubVolume(  getBox(   ) );
          }
          
          
      84  Ogre::Image::Box IconImageStoreEntry::getBox(   )
          {
           Ogre::Image::Box box(  mPixelPosInImageset.first,   mPixelPosInImageset.second,   mPixelPosInImageset.first + mIconImageStore.mIconSize,   mPixelPosInImageset.second + mIconImageStore.mIconSize );
           return box;
          }
          
      90  IconImageStore::IconImageStore(  const std::string& imagesetName )
          : mImagesetName(  imagesetName )
          ,   mIconSize(  64 )
          ,   mImageSize(  256 )
          ,   mImageDataStream(  new Ogre::MemoryDataStream(  mImageSize * mImageSize * 4,   true ) )
      95  ,   mImageDataStreamPtr(  mImageDataStream )
          ,   mCeguiTexture(  0 )
          ,   mImageset(  0 )
          {
           createImageset(   );
           createEntries(   );
          }
          
          /**
          Constructor for when we already have a texture of the whole icon.
          */
     106  IconImageStore::IconImageStore(  const std::string& imagesetName,   Ogre::TexturePtr texPtr )
          : mImagesetName(  imagesetName )
          ,   mTexPtr(  texPtr )
          ,   mImageDataStream(  0 )
          ,   mImageDataStreamPtr(  mImageDataStream )
          ,   mCeguiTexture(  0 )
          ,   mImageset(  0 )
          {
           mCeguiTexture = GUIManager::getSingleton(   ).getGuiRenderer(   )->createTexture(  mTexPtr );
          
           ///we need a imageset in order to create GUI elements from the ceguiTexture
           mImageset = CEGUI::ImagesetManager::getSingleton(   ).createImageset(  mImagesetName,   mCeguiTexture );
          
           ///we'll assume that height and width are the same
           mImageSize = texPtr->getWidth(   );
           mIconSize = mImageSize;
          
           ///this will only create one entry
           createEntries(   );
          }
          
          
     128  IconImageStore::~IconImageStore(   )
          {
          ///the stream will be destroyed by the mImageDataStreamPtr pointer
          // delete mImageDataStream;
          }
          
     134  void IconImageStore::createImageset(   )
          {
           ///reset the image
           memset(  mImageDataStream->getPtr(   ),   '\0',   mImageDataStream->size(   ) );
           mImage.loadRawData(  mImageDataStreamPtr,   mImageSize,   mImageSize,   Ogre::PF_A8R8G8B8 );
          
          // mTexPtr = Ogre::TextureManager::getSingleton(   ).createManual(  mImagesetName,   "Gui",   Ogre::TEX_TYPE_2D,   mImageSize,   mImageSize,   0,   Ogre::PF_A8R8G8B8,  Ogre::TU_DYNAMIC_WRITE_ONLY );
           mTexPtr = Ogre::TextureManager::getSingleton(   ).loadImage(  mImagesetName,   "Gui",   mImage );
          // mTexPtr = Ogre::TextureManager::getSingleton(   ).loadRawData(  mImagesetName,   "Gui",   mImageDataStreamPtr,   mImageSize,   mImageSize,  Ogre::PF_A8R8G8B8,   Ogre::TEX_TYPE_2D,   0 );
           if (  mTexPtr.isNull(   ) ) {
           S_LOG_WARNING(  "Could not create a texture." );
           return;
           }
          
          
          
           mCeguiTexture = GUIManager::getSingleton(   ).getGuiRenderer(   )->createTexture(  mTexPtr );
          
           ///we need a imageset in order to create GUI elements from the ceguiTexture
           //S_LOG_VERBOSE(  "Creating new CEGUI imageset with name " << imageSetName + "_EntityCEGUITextureImageset" );
           mImageset = CEGUI::ImagesetManager::getSingleton(   ).createImageset(  mImagesetName,   mCeguiTexture );
          
          }
          
     158  void IconImageStore::createEntries(   )
          {
           int entriesPerAxis(  mImageSize / mIconSize );
           for (  int x = 0; x < entriesPerAxis; ++x ) {
           for (  int y = 0; y < entriesPerAxis; ++y ) {
           int pixelPosStartX = x * mIconSize;
           int pixelPosStartY = y * mIconSize;
           IconImageStoreEntry* entry = new IconImageStoreEntry(  *this,   IconImageStoreEntry::PixelPos(  pixelPosStartX,   pixelPosStartY ) );
           mIconImages.push_back(  entry );
           mUnclaimedIconImages.push(  entry );
           }
           }
          }
          
     172  size_t IconImageStore::getNumberOfUnclaimedIcons(   )
          {
           return mUnclaimedIconImages.size(   );
          }
          
     177  IconImageStoreEntry* IconImageStore::claimImageEntry(   )
          {
           if (  !getNumberOfUnclaimedIcons(   ) ) {
           S_LOG_WARNING(  "Trying to claim image entry from store with no unclaimed entries." );
           return 0;
           }
           IconImageStoreEntry* entry = mUnclaimedIconImages.top(   );
           mUnclaimedIconImages.pop(   );
           return entry;
          }
          
     188  void IconImageStore::returnImageEntry(  IconImageStoreEntry* imageEntry )
          {
          // if (  std::find(  mUnclaimedIconImages.begin(   ),   mUnclaimedIconImages.end(   ),   imageEntry ) != mUnclaimedIconImages.end(   ) ) {
          // S_LOG_WARNING(  "Trying to return an image entry which is unclaimed." );
          // }
           if (  std::find(  mIconImages.begin(   ),   mIconImages.end(   ),   imageEntry ) == mIconImages.end(   ) ) {
           S_LOG_WARNING(  "Trying to return an image entry which doesn't belong to this store." );
           }
          
           mUnclaimedIconImages.push(  imageEntry );
          }
          
          
     201  Ogre::Image& IconImageStore::getImage(   )
          {
           return mImage;
          }
          
          // Ogre::TexturePtr IconImageStore::getTexture(   )
          // {
          // return mTexPtr;
          // }
          
          
          }
          
          }
          
          }

./components/ogre/widgets/icons/IconImageStore.h

       1  //
          // C++ Interface: IconImageStore
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ICONSICONIMAGESTORE_H
          #define EMBEROGRE_GUI_ICONSICONIMAGESTORE_H
          
          #include <map>
          #include <string>
          #include <stack>
          #include <vector>
          
          #include <OgreTexture.h>
          
          namespace CEGUI {
      34   class Imageset;
      35   class Image;
      36   class Texture;
          }
          
          namespace Ogre {
      40   class Image;
          }
          
      43  namespace EmberOgre {
          
          namespace Gui {
          
          namespace Icons {
          
          class IconImageStore;
          
          class IconImageStoreEntry {
          public:
           typedef std::pair<size_t,   size_t> PixelPos;
          
           IconImageStoreEntry(  IconImageStore& iconImageStore,   const PixelPos& pixelPosInImageset );
           virtual ~IconImageStoreEntry(   ) {}
          
           const CEGUI::Image* getImage(   );
           const CEGUI::Image* getImage(   ) const;
          
           const std::string& getImageName(   );
           const std::string& getImageName(   ) const;
          
           Ogre::Image::Box getBox(   );
           Ogre::TexturePtr getTexture(   );
           Ogre::PixelBox getImagePixelBox(   );
          
          // Ogre::Image::PixelBox getImageBox(   );
          
          protected:
           void createImage(   );
          
           const CEGUI::Image* mImage;
           IconImageStore& mIconImageStore;
           PixelPos mPixelPosInImageset;
           std::string mImageName;
          };
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
          class IconImageStore {
          public:
           friend class IconImageStoreEntry;
           //typedef std::map<int,   IconImageStoreEntry*> IconImageStoreEntryMap;
           typedef std::stack<IconImageStoreEntry*> IconImageStoreEntryStack;
           typedef std::vector<IconImageStoreEntry*> IconImageStoreEntryStore;
          
           /**
           * Ctor. Creates a new empty imageset into which dynamic icons can be rendered.
           * @param imagesetName The name of the imageset to create.
           */
           IconImageStore(  const std::string& imagesetName );
           /**
           * Ctor. Creates a new imageset from an alreay existing texture. The whole texture will be used for a single icon.
           * Use this when you already have an icon.
           * @param imagesetName The name of the imageset to create.
           * @param texPtr The texture to use.
           */
           IconImageStore(  const std::string& imagesetName,   Ogre::TexturePtr texPtr );
           virtual ~IconImageStore(   );
          
          
           /**
           * Gets the number of icons in this store that haven't been claimed yet.
           * @return
           */
           size_t getNumberOfUnclaimedIcons(   );
          
          
           /**
           * Claims an icon from the store.
           * @return An entry or null if there are no unclaimed left.
           */
           IconImageStoreEntry* claimImageEntry(   );
          
           /**
           * Returns an already claimed entry to the store,   so that it can be reused by other icons.
           * @param imageEntry
           */
           void returnImageEntry(  IconImageStoreEntry* imageEntry );
          
           Ogre::Image& getImage(   );
          
          // Ogre::TexturePtr getTexture(   );
          
          private:
           void createImageset(   );
           void createEntries(   );
          
           std::string mImagesetName;
           int mIconSize;
           int mImageSize;
           //Ogre::Image* mOgreImage;
           Ogre::TexturePtr mTexPtr;
           Ogre::MemoryDataStream* mImageDataStream;
           Ogre::DataStreamPtr mImageDataStreamPtr;
           Ogre::Image mImage;
           CEGUI::Texture* mCeguiTexture;
           CEGUI::Imageset* mImageset;
          
           IconImageStoreEntryStore mIconImages;
           IconImageStoreEntryStack mUnclaimedIconImages;
          
          };
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/icons/IconManager.cpp

       1  //
          // C++ Implementation: IconManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "IconManager.h"
          #include "../../EmberPhysicalEntity.h"
          #include "../../EmberEntity.h"
          #include <Eris/Entity.h>
          #include <Eris/TypeInfo.h>
          #include <Eris/View.h>
          #include "components/ogre/model/Model.h"
          #include "components/ogre/model/ModelDefinitionManager.h"
          #include "components/ogre/model/mapping/ModelMappingManager.h"
          #include "components/ogre/model/mapping/EmberModelMappingManager.h"
          #include "components/ogre/model/mapping/ModelMapping.h"
          #include "components/ogre/model/mapping/Definitions/ModelMappingDefinition.h"
          #include "components/ogre/model/mapping/IActionCreator.h"
          #include "../../SimpleRenderContext.h"
          #include "main/Application.h"
          
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Icons {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      49  class IconActionCreator : public Model::Mapping::IActionCreator
          {
          public:
          
      53  IconActionCreator(  Eris::Entity& entity ): mEntity(  entity ),   mModelName(  "" )
          {
          }
          
      57  ~IconActionCreator(   ) {}
          
      59  virtual void createActions(  Model::Mapping::ModelMapping& modelMapping,   Model::Mapping::Cases::CaseBase* aCase,   Model::Mapping::Definitions::CaseDefinition& caseDefinition )
          {
           Model::Mapping::Definitions::CaseDefinition::ActionStore::iterator endJ = caseDefinition.getActions(   ).end(   );
           for (  Model::Mapping::Definitions::CaseDefinition::ActionStore::iterator J = caseDefinition.getActions(   ).begin(   ); J != endJ; ++J ) {
           if (  J->getType(   ) == "display-model" ) {
           mModelName = J->getValue(   );
           }
           }
          }
          
      69  const std::string& getModelName(   ) const
          {
           return mModelName;
          }
          protected:
      74  Eris::Entity& mEntity;
      75  std::string mModelName;
          
          };
          
          
          
      81  IconManager::IconManager(   )
          : mIconRenderer(  "IconManager",   64 )
          {
          // mIconRenderer.setWorker(  new DirectRendererWorker(  mIconRenderer ) );
           mIconRenderer.setWorker(  new DelayedIconRendererWorker(  mIconRenderer ) );
          }
          
          
      89  IconManager::~IconManager(   )
          {
          }
          
      93  Icon* IconManager::getIcon(  int pixelWidth,   EmberEntity* entity )
          {
           EmberPhysicalEntity* physEntity = dynamic_cast<EmberPhysicalEntity*>(  entity );
           if (  physEntity ) {
           std::string key = "entity_" + physEntity->getId(   );
           if (  mIconStore.hasIcon(  key ) ) {
           return mIconStore.getIcon(  key );
           } else {
           IconActionCreator actionCreator(  *entity );
           std::auto_ptr<Model::Mapping::ModelMapping> modelMapping(  ::EmberOgre::Model::Mapping::EmberModelMappingManager::getSingleton(   ).getManager(   ).createMapping(  entity,   &actionCreator ) );
           std::string modelName;
           if (  modelMapping.get(   ) ) {
           modelMapping->initialize(   );
           modelName = actionCreator.getModelName(   );
           }
           ///if there's no model defined for this use the placeholder model
           if (  modelName == "" ) {
           modelName = "placeholder";
           }
           Ogre::ResourcePtr modelDefPtr = Model::ModelDefinitionManager::getSingleton(   ).getByName(  modelName );
           if (  !modelDefPtr.isNull(   ) ) {
           Model::ModelDefinition* modelDef = static_cast< Model::ModelDefinition*>(  modelDefPtr.get(   ) );
           const std::string& iconPath(  modelDef->getIconPath(   ) );
           if (  iconPath != "" ) {
          
           Ogre::TexturePtr texPtr;
           try {
           if (  Ogre::TextureManager::getSingleton(   ).resourceExists(  iconPath ) ) {
           texPtr = static_cast<Ogre::TexturePtr>(  Ogre::TextureManager::getSingleton(   ).getByName(  iconPath ) );
           ///try to load it to make sure that's it a working image
           texPtr->load(   );
           }
           if (  texPtr.isNull(   ) ) {
           texPtr = Ogre::TextureManager::getSingleton(   ).load(  iconPath,   "Gui" );
           }
           } catch (  ... ) {
           S_LOG_WARNING(  "Error when trying to load the icon " << iconPath <<". The icon will be rendered dynamically." );
           texPtr.setNull(   );
           }
           if (  !texPtr.isNull(   ) ) {
           Icon* icon = mIconStore.createIcon(  key,   texPtr );
           return icon;
           }
           }
           }
           Icon* icon = mIconStore.createIcon(  key );
           if (  icon ) {
           ///update the model preview window
          // Model::Model* model = Model::Model::createModel(  mIconRenderer.getRenderContext(   )->getSceneManager(   ),   modelName );
           mIconRenderer.render(  modelName,   icon );
          // mIconRenderer.getRenderContext(   )->getSceneManager(   )->destroyMovableObject(  model );
           }
           return icon;
           }
           }
           return 0;
          }
          
     151  Icon* IconManager::getIcon(  int pixelWidth,   Eris::TypeInfo* erisType )
          {
          
           std::string key = "entity_" + erisType->getName(   );
           if (  mIconStore.hasIcon(  key ) ) {
           return mIconStore.getIcon(  key );
           } else {
           Icon* icon = mIconStore.createIcon(  key );
           if (  icon ) {
           ///we need to get the model mapping definition for this type
           ///once we have that,   we will check for the first action of the first case of the first match (  since that's guaranteed to be a show-model action
           if (  erisType ) {
           Eris::View* view = Ember::Application::getSingleton(   ).getMainView(   );
           if (  view ) {
           Eris::Entity dummyEntity(  "-1",   erisType,   view );
           IconActionCreator actionCreator(  dummyEntity );
           std::auto_ptr<Model::Mapping::ModelMapping> modelMapping(  ::EmberOgre::Model::Mapping::EmberModelMappingManager::getSingleton(   ).getManager(   ).createMapping(  &dummyEntity,   &actionCreator ) );
           std::string modelName;
           if (  modelMapping.get(   ) ) {
           modelMapping->initialize(   );
           modelName = actionCreator.getModelName(   );
           }
           ///if there's no model defined for this use the placeholder model
           if (  modelName == "" ) {
           modelName = "placeholder";
           }
           ///update the model preview window
          // Model::Model* model = Model::Model::createModel(  mIconRenderer.getRenderContext(   )->getSceneManager(   ),   modelName );
           mIconRenderer.render(  modelName,   icon );
          // mIconRenderer.getRenderContext(   )->getSceneManager(   )->destroyMovableObject(  model );
          
           dummyEntity.shutdown(   );
           }
           }
           }
           return icon;
           }
          }
          
          
          }
          
          }
          
          }

./components/ogre/widgets/icons/IconManager.h

       1  //
          // C++ Interface: IconManager
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ICONSICONMANAGER_H
          #define EMBEROGRE_GUI_ICONSICONMANAGER_H
          
          #include "IconStore.h"
          #include "IconRenderer.h"
          
          namespace Eris
          {
      31   class TypeInfo;
          }
          
          namespace EmberOgre {
          
      36   class EmberEntity;
          
          namespace Gui {
          
          namespace Icons {
          
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      46  class IconManager{
          public:
          
      49   IconManager(   );
          
      51   ~IconManager(   );
          
      53   Icon* getIcon(  int pixelWidth,   EmberEntity* entity );
      54   Icon* getIcon(  int pixelWidth,   Eris::TypeInfo* erisType );
          protected:
          
      57   IconStore mIconStore;
      58   IconRenderer mIconRenderer;
          
          
          };
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/icons/IconRenderer.cpp

       1  //
          // C++ Implementation: IconRenderer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "IconRenderer.h"
          #include "Icon.h"
          #include "IconImageStore.h"
          
          #include "../../model/Model.h"
          #include "../../model/ModelDefinition.h"
          #include "../../SimpleRenderContext.h"
          
          // #include <SDL.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Icons {
          
      39  IconRenderer::IconRenderer(  const std::string& prefix,   int pixelWidth )
      40  : mPixelWidth(  pixelWidth ),   mRenderContext(  new SimpleRenderContext(  prefix,   pixelWidth,   pixelWidth ) ),   mWorker(  0 )
          {
           mRenderContext->getSceneManager(   )->setAmbientLight(  Ogre::ColourValue(  0.7,   0.7,   0.7 ) );
           mRenderContext->setBackgroundColour(  Ogre::ColourValue::ZERO );
          
          }
          
          
      48  IconRenderer::~IconRenderer(   )
          {
           delete mWorker;
          }
          
          
      54  void IconRenderer::setWorker(  IconRenderWorker* worker )
          {
           mWorker = worker;
          }
          
      59  void IconRenderer::render(  const std::string& modelName,   Icon* icon )
          {
           Model::Model* model = Model::Model::createModel(  getRenderContext(   )->getSceneManager(   ),   modelName );
           if (  model ) {
           render(  model,   icon );
           }
          }
          
      67  void IconRenderer::render(  Model::Model* model,   Icon* icon )
          {
           mWorker->render(  model,   icon );
          }
          
      72  void IconRenderer::performRendering(  Model::Model* model,   Icon* icon )
          {
          
           if (  model ) {
           Ogre::SceneNode* node = mRenderContext->getSceneNode(   );
          
           node->detachAllObjects(   );
           node->attachObject(  model );
          
           ///check for a defined "icon" view and use that if available,   else just reposition the camera
           const Model::ViewDefinitionStore::const_iterator I = model->getDefinition(   )->getViewDefinitions(   ).find(  "icon" );
           if (  I != model->getDefinition(   )->getViewDefinitions(   ).end(   ) ) {
           mRenderContext->resetCameraOrientation(   );
           mRenderContext->repositionCamera(   );
           mRenderContext->showFull(  model );
           if (  I->second->Distance ) {
           mRenderContext->setCameraDistance(  I->second->Distance );
           }
          // Ogre::Camera* camera = mRenderContext->getCamera(   );
           mRenderContext->getCameraRootNode(   )->setOrientation(  I->second->Rotation );
           } else {
           mRenderContext->resetCameraOrientation(   );
           mRenderContext->repositionCamera(   );
           mRenderContext->showFull(  model );
           mRenderContext->setCameraDistance(  mRenderContext->getDefaultCameraDistance(   ) * 0.75 );
           }
          
          // mRenderContext->setCameraDistance(  0.75 );
          
           ///the problem with PBuffer and Copy might be that we need to wait a little before we try to blit,   since it's not guaranteed that the content will be correctly rendered (  since the render ops are queued to the GPU )
           ///thus we need to create some kind of frame listener callback mechanism
          
           mRenderContext->getRenderTexture(   )->update(   );
          
          // SDL_Delay(  1000 );
          // blitRenderToIcon(  icon );
          
           node->detachAllObjects(   );
          
           }
          }
          
     114  void IconRenderer::blitRenderToIcon(  Icon* icon )
          {
           Ogre::HardwarePixelBufferSharedPtr srcBuffer = mRenderContext->getTexture(   )->getBuffer(   );
           Ogre::HardwarePixelBufferSharedPtr dstBuffer = icon->getImageStoreEntry(   )->getTexture(   )->getBuffer(   );
          
           Ogre::Box sourceBox(  0,   0,   mRenderContext->getRenderTexture(   )->getWidth(   ),   mRenderContext->getRenderTexture(   )->getHeight(   ) );
          // Ogre::PixelBox sourceLockedBox = srcBuffer->lock(  sourceBox,   Ogre::HardwareBuffer::HBL_READ_ONLY );
          
           Ogre::Box dstBox = icon->getImageStoreEntry(   )->getBox(   );
          // Ogre::PixelBox dstLockedBox = dstBuffer->lock(  dstBox,   Ogre::HardwareBuffer::HBL_NORMAL );
          
           Ogre::MemoryDataStream* dataStream = new Ogre::MemoryDataStream(  sourceBox.getWidth(   ) * sourceBox.getHeight(   ) * 4,   true );
           Ogre::DataStreamPtr imageDataStreamPtr(  dataStream );
          
          
          /* Ogre::Image image;
           image.loadRawData(  imageDataStreamPtr,   sourceBox.getWidth(   ),   sourceBox.getHeight(   ),   Ogre::PF_A8R8G8B8 );*/
          
           srcBuffer->blitToMemory(  icon->getImageStoreEntry(   )->getImagePixelBox(   ) );
           dstBuffer->blitFromMemory(  icon->getImageStoreEntry(   )->getImagePixelBox(   ),   dstBox );
          // static int counter(  0 );
          // std::stringstream ss;
          // ss << "/home/erik/skit/temp_" << counter++ << ".jpg";
          // image.save(  ss.str(   ) );
          
          // dstBuffer->blit(  srcBuffer,   sourceBox,   dstBox );
          
          // srcBuffer->unlock(   );
          // dstBuffer->unlock(   );
          }
          
          
          // void IconRenderer::showModel(  const std::string& modelName )
          // {
          // if (  mModel ) {
          // mModel->_getManager(   )->destroyMovableObject(  mModel );
          // //delete mModel;
          // }
          // if (  modelName != "" ) {
          // mModel = Model::Model::createModel(  mTexture->getRenderContext(   )->getSceneManager(   ),   modelName );
          // // mModel->create(  modelName );
          // ///override the rendering distance from the model; we want to always show it in the preview
          // mModel->setRenderingDistance(  0 );
          // setModel(  mModel );
          // mTexture->getRenderContext(   )->setActive(  true );
          // } else {
          // setModel(  0 );
          // mTexture->getRenderContext(   )->setActive(  false );
          // }
          // }
          
          // }
     166  SimpleRenderContext* IconRenderer::getRenderContext(   )
          {
           return mRenderContext.get(   );
          }
          
          
          
     173  IconRenderWorker::IconRenderWorker(  IconRenderer& renderer ) : mRenderer(  renderer )
          {
          }
          
     177  IconRenderWorker::~IconRenderWorker(   )
          {
          }
          
          
     182  DirectRendererWorker::DirectRendererWorker(  IconRenderer& renderer )
          : IconRenderWorker(  renderer )
          {
          }
          
     187  DirectRendererWorker::~DirectRendererWorker(   )
          {
          }
          
     191  void DirectRendererWorker::render(  Model::Model* model,   Icon* icon )
          {
           mRenderer.performRendering(  model,   icon );
           mRenderer.blitRenderToIcon(  icon );
           mRenderer.getRenderContext(   )->getSceneManager(   )->destroyMovableObject(  model );
          }
          
          
     199  DelayedIconRendererEntry::DelayedIconRendererEntry(  DelayedIconRendererWorker& renderer,   Model::Model* model,   Icon* icon )
          : mRenderer(  renderer ),   mModel(  model ),   mIcon(  icon ),   mFrames(  0 )
          {
          }
          
     204  DelayedIconRendererEntry::~DelayedIconRendererEntry(   )
          {
           //mRenderer.getRenderer(   ).getRenderContext(   )->getSceneManager(   )->destroyMovableObject(  mModel );
          }
          
     209  Model::Model* DelayedIconRendererEntry::getModel(   )
          {
           return mModel;
          }
          
     214  Icon* DelayedIconRendererEntry::getIcon(   )
          {
           return mIcon;
          }
          
     219  void DelayedIconRendererEntry::frameStarted(   )
          {
           ///on the first frame we'll do the rendering,   and then do the blitting on the second frame
           if (  mFrames == 0 ) {
           ///do render
           mRenderer.performRendering(  *this );
           mFrames++;
           } else {
           ///do blit
           mRenderer.finalizeRendering(  *this );
           ///we can't do anything here,   since the call to finalizeRendering will delete this instance
           }
          
          }
          
          
     235  DelayedIconRendererWorker::DelayedIconRendererWorker(  IconRenderer& renderer )
          : IconRenderWorker(  renderer )
          {
           Ogre::Root::getSingleton(   ).addFrameListener(  this );
          }
          
     241  void DelayedIconRendererWorker::render(  Model::Model* model,   Icon* icon )
          {
           DelayedIconRendererEntry entry(  *this,   model,   icon );
           entries.push(  entry );
          }
          
     247  bool DelayedIconRendererWorker::frameStarted(  const Ogre::FrameEvent& event )
          {
           if (  entries.size(   ) ) {
           entries.front(   ).frameStarted(   );
           }
           return true;
          }
          
     255  IconRenderer& DelayedIconRendererWorker::getRenderer(   )
          {
           return mRenderer;
          }
          
          
     261  void DelayedIconRendererWorker::performRendering(  DelayedIconRendererEntry& entry )
          {
           mRenderer.performRendering(  entry.getModel(   ),   entry.getIcon(   ) );
          }
          
          
     267  void DelayedIconRendererWorker::finalizeRendering(  DelayedIconRendererEntry& entry )
          {
           mRenderer.blitRenderToIcon(  entry.getIcon(   ) );
           mRenderer.getRenderContext(   )->getSceneManager(   )->destroyMovableObject(  entry.getModel(   ) );
           entries.pop(   );
          }
          
          
          
          
          
          
          
          }
          
          
          
          }
          
          }

./components/ogre/widgets/icons/IconRenderer.h

       1  //
          // C++ Interface: IconRenderer
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ICONSICONRENDERER_H
          #define EMBEROGRE_GUI_ICONSICONRENDERER_H
          
          #include <string>
          #include <Ogre.h>
          
          namespace EmberOgre {
          
      31  class SimpleRenderContext;
          
          namespace Model
          {
      35   class Model;
          }
          
          namespace Gui {
          
          namespace Icons {
          
      42  class Icon;
      43  class IconRenderer;
      44  class DelayedIconRendererWorker;
          
          /**
          An entry belonging to the DelayedIconRendererWorker.
          */
      49  class DelayedIconRendererEntry
          {
          public:
      52   DelayedIconRendererEntry(  DelayedIconRendererWorker& renderer,   Model::Model* model,   Icon* icon );
      53   virtual ~DelayedIconRendererEntry(   );
           /**
           * Accessor for the model which will be rendered.
           * @return
           */
      58   Model::Model* getModel(   );
           /**
           * Accessor for the icon.
           * @return
           */
      63   Icon* getIcon(   );
          
           /**
           * Called by the DelayedIconRendererWorker at the start of each frame.
           */
      68   void frameStarted(   );
          
          protected:
           /**
           A reference to the owner instance.
           */
      74   DelayedIconRendererWorker& mRenderer;
      75   Model::Model* mModel;
      76   Icon* mIcon;
           /**
           We'll keep track of the number of frames for this instance. On the first frame we'll perform the rendering,   and on later frames we'll blit the texture.
           */
           unsigned int mFrames;
          
          };
          
          
          /**
          The abstract class which performs the actual rendering.
          Note that it's the responsibility of this class to make sure that the Model supplied in the render method is properly destroyed.
          */
      89  class IconRenderWorker
          {
          public:
      92   IconRenderWorker(  IconRenderer& renderer );
      93   virtual ~IconRenderWorker(   );
           /**
           * Starts the process of rendering the model onto the icon. Depending on the implementation the actual blitting and rendering might be delayed some frames.
           * @param model The model to render. Note that it's the responsibility of this class to make sure that's it's properly destroyed after use.
           * @param icon
           */
      99   virtual void render(  Model::Model* model,   Icon* icon ) = 0;
          protected:
     101   IconRenderer& mRenderer;
          };
          
          /**
          Renders with a delay between the rendering and the blitting,   thus allowing the GPU to perform the rendering.
          */
     107  class DelayedIconRendererWorker : public Ogre::FrameListener,   public IconRenderWorker
          {
     109  friend class DelayedIconRendererEntry;
          public:
     111   DelayedIconRendererWorker(  IconRenderer& renderer );
           /**
           * Calles by Ogre. At each frame we'll see if there's any entries in our queue. If so,   we'll call frameStarted on the first entry in the list.
           */
     115   bool frameStarted(  const Ogre::FrameEvent& event );
          
           /**
           * Starts the process of rendering a model onto an icon. The blitting will be delayed a couple of frames though.
           * @param model
           * @param icon
           */
     122   void render(  Model::Model* model,   Icon* icon );
          
          
          protected:
          
     127   IconRenderer& getRenderer(   );
          
           /**
           * Method to be called by the contained entries when they want to perform the actual rendering operation.
           * @param entry
           */
     133   void performRendering(  DelayedIconRendererEntry& entry );
          
           /**
           * Method to be called by the contained entries when they want the blitting to occur.
           * Calling this method will also pop an entry from the entries queue. (  So if you call it from within a DelayedIconRendererEntry entry,   make sure to not touch any member variables afterwards,   since the instance will have been destroyed. )
           * @param entry
           */
     140   void finalizeRendering(  DelayedIconRendererEntry& entry );
          
           typedef std::queue<DelayedIconRendererEntry> EntryStore;
          
           /**
           The queue of entries which will be rendered in order.
           */
     147   EntryStore entries;
          
          };
          
          /**
          An instance of this class will render the icon and blit it to texture all in the same frame.
          */
     154  class DirectRendererWorker : public IconRenderWorker
          {
          public:
     157   DirectRendererWorker(  IconRenderer& renderer );
     158   virtual ~DirectRendererWorker(   );
          
           /**
           * Starts the process of rendering a model onto an icon. The blitting will occur in the same frame as the rendering.
           * @param model
           * @param icon
           */
     165   void render(  Model::Model* model,   Icon* icon );
          };
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
           Responsible for rendering the model to the icon texture.
           The actual rendering will be handled by an instance of IconRenderWorker.
           Note that it's not guaranteed that the rendering and blitting will occur on the same frame.
          */
     174  class IconRenderer
          {
     176  friend class IconRenderWorker;
          public:
          
           /**
           * Ctor. Be sure to call setWorker before you start any rendering.
           * @param prefix
           * @param pixelWidth
           */
     184   IconRenderer(  const std::string& prefix,   int pixelWidth );
          
     186   ~IconRenderer(   );
          
           /**
           * Renders a model by the specified name to the icon.
           * @param modelName The name of the model to render.
           * @param icon The icon it should be rendered to.
           */
     193   void render(  const std::string& modelName,   Icon* icon );
          
           /**
           * Renders the Model onto the Icon. Note that depending on the IconRenderWorker used this might not occur on the same frame.
           * Make sure to call setWorker before calling this method.
           * @param model The Model to render. Note that after calling this ownership of the Model is transferred to this instance,   which takes care of the proper destruction of it.
           * @param icon The icon to render to.
           */
     201   void render(  Model::Model* model,   Icon* icon );
          
           /**
           * Gets the SimpleRenderContext used for the rendering.
           * @return
           */
     207   SimpleRenderContext* getRenderContext(   );
          
           /**
           * Sets the worker instance. Be sure to call this before doing any rendering.
           * @param worker
           */
     213   void setWorker(  IconRenderWorker* worker );
          
          
           /**
           * Performs the actual rendering op.
           * @param model
           * @param icon
           */
     221   void performRendering(  Model::Model* model,   Icon* icon );
          
          
           /**
           * Blits the rendered texture onto the icon texture.
           * @param icon
           */
     228   void blitRenderToIcon(  Icon* icon );
          
          protected:
          
          
           int mPixelWidth;
     234   std::auto_ptr<SimpleRenderContext> mRenderContext;
     235   IconRenderWorker* mWorker;
          };
          
          }
          
          }
          
          }
          
          #endif

./components/ogre/widgets/icons/IconStore.cpp

       1  //
          // C++ Implementation: IconStore
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "IconStore.h"
          #include "IconImageStore.h"
          #include "Icon.h"
          
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Icons {
          
      34  IconStore::IconStore(   )
          {
          }
          
          
      39  IconStore::~IconStore(   )
          {
           for (  IconMap::iterator I = mIcons.begin(   ); I != mIcons.end(   ); ++I ) {
           delete I->second;
           }
           for (  IconImageStoreStore::iterator I = mIconImageStores.begin(   ); I != mIconImageStores.end(   ); ++I ) {
           delete *I;
           }
           for (  IconImageStoreMap::iterator I = mPremadeIconImageStores.begin(   ); I != mPremadeIconImageStores.end(   ); ++I ) {
           delete I->second;
           }
          }
          
      52  Icon* IconStore::createIcon(  const std::string& key )
          {
           IconImageStoreEntry* imageStoreEntry = getImageStoreEntry(   );
           Icon* icon = new Icon(  key,   imageStoreEntry );
          
           mIcons.insert(  IconMap::value_type(  key,   icon ) );
           return icon;
          }
          
      61  Icon* IconStore::createIcon(  const std::string& key,   Ogre::TexturePtr texPtr )
          {
           IconImageStore* store = new IconImageStore(  key,   texPtr );
           mPremadeIconImageStores.insert(  IconImageStoreMap::value_type(  key,   store ) );
           IconImageStoreEntry* imageStoreEntry = store->claimImageEntry(   );
          
           Icon* icon = new Icon(  key,   imageStoreEntry );
          
           mIcons.insert(  IconMap::value_type(  key,   icon ) );
           return icon;
          }
          
          
      74  Icon* IconStore::getIcon(  const std::string& key )
          {
           IconMap::iterator I = mIcons.find(  key );
           if (  I != mIcons.end(   ) ) {
           return I->second;
           }
           return 0;
          }
          
      83  bool IconStore::hasIcon(  const std::string& key )
          {
           return mIcons.find(  key ) != mIcons.end(   );
          }
          
      88  void IconStore::destroyIcon(  Icon* icon )
          {
           mIcons.erase(  icon->mKey );
           delete icon;
          }
          
      94  IconImageStoreEntry* IconStore::getImageStoreEntry(   )
          {
           for (  IconImageStoreStore::iterator I = mIconImageStores.begin(   ); I != mIconImageStores.end(   ); ++I ) {
           if (  (  *I )->getNumberOfUnclaimedIcons(   ) ) {
           return (  *I )->claimImageEntry(   );
           }
           }
           std::stringstream ss;
           ss << "iconImageStore_" << mIconImageStores.size(   );
           IconImageStore* store = new IconImageStore(  ss.str(   ) );
           mIconImageStores.push_back(  store );
           return store->claimImageEntry(   );
          }
          
          
          
          }
          
          }
          
          }

./components/ogre/widgets/icons/IconStore.h

       1  //
          // C++ Interface: IconStore
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGRE_GUI_ICONSICONSTORE_H
          #define EMBEROGRE_GUI_ICONSICONSTORE_H
          
          #include <map>
          #include <vector>
          #include <OgreTexture.h>
          
          namespace EmberOgre {
          
          namespace Gui {
          
          namespace Icons {
          
      36  class Icon;
      37  class IconImageStore;
      38  class IconImageStoreEntry;
          
          /**
           @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
          */
      43  class IconStore{
          public:
           typedef std::map<std::string,   Icon*> IconMap;
           typedef std::vector<IconImageStore*> IconImageStoreStore;
           typedef std::map<std::string,   IconImageStore*> IconImageStoreMap;
      48   IconStore(   );
          
      50   ~IconStore(   );
          
      52   Icon* createIcon(  const std::string& key );
      53   Icon* createIcon(  const std::string& key,   Ogre::TexturePtr texPtr );
      54   Icon* getIcon(  const std::string& key );
      55   bool hasIcon(  const std::string& key );
      56   void destroyIcon(  Icon* icon );
          
          protected:
      59   IconMap mIcons;
      60   IconImageStoreStore mIconImageStores;
      61   IconImageStoreMap mPremadeIconImageStores;
          
      63   IconImageStoreEntry* getImageStoreEntry(   );
          
          };
          
          }
          
          }
          
          }
          
          #endif

./components/text/EmberText.cpp

       1  /*
           EmberText.cpp by Miguel Guzman (  Aglanor )
           Copyright (  C ) 2002 Miguel Guzman & The Worldforge Project
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // config headers
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          // system headers
          
          // library headers
          #include <iostream>
          //#include <string>
          // Headers to stop compile problems from headers
          #include <stdlib.h>
          
          // ------------------------------
          // Include Eris header files
          // ------------------------------
          #if defined(   _MSC_VER  ) && (   _MSC_VER < 1300  )
          // GNDN: MSVC < version 7 is broken
          #else
          #include <Eris/PollDefault.h>
          #include <Eris/Log.h>
          #endif
          
          
          //Dime headers
          #include "services/DimeServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/server/ServerService.h"
          #include "services/config/ConfigService.h"
          #include "services/metaserver/MetaserverService.h"
          #include "framework/ConsoleBackend.h"
          
          // local headers
          #include "EmberText.h"
          
          
          // TODO: move CerrLogObserver to its own class (  under Logging service,   or under Framework )
      57   class CerrLogObserver: public dime::LoggingService::Observer
           {
           public:
      60   CerrLogObserver(   )
           {
           }
          
      64   virtual void onNewMessage(  const std::string & message,   const std::string & file,   const int & line,  
      65   const dime::LoggingService::MessageImportance & importance,   const time_t & timeStamp )
           {
           tm * ctm = localtime(  &timeStamp ); //currentLocalTime was too long,   sorry
          
           std::cerr.fill(  '0' );
           std::cerr << "[";
           std::cerr.width(  2 );
           std::cerr << (  ctm->tm_year/*+1900*/ )%100 << "-";
           std::cerr.width(  2 );
           std::cerr << ctm->tm_mon+1 << "-";
           std::cerr.width(  2 );
           std::cerr << ctm->tm_mday << " ";
           std::cerr.width(  2 );
           std::cerr << ctm->tm_hour << ":";
           std::cerr.width(  2 );
           std::cerr << ctm->tm_min << ":";
           std::cerr.width(  2 );
           std::cerr << ctm->tm_sec << "] ";
           std::cerr << "[File: " << file << ",   Line #:" << line << "] (  ";
          
           if(  importance == dime::LoggingService::CRITICAL )
           {
           std::cerr << "CRITICAL";
           }
           else if(  importance == dime::LoggingService::FAILURE )
           {
           std::cerr << "FAILURE";
           }
           else if(  importance == dime::LoggingService::WARNING )
           {
           std::cerr << "WARNING";
           }
           else if(  importance == dime::LoggingService::INFO )
           {
           std::cerr << "INFO";
           }
           else
           {
           std::cerr << "VERBOSE";
           }
           std::cerr << " ) " <<message << std::endl;
           }
          
           private:
          
           };
          
     112  void EmberText::init(   )
          {
           myBackend = dime::ConsoleBackend::getMainConsole(   );
           initializeDimeServices(   );
           std::cout << "EmberText initialised" << std::endl;
           return;
          }
          
          
     121  void EmberText::initializeDimeServices(  void )
          {
           // Initialize dime services
          
           // Initialize the Logging service and an error observer
           dime::LoggingService *logging = dime::DimeServices::getInstance(   )->getLoggingService(   );
           CerrLogObserver* obs = new CerrLogObserver(   );
           obs->setFilter(  dime::LoggingService::VERBOSE );
           logging->addObserver(  obs );
          
          
           // Initialize the Configuration Service
           dime::DimeServices::getInstance(   )->getConfigService(   )->start(   );
          
          
          /*
           // Initialize the Sound Service
          #ifndef WIN32
           // Test that /dev/dsp is availible
           FILE *temp = fopen(  "/dev/dsp",  "w" );
           if (  temp ) {
           fclose(  temp );
          #endif
           // Initialize the SoundService
           dime::DimeServices::getInstance(   )->getSoundService(   )->start(   );
          #ifndef WIN32
           }
          #endif
          */
          
           // Initialize and start the Metaserver Service.
          #if defined(   _MSC_VER  ) && (   _MSC_VER < 1300  )
           // GNDN: MSVC < version 7 is broken
          #else
           // Set Eris Logging Level
           Eris::setLogLevel(  Eris::LOG_DEBUG );
          
           // Initialize the Metaserver Service
           dime::DimeServices::getInstance(   )->getMetaserverService(   )->start(   );
          
           // Initialize the Server Service
           dime::DimeServices::getInstance(   )->getServerService(   )->start(   );
          #endif
          
          
          
          }
          
          
          
     171  void EmberText::loop(   )
          {
          
          int n=30;
          std::string command;
          while(  n>=0 )
          {
           command = "";
           std::cout << ">>> ";
           std::getline(  std::cin,  command );
           std::cout << "-> [" << command << "]" << std::endl;
          
           // run the command
           myBackend->runCommand(  command );
          
           // Display all console queued messages
           std::cout << "Queued msgs: " << std::endl;
           const std::list<std::string> msgs = myBackend->getConsoleMessages(   );
           std::list<std::string>::const_iterator index = msgs.begin(   );
           std::list<std::string>::const_iterator end = msgs.end(   );
           while(   index != end  )
           {
           std::cout << "... " << *index << std::endl;
           ++index;
           }
           std::cout << "End queue." << std::endl;
          
           // Eris polling
           Eris::PollDefault::poll(   );
          
           n--;
          }
          
          
          }
          
          
          // ----------------------------------------------------------------------------
          // Main function,   just boots the application object
          // ----------------------------------------------------------------------------
          //#if OGRE_PLATFORM == PLATFORM_WIN32
          //#define WIN32_LEAN_AND_MEAN
          //#include "windows.h"
          //INT WINAPI WinMain(   HINSTANCE hInst,   HINSTANCE,   LPSTR strCmdLine,   INT  )
          //#else
     216  int main(  int argc,   char **argv )
          //#endif
          {
           // Create application object
           EmberText app;
          
           // Initialise
           app.init(   );
          
           // Run
           app.loop(   );
          
           return 0;
          }

./components/text/EmberText.h

       1  /*
           EmberText.h by Miguel Guzman (  Aglanor )
           Copyright (  C ) 2002 Miguel Guzman & The Worldforge Project
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "framework/ConsoleBackend.h" //TODO: do a forward declaration
          
      22  class EmberText
          {
          
           public:
          
      27   void init(   );
      28   void loop(   );
          
           private:
          
      32   void initializeDimeServices(  void );
          
      34   bool running;
      35   dime::ConsoleBackend *myBackend;
          
          };

./framework/ConsoleBackend.cpp

       1  /*
           Copyright (  C ) 2002 Martin Pollard (  Xmp ),   Simon Goodall
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Rewritten for Ember by Martin Pollard (  Xmp )
          
          // Some code originally written for Sear by Simon Goodall,   University of Southampton
          // Original Copyright (  C ) 2001 - 2002
          
          #include "ConsoleBackend.h"
          #include "services/logging/LoggingService.h"
          
          #include <sstream>
          
          namespace Ember {
          
          // List of ConsoleBackend's console commands
      32  const char * const ConsoleBackend::LIST_CONSOLE_COMMANDS = "list_commands";
          const unsigned int ConsoleBackend::MAX_MESSAGES = 7;
          
          Ember::ConsoleBackend *Ember::ConsoleBackend::theMainConsole = 0;
          
      37  ConsoleBackend::ConsoleBackend(  void ) :
           myRegisteredCommands(  ConsoleObjectEntryStore(   ) ),  
           myConsoleMessages(  std::list<std::string>(   ) ),  
           mHistoryPosition(  0 )
          {
           // Register console commands
           registerCommand(  LIST_CONSOLE_COMMANDS,   this );
          }
          
      46  ConsoleBackend::ConsoleBackend(   const ConsoleBackend &source  )
          {
           // Use assignment operator to do the copy
           // NOTE: If you need to do custom initialization in the constructor this may not be enough.
           *this = source;
          }
          
      53  ConsoleBackend& ConsoleBackend::operator= (   const ConsoleBackend &source  )
          {
           // Copy fields from source class to this class here.
          
           // Return this object with new value
           return *this;
          }
          
      61  ConsoleBackend::~ConsoleBackend (   )
          {
           // TODO: Free any allocated resources here.
          }
          
      66  void ConsoleBackend::moveBackwards(  void )
          {
           if(  mHistoryPosition < mHistory.size(   ) )
           {
           mHistoryPosition++;
           }
          }
          
      74  void ConsoleBackend::moveForwards(  void )
          {
           if(  mHistoryPosition > 0 )
           {
           mHistoryPosition--;
           }
          }
          
      82  const std::string& ConsoleBackend::getHistoryString(   )
          {
           static std::string sEmpty(  "" );
          
           if(  mHistoryPosition == 0 )
           {
           return sEmpty;
           }
           else
           {
           return mHistory[mHistoryPosition - 1];
           }
          }
          
          
      97  void ConsoleBackend::pushMessage(  const std::string &message ) {
           //only save message if onGotMessage returns true
           if (  !onGotMessage(  message ) ) {
           // If we have reached our message limit,   remove the oldest message
           if (  myConsoleMessages.size(   ) >= MAX_MESSAGES )
           myConsoleMessages.erase(  myConsoleMessages.begin(   ) );
           myConsoleMessages.push_back(  message );
           }
          }
          
     107  bool ConsoleBackend::onGotMessage(  const std::string &message )
          {
           return GotMessage.emit(  message );
          }
          
          
     113  void ConsoleBackend::registerCommand(  const std::string &command,   ConsoleObject *object,   const std::string& description )
          {
           S_LOG_INFO(  "Registering: " << command );
          
           ConsoleObjectEntry entry;
           entry.Object = object;
           entry.Description = description;
           // Assign the ConsoleObject to the command
           myRegisteredCommands[command] = entry;
          
           // prepare the prefix map to have fast access to commands
           for(  std::string::size_type i = 1; i <= command.length(   ); ++i )
           {
           mPrefixes[command.substr(  0,   i )].insert(  command );
           }
          }
          
     130  void ConsoleBackend::deregisterCommand(  const std::string &command )
          {
           S_LOG_INFO(  "Deregistering: " << command );
          
           // Delete from the map
           myRegisteredCommands.erase(  myRegisteredCommands.find(  command ) );
          }
          
     138  void ConsoleBackend::runCommand(  const std::string &command,   bool addToHistory )
          {
           if (  command.empty(   ) ) return; // Ignore empty string
          
           // Grab first character of command string
           char c = command.c_str(   )[0];
          
           // Check to see if command is a command,   or a speech string
           if (  (  c != '/' && c != '+' && c != '-' ) ) {
           // Its a speech string,   so SAY it
           // FIXME /say is not always available!
           runCommand(  std::string(  "/say " ) + command,   addToHistory );
           return;
           }
          
           // If command has a leading /,   remove it
           std::string command_string = (  c == '/' )? command.substr(  1 ) : command;
          
           // Split string into command / arguments pair
           Tokeniser tokeniser = Tokeniser(   );
           tokeniser.initTokens(  command_string );
           std::string cmd = tokeniser.nextToken(   );
           std::string args = tokeniser.remainingTokens(   );
          
           //Grab object registered to the command
           ConsoleObjectEntryStore::iterator I = myRegisteredCommands.find(  cmd );
          
           // Print all commands to the console
           // pushMessage(  command_string );
          
           if (  addToHistory ) {
           mHistory.push_front(  command );
           mHistoryPosition = 0;
           }
           // If object exists,   run the command
           if (  I != myRegisteredCommands.end(   ) && I->second.Object != 0 ) {
           I->second.Object->runCommand(  cmd,   args );
           }
           else { // Else print error message
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::WARNING ) << "Unknown command:"<<command<< ENDM;
           pushMessage(  std::string(  "Unknown command " ) + command );
           }
          }
          
     182  void ConsoleBackend::runCommand(  const std::string &command,   const std::string &args )
          {
           std::ostringstream temp;
          
           // This commands prints all currently registers commands to the Log File
           if (  command == LIST_CONSOLE_COMMANDS ) {
           for (  ConsoleObjectEntryStore::const_iterator I = myRegisteredCommands.begin(   ); I != myRegisteredCommands.end(   ); I++ ) {
           // TODO - should we check to see if I->second is valid?
           temp << I->first<< " : " << I->second.Description << std::endl;
           }
           }
          
           S_LOG_VERBOSE(  temp.str(   ) );
           temp<< std::ends;
          
           pushMessage(  temp.str(   ) );
          }
          
     200  const std::set< std::string > & ConsoleBackend::getPrefixes(  const std::string & prefix ) const
          {
           static std::set< std::string > empty;
           std::map< std::string,   std::set< std::string > >::const_iterator iPrefixes(  mPrefixes.find(  prefix ) );
          
           if(  iPrefixes != mPrefixes.end(   ) )
           {
           return iPrefixes->second;
           }
          
           return empty;
          }
          
     213  void ConsoleBackend::changeHistory(  size_t stHistoryIndex,   const std::string & sCommand )
          {
           if(  stHistoryIndex < mHistory.size(   ) )
           {
           mHistory[stHistoryIndex - 1] = sCommand;
           }
          }
          
          } // namespace Ember

./framework/ConsoleBackend.h

       1  /*
           Copyright (  C ) 2002 Martin Pollard,   Simon
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
           */
          
          #ifndef CONSOLEBACKEND_H
          #define CONSOLEBACKEND_H
          
          // Included headers from the current project
          #include "ConsoleObject.h"
          #include "Tokeniser.h"
          
          // Included custom library headers
          
          #include <sigc++/signal.h>
          #include <sigc++/object_slot.h>
          
          // Included system headers
          #include <deque>
          #include <list>
          #include <map>
          #include <set>
          #include <string>
          
          namespace Ember {
          
          /**
           * Backend storage class for Console's.
           *
           * More detailed description of the class,   it's purpose,   what it does,  
           * how to use it and so on.
           *
           * A short piece of example code demonstarting how this class it is used,  
           * and in what context,   is encouraged.
           *
           * @author Martin Pollard aka Xmp
           *
           * NOTE: You can also specify the author for individual methods
           * if different persons have created them.
           * It is also possible to have multiple @author tags for a method.
           * Only add yourself as an @author if you have done serious work
           * on a class/method,   and can help fixing bugs in it,   etc.
           * If you just fixed a bug or added a short code snipplet you
           * don't need to add yourself.
           *
           * @see Ember::Console
           * @see Ember::ConsoleObject
           *
           */
          
      64  class ConsoleBackend : public ConsoleObject
          {
           //======================================================================
           // Inner Classes,   Typedefs,   and Enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Public Constants
           //======================================================================
           public:
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           struct ConsoleObjectEntry
           {
           ConsoleObject* Object;
           std::string Description;
           };
          
           typedef std::map<std::string,   ConsoleObjectEntry> ConsoleObjectEntryStore;
          
           static const unsigned int MAX_MESSAGES;
          
           // List of ConsoleBackend's console commands
           static const char * const LIST_CONSOLE_COMMANDS;
          
           //======================================================================
           // Private Variables
           //======================================================================/
           private:
          
           /**
           * Instance variable for singleton main Ember console.
           */
           static ConsoleBackend* theMainConsole;
          
           /**
           * Mapping of registered commands to associated object.
           */
           ConsoleObjectEntryStore myRegisteredCommands;
          
           /**
           * Current console messages
           */
           std::list< std::string > myConsoleMessages;
          
           /**
           * Message history.
           **/
           std::deque< std::string > mHistory;
          
           /**
           * History iterator.
           **/
           size_t mHistoryPosition;
          
           /**
           * Prefix map for commands.
           **/
           std::map< std::string,   std::set< std::string > > mPrefixes;
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           //----------------------------------------------------------------------
           // Constructors
          
           /**
           * Creates a new ConsoleBackend using default values.
           */
           ConsoleBackend(  void );
          
           /**
           * Copy constructor.
           */
           ConsoleBackend(   const ConsoleBackend &source  );
          
          
           /**
           * Assignment operator.
           */
           ConsoleBackend &operator= (   const ConsoleBackend &source  );
          
          
           //----------------------------------------------------------------------
           // Destructor
          
           /**
           * Deletes a ConsoleBackend instance.
           */
           virtual ~ConsoleBackend (   );
          
          
           //----------------------------------------------------------------------
           // Getters
          
           /**
           * Gets an instance of the main Ember console
           */
           inline static ConsoleBackend* getMainConsole(   );
          
           inline const std::list<std::string>& getConsoleMessages(   ) const;
          
          
           inline size_t getHistoryPosition(   ) const;
          
           const std::set< std::string > & getPrefixes(  const std::string & prefix ) const;
          
           /**
           * Get the current history string.
           * The history position 0 is managed in the ConsoleWidget.
           **/
           const std::string & getHistoryString(   );
          
           void changeHistory(  size_t stHistoryIndex,   const std::string & sCommand );
          
          
           //----------------------------------------------------------------------
           // Setters
          
           /**
           * Moves the history iterator backwards (  in time ).
           **/
           void moveBackwards(  void );
          
           /**
           * Moves the history iterator forwards (  in time ).
           **/
           void moveForwards(  void );
          
          
           //----------------------------------------------------------------------
           // Other public methods
          
           /**
           * Registers a command with the console
           * command is the command to register
           * object is the originating object
           */
           void registerCommand(  const std::string &command,   ConsoleObject *object,   const std::string& description = "" );
          
           /**
           * Deregisters a command with the console
           * command is the command to deregister
           */
           void deregisterCommand(  const std::string &command );
          
           /**
           * This is the method the determines what object the pass the command onto
           *
           * @param command the command string to process
           */
           void runCommand(  const std::string &command,   bool addToHistory = true );
          
           /**
           * Add a message to the console message queue.
           * message is the message string
           */
           void pushMessage(  const std::string &message );
          
           /**
           * This is the ConsoleObject method.
           * command is the command to run
           * args is the commands arguments
           */
           void runCommand(  const std::string &command,   const std::string &args );
          
          
           //------------------------------------
           // Events
          
          
           /**
           * This event is raised every time a message is pushed to the console.
           * If True is returned,   the message won't be saved in myConsoleMessages
           */
           sigc::signal<bool,   const std::string&> GotMessage;
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
           virtual bool onGotMessage(  const std::string &message );
          
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
           //======================================================================
           // Disabled constructors and operators
           //======================================================================
           private:
          
          
          }; // End of ConsoleBackend
          
     270  ConsoleBackend* ConsoleBackend::getMainConsole(   )
          {
           if (   !theMainConsole  )
           theMainConsole = new ConsoleBackend(   );
           return theMainConsole;
          }
          
     277  const std::list<std::string>& ConsoleBackend::getConsoleMessages(   ) const
          {
           return myConsoleMessages;
          }
          
     282  size_t ConsoleBackend::getHistoryPosition(   ) const
          {
           return mHistoryPosition;
          }
          
          
          } // End of Ember namespace
          
          #endif

./framework/ConsoleCommandWrapper.cpp

       1  //
          // C++ Implementation: ConsoleCommandWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ConsoleCommandWrapper.h"
          #include "ConsoleBackend.h"
          #include "services/logging/LoggingService.h"
          
          namespace Ember {
          
          
      30  ConsoleCommandWrapper::ConsoleCommandWrapper(  std::string command,   ConsoleObject *object,   std::string description ) : mCommand(  command ),   mInverseCommand(  "" ),   mDescription(  description ),   mObject(  object )
          {
           if (  mCommand.size(   ) > 0 && mCommand[0] == '+' ) {
           mInverseCommand = std::string(  "-" ) + std::string(  mCommand ).erase(  0,   1 );
           }
           if (  Ember::ConsoleBackend::getMainConsole(   ) ) {
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  mCommand,   object,   mDescription );
           if (  mInverseCommand != "" ) {
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  mInverseCommand,   object,   std::string(  "Releases the command " ) + mCommand );
           }
           } else {
           S_LOG_WARNING(  "Could not register command "<< command << " since there was no console backend." );
           }
          }
          
      45  ConsoleCommandWrapper::~ConsoleCommandWrapper(   )
          {
           if (  Ember::ConsoleBackend::getMainConsole(   ) ) {
           Ember::ConsoleBackend::getMainConsole(   )->deregisterCommand(  mCommand );
           }
          }
          
          
          }

./framework/ConsoleCommandWrapper.h

       1  //
          // C++ Interface: ConsoleCommandWrapper
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERCONSOLECOMMANDWRAPPER_H
          #define EMBERCONSOLECOMMANDWRAPPER_H
          
          #include <string>
          
          namespace Ember {
      29  class ConsoleObject;
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          
           A utility wrapper object for a console command. Use this on classes that have console commands. It will register and deregister itself on construction and destruction.
          */
      35  class ConsoleCommandWrapper {
          public:
          
          
           /**
           * Constructor.
           * @param command The console command.
           * @param object The object instance.
           * @param description Description of the command.
           * @return
           */
      46   ConsoleCommandWrapper(  std::string command,   ConsoleObject *object,   std::string description = "" );
          
      48   ~ConsoleCommandWrapper(   );
          
           /**
           * Gets the command.
           * @return
           */
      54   inline const std::string& getCommand(   ) const;
          
      56   inline const std::string& getInverseCommand(   ) const;
          
           /**
           * Gets the description of the command.
           * @return
           */
      62   inline const std::string& getDescription(   ) const;
          
      64   inline bool operator==(   const std::string& command ) const;
          
          private:
          
      68   std::string mCommand;
      69   std::string mInverseCommand;
      70   std::string mDescription;
      71   ConsoleObject* mObject;
          };
          
          
      75  const std::string& ConsoleCommandWrapper::getCommand(   ) const {return mCommand;}
      76  const std::string& ConsoleCommandWrapper::getInverseCommand(   ) const {return mInverseCommand;}
      77  const std::string& ConsoleCommandWrapper::getDescription(   ) const {return mDescription;}
      78  bool ConsoleCommandWrapper::operator==(   const std::string& command ) const { return command == mCommand; }
          
          
          }
          
          #endif

./framework/ConsoleObject.h

       1  /*
           Copyright (  C ) 2002 Martin Pollard (  Xmp ),   Simon Goodall
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Rewritten for Ember by Martin Pollard (  Xmp )
          
          // Originally written for Sear by Simon Goodall,   University of Southampton
          // Original Copyright (  C ) 2001 - 2002
          
          #ifndef CONSOLEOBJECT_H
          #define CONSOLEOBJECT_H
          
          // Included headers from the current project
          
          // Included custom library headers
          
          // Included system headers
          #include <string>
          #include "framework/ConsoleCommandWrapper.h"
          
          namespace Ember {
          /**
           * ConsoleObject
           *
           * The ConsoleObject is an interface used to allow objects to register commands
           * with the console. Any object wishing to register a command,   must implement
           * this interface.
           *
           * class SomeClass : public ConsoleObject {
           * void runCommand(  const std::string &command,   const std::string &args );
           * }
           *
           * @author Xmp (  Martin Pollard )
           *
           * @see Console
           */
      51  class ConsoleObject {
          public:
           /**
           * Default constructor
           */
      56   ConsoleObject(   ) {}
          
           /**
           * Default destructor
           */
      61   virtual ~ConsoleObject(   ) {}
          
           /**
           * This is the function that needs to be extended to use the console.
           * "command" is a command that has been previously registered with the console
           * "args" is the argument string that has been provided for the command
           */
      68   virtual void runCommand(  const std::string &command,   const std::string &args ) = 0;
          };
          
          } /* namespace Ember */
          #endif /* CONSOLEOBJECT_H */

./framework/Exception.h

       1  /*
           * File: Exception.h
           * Summary: The class which defines the base class for exceptions.
           * Written by: nikal and xmp
           *
           * Copyright (  C ) 2002 nikal,   xmp.
           * This code is distributed under the GPL.
           * See file COPYING for details.
           *
           * Change History (  most recent first ):
           *
           */
          /*
           Copyright (  C ) 2002 Nikal,   Xmp
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          
          #ifndef EXCEPTION_H
          #define EXCEPTION_H
          
          // Included headers from the current project
          
          // Included custom library headers
          
          // Included system headers
          #include <string>
          // #include <stdarg.h>
          // #include <stdio.h>
          
          namespace Ember
          {
      46  class Exception;
          /**
           * The default way to throw exceptions is to use one of the following macros.
           */
          
          // #define THROW(  message ) throw Exception(  message,   __FILE__,   __LINE__ );
          // #define THROW1(  message,   p1 ) throw Exception(  message,   __FILE__,   __LINE__,   p1 );
          // #define THROW2(  message,   p1,   p2 ) throw Exception(  message,   __FILE__,   __LINE__,   p1,   p2 );
          // #define THROW3(  message,   p1,   p2,   p3 ) throw Exception(  message,   __FILE__,   __LINE__,   p1,   p2,   p3 );
          
          /**
           * The base class for all exceptions that are thrown within Ember.
           *
           * More detailed description of the class,   it's purpose,   what it does,  
           * how to use it and so on.
           *
           * A short piece of example code demonstarting how this class it is used,  
           * and in what context,   is encouraged.
           *
           * @author Nikal
           * @author Xmp (  Martin Pollard )
           *
           */
          
          const int EXCEPTION_TEXT_SIZE = 1024;
          
      72  class Exception
          {
          
           //======================================================================
           // Private Variables
           //======================================================================
          private:
      79   std::string myError;
      80   std::string myFile;
           int myLine;
          
           //======================================================================
           // Public Methods
           //======================================================================
          public:
          
           //----------------------------------------------------------------------
           // Constructors
          
           /**
           * Creates a new generic Exception using default values.
           */
      94   Exception(   )
           : myError(  "Unknown Exception" )
           {
           }
          
           /**
           * Creates a new generic Exception using the specified error string.
           */
     102   Exception(  const std::string& error )
           : myError(  error )
           {
           myLine = -1;
           myFile = "";
           }
          
           /**
           * Creates a new generic Exception using the specified error string,   file and line
           * occurence.
           */
     113   Exception(  const std::string& error,   const std::string & file,   int line,   ... )
           : myFile(  file ),   myLine(  line )
           {
           char buffer[EXCEPTION_TEXT_SIZE];
           va_list va;
           va_start (  va,   line );
           vsprintf(  buffer,   error.c_str(   ),   va );
           myError = buffer;
           }
          
          
           //----------------------------------------------------------------------
           // Destructor
          
           /**
           * Deletes an Exception instance.
           */
     130   virtual ~Exception(   )
           {
           }
          
           //----------------------------------------------------------------------
           // Getters
          
           /**
           * Returns the error that caused the exception
           */
     140   const std::string& getError(   ) const
           {
           return myError;
           }
          
           //----------------------------------------------------------------------
           // Setters
          
     148   void setError(  const std::string& error )
           {
           myError = error;
           }
          
           //----------------------------------------------------------------------
           // Other public methods
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
           //======================================================================
           // Disabled constructors and operators
           //======================================================================
           private:
          };
          
          
          }
          #endif

./framework/IGameView.h

       1  //
          // C++ Interface: IGameView
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          namespace Ember
          {
      26   class IGameView
           {
           public:
      29   bool initialize(   );
          
      31   void start(   );
           };
          }

./framework/IResourceProvider.h

       1  //
          // C++ Interface: IResourceProvider
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include <memory>
          
          namespace Ember {
          
          /**
          An internal interface to be implemented by data providers.
          */
      31  class IResourceWrapper
          {
          public:
      34   virtual ~IResourceWrapper(   ) {}
          
           /**
           Gets raw data pointer.
           */
      39   virtual char* getDataPtr(   ) = 0;
          
           /**
           True if the wrapper has data.
           */
      44   virtual bool hasData(   ) = 0;
          
           /**
           Gets the size of the data.
           */
      49   virtual size_t getSize(   ) = 0;
          };
          
          /**
          A simple wrapper for general data.
          A wrapper does not need to contain any data: use the hasData method to check before accessing.
          */
      56  class ResourceWrapper
          {
          public:
      59   ResourceWrapper(  const ResourceWrapper& wrapper ) : mInternalWrapper(  wrapper.mInternalWrapper ),   mName(  wrapper.mName ) { }
      60   ResourceWrapper(  IResourceWrapper* internalWrapper,   const std::string& name ) : mInternalWrapper(  internalWrapper ),   mName(  name ) {}
          
           /**
           Gets raw data pointer.
           */
      65   inline char* getDataPtr(   );
           /**
           True if the wrapper has data.
           */
      69   inline bool hasData(   );
           /**
           Gets the size of the data.
           */
      73   inline size_t getSize(   );
           /**
           Gets the name of the resource.
           */
      77   inline const std::string& getName(   );
          
          private:
           mutable std::auto_ptr<IResourceWrapper> mInternalWrapper;
           std::string mName;
          };
          
          /**
          Interface implemented by resource providers.
          */
      87  class IResourceProvider
          {
          public:
      90   virtual ~IResourceProvider(   ) {}
          
           /**
           Returns a resource by the name.
           */
      95   virtual ResourceWrapper getResource(  const std::string& name ) = 0;
          };
          
      98  char* ResourceWrapper::getDataPtr(   ) { return mInternalWrapper->getDataPtr(   );}
      99  bool ResourceWrapper::hasData(   ) { return mInternalWrapper->hasData(   );}
     100  size_t ResourceWrapper::getSize(   ) { return mInternalWrapper->getSize(   );}
     101  const std::string& ResourceWrapper::getName(   ) {return mName;}
          
          }

./framework/IScriptingProvider.h

       1  //
          // C++ Interface: IScriptingProvider
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERISCRIPTINGPROVIDER_H
          #define EMBERISCRIPTINGPROVIDER_H
          
          #include <string>
          
          #include "IResourceProvider.h"
          
          namespace Ember {
          
      32  class ScriptingService;
          
          /**
          @author Erik Hjortsberg
          */
      37  class IScriptingProvider{
          public:
          
      40   virtual ~IScriptingProvider(   ){}
          
           /**
           * Loads the script.
           * @param scriptName
           */
      46   virtual void loadScript(  ResourceWrapper& resourceWrapper ) = 0;
          
           /**
           * Executes the supplied string directly into the scripting environment.
           * @param scriptCode
           */
      52   virtual void executeScript(  const std::string& scriptCode ) = 0;
          
          
           /**
           * Returns true if the provider will load the supplied script name. This is in most cases decided from the filename suffix.
           * @param scriptName
           * @return
           */
      60   virtual bool willLoadScript(  const std::string& scriptName ) = 0;
          
           /**
           * Gets the unique name of the scripting provider.
           * @return
           */
      66   virtual const std::string& getName(   ) const = 0;
          
           /**
           * Register with a service to allow for callbacks etc.
           * @param service
           */
      72   virtual void _registerWithService(  ScriptingService* service ) = 0;
          
           /**
           * Forces a full garbage collection.
           */
      77   virtual void forceGC(   ) = 0;
          
          // virtual void start(   ) = 0;
           /**
           * Stops the scripting provider. This involves releasing all of the objects held in scripts,   but not destroying the actual scripting environment (  so that callbacks and similiar objects still can use it ).
           */
      83   virtual void stop(   ) = 0;
          
          };
          
          }
          
          #endif

./framework/ISoundProvider.h

       1  //
          // C++ Interface: ISoundProvider
          //
          // Description:
          //
          //
          // Author: Miguel Guzman <aglanor@gmail.com>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERISOUNDPROVIDER_H
          #define EMBERISOUNDPROVIDER_H
          
          #include <string>
          
          namespace Ember {
          
      30  class SoundService;
          
          /**
          @author Miguel Guzman
          */
      35  class ISoundProvider{
          public:
          
      38   virtual ~ISoundProvider(   ) {}
          
           /**
           * Loads a sound
           * @param soundName
           */
      44   virtual void loadSound(  const std::string& soundName ) = 0;
          
           /**
           * Returns true if the provider will load the supplied sound name. This is in most cases decided from the filename suffix.
           * @param soundName
           * @return
           */
           // TODO: perhaps the Sound Provider doesn't need this
      52   virtual bool willLoadSound(  const std::string& soundName ) = 0;
          
           /**
           * Gets the unique name of the sound provider.
           * @return
           */
      58   virtual const std::string& getName(   ) const = 0;
          
           /**
           * Register with a service to allow for callbacks etc.
           * @param service
           */
      64   virtual void _registerWithService(  SoundService* service ) = 0;
          
          };
          
          }
          
          #endif

./framework/Service.h

       1  /*
           Copyright (  C ) 2002 Miguel Guzman Miranda [Aglanor]
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef SERVICE_H
          #define SERVICE_H
          
          // Include other headers of the current program here
          
          // Include library headers here
          
          // Include system headers here
          #include <string>
          #include <sigc++/trackable.h>
          #include <sigc++/signal.h>
          
          namespace Ember {
          
          /**
           * Abstract class for interface common denominator of services.
           *
           * Establishes the basic variables and methods to be shared by all services.
           *
           * @author Miguel Guzman Miranda
           *
           * @see OtherSubsystem::AnOtherRelatedClass
           * NOTE: Add other related classes here,   doxygen will create links to them.
           */
      43  class Service : public sigc::trackable
          {
           //======================================================================
           // Public Constants
           //======================================================================
           public:
          
           /**
           * Contains the different error states that a service can be in. <p>
           * <ul>
           * <li> OK - Service working normally. </li>
           * <li> NOTE - Service working,   but there is something that may need user attention. </li>
           * <li> WARNING - Service is working to some degree,   but there was some problems encountered,   or non-critical parts that are not working. </li>
           * <li> FAILURE - Service is not working. A resource it depends on is not present,   or the service is unimplemented. </li>
           * <li> CRITICAL - Service detected internal errors in itself or the system that can lead to data loss or other serious problems. </li>
           * </ul>
           *
           * (  The difference between FAILURE and CRITICAL is basically that FAILURE
           * means that the rest of the system may still work fine,   while CRITICAL means
           * that the whole system is likely to be unstable. )
           */
           enum Status
           {
           OK = 0,  
           NOTE = 1,  
           WARNING = 2,  
           FAILURE = 3,  
           CRITICAL = 4
           };
          
          
           //======================================================================
           // Private Variables
           //======================================================================
           private:
          
           /** Stores the unique name of the service */
      80   std::string myName;
          
           /** Stores the description of the service */
      83   std::string myDescription;
          
           /** Tells if the service is running or not */
      86   bool myRunning;
          
           /** Current status code */
           Status myStatus;
          
           /** Textual description of the current status,   especially if it is some problem. */
      92   std::string myStatusText;
          
          
           //======================================================================
           // Public methods
           //======================================================================
           public:
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           /** Creates a new Service using default values. */
     104   Service(   )
           {
           setName(   ""  );
           setDescription(   ""  );
           setStatusText(   ""  );
           myStatus = OK;
           myRunning = false;
           }
          
          
           /** Copy constructor. */
     115   Service(   const Service &source  )
           {
           // Use the assignment operator to initialize the new class.
           *this = source;
           }
          
          
           /** Assignment operator. */
     123   virtual Service &operator= (   const Service &source  )
           {
           myName = source.myName;
           myDescription = source.myDescription;
          
           myRunning = false; // The new service has not been initialized...
           myStatus = OK;
           myStatusText = ""; // Initial value
          
           // Return reference to this instance.
           return *this;
           }
          
           /** Deletes a Service instance. */
     137   virtual ~Service(   )
           {
           }
          
          
           //----------------------------------------------------------------------
           // Getters
          
           /** Returns the name of this Service. */
     146   virtual std::string getName(   ) const
           {
           return myName;
           }
          
          
           /** Returns the description of this Service. */
     153   virtual std::string getDescription(   ) const
           {
           return myDescription;
           }
          
          
           /** Returns the status of this Service. */
     160   virtual Service::Status getStatus(   ) const
           {
           return myStatus;
           }
          
          
           /** Returns true if the service is currently running. */
     167   virtual bool isRunning(   )
           {
           return myRunning;
           }
          
          
           /**
           * Returns the textual status message for this Service.
           * It is a description of the current status,  
           * especially if there is some problem.
           * (  If everything is fine,   then this can be empty,   as the status code can be
           * used to determine this. )
           */
     180   virtual std::string getStatusText(   )
           {
           return myStatusText;
           }
          
          
           //----------------------------------------------------------------------
           // Methods
          
           /**
           * This method is used to start the service.
           * It should take care of aquiring needed resources,   initializing
           * data structures,   and so on. <p>
           *
           * If the initialization suceeds,   it should also call setRunning(   true  )
           * to indicate that the service is running. <p>
           *
           * If initialization fails,   it should set appropriate status code and
           * status text. It could also write an entry into a log through the logging
           * service. <p>
           *
           * This method must be implemented by all inheriting classes. <p>
           *
           *
           * @returns success or error code
           */
     206   virtual Status start(   ) = 0;
          
          
           /**
           * This method stops the service,   and frees any used resources.
           * If the service has no special resources that need to be freed,  
           * or de-initialization to be done,   this
           * method can be left to the default implementation (  which just sets the
           * running state to false ). <p>
           *
           * Otherwise this method should be overridden,   and setRunning(   false  )
           * should be called if the service was stopped. <p>
           *
           * @ param code code which represents the cause of the service halt
           * TODO(  zzorn ): What do we need it for?
           */
     222   virtual void stop(   int code  )
           {
           EventStopping.emit(   );
           setRunning(   false  );
           }
          
           /**
           Emitted when the server has stopped.
           */
     231   sigc::signal<void> EventStopping;
          
          
           //======================================================================
           // Protected methods
           //======================================================================
           protected:
          
           //----------------------------------------------------------------------
           // Setters
          
           /** Sets the name of this Service. */
     243   virtual void setName(   const std::string& name  )
           {
           myName = name;
           }
          
          
           /** Sets the description of this Service. */
     250   virtual void setDescription(   const std::string& description  )
           {
           myDescription = description;
           }
          
          
           /* *
           * Sets the description of this Service.
           */
     259   virtual void setStatus(   Service::Status status  )
           {
           myStatus = status;
           }
          
          
           /** Specifies wether this service is currently running or not. */
     266   virtual void setRunning(   bool running  )
           {
           myRunning = running;
           }
          
          
           /**
           * Sets the textual status message for this Service.
           * It is a description of the current status,  
           * especially if there is some problem.
           * (  If everything is fine,   then this can be empty,   as the status code can be
           * used to determine this. )
           */
     279   virtual void setStatusText(   const std::string& statusText  )
           {
           myStatusText = statusText;
           }
          
          
          }; // Service
          
          } // namespace Ember
          
          #endif
          
          

./framework/ServiceManager.cpp

       1  
          #include "ServiceManager.h"
          
          #include <iostream>
          
          namespace dime
          {
          
           /** Typedef for the iterator */
           typedef std::vector<Service*> Container;
           typedef Container::iterator Iter;
          
          
           /* ctor */
      15   ServiceManager::ServiceManager(   )
           {
           }
          
           /* dtor */
      20   ServiceManager::~ServiceManager(   )
           {
           }
          
      24   void ServiceManager::startAll(   )
           {
           for(  Iter j = myServiceVector.begin(   ); j != myServiceVector.end(   ); j++ )
           {
           (  *j )->start(   );
           }
           }
          
      32   void ServiceManager::stopAll(  int code )
           {
           for(  Iter j = myServiceVector.begin(   ); j != myServiceVector.end(   ); j++ )
           {
           (  *j )->stop(  0 );
           }
           }
          
      40   void ServiceManager::listAll(   )
           {
           cout << "listing all services" << endl;
           for(  Iter i = myServiceVector.begin(   ); i != myServiceVector.end(   ); i++ )
           {
           //HINT: Always use .data(   ) for compatibility to MSVC
           cout << (  *i )->getName(   ).data(   ) << endl;
           cout << "TODO!" << endl;
           }
           }
          
          
          
      53   bool ServiceManager::addService(   Service *pservice  )
           {
           for(  Iter j = myServiceVector.begin(   ); j != myServiceVector.end(   ); j++ )
           {
           if (   (  (  pservice )->getName(   ) ) == (  (  *j )->getName(   ) )  )
           {
           return false; // services can't be duplicated
           }
           }
           myServiceVector.push_back(  pservice );
           return true;
           }
          
      66   bool ServiceManager::removeService(   Service *service  )
           {
           for(  Iter j = myServiceVector.begin(   ); j != myServiceVector.end(   ); j++ )
           {
           if (  (  service )==*j )
           {
           myServiceVector.erase(  j );
           return true;
           }
           }
           return false; // the service was not there
           }
          
          } // namespace dime

./framework/ServiceManager.h

       1  /*
           Copyright (  C ) 2002 Miguel Guzman Miranda [Aglanor]
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef SERVICEMANAGER_H
          #define SERVICEMANAGER_H
          
          #include "Service.h"
          
          #include <string>
          #include <vector>
          
          namespace Ember {
          
          /**
           * Service Manager: keeps track and controls the Ember services.
           *
           * Maintains a list of services and performs operations on them.
           *
           * @author Miguel Guzman Miranda [Aglanor]
           *
           */
      37  class ServiceManager
          
          {
           //======================================================================
           // Private Variables
           //======================================================================
           private:
           /** Ember Service Vector */
      45   std::vector < Service* > myServiceVector;
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           public:
          
           /** Creates a new Service using default values. */
      53   ServiceManager(   );
          
           /** Deletes an instance. */
      56   ~ServiceManager(   );
          
          
           //----------------------------------------------------------------------
           // Getters & Setters
          
          
           //----------------------------------------------------------------------
           // Methods
          
           /**
           * Starts all services.
           *
           */
      70   void startAll(   );
          
           /**
           * Stops all services.
           *
           * @param code Cause of the halt
           */
      77   void stopAll(  int code );
          
           /**
           * Lists all services to the standard output.
           *
           */
      83   void listAll(   );
          
           /**
           * Returns pointers to all registered service instances.
           *
           * @return iterator to go through a collection of pointers to services.
           */
      90   std::vector< Service* >::iterator getServices(   )
           {
           return myServiceVector.begin(   );
           }
          
           /**
           * Registers a new service and adds it to the list of registered services,   if it isn't
           * already registered.
           * @return true if successfully added & registered,   false otherwise.
           */
     100   bool addService(   Service *service  );
          
          
           /**
           * Unregisters a service and removes it from the list of registered services,  
           * if it was registered. If it was removed sucessfully,   true is returned.
           * If it wasn't registered or there was som other problem,   false is returned.
           * @return true if successfully removed and unregistered,   false otherwise.
           */
     109   bool removeService(   Service *service  );
          
          
           //======================================================================
           // Unimplemented copy constructor and assignment operator
           //======================================================================
           private:
          
           /** Copy constructor not provided. */
     118   ServiceManager(   const ServiceManager &source  )
           {
           }
          
           /** Assignment operator not provided. */
     123   ServiceManager &operator= (   const ServiceManager &source  )
           {
           }
          
          
          }; // Service
          
          } // namespace Ember
          
          #endif
          
          

./framework/Singleton.h

       1  /*
           Copyright (  C ) 2004 Erik Hjortsberg
          
           Taken from the file OgreSingleton.h from the Ogre project,   release 0.14
           (  www.ogre3d.org )
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef _EMBER_SINGLETON_H__
          #define _EMBER_SINGLETON_H__
          
          #include <cassert>
          
          namespace Ember {
          
           /** Template class for creating single-instance global classes.
           */
      31   template <typename T> class Singleton
           {
           protected:
          
      35   static T* ms_Singleton;
          
           public:
      38   Singleton(   void  )
           {
           assert(   !ms_Singleton  );
           ms_Singleton = static_cast< T* >(   this  );
           }
          
      44   ~Singleton(   void  )
           {
           assert(   ms_Singleton  ); ms_Singleton = 0;
           }
          
      49   static T& getSingleton(   void  )
           {
           assert(   ms_Singleton  );
           return (   *ms_Singleton  );
           }
          
      55   static T* getSingletonPtr(   void  )
           {
           assert(   ms_Singleton  );
           return ms_Singleton;
           }
          
      61   static T& instance(   void  )
           {
           return getSingleton(   );
           }
           };
          }
          #endif
          

./framework/StreamLogObserver.cpp

       1  /*
           Copyright (  C ) 2002 Lakin Wecker
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
           */
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "StreamLogObserver.h"
          #include <ctime>
          
          namespace Ember {
           /**
           * Creates a new StreamLogObserver using default values.
           */
      30   StreamLogObserver::StreamLogObserver(  std::ostream &out )
           : myOut(  out )
           {
           }
          
           /**
           * Copy constructor.
           */
      38   StreamLogObserver::StreamLogObserver(   const StreamLogObserver &source  )
           : myOut(  source.myOut )
           {
           }
          
           //----------------------------------------------------------------------
           // Destructor
          
           /**
           * Deletes a StreamLogObserver instance.
           */
      49   StreamLogObserver::~StreamLogObserver (   ) {}
          
           //----------------------------------------------------------------------
           // Implemented methods from LoggingService::Observer
          
           /**
           * Prints out the message provided with file,   line and datestamp to myOut;
           */
      57   void StreamLogObserver::onNewMessage(  const std::string & message,   const std::string & file,   const int & line,  
      58   const Ember::LoggingService::MessageImportance & importance,   const time_t & timeStamp )
           {
           tm * ctm = localtime(  &timeStamp ); //currentLocalTime was too long,   sorry
          
           myOut.fill(  '0' );
           myOut << "[";
           myOut.width(  2 );
           myOut << ctm->tm_hour << ":";
           myOut.width(  2 );
           myOut << ctm->tm_min << ":";
           myOut.width(  2 );
           myOut << ctm->tm_sec << "] ";
          
           if(  importance == Ember::LoggingService::CRITICAL )
           {
           myOut << "CRITICAL";
           }
           else if(  importance == Ember::LoggingService::FAILURE )
           {
           myOut << "FAILURE";
           }
           else if(  importance == Ember::LoggingService::WARNING )
           {
           myOut << "WARNING";
           }
           else if(  importance == Ember::LoggingService::INFO )
           {
           myOut << "INFO";
           }
           else
           {
           myOut << "VERBOSE";
           }
          
           myOut << " " << message;
          
           ///only write file and line number if we're in verbose mode (  to make the log a little smaller in most cases
          /* if (  getFilter(   ) == Ember::LoggingService::VERBOSE ) {
           myOut << " [File: " << file << ",   Line #:" << line << "]";
           }*/
           myOut << std::endl;
          
           }
          }; //end namespace Ember

./framework/StreamLogObserver.h

       1  /*
           Copyright (  C ) 2002 Lakin Wecker
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
           */
          
          #ifndef STREAMLOGOBSERVER_H
          #define STREAMLOGOBSERVER_H
          
          // Included headers from the current project
          #include "services/logging/LoggingService.h"
          
          // Included custom library headers
          
          // Included system headers
          #include <iostream>
          
          namespace Ember {
          
          /**
           * Log Observer which logs stuff to the stream provided on creation.
           *
           * This log observer takes an arbitrary ostream at it's creation
           * and logs all messages sent to it to this stream.
           *
           * LoggingService *logging = EmberServices::getSingletonPtr(   )->getLoggingService(   );
           * //Create log observer that prints everything to cerr
           * StreamLogObserver* obs = new StreamLogObserver(  std::cerr );
           * obs->setFilter(  LoggingService::VERBOSE );
           * logging->addObserver(  obs );
           *
           * @author Lakin Wecker aka nikal
           *
           * @see LoggingService::Observer
           */
          
      49  class StreamLogObserver : public Ember::LoggingService::Observer
          {
          
           //======================================================================
           // Private Variables
           //======================================================================/
           private:
          
      57   std::ostream &myOut;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           //----------------------------------------------------------------------
           // Constructors
          
           /**
           * Creates a new StreamLogObserver using default values.
           */
      70   StreamLogObserver(  std::ostream &out );
          
           /**
           * Copy constructor.
           */
      75   StreamLogObserver(   const StreamLogObserver &source  );
          
          
          
          
           //----------------------------------------------------------------------
           // Destructor
          
           /**
           * Deletes a StreamLogObserver instance.
           */
      86   virtual ~StreamLogObserver (   );
          
           //----------------------------------------------------------------------
           // Implmented methods from LogginService::Observer
          
           /**
           * Prints out the message provided with file,   line and datestamp to myOut;
           */
      94   virtual void onNewMessage(  const std::string & message,   const std::string & file,   const int & line,  
      95   const Ember::LoggingService::MessageImportance & importance,   const time_t & timeStamp );
          
           //----------------------------------------------------------------------
           // Disable Assignment operator
           private:
           /**
           * Disabled Assignment operator.
           */
     103   StreamLogObserver &operator= (   const StreamLogObserver &source  );
          
          }; // End of StreamLogObserver
          
          } // End of Ember namespace
          
          #endif

./framework/Tokeniser.cpp

       1  /*
           Copyright (  C ) 2002 Simon Goodall,   Martin Pollard (  Xmp )
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Rewritten for Ember by Martin Pollard (  Xmp )
          
          // Originally written for Sear by Simon Goodall,   University of Southampton
          // Original Copyright (  C ) 2001 - 2002
          
          #include "Tokeniser.h"
          
          namespace Ember
          {
          
          
      30  Tokeniser::Tokeniser(   )
          : mDelimeters(  " " )
          {
          }
          
      35  Tokeniser::Tokeniser(  const std::string &tokens )
          : mDelimeters(  " " )
          {
           initTokens(  tokens );
          }
          
      41  Tokeniser::Tokeniser(  const std::string &tokens,   const std::string &delimiters )
          : mDelimeters(  delimiters )
          {
           initTokens(  tokens );
          }
          
          
      48  void Tokeniser::initTokens(  const std::string &tokens ) {
           mTokenString = tokens;
          // try {
           mLastPos = mTokenString.find_first_not_of(  mDelimeters,   0 );
           mPos = mTokenString.find_first_of(  mDelimeters,   mLastPos );
          // } catch (  ... ) {
          //
          // }
          
          }
          
      59  std::string Tokeniser::nextToken(   ) {
           if (  mLastPos == std::string::npos ) return "";
          // try {
           std::string token = mTokenString.substr(  mLastPos,   mPos - mLastPos );
           mLastPos = mTokenString.find_first_not_of(  mDelimeters,   mPos );
           mPos = mTokenString.find_first_of(  mDelimeters,   mLastPos );
           return token;
          // } catch (  ... ) {
          // return "";
          // }
          }
          
      71  std::string Tokeniser::remainingTokens(   ) {
           if (  mLastPos == std::string::npos ) return "";
          //try {
           return mTokenString.substr(  mLastPos,   mTokenString.size(   ) - mLastPos );
          // } catch (  ... ) {
          // return "";
          // }
          }
          
          }// end of namespace Ember

./framework/Tokeniser.h

       1  /*
           Copyright (  C ) 2002 Simon Goodall,   Martin Pollard (  Xmp )
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
           */
          
          // Rewritten for Ember by Martin Pollard (  Xmp )
          
          // Originally written for Sear by Simon Goodall,   University of Southampton
          // Original Copyright (  C ) 2001 - 2002
          
          #ifndef TOKENISER_H
          #define TOKENISER_H
          
          #include <string>
          
          namespace Ember {
          
          /**
           * @author Martin Pollard (  Xmp ) aka Xmp
           * @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
           */
          
      36  class Tokeniser
          {
           protected:
      39   std::string::size_type mPos,   mLastPos;
      40   std::string mTokenString;
      41   const std::string mDelimeters;
          // static const std::string mQuotes;
          // bool quoted;
          
           public:
          
          
           /**
           * Creates a new Tokeniser using default values.
           */
      51   Tokeniser(   );
      52   Tokeniser(  const std::string &tokens );
      53   Tokeniser(  const std::string &tokens,   const std::string &delimiters );
          
      55   virtual ~Tokeniser (   )
           {
           }
          
          
      60   void initTokens(  const std::string &tokens );
      61   std::string nextToken(   );
      62   std::string remainingTokens(   );
          }; // End of Tokeniser
          
          } // End of Ember namespace
          
          #endif

./framework/bindings/lua/atlas/lua_Atlas.cpp

       1  /*
          ** Lua binding: Atlas
          ** Generated automatically by tolua++-1.0.92 on Sat Oct 20 23:43:39 2007.
          */
          
          #ifndef __cplusplus
          #include "stdlib.h"
          #endif
          #include "string.h"
          
          #include "tolua++.h"
          
          /* Exported function */
      14  TOLUA_API int tolua_Atlas_open (  lua_State* tolua_S );
          
          #include "required.h"
          
          /* function to release collected object via destructor */
          #ifdef __cplusplus
          
      21  static int tolua_collect_Atlas__Message__MapType (  lua_State* tolua_S )
          {
           Atlas::Message::MapType* self = (  Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      28  static int tolua_collect_Atlas__Message__Element (  lua_State* tolua_S )
          {
           Atlas::Message::Element* self = (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      35  static int tolua_collect_Atlas__Message__MapType__iterator (  lua_State* tolua_S )
          {
           Atlas::Message::MapType::iterator* self = (  Atlas::Message::MapType::iterator* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          #endif
          
          
          /* function to register type */
      45  static void tolua_reg_types (  lua_State* tolua_S )
          {
           tolua_usertype(  tolua_S,  "Atlas::Message::MapType::value_type" );
           tolua_usertype(  tolua_S,  "Atlas::Message::MapType" );
           tolua_usertype(  tolua_S,  "std::vector<Atlas::Message::Element>" );
           tolua_usertype(  tolua_S,  "Atlas::Message::Element" );
           tolua_usertype(  tolua_S,  "Atlas::Message::MapType::iterator" );
          }
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new00
      56  static int tolua_Atlas_Atlas_Message_Element_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new00_local
      84  static int tolua_Atlas_Atlas_Message_Element_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_delete00
     112  static int tolua_Atlas_Atlas_Message_Element_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Atlas::Message::Element* self = (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new01
     141  static int tolua_Atlas_Atlas_Message_Element_new01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::Element* obj = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  *obj );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new01_local
     166  static int tolua_Atlas_Atlas_Message_Element_new01_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::Element* obj = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  *obj );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new00_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new02
     191  static int tolua_Atlas_Atlas_Message_Element_new02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           int v = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new02_local
     216  static int tolua_Atlas_Atlas_Message_Element_new02_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           int v = (  (  int ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new01_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new03
     241  static int tolua_Atlas_Atlas_Message_Element_new03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           bool v = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new03_local
     266  static int tolua_Atlas_Atlas_Message_Element_new03_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           bool v = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new02_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new04
     291  static int tolua_Atlas_Atlas_Message_Element_new04(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           long v = (  (  long ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new03(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new04_local
     316  static int tolua_Atlas_Atlas_Message_Element_new04_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           long v = (  (  long ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new03_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new05
     341  static int tolua_Atlas_Atlas_Message_Element_new05(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float v = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new04(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new05_local
     366  static int tolua_Atlas_Atlas_Message_Element_new05_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           float v = (  (  float ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new04_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new06
     391  static int tolua_Atlas_Atlas_Message_Element_new06(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           double v = (  (  double ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new05(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new06_local
     416  static int tolua_Atlas_Atlas_Message_Element_new06_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           double v = (  (  double ) tolua_tonumber(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new05_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new07
     441  static int tolua_Atlas_Atlas_Message_Element_new07(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isuserdata(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           void* v = (  (  void* ) tolua_touserdata(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new06(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new07_local
     466  static int tolua_Atlas_Atlas_Message_Element_new07_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isuserdata(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           void* v = (  (  void* ) tolua_touserdata(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new06_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new08
     491  static int tolua_Atlas_Atlas_Message_Element_new08(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const char* v = (  (  const char* ) tolua_tostring(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new07(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new08_local
     516  static int tolua_Atlas_Atlas_Message_Element_new08_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const char* v = (  (  const char* ) tolua_tostring(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new07_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new09
     541  static int tolua_Atlas_Atlas_Message_Element_new09(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const std::string v = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           tolua_pushcppstring(  tolua_S,  (  const char* )v );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new08(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new09_local
     567  static int tolua_Atlas_Atlas_Message_Element_new09_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const std::string v = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           tolua_pushcppstring(  tolua_S,  (  const char* )v );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new08_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new10
     593  static int tolua_Atlas_Atlas_Message_Element_new10(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::MapType* v = (  (  const Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  *v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new09(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new10_local
     618  static int tolua_Atlas_Atlas_Message_Element_new10_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::MapType* v = (  (  const Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  *v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new09_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new11
     643  static int tolua_Atlas_Atlas_Message_Element_new11(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const std::vector<Atlas::Message::Element>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const std::vector<Atlas::Message::Element>* v = (  (  const std::vector<Atlas::Message::Element>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  *v );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new10(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_new11_local
     668  static int tolua_Atlas_Atlas_Message_Element_new11_local(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const std::vector<Atlas::Message::Element>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const std::vector<Atlas::Message::Element>* v = (  (  const std::vector<Atlas::Message::Element>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           {
           Atlas::Message::Element* tolua_ret = (  Atlas::Message::Element* ) new Atlas::Message::Element(  *v );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::Element" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_new10_local(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element__eq00
     693  static int tolua_Atlas_Atlas_Message_Element__eq00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Atlas::Message::Element* o = (  (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  *o );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.eq'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element__eq01
     727  static int tolua_Atlas_Atlas_Message_Element__eq01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           long v = (  (  long ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  v );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element__eq00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element__eq02
     756  static int tolua_Atlas_Atlas_Message_Element__eq02(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           double v = (  (  double ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  v );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element__eq01(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element__eq03
     785  static int tolua_Atlas_Atlas_Message_Element__eq03(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isuserdata(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           void* v = (  (  void* ) tolua_touserdata(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  v );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element__eq02(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element__eq04
     814  static int tolua_Atlas_Atlas_Message_Element__eq04(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           const char* v = (  (  const char* ) tolua_tostring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  v );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element__eq03(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element__eq05
     843  static int tolua_Atlas_Atlas_Message_Element__eq05(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string v = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  v );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )v );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element__eq04(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element__eq06
     873  static int tolua_Atlas_Atlas_Message_Element__eq06(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Atlas::Message::MapType* v = (  (  const Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  *v );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element__eq05(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element__eq07
     902  static int tolua_Atlas_Atlas_Message_Element__eq07(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const std::vector<Atlas::Message::Element>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::vector<Atlas::Message::Element>* v = (  (  const std::vector<Atlas::Message::Element>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  *v );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element__eq06(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getType of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_getType00
     931  static int tolua_Atlas_Atlas_Message_Element_getType00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getType'",  NULL );
          #endif
           {
           Atlas::Message::Element::Type tolua_ret = (  Atlas::Message::Element::Type ) self->getType(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getType'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isNone of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_isNone00
     963  static int tolua_Atlas_Atlas_Message_Element_isNone00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isNone'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isNone(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isNone'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isInt of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_isInt00
     995  static int tolua_Atlas_Atlas_Message_Element_isInt00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isInt'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isInt(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isInt'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isFloat of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_isFloat00
    1027  static int tolua_Atlas_Atlas_Message_Element_isFloat00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isFloat'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isFloat(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isFloat'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isPtr of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_isPtr00
    1059  static int tolua_Atlas_Atlas_Message_Element_isPtr00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isPtr'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isPtr(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isPtr'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isNum of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_isNum00
    1091  static int tolua_Atlas_Atlas_Message_Element_isNum00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isNum'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isNum(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isNum'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isString of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_isString00
    1123  static int tolua_Atlas_Atlas_Message_Element_isString00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isString'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isString(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isString'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isMap of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_isMap00
    1155  static int tolua_Atlas_Atlas_Message_Element_isMap00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isMap'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isMap(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isMap'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isList of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_isList00
    1187  static int tolua_Atlas_Atlas_Message_Element_isList00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isList'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isList(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isList'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: asInt of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_asInt00
    1219  static int tolua_Atlas_Atlas_Message_Element_asInt00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'asInt'",  NULL );
          #endif
           {
           long tolua_ret = (  long ) self->asInt(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'asInt'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Int of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_Int00
    1251  static int tolua_Atlas_Atlas_Message_Element_Int00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'Int'",  NULL );
          #endif
           {
           long tolua_ret = (  long ) self->Int(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Int'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: asFloat of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_asFloat00
    1283  static int tolua_Atlas_Atlas_Message_Element_asFloat00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'asFloat'",  NULL );
          #endif
           {
           double tolua_ret = (  double ) self->asFloat(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'asFloat'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Float of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_Float00
    1315  static int tolua_Atlas_Atlas_Message_Element_Float00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'Float'",  NULL );
          #endif
           {
           double tolua_ret = (  double ) self->Float(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Float'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: asNum of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_asNum00
    1347  static int tolua_Atlas_Atlas_Message_Element_asNum00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'asNum'",  NULL );
          #endif
           {
           double tolua_ret = (  double ) self->asNum(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'asNum'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: asString of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_asString00
    1379  static int tolua_Atlas_Atlas_Message_Element_asString00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'asString'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->asString(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'asString'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: asString of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_asString01
    1411  static int tolua_Atlas_Atlas_Message_Element_asString01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Atlas::Message::Element* self = (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'asString'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->asString(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_asString00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: String of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_String00
    1438  static int tolua_Atlas_Atlas_Message_Element_String00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'String'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->String(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'String'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: String of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_String01
    1470  static int tolua_Atlas_Atlas_Message_Element_String01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Atlas::Message::Element* self = (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'String'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->String(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_String00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: asMap of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_asMap00
    1497  static int tolua_Atlas_Atlas_Message_Element_asMap00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'asMap'",  NULL );
          #endif
           {
           const Atlas::Message::MapType& tolua_ret = (  const Atlas::Message::MapType& ) self->asMap(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Atlas::Message::MapType" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'asMap'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: asMap of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_asMap01
    1529  static int tolua_Atlas_Atlas_Message_Element_asMap01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Atlas::Message::Element* self = (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'asMap'",  NULL );
          #endif
           {
           Atlas::Message::MapType& tolua_ret = (  Atlas::Message::MapType& ) self->asMap(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Atlas::Message::MapType" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_asMap00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Map of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_Map00
    1556  static int tolua_Atlas_Atlas_Message_Element_Map00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'Map'",  NULL );
          #endif
           {
           const Atlas::Message::MapType& tolua_ret = (  const Atlas::Message::MapType& ) self->Map(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Atlas::Message::MapType" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'Map'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: Map of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_Map01
    1588  static int tolua_Atlas_Atlas_Message_Element_Map01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Atlas::Message::Element* self = (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'Map'",  NULL );
          #endif
           {
           Atlas::Message::MapType& tolua_ret = (  Atlas::Message::MapType& ) self->Map(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Atlas::Message::MapType" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_Map00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: asList of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_asList00
    1615  static int tolua_Atlas_Atlas_Message_Element_asList00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'asList'",  NULL );
          #endif
           {
           const std::vector<Atlas::Message::Element>& tolua_ret = (  const std::vector<Atlas::Message::Element>& ) self->asList(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const std::vector<Atlas::Message::Element>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'asList'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: asList of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_asList01
    1647  static int tolua_Atlas_Atlas_Message_Element_asList01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Atlas::Message::Element* self = (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'asList'",  NULL );
          #endif
           {
           std::vector<Atlas::Message::Element>& tolua_ret = (  std::vector<Atlas::Message::Element>& ) self->asList(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "std::vector<Atlas::Message::Element>" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_asList00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: List of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_List00
    1674  static int tolua_Atlas_Atlas_Message_Element_List00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::Element* self = (  const Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'List'",  NULL );
          #endif
           {
           const std::vector<Atlas::Message::Element>& tolua_ret = (  const std::vector<Atlas::Message::Element>& ) self->List(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const std::vector<Atlas::Message::Element>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'List'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: List of class Atlas::Message::Element */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_Element_List01
    1706  static int tolua_Atlas_Atlas_Message_Element_List01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::Element",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Atlas::Message::Element* self = (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'List'",  NULL );
          #endif
           {
           std::vector<Atlas::Message::Element>& tolua_ret = (  std::vector<Atlas::Message::Element>& ) self->List(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "std::vector<Atlas::Message::Element>" );
           }
           }
           return 1;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_Element_List00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: first of class value_type */
          #ifndef TOLUA_DISABLE_tolua_get_Atlas__Message__MapType__value_type_first
    1733  static int tolua_get_Atlas__Message__MapType__value_type_first(  lua_State* tolua_S )
          {
           Atlas::Message::MapType::value_type* self = (  Atlas::Message::MapType::value_type* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'first'",  NULL );
          #endif
           tolua_pushcppstring(  tolua_S,  (  const char* )self->first );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: second of class value_type */
          #ifndef TOLUA_DISABLE_tolua_get_Atlas__Message__MapType__value_type_second_ref
    1746  static int tolua_get_Atlas__Message__MapType__value_type_second_ref(  lua_State* tolua_S )
          {
           Atlas::Message::MapType::value_type* self = (  Atlas::Message::MapType::value_type* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'second'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->second,  "Atlas::Message::Element" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: second of class value_type */
          #ifndef TOLUA_DISABLE_tolua_set_Atlas__Message__MapType__value_type_second_ref
    1759  static int tolua_set_Atlas__Message__MapType__value_type_second_ref(  lua_State* tolua_S )
          {
           Atlas::Message::MapType::value_type* self = (  Atlas::Message::MapType::value_type* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'second'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "Atlas::Message::Element",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->second = (  (  Atlas::Message::Element* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator* of class iterator */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_iterator__mul00
    1776  static int tolua_Atlas_Atlas_Message_MapType_iterator__mul00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::MapType::iterator",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Atlas::Message::MapType::iterator* self = (  Atlas::Message::MapType::iterator* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator*'",  NULL );
          #endif
           {
           Atlas::Message::MapType::value_type& tolua_ret = (  Atlas::Message::MapType::value_type& ) self->operator*(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Atlas::Message::MapType::value_type" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.mul'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: operator== of class iterator */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_iterator__eq00
    1808  static int tolua_Atlas_Atlas_Message_MapType_iterator__eq00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::MapType::iterator",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const Atlas::Message::MapType::iterator",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Atlas::Message::MapType::iterator* self = (  Atlas::Message::MapType::iterator* ) tolua_tousertype(  tolua_S,  1,  0 );
           const Atlas::Message::MapType::iterator* value = (  (  const Atlas::Message::MapType::iterator* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'operator=='",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->operator==(  *value );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function '.eq'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: clear of class Atlas::Message::MapType */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_clear00
    1842  static int tolua_Atlas_Atlas_Message_MapType_clear00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Atlas::Message::MapType* self = (  Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'clear'",  NULL );
          #endif
           {
           self->clear(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'clear'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: size of class Atlas::Message::MapType */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_size00
    1873  static int tolua_Atlas_Atlas_Message_MapType_size00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::MapType* self = (  const Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'size'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->size(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'size'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: find of class Atlas::Message::MapType */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_find00
    1905  static int tolua_Atlas_Atlas_Message_MapType_find00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Atlas::Message::MapType* self = (  Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string index = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'find'",  NULL );
          #endif
           {
           Atlas::Message::MapType::iterator tolua_ret = (  Atlas::Message::MapType::iterator ) self->find(  index );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Atlas::Message::MapType::iterator(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::MapType::iterator" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Atlas::Message::MapType::iterator ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::MapType::iterator" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )index );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'find'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: end of class Atlas::Message::MapType */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_theEnd00
    1948  static int tolua_Atlas_Atlas_Message_MapType_theEnd00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Atlas::Message::MapType* self = (  Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'end'",  NULL );
          #endif
           {
           Atlas::Message::MapType::iterator tolua_ret = (  Atlas::Message::MapType::iterator ) self->end(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new Atlas::Message::MapType::iterator(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::MapType::iterator" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  Atlas::Message::MapType::iterator ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "Atlas::Message::MapType::iterator" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'theEnd'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: findInMap of class Atlas::Message::MapType */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_get00
    1988  static int tolua_Atlas_Atlas_Message_MapType_get00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Atlas::Message::MapType* self = (  const Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string index = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'findInMap'",  NULL );
          #endif
           {
           const Atlas::Message::Element& tolua_ret = (  const Atlas::Message::Element& ) _MapType_findInMap(  self,  index );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Atlas::Message::Element" );
           tolua_pushcppstring(  tolua_S,  (  const char* )index );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'get'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: __operator_index of class Atlas::Message::MapType */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_get01
    2023  static int tolua_Atlas_Atlas_Message_MapType_get01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Atlas::Message::MapType* self = (  Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string index = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function '__operator_index'",  NULL );
          #endif
           {
           Atlas::Message::Element& tolua_ret = (  Atlas::Message::Element& ) self->__operator_index(  index );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Atlas::Message::Element" );
           tolua_pushcppstring(  tolua_S,  (  const char* )index );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Atlas_Atlas_Message_MapType_get00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Atlas::Message::MapType */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_new00
    2053  static int tolua_Atlas_Atlas_Message_MapType_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Atlas::Message::MapType* tolua_ret = (  Atlas::Message::MapType* ) new Atlas::Message::MapType(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Atlas::Message::MapType" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Atlas::Message::MapType */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_new00_local
    2081  static int tolua_Atlas_Atlas_Message_MapType_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Atlas::Message::MapType* tolua_ret = (  Atlas::Message::MapType* ) new Atlas::Message::MapType(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Atlas::Message::MapType" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class Atlas::Message::MapType */
          #ifndef TOLUA_DISABLE_tolua_Atlas_Atlas_Message_MapType_delete00
    2109  static int tolua_Atlas_Atlas_Message_MapType_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Atlas::Message::MapType* self = (  Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* Open function */
    2137  TOLUA_API int tolua_Atlas_open (  lua_State* tolua_S )
          {
           tolua_open(  tolua_S );
           tolua_reg_types(  tolua_S );
           tolua_module(  tolua_S,  NULL,  0 );
           tolua_beginmodule(  tolua_S,  NULL );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           tolua_module(  tolua_S,  "Message",  0 );
           tolua_beginmodule(  tolua_S,  "Message" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Element",  "Atlas::Message::Element",  "",  tolua_collect_Atlas__Message__Element );
           #else
           tolua_cclass(  tolua_S,  "Element",  "Atlas::Message::Element",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Element" );
           tolua_constant(  tolua_S,  "TYPE_NONE",  Atlas::Message::Element::TYPE_NONE );
           tolua_constant(  tolua_S,  "TYPE_INT",  Atlas::Message::Element::TYPE_INT );
           tolua_constant(  tolua_S,  "TYPE_FLOAT",  Atlas::Message::Element::TYPE_FLOAT );
           tolua_constant(  tolua_S,  "TYPE_PTR",  Atlas::Message::Element::TYPE_PTR );
           tolua_constant(  tolua_S,  "TYPE_STRING",  Atlas::Message::Element::TYPE_STRING );
           tolua_constant(  tolua_S,  "TYPE_MAP",  Atlas::Message::Element::TYPE_MAP );
           tolua_constant(  tolua_S,  "TYPE_LIST",  Atlas::Message::Element::TYPE_LIST );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_Atlas_Atlas_Message_Element_delete00 );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new01 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new01_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new01_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new02 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new02_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new02_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new03 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new03_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new03_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new04 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new04_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new04_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new05 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new05_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new05_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new06 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new06_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new06_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new07 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new07_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new07_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new08 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new08_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new08_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new09 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new09_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new09_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new10 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new10_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new10_local );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_Element_new11 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_Element_new11_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_Element_new11_local );
           tolua_function(  tolua_S,  ".eq",  tolua_Atlas_Atlas_Message_Element__eq00 );
           tolua_function(  tolua_S,  ".eq",  tolua_Atlas_Atlas_Message_Element__eq01 );
           tolua_function(  tolua_S,  ".eq",  tolua_Atlas_Atlas_Message_Element__eq02 );
           tolua_function(  tolua_S,  ".eq",  tolua_Atlas_Atlas_Message_Element__eq03 );
           tolua_function(  tolua_S,  ".eq",  tolua_Atlas_Atlas_Message_Element__eq04 );
           tolua_function(  tolua_S,  ".eq",  tolua_Atlas_Atlas_Message_Element__eq05 );
           tolua_function(  tolua_S,  ".eq",  tolua_Atlas_Atlas_Message_Element__eq06 );
           tolua_function(  tolua_S,  ".eq",  tolua_Atlas_Atlas_Message_Element__eq07 );
           tolua_function(  tolua_S,  "getType",  tolua_Atlas_Atlas_Message_Element_getType00 );
           tolua_function(  tolua_S,  "isNone",  tolua_Atlas_Atlas_Message_Element_isNone00 );
           tolua_function(  tolua_S,  "isInt",  tolua_Atlas_Atlas_Message_Element_isInt00 );
           tolua_function(  tolua_S,  "isFloat",  tolua_Atlas_Atlas_Message_Element_isFloat00 );
           tolua_function(  tolua_S,  "isPtr",  tolua_Atlas_Atlas_Message_Element_isPtr00 );
           tolua_function(  tolua_S,  "isNum",  tolua_Atlas_Atlas_Message_Element_isNum00 );
           tolua_function(  tolua_S,  "isString",  tolua_Atlas_Atlas_Message_Element_isString00 );
           tolua_function(  tolua_S,  "isMap",  tolua_Atlas_Atlas_Message_Element_isMap00 );
           tolua_function(  tolua_S,  "isList",  tolua_Atlas_Atlas_Message_Element_isList00 );
           tolua_function(  tolua_S,  "asInt",  tolua_Atlas_Atlas_Message_Element_asInt00 );
           tolua_function(  tolua_S,  "Int",  tolua_Atlas_Atlas_Message_Element_Int00 );
           tolua_function(  tolua_S,  "asFloat",  tolua_Atlas_Atlas_Message_Element_asFloat00 );
           tolua_function(  tolua_S,  "Float",  tolua_Atlas_Atlas_Message_Element_Float00 );
           tolua_function(  tolua_S,  "asNum",  tolua_Atlas_Atlas_Message_Element_asNum00 );
           tolua_function(  tolua_S,  "asString",  tolua_Atlas_Atlas_Message_Element_asString00 );
           tolua_function(  tolua_S,  "asString",  tolua_Atlas_Atlas_Message_Element_asString01 );
           tolua_function(  tolua_S,  "String",  tolua_Atlas_Atlas_Message_Element_String00 );
           tolua_function(  tolua_S,  "String",  tolua_Atlas_Atlas_Message_Element_String01 );
           tolua_function(  tolua_S,  "asMap",  tolua_Atlas_Atlas_Message_Element_asMap00 );
           tolua_function(  tolua_S,  "asMap",  tolua_Atlas_Atlas_Message_Element_asMap01 );
           tolua_function(  tolua_S,  "Map",  tolua_Atlas_Atlas_Message_Element_Map00 );
           tolua_function(  tolua_S,  "Map",  tolua_Atlas_Atlas_Message_Element_Map01 );
           tolua_function(  tolua_S,  "asList",  tolua_Atlas_Atlas_Message_Element_asList00 );
           tolua_function(  tolua_S,  "asList",  tolua_Atlas_Atlas_Message_Element_asList01 );
           tolua_function(  tolua_S,  "List",  tolua_Atlas_Atlas_Message_Element_List00 );
           tolua_function(  tolua_S,  "List",  tolua_Atlas_Atlas_Message_Element_List01 );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "MapType",  "Atlas::Message::MapType",  "",  tolua_collect_Atlas__Message__MapType );
           #else
           tolua_cclass(  tolua_S,  "MapType",  "Atlas::Message::MapType",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "MapType" );
           tolua_cclass(  tolua_S,  "value_type",  "Atlas::Message::MapType::value_type",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "value_type" );
           tolua_variable(  tolua_S,  "first",  tolua_get_Atlas__Message__MapType__value_type_first,  NULL );
           tolua_variable(  tolua_S,  "second",  tolua_get_Atlas__Message__MapType__value_type_second_ref,  tolua_set_Atlas__Message__MapType__value_type_second_ref );
           tolua_endmodule(  tolua_S );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "iterator",  "Atlas::Message::MapType::iterator",  "",  tolua_collect_Atlas__Message__MapType__iterator );
           #else
           tolua_cclass(  tolua_S,  "iterator",  "Atlas::Message::MapType::iterator",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "iterator" );
           tolua_function(  tolua_S,  ".mul",  tolua_Atlas_Atlas_Message_MapType_iterator__mul00 );
           tolua_function(  tolua_S,  ".eq",  tolua_Atlas_Atlas_Message_MapType_iterator__eq00 );
           tolua_endmodule(  tolua_S );
           tolua_function(  tolua_S,  "clear",  tolua_Atlas_Atlas_Message_MapType_clear00 );
           tolua_function(  tolua_S,  "size",  tolua_Atlas_Atlas_Message_MapType_size00 );
           tolua_function(  tolua_S,  "find",  tolua_Atlas_Atlas_Message_MapType_find00 );
           tolua_function(  tolua_S,  "theEnd",  tolua_Atlas_Atlas_Message_MapType_theEnd00 );
           tolua_function(  tolua_S,  "get",  tolua_Atlas_Atlas_Message_MapType_get00 );
           tolua_function(  tolua_S,  "get",  tolua_Atlas_Atlas_Message_MapType_get01 );
           tolua_function(  tolua_S,  "new",  tolua_Atlas_Atlas_Message_MapType_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Atlas_Atlas_Message_MapType_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Atlas_Atlas_Message_MapType_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_Atlas_Atlas_Message_MapType_delete00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           return 1;
          }
          
          
          #if defined(  LUA_VERSION_NUM ) && LUA_VERSION_NUM >= 501
    2271   TOLUA_API int luaopen_Atlas (  lua_State* tolua_S ) {
           return tolua_Atlas_open(  tolua_S );
          };
          #endif
          

./framework/bindings/lua/atlas/required.h

       1  //
          // C++ Interface: required
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #define __operator_dereference operator*
          #define __operator_index operator[]
          
          #include <Atlas/Message/Element.h>
          
          /**
          Utility method for the lua bindings which looks for a entry in a const map. If no entry is found we'll return null,   which will be translated to "nil" in lua.
          */
      31  const Atlas::Message::Element& _MapType_findInMap(  const Atlas::Message::MapType* map,   const std::string& key ) {
           Atlas::Message::MapType::const_iterator I = map->find(  key );
           if (  I != map->end(   ) ) {
           return I->second;
           } else {
           ///we'll avoid compiler warnings by doing it this way
           static Atlas::Message::Element* element(  0 );
           return *element;
           }
          }

./framework/bindings/lua/eris/lua_Eris.cpp

       1  /*
          ** Lua binding: Eris
          ** Generated automatically by tolua++-1.0.92 on Fri Oct 12 00:10:33 2007.
          */
          
          #ifndef __cplusplus
          #include "stdlib.h"
          #endif
          #include "string.h"
          
          #include "tolua++.h"
          
          /* Exported function */
      14  TOLUA_API int tolua_Eris_open (  lua_State* tolua_S );
          
          #include "required.h"
          #include <Eris/Types.h>
          #include <Eris/Entity.h>
          #include <Eris/ServerInfo.h>
          #include <Eris/Metaserver.h>
          #include <Eris/Connection.h>
          #include <Eris/Account.h>
          #include <Eris/TypeInfo.h>
          
          /* function to release collected object via destructor */
          #ifdef __cplusplus
          
      28  static int tolua_collect_WFMath__Point_3_ (  lua_State* tolua_S )
          {
           WFMath::Point<3>* self = (  WFMath::Point<3>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      35  static int tolua_collect_sigc__connection (  lua_State* tolua_S )
          {
           sigc::connection* self = (  sigc::connection* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      42  static int tolua_collect_WFMath__Vector_3_ (  lua_State* tolua_S )
          {
           WFMath::Vector<3>* self = (  WFMath::Vector<3>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      49  static int tolua_collect_WFMath__Quaternion (  lua_State* tolua_S )
          {
           WFMath::Quaternion* self = (  WFMath::Quaternion* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          #endif
          
          
          /* function to register type */
      59  static void tolua_reg_types (  lua_State* tolua_S )
          {
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const Atlas::Objects::Root&>" );
           tolua_usertype(  tolua_S,  "Eris::ServerInfo" );
           tolua_usertype(  tolua_S,  "sigc::slot<void,  const Atlas::Message::Element&>" );
           tolua_usertype(  tolua_S,  "WFMath::Quaternion" );
           tolua_usertype(  tolua_S,  "WFMath::Vector<3>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const Eris::ServerInfo&>" );
           tolua_usertype(  tolua_S,  "Eris::View" );
           tolua_usertype(  tolua_S,  "Atlas::Message::MapType" );
           tolua_usertype(  tolua_S,  "sigc::connection" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Eris::Entity*>" );
           tolua_usertype(  tolua_S,  "std::set<Eris::TypeInfo*>" );
           tolua_usertype(  tolua_S,  "Eris::TypeInfo" );
           tolua_usertype(  tolua_S,  "Eris::Task" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  bool>" );
           tolua_usertype(  tolua_S,  "Eris::Connection" );
           tolua_usertype(  tolua_S,  "Eris::Entity" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  int>" );
           tolua_usertype(  tolua_S,  "std::vector<Eris::Task*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::string&>" );
           tolua_usertype(  tolua_S,  "Eris::Meta" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Eris::Task*>" );
           tolua_usertype(  tolua_S,  "WFMath::Point<3>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const Atlas::Objects::Operation::RootOperation&>" );
           tolua_usertype(  tolua_S,  "Eris::Account" );
           tolua_usertype(  tolua_S,  "sigc::signal<void>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::set<std::string>&>" );
           tolua_usertype(  tolua_S,  "Atlas::Message::Element" );
           tolua_usertype(  tolua_S,  "WFMath::AxisBox<3>" );
          }
          
          /* method: numContained of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_numContained00
      93  static int tolua_Eris_Eris_Entity_numContained00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'numContained'",  NULL );
          #endif
           {
           unsigned int tolua_ret = (  unsigned int ) self->numContained(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'numContained'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getContained of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getContained00
     125  static int tolua_Eris_Eris_Entity_getContained00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned int index = (  (  unsigned int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getContained'",  NULL );
          #endif
           {
           Eris::Entity* tolua_ret = (  Eris::Entity* ) self->getContained(  index );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Eris::Entity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getContained'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: valueOfAttr of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_valueOfAttr00
     159  static int tolua_Eris_Eris_Entity_valueOfAttr00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string attr = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'valueOfAttr'",  NULL );
          #endif
           {
           const Atlas::Message::Element& tolua_ret = (  const Atlas::Message::Element& ) self->valueOfAttr(  attr );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Atlas::Message::Element" );
           tolua_pushcppstring(  tolua_S,  (  const char* )attr );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'valueOfAttr'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasAttr of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_hasAttr00
     194  static int tolua_Eris_Eris_Entity_hasAttr00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string p = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasAttr'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasAttr(  p );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )p );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasAttr'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: observe of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_observe00
     229  static int tolua_Eris_Eris_Entity_observe00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const sigc::slot<void,  const Atlas::Message::Element&>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string attr = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const sigc::slot<void,  const Atlas::Message::Element&>* aslot = (  (  const sigc::slot<void,  const Atlas::Message::Element&>* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'observe'",  NULL );
          #endif
           {
           sigc::connection tolua_ret = (  sigc::connection ) self->observe(  attr,  *aslot );
           {
          #ifdef __cplusplus
           void* tolua_obj = new sigc::connection(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "sigc::connection" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  sigc::connection ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "sigc::connection" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )attr );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'observe'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getId of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getId00
     274  static int tolua_Eris_Eris_Entity_getId00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getId'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getId(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getId'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getName00
     306  static int tolua_Eris_Eris_Entity_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getStamp of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getStamp00
     338  static int tolua_Eris_Eris_Entity_getStamp00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getStamp'",  NULL );
          #endif
           {
           float tolua_ret = (  float ) self->getStamp(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getStamp'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getType of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getType00
     370  static int tolua_Eris_Eris_Entity_getType00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getType'",  NULL );
          #endif
           {
           Eris::TypeInfo* tolua_ret = (  Eris::TypeInfo* ) self->getType(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Eris::TypeInfo" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getType'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getLocation of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getLocation00
     402  static int tolua_Eris_Eris_Entity_getLocation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getLocation'",  NULL );
          #endif
           {
           Eris::Entity* tolua_ret = (  Eris::Entity* ) self->getLocation(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Eris::Entity" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getLocation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPosition of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getPosition00
     434  static int tolua_Eris_Eris_Entity_getPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPosition'",  NULL );
          #endif
           {
           WFMath::Point<3> tolua_ret = (  WFMath::Point<3> ) self->getPosition(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new WFMath::Point<3>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Point<3>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  WFMath::Point<3> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Point<3>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAttributes of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getAttributes00
     474  static int tolua_Eris_Eris_Entity_getAttributes00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAttributes'",  NULL );
          #endif
           {
           const Atlas::Message::MapType& tolua_ret = (  const Atlas::Message::MapType& ) self->getAttributes(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Atlas::Message::MapType" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAttributes'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isMoving of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_isMoving00
     506  static int tolua_Eris_Eris_Entity_isMoving00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isMoving'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isMoving(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isMoving'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPredictedPos of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getPredictedPos00
     538  static int tolua_Eris_Eris_Entity_getPredictedPos00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPredictedPos'",  NULL );
          #endif
           {
           WFMath::Point<3> tolua_ret = (  WFMath::Point<3> ) self->getPredictedPos(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new WFMath::Point<3>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Point<3>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  WFMath::Point<3> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Point<3>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPredictedPos'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPredictedVelocity of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getPredictedVelocity00
     578  static int tolua_Eris_Eris_Entity_getPredictedVelocity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPredictedVelocity'",  NULL );
          #endif
           {
           WFMath::Vector<3> tolua_ret = (  WFMath::Vector<3> ) self->getPredictedVelocity(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new WFMath::Vector<3>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Vector<3>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  WFMath::Vector<3> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Vector<3>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPredictedVelocity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getViewPosition of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getViewPosition00
     618  static int tolua_Eris_Eris_Entity_getViewPosition00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getViewPosition'",  NULL );
          #endif
           {
           WFMath::Point<3> tolua_ret = (  WFMath::Point<3> ) self->getViewPosition(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new WFMath::Point<3>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Point<3>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  WFMath::Point<3> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Point<3>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getViewPosition'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getViewOrientation of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getViewOrientation00
     658  static int tolua_Eris_Eris_Entity_getViewOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getViewOrientation'",  NULL );
          #endif
           {
           WFMath::Quaternion tolua_ret = (  WFMath::Quaternion ) self->getViewOrientation(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new WFMath::Quaternion(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Quaternion" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  WFMath::Quaternion ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "WFMath::Quaternion" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getViewOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getVelocity of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getVelocity00
     698  static int tolua_Eris_Eris_Entity_getVelocity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getVelocity'",  NULL );
          #endif
           {
           const WFMath::Vector<3>& tolua_ret = (  const WFMath::Vector<3>& ) self->getVelocity(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const WFMath::Vector<3>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getVelocity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getOrientation of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getOrientation00
     730  static int tolua_Eris_Eris_Entity_getOrientation00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getOrientation'",  NULL );
          #endif
           {
           const WFMath::Quaternion& tolua_ret = (  const WFMath::Quaternion& ) self->getOrientation(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const WFMath::Quaternion" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getOrientation'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBBox of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getBBox00
     762  static int tolua_Eris_Eris_Entity_getBBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBBox'",  NULL );
          #endif
           {
           const WFMath::AxisBox<3>& tolua_ret = (  const WFMath::AxisBox<3>& ) self->getBBox(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const WFMath::AxisBox<3>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasBBox of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_hasBBox00
     794  static int tolua_Eris_Eris_Entity_hasBBox00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasBBox'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasBBox(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasBBox'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasChild of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_hasChild00
     826  static int tolua_Eris_Eris_Entity_hasChild00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string eid = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasChild'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasChild(  eid );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )eid );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasChild'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isVisible of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_isVisible00
     861  static int tolua_Eris_Eris_Entity_isVisible00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isVisible'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isVisible(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isVisible'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ChildAdded of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_ChildAdded
     893  static int tolua_get_Eris__Entity_ChildAdded(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'ChildAdded'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->ChildAdded,  "sigc::signal<void,  Eris::Entity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: ChildAdded of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_ChildAdded
     906  static int tolua_set_Eris__Entity_ChildAdded(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'ChildAdded'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Entity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->ChildAdded = *(  (  sigc::signal<void,  Eris::Entity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ChildRemoved of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_ChildRemoved
     923  static int tolua_get_Eris__Entity_ChildRemoved(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'ChildRemoved'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->ChildRemoved,  "sigc::signal<void,  Eris::Entity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: ChildRemoved of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_ChildRemoved
     936  static int tolua_set_Eris__Entity_ChildRemoved(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'ChildRemoved'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Entity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->ChildRemoved = *(  (  sigc::signal<void,  Eris::Entity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: LocationChanged of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_LocationChanged
     953  static int tolua_get_Eris__Entity_LocationChanged(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'LocationChanged'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->LocationChanged,  "sigc::signal<void,  Eris::Entity*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: LocationChanged of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_LocationChanged
     966  static int tolua_set_Eris__Entity_LocationChanged(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'LocationChanged'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Entity*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->LocationChanged = *(  (  sigc::signal<void,  Eris::Entity*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Changed of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_Changed
     983  static int tolua_get_Eris__Entity_Changed(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Changed'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Changed,  "sigc::signal<void,  const std::set<std::string>&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Changed of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_Changed
     996  static int tolua_set_Eris__Entity_Changed(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Changed'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::set<std::string>&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Changed = *(  (  sigc::signal<void,  const std::set<std::string>&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Moved of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_Moved
    1013  static int tolua_get_Eris__Entity_Moved(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Moved'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Moved,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Moved of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_Moved
    1026  static int tolua_set_Eris__Entity_Moved(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Moved'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Moved = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Moving of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_Moving
    1043  static int tolua_get_Eris__Entity_Moving(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Moving'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Moving,  "sigc::signal<void,  bool>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Moving of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_Moving
    1056  static int tolua_set_Eris__Entity_Moving(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Moving'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  bool>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Moving = *(  (  sigc::signal<void,  bool>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Say of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_Say
    1073  static int tolua_get_Eris__Entity_Say(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Say'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Say,  "sigc::signal<void,  const Atlas::Objects::Root&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Say of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_Say
    1086  static int tolua_set_Eris__Entity_Say(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Say'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Atlas::Objects::Root&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Say = *(  (  sigc::signal<void,  const Atlas::Objects::Root&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Emote of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_Emote
    1103  static int tolua_get_Eris__Entity_Emote(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Emote'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Emote,  "sigc::signal<void,  const std::string&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Emote of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_Emote
    1116  static int tolua_set_Eris__Entity_Emote(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Emote'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Emote = *(  (  sigc::signal<void,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Acted of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_Acted
    1133  static int tolua_get_Eris__Entity_Acted(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Acted'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Acted,  "sigc::signal<void,  const Atlas::Objects::Operation::RootOperation&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Acted of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_Acted
    1146  static int tolua_set_Eris__Entity_Acted(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Acted'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Atlas::Objects::Operation::RootOperation&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Acted = *(  (  sigc::signal<void,  const Atlas::Objects::Operation::RootOperation&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Noise of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_Noise
    1163  static int tolua_get_Eris__Entity_Noise(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Noise'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Noise,  "sigc::signal<void,  const Atlas::Objects::Root&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Noise of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_Noise
    1176  static int tolua_set_Eris__Entity_Noise(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Noise'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Atlas::Objects::Root&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Noise = *(  (  sigc::signal<void,  const Atlas::Objects::Root&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: VisibilityChanged of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_VisibilityChanged
    1193  static int tolua_get_Eris__Entity_VisibilityChanged(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'VisibilityChanged'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->VisibilityChanged,  "sigc::signal<void,  bool>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: VisibilityChanged of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_VisibilityChanged
    1206  static int tolua_set_Eris__Entity_VisibilityChanged(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'VisibilityChanged'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  bool>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->VisibilityChanged = *(  (  sigc::signal<void,  bool>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: BeingDeleted of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_BeingDeleted
    1223  static int tolua_get_Eris__Entity_BeingDeleted(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'BeingDeleted'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->BeingDeleted,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: BeingDeleted of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_BeingDeleted
    1236  static int tolua_set_Eris__Entity_BeingDeleted(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'BeingDeleted'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->BeingDeleted = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: TaskAdded of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_TaskAdded
    1253  static int tolua_get_Eris__Entity_TaskAdded(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'TaskAdded'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->TaskAdded,  "sigc::signal<void,  Eris::Task*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: TaskAdded of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_TaskAdded
    1266  static int tolua_set_Eris__Entity_TaskAdded(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'TaskAdded'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Task*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->TaskAdded = *(  (  sigc::signal<void,  Eris::Task*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: TaskRemoved of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Entity_TaskRemoved
    1283  static int tolua_get_Eris__Entity_TaskRemoved(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'TaskRemoved'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->TaskRemoved,  "sigc::signal<void,  Eris::Task*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: TaskRemoved of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Entity_TaskRemoved
    1296  static int tolua_set_Eris__Entity_TaskRemoved(  lua_State* tolua_S )
          {
           Eris::Entity* self = (  Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'TaskRemoved'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Task*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->TaskRemoved = *(  (  sigc::signal<void,  Eris::Task*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getTasks of class Eris::Entity */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Entity_getTasks00
    1313  static int tolua_Eris_Eris_Entity_getTasks00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Entity* self = (  const Eris::Entity* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getTasks'",  NULL );
          #endif
           {
           const std::vector<Eris::Task*>& tolua_ret = (  const std::vector<Eris::Task*>& ) self->getTasks(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const std::vector<Eris::Task*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getTasks'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getStatus of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getStatus00
    1345  static int tolua_Eris_Eris_ServerInfo_getStatus00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getStatus'",  NULL );
          #endif
           {
           Eris::ServerInfo::Status tolua_ret = (  Eris::ServerInfo::Status ) self->getStatus(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getStatus'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getHostname of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getHostname00
    1377  static int tolua_Eris_Eris_ServerInfo_getHostname00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getHostname'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getHostname(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getHostname'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getServername of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getServername00
    1409  static int tolua_Eris_Eris_ServerInfo_getServername00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getServername'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getServername(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getServername'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getRuleset of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getRuleset00
    1441  static int tolua_Eris_Eris_ServerInfo_getRuleset00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getRuleset'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getRuleset(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getRuleset'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getServer of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getServer00
    1473  static int tolua_Eris_Eris_ServerInfo_getServer00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getServer'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getServer(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getServer'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getVersion of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getVersion00
    1505  static int tolua_Eris_Eris_ServerInfo_getVersion00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getVersion'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getVersion(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getVersion'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getBuildDate of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getBuildDate00
    1537  static int tolua_Eris_Eris_ServerInfo_getBuildDate00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getBuildDate'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getBuildDate(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getBuildDate'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getNumClients of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getNumClients00
    1569  static int tolua_Eris_Eris_ServerInfo_getNumClients00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getNumClients'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->getNumClients(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getNumClients'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getPing of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getPing00
    1601  static int tolua_Eris_Eris_ServerInfo_getPing00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getPing'",  NULL );
          #endif
           {
           int tolua_ret = (  int ) self->getPing(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getPing'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getUptime of class Eris::ServerInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_ServerInfo_getUptime00
    1633  static int tolua_Eris_Eris_ServerInfo_getUptime00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::ServerInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::ServerInfo* self = (  const Eris::ServerInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getUptime'",  NULL );
          #endif
           {
           double tolua_ret = (  double ) self->getUptime(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getUptime'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getGameServerCount of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Meta_getGameServerCount00
    1665  static int tolua_Eris_Eris_Meta_getGameServerCount00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Meta",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Meta* self = (  const Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getGameServerCount'",  NULL );
          #endif
           {
           unsigned int tolua_ret = (  unsigned int ) self->getGameServerCount(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getGameServerCount'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getInfoForServer of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Meta_getInfoForServer00
    1697  static int tolua_Eris_Eris_Meta_getInfoForServer00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Meta",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Meta* self = (  const Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned int index = (  (  unsigned int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getInfoForServer'",  NULL );
          #endif
           {
           const Eris::ServerInfo& tolua_ret = (  const Eris::ServerInfo& ) self->getInfoForServer(  index );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const Eris::ServerInfo" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInfoForServer'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: queryServerByIndex of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Meta_queryServerByIndex00
    1731  static int tolua_Eris_Eris_Meta_queryServerByIndex00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Eris::Meta",  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
           unsigned int index = (  (  unsigned int ) tolua_tonumber(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'queryServerByIndex'",  NULL );
          #endif
           {
           self->queryServerByIndex(  index );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'queryServerByIndex'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: refresh of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Meta_refresh00
    1764  static int tolua_Eris_Eris_Meta_refresh00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Eris::Meta",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'refresh'",  NULL );
          #endif
           {
           self->refresh(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'refresh'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: cancel of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Meta_cancel00
    1795  static int tolua_Eris_Eris_Meta_cancel00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Eris::Meta",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'cancel'",  NULL );
          #endif
           {
           self->cancel(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'cancel'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: ReceivedServerInfo of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Meta_ReceivedServerInfo
    1826  static int tolua_get_Eris__Meta_ReceivedServerInfo(  lua_State* tolua_S )
          {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'ReceivedServerInfo'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->ReceivedServerInfo,  "sigc::signal<void,  const Eris::ServerInfo&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: ReceivedServerInfo of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Meta_ReceivedServerInfo
    1839  static int tolua_set_Eris__Meta_ReceivedServerInfo(  lua_State* tolua_S )
          {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'ReceivedServerInfo'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Eris::ServerInfo&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->ReceivedServerInfo = *(  (  sigc::signal<void,  const Eris::ServerInfo&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: CompletedServerList of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Meta_CompletedServerList
    1856  static int tolua_get_Eris__Meta_CompletedServerList(  lua_State* tolua_S )
          {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'CompletedServerList'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->CompletedServerList,  "sigc::signal<void,  int>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: CompletedServerList of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Meta_CompletedServerList
    1869  static int tolua_set_Eris__Meta_CompletedServerList(  lua_State* tolua_S )
          {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'CompletedServerList'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  int>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->CompletedServerList = *(  (  sigc::signal<void,  int>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: AllQueriesDone of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Meta_AllQueriesDone
    1886  static int tolua_get_Eris__Meta_AllQueriesDone(  lua_State* tolua_S )
          {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AllQueriesDone'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->AllQueriesDone,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: AllQueriesDone of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Meta_AllQueriesDone
    1899  static int tolua_set_Eris__Meta_AllQueriesDone(  lua_State* tolua_S )
          {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'AllQueriesDone'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->AllQueriesDone = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Failure of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Meta_Failure
    1916  static int tolua_get_Eris__Meta_Failure(  lua_State* tolua_S )
          {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Failure'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Failure,  "sigc::signal<void,  const std::string&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Failure of class Eris::Meta */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Meta_Failure
    1929  static int tolua_set_Eris__Meta_Failure(  lua_State* tolua_S )
          {
           Eris::Meta* self = (  Eris::Meta* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Failure'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Failure = *(  (  sigc::signal<void,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: lookQueueSize of class Eris::View */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_View_lookQueueSize00
    1946  static int tolua_Eris_Eris_View_lookQueueSize00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::View",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::View* self = (  const Eris::View* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'lookQueueSize'",  NULL );
          #endif
           {
           unsigned int tolua_ret = (  unsigned int ) self->lookQueueSize(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'lookQueueSize'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isA of class Eris::TypeInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_TypeInfo_isA00
    1978  static int tolua_Eris_Eris_TypeInfo_isA00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Eris::TypeInfo",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::TypeInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::TypeInfo* self = (  Eris::TypeInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::TypeInfo* ti = (  (  Eris::TypeInfo* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isA'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isA(  ti );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isA'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isBound of class Eris::TypeInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_TypeInfo_isBound00
    2012  static int tolua_Eris_Eris_TypeInfo_isBound00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::TypeInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::TypeInfo* self = (  const Eris::TypeInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isBound'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isBound(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isBound'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: hasUnresolvedChildren of class Eris::TypeInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_TypeInfo_hasUnresolvedChildren00
    2044  static int tolua_Eris_Eris_TypeInfo_hasUnresolvedChildren00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::TypeInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::TypeInfo* self = (  const Eris::TypeInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'hasUnresolvedChildren'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->hasUnresolvedChildren(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'hasUnresolvedChildren'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: resolveChildren of class Eris::TypeInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_TypeInfo_resolveChildren00
    2076  static int tolua_Eris_Eris_TypeInfo_resolveChildren00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Eris::TypeInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Eris::TypeInfo* self = (  Eris::TypeInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'resolveChildren'",  NULL );
          #endif
           {
           self->resolveChildren(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'resolveChildren'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class Eris::TypeInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_TypeInfo_getName00
    2107  static int tolua_Eris_Eris_TypeInfo_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::TypeInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::TypeInfo* self = (  const Eris::TypeInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getChildren of class Eris::TypeInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_TypeInfo_getChildren00
    2139  static int tolua_Eris_Eris_TypeInfo_getChildren00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::TypeInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::TypeInfo* self = (  const Eris::TypeInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getChildren'",  NULL );
          #endif
           {
           const std::set<Eris::TypeInfo*>& tolua_ret = (   const std::set<Eris::TypeInfo*>& ) self->getChildren(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const std::set<Eris::TypeInfo*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getChildren'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getParents of class Eris::TypeInfo */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_TypeInfo_getParents00
    2171  static int tolua_Eris_Eris_TypeInfo_getParents00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::TypeInfo",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::TypeInfo* self = (  const Eris::TypeInfo* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getParents'",  NULL );
          #endif
           {
           const std::set<Eris::TypeInfo*>& tolua_ret = (   const std::set<Eris::TypeInfo*>& ) self->getParents(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "const std::set<Eris::TypeInfo*>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getParents'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: name of class Eris::Task */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Task_name00
    2203  static int tolua_Eris_Eris_Task_name00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Task",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Task* self = (  const Eris::Task* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'name'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->name(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'name'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: progress of class Eris::Task */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Task_progress00
    2235  static int tolua_Eris_Eris_Task_progress00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Task",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Task* self = (  const Eris::Task* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'progress'",  NULL );
          #endif
           {
           double tolua_ret = (  double ) self->progress(   );
           tolua_pushnumber(  tolua_S,  (  lua_Number )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'progress'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isComplete of class Eris::Task */
          #ifndef TOLUA_DISABLE_tolua_Eris_Eris_Task_isComplete00
    2267  static int tolua_Eris_Eris_Task_isComplete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Eris::Task",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Eris::Task* self = (  const Eris::Task* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isComplete'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isComplete(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isComplete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Completed of class Eris::Task */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Task_Completed
    2299  static int tolua_get_Eris__Task_Completed(  lua_State* tolua_S )
          {
           Eris::Task* self = (  Eris::Task* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Completed'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Completed,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Completed of class Eris::Task */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Task_Completed
    2312  static int tolua_set_Eris__Task_Completed(  lua_State* tolua_S )
          {
           Eris::Task* self = (  Eris::Task* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Completed'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Completed = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Cancelled of class Eris::Task */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Task_Cancelled
    2329  static int tolua_get_Eris__Task_Cancelled(  lua_State* tolua_S )
          {
           Eris::Task* self = (  Eris::Task* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Cancelled'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Cancelled,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Cancelled of class Eris::Task */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Task_Cancelled
    2342  static int tolua_set_Eris__Task_Cancelled(  lua_State* tolua_S )
          {
           Eris::Task* self = (  Eris::Task* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Cancelled'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Cancelled = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: Progressed of class Eris::Task */
          #ifndef TOLUA_DISABLE_tolua_get_Eris__Task_Progressed
    2359  static int tolua_get_Eris__Task_Progressed(  lua_State* tolua_S )
          {
           Eris::Task* self = (  Eris::Task* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Progressed'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->Progressed,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: Progressed of class Eris::Task */
          #ifndef TOLUA_DISABLE_tolua_set_Eris__Task_Progressed
    2372  static int tolua_set_Eris__Task_Progressed(  lua_State* tolua_S )
          {
           Eris::Task* self = (  Eris::Task* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'Progressed'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->Progressed = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* Open function */
    2388  TOLUA_API int tolua_Eris_open (  lua_State* tolua_S )
          {
           tolua_open(  tolua_S );
           tolua_reg_types(  tolua_S );
           tolua_module(  tolua_S,  NULL,  0 );
           tolua_beginmodule(  tolua_S,  NULL );
           tolua_module(  tolua_S,  "Atlas",  0 );
           tolua_beginmodule(  tolua_S,  "Atlas" );
           tolua_module(  tolua_S,  "Message",  0 );
           tolua_beginmodule(  tolua_S,  "Message" );
           tolua_cclass(  tolua_S,  "Element",  "Atlas::Message::Element",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Element" );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Eris",  0 );
           tolua_beginmodule(  tolua_S,  "Eris" );
           tolua_constant(  tolua_S,  "NO_ERR",  Eris::NO_ERR );
           tolua_constant(  tolua_S,  "NOT_CONNECTED",  Eris::NOT_CONNECTED );
           tolua_constant(  tolua_S,  "NOT_LOGGED_IN",  Eris::NOT_LOGGED_IN );
           tolua_constant(  tolua_S,  "ALREADY_LOGGED_IN",  Eris::ALREADY_LOGGED_IN );
           tolua_constant(  tolua_S,  "DUPLICATE_CHAR_ACTIVE",  Eris::DUPLICATE_CHAR_ACTIVE );
           tolua_constant(  tolua_S,  "BAD_CHARACTER_ID",  Eris::BAD_CHARACTER_ID );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Eris",  0 );
           tolua_beginmodule(  tolua_S,  "Eris" );
           tolua_cclass(  tolua_S,  "Entity",  "Eris::Entity",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Entity" );
           tolua_function(  tolua_S,  "numContained",  tolua_Eris_Eris_Entity_numContained00 );
           tolua_function(  tolua_S,  "getContained",  tolua_Eris_Eris_Entity_getContained00 );
           tolua_function(  tolua_S,  "valueOfAttr",  tolua_Eris_Eris_Entity_valueOfAttr00 );
           tolua_function(  tolua_S,  "hasAttr",  tolua_Eris_Eris_Entity_hasAttr00 );
           tolua_function(  tolua_S,  "observe",  tolua_Eris_Eris_Entity_observe00 );
           tolua_function(  tolua_S,  "getId",  tolua_Eris_Eris_Entity_getId00 );
           tolua_function(  tolua_S,  "getName",  tolua_Eris_Eris_Entity_getName00 );
           tolua_function(  tolua_S,  "getStamp",  tolua_Eris_Eris_Entity_getStamp00 );
           tolua_function(  tolua_S,  "getType",  tolua_Eris_Eris_Entity_getType00 );
           tolua_function(  tolua_S,  "getLocation",  tolua_Eris_Eris_Entity_getLocation00 );
           tolua_function(  tolua_S,  "getPosition",  tolua_Eris_Eris_Entity_getPosition00 );
           tolua_function(  tolua_S,  "getAttributes",  tolua_Eris_Eris_Entity_getAttributes00 );
           tolua_function(  tolua_S,  "isMoving",  tolua_Eris_Eris_Entity_isMoving00 );
           tolua_function(  tolua_S,  "getPredictedPos",  tolua_Eris_Eris_Entity_getPredictedPos00 );
           tolua_function(  tolua_S,  "getPredictedVelocity",  tolua_Eris_Eris_Entity_getPredictedVelocity00 );
           tolua_function(  tolua_S,  "getViewPosition",  tolua_Eris_Eris_Entity_getViewPosition00 );
           tolua_function(  tolua_S,  "getViewOrientation",  tolua_Eris_Eris_Entity_getViewOrientation00 );
           tolua_function(  tolua_S,  "getVelocity",  tolua_Eris_Eris_Entity_getVelocity00 );
           tolua_function(  tolua_S,  "getOrientation",  tolua_Eris_Eris_Entity_getOrientation00 );
           tolua_function(  tolua_S,  "getBBox",  tolua_Eris_Eris_Entity_getBBox00 );
           tolua_function(  tolua_S,  "hasBBox",  tolua_Eris_Eris_Entity_hasBBox00 );
           tolua_function(  tolua_S,  "hasChild",  tolua_Eris_Eris_Entity_hasChild00 );
           tolua_function(  tolua_S,  "isVisible",  tolua_Eris_Eris_Entity_isVisible00 );
           tolua_variable(  tolua_S,  "ChildAdded",  tolua_get_Eris__Entity_ChildAdded,  tolua_set_Eris__Entity_ChildAdded );
           tolua_variable(  tolua_S,  "ChildRemoved",  tolua_get_Eris__Entity_ChildRemoved,  tolua_set_Eris__Entity_ChildRemoved );
           tolua_variable(  tolua_S,  "LocationChanged",  tolua_get_Eris__Entity_LocationChanged,  tolua_set_Eris__Entity_LocationChanged );
           tolua_variable(  tolua_S,  "Changed",  tolua_get_Eris__Entity_Changed,  tolua_set_Eris__Entity_Changed );
           tolua_variable(  tolua_S,  "Moved",  tolua_get_Eris__Entity_Moved,  tolua_set_Eris__Entity_Moved );
           tolua_variable(  tolua_S,  "Moving",  tolua_get_Eris__Entity_Moving,  tolua_set_Eris__Entity_Moving );
           tolua_variable(  tolua_S,  "Say",  tolua_get_Eris__Entity_Say,  tolua_set_Eris__Entity_Say );
           tolua_variable(  tolua_S,  "Emote",  tolua_get_Eris__Entity_Emote,  tolua_set_Eris__Entity_Emote );
           tolua_variable(  tolua_S,  "Acted",  tolua_get_Eris__Entity_Acted,  tolua_set_Eris__Entity_Acted );
           tolua_variable(  tolua_S,  "Noise",  tolua_get_Eris__Entity_Noise,  tolua_set_Eris__Entity_Noise );
           tolua_variable(  tolua_S,  "VisibilityChanged",  tolua_get_Eris__Entity_VisibilityChanged,  tolua_set_Eris__Entity_VisibilityChanged );
           tolua_variable(  tolua_S,  "BeingDeleted",  tolua_get_Eris__Entity_BeingDeleted,  tolua_set_Eris__Entity_BeingDeleted );
           tolua_variable(  tolua_S,  "TaskAdded",  tolua_get_Eris__Entity_TaskAdded,  tolua_set_Eris__Entity_TaskAdded );
           tolua_variable(  tolua_S,  "TaskRemoved",  tolua_get_Eris__Entity_TaskRemoved,  tolua_set_Eris__Entity_TaskRemoved );
           tolua_function(  tolua_S,  "getTasks",  tolua_Eris_Eris_Entity_getTasks00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Eris",  0 );
           tolua_beginmodule(  tolua_S,  "Eris" );
           tolua_cclass(  tolua_S,  "ServerInfo",  "Eris::ServerInfo",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ServerInfo" );
           tolua_constant(  tolua_S,  "INVALID",  Eris::ServerInfo::INVALID );
           tolua_constant(  tolua_S,  "QUERYING",  Eris::ServerInfo::QUERYING );
           tolua_constant(  tolua_S,  "VALID",  Eris::ServerInfo::VALID );
           tolua_constant(  tolua_S,  "TIMEOUT",  Eris::ServerInfo::TIMEOUT );
           tolua_function(  tolua_S,  "getStatus",  tolua_Eris_Eris_ServerInfo_getStatus00 );
           tolua_function(  tolua_S,  "getHostname",  tolua_Eris_Eris_ServerInfo_getHostname00 );
           tolua_function(  tolua_S,  "getServername",  tolua_Eris_Eris_ServerInfo_getServername00 );
           tolua_function(  tolua_S,  "getRuleset",  tolua_Eris_Eris_ServerInfo_getRuleset00 );
           tolua_function(  tolua_S,  "getServer",  tolua_Eris_Eris_ServerInfo_getServer00 );
           tolua_function(  tolua_S,  "getVersion",  tolua_Eris_Eris_ServerInfo_getVersion00 );
           tolua_function(  tolua_S,  "getBuildDate",  tolua_Eris_Eris_ServerInfo_getBuildDate00 );
           tolua_function(  tolua_S,  "getNumClients",  tolua_Eris_Eris_ServerInfo_getNumClients00 );
           tolua_function(  tolua_S,  "getPing",  tolua_Eris_Eris_ServerInfo_getPing00 );
           tolua_function(  tolua_S,  "getUptime",  tolua_Eris_Eris_ServerInfo_getUptime00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Eris",  0 );
           tolua_beginmodule(  tolua_S,  "Eris" );
           tolua_cclass(  tolua_S,  "Meta",  "Eris::Meta",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Meta" );
           tolua_function(  tolua_S,  "getGameServerCount",  tolua_Eris_Eris_Meta_getGameServerCount00 );
           tolua_function(  tolua_S,  "getInfoForServer",  tolua_Eris_Eris_Meta_getInfoForServer00 );
           tolua_function(  tolua_S,  "queryServerByIndex",  tolua_Eris_Eris_Meta_queryServerByIndex00 );
           tolua_function(  tolua_S,  "refresh",  tolua_Eris_Eris_Meta_refresh00 );
           tolua_function(  tolua_S,  "cancel",  tolua_Eris_Eris_Meta_cancel00 );
           tolua_variable(  tolua_S,  "ReceivedServerInfo",  tolua_get_Eris__Meta_ReceivedServerInfo,  tolua_set_Eris__Meta_ReceivedServerInfo );
           tolua_variable(  tolua_S,  "CompletedServerList",  tolua_get_Eris__Meta_CompletedServerList,  tolua_set_Eris__Meta_CompletedServerList );
           tolua_variable(  tolua_S,  "AllQueriesDone",  tolua_get_Eris__Meta_AllQueriesDone,  tolua_set_Eris__Meta_AllQueriesDone );
           tolua_variable(  tolua_S,  "Failure",  tolua_get_Eris__Meta_Failure,  tolua_set_Eris__Meta_Failure );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Eris",  0 );
           tolua_beginmodule(  tolua_S,  "Eris" );
           tolua_cclass(  tolua_S,  "Connection",  "Eris::Connection",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Connection" );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Eris",  0 );
           tolua_beginmodule(  tolua_S,  "Eris" );
           tolua_cclass(  tolua_S,  "Account",  "Eris::Account",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Account" );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Eris",  0 );
           tolua_beginmodule(  tolua_S,  "Eris" );
           tolua_cclass(  tolua_S,  "View",  "Eris::View",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "View" );
           tolua_function(  tolua_S,  "lookQueueSize",  tolua_Eris_Eris_View_lookQueueSize00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Eris",  0 );
           tolua_beginmodule(  tolua_S,  "Eris" );
           tolua_cclass(  tolua_S,  "TypeInfo",  "Eris::TypeInfo",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "TypeInfo" );
           tolua_function(  tolua_S,  "isA",  tolua_Eris_Eris_TypeInfo_isA00 );
           tolua_function(  tolua_S,  "isBound",  tolua_Eris_Eris_TypeInfo_isBound00 );
           tolua_function(  tolua_S,  "hasUnresolvedChildren",  tolua_Eris_Eris_TypeInfo_hasUnresolvedChildren00 );
           tolua_function(  tolua_S,  "resolveChildren",  tolua_Eris_Eris_TypeInfo_resolveChildren00 );
           tolua_function(  tolua_S,  "getName",  tolua_Eris_Eris_TypeInfo_getName00 );
           tolua_function(  tolua_S,  "getChildren",  tolua_Eris_Eris_TypeInfo_getChildren00 );
           tolua_function(  tolua_S,  "getParents",  tolua_Eris_Eris_TypeInfo_getParents00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Eris",  0 );
           tolua_beginmodule(  tolua_S,  "Eris" );
           tolua_cclass(  tolua_S,  "Task",  "Eris::Task",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Task" );
           tolua_function(  tolua_S,  "name",  tolua_Eris_Eris_Task_name00 );
           tolua_function(  tolua_S,  "progress",  tolua_Eris_Eris_Task_progress00 );
           tolua_function(  tolua_S,  "isComplete",  tolua_Eris_Eris_Task_isComplete00 );
           tolua_variable(  tolua_S,  "Completed",  tolua_get_Eris__Task_Completed,  tolua_set_Eris__Task_Completed );
           tolua_variable(  tolua_S,  "Cancelled",  tolua_get_Eris__Task_Cancelled,  tolua_set_Eris__Task_Cancelled );
           tolua_variable(  tolua_S,  "Progressed",  tolua_get_Eris__Task_Progressed,  tolua_set_Eris__Task_Progressed );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           return 1;
          }
          
          
          #if defined(  LUA_VERSION_NUM ) && LUA_VERSION_NUM >= 501
    2541   TOLUA_API int luaopen_Eris (  lua_State* tolua_S ) {
           return tolua_Eris_open(  tolua_S );
          };
          #endif
          

./framework/bindings/lua/eris/required.h

       1  #include <sigc++/sigc++.h>
          #include <Eris/View.h>
          #include <Eris/Task.h>

./framework/bindings/lua/lua_Framework.cpp

       1  /*
          ** Lua binding: Framework
          ** Generated automatically by tolua++-1.0.92 on Sun May 27 17:32:42 2007.
          */
          
          #ifndef __cplusplus
          #include "stdlib.h"
          #endif
          #include "string.h"
          
          #include "tolua++.h"
          
          /* Exported function */
      14  TOLUA_API int tolua_Framework_open (  lua_State* tolua_S );
          
          #include "required.h"
          #include "../../IScriptingProvider.h"
          
          /* function to release collected object via destructor */
          #ifdef __cplusplus
          
      22  static int tolua_collect_Ember__Tokeniser (  lua_State* tolua_S )
          {
           Ember::Tokeniser* self = (  Ember::Tokeniser* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          #endif
          
          
          /* function to register type */
      32  static void tolua_reg_types (  lua_State* tolua_S )
          {
           tolua_usertype(  tolua_S,  "sigc::signal<bool,  const std::string&>" );
           tolua_usertype(  tolua_S,  "Ember::ConsoleBackend" );
           tolua_usertype(  tolua_S,  "Ember::IScriptingProvider" );
           tolua_usertype(  tolua_S,  "Ember::Tokeniser" );
          }
          
          /* method: getMainConsole of class Ember::ConsoleBackend */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_ConsoleBackend_getMainConsole00
      42  static int tolua_Framework_Ember_ConsoleBackend_getMainConsole00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ember::ConsoleBackend",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ember::ConsoleBackend* tolua_ret = (  Ember::ConsoleBackend* ) Ember::ConsoleBackend::getMainConsole(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ember::ConsoleBackend" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMainConsole'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: runCommand of class Ember::ConsoleBackend */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_ConsoleBackend_runCommand00
      70  static int tolua_Framework_Ember_ConsoleBackend_runCommand00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ConsoleBackend",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ConsoleBackend* self = (  Ember::ConsoleBackend* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string command = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           bool addToHistory = (  (  bool ) tolua_toboolean(  tolua_S,  3,  true ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'runCommand'",  NULL );
          #endif
           {
           self->runCommand(  command,  addToHistory );
           tolua_pushcppstring(  tolua_S,  (  const char* )command );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'runCommand'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: pushMessage of class Ember::ConsoleBackend */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_ConsoleBackend_pushMessage00
     106  static int tolua_Framework_Ember_ConsoleBackend_pushMessage00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ConsoleBackend",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ConsoleBackend* self = (  Ember::ConsoleBackend* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string message = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'pushMessage'",  NULL );
          #endif
           {
           self->pushMessage(  message );
           tolua_pushcppstring(  tolua_S,  (  const char* )message );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'pushMessage'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: runCommand of class Ember::ConsoleBackend */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_ConsoleBackend_runCommand01
     140  static int tolua_Framework_Ember_ConsoleBackend_runCommand01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ConsoleBackend",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ember::ConsoleBackend* self = (  Ember::ConsoleBackend* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string command = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string args = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'runCommand'",  NULL );
          #endif
           {
           self->runCommand(  command,  args );
           tolua_pushcppstring(  tolua_S,  (  const char* )command );
           tolua_pushcppstring(  tolua_S,  (  const char* )args );
           }
           }
           return 2;
          tolua_lerror:
           return tolua_Framework_Ember_ConsoleBackend_runCommand00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: GotMessage of class Ember::ConsoleBackend */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ConsoleBackend_GotMessage
     172  static int tolua_get_Ember__ConsoleBackend_GotMessage(  lua_State* tolua_S )
          {
           Ember::ConsoleBackend* self = (  Ember::ConsoleBackend* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotMessage'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->GotMessage,  "sigc::signal<bool,  const std::string&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: GotMessage of class Ember::ConsoleBackend */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ConsoleBackend_GotMessage
     185  static int tolua_set_Ember__ConsoleBackend_GotMessage(  lua_State* tolua_S )
          {
           Ember::ConsoleBackend* self = (  Ember::ConsoleBackend* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotMessage'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<bool,  const std::string&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->GotMessage = *(  (  sigc::signal<bool,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new of class Ember::Tokeniser */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_Tokeniser_new00
     202  static int tolua_Framework_Ember_Tokeniser_new00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ember::Tokeniser",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ember::Tokeniser* tolua_ret = (  Ember::Tokeniser* ) new Ember::Tokeniser(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ember::Tokeniser" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: new_local of class Ember::Tokeniser */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_Tokeniser_new00_local
     230  static int tolua_Framework_Ember_Tokeniser_new00_local(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ember::Tokeniser",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ember::Tokeniser* tolua_ret = (  Ember::Tokeniser* ) new Ember::Tokeniser(   );
           tolua_pushusertype_and_takeownership(  tolua_S,  (  void * )tolua_ret,  "Ember::Tokeniser" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'new'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: delete of class Ember::Tokeniser */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_Tokeniser_delete00
     258  static int tolua_Framework_Ember_Tokeniser_delete00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::Tokeniser",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::Tokeniser* self = (  Ember::Tokeniser* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'delete'",  NULL );
          #endif
           delete self;
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'delete'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: initTokens of class Ember::Tokeniser */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_Tokeniser_initTokens00
     287  static int tolua_Framework_Ember_Tokeniser_initTokens00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::Tokeniser",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::Tokeniser* self = (  Ember::Tokeniser* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string tokens = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'initTokens'",  NULL );
          #endif
           {
           self->initTokens(  tokens );
           tolua_pushcppstring(  tolua_S,  (  const char* )tokens );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'initTokens'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: nextToken of class Ember::Tokeniser */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_Tokeniser_nextToken00
     321  static int tolua_Framework_Ember_Tokeniser_nextToken00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::Tokeniser",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::Tokeniser* self = (  Ember::Tokeniser* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'nextToken'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->nextToken(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'nextToken'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: remainingTokens of class Ember::Tokeniser */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_Tokeniser_remainingTokens00
     353  static int tolua_Framework_Ember_Tokeniser_remainingTokens00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::Tokeniser",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::Tokeniser* self = (  Ember::Tokeniser* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'remainingTokens'",  NULL );
          #endif
           {
           std::string tolua_ret = (  std::string ) self->remainingTokens(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'remainingTokens'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: executeScript of class Ember::IScriptingProvider */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_IScriptingProvider_executeScript00
     385  static int tolua_Framework_Ember_IScriptingProvider_executeScript00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::IScriptingProvider",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::IScriptingProvider* self = (  Ember::IScriptingProvider* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string scriptCode = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'executeScript'",  NULL );
          #endif
           {
           self->executeScript(  scriptCode );
           tolua_pushcppstring(  tolua_S,  (  const char* )scriptCode );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'executeScript'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: willLoadScript of class Ember::IScriptingProvider */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_IScriptingProvider_willLoadScript00
     419  static int tolua_Framework_Ember_IScriptingProvider_willLoadScript00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::IScriptingProvider",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::IScriptingProvider* self = (  Ember::IScriptingProvider* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string scriptName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'willLoadScript'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->willLoadScript(  scriptName );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )scriptName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'willLoadScript'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getName of class Ember::IScriptingProvider */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_IScriptingProvider_getName00
     454  static int tolua_Framework_Ember_IScriptingProvider_getName00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::IScriptingProvider",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::IScriptingProvider* self = (  const Ember::IScriptingProvider* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getName'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getName(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getName'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: forceGC of class Ember::IScriptingProvider */
          #ifndef TOLUA_DISABLE_tolua_Framework_Ember_IScriptingProvider_forceGC00
     486  static int tolua_Framework_Ember_IScriptingProvider_forceGC00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::IScriptingProvider",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::IScriptingProvider* self = (  Ember::IScriptingProvider* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'forceGC'",  NULL );
          #endif
           {
           self->forceGC(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'forceGC'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* Open function */
     516  TOLUA_API int tolua_Framework_open (  lua_State* tolua_S )
          {
           tolua_open(  tolua_S );
           tolua_reg_types(  tolua_S );
           tolua_module(  tolua_S,  NULL,  0 );
           tolua_beginmodule(  tolua_S,  NULL );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           tolua_cclass(  tolua_S,  "ConsoleBackend",  "Ember::ConsoleBackend",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ConsoleBackend" );
           tolua_function(  tolua_S,  "getMainConsole",  tolua_Framework_Ember_ConsoleBackend_getMainConsole00 );
           tolua_function(  tolua_S,  "runCommand",  tolua_Framework_Ember_ConsoleBackend_runCommand00 );
           tolua_function(  tolua_S,  "pushMessage",  tolua_Framework_Ember_ConsoleBackend_pushMessage00 );
           tolua_function(  tolua_S,  "runCommand",  tolua_Framework_Ember_ConsoleBackend_runCommand01 );
           tolua_variable(  tolua_S,  "GotMessage",  tolua_get_Ember__ConsoleBackend_GotMessage,  tolua_set_Ember__ConsoleBackend_GotMessage );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           #ifdef __cplusplus
           tolua_cclass(  tolua_S,  "Tokeniser",  "Ember::Tokeniser",  "",  tolua_collect_Ember__Tokeniser );
           #else
           tolua_cclass(  tolua_S,  "Tokeniser",  "Ember::Tokeniser",  "",  NULL );
           #endif
           tolua_beginmodule(  tolua_S,  "Tokeniser" );
           tolua_function(  tolua_S,  "new",  tolua_Framework_Ember_Tokeniser_new00 );
           tolua_function(  tolua_S,  "new_local",  tolua_Framework_Ember_Tokeniser_new00_local );
           tolua_function(  tolua_S,  ".call",  tolua_Framework_Ember_Tokeniser_new00_local );
           tolua_function(  tolua_S,  "delete",  tolua_Framework_Ember_Tokeniser_delete00 );
           tolua_function(  tolua_S,  "initTokens",  tolua_Framework_Ember_Tokeniser_initTokens00 );
           tolua_function(  tolua_S,  "nextToken",  tolua_Framework_Ember_Tokeniser_nextToken00 );
           tolua_function(  tolua_S,  "remainingTokens",  tolua_Framework_Ember_Tokeniser_remainingTokens00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           tolua_cclass(  tolua_S,  "IScriptingProvider",  "Ember::IScriptingProvider",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "IScriptingProvider" );
           tolua_function(  tolua_S,  "executeScript",  tolua_Framework_Ember_IScriptingProvider_executeScript00 );
           tolua_function(  tolua_S,  "willLoadScript",  tolua_Framework_Ember_IScriptingProvider_willLoadScript00 );
           tolua_function(  tolua_S,  "getName",  tolua_Framework_Ember_IScriptingProvider_getName00 );
           tolua_function(  tolua_S,  "forceGC",  tolua_Framework_Ember_IScriptingProvider_forceGC00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           return 1;
          }
          
          
          #if defined(  LUA_VERSION_NUM ) && LUA_VERSION_NUM >= 501
     566   TOLUA_API int luaopen_Framework (  lua_State* tolua_S ) {
           return tolua_Framework_open(  tolua_S );
          };
          #endif
          

./framework/bindings/lua/required.h

       1  #include "framework/ConsoleBackend.h"

./framework/binreloc.c

       1  /*
           * BinReloc - a library for creating relocatable executables
           * Written by: Hongli Lai <h.lai@chello.nl>
           * http://autopackage.org/
           *
           * This source code is public domain. You can relicense this code
           * under whatever license you want.
           *
           * See http://autopackage.org/docs/binreloc/ for
           * more information and how to use this.
           */
          
          #ifndef __BINRELOC_C__
          #define __BINRELOC_C__
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #ifdef ENABLE_BINRELOC
           #include <sys/types.h>
           #include <sys/stat.h>
           #include <unistd.h>
          #endif /* ENABLE_BINRELOC */
          #include <stdio.h>
          #include <stdlib.h>
          #include <limits.h>
          #include <string.h>
          #include "binreloc.h"
          
          #ifdef __cplusplus
          extern "C" {
          #endif /* __cplusplus */
          
          
          
          /** @internal
           * Find the canonical filename of the executable. Returns the filename
           * (  which must be freed ) or NULL on error. If the parameter 'error' is
           * not NULL,   the error code will be stored there,   if an error occured.
           */
          static char *
      43  _br_find_exe (  BrInitError *error )
          {
          #ifndef ENABLE_BINRELOC
           if (  error )
           *error = BR_INIT_ERROR_DISABLED;
           return NULL;
          #else
           char *path,   *path2,   *line,   *result;
           size_t buf_size;
           ssize_t size;
           struct stat stat_buf;
           FILE *f;
          
           /* Read from /proc/self/exe (  symlink ) */
           if (  sizeof (  path ) > SSIZE_MAX )
           buf_size = SSIZE_MAX - 1;
           else
           buf_size = PATH_MAX - 1;
           path = (  char * ) malloc (  buf_size );
           if (  path == NULL ) {
           /* Cannot allocate memory. */
           if (  error )
           *error = BR_INIT_ERROR_NOMEM;
           return NULL;
           }
           path2 = (  char * ) malloc (  buf_size );
           if (  path2 == NULL ) {
           /* Cannot allocate memory. */
           if (  error )
           *error = BR_INIT_ERROR_NOMEM;
           free (  path );
           return NULL;
           }
          
           strncpy (  path2,   "/proc/self/exe",   buf_size - 1 );
          
           while (  1 ) {
           int i;
          
           size = readlink (  path2,   path,   buf_size - 1 );
           if (  size == -1 ) {
           /* Error. */
           free (  path2 );
           break;
           }
          
           /* readlink(   ) success. */
           path[size] = '\0';
          
           /* Check whether the symlink's target is also a symlink.
           * We want to get the final target. */
           i = stat (  path,   &stat_buf );
           if (  i == -1 ) {
           /* Error. */
           free (  path2 );
           break;
           }
          
           /* stat(   ) success. */
           if (  !S_ISLNK (  stat_buf.st_mode ) ) {
           /* path is not a symlink. Done. */
           free (  path2 );
           return path;
           }
          
           /* path is a symlink. Continue loop and resolve this. */
           strncpy (  path,   path2,   buf_size - 1 );
           }
          
          
           /* readlink(   ) or stat(   ) failed; this can happen when the program is
           * running in Valgrind 2.2. Read from /proc/self/maps as fallback. */
          
           buf_size = PATH_MAX + 128;
           line = (  char * ) realloc (  path,   buf_size );
           if (  line == NULL ) {
           /* Cannot allocate memory. */
           free (  path );
           if (  error )
           *error = BR_INIT_ERROR_NOMEM;
           return NULL;
           }
          
           f = fopen (  "/proc/self/maps",   "r" );
           if (  f == NULL ) {
           free (  line );
           if (  error )
           *error = BR_INIT_ERROR_OPEN_MAPS;
           return NULL;
           }
          
           /* The first entry should be the executable name. */
           result = fgets (  line,   (  int ) buf_size,   f );
           if (  result == NULL ) {
           fclose (  f );
           free (  line );
           if (  error )
           *error = BR_INIT_ERROR_READ_MAPS;
           return NULL;
           }
          
           /* Get rid of newline character. */
           buf_size = strlen (  line );
           if (  buf_size <= 0 ) {
           /* Huh? An empty string? */
           fclose (  f );
           free (  line );
           if (  error )
           *error = BR_INIT_ERROR_INVALID_MAPS;
           return NULL;
           }
           if (  line[buf_size - 1] == 10 )
           line[buf_size - 1] = 0;
          
           /* Extract the filename; it is always an absolute path. */
           path = strchr (  line,   '/' );
          
           /* Sanity check. */
           if (  strstr (  line,   " r-xp " ) == NULL || path == NULL ) {
           fclose (  f );
           free (  line );
           if (  error )
           *error = BR_INIT_ERROR_INVALID_MAPS;
           return NULL;
           }
          
           path = strdup (  path );
           free (  line );
           fclose (  f );
           return path;
          #endif /* ENABLE_BINRELOC */
          }
          
          
          /** @internal
           * Find the canonical filename of the executable which owns symbol.
           * Returns a filename which must be freed,   or NULL on error.
           */
          static char *
     182  _br_find_exe_for_symbol (  const void *symbol,   BrInitError *error )
          {
          #ifndef ENABLE_BINRELOC
           if (  error )
           *error = BR_INIT_ERROR_DISABLED;
           return (  char * ) NULL;
          #else
           #define SIZE PATH_MAX + 100
           FILE *f;
           size_t address_string_len;
           char *address_string,   line[SIZE],   *found;
          
           if (  symbol == NULL )
           return (  char * ) NULL;
          
           f = fopen (  "/proc/self/maps",   "r" );
           if (  f == NULL )
           return (  char * ) NULL;
          
           address_string_len = 4;
           address_string = (  char * ) malloc (  address_string_len );
           found = (  char * ) NULL;
          
           while (  !feof (  f ) ) {
           char *start_addr,   *end_addr,   *end_addr_end,   *file;
           void *start_addr_p,   *end_addr_p;
           size_t len;
          
           if (  fgets (  line,   SIZE,   f ) == NULL )
           break;
          
           /* Sanity check. */
           if (  strstr (  line,   " r-xp " ) == NULL || strchr (  line,   '/' ) == NULL )
           continue;
          
           /* Parse line. */
           start_addr = line;
           end_addr = strchr (  line,   '-' );
           file = strchr (  line,   '/' );
          
           /* More sanity check. */
           if (  !(  file > end_addr && end_addr != NULL && end_addr[0] == '-' ) )
           continue;
          
           end_addr[0] = '\0';
           end_addr++;
           end_addr_end = strchr (  end_addr,   ' ' );
           if (  end_addr_end == NULL )
           continue;
          
           end_addr_end[0] = '\0';
           len = strlen (  file );
           if (  len == 0 )
           continue;
           if (  file[len - 1] == '\n' )
           file[len - 1] = '\0';
          
           /* Get rid of "(  deleted )" from the filename. */
           len = strlen (  file );
           if (  len > 10 && strcmp (  file + len - 10,   " (  deleted )" ) == 0 )
           file[len - 10] = '\0';
          
           /* I don't know whether this can happen but better safe than sorry. */
           len = strlen (  start_addr );
           if (  len != strlen (  end_addr ) )
           continue;
          
          
           /* Transform the addresses into a string in the form of 0xdeadbeef,  
           * then transform that into a pointer. */
           if (  address_string_len < len + 3 ) {
           address_string_len = len + 3;
           address_string = (  char * ) realloc (  address_string,   address_string_len );
           }
          
           memcpy (  address_string,   "0x",   2 );
           memcpy (  address_string + 2,   start_addr,   len );
           address_string[2 + len] = '\0';
           sscanf (  address_string,   "%p",   &start_addr_p );
          
           memcpy (  address_string,   "0x",   2 );
           memcpy (  address_string + 2,   end_addr,   len );
           address_string[2 + len] = '\0';
           sscanf (  address_string,   "%p",   &end_addr_p );
          
          
           if (  symbol >= start_addr_p && symbol < end_addr_p ) {
           found = file;
           break;
           }
           }
          
           free (  address_string );
           fclose (  f );
          
           if (  found == NULL )
           return (  char * ) NULL;
           else
           return strdup (  found );
          #endif /* ENABLE_BINRELOC */
          }
          
          
          #ifndef BINRELOC_RUNNING_DOXYGEN
           #undef NULL
           #define NULL (  (  void * ) 0 ) /* typecasted as char* for C++ type safeness */
          #endif
          
          static char *exe = (  char * ) NULL;
          
          
          /** Initialize the BinReloc library (  for applications ).
           *
           * This function must be called before using any other BinReloc functions.
           * It attempts to locate the application's canonical filename.
           *
           * @note If you want to use BinReloc for a library,   then you should call
           * br_init_lib(   ) instead.
           *
           * @param error If BinReloc failed to initialize,   then the error code will
           * be stored in this variable. Set to NULL if you want to
           * ignore this. See #BrInitError for a list of error codes.
           *
           * @returns 1 on success,   0 if BinReloc failed to initialize.
           */
          int
     308  br_init (  BrInitError *error )
          {
           exe = _br_find_exe (  error );
           return exe != NULL;
          }
          
          
          /** Initialize the BinReloc library (  for libraries ).
           *
           * This function must be called before using any other BinReloc functions.
           * It attempts to locate the calling library's canonical filename.
           *
           * @note The BinReloc source code MUST be included in your library,   or this
           * function won't work correctly.
           *
           * @param error If BinReloc failed to initialize,   then the error code will
           * be stored in this variable. Set to NULL if you want to
           * ignore this. See #BrInitError for a list of error codes.
           *
           * @returns 1 on success,   0 if a filename cannot be found.
           */
          int
     330  br_init_lib (  BrInitError *error )
          {
           exe = _br_find_exe_for_symbol (  (  const void * ) "",   error );
           return exe != NULL;
          }
          
          
          /** Find the canonical filename of the current application.
           *
           * @param default_exe A default filename which will be used as fallback.
           * @returns A string containing the application's canonical filename,  
           * which must be freed when no longer necessary. If BinReloc is
           * not initialized,   or if br_init(   ) failed,   then a copy of
           * default_exe will be returned. If default_exe is NULL,   then
           * NULL will be returned.
           */
          char *
     347  br_find_exe (  const char *default_exe )
          {
           if (  exe == (  char * ) NULL ) {
           /* BinReloc is not initialized. */
           if (  default_exe != (  const char * ) NULL )
           return strdup (  default_exe );
           else
           return (  char * ) NULL;
           }
           return strdup (  exe );
          }
          
          
          /** Locate the directory in which the current application is installed.
           *
           * The prefix is generated by the following pseudo-code evaluation:
           * \code
           * dirname(  exename )
           * \endcode
           *
           * @param default_dir A default directory which will used as fallback.
           * @return A string containing the directory,   which must be freed when no
           * longer necessary. If BinReloc is not initialized,   or if the
           * initialization function failed,   then a copy of default_dir
           * will be returned. If default_dir is NULL,   then NULL will be
           * returned.
           */
          char *
     375  br_find_exe_dir (  const char *default_dir )
          {
           if (  exe == NULL ) {
           /* BinReloc not initialized. */
           if (  default_dir != NULL )
           return strdup (  default_dir );
           else
           return NULL;
           }
          
           return br_dirname (  exe );
          }
          
          
          /** Locate the prefix in which the current application is installed.
           *
           * The prefix is generated by the following pseudo-code evaluation:
           * \code
           * dirname(  dirname(  exename ) )
           * \endcode
           *
           * @param default_prefix A default prefix which will used as fallback.
           * @return A string containing the prefix,   which must be freed when no
           * longer necessary. If BinReloc is not initialized,   or if
           * the initialization function failed,   then a copy of default_prefix
           * will be returned. If default_prefix is NULL,   then NULL will be returned.
           */
          char *
     403  br_find_prefix (  const char *default_prefix )
          {
           char *dir1,   *dir2;
          
           if (  exe == (  char * ) NULL ) {
           /* BinReloc not initialized. */
           if (  default_prefix != (  const char * ) NULL )
           return strdup (  default_prefix );
           else
           return (  char * ) NULL;
           }
          
           dir1 = br_dirname (  exe );
           dir2 = br_dirname (  dir1 );
           free (  dir1 );
           return dir2;
          }
          
          
          /** Locate the application's binary folder.
           *
           * The path is generated by the following pseudo-code evaluation:
           * \code
           * prefix + "/bin"
           * \endcode
           *
           * @param default_bin_dir A default path which will used as fallback.
           * @return A string containing the bin folder's path,   which must be freed when
           * no longer necessary. If BinReloc is not initialized,   or if
           * the initialization function failed,   then a copy of default_bin_dir will
           * be returned. If default_bin_dir is NULL,   then NULL will be returned.
           */
          char *
     436  br_find_bin_dir (  const char *default_bin_dir )
          {
           char *prefix,   *dir;
          
           prefix = br_find_prefix (  (  const char * ) NULL );
           if (  prefix == (  char * ) NULL ) {
           /* BinReloc not initialized. */
           if (  default_bin_dir != (  const char * ) NULL )
           return strdup (  default_bin_dir );
           else
           return (  char * ) NULL;
           }
          
           dir = br_build_path (  prefix,   "bin" );
           free (  prefix );
           return dir;
          }
          
          
          /** Locate the application's superuser binary folder.
           *
           * The path is generated by the following pseudo-code evaluation:
           * \code
           * prefix + "/sbin"
           * \endcode
           *
           * @param default_sbin_dir A default path which will used as fallback.
           * @return A string containing the sbin folder's path,   which must be freed when
           * no longer necessary. If BinReloc is not initialized,   or if the
           * initialization function failed,   then a copy of default_sbin_dir will
           * be returned. If default_bin_dir is NULL,   then NULL will be returned.
           */
          char *
     469  br_find_sbin_dir (  const char *default_sbin_dir )
          {
           char *prefix,   *dir;
          
           prefix = br_find_prefix (  (  const char * ) NULL );
           if (  prefix == (  char * ) NULL ) {
           /* BinReloc not initialized. */
           if (  default_sbin_dir != (  const char * ) NULL )
           return strdup (  default_sbin_dir );
           else
           return (  char * ) NULL;
           }
          
           dir = br_build_path (  prefix,   "sbin" );
           free (  prefix );
           return dir;
          }
          
          
          /** Locate the application's data folder.
           *
           * The path is generated by the following pseudo-code evaluation:
           * \code
           * prefix + "/share"
           * \endcode
           *
           * @param default_data_dir A default path which will used as fallback.
           * @return A string containing the data folder's path,   which must be freed when
           * no longer necessary. If BinReloc is not initialized,   or if the
           * initialization function failed,   then a copy of default_data_dir
           * will be returned. If default_data_dir is NULL,   then NULL will be
           * returned.
           */
          char *
     503  br_find_data_dir (  const char *default_data_dir )
          {
           char *prefix,   *dir;
          
           prefix = br_find_prefix (  (  const char * ) NULL );
           if (  prefix == (  char * ) NULL ) {
           /* BinReloc not initialized. */
           if (  default_data_dir != (  const char * ) NULL )
           return strdup (  default_data_dir );
           else
           return (  char * ) NULL;
           }
          
           dir = br_build_path (  prefix,   "share" );
           free (  prefix );
           return dir;
          }
          
          
          /** Locate the application's localization folder.
           *
           * The path is generated by the following pseudo-code evaluation:
           * \code
           * prefix + "/share/locale"
           * \endcode
           *
           * @param default_locale_dir A default path which will used as fallback.
           * @return A string containing the localization folder's path,   which must be freed when
           * no longer necessary. If BinReloc is not initialized,   or if the
           * initialization function failed,   then a copy of default_locale_dir will be returned.
           * If default_locale_dir is NULL,   then NULL will be returned.
           */
          char *
     536  br_find_locale_dir (  const char *default_locale_dir )
          {
           char *data_dir,   *dir;
          
           data_dir = br_find_data_dir (  (  const char * ) NULL );
           if (  data_dir == (  char * ) NULL ) {
           /* BinReloc not initialized. */
           if (  default_locale_dir != (  const char * ) NULL )
           return strdup (  default_locale_dir );
           else
           return (  char * ) NULL;
           }
          
           dir = br_build_path (  data_dir,   "locale" );
           free (  data_dir );
           return dir;
          }
          
          
          /** Locate the application's library folder.
           *
           * The path is generated by the following pseudo-code evaluation:
           * \code
           * prefix + "/lib"
           * \endcode
           *
           * @param default_lib_dir A default path which will used as fallback.
           * @return A string containing the library folder's path,   which must be freed when
           * no longer necessary. If BinReloc is not initialized,   or if the initialization
           * function failed,   then a copy of default_lib_dir will be returned.
           * If default_lib_dir is NULL,   then NULL will be returned.
           */
          char *
     569  br_find_lib_dir (  const char *default_lib_dir )
          {
           char *prefix,   *dir;
          
           prefix = br_find_prefix (  (  const char * ) NULL );
           if (  prefix == (  char * ) NULL ) {
           /* BinReloc not initialized. */
           if (  default_lib_dir != (  const char * ) NULL )
           return strdup (  default_lib_dir );
           else
           return (  char * ) NULL;
           }
          
           dir = br_build_path (  prefix,   "lib" );
           free (  prefix );
           return dir;
          }
          
          
          /** Locate the application's libexec folder.
           *
           * The path is generated by the following pseudo-code evaluation:
           * \code
           * prefix + "/libexec"
           * \endcode
           *
           * @param default_libexec_dir A default path which will used as fallback.
           * @return A string containing the libexec folder's path,   which must be freed when
           * no longer necessary. If BinReloc is not initialized,   or if the initialization
           * function failed,   then a copy of default_libexec_dir will be returned.
           * If default_libexec_dir is NULL,   then NULL will be returned.
           */
          char *
     602  br_find_libexec_dir (  const char *default_libexec_dir )
          {
           char *prefix,   *dir;
          
           prefix = br_find_prefix (  (  const char * ) NULL );
           if (  prefix == (  char * ) NULL ) {
           /* BinReloc not initialized. */
           if (  default_libexec_dir != (  const char * ) NULL )
           return strdup (  default_libexec_dir );
           else
           return (  char * ) NULL;
           }
          
           dir = br_build_path (  prefix,   "libexec" );
           free (  prefix );
           return dir;
          }
          
          
          /** Locate the application's configuration files folder.
           *
           * The path is generated by the following pseudo-code evaluation:
           * \code
           * prefix + "/etc"
           * \endcode
           *
           * @param default_etc_dir A default path which will used as fallback.
           * @return A string containing the etc folder's path,   which must be freed when
           * no longer necessary. If BinReloc is not initialized,   or if the initialization
           * function failed,   then a copy of default_etc_dir will be returned.
           * If default_etc_dir is NULL,   then NULL will be returned.
           */
          char *
     635  br_find_etc_dir (  const char *default_etc_dir )
          {
           char *prefix,   *dir;
          
           prefix = br_find_prefix (  (  const char * ) NULL );
           if (  prefix == (  char * ) NULL ) {
           /* BinReloc not initialized. */
           if (  default_etc_dir != (  const char * ) NULL )
           return strdup (  default_etc_dir );
           else
           return (  char * ) NULL;
           }
          
           dir = br_build_path (  prefix,   "etc" );
           free (  prefix );
           return dir;
          }
          
          
          /***********************
           * Utility functions
           ***********************/
          
          /** Concatenate str1 and str2 to a newly allocated string.
           *
           * @param str1 A string.
           * @param str2 Another string.
           * @returns A newly-allocated string. This string should be freed when no longer needed.
           */
          char *
     665  br_strcat (  const char *str1,   const char *str2 )
          {
           char *result;
           size_t len1,   len2;
          
           if (  str1 == NULL )
           str1 = "";
           if (  str2 == NULL )
           str2 = "";
          
           len1 = strlen (  str1 );
           len2 = strlen (  str2 );
          
           result = (  char * ) malloc (  len1 + len2 + 1 );
           memcpy (  result,   str1,   len1 );
           memcpy (  result + len1,   str2,   len2 );
           result[len1 + len2] = '\0';
          
           return result;
          }
          
          
          char *
     688  br_build_path (  const char *dir,   const char *file )
          {
           char *dir2,   *result;
           size_t len;
           int must_free = 0;
          
           len = strlen (  dir );
           if (  len > 0 && dir[len - 1] != '/' ) {
           dir2 = br_strcat (  dir,   "/" );
           must_free = 1;
           } else
           dir2 = (  char * ) dir;
          
           result = br_strcat (  dir2,   file );
           if (  must_free )
           free (  dir2 );
           return result;
          }
          
          
          /* Emulates glibc's strndup(   ) */
          static char *
     710  br_strndup (  const char *str,   size_t size )
          {
           char *result = (  char * ) NULL;
           size_t len;
          
           if (  str == (  const char * ) NULL )
           return (  char * ) NULL;
          
           len = strlen (  str );
           if (  len == 0 )
           return strdup (  "" );
           if (  size > len )
           size = len;
          
           result = (  char * ) malloc (  len + 1 );
           memcpy (  result,   str,   size );
           result[size] = '\0';
           return result;
          }
          
          
          /** Extracts the directory component of a path.
           *
           * Similar to g_dirname(   ) or the dirname commandline application.
           *
           * Example:
           * \code
           * br_dirname (  "/usr/local/foobar" ); --> Returns: "/usr/local"
           * \endcode
           *
           * @param path A path.
           * @returns A directory name. This string should be freed when no longer needed.
           */
          char *
     744  br_dirname (  const char *path )
          {
           char *end,   *result;
          
           if (  path == (  const char * ) NULL )
           return (  char * ) NULL;
          
           end = strrchr (  path,   '/' );
           if (  end == (  const char * ) NULL )
           return strdup (  "." );
          
           while (  end > path && *end == '/' )
           end--;
           result = br_strndup (  path,   end - path + 1 );
           if (  result[0] == 0 ) {
           free (  result );
           return strdup (  "/" );
           } else
           return result;
          }
          
          
          #ifdef __cplusplus
          }
          #endif /* __cplusplus */
          
          #endif /* __BINRELOC_C__ */

./framework/binreloc.h

       1  /*
           * BinReloc - a library for creating relocatable executables
           * Written by: Hongli Lai <h.lai@chello.nl>
           * http://autopackage.org/
           *
           * This source code is public domain. You can relicense this code
           * under whatever license you want.
           *
           * See http://autopackage.org/docs/binreloc/ for
           * more information and how to use this.
           */
          
          #ifndef __BINRELOC_H__
          #define __BINRELOC_H__
          
          #ifdef __cplusplus
          extern "C" {
          #endif /* __cplusplus */
          
          
          /** These error codes can be returned by br_init(   ),   br_init_lib(   ),   gbr_init(   ) or gbr_init_lib(   ). */
          typedef enum {
           /** Cannot allocate memory. */
           BR_INIT_ERROR_NOMEM,  
           /** Unable to open /proc/self/maps; see errno for details. */
           BR_INIT_ERROR_OPEN_MAPS,  
           /** Unable to read from /proc/self/maps; see errno for details. */
           BR_INIT_ERROR_READ_MAPS,  
           /** The file format of /proc/self/maps is invalid; kernel bug? */
           BR_INIT_ERROR_INVALID_MAPS,  
           /** BinReloc is disabled (  the ENABLE_BINRELOC macro is not defined ). */
           BR_INIT_ERROR_DISABLED
          } BrInitError;
          
          
          #ifndef BINRELOC_RUNNING_DOXYGEN
          /* Mangle symbol names to avoid symbol collisions with other ELF objects. */
           #define br_init ybed95943699743390_br_init
           #define br_init_lib ybed95943699743390_br_init_lib
           #define br_find_exe ybed95943699743390_br_find_exe
           #define br_find_exe_dir ybed95943699743390_br_find_exe_dir
           #define br_find_prefix ybed95943699743390_br_find_prefix
           #define br_find_bin_dir ybed95943699743390_br_find_bin_dir
           #define br_find_sbin_dir ybed95943699743390_br_find_sbin_dir
           #define br_find_data_dir ybed95943699743390_br_find_data_dir
           #define br_find_locale_dir ybed95943699743390_br_find_locale_dir
           #define br_find_lib_dir ybed95943699743390_br_find_lib_dir
           #define br_find_libexec_dir ybed95943699743390_br_find_libexec_dir
           #define br_find_etc_dir ybed95943699743390_br_find_etc_dir
           #define br_strcat ybed95943699743390_br_strcat
           #define br_build_path ybed95943699743390_br_build_path
           #define br_dirname ybed95943699743390_br_dirname
          
          
          #endif
      56  int br_init (  BrInitError *error );
      57  int br_init_lib (  BrInitError *error );
          
      59  char *br_find_exe (  const char *default_exe );
      60  char *br_find_exe_dir (  const char *default_dir );
      61  char *br_find_prefix (  const char *default_prefix );
      62  char *br_find_bin_dir (  const char *default_bin_dir );
      63  char *br_find_sbin_dir (  const char *default_sbin_dir );
      64  char *br_find_data_dir (  const char *default_data_dir );
      65  char *br_find_locale_dir (  const char *default_locale_dir );
      66  char *br_find_lib_dir (  const char *default_lib_dir );
      67  char *br_find_libexec_dir (  const char *default_libexec_dir );
      68  char *br_find_etc_dir (  const char *default_etc_dir );
          
          /* Utility functions */
      71  char *br_strcat (  const char *str1,   const char *str2 );
      72  char *br_build_path (  const char *dir,   const char *file );
      73  char *br_dirname (  const char *path );
          
          
          #ifdef __cplusplus
          }
          #endif /* __cplusplus */
          
          #endif /* __BINRELOC_H__ */

./framework/float_cast.h

       1  /*
          ** Copyright (  C ) 2001 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
          **
          ** Permission to use,   copy,   modify,   distribute,   and sell this file for any
          ** purpose is hereby granted without fee,   provided that the above copyright
          ** and this permission notice appear in all copies. No representations are
          ** made about the suitability of this software for any purpose. It is
          ** provided "as is" without express or implied warranty.
          */
          
          /* Version 1.1 */
          
          
          /*============================================================================
          ** On Intel Pentium processors (  especially PIII and probably P4 ),   converting
          ** from float to int is very slow. To meet the C specs,   the code produced by
          ** most C compilers targeting Pentium needs to change the FPU rounding mode
          ** before the float to int conversion is performed.
          **
          ** Changing the FPU rounding mode causes the FPU pipeline to be flushed. It
          ** is this flushing of the pipeline which is so slow.
          **
          ** Fortunately the ISO C99 specifications define the functions lrint,   lrintf,  
          ** llrint and llrintf which fix this problem as a side effect.
          **
          ** On Unix-like systems,   the configure process should have detected the
          ** presence of these functions. If they weren't found we have to replace them
          ** here with a standard C cast.
          */
          
          /*
          ** The C99 prototypes for lrint and lrintf are as follows:
          **
          ** long int lrintf (  float x ) ;
          ** long int lrint (  double x ) ;
          */
          
          #ifndef FLOAT_CAST_H
          #define FLOAT_CAST_H
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          /* The presence of the required functions are detected during the configure
          ** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in
          ** the config.h file.
          */
          
          #if (  HAVE_MATH_H )
          
           /* These defines enable functionality introduced with the 1999 ISO C
           ** standard. They must be defined before the inclusion of math.h to
           ** engage them. If optimisation is enabled,   these functions will be
           ** inlined. With optimisation switched off,   you have to link in the
           ** maths library using -lm.
           */
          
           #define _ISOC9X_SOURCE 1
           #define _ISOC99_SOURCE 1
          
           #define __USE_ISOC9X 1
           #define __USE_ISOC99 1
          
           #include <math.h>
          
          #elif (  defined (  WIN32 ) || defined (  _WIN32 ) )
          
           #include <math.h>
          
           /* Win32 doesn't seem to have these functions.
           ** Therefore implement inline versions of these functions here.
           */
          
      75   __inline long int
           lrint (  double flt )
           { int intgr;
          
           _asm
           { fld flt
           fistp intgr
           } ;
          
           return intgr ;
           }
          
      87   __inline long int
           lrintf (  float flt )
           { int intgr;
          
           _asm
           { fld flt
           fistp intgr
           } ;
          
           return intgr ;
           }
          #define HAVE_LRINTF 1
          #define HAVE_LRINT 1
          #else
          
           #warning "Don't have the functions lrint(   ) and lrintf (   )."
           #warning "Replacing these functions with a standard C cast."
          
           #include <math.h>
          
           #define lrint(  dbl ) (  (  int )(  dbl ) )
           #define lrintf(  flt ) (  (  int )(  flt ) )
          
          #endif
          
          #endif //FLOAT_CAST_H
          

./framework/osdir.h

       1  /**
           * Copyright (  C ) 2002 Bart Vanhauwaert
           *
           * Permission to use,   copy,   modify,   distribute and sell this software
           * for any purpose is hereby granted without fee. This license
           * includes (  but is not limited to ) standalone compilation or as part
           * of a larger project.
           *
           * This software is provided "as is" without express or implied warranty.
           *
           * For a full statement on warranty and terms and conditions for
           * copying,   distribution and modification,   please see the comment block
           * at the end of this file.
           *
           * Version 1
           *
           */
          
          #ifndef OSLINK_OSDIR_HEADER_H_
          #define OSLINK_OSDIR_HEADER_H_
          
          #if defined(  unix ) || defined(  __unix ) || defined(  __unix__ )
          #define OSLINK_OSDIR_POSIX
          #elif defined(  _WIN32 )
          #define OSLINK_OSDIR_WINDOWS
          #else
          #define OSLINK_OSDIR_NOTSUPPORTED
          #endif
          
          #include <string>
          
          #if defined(  OSLINK_OSDIR_NOTSUPPORTED )
          
          namespace oslink
          {
      36   class directory
           {
           public:
      39   directory(  const std::string& ) { }
      40   operator void*(   ) const { return (  void* )0; }
      41   std::string next(   ) { return ""; }
      42   bool isExisting(   ) {return false;}
           };
          }
          
          #elif defined(  OSLINK_OSDIR_POSIX )
          
          #include <sys/types.h>
          #include <dirent.h>
          
          namespace oslink
          {
      53   class directory
           {
           public:
      56   directory(  const std::string& aName )
           : handle(  opendir(  aName.c_str(   ) ) ),   willfail(  false )
           {
           if (  !handle )
           willfail = true;
           else
           {
           dirent* entry = readdir(  handle );
           if (  entry )
           current = entry->d_name;
           else
           willfail = true;
           }
           }
      70   ~directory(   )
           {
           if (  handle )
           closedir(  handle );
           }
      75   operator void*(   ) const
           {
           return willfail ? (  void* )0:(  void* )(  -1 );
           }
      79   bool isExisting(   )
           {
           return !willfail;
           }
      83   std::string next(   )
           {
           std::string prev(  current );
           dirent* entry = readdir(  handle );
           if (  entry )
           current = entry->d_name;
           else
           willfail = true;
           return prev;
           }
           private:
      94   DIR* handle;
      95   bool willfail;
      96   std::string current;
           };
          }
          
          #elif defined(  OSLINK_OSDIR_WINDOWS )
          
          #include <windows.h>
          #include <winbase.h>
          
     105  namespace oslink
          {
           class directory
           {
           public:
           directory(  const std::string& aName )
           : handle(  INVALID_HANDLE_VALUE ),   willfail(  false )
           {
           // First check the attributes trying to access a non-directory with
           // FindFirstFile takes ages
           DWORD attrs = GetFileAttributes(  aName.c_str(   ) );
           if (   (  attrs == 0xFFFFFFFF ) || (  (  attrs && FILE_ATTRIBUTE_DIRECTORY ) == 0 )  )
           {
           willfail = true;
           return;
           }
           std::string Full(  aName );
           // Circumvent a problem in FindFirstFile with c:\\* as parameter
           if (   (  Full.length(   ) > 0 ) && (  Full[Full.length(   )-1] != '\\' )  )
           Full += "\\";
           WIN32_FIND_DATA entry;
           handle = FindFirstFile(   (  Full+"*" ).c_str(   ),   &entry );
           if (  handle == INVALID_HANDLE_VALUE )
           willfail = true;
           else
           current = entry.cFileName;
           }
           ~directory(   )
           {
           if (  handle != INVALID_HANDLE_VALUE )
           FindClose(  handle );
           }
          
           operator void*(   ) const
           {
           return willfail ? (  void* )0:(  void* )(  -1 );
           }
           bool isExisting(   )
           {
           return !willfail;
           }
           std::string next(   )
           {
           std::string prev = current;
           WIN32_FIND_DATA entry;
           int ok = FindNextFile(  handle,   &entry );
           if (  !ok )
           willfail = true;
           else
           current = entry.cFileName;
           return current;
           }
           private:
           HANDLE handle;
           bool willfail;
           std::string current;
           };
          }
          
          
          #endif
          
          #endif
          
          /**
           *
           * The "library",   below,   refers to the collection of software functions
           * and/or data contained in this file,   prepared so as to be conveniently
           * compiled and linked with application programs (  which use some of those
           * functions and data ) to form executables.
           *
           * NO WARRANTY
           *
           * 1. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE,   THERE IS NO
           * WARRANTY FOR THE LIBRARY,   TO THE EXTENT PERMITTED BY APPLICABLE LAW.
           * EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
           * OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
           * KIND,   EITHER EXPRESSED OR IMPLIED,   INCLUDING,   BUT NOT LIMITED TO,   THE
           * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
           * PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
           * LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE,   YOU ASSUME
           * THE COST OF ALL NECESSARY SERVICING,   REPAIR OR CORRECTION.
           *
           * 2. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
           * WRITING WILL ANY COPYRIGHT HOLDER,   OR ANY OTHER PARTY WHO MAY MODIFY
           * AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE,   BE LIABLE TO YOU
           * FOR DAMAGES,   INCLUDING ANY GENERAL,   SPECIAL,   INCIDENTAL OR
           * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
           * LIBRARY (  INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
           * RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
           * FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE ),   EVEN IF
           * SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
           * DAMAGES.
           *
           * END OF TERMS AND CONDITIONS
           *
           */
          

./framework/scrap.h

       1  
          /* Handle clipboard text and data in arbitrary formats */
          
          /* Miscellaneous defines */
          #define T(  A,   B,   C,   D ) (  int )(  (  A<<24 )|(  B<<16 )|(  C<<8 )|(  D<<0 ) )
          #ifdef __cplusplus
          extern "C" {
          #endif /* __cplusplus */
          
      10  extern int init_scrap(  void );
      11  extern int lost_scrap(  void );
      12  extern void put_scrap(  int type,   int srclen,   char *src );
      13  extern void get_scrap(  int type,   int *dstlen,   char **dst );
          
          #ifdef __cplusplus
          }
          #endif /* __cplusplus */

./framework/tinyxml/tinystr.cpp

       1  /*
          www.sourceforge.net/projects/tinyxml
          Original file by Yves Berquin.
          
          This software is provided 'as-is',   without any express or implied
          warranty. In no event will the authors be held liable for any
          damages arising from the use of this software.
          
          Permission is granted to anyone to use this software for any
          purpose,   including commercial applications,   and to alter it and
          redistribute it freely,   subject to the following restrictions:
          
          1. The origin of this software must not be misrepresented; you must
          not claim that you wrote the original software. If you use this
          software in a product,   an acknowledgment in the product documentation
          would be appreciated but is not required.
          
          2. Altered source versions must be plainly marked as such,   and
          must not be misrepresented as being the original software.
          
          3. This notice may not be removed or altered from any source
          distribution.
          */
          
          /*
           * THIS FILE WAS ALTERED BY Tyge Løvset,   7. April 2005.
           */
          
          
          #ifndef TIXML_USE_STL
          
          #include "tinystr.h"
          namespace Ember {
          
          // Error value for find primitive
          const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(  -1 );
          
          
          // Null rep.
          TiXmlString::Rep TiXmlString::nullrep_ = { 0,   0,   '\0' };
          
          
      43  void TiXmlString::reserve (  size_type cap )
          {
           if (  cap > capacity(   ) )
           {
           TiXmlString tmp;
           tmp.init(  length(   ),   cap );
           memcpy(  tmp.start(   ),   data(   ),   length(   ) );
           swap(  tmp );
           }
          }
          
          
      55  TiXmlString& TiXmlString::assign(  const char* str,   size_type len )
          {
           size_type cap = capacity(   );
           if (  len > cap || cap > 3*(  len + 8 ) )
           {
           TiXmlString tmp;
           tmp.init(  len );
           memcpy(  tmp.start(   ),   str,   len );
           swap(  tmp );
           }
           else
           {
           memmove(  start(   ),   str,   len );
           set_size(  len );
           }
           return *this;
          }
          
          
      74  TiXmlString& TiXmlString::append(  const char* str,   size_type len )
          {
           size_type newsize = length(   ) + len;
           if (  newsize > capacity(   ) )
           {
           reserve (  newsize + capacity(   ) );
           }
           memmove(  finish(   ),   str,   len );
           set_size(  newsize );
           return *this;
          }
          
          
      87  TiXmlString operator + (  const TiXmlString & a,   const TiXmlString & b )
          {
           TiXmlString tmp;
           tmp.reserve(  a.length(   ) + b.length(   ) );
           tmp += a;
           tmp += b;
           return tmp;
          }
          
      96  TiXmlString operator + (  const TiXmlString & a,   const char* b )
          {
           TiXmlString tmp;
           TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>(   strlen(  b )  );
           tmp.reserve(  a.length(   ) + b_len );
           tmp += a;
           tmp.append(  b,   b_len );
           return tmp;
          }
          
     106  TiXmlString operator + (  const char* a,   const TiXmlString & b )
          {
           TiXmlString tmp;
           TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>(   strlen(  a )  );
           tmp.reserve(  a_len + b.length(   ) );
           tmp.append(  a,   a_len );
           tmp += b;
           return tmp;
          }
          
          }
          #endif // TIXML_USE_STL

./framework/tinyxml/tinystr.h

          /*
          www.sourceforge.net/projects/tinyxml
          Original file by Yves Berquin.
          
          This software is provided 'as-is',   without any express or implied
          warranty. In no event will the authors be held liable for any
          damages arising from the use of this software.
          
          Permission is granted to anyone to use this software for any
          purpose,   including commercial applications,   and to alter it and
          redistribute it freely,   subject to the following restrictions:
          
          1. The origin of this software must not be misrepresented; you must
          not claim that you wrote the original software. If you use this
          software in a product,   an acknowledgment in the product documentation
          would be appreciated but is not required.
          
          2. Altered source versions must be plainly marked as such,   and
          must not be misrepresented as being the original software.
          
          3. This notice may not be removed or altered from any source
          distribution.
          */
          
          /*
           * THIS FILE WAS ALTERED BY Tyge Lovset,   7. April 2005.
           *
           * - completely rewritten. compact,   clean,   and fast implementation.
           * - sizeof(  TiXmlString ) = pointer size (  4 bytes on 32-bit systems )
           * - fixed reserve(   ) to work as per specification.
           * - fixed buggy compares operator==(   ),   operator<(   ),   and operator>(   )
           * - fixed operator+=(   ) to take a const ref argument,   following spec.
           * - added "copy" constructor with length,   and most compare operators.
           * - added swap(   ),   clear(   ),   size(   ),   capacity(   ),   operator+(   ).
           */
          
          #ifndef TIXML_USE_STL
          
          #ifndef TIXML_STRING_INCLUDED
          #define TIXML_STRING_INCLUDED
          
          #include <assert.h>
          #include <string.h>
          
          /* The support for explicit isn't that universal,   and it isn't really
           required - it is used to check that the TiXmlString class isn't incorrectly
           used. Be nice to old compilers and macro it here:
          */
          #if defined(  _MSC_VER ) && (  _MSC_VER >= 1200  )
           // Microsoft visual studio,   version 6 and higher.
           #define TIXML_EXPLICIT explicit
          #elif defined(  __GNUC__ ) && (  __GNUC__ >= 3  )
           // GCC version 3 and higher.s
           #define TIXML_EXPLICIT explicit
          #else
           #define TIXML_EXPLICIT
          #endif
          
          namespace Ember {
          
          /*
           TiXmlString is an emulation of a subset of the std::string template.
           Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
           Only the member functions relevant to the TinyXML project have been implemented.
           The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
           a string and there's no more room,   we allocate a buffer twice as big as we need.
          */
      68  class TiXmlString
          {
           public :
           // The size type used
           typedef size_t size_type;
          
           // Error value for find primitive
      75   static const size_type npos; // = -1;
          
          
           // TiXmlString empty constructor
           TiXmlString (   ) : rep_(  &nullrep_ )
           {
           }
          
           // TiXmlString copy constructor
           TiXmlString (   const TiXmlString & copy ) : rep_(  0 )
           {
      86   init(  copy.length(   ) );
      87   memcpy(  start(   ),   copy.data(   ),   length(   ) );
           }
          
           // TiXmlString constructor,   based on a string
      91   TIXML_EXPLICIT TiXmlString (   const char * copy ) : rep_(  0 )
           {
           init(   static_cast<size_type>(   strlen(  copy )  ) );
           memcpy(  start(   ),   copy,   length(   ) );
           }
          
           // TiXmlString constructor,   based on a string
      98   TIXML_EXPLICIT TiXmlString (   const char * str,   size_type len ) : rep_(  0 )
           {
           init(  len );
           memcpy(  start(   ),   str,   len );
           }
          
           // TiXmlString destructor
     105   ~TiXmlString (   )
           {
           quit(   );
           }
          
           // = operator
     111   TiXmlString& operator = (  const char * copy )
           {
           return assign(   copy,   (  size_type )strlen(  copy ) );
           }
          
           // = operator
     117   TiXmlString& operator = (  const TiXmlString & copy )
           {
           return assign(  copy.start(   ),   copy.length(   ) );
           }
          
          
           // += operator. Maps to append
     124   TiXmlString& operator += (  const char * suffix )
           {
           return append(  suffix,   static_cast<size_type>(   strlen(  suffix )  ) );
           }
          
           // += operator. Maps to append
     130   TiXmlString& operator += (  char single )
           {
           return append(  &single,   1 );
           }
          
           // += operator. Maps to append
     136   TiXmlString& operator += (  const TiXmlString & suffix )
           {
           return append(  suffix.data(   ),   suffix.length(   ) );
           }
          
          
           // Convert a TiXmlString into a null-terminated char *
     143   const char * c_str (   ) const { return rep_->str; }
          
           // Convert a TiXmlString into a char * (  need not be null terminated ).
     146   const char * data (   ) const { return rep_->str; }
          
           // Return the length of a TiXmlString
     149   size_type length (   ) const { return rep_->size; }
          
           // Alias for length(   )
     152   size_type size (   ) const { return rep_->size; }
          
           // Checks if a TiXmlString is empty
     155   bool empty (   ) const { return rep_->size == 0; }
          
           // Return capacity of string
     158   size_type capacity (   ) const { return rep_->capacity; }
          
          
           // single char extraction
     162   const char& at (  size_type index ) const
           {
           assert(   index < length(   )  );
           return rep_->str[ index ];
           }
          
           // [] operator
     169   char& operator [] (  size_type index ) const
           {
           assert(   index < length(   )  );
           return rep_->str[ index ];
           }
          
           // find a char in a string. Return TiXmlString::npos if not found
     176   size_type find (  char lookup ) const
           {
           return find(  lookup,   0 );
           }
          
           // find a char in a string from an offset. Return TiXmlString::npos if not found
     182   size_type find (  char tofind,   size_type offset ) const
           {
           if (  offset >= length(   ) ) return npos;
          
           for (  const char* p = c_str(   ) + offset; *p != '\0'; ++p )
           {
           if (  *p == tofind ) return static_cast< size_type >(   p - c_str(   )  );
           }
           return npos;
           }
          
     193   void clear (   )
           {
           //Lee:
           //The original was just too strange,   though correct:
           // TiXmlString(   ).swap(  *this );
           //Instead use the quit & re-init:
           quit(   );
           init(  0,  0 );
           }
          
           /* Function to reserve a big amount of data when we know we'll need it. Be aware that this
           function DOES NOT clear the content of the TiXmlString if any exists.
           */
     206   void reserve (  size_type cap );
          
     208   TiXmlString& assign (  const char* str,   size_type len );
          
     210   TiXmlString& append (  const char* str,   size_type len );
          
     212   void swap (  TiXmlString& other )
           {
           Rep* r = rep_;
           rep_ = other.rep_;
           other.rep_ = r;
           }
          
           private:
          
           void init(  size_type sz ) { init(  sz,   sz ); }
           void set_size(  size_type sz ) { rep_->str[ rep_->size = sz ] = '\0'; }
           char* start(   ) const { return rep_->str; }
           char* finish(   ) const { return rep_->str + rep_->size; }
          
           struct Rep
           {
           size_type size,   capacity;
           char str[1];
           };
          
           void init(  size_type sz,   size_type cap )
           {
           if (  cap )
           {
           // Lee: the original form:
           // rep_ = static_cast<Rep*>(  operator new(  sizeof(  Rep ) + cap ) );
           // doesn't work in some cases of new being overloaded. Switching
           // to the normal allocation,   although use an 'int' for systems
           // that are overly picky about structure alignment.
           const size_type bytesNeeded = sizeof(  Rep ) + cap;
           const size_type intsNeeded = (   bytesNeeded + sizeof(  int ) - 1  ) / sizeof(   int  );
           rep_ = reinterpret_cast<Rep*>(   new int[ intsNeeded ]  );
          
           rep_->str[ rep_->size = sz ] = '\0';
           rep_->capacity = cap;
           }
           else
           {
           rep_ = &nullrep_;
           }
           }
          
           void quit(   )
           {
           if (  rep_ != &nullrep_ )
           {
           // The rep_ is really an array of ints. (  see the allocator,   above ).
           // Cast it back before delete,   so the compiler won't incorrectly call destructors.
           delete [] (   reinterpret_cast<int*>(   rep_  )  );
           }
           }
          
           Rep * rep_;
           static Rep nullrep_;
          
          } ;
          
          
          inline bool operator == (  const TiXmlString & a,   const TiXmlString & b )
          {
           return (   a.length(   ) == b.length(   )  ) // optimization on some platforms
           && (   strcmp(  a.c_str(   ),   b.c_str(   ) ) == 0  ); // actual compare
          }
          inline bool operator < (  const TiXmlString & a,   const TiXmlString & b )
          {
           return strcmp(  a.c_str(   ),   b.c_str(   ) ) < 0;
          }
          
          inline bool operator != (  const TiXmlString & a,   const TiXmlString & b ) { return !(  a == b ); }
          inline bool operator > (  const TiXmlString & a,   const TiXmlString & b ) { return b < a; }
          inline bool operator <= (  const TiXmlString & a,   const TiXmlString & b ) { return !(  b < a ); }
          inline bool operator >= (  const TiXmlString & a,   const TiXmlString & b ) { return !(  a < b ); }
          
          inline bool operator == (  const TiXmlString & a,   const char* b ) { return strcmp(  a.c_str(   ),   b ) == 0; }
          inline bool operator == (  const char* a,   const TiXmlString & b ) { return b == a; }
          inline bool operator != (  const TiXmlString & a,   const char* b ) { return !(  a == b ); }
          inline bool operator != (  const char* a,   const TiXmlString & b ) { return !(  b == a ); }
          
          TiXmlString operator + (  const TiXmlString & a,   const TiXmlString & b );
          TiXmlString operator + (  const TiXmlString & a,   const char* b );
          TiXmlString operator + (  const char* a,   const TiXmlString & b );
          
          
          /*
           TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
           Only the operators that we need for TinyXML have been developped.
          */
          class TiXmlOutStream : public TiXmlString
          {
          public :
          
           // TiXmlOutStream << operator.
           TiXmlOutStream & operator << (  const TiXmlString & in )
           {
           *this += in;
           return *this;
           }
          
           // TiXmlOutStream << operator.
           TiXmlOutStream & operator << (  const char * in )
           {
           *this += in;
           return *this;
           }
          
          } ;
          
          }
          
          #endif // TIXML_STRING_INCLUDED
          #endif // TIXML_USE_STL

./framework/tinyxml/tinyxml.cpp

       1  /*
          www.sourceforge.net/projects/tinyxml
          Original code (  2.0 and earlier  )copyright (  c ) 2000-2006 Lee Thomason (  www.grinninglizard.com )
          
          This software is provided 'as-is',   without any express or implied
          warranty. In no event will the authors be held liable for any
          damages arising from the use of this software.
          
          Permission is granted to anyone to use this software for any
          purpose,   including commercial applications,   and to alter it and
          redistribute it freely,   subject to the following restrictions:
          
          1. The origin of this software must not be misrepresented; you must
          not claim that you wrote the original software. If you use this
          software in a product,   an acknowledgment in the product documentation
          would be appreciated but is not required.
          
          2. Altered source versions must be plainly marked as such,   and
          must not be misrepresented as being the original software.
          
          3. This notice may not be removed or altered from any source
          distribution.
          */
          
          #include <ctype.h>
          
          #ifdef TIXML_USE_STL
          #include <sstream>
          #include <iostream>
          #endif
          
          #include "tinyxml.h"
          
          namespace Ember {
          
          bool TiXmlBase::condenseWhiteSpace = true;
          
      38  void TiXmlBase::PutString(   const TIXML_STRING& str,   TIXML_STRING* outString  )
          {
           int i=0;
          
           while(   i<(  int )str.length(   )  )
           {
           unsigned char c = (  unsigned char ) str[i];
          
           if (   c == '&'
           && i < (   (  int )str.length(   ) - 2  )
           && str[i+1] == '#'
           && str[i+2] == 'x'  )
           {
           // Hexadecimal character reference.
           // Pass through unchanged.
           // &#xA9; -- copyright symbol,   for example.
           //
           // The -1 is a bug fix from Rob Laveaux. It keeps
           // an overflow from happening if there is no ';'.
           // There are actually 2 ways to exit this loop -
           // while fails (  error case ) and break (  semicolon found ).
           // However,   there is no mechanism (  currently ) for
           // this function to return an error.
           while (   i<(  int )str.length(   )-1  )
           {
           outString->append(   str.c_str(   ) + i,   1  );
           ++i;
           if (   str[i] == ';'  )
           break;
           }
           }
           else if (   c == '&'  )
           {
           outString->append(   entity[0].str,   entity[0].strLength  );
           ++i;
           }
           else if (   c == '<'  )
           {
           outString->append(   entity[1].str,   entity[1].strLength  );
           ++i;
           }
           else if (   c == '>'  )
           {
           outString->append(   entity[2].str,   entity[2].strLength  );
           ++i;
           }
           else if (   c == '\"'  )
           {
           outString->append(   entity[3].str,   entity[3].strLength  );
           ++i;
           }
           else if (   c == '\''  )
           {
           outString->append(   entity[4].str,   entity[4].strLength  );
           ++i;
           }
           else if (   c < 32  )
           {
           // Easy pass at non-alpha/numeric/symbol
           // Below 32 is symbolic.
           char buf[ 32 ];
          
           #if defined(  TIXML_SNPRINTF )
           TIXML_SNPRINTF(   buf,   sizeof(  buf ),   "&#x%02X;",   (  unsigned ) (   c & 0xff  )  );
           #else
           sprintf(   buf,   "&#x%02X;",   (  unsigned ) (   c & 0xff  )  );
           #endif
          
           //*ME: warning C4267: convert 'size_t' to 'int'
           //*ME: Int-Cast to make compiler happy ...
           outString->append(   buf,   (  int )strlen(   buf  )  );
           ++i;
           }
           else
           {
           //char realc = (  char ) c;
           //outString->append(   &realc,   1  );
           *outString += (  char ) c; // somewhat more efficient function call.
           ++i;
           }
           }
          }
          
          
          TiXmlNode::TiXmlNode(   NodeType _type  ) : TiXmlBase(   )
          {
           parent = 0;
           type = _type;
           firstChild = 0;
           lastChild = 0;
           prev = 0;
           next = 0;
          }
          
          
          TiXmlNode::~TiXmlNode(   )
          {
           TiXmlNode* node = firstChild;
           TiXmlNode* temp = 0;
          
           while (   node  )
           {
           temp = node;
           node = node->next;
           delete temp;
           }
          }
          
          
          void TiXmlNode::CopyTo(   TiXmlNode* target  ) const
          {
           target->SetValue (  value.c_str(   )  );
           target->userData = userData;
          }
          
          
          void TiXmlNode::Clear(   )
          {
           TiXmlNode* node = firstChild;
           TiXmlNode* temp = 0;
          
           while (   node  )
           {
           temp = node;
           node = node->next;
           delete temp;
           }
          
           firstChild = 0;
           lastChild = 0;
          }
          
          
          TiXmlNode* TiXmlNode::LinkEndChild(   TiXmlNode* node  )
          {
           assert(   node->parent == 0 || node->parent == this  );
           assert(   node->GetDocument(   ) == 0 || node->GetDocument(   ) == this->GetDocument(   )  );
          
           if (   node->Type(   ) == TiXmlNode::DOCUMENT  )
           {
           delete node;
           if (   GetDocument(   )  ) GetDocument(   )->SetError(   TIXML_ERROR_DOCUMENT_TOP_ONLY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return 0;
           }
          
           node->parent = this;
          
           node->prev = lastChild;
           node->next = 0;
          
           if (   lastChild  )
           lastChild->next = node;
           else
           firstChild = node; // it was an empty list.
          
           lastChild = node;
           return node;
          }
          
          
          TiXmlNode* TiXmlNode::InsertEndChild(   const TiXmlNode& addThis  )
          {
           if (   addThis.Type(   ) == TiXmlNode::DOCUMENT  )
           {
           if (   GetDocument(   )  ) GetDocument(   )->SetError(   TIXML_ERROR_DOCUMENT_TOP_ONLY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return 0;
           }
           TiXmlNode* node = addThis.Clone(   );
           if (   !node  )
           return 0;
          
           return LinkEndChild(   node  );
          }
          
          
          TiXmlNode* TiXmlNode::InsertBeforeChild(   TiXmlNode* beforeThis,   const TiXmlNode& addThis  )
          {
           if (   !beforeThis || beforeThis->parent != this  ) {
           return 0;
           }
           if (   addThis.Type(   ) == TiXmlNode::DOCUMENT  )
           {
           if (   GetDocument(   )  ) GetDocument(   )->SetError(   TIXML_ERROR_DOCUMENT_TOP_ONLY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return 0;
           }
          
           TiXmlNode* node = addThis.Clone(   );
           if (   !node  )
           return 0;
           node->parent = this;
          
           node->next = beforeThis;
           node->prev = beforeThis->prev;
           if (   beforeThis->prev  )
           {
           beforeThis->prev->next = node;
           }
           else
           {
           assert(   firstChild == beforeThis  );
           firstChild = node;
           }
           beforeThis->prev = node;
           return node;
          }
          
          
          TiXmlNode* TiXmlNode::InsertAfterChild(   TiXmlNode* afterThis,   const TiXmlNode& addThis  )
          {
           if (   !afterThis || afterThis->parent != this  ) {
           return 0;
           }
           if (   addThis.Type(   ) == TiXmlNode::DOCUMENT  )
           {
           if (   GetDocument(   )  ) GetDocument(   )->SetError(   TIXML_ERROR_DOCUMENT_TOP_ONLY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return 0;
           }
          
           TiXmlNode* node = addThis.Clone(   );
           if (   !node  )
           return 0;
           node->parent = this;
          
           node->prev = afterThis;
           node->next = afterThis->next;
           if (   afterThis->next  )
           {
           afterThis->next->prev = node;
           }
           else
           {
           assert(   lastChild == afterThis  );
           lastChild = node;
           }
           afterThis->next = node;
           return node;
          }
          
          
          TiXmlNode* TiXmlNode::ReplaceChild(   TiXmlNode* replaceThis,   const TiXmlNode& withThis  )
          {
           if (   replaceThis->parent != this  )
           return 0;
          
           TiXmlNode* node = withThis.Clone(   );
           if (   !node  )
           return 0;
          
           node->next = replaceThis->next;
           node->prev = replaceThis->prev;
          
           if (   replaceThis->next  )
           replaceThis->next->prev = node;
           else
           lastChild = node;
          
           if (   replaceThis->prev  )
           replaceThis->prev->next = node;
           else
           firstChild = node;
          
           delete replaceThis;
           node->parent = this;
           return node;
          }
          
          
          bool TiXmlNode::RemoveChild(   TiXmlNode* removeThis  )
          {
           if (   removeThis->parent != this  )
           {
           assert(   0  );
           return false;
           }
          
           if (   removeThis->next  )
           removeThis->next->prev = removeThis->prev;
           else
           lastChild = removeThis->prev;
          
           if (   removeThis->prev  )
           removeThis->prev->next = removeThis->next;
           else
           firstChild = removeThis->next;
          
           delete removeThis;
           return true;
          }
          
          const TiXmlNode* TiXmlNode::FirstChild(   const char * _value  ) const
          {
           const TiXmlNode* node;
           for (   node = firstChild; node; node = node->next  )
           {
           if (   strcmp(   node->Value(   ),   _value  ) == 0  )
           return node;
           }
           return 0;
          }
          
          
          const TiXmlNode* TiXmlNode::LastChild(   const char * _value  ) const
          {
           const TiXmlNode* node;
           for (   node = lastChild; node; node = node->prev  )
           {
           if (   strcmp(   node->Value(   ),   _value  ) == 0  )
           return node;
           }
           return 0;
          }
          
          
          const TiXmlNode* TiXmlNode::IterateChildren(   const TiXmlNode* previous  ) const
          {
           if (   !previous  )
           {
           return FirstChild(   );
           }
           else
           {
           assert(   previous->parent == this  );
           return previous->NextSibling(   );
           }
          }
          
          
          const TiXmlNode* TiXmlNode::IterateChildren(   const char * val,   const TiXmlNode* previous  ) const
          {
           if (   !previous  )
           {
           return FirstChild(   val  );
           }
           else
           {
           assert(   previous->parent == this  );
           return previous->NextSibling(   val  );
           }
          }
          
          
          const TiXmlNode* TiXmlNode::NextSibling(   const char * _value  ) const
          {
           const TiXmlNode* node;
           for (   node = next; node; node = node->next  )
           {
           if (   strcmp(   node->Value(   ),   _value  ) == 0  )
           return node;
           }
           return 0;
          }
          
          
          const TiXmlNode* TiXmlNode::PreviousSibling(   const char * _value  ) const
          {
           const TiXmlNode* node;
           for (   node = prev; node; node = node->prev  )
           {
           if (   strcmp(   node->Value(   ),   _value  ) == 0  )
           return node;
           }
           return 0;
          }
          
          
          void TiXmlElement::RemoveAttribute(   const char * name  )
          {
           #ifdef TIXML_USE_STL
           TIXML_STRING str(   name  );
           TiXmlAttribute* node = attributeSet.Find(   str  );
           #else
           TiXmlAttribute* node = attributeSet.Find(   name  );
           #endif
           if (   node  )
           {
           attributeSet.Remove(   node  );
           delete node;
           }
          }
          
          const TiXmlElement* TiXmlNode::FirstChildElement(   ) const
          {
           const TiXmlNode* node;
          
           for (   node = FirstChild(   );
           node;
           node = node->NextSibling(   )  )
           {
           if (   node->ToElement(   )  )
           return node->ToElement(   );
           }
           return 0;
          }
          
          
          const TiXmlElement* TiXmlNode::FirstChildElement(   const char * _value  ) const
          {
           const TiXmlNode* node;
          
           for (   node = FirstChild(   _value  );
           node;
           node = node->NextSibling(   _value  )  )
           {
           if (   node->ToElement(   )  )
           return node->ToElement(   );
           }
           return 0;
          }
          
          
          const TiXmlElement* TiXmlNode::NextSiblingElement(   ) const
          {
           const TiXmlNode* node;
          
           for (   node = NextSibling(   );
           node;
           node = node->NextSibling(   )  )
           {
           if (   node->ToElement(   )  )
           return node->ToElement(   );
           }
           return 0;
          }
          
          
          const TiXmlElement* TiXmlNode::NextSiblingElement(   const char * _value  ) const
          {
           const TiXmlNode* node;
          
           for (   node = NextSibling(   _value  );
           node;
           node = node->NextSibling(   _value  )  )
           {
           if (   node->ToElement(   )  )
           return node->ToElement(   );
           }
           return 0;
          }
          
          
          const TiXmlDocument* TiXmlNode::GetDocument(   ) const
          {
           const TiXmlNode* node;
          
           for(   node = this; node; node = node->parent  )
           {
           if (   node->ToDocument(   )  )
           return node->ToDocument(   );
           }
           return 0;
          }
          
          
          TiXmlElement::TiXmlElement (  const char * _value )
           : TiXmlNode(   TiXmlNode::ELEMENT  )
          {
           firstChild = lastChild = 0;
           value = _value;
          }
          
          
          #ifdef TIXML_USE_STL
          TiXmlElement::TiXmlElement(   const std::string& _value  )
           : TiXmlNode(   TiXmlNode::ELEMENT  )
          {
           firstChild = lastChild = 0;
           value = _value;
          }
          #endif
          
          
          TiXmlElement::TiXmlElement(   const TiXmlElement& copy )
           : TiXmlNode(   TiXmlNode::ELEMENT  )
          {
           firstChild = lastChild = 0;
           copy.CopyTo(   this  );
          }
          
          
          void TiXmlElement::operator=(   const TiXmlElement& base  )
          {
           ClearThis(   );
           base.CopyTo(   this  );
          }
          
          
          TiXmlElement::~TiXmlElement(   )
          {
           ClearThis(   );
          }
          
          
          void TiXmlElement::ClearThis(   )
          {
           Clear(   );
           while(   attributeSet.First(   )  )
           {
           TiXmlAttribute* node = attributeSet.First(   );
           attributeSet.Remove(   node  );
           delete node;
           }
          }
          
          
          const char* TiXmlElement::Attribute(   const char* name  ) const
          {
           const TiXmlAttribute* node = attributeSet.Find(   name  );
           if (   node  )
           return node->Value(   );
           return 0;
          }
          
          
          #ifdef TIXML_USE_STL
          const std::string* TiXmlElement::Attribute(   const std::string& name  ) const
          {
           const TiXmlAttribute* node = attributeSet.Find(   name  );
           if (   node  )
           return &node->ValueStr(   );
           return 0;
          }
          #endif
          
          
          const char* TiXmlElement::Attribute(   const char* name,   int* i  ) const
          {
           const char* s = Attribute(   name  );
           if (   i  )
           {
           if (   s  ) {
           *i = atoi(   s  );
           }
           else {
           *i = 0;
           }
           }
           return s;
          }
          
          
          #ifdef TIXML_USE_STL
          const std::string* TiXmlElement::Attribute(   const std::string& name,   int* i  ) const
          {
           const std::string* s = Attribute(   name  );
           if (   i  )
           {
           if (   s  ) {
           *i = atoi(   s->c_str(   )  );
           }
           else {
           *i = 0;
           }
           }
           return s;
          }
          #endif
          
          
          const char* TiXmlElement::Attribute(   const char* name,   double* d  ) const
          {
           const char* s = Attribute(   name  );
           if (   d  )
           {
           if (   s  ) {
           *d = atof(   s  );
           }
           else {
           *d = 0;
           }
           }
           return s;
          }
          
          
          #ifdef TIXML_USE_STL
          const std::string* TiXmlElement::Attribute(   const std::string& name,   double* d  ) const
          {
           const std::string* s = Attribute(   name  );
           if (   d  )
           {
           if (   s  ) {
           *d = atof(   s->c_str(   )  );
           }
           else {
           *d = 0;
           }
           }
           return s;
          }
          #endif
          
          
          int TiXmlElement::QueryIntAttribute(   const char* name,   int* ival  ) const
          {
           const TiXmlAttribute* node = attributeSet.Find(   name  );
           if (   !node  )
           return TIXML_NO_ATTRIBUTE;
           return node->QueryIntValue(   ival  );
          }
          
          
          #ifdef TIXML_USE_STL
          int TiXmlElement::QueryIntAttribute(   const std::string& name,   int* ival  ) const
          {
           const TiXmlAttribute* node = attributeSet.Find(   name  );
           if (   !node  )
           return TIXML_NO_ATTRIBUTE;
           return node->QueryIntValue(   ival  );
          }
          #endif
          
          
          int TiXmlElement::QueryDoubleAttribute(   const char* name,   double* dval  ) const
          {
           const TiXmlAttribute* node = attributeSet.Find(   name  );
           if (   !node  )
           return TIXML_NO_ATTRIBUTE;
           return node->QueryDoubleValue(   dval  );
          }
          
          
          #ifdef TIXML_USE_STL
          int TiXmlElement::QueryDoubleAttribute(   const std::string& name,   double* dval  ) const
          {
           const TiXmlAttribute* node = attributeSet.Find(   name  );
           if (   !node  )
           return TIXML_NO_ATTRIBUTE;
           return node->QueryDoubleValue(   dval  );
          }
          #endif
          
          
          void TiXmlElement::SetAttribute(   const char * name,   int val  )
          {
           char buf[64];
           #if defined(  TIXML_SNPRINTF )
           TIXML_SNPRINTF(   buf,   sizeof(  buf ),   "%d",   val  );
           #else
           sprintf(   buf,   "%d",   val  );
           #endif
           SetAttribute(   name,   buf  );
          }
          
          
          #ifdef TIXML_USE_STL
          void TiXmlElement::SetAttribute(   const std::string& name,   int val  )
          {
           std::ostringstream oss;
           oss << val;
           SetAttribute(   name,   oss.str(   )  );
          }
          #endif
          
          
          void TiXmlElement::SetDoubleAttribute(   const char * name,   double val  )
          {
           char buf[256];
           #if defined(  TIXML_SNPRINTF )
           TIXML_SNPRINTF(   buf,   sizeof(  buf ),   "%f",   val  );
           #else
           sprintf(   buf,   "%f",   val  );
           #endif
           SetAttribute(   name,   buf  );
          }
          
          
          void TiXmlElement::SetAttribute(   const char * cname,   const char * cvalue  )
          {
           #ifdef TIXML_USE_STL
           TIXML_STRING _name(   cname  );
           TIXML_STRING _value(   cvalue  );
           #else
           const char* _name = cname;
           const char* _value = cvalue;
           #endif
          
           TiXmlAttribute* node = attributeSet.Find(   _name  );
           if (   node  )
           {
           node->SetValue(   _value  );
           return;
           }
          
           TiXmlAttribute* attrib = new TiXmlAttribute(   cname,   cvalue  );
           if (   attrib  )
           {
           attributeSet.Add(   attrib  );
           }
           else
           {
           TiXmlDocument* document = GetDocument(   );
           if (   document  ) document->SetError(   TIXML_ERROR_OUT_OF_MEMORY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           }
          }
          
          
          #ifdef TIXML_USE_STL
          void TiXmlElement::SetAttribute(   const std::string& name,   const std::string& _value  )
          {
           TiXmlAttribute* node = attributeSet.Find(   name  );
           if (   node  )
           {
           node->SetValue(   _value  );
           return;
           }
          
           TiXmlAttribute* attrib = new TiXmlAttribute(   name,   _value  );
           if (   attrib  )
           {
           attributeSet.Add(   attrib  );
           }
           else
           {
           TiXmlDocument* document = GetDocument(   );
           if (   document  ) document->SetError(   TIXML_ERROR_OUT_OF_MEMORY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           }
          }
          #endif
          
          
          void TiXmlElement::Print(   FILE* cfile,   int depth  ) const
          {
           int i;
           assert(   cfile  );
           for (   i=0; i<depth; i++  ) {
           fprintf(   cfile,   " "  );
           }
          
           fprintf(   cfile,   "<%s",   value.c_str(   )  );
          
           const TiXmlAttribute* attrib;
           for (   attrib = attributeSet.First(   ); attrib; attrib = attrib->Next(   )  )
           {
           fprintf(   cfile,   " "  );
           attrib->Print(   cfile,   depth  );
           }
          
           // There are 3 different formatting approaches:
           // 1 ) An element without children is printed as a <foo /> node
           // 2 ) An element with only a text child is printed as <foo> text </foo>
           // 3 ) An element with children is printed on multiple lines.
           TiXmlNode* node;
           if (   !firstChild  )
           {
           fprintf(   cfile,   " />"  );
           }
           else if (   firstChild == lastChild && firstChild->ToText(   )  )
           {
           fprintf(   cfile,   ">"  );
           firstChild->Print(   cfile,   depth + 1  );
           fprintf(   cfile,   "</%s>",   value.c_str(   )  );
           }
           else
           {
           fprintf(   cfile,   ">"  );
          
           for (   node = firstChild; node; node=node->NextSibling(   )  )
           {
           if (   !node->ToText(   )  )
           {
           fprintf(   cfile,   "\n"  );
           }
           node->Print(   cfile,   depth+1  );
           }
           fprintf(   cfile,   "\n"  );
           for(   i=0; i<depth; ++i  ) {
           fprintf(   cfile,   " "  );
           }
           fprintf(   cfile,   "</%s>",   value.c_str(   )  );
           }
          }
          
          
          void TiXmlElement::CopyTo(   TiXmlElement* target  ) const
          {
           // superclass:
           TiXmlNode::CopyTo(   target  );
          
           // Element class:
           // Clone the attributes,   then clone the children.
           const TiXmlAttribute* attribute = 0;
           for(   attribute = attributeSet.First(   );
           attribute;
           attribute = attribute->Next(   )  )
           {
           target->SetAttribute(   attribute->Name(   ),   attribute->Value(   )  );
           }
          
           TiXmlNode* node = 0;
           for (   node = firstChild; node; node = node->NextSibling(   )  )
           {
           target->LinkEndChild(   node->Clone(   )  );
           }
          }
          
          bool TiXmlElement::Accept(   TiXmlVisitor* visitor  ) const
          {
           if (   visitor->VisitEnter(   *this,   attributeSet.First(   )  )  )
           {
           for (   const TiXmlNode* node=FirstChild(   ); node; node=node->NextSibling(   )  )
           {
           if (   !node->Accept(   visitor  )  )
           break;
           }
           }
           return visitor->VisitExit(   *this  );
          }
          
          
          TiXmlNode* TiXmlElement::Clone(   ) const
          {
           TiXmlElement* clone = new TiXmlElement(   Value(   )  );
           if (   !clone  )
           return 0;
          
           CopyTo(   clone  );
           return clone;
          }
          
          
          const char* TiXmlElement::GetText(   ) const
          {
           const TiXmlNode* child = this->FirstChild(   );
           if (   child  ) {
           const TiXmlText* childText = child->ToText(   );
           if (   childText  ) {
           return childText->Value(   );
           }
           }
           return 0;
          }
          
          
          TiXmlDocument::TiXmlDocument(   ) : TiXmlNode(   TiXmlNode::DOCUMENT  )
          {
           tabsize = 4;
           useMicrosoftBOM = false;
           ClearError(   );
          }
          
          TiXmlDocument::TiXmlDocument(   const char * documentName  ) : TiXmlNode(   TiXmlNode::DOCUMENT  )
          {
           tabsize = 4;
           useMicrosoftBOM = false;
           value = documentName;
           ClearError(   );
          }
          
          
          #ifdef TIXML_USE_STL
          TiXmlDocument::TiXmlDocument(   const std::string& documentName  ) : TiXmlNode(   TiXmlNode::DOCUMENT  )
          {
           tabsize = 4;
           useMicrosoftBOM = false;
           value = documentName;
           ClearError(   );
          }
          #endif
          
          
          TiXmlDocument::TiXmlDocument(   const TiXmlDocument& copy  ) : TiXmlNode(   TiXmlNode::DOCUMENT  )
          {
           copy.CopyTo(   this  );
          }
          
          
          void TiXmlDocument::operator=(   const TiXmlDocument& copy  )
          {
           Clear(   );
           copy.CopyTo(   this  );
          }
          
          
          bool TiXmlDocument::LoadFile(   TiXmlEncoding encoding  )
          {
           // See STL_STRING_BUG below.
           //StringToBuffer buf(   value  );
          
           return LoadFile(   Value(   ),   encoding  );
          }
          
          
          bool TiXmlDocument::SaveFile(   ) const
          {
           // See STL_STRING_BUG below.
          // StringToBuffer buf(   value  );
          //
          // if (   buf.buffer && SaveFile(   buf.buffer  )  )
          // return true;
          //
          // return false;
           return SaveFile(   Value(   )  );
          }
          
          bool TiXmlDocument::LoadFile(   const char* _filename,   TiXmlEncoding encoding  )
          {
           // There was a really terrifying little bug here. The code:
           // value = filename
           // in the STL case,   cause the assignment method of the std::string to
           // be called. What is strange,   is that the std::string had the same
           // address as it's c_str(   ) method,   and so bad things happen. Looks
           // like a bug in the Microsoft STL implementation.
           // Add an extra string to avoid the crash.
           TIXML_STRING filename(   _filename  );
           value = filename;
          
           // reading in binary mode so that tinyxml can normalize the EOL
           FILE* file = fopen(   value.c_str (   ),   "rb"  );
          
           if (   file  )
           {
           bool result = LoadFile(   file,   encoding  );
           fclose(   file  );
           return result;
           }
           else
           {
           SetError(   TIXML_ERROR_OPENING_FILE,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return false;
           }
          }
          
          bool TiXmlDocument::LoadFile(   FILE* file,   TiXmlEncoding encoding  )
          {
           if (   !file  )
           {
           SetError(   TIXML_ERROR_OPENING_FILE,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return false;
           }
          
           // Delete the existing data:
           Clear(   );
           location.Clear(   );
          
           // Get the file size,   so we can pre-allocate the string. HUGE speed impact.
           long length = 0;
           fseek(   file,   0,   SEEK_END  );
           length = ftell(   file  );
           fseek(   file,   0,   SEEK_SET  );
          
           // Strange case,   but good to handle up front.
           if (   length == 0  )
           {
           SetError(   TIXML_ERROR_DOCUMENT_EMPTY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return false;
           }
          
           // If we have a file,   assume it is all one big XML file,   and read it in.
           // The document parser may decide the document ends sooner than the entire file,   however.
           TIXML_STRING data;
           data.reserve(   length  );
          
           // Subtle bug here. TinyXml did use fgets. But from the XML spec:
           // 2.11 End-of-Line Handling
           // <snip>
           // <quote>
           // ...the XML processor MUST behave as if it normalized all line breaks in external
           // parsed entities (  including the document entity ) on input,   before parsing,   by translating
           // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
           // a single #xA character.
           // </quote>
           //
           // It is not clear fgets does that,   and certainly isn't clear it works cross platform.
           // Generally,   you expect fgets to translate from the convention of the OS to the c/unix
           // convention,   and not work generally.
          
           /*
           while(   fgets(   buf,   sizeof(  buf ),   file  )  )
           {
           data += buf;
           }
           */
          
           char* buf = new char[ length+1 ];
           buf[0] = 0;
          
           if (   fread(   buf,   length,   1,   file  ) != 1  ) {
           delete [] buf;
           SetError(   TIXML_ERROR_OPENING_FILE,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return false;
           }
          
           const char* lastPos = buf;
           const char* p = buf;
          
           buf[length] = 0;
           while(   *p  ) {
           assert(   p < (  buf+length )  );
           if (   *p == 0xa  ) {
           // Newline character. No special rules for this. Append all the characters
           // since the last string,   and include the newline.
           data.append(   lastPos,   (  p-lastPos+1 )  ); // append,   include the newline
           ++p; // move past the newline
           lastPos = p; // and point to the new buffer (  may be 0 )
           assert(   p <= (  buf+length )  );
           }
           else if (   *p == 0xd  ) {
           // Carriage return. Append what we have so far,   then
           // handle moving forward in the buffer.
           if (   (  p-lastPos ) > 0  ) {
           data.append(   lastPos,   p-lastPos  ); // do not add the CR
           }
           data += (  char )0xa; // a proper newline
          
           if (   *(  p+1 ) == 0xa  ) {
           // Carriage return - new line sequence
           p += 2;
           lastPos = p;
           assert(   p <= (  buf+length )  );
           }
           else {
           // it was followed by something else...that is presumably characters again.
           ++p;
           lastPos = p;
           assert(   p <= (  buf+length )  );
           }
           }
           else {
           ++p;
           }
           }
           // Handle any left over characters.
           if (   p-lastPos  ) {
           data.append(   lastPos,   p-lastPos  );
           }
           delete [] buf;
           buf = 0;
          
           Parse(   data.c_str(   ),   0,   encoding  );
          
           if (   Error(   )  )
           return false;
           else
           return true;
          }
          
          
          bool TiXmlDocument::SaveFile(   const char * filename  ) const
          {
           // The old c stuff lives on...
           FILE* fp = fopen(   filename,   "w"  );
           if (   fp  )
           {
           bool result = SaveFile(   fp  );
           fclose(   fp  );
           return result;
           }
           return false;
          }
          
          
          bool TiXmlDocument::SaveFile(   FILE* fp  ) const
          {
           if (   useMicrosoftBOM  )
           {
           const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
           const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
           const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
          
           fputc(   TIXML_UTF_LEAD_0,   fp  );
           fputc(   TIXML_UTF_LEAD_1,   fp  );
           fputc(   TIXML_UTF_LEAD_2,   fp  );
           }
           Print(   fp,   0  );
           return (  ferror(  fp ) == 0 );
          }
          
          
          void TiXmlDocument::CopyTo(   TiXmlDocument* target  ) const
          {
           TiXmlNode::CopyTo(   target  );
          
           target->error = error;
           target->errorDesc = errorDesc.c_str (   );
          
           TiXmlNode* node = 0;
           for (   node = firstChild; node; node = node->NextSibling(   )  )
           {
           target->LinkEndChild(   node->Clone(   )  );
           }
          }
          
          
          TiXmlNode* TiXmlDocument::Clone(   ) const
          {
           TiXmlDocument* clone = new TiXmlDocument(   );
           if (   !clone  )
           return 0;
          
           CopyTo(   clone  );
           return clone;
          }
          
          
          void TiXmlDocument::Print(   FILE* cfile,   int depth  ) const
          {
           assert(   cfile  );
           for (   const TiXmlNode* node=FirstChild(   ); node; node=node->NextSibling(   )  )
           {
           node->Print(   cfile,   depth  );
           fprintf(   cfile,   "\n"  );
           }
          }
          
          
          bool TiXmlDocument::Accept(   TiXmlVisitor* visitor  ) const
          {
           if (   visitor->VisitEnter(   *this  )  )
           {
           for (   const TiXmlNode* node=FirstChild(   ); node; node=node->NextSibling(   )  )
           {
           if (   !node->Accept(   visitor  )  )
           break;
           }
           }
           return visitor->VisitExit(   *this  );
          }
          
          
          const TiXmlAttribute* TiXmlAttribute::Next(   ) const
          {
           // We are using knowledge of the sentinel. The sentinel
           // have a value or name.
           if (   next->value.empty(   ) && next->name.empty(   )  )
           return 0;
           return next;
          }
          
          /*
          TiXmlAttribute* TiXmlAttribute::Next(   )
          {
           // We are using knowledge of the sentinel. The sentinel
           // have a value or name.
           if (   next->value.empty(   ) && next->name.empty(   )  )
           return 0;
           return next;
          }
          */
          
          const TiXmlAttribute* TiXmlAttribute::Previous(   ) const
          {
           // We are using knowledge of the sentinel. The sentinel
           // have a value or name.
           if (   prev->value.empty(   ) && prev->name.empty(   )  )
           return 0;
           return prev;
          }
          
          /*
          TiXmlAttribute* TiXmlAttribute::Previous(   )
          {
           // We are using knowledge of the sentinel. The sentinel
           // have a value or name.
           if (   prev->value.empty(   ) && prev->name.empty(   )  )
           return 0;
           return prev;
          }
          */
          
          void TiXmlAttribute::Print(   FILE* cfile,   int /*depth*/,   TIXML_STRING* str  ) const
          {
           TIXML_STRING n,   v;
          
           PutString(   name,   &n  );
           PutString(   value,   &v  );
          
           if (  value.find (  '\"' ) == TIXML_STRING::npos ) {
           if (   cfile  ) {
           fprintf (  cfile,   "%s=\"%s\"",   n.c_str(   ),   v.c_str(   )  );
           }
           if (   str  ) {
           (  *str ) += n; (  *str ) += "=\""; (  *str ) += v; (  *str ) += "\"";
           }
           }
           else {
           if (   cfile  ) {
           fprintf (  cfile,   "%s='%s'",   n.c_str(   ),   v.c_str(   )  );
           }
           if (   str  ) {
           (  *str ) += n; (  *str ) += "='"; (  *str ) += v; (  *str ) += "'";
           }
           }
          }
          
          
          int TiXmlAttribute::QueryIntValue(   int* ival  ) const
          {
           if (   sscanf(   value.c_str(   ),   "%d",   ival  ) == 1  )
           return TIXML_SUCCESS;
           return TIXML_WRONG_TYPE;
          }
          
          int TiXmlAttribute::QueryDoubleValue(   double* dval  ) const
          {
           if (   sscanf(   value.c_str(   ),   "%lf",   dval  ) == 1  )
           return TIXML_SUCCESS;
           return TIXML_WRONG_TYPE;
          }
          
          void TiXmlAttribute::SetIntValue(   int _value  )
          {
           char buf [64];
           #if defined(  TIXML_SNPRINTF )
           TIXML_SNPRINTF(  buf,   sizeof(  buf ),   "%d",   _value );
           #else
           sprintf (  buf,   "%d",   _value );
           #endif
           SetValue (  buf );
          }
          
          void TiXmlAttribute::SetDoubleValue(   double _value  )
          {
           char buf [256];
           #if defined(  TIXML_SNPRINTF )
           TIXML_SNPRINTF(   buf,   sizeof(  buf ),   "%lf",   _value );
           #else
           sprintf (  buf,   "%lf",   _value );
           #endif
           SetValue (  buf );
          }
          
          int TiXmlAttribute::IntValue(   ) const
          {
           return atoi (  value.c_str (   ) );
          }
          
          double TiXmlAttribute::DoubleValue(   ) const
          {
           return atof (  value.c_str (   ) );
          }
          
          
          TiXmlComment::TiXmlComment(   const TiXmlComment& copy  ) : TiXmlNode(   TiXmlNode::COMMENT  )
          {
           copy.CopyTo(   this  );
          }
          
          
          void TiXmlComment::operator=(   const TiXmlComment& base  )
          {
           Clear(   );
           base.CopyTo(   this  );
          }
          
          
          void TiXmlComment::Print(   FILE* cfile,   int depth  ) const
          {
           assert(   cfile  );
           for (   int i=0; i<depth; i++  )
           {
           fprintf(   cfile,   " "  );
           }
           fprintf(   cfile,   "<!--%s-->",   value.c_str(   )  );
          }
          
          
          void TiXmlComment::CopyTo(   TiXmlComment* target  ) const
          {
           TiXmlNode::CopyTo(   target  );
          }
          
          
          bool TiXmlComment::Accept(   TiXmlVisitor* visitor  ) const
          {
           return visitor->Visit(   *this  );
          }
          
          
          TiXmlNode* TiXmlComment::Clone(   ) const
          {
           TiXmlComment* clone = new TiXmlComment(   );
          
           if (   !clone  )
           return 0;
          
           CopyTo(   clone  );
           return clone;
          }
          
          
          void TiXmlText::Print(   FILE* cfile,   int depth  ) const
          {
           assert(   cfile  );
           if (   cdata  )
           {
           int i;
           fprintf(   cfile,   "\n"  );
           for (   i=0; i<depth; i++  ) {
           fprintf(   cfile,   " "  );
           }
           fprintf(   cfile,   "<![CDATA[%s]]>\n",   value.c_str(   )  ); // unformatted output
           }
           else
           {
           TIXML_STRING buffer;
           PutString(   value,   &buffer  );
           fprintf(   cfile,   "%s",   buffer.c_str(   )  );
           }
          }
          
          
          void TiXmlText::CopyTo(   TiXmlText* target  ) const
          {
           TiXmlNode::CopyTo(   target  );
           target->cdata = cdata;
          }
          
          
          bool TiXmlText::Accept(   TiXmlVisitor* visitor  ) const
          {
           return visitor->Visit(   *this  );
          }
          
          
          TiXmlNode* TiXmlText::Clone(   ) const
          {
           TiXmlText* clone = 0;
           clone = new TiXmlText(   ""  );
          
           if (   !clone  )
           return 0;
          
           CopyTo(   clone  );
           return clone;
          }
          
          
          TiXmlDeclaration::TiXmlDeclaration(   const char * _version,  
           const char * _encoding,  
           const char * _standalone  )
           : TiXmlNode(   TiXmlNode::DECLARATION  )
          {
           version = _version;
           encoding = _encoding;
           standalone = _standalone;
          }
          
          
          #ifdef TIXML_USE_STL
          TiXmlDeclaration::TiXmlDeclaration(   const std::string& _version,  
           const std::string& _encoding,  
           const std::string& _standalone  )
           : TiXmlNode(   TiXmlNode::DECLARATION  )
          {
           version = _version;
           encoding = _encoding;
           standalone = _standalone;
          }
          #endif
          
          
          TiXmlDeclaration::TiXmlDeclaration(   const TiXmlDeclaration& copy  )
           : TiXmlNode(   TiXmlNode::DECLARATION  )
          {
           copy.CopyTo(   this  );
          }
          
          
          void TiXmlDeclaration::operator=(   const TiXmlDeclaration& copy  )
          {
           Clear(   );
           copy.CopyTo(   this  );
          }
          
          
          void TiXmlDeclaration::Print(   FILE* cfile,   int /*depth*/,   TIXML_STRING* str  ) const
          {
           if (   cfile  ) fprintf(   cfile,   "<?xml "  );
           if (   str  ) (  *str ) += "<?xml ";
          
           if (   !version.empty(   )  ) {
           if (   cfile  ) fprintf (  cfile,   "version=\"%s\" ",   version.c_str (   ) );
           if (   str  ) { (  *str ) += "version=\""; (  *str ) += version; (  *str ) += "\" "; }
           }
           if (   !encoding.empty(   )  ) {
           if (   cfile  ) fprintf (  cfile,   "encoding=\"%s\" ",   encoding.c_str (   ) );
           if (   str  ) { (  *str ) += "encoding=\""; (  *str ) += encoding; (  *str ) += "\" "; }
           }
           if (   !standalone.empty(   )  ) {
           if (   cfile  ) fprintf (  cfile,   "standalone=\"%s\" ",   standalone.c_str (   ) );
           if (   str  ) { (  *str ) += "standalone=\""; (  *str ) += standalone; (  *str ) += "\" "; }
           }
           if (   cfile  ) fprintf(   cfile,   "?>"  );
           if (   str  ) (  *str ) += "?>";
          }
          
          
          void TiXmlDeclaration::CopyTo(   TiXmlDeclaration* target  ) const
          {
           TiXmlNode::CopyTo(   target  );
          
           target->version = version;
           target->encoding = encoding;
           target->standalone = standalone;
          }
          
          
          bool TiXmlDeclaration::Accept(   TiXmlVisitor* visitor  ) const
          {
           return visitor->Visit(   *this  );
          }
          
          
          TiXmlNode* TiXmlDeclaration::Clone(   ) const
          {
           TiXmlDeclaration* clone = new TiXmlDeclaration(   );
          
           if (   !clone  )
           return 0;
          
           CopyTo(   clone  );
           return clone;
          }
          
          
          void TiXmlUnknown::Print(   FILE* cfile,   int depth  ) const
          {
           for (   int i=0; i<depth; i++  )
           fprintf(   cfile,   " "  );
           fprintf(   cfile,   "<%s>",   value.c_str(   )  );
          }
          
          
          void TiXmlUnknown::CopyTo(   TiXmlUnknown* target  ) const
          {
           TiXmlNode::CopyTo(   target  );
          }
          
          
          bool TiXmlUnknown::Accept(   TiXmlVisitor* visitor  ) const
          {
           return visitor->Visit(   *this  );
          }
          
          
          TiXmlNode* TiXmlUnknown::Clone(   ) const
          {
           TiXmlUnknown* clone = new TiXmlUnknown(   );
          
           if (   !clone  )
           return 0;
          
           CopyTo(   clone  );
           return clone;
          }
          
          
          TiXmlAttributeSet::TiXmlAttributeSet(   )
          {
           sentinel.next = &sentinel;
           sentinel.prev = &sentinel;
          }
          
          
          TiXmlAttributeSet::~TiXmlAttributeSet(   )
          {
           assert(   sentinel.next == &sentinel  );
           assert(   sentinel.prev == &sentinel  );
          }
          
          
          void TiXmlAttributeSet::Add(   TiXmlAttribute* addMe  )
          {
           #ifdef TIXML_USE_STL
           assert(   !Find(   TIXML_STRING(   addMe->Name(   )  )  )  ); // Shouldn't be multiply adding to the set.
           #else
           assert(   !Find(   addMe->Name(   )  )  ); // Shouldn't be multiply adding to the set.
           #endif
          
           addMe->next = &sentinel;
           addMe->prev = sentinel.prev;
          
           sentinel.prev->next = addMe;
           sentinel.prev = addMe;
          }
          
          void TiXmlAttributeSet::Remove(   TiXmlAttribute* removeMe  )
          {
           TiXmlAttribute* node;
          
           for(   node = sentinel.next; node != &sentinel; node = node->next  )
           {
           if (   node == removeMe  )
           {
           node->prev->next = node->next;
           node->next->prev = node->prev;
           node->next = 0;
           node->prev = 0;
           return;
           }
           }
           assert(   0  ); // we tried to remove a non-linked attribute.
          }
          
          
          #ifdef TIXML_USE_STL
          const TiXmlAttribute* TiXmlAttributeSet::Find(   const std::string& name  ) const
          {
           for(   const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next  )
           {
           if (   node->name == name  )
           return node;
           }
           return 0;
          }
          
          /*
          TiXmlAttribute* TiXmlAttributeSet::Find(   const std::string& name  )
          {
           for(   TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next  )
           {
           if (   node->name == name  )
           return node;
           }
           return 0;
          }
          */
          #endif
          
          
          const TiXmlAttribute* TiXmlAttributeSet::Find(   const char* name  ) const
          {
           for(   const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next  )
           {
           if (   strcmp(   node->name.c_str(   ),   name  ) == 0  )
           return node;
           }
           return 0;
          }
          
          /*
          TiXmlAttribute* TiXmlAttributeSet::Find(   const char* name  )
          {
           for(   TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next  )
           {
           if (   strcmp(   node->name.c_str(   ),   name  ) == 0  )
           return node;
           }
           return 0;
          }
          */
          
          #ifdef TIXML_USE_STL
          std::istream& operator>> (  std::istream & in,   TiXmlNode & base )
          {
           TIXML_STRING tag;
           tag.reserve(   8 * 1000  );
           base.StreamIn(   &in,   &tag  );
          
           base.Parse(   tag.c_str(   ),   0,   TIXML_DEFAULT_ENCODING  );
           return in;
          }
          #endif
          
          
          #ifdef TIXML_USE_STL
          std::ostream& operator<< (  std::ostream & out,   const TiXmlNode & base )
          {
           TiXmlPrinter printer;
           printer.SetStreamPrinting(   );
           base.Accept(   &printer  );
           out << printer.Str(   );
          
           return out;
          }
          
          
          std::string& operator<< (  std::string& out,   const TiXmlNode& base  )
          {
           TiXmlPrinter printer;
           printer.SetStreamPrinting(   );
           base.Accept(   &printer  );
           out.append(   printer.Str(   )  );
          
           return out;
          }
          #endif
          
          
          TiXmlHandle TiXmlHandle::FirstChild(   ) const
          {
           if (   node  )
           {
           TiXmlNode* child = node->FirstChild(   );
           if (   child  )
           return TiXmlHandle(   child  );
           }
           return TiXmlHandle(   0  );
          }
          
          
          TiXmlHandle TiXmlHandle::FirstChild(   const char * value  ) const
          {
           if (   node  )
           {
           TiXmlNode* child = node->FirstChild(   value  );
           if (   child  )
           return TiXmlHandle(   child  );
           }
           return TiXmlHandle(   0  );
          }
          
          
          TiXmlHandle TiXmlHandle::FirstChildElement(   ) const
          {
           if (   node  )
           {
           TiXmlElement* child = node->FirstChildElement(   );
           if (   child  )
           return TiXmlHandle(   child  );
           }
           return TiXmlHandle(   0  );
          }
          
          
          TiXmlHandle TiXmlHandle::FirstChildElement(   const char * value  ) const
          {
           if (   node  )
           {
           TiXmlElement* child = node->FirstChildElement(   value  );
           if (   child  )
           return TiXmlHandle(   child  );
           }
           return TiXmlHandle(   0  );
          }
          
          
          TiXmlHandle TiXmlHandle::Child(   int count  ) const
          {
           if (   node  )
           {
           int i;
           TiXmlNode* child = node->FirstChild(   );
           for (   i=0;
           child && i<count;
           child = child->NextSibling(   ),   ++i  )
           {
           // nothing
           }
           if (   child  )
           return TiXmlHandle(   child  );
           }
           return TiXmlHandle(   0  );
          }
          
          
          TiXmlHandle TiXmlHandle::Child(   const char* value,   int count  ) const
          {
           if (   node  )
           {
           int i;
           TiXmlNode* child = node->FirstChild(   value  );
           for (   i=0;
           child && i<count;
           child = child->NextSibling(   value  ),   ++i  )
           {
           // nothing
           }
           if (   child  )
           return TiXmlHandle(   child  );
           }
           return TiXmlHandle(   0  );
          }
          
          
          TiXmlHandle TiXmlHandle::ChildElement(   int count  ) const
          {
           if (   node  )
           {
           int i;
           TiXmlElement* child = node->FirstChildElement(   );
           for (   i=0;
           child && i<count;
           child = child->NextSiblingElement(   ),   ++i  )
           {
           // nothing
           }
           if (   child  )
           return TiXmlHandle(   child  );
           }
           return TiXmlHandle(   0  );
          }
          
          
          TiXmlHandle TiXmlHandle::ChildElement(   const char* value,   int count  ) const
          {
           if (   node  )
           {
           int i;
           TiXmlElement* child = node->FirstChildElement(   value  );
           for (   i=0;
           child && i<count;
           child = child->NextSiblingElement(   value  ),   ++i  )
           {
           // nothing
           }
           if (   child  )
           return TiXmlHandle(   child  );
           }
           return TiXmlHandle(   0  );
          }
          
          
          bool TiXmlPrinter::VisitEnter(   const TiXmlDocument&  )
          {
           return true;
          }
          
          bool TiXmlPrinter::VisitExit(   const TiXmlDocument&  )
          {
           return true;
          }
          
          bool TiXmlPrinter::VisitEnter(   const TiXmlElement& element,   const TiXmlAttribute* firstAttribute  )
          {
           DoIndent(   );
           buffer += "<";
           buffer += element.Value(   );
          
           for(   const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next(   )  )
           {
           buffer += " ";
           attrib->Print(   0,   0,   &buffer  );
           }
          
           if (   !element.FirstChild(   )  )
           {
           buffer += " />";
           DoLineBreak(   );
           }
           else
           {
           buffer += ">";
           if (   element.FirstChild(   )->ToText(   )
           && element.LastChild(   ) == element.FirstChild(   )
           && element.FirstChild(   )->ToText(   )->CDATA(   ) == false  )
           {
           simpleTextPrint = true;
           // no DoLineBreak(   )!
           }
           else
           {
           DoLineBreak(   );
           }
           }
           ++depth;
           return true;
          }
          
          
          bool TiXmlPrinter::VisitExit(   const TiXmlElement& element  )
          {
           --depth;
           if (   !element.FirstChild(   )  )
           {
           // nothing.
           }
           else
           {
           if (   simpleTextPrint  )
           {
           simpleTextPrint = false;
           }
           else
           {
           DoIndent(   );
           }
           buffer += "</";
           buffer += element.Value(   );
           buffer += ">";
           DoLineBreak(   );
           }
           return true;
          }
          
          
          bool TiXmlPrinter::Visit(   const TiXmlText& text  )
          {
           if (   text.CDATA(   )  )
           {
           DoIndent(   );
           buffer += "<![CDATA[";
           buffer += text.Value(   );
           buffer += "]]>";
           DoLineBreak(   );
           }
           else if (   simpleTextPrint  )
           {
           buffer += text.Value(   );
           }
           else
           {
           DoIndent(   );
           buffer += text.Value(   );
           DoLineBreak(   );
           }
           return true;
          }
          
          
          bool TiXmlPrinter::Visit(   const TiXmlDeclaration& declaration  )
          {
           DoIndent(   );
           declaration.Print(   0,   0,   &buffer  );
           DoLineBreak(   );
           return true;
          }
          
          
          bool TiXmlPrinter::Visit(   const TiXmlComment& comment  )
          {
           DoIndent(   );
           buffer += "<!--";
           buffer += comment.Value(   );
           buffer += "-->";
           DoLineBreak(   );
           return true;
          }
          
          
          bool TiXmlPrinter::Visit(   const TiXmlUnknown& unknown  )
          {
           DoIndent(   );
           buffer += "<";
           buffer += unknown.Value(   );
           buffer += ">";
           DoLineBreak(   );
           return true;
          }
          
          }

./framework/tinyxml/tinyxml.h

          /*
          www.sourceforge.net/projects/tinyxml
          Original code (  2.0 and earlier  )copyright (  c ) 2000-2006 Lee Thomason (  www.grinninglizard.com )
          
          This software is provided 'as-is',   without any express or implied
          warranty. In no event will the authors be held liable for any
          damages arising from the use of this software.
          
          Permission is granted to anyone to use this software for any
          purpose,   including commercial applications,   and to alter it and
          redistribute it freely,   subject to the following restrictions:
          
          1. The origin of this software must not be misrepresented; you must
          not claim that you wrote the original software. If you use this
          software in a product,   an acknowledgment in the product documentation
          would be appreciated but is not required.
          
          2. Altered source versions must be plainly marked as such,   and
          must not be misrepresented as being the original software.
          
          3. This notice may not be removed or altered from any source
          distribution.
          */
          
          
          #ifndef TINYXML_INCLUDED
          #define TINYXML_INCLUDED
          
          #ifdef _MSC_VER
          #pragma warning(   push  )
          #pragma warning(   disable : 4530  )
          #pragma warning(   disable : 4786  )
          #endif
          
          #include <ctype.h>
          #include <stdio.h>
          #include <stdlib.h>
          #include <string.h>
          #include <assert.h>
          
          // Help out windows:
          #if defined(   _DEBUG  ) && !defined(   DEBUG  )
          #define DEBUG
          #endif
          
          #ifdef TIXML_USE_STL
           #include <string>
           #include <iostream>
           #include <sstream>
           #define TIXML_STRING std::string
          #else
           #include "tinystr.h"
           #define TIXML_STRING TiXmlString
          #endif
          
          // Deprecated library function hell. Compilers want to use the
          // new safe versions. This probably doesn't fully address the problem,  
          // but it gets closer. There are too many compilers for me to fully
          // test. If you get compilation troubles,   undefine TIXML_SAFE
          #define TIXML_SAFE
          
          #ifdef TIXML_SAFE
           #if defined(  _MSC_VER ) && (  _MSC_VER >= 1400  )
           // Microsoft visual studio,   version 2005 and higher.
           #define TIXML_SNPRINTF _snprintf_s
           #define TIXML_SNSCANF _snscanf_s
           #elif defined(  _MSC_VER ) && (  _MSC_VER >= 1200  )
           // Microsoft visual studio,   version 6 and higher.
           //#pragma message(   "Using _sn* functions."  )
           #define TIXML_SNPRINTF _snprintf
           #define TIXML_SNSCANF _snscanf
           #elif defined(  __GNUC__ ) && (  __GNUC__ >= 3  )
           // GCC version 3 and higher.s
           //#warning(   "Using sn* functions."  )
           #define TIXML_SNPRINTF snprintf
           #define TIXML_SNSCANF snscanf
           #endif
          #endif
          namespace Ember {
          
      81  class TiXmlDocument;
      82  class TiXmlElement;
      83  class TiXmlComment;
      84  class TiXmlUnknown;
      85  class TiXmlAttribute;
      86  class TiXmlText;
      87  class TiXmlDeclaration;
      88  class TiXmlParsingData;
          
          const int TIXML_MAJOR_VERSION = 2;
          const int TIXML_MINOR_VERSION = 5;
          const int TIXML_PATCH_VERSION = 2;
          
          /* Internal structure for tracking location of items
           in the XML file.
          */
          struct TiXmlCursor
          {
           TiXmlCursor(   ) { Clear(   ); }
           void Clear(   ) { row = col = -1; }
          
           int row; // 0 based.
           int col; // 0 based.
          };
          
          
          /**
           If you call the Accept(   ) method,   it requires being passed a TiXmlVisitor
           class to handle callbacks. For nodes that contain other nodes (  Document,   Element )
           you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
           are simple called with Visit(   ).
          
           If you return 'true' from a Visit method,   recursive parsing will continue. If you return
           false,   <b>no children of this node or its sibilings</b> will be Visited.
          
           All flavors of Visit methods have a default implementation that returns 'true' (  continue
           visiting ). You need to only override methods that are interesting to you.
          
           Generally Accept(   ) is called on the TiXmlDocument,   although all nodes suppert Visiting.
          
           You should never change the document from a callback.
          
           @sa TiXmlNode::Accept(   )
          */
     125  class TiXmlVisitor
          {
          public:
     128   virtual ~TiXmlVisitor(   ) {}
          
           /// Visit a document.
     131   virtual bool VisitEnter(   const TiXmlDocument& doc  ) { return true; }
           /// Visit a document.
     133   virtual bool VisitExit(   const TiXmlDocument& doc  ) { return true; }
          
           /// Visit an element.
     136   virtual bool VisitEnter(   const TiXmlElement& element,   const TiXmlAttribute* firstAttribute  ) { return true; }
           /// Visit an element.
     138   virtual bool VisitExit(   const TiXmlElement& element  ) { return true; }
          
           /// Visit a declaration
     141   virtual bool Visit(   const TiXmlDeclaration& declaration  ) { return true; }
           /// Visit a text node
     143   virtual bool Visit(   const TiXmlText& text  ) { return true; }
           /// Visit a comment node
     145   virtual bool Visit(   const TiXmlComment& comment  ) { return true; }
           /// Visit an unknow node
     147   virtual bool Visit(   const TiXmlUnknown& unknown  ) { return true; }
          };
          
          // Only used by Attribute::Query functions
          enum
          {
           TIXML_SUCCESS,  
           TIXML_NO_ATTRIBUTE,  
           TIXML_WRONG_TYPE
          };
          
          
          // Used by the parsing routines.
          enum TiXmlEncoding
          {
           TIXML_ENCODING_UNKNOWN,  
           TIXML_ENCODING_UTF8,  
           TIXML_ENCODING_LEGACY
          };
          
          const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
          
          /** TiXmlBase is a base class for every class in TinyXml.
           It does little except to establish that TinyXml classes
           can be printed and provide some utility functions.
          
           In XML,   the document and elements can contain
           other elements and other types of nodes.
          
           @verbatim
           A Document can contain: Element (  container or leaf )
           Comment (  leaf )
           Unknown (  leaf )
           Declaration(   leaf  )
          
           An Element can contain: Element (  container or leaf )
           Text (  leaf )
           Attributes (  not on tree )
           Comment (  leaf )
           Unknown (  leaf )
          
           A Decleration contains: Attributes (  not on tree )
           @endverbatim
          */
     191  class TiXmlBase
          {
     193   friend class TiXmlNode;
     194   friend class TiXmlElement;
     195   friend class TiXmlDocument;
          
          public:
     198   TiXmlBase(   ) : userData(  0 ) {}
     199   virtual ~TiXmlBase(   ) {}
          
           /** All TinyXml classes can print themselves to a filestream
           or the string class (  TiXmlString in non-STL mode,   std::string
           in STL mode. ) Either or both cfile and str can be null.
          
           This is a formatted print,   and will insert
           tabs and newlines.
          
           (  For an unformatted stream,   use the << operator. )
           */
     210   virtual void Print(   FILE* cfile,   int depth  ) const = 0;
          
           /** The world does not agree on whether white space should be kept or
           not. In order to make everyone happy,   these global,   static functions
           are provided to set whether or not TinyXml will condense all white space
           into a single space or not. The default is to condense. Note changing this
           value is not thread safe.
           */
     218   static void SetCondenseWhiteSpace(   bool condense  ) { condenseWhiteSpace = condense; }
          
           /// Return the current white space setting.
     221   static bool IsWhiteSpaceCondensed(   ) { return condenseWhiteSpace; }
          
           /** Return the position,   in the original source file,   of this node or attribute.
           The row and column are 1-based. (  That is the first row and first column is
           1,  1 ). If the returns values are 0 or less,   then the parser does not have
           a row and column value.
          
           Generally,   the row and column value will be set when the TiXmlDocument::Load(   ),  
           TiXmlDocument::LoadFile(   ),   or any TiXmlNode::Parse(   ) is called. It will NOT be set
           when the DOM was created from operator>>.
          
           The values reflect the initial load. Once the DOM is modified programmatically
           (  by adding or changing nodes and attributes ) the new values will NOT update to
           reflect changes in the document.
          
           There is a minor performance cost to computing the row and column. Computation
           can be disabled if TiXmlDocument::SetTabSize(   ) is called with 0 as the value.
          
           @sa TiXmlDocument::SetTabSize(   )
           */
     241   int Row(   ) const { return location.row + 1; }
     242   int Column(   ) const { return location.col + 1; } ///< See Row(   )
          
     244   void SetUserData(   void* user  ) { userData = user; } ///< Set a pointer to arbitrary user data.
     245   void* GetUserData(   ) { return userData; } ///< Get a pointer to arbitrary user data.
     246   const void* GetUserData(   ) const { return userData; } ///< Get a pointer to arbitrary user data.
          
           // Table that returs,   for a given lead byte,   the total number of bytes
           // in the UTF-8 sequence.
           static const int utf8ByteTable[256];
          
     252   virtual const char* Parse(   const char* p,  
     253   TiXmlParsingData* data,  
           TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */  ) = 0;
          
           enum
           {
           TIXML_NO_ERROR = 0,  
           TIXML_ERROR,  
           TIXML_ERROR_OPENING_FILE,  
           TIXML_ERROR_OUT_OF_MEMORY,  
           TIXML_ERROR_PARSING_ELEMENT,  
           TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,  
           TIXML_ERROR_READING_ELEMENT_VALUE,  
           TIXML_ERROR_READING_ATTRIBUTES,  
           TIXML_ERROR_PARSING_EMPTY,  
           TIXML_ERROR_READING_END_TAG,  
           TIXML_ERROR_PARSING_UNKNOWN,  
           TIXML_ERROR_PARSING_COMMENT,  
           TIXML_ERROR_PARSING_DECLARATION,  
           TIXML_ERROR_DOCUMENT_EMPTY,  
           TIXML_ERROR_EMBEDDED_NULL,  
           TIXML_ERROR_PARSING_CDATA,  
           TIXML_ERROR_DOCUMENT_TOP_ONLY,  
          
           TIXML_ERROR_STRING_COUNT
           };
          
          protected:
          
     281   static const char* SkipWhiteSpace(   const char*,   TiXmlEncoding encoding  );
     282   inline static bool IsWhiteSpace(   char c  )
           {
           return (   isspace(   (  unsigned char ) c  ) || c == '\n' || c == '\r'  );
           }
     286   inline static bool IsWhiteSpace(   int c  )
           {
           if (   c < 256  )
           return IsWhiteSpace(   (  char ) c  );
           return false; // Again,   only truly correct for English/Latin...but usually works.
           }
          
           #ifdef TIXML_USE_STL
     294   static bool StreamWhiteSpace(   std::istream * in,   TIXML_STRING * tag  );
     295   static bool StreamTo(   std::istream * in,   int character,   TIXML_STRING * tag  );
           #endif
          
           /* Reads an XML name into the string provided. Returns
           a pointer just past the last character of the name,  
           or 0 if the function has an error.
           */
     302   static const char* ReadName(   const char* p,   TIXML_STRING* name,   TiXmlEncoding encoding  );
          
           /* Reads text. Returns a pointer past the given end tag.
           Wickedly complex options,   but it keeps the (  sensitive ) code in one place.
           */
     307   static const char* ReadText(   const char* in,   // where to start
     308   TIXML_STRING* text,   // the string read
     309   bool ignoreWhiteSpace,   // whether to keep the white space
           const char* endTag,   // what ends this text
     311   bool ignoreCase,   // whether to ignore case in the end tag
           TiXmlEncoding encoding  ); // the current encoding
          
           // If an entity has been found,   transform it into a character.
     315   static const char* GetEntity(   const char* in,   char* value,   int* length,   TiXmlEncoding encoding  );
          
           // Get a character,   while interpreting entities.
           // The length can be from 0 to 4 bytes.
     319   inline static const char* GetChar(   const char* p,   char* _value,   int* length,   TiXmlEncoding encoding  )
           {
           assert(   p  );
           if (   encoding == TIXML_ENCODING_UTF8  )
           {
           *length = utf8ByteTable[ *(  (  const unsigned char* )p ) ];
           assert(   *length >= 0 && *length < 5  );
           }
           else
           {
           *length = 1;
           }
          
           if (   *length == 1  )
           {
           if (   *p == '&'  )
           return GetEntity(   p,   _value,   length,   encoding  );
           *_value = *p;
           return p+1;
           }
           else if (   *length  )
           {
           //strncpy(   _value,   p,   *length  ); // lots of compilers don't like this function (  unsafe ),  
           // and the null terminator isn't needed
           for(   int i=0; p[i] && i<*length; ++i  ) {
           _value[i] = p[i];
           }
           return p + (  *length );
           }
           else
           {
           // Not valid text.
           return 0;
           }
           }
          
           // Puts a string to a stream,   expanding entities as it goes.
           // Note this should not contian the '<',   '>',   etc,   or they will be transformed into entities!
     357   static void PutString(   const TIXML_STRING& str,   TIXML_STRING* out  );
          
           // Return true if the next characters in the stream are any of the endTag sequences.
           // Ignore case only works for english,   and should only be relied on when comparing
           // to English words: StringEqual(   p,   "version",   true  ) is fine.
     362   static bool StringEqual(   const char* p,  
           const char* endTag,  
     364   bool ignoreCase,  
           TiXmlEncoding encoding  );
          
           static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
          
           TiXmlCursor location;
          
           /// Field containing a generic user pointer
           void* userData;
          
           // None of these methods are reliable for any language except English.
           // Good for approximation,   not great for accuracy.
     376   static int IsAlpha(   unsigned char anyByte,   TiXmlEncoding encoding  );
     377   static int IsAlphaNum(   unsigned char anyByte,   TiXmlEncoding encoding  );
     378   inline static int ToLower(   int v,   TiXmlEncoding encoding  )
           {
           if (   encoding == TIXML_ENCODING_UTF8  )
           {
           if (   v < 128  ) return tolower(   v  );
           return v;
           }
           else
           {
           return tolower(   v  );
           }
           }
     390   static void ConvertUTF32ToUTF8(   unsigned long input,   char* output,   int* length  );
          
          private:
     393   TiXmlBase(   const TiXmlBase&  ); // not implemented.
     394   void operator=(   const TiXmlBase& base  ); // not allowed.
          
     396   struct Entity
           {
           const char* str;
           unsigned int strLength;
           char chr;
           };
           enum
           {
           NUM_ENTITY = 5,  
           MAX_ENTITY_LENGTH = 6
          
           };
     408   static Entity entity[ NUM_ENTITY ];
     409   static bool condenseWhiteSpace;
          };
          
          
          /** The parent class for everything in the Document Object Model.
           (  Except for attributes ).
           Nodes have siblings,   a parent,   and children. A node can be
           in a document,   or stand on its own. The type of a TiXmlNode
           can be queried,   and it can be cast to its more defined type.
          */
     419  class TiXmlNode : public TiXmlBase
          {
     421   friend class TiXmlDocument;
     422   friend class TiXmlElement;
          
          public:
           #ifdef TIXML_USE_STL
          
           /** An input stream operator,   for every class. Tolerant of newlines and
           formatting,   but doesn't expect them.
           */
     430   friend std::istream& operator >> (  std::istream& in,   TiXmlNode& base );
          
           /** An output stream operator,   for every class. Note that this outputs
           without any newlines or formatting,   as opposed to Print(   ),   which
           includes tabs and new lines.
          
           The operator<< and operator>> are not completely symmetric. Writing
           a node to a stream is very well defined. You'll get a nice stream
           of output,   without any extra whitespace or newlines.
          
           But reading is not as well defined. (  As it always is. ) If you create
           a TiXmlElement (  for example ) and read that from an input stream,  
           the text needs to define an element or junk will result. This is
           true of all input streams,   but it's worth keeping in mind.
          
           A TiXmlDocument will read nodes until it reads a root element,   and
           all the children of that root element.
           */
     448   friend std::ostream& operator<< (  std::ostream& out,   const TiXmlNode& base );
          
           /// Appends the XML node or attribute to a std::string.
     451   friend std::string& operator<< (  std::string& out,   const TiXmlNode& base  );
          
           #endif
          
           /** The types of XML nodes supported by TinyXml. (  All the
           unsupported types are picked up by UNKNOWN. )
           */
           enum NodeType
           {
           DOCUMENT,  
           ELEMENT,  
           COMMENT,  
           UNKNOWN,  
           TEXT,  
           DECLARATION,  
           TYPECOUNT
           };
          
     469   virtual ~TiXmlNode(   );
          
           /** The meaning of 'value' changes for the specific type of
           TiXmlNode.
           @verbatim
           Document: filename of the xml file
           Element: name of the element
           Comment: the comment text
           Unknown: the tag contents
           Text: the text string
           @endverbatim
          
           The subclasses will wrap this function.
           */
     483   const char *Value(   ) const { return value.c_str (   ); }
          
           #ifdef TIXML_USE_STL
           /** Return Value(   ) as a std::string. If you only use STL,  
           this is more efficient than calling Value(   ).
           Only available in STL mode.
           */
     490   const std::string& ValueStr(   ) const { return value; }
           #endif
          
           /** Changes the value of the node. Defined as:
           @verbatim
           Document: filename of the xml file
           Element: name of the element
           Comment: the comment text
           Unknown: the tag contents
           Text: the text string
           @endverbatim
           */
     502   void SetValue(  const char * _value ) { value = _value;}
          
           #ifdef TIXML_USE_STL
           /// STL std::string form.
     506   void SetValue(   const std::string& _value  ) { value = _value; }
           #endif
          
           /// Delete all the children of this node. Does not affect 'this'.
     510   void Clear(   );
          
           /// One step up the DOM.
     513   TiXmlNode* Parent(   ) { return parent; }
     514   const TiXmlNode* Parent(   ) const { return parent; }
          
     516   const TiXmlNode* FirstChild(   ) const { return firstChild; } ///< The first child of this node. Will be null if there are no children.
     517   TiXmlNode* FirstChild(   ) { return firstChild; }
     518   const TiXmlNode* FirstChild(   const char * value  ) const; ///< The first child of this node with the matching 'value'. Will be null if none found.
           /// The first child of this node with the matching 'value'. Will be null if none found.
     520   TiXmlNode* FirstChild(   const char * _value  ) {
           // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (  always safe )
           // call the method,   cast the return back to non-const.
           return const_cast< TiXmlNode* > (  (  const_cast< const TiXmlNode* >(  this ) )->FirstChild(   _value  ) );
           }
     525   const TiXmlNode* LastChild(   ) const { return lastChild; } /// The last child of this node. Will be null if there are no children.
     526   TiXmlNode* LastChild(   ) { return lastChild; }
          
     528   const TiXmlNode* LastChild(   const char * value  ) const; /// The last child of this node matching 'value'. Will be null if there are no children.
     529   TiXmlNode* LastChild(   const char * _value  ) {
           return const_cast< TiXmlNode* > (  (  const_cast< const TiXmlNode* >(  this ) )->LastChild(   _value  ) );
           }
          
           #ifdef TIXML_USE_STL
     534   const TiXmlNode* FirstChild(   const std::string& _value  ) const { return FirstChild (  _value.c_str (   ) ); } ///< STL std::string form.
     535   TiXmlNode* FirstChild(   const std::string& _value  ) { return FirstChild (  _value.c_str (   ) ); } ///< STL std::string form.
     536   const TiXmlNode* LastChild(   const std::string& _value  ) const { return LastChild (  _value.c_str (   ) ); } ///< STL std::string form.
     537   TiXmlNode* LastChild(   const std::string& _value  ) { return LastChild (  _value.c_str (   ) ); } ///< STL std::string form.
           #endif
          
           /** An alternate way to walk the children of a node.
           One way to iterate over nodes is:
           @verbatim
           for(   child = parent->FirstChild(   ); child; child = child->NextSibling(   )  )
           @endverbatim
          
           IterateChildren does the same thing with the syntax:
           @verbatim
           child = 0;
           while(   child = parent->IterateChildren(   child  )  )
           @endverbatim
          
           IterateChildren takes the previous child as input and finds
           the next one. If the previous child is null,   it returns the
           first. IterateChildren will return null when done.
           */
     556   const TiXmlNode* IterateChildren(   const TiXmlNode* previous  ) const;
     557   TiXmlNode* IterateChildren(   const TiXmlNode* previous  ) {
           return const_cast< TiXmlNode* >(   (  const_cast< const TiXmlNode* >(  this ) )->IterateChildren(   previous  )  );
           }
          
           /// This flavor of IterateChildren searches for children with a particular 'value'
     562   const TiXmlNode* IterateChildren(   const char * value,   const TiXmlNode* previous  ) const;
     563   TiXmlNode* IterateChildren(   const char * _value,   const TiXmlNode* previous  ) {
           return const_cast< TiXmlNode* >(   (  const_cast< const TiXmlNode* >(  this ) )->IterateChildren(   _value,   previous  )  );
           }
          
           #ifdef TIXML_USE_STL
     568   const TiXmlNode* IterateChildren(   const std::string& _value,   const TiXmlNode* previous  ) const { return IterateChildren (  _value.c_str (   ),   previous ); } ///< STL std::string form.
     569   TiXmlNode* IterateChildren(   const std::string& _value,   const TiXmlNode* previous  ) { return IterateChildren (  _value.c_str (   ),   previous ); } ///< STL std::string form.
           #endif
          
           /** Add a new node related to this. Adds a child past the LastChild.
           Returns a pointer to the new object or NULL if an error occured.
           */
     575   TiXmlNode* InsertEndChild(   const TiXmlNode& addThis  );
          
          
           /** Add a new node related to this. Adds a child past the LastChild.
          
           NOTE: the node to be added is passed by pointer,   and will be
           henceforth owned (  and deleted ) by tinyXml. This method is efficient
           and avoids an extra copy,   but should be used with care as it
           uses a different memory model than the other insert functions.
          
           @sa InsertEndChild
           */
     587   TiXmlNode* LinkEndChild(   TiXmlNode* addThis  );
          
           /** Add a new node related to this. Adds a child before the specified child.
           Returns a pointer to the new object or NULL if an error occured.
           */
     592   TiXmlNode* InsertBeforeChild(   TiXmlNode* beforeThis,   const TiXmlNode& addThis  );
          
           /** Add a new node related to this. Adds a child after the specified child.
           Returns a pointer to the new object or NULL if an error occured.
           */
     597   TiXmlNode* InsertAfterChild(   TiXmlNode* afterThis,   const TiXmlNode& addThis  );
          
           /** Replace a child of this node.
           Returns a pointer to the new object or NULL if an error occured.
           */
     602   TiXmlNode* ReplaceChild(   TiXmlNode* replaceThis,   const TiXmlNode& withThis  );
          
           /// Delete a child of this node.
     605   bool RemoveChild(   TiXmlNode* removeThis  );
          
           /// Navigate to a sibling node.
     608   const TiXmlNode* PreviousSibling(   ) const { return prev; }
     609   TiXmlNode* PreviousSibling(   ) { return prev; }
          
           /// Navigate to a sibling node.
     612   const TiXmlNode* PreviousSibling(   const char *  ) const;
     613   TiXmlNode* PreviousSibling(   const char *_prev  ) {
           return const_cast< TiXmlNode* >(   (  const_cast< const TiXmlNode* >(  this ) )->PreviousSibling(   _prev  )  );
           }
          
           #ifdef TIXML_USE_STL
     618   const TiXmlNode* PreviousSibling(   const std::string& _value  ) const { return PreviousSibling (  _value.c_str (   ) ); } ///< STL std::string form.
     619   TiXmlNode* PreviousSibling(   const std::string& _value  ) { return PreviousSibling (  _value.c_str (   ) ); } ///< STL std::string form.
     620   const TiXmlNode* NextSibling(   const std::string& _value ) const { return NextSibling (  _value.c_str (   ) ); } ///< STL std::string form.
     621   TiXmlNode* NextSibling(   const std::string& _value ) { return NextSibling (  _value.c_str (   ) ); } ///< STL std::string form.
           #endif
          
           /// Navigate to a sibling node.
     625   const TiXmlNode* NextSibling(   ) const { return next; }
     626   TiXmlNode* NextSibling(   ) { return next; }
          
           /// Navigate to a sibling node with the given 'value'.
     629   const TiXmlNode* NextSibling(   const char *  ) const;
     630   TiXmlNode* NextSibling(   const char* _next  ) {
           return const_cast< TiXmlNode* >(   (  const_cast< const TiXmlNode* >(  this ) )->NextSibling(   _next  )  );
           }
          
           /** Convenience function to get through elements.
           Calls NextSibling and ToElement. Will skip all non-Element
           nodes. Returns 0 if there is not another element.
           */
     638   const TiXmlElement* NextSiblingElement(   ) const;
     639   TiXmlElement* NextSiblingElement(   ) {
           return const_cast< TiXmlElement* >(   (  const_cast< const TiXmlNode* >(  this ) )->NextSiblingElement(   )  );
           }
          
           /** Convenience function to get through elements.
           Calls NextSibling and ToElement. Will skip all non-Element
           nodes. Returns 0 if there is not another element.
           */
     647   const TiXmlElement* NextSiblingElement(   const char *  ) const;
     648   TiXmlElement* NextSiblingElement(   const char *_next  ) {
           return const_cast< TiXmlElement* >(   (  const_cast< const TiXmlNode* >(  this ) )->NextSiblingElement(   _next  )  );
           }
          
           #ifdef TIXML_USE_STL
     653   const TiXmlElement* NextSiblingElement(   const std::string& _value ) const { return NextSiblingElement (  _value.c_str (   ) ); } ///< STL std::string form.
     654   TiXmlElement* NextSiblingElement(   const std::string& _value ) { return NextSiblingElement (  _value.c_str (   ) ); } ///< STL std::string form.
           #endif
          
           /// Convenience function to get through elements.
     658   const TiXmlElement* FirstChildElement(   ) const;
     659   TiXmlElement* FirstChildElement(   ) {
           return const_cast< TiXmlElement* >(   (  const_cast< const TiXmlNode* >(  this ) )->FirstChildElement(   )  );
           }
          
           /// Convenience function to get through elements.
     664   const TiXmlElement* FirstChildElement(   const char * _value  ) const;
     665   TiXmlElement* FirstChildElement(   const char * _value  ) {
           return const_cast< TiXmlElement* >(   (  const_cast< const TiXmlNode* >(  this ) )->FirstChildElement(   _value  )  );
           }
          
           #ifdef TIXML_USE_STL
     670   const TiXmlElement* FirstChildElement(   const std::string& _value  ) const { return FirstChildElement (  _value.c_str (   ) ); } ///< STL std::string form.
     671   TiXmlElement* FirstChildElement(   const std::string& _value  ) { return FirstChildElement (  _value.c_str (   ) ); } ///< STL std::string form.
           #endif
          
           /** Query the type (  as an enumerated value,   above ) of this node.
           The possible types are: DOCUMENT,   ELEMENT,   COMMENT,  
           UNKNOWN,   TEXT,   and DECLARATION.
           */
     678   int Type(   ) const { return type; }
          
           /** Return a pointer to the Document this node lives in.
           Returns null if not in a document.
           */
     683   const TiXmlDocument* GetDocument(   ) const;
     684   TiXmlDocument* GetDocument(   ) {
           return const_cast< TiXmlDocument* >(   (  const_cast< const TiXmlNode* >(  this ) )->GetDocument(   )  );
           }
          
           /// Returns true if this node has no children.
     689   bool NoChildren(   ) const { return !firstChild; }
          
     691   virtual const TiXmlDocument* ToDocument(   ) const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     692   virtual const TiXmlElement* ToElement(   ) const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     693   virtual const TiXmlComment* ToComment(   ) const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     694   virtual const TiXmlUnknown* ToUnknown(   ) const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     695   virtual const TiXmlText* ToText(   ) const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     696   virtual const TiXmlDeclaration* ToDeclaration(   ) const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
          
     698   virtual TiXmlDocument* ToDocument(   ) { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     699   virtual TiXmlElement* ToElement(   ) { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     700   virtual TiXmlComment* ToComment(   ) { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     701   virtual TiXmlUnknown* ToUnknown(   ) { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     702   virtual TiXmlText* ToText(   ) { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
     703   virtual TiXmlDeclaration* ToDeclaration(   ) { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
          
           /** Create an exact duplicate of this node and return it. The memory must be deleted
           by the caller.
           */
     708   virtual TiXmlNode* Clone(   ) const = 0;
          
           /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the
           XML tree will be conditionally visited and the host will be called back
           via the TiXmlVisitor interface.
          
           This is essentially a SAX interface for TinyXML. (  Note however it doesn't re-parse
           the XML for the callbacks,   so the performance of TinyXML is unchanged by using this
           interface versus any other. )
          
           The interface has been based on ideas from:
          
           - http://www.saxproject.org/
           - http://c2.com/cgi/wiki?HierarchicalVisitorPattern
          
           Which are both good references for "visiting".
          
           An example of using Accept(   ):
           @verbatim
           TiXmlPrinter printer;
           tinyxmlDoc.Accept(   &printer  );
           const char* xmlcstr = printer.CStr(   );
           @endverbatim
           */
     732   virtual bool Accept(   TiXmlVisitor* visitor  ) const = 0;
          
          protected:
     735   TiXmlNode(   NodeType _type  );
          
           // Copy to the allocated object. Shared functionality between Clone,   Copy constructor,  
           // and the assignment operator.
     739   void CopyTo(   TiXmlNode* target  ) const;
          
           #ifdef TIXML_USE_STL
           // The real work of the input operator.
     743   virtual void StreamIn(   std::istream* in,   TIXML_STRING* tag  ) = 0;
           #endif
          
           // Figure out what is at *p,   and parse it. Returns null if it is not an xml node.
     747   TiXmlNode* Identify(   const char* start,   TiXmlEncoding encoding  );
          
           TiXmlNode* parent;
           NodeType type;
          
           TiXmlNode* firstChild;
           TiXmlNode* lastChild;
          
     755   TIXML_STRING value;
          
           TiXmlNode* prev;
           TiXmlNode* next;
          
          private:
     761   TiXmlNode(   const TiXmlNode&  ); // not implemented.
     762   void operator=(   const TiXmlNode& base  ); // not allowed.
          };
          
          
          /** An attribute is a name-value pair. Elements have an arbitrary
           number of attributes,   each with a unique name.
          
           @note The attributes are not TiXmlNodes,   since they are not
           part of the tinyXML document object model. There are other
           suggested ways to look at this problem.
          */
     773  class TiXmlAttribute : public TiXmlBase
          {
     775   friend class TiXmlAttributeSet;
          
          public:
           /// Construct an empty attribute.
     779   TiXmlAttribute(   ) : TiXmlBase(   )
           {
           document = 0;
           prev = next = 0;
           }
          
           #ifdef TIXML_USE_STL
           /// std::string constructor.
     787   TiXmlAttribute(   const std::string& _name,   const std::string& _value  )
           {
           name = _name;
           value = _value;
           document = 0;
           prev = next = 0;
           }
           #endif
          
           /// Construct an attribute with a name and value.
     797   TiXmlAttribute(   const char * _name,   const char * _value  )
           {
           name = _name;
           value = _value;
           document = 0;
           prev = next = 0;
           }
          
     805   const char* Name(   ) const { return name.c_str(   ); } ///< Return the name of this attribute.
     806   const char* Value(   ) const { return value.c_str(   ); } ///< Return the value of this attribute.
           #ifdef TIXML_USE_STL
     808   const std::string& ValueStr(   ) const { return value; } ///< Return the value of this attribute.
           #endif
     810   int IntValue(   ) const; ///< Return the value of this attribute,   converted to an integer.
     811   double DoubleValue(   ) const; ///< Return the value of this attribute,   converted to a double.
          
           // Get the tinyxml string representation
     814   const TIXML_STRING& NameTStr(   ) const { return name; }
          
           /** QueryIntValue examines the value string. It is an alternative to the
           IntValue(   ) method with richer error checking.
           If the value is an integer,   it is stored in 'value' and
           the call returns TIXML_SUCCESS. If it is not
           an integer,   it returns TIXML_WRONG_TYPE.
          
           A specialized but useful call. Note that for success it returns 0,  
           which is the opposite of almost all other TinyXml calls.
           */
     825   int QueryIntValue(   int* _value  ) const;
           /// QueryDoubleValue examines the value string. See QueryIntValue(   ).
     827   int QueryDoubleValue(   double* _value  ) const;
          
     829   void SetName(   const char* _name  ) { name = _name; } ///< Set the name of this attribute.
     830   void SetValue(   const char* _value  ) { value = _value; } ///< Set the value.
          
     832   void SetIntValue(   int _value  ); ///< Set the value from an integer.
     833   void SetDoubleValue(   double _value  ); ///< Set the value from a double.
          
           #ifdef TIXML_USE_STL
           /// STL std::string form.
     837   void SetName(   const std::string& _name  ) { name = _name; }
           /// STL std::string form.
     839   void SetValue(   const std::string& _value  ) { value = _value; }
           #endif
          
           /// Get the next sibling attribute in the DOM. Returns null at end.
     843   const TiXmlAttribute* Next(   ) const;
     844   TiXmlAttribute* Next(   ) {
           return const_cast< TiXmlAttribute* >(   (  const_cast< const TiXmlAttribute* >(  this ) )->Next(   )  );
           }
          
           /// Get the previous sibling attribute in the DOM. Returns null at beginning.
     849   const TiXmlAttribute* Previous(   ) const;
     850   TiXmlAttribute* Previous(   ) {
           return const_cast< TiXmlAttribute* >(   (  const_cast< const TiXmlAttribute* >(  this ) )->Previous(   )  );
           }
          
     854   bool operator==(   const TiXmlAttribute& rhs  ) const { return rhs.name == name; }
     855   bool operator<(   const TiXmlAttribute& rhs  ) const { return name < rhs.name; }
     856   bool operator>(   const TiXmlAttribute& rhs  ) const { return name > rhs.name; }
          
           /* Attribute parsing starts: first letter of the name
           returns: the next char after the value end quote
           */
     861   virtual const char* Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  );
          
           // Prints this Attribute to a FILE stream.
     864   virtual void Print(   FILE* cfile,   int depth  ) const {
           Print(   cfile,   depth,   0  );
           }
     867   void Print(   FILE* cfile,   int depth,   TIXML_STRING* str  ) const;
          
           // [internal use]
           // Set the document pointer so the attribute can report errors.
     871   void SetDocument(   TiXmlDocument* doc  ) { document = doc; }
          
          private:
     874   TiXmlAttribute(   const TiXmlAttribute&  ); // not implemented.
     875   void operator=(   const TiXmlAttribute& base  ); // not allowed.
          
     877   TiXmlDocument* document; // A pointer back to a document,   for error reporting.
     878   TIXML_STRING name;
     879   TIXML_STRING value;
           TiXmlAttribute* prev;
           TiXmlAttribute* next;
          };
          
          
          /* A class used to manage a group of attributes.
           It is only used internally,   both by the ELEMENT and the DECLARATION.
          
           The set can be changed transparent to the Element and Declaration
           classes that use it,   but NOT transparent to the Attribute
           which has to implement a next(   ) and previous(   ) method. Which makes
           it a bit problematic and prevents the use of STL.
          
           This version is implemented with circular lists because:
           - I like circular lists
           - it demonstrates some independence from the (  typical ) doubly linked list.
          */
     897  class TiXmlAttributeSet
          {
          public:
     900   TiXmlAttributeSet(   );
     901   ~TiXmlAttributeSet(   );
          
     903   void Add(   TiXmlAttribute* attribute  );
     904   void Remove(   TiXmlAttribute* attribute  );
          
     906   const TiXmlAttribute* First(   ) const { return (   sentinel.next == &sentinel  ) ? 0 : sentinel.next; }
     907   TiXmlAttribute* First(   ) { return (   sentinel.next == &sentinel  ) ? 0 : sentinel.next; }
     908   const TiXmlAttribute* Last(   ) const { return (   sentinel.prev == &sentinel  ) ? 0 : sentinel.prev; }
     909   TiXmlAttribute* Last(   ) { return (   sentinel.prev == &sentinel  ) ? 0 : sentinel.prev; }
          
     911   const TiXmlAttribute* Find(   const char* _name  ) const;
     912   TiXmlAttribute* Find(   const char* _name  ) {
           return const_cast< TiXmlAttribute* >(   (  const_cast< const TiXmlAttributeSet* >(  this ) )->Find(   _name  )  );
           }
           #ifdef TIXML_USE_STL
     916   const TiXmlAttribute* Find(   const std::string& _name  ) const;
     917   TiXmlAttribute* Find(   const std::string& _name  ) {
           return const_cast< TiXmlAttribute* >(   (  const_cast< const TiXmlAttributeSet* >(  this ) )->Find(   _name  )  );
           }
          
           #endif
          
          private:
           //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (  sentinel-element ),  
           //*ME: this class must be also use a hidden/disabled copy-constructor !!!
     926   TiXmlAttributeSet(   const TiXmlAttributeSet&  ); // not allowed
     927   void operator=(   const TiXmlAttributeSet&  ); // not allowed (  as TiXmlAttribute )
          
     929   TiXmlAttribute sentinel;
          };
          
          
          /** The element is a container class. It has a value,   the element name,  
           and can contain other elements,   text,   comments,   and unknowns.
           Elements also contain an arbitrary number of attributes.
          */
     937  class TiXmlElement : public TiXmlNode
          {
          public:
           /// Construct an element.
     941   TiXmlElement (  const char * in_value );
          
           #ifdef TIXML_USE_STL
           /// std::string constructor.
     945   TiXmlElement(   const std::string& _value  );
           #endif
          
     948   TiXmlElement(   const TiXmlElement&  );
          
     950   void operator=(   const TiXmlElement& base  );
          
     952   virtual ~TiXmlElement(   );
          
           /** Given an attribute name,   Attribute(   ) returns the value
           for the attribute of that name,   or null if none exists.
           */
     957   const char* Attribute(   const char* name  ) const;
          
           /** Given an attribute name,   Attribute(   ) returns the value
           for the attribute of that name,   or null if none exists.
           If the attribute exists and can be converted to an integer,  
           the integer value will be put in the return 'i',   if 'i'
           is non-null.
           */
     965   const char* Attribute(   const char* name,   int* i  ) const;
          
           /** Given an attribute name,   Attribute(   ) returns the value
           for the attribute of that name,   or null if none exists.
           If the attribute exists and can be converted to an double,  
           the double value will be put in the return 'd',   if 'd'
           is non-null.
           */
     973   const char* Attribute(   const char* name,   double* d  ) const;
          
           /** QueryIntAttribute examines the attribute - it is an alternative to the
           Attribute(   ) method with richer error checking.
           If the attribute is an integer,   it is stored in 'value' and
           the call returns TIXML_SUCCESS. If it is not
           an integer,   it returns TIXML_WRONG_TYPE. If the attribute
           does not exist,   then TIXML_NO_ATTRIBUTE is returned.
           */
     982   int QueryIntAttribute(   const char* name,   int* _value  ) const;
           /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(   ).
     984   int QueryDoubleAttribute(   const char* name,   double* _value  ) const;
           /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(   ).
     986   int QueryFloatAttribute(   const char* name,   float* _value  ) const {
           double d;
           int result = QueryDoubleAttribute(   name,   &d  );
           if (   result == TIXML_SUCCESS  ) {
           *_value = (  float )d;
           }
           return result;
           }
           #ifdef TIXML_USE_STL
           /** Template form of the attribute query which will try to read the
           attribute into the specified type. Very easy,   very powerful,   but
           be careful to make sure to call this with the correct type.
          
           @return TIXML_SUCCESS,   TIXML_WRONG_TYPE,   or TIXML_NO_ATTRIBUTE
           */
           template< typename T > int QueryValueAttribute(   const std::string& name,   T* outValue  ) const
           {
           const TiXmlAttribute* node = attributeSet.Find(   name  );
           if (   !node  )
           return TIXML_NO_ATTRIBUTE;
          
           std::stringstream sstream(   node->ValueStr(   )  );
           sstream >> *outValue;
           if (   !sstream.fail(   )  )
           return TIXML_SUCCESS;
           return TIXML_WRONG_TYPE;
           }
           #endif
          
           /** Sets an attribute of name to a given value. The attribute
           will be created if it does not exist,   or changed if it does.
           */
           void SetAttribute(   const char* name,   const char * _value  );
          
           #ifdef TIXML_USE_STL
    1021   const std::string* Attribute(   const std::string& name  ) const;
    1022   const std::string* Attribute(   const std::string& name,   int* i  ) const;
    1023   const std::string* Attribute(   const std::string& name,   double* d  ) const;
    1024   int QueryIntAttribute(   const std::string& name,   int* _value  ) const;
    1025   int QueryDoubleAttribute(   const std::string& name,   double* _value  ) const;
          
           /// STL std::string form.
    1028   void SetAttribute(   const std::string& name,   const std::string& _value  );
           ///< STL std::string form.
    1030   void SetAttribute(   const std::string& name,   int _value  );
           #endif
          
           /** Sets an attribute of name to a given value. The attribute
           will be created if it does not exist,   or changed if it does.
           */
    1036   void SetAttribute(   const char * name,   int value  );
          
           /** Sets an attribute of name to a given value. The attribute
           will be created if it does not exist,   or changed if it does.
           */
    1041   void SetDoubleAttribute(   const char * name,   double value  );
          
           /** Deletes an attribute with the given name.
           */
    1045   void RemoveAttribute(   const char * name  );
           #ifdef TIXML_USE_STL
    1047   void RemoveAttribute(   const std::string& name  ) { RemoveAttribute (  name.c_str (   ) ); } ///< STL std::string form.
           #endif
          
    1050   const TiXmlAttribute* FirstAttribute(   ) const { return attributeSet.First(   ); } ///< Access the first attribute in this element.
    1051   TiXmlAttribute* FirstAttribute(   ) { return attributeSet.First(   ); }
    1052   const TiXmlAttribute* LastAttribute(   ) const { return attributeSet.Last(   ); } ///< Access the last attribute in this element.
    1053   TiXmlAttribute* LastAttribute(   ) { return attributeSet.Last(   ); }
          
           /** Convenience function for easy access to the text inside an element. Although easy
           and concise,   GetText(   ) is limited compared to getting the TiXmlText child
           and accessing it directly.
          
           If the first child of 'this' is a TiXmlText,   the GetText(   )
           returns the character string of the Text node,   else null is returned.
          
           This is a convenient method for getting the text of simple contained text:
           @verbatim
           <foo>This is text</foo>
           const char* str = fooElement->GetText(   );
           @endverbatim
          
           'str' will be a pointer to "This is text".
          
           Note that this function can be misleading. If the element foo was created from
           this XML:
           @verbatim
           <foo><b>This is text</b></foo>
           @endverbatim
          
           then the value of str would be null. The first child node isn't a text node,   it is
           another element. From this XML:
           @verbatim
           <foo>This is <b>text</b></foo>
           @endverbatim
           GetText(   ) will return "This is ".
          
           WARNING: GetText(   ) accesses a child node - don't become confused with the
           similarly named TiXmlHandle::Text(   ) and TiXmlNode::ToText(   ) which are
           safe type casts on the referenced node.
           */
    1087   const char* GetText(   ) const;
          
           /// Creates a new Element and returns it - the returned element is a copy.
    1090   virtual TiXmlNode* Clone(   ) const;
           // Print the Element to a FILE stream.
           virtual void Print(   FILE* cfile,   int depth  ) const;
          
           /* Attribtue parsing starts: next char past '<'
           returns: next char past '>'
           */
           virtual const char* Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  );
          
           virtual const TiXmlElement* ToElement(   ) const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
           virtual TiXmlElement* ToElement(   ) { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
          
           /** Walk the XML tree visiting this node and all of its children.
           */
           virtual bool Accept(   TiXmlVisitor* visitor  ) const;
          
          protected:
          
           void CopyTo(   TiXmlElement* target  ) const;
           void ClearThis(   ); // like clear,   but initializes 'this' object as well
          
           // Used to be public [internal use]
           #ifdef TIXML_USE_STL
           virtual void StreamIn(   std::istream * in,   TIXML_STRING * tag  );
           #endif
           /* [internal use]
           Reads the "value" of the element -- another element,   or text.
           This should terminate with the current end tag.
           */
           const char* ReadValue(   const char* in,   TiXmlParsingData* prevData,   TiXmlEncoding encoding  );
          
          private:
          
           TiXmlAttributeSet attributeSet;
          };
          
          
          /** An XML comment.
          */
          class TiXmlComment : public TiXmlNode
          {
          public:
           /// Constructs an empty comment.
           TiXmlComment(   ) : TiXmlNode(   TiXmlNode::COMMENT  ) {}
           /// Construct a comment from text.
           TiXmlComment(   const char* _value  ) : TiXmlNode(   TiXmlNode::COMMENT  ) {
           SetValue(   _value  );
           }
           TiXmlComment(   const TiXmlComment&  );
           void operator=(   const TiXmlComment& base  );
          
           virtual ~TiXmlComment(   ) {}
          
           /// Returns a copy of this Comment.
           virtual TiXmlNode* Clone(   ) const;
           // Write this Comment to a FILE stream.
           virtual void Print(   FILE* cfile,   int depth  ) const;
          
           /* Attribtue parsing starts: at the ! of the !--
           returns: next char past '>'
           */
           virtual const char* Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  );
          
           virtual const TiXmlComment* ToComment(   ) const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
           virtual TiXmlComment* ToComment(   ) { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
          
           /** Walk the XML tree visiting this node and all of its children.
           */
           virtual bool Accept(   TiXmlVisitor* visitor  ) const;
          
          protected:
           void CopyTo(   TiXmlComment* target  ) const;
          
           // used to be public
           #ifdef TIXML_USE_STL
           virtual void StreamIn(   std::istream * in,   TIXML_STRING * tag  );
           #endif
          // virtual void StreamOut(   TIXML_OSTREAM * out  ) const;
          
          private:
          
          };
          
          
          /** XML text. A text node can have 2 ways to output the next. "normal" output
           and CDATA. It will default to the mode it was parsed from the XML file and
           you generally want to leave it alone,   but you can change the output mode with
           SetCDATA(   ) and query it with CDATA(   ).
          */
          class TiXmlText : public TiXmlNode
          {
           friend class TiXmlElement;
          public:
           /** Constructor for text element. By default,   it is treated as
           normal,   encoded text. If you want it be output as a CDATA text
           element,   set the parameter _cdata to 'true'
           */
           TiXmlText (  const char * initValue  ) : TiXmlNode (  TiXmlNode::TEXT )
           {
           SetValue(   initValue  );
           cdata = false;
           }
           virtual ~TiXmlText(   ) {}
          
           #ifdef TIXML_USE_STL
           /// Constructor.
           TiXmlText(   const std::string& initValue  ) : TiXmlNode (  TiXmlNode::TEXT )
           {
           SetValue(   initValue  );
           cdata = false;
           }
           #endif
          
           TiXmlText(   const TiXmlText& copy  ) : TiXmlNode(   TiXmlNode::TEXT  ) { copy.CopyTo(   this  ); }
           void operator=(   const TiXmlText& base  ) { base.CopyTo(   this  ); }
          
           // Write this text object to a FILE stream.
           virtual void Print(   FILE* cfile,   int depth  ) const;
          
           /// Queries whether this represents text using a CDATA section.
           bool CDATA(   ) const { return cdata; }
           /// Turns on or off a CDATA representation of text.
           void SetCDATA(   bool _cdata  ) { cdata = _cdata; }
          
           virtual const char* Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  );
          
           virtual const TiXmlText* ToText(   ) const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
           virtual TiXmlText* ToText(   ) { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
          
           /** Walk the XML tree visiting this node and all of its children.
           */
           virtual bool Accept(   TiXmlVisitor* content  ) const;
          
          protected :
           /// [internal use] Creates a new Element and returns it.
           virtual TiXmlNode* Clone(   ) const;
           void CopyTo(   TiXmlText* target  ) const;
          
           bool Blank(   ) const; // returns true if all white space and new lines
           // [internal use]
           #ifdef TIXML_USE_STL
           virtual void StreamIn(   std::istream * in,   TIXML_STRING * tag  );
           #endif
          
          private:
           bool cdata; // true if this should be input and output as a CDATA style text element
          };
          
          
          /** In correct XML the declaration is the first entry in the file.
           @verbatim
           <?xml version="1.0" standalone="yes"?>
           @endverbatim
          
           TinyXml will happily read or write files without a declaration,  
           however. There are 3 possible attributes to the declaration:
           version,   encoding,   and standalone.
          
           Note: In this version of the code,   the attributes are
           handled as special cases,   not generic attributes,   simply
           because there can only be at most 3 and they are always the same.
          */
          class TiXmlDeclaration : public TiXmlNode
          {
          public:
           /// Construct an empty declaration.
           TiXmlDeclaration(   ) : TiXmlNode(   TiXmlNode::DECLARATION  ) {}
          
          #ifdef TIXML_USE_STL
           /// Constructor.
           TiXmlDeclaration(   const std::string& _version,  
           const std::string& _encoding,  
           const std::string& _standalone  );
          #endif
          
           /// Construct.
           TiXmlDeclaration(   const char* _version,  
           const char* _encoding,  
           const char* _standalone  );
          
           TiXmlDeclaration(   const TiXmlDeclaration& copy  );
           void operator=(   const TiXmlDeclaration& copy  );
          
           virtual ~TiXmlDeclaration(   ) {}
          
           /// Version. Will return an empty string if none was found.
           const char *Version(   ) const { return version.c_str (   ); }
           /// Encoding. Will return an empty string if none was found.
           const char *Encoding(   ) const { return encoding.c_str (   ); }
           /// Is this a standalone document?
           const char *Standalone(   ) const { return standalone.c_str (   ); }
          
           /// Creates a copy of this Declaration and returns it.
           virtual TiXmlNode* Clone(   ) const;
           // Print this declaration to a FILE stream.
           virtual void Print(   FILE* cfile,   int depth,   TIXML_STRING* str  ) const;
           virtual void Print(   FILE* cfile,   int depth  ) const {
           Print(   cfile,   depth,   0  );
           }
          
           virtual const char* Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  );
          
           virtual const TiXmlDeclaration* ToDeclaration(   ) const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
           virtual TiXmlDeclaration* ToDeclaration(   ) { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
          
           /** Walk the XML tree visiting this node and all of its children.
           */
           virtual bool Accept(   TiXmlVisitor* visitor  ) const;
          
          protected:
           void CopyTo(   TiXmlDeclaration* target  ) const;
           // used to be public
           #ifdef TIXML_USE_STL
           virtual void StreamIn(   std::istream * in,   TIXML_STRING * tag  );
           #endif
          
          private:
          
           TIXML_STRING version;
           TIXML_STRING encoding;
           TIXML_STRING standalone;
          };
          
          
          /** Any tag that tinyXml doesn't recognize is saved as an
           unknown. It is a tag of text,   but should not be modified.
           It will be written back to the XML,   unchanged,   when the file
           is saved.
          
           DTD tags get thrown into TiXmlUnknowns.
          */
          class TiXmlUnknown : public TiXmlNode
          {
          public:
           TiXmlUnknown(   ) : TiXmlNode(   TiXmlNode::UNKNOWN  ) {}
           virtual ~TiXmlUnknown(   ) {}
          
           TiXmlUnknown(   const TiXmlUnknown& copy  ) : TiXmlNode(   TiXmlNode::UNKNOWN  ) { copy.CopyTo(   this  ); }
           void operator=(   const TiXmlUnknown& copy  ) { copy.CopyTo(   this  ); }
          
           /// Creates a copy of this Unknown and returns it.
           virtual TiXmlNode* Clone(   ) const;
           // Print this Unknown to a FILE stream.
           virtual void Print(   FILE* cfile,   int depth  ) const;
          
           virtual const char* Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  );
          
           virtual const TiXmlUnknown* ToUnknown(   ) const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
           virtual TiXmlUnknown* ToUnknown(   ) { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
          
           /** Walk the XML tree visiting this node and all of its children.
           */
           virtual bool Accept(   TiXmlVisitor* content  ) const;
          
          protected:
           void CopyTo(   TiXmlUnknown* target  ) const;
          
           #ifdef TIXML_USE_STL
           virtual void StreamIn(   std::istream * in,   TIXML_STRING * tag  );
           #endif
          
          private:
          
          };
          
          
          /** Always the top level node. A document binds together all the
           XML pieces. It can be saved,   loaded,   and printed to the screen.
           The 'value' of a document node is the xml file name.
          */
          class TiXmlDocument : public TiXmlNode
          {
          public:
           /// Create an empty document,   that has no name.
           TiXmlDocument(   );
           /// Create a document with a name. The name of the document is also the filename of the xml.
           TiXmlDocument(   const char * documentName  );
          
           #ifdef TIXML_USE_STL
           /// Constructor.
           TiXmlDocument(   const std::string& documentName  );
           #endif
          
           TiXmlDocument(   const TiXmlDocument& copy  );
           void operator=(   const TiXmlDocument& copy  );
          
           virtual ~TiXmlDocument(   ) {}
          
           /** Load a file using the current document value.
           Returns true if successful. Will delete any existing
           document data before loading.
           */
           bool LoadFile(   TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING  );
           /// Save a file using the current document value. Returns true if successful.
           bool SaveFile(   ) const;
           /// Load a file using the given filename. Returns true if successful.
           bool LoadFile(   const char * filename,   TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING  );
           /// Save a file using the given filename. Returns true if successful.
           bool SaveFile(   const char * filename  ) const;
           /** Load a file using the given FILE*. Returns true if successful. Note that this method
           doesn't stream - the entire object pointed at by the FILE*
           will be interpreted as an XML file. TinyXML doesn't stream in XML from the current
           file location. Streaming may be added in the future.
           */
           bool LoadFile(   FILE*,   TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING  );
           /// Save a file using the given FILE*. Returns true if successful.
           bool SaveFile(   FILE*  ) const;
          
           #ifdef TIXML_USE_STL
           bool LoadFile(   const std::string& filename,   TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING  ) ///< STL std::string version.
           {
          // StringToBuffer f(   filename  );
          // return (   f.buffer && LoadFile(   f.buffer,   encoding  ) );
           return LoadFile(   filename.c_str(   ),   encoding  );
           }
           bool SaveFile(   const std::string& filename  ) const ///< STL std::string version.
           {
          // StringToBuffer f(   filename  );
          // return (   f.buffer && SaveFile(   f.buffer  ) );
           return SaveFile(   filename.c_str(   )  );
           }
           #endif
          
           /** Parse the given null terminated block of xml data. Passing in an encoding to this
           method (  either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml
           to use that encoding,   regardless of what TinyXml might otherwise try to detect.
           */
           virtual const char* Parse(   const char* p,   TiXmlParsingData* data = 0,   TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING  );
          
           /** Get the root element -- the only top level element -- of the document.
           In well formed XML,   there should only be one. TinyXml is tolerant of
           multiple elements at the document level.
           */
           const TiXmlElement* RootElement(   ) const { return FirstChildElement(   ); }
           TiXmlElement* RootElement(   ) { return FirstChildElement(   ); }
          
           /** If an error occurs,   Error will be set to true. Also,  
           - The ErrorId(   ) will contain the integer identifier of the error (  not generally useful )
           - The ErrorDesc(   ) method will return the name of the error. (  very useful )
           - The ErrorRow(   ) and ErrorCol(   ) will return the location of the error (  if known )
           */
           bool Error(   ) const { return error; }
          
           /// Contains a textual (  english ) description of the error if one occurs.
           const char * ErrorDesc(   ) const { return errorDesc.c_str (   ); }
          
           /** Generally,   you probably want the error string (   ErrorDesc(   )  ). But if you
           prefer the ErrorId,   this function will fetch it.
           */
           int ErrorId(   ) const { return errorId; }
          
           /** Returns the location (  if known ) of the error. The first column is column 1,  
           and the first row is row 1. A value of 0 means the row and column wasn't applicable
           (  memory errors,   for example,   have no row/column ) or the parser lost the error. (  An
           error in the error reporting,   in that case. )
          
           @sa SetTabSize,   Row,   Column
           */
           int ErrorRow(   ) const { return errorLocation.row+1; }
           int ErrorCol(   ) const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow(   )
          
           /** SetTabSize(   ) allows the error reporting functions (  ErrorRow(   ) and ErrorCol(   ) )
           to report the correct values for row and column. It does not change the output
           or input in any way.
          
           By calling this method,   with a tab size
           greater than 0,   the row and column of each node and attribute is stored
           when the file is loaded. Very useful for tracking the DOM back in to
           the source file.
          
           The tab size is required for calculating the location of nodes. If not
           set,   the default of 4 is used. The tabsize is set per document. Setting
           the tabsize to 0 disables row/column tracking.
          
           Note that row and column tracking is not supported when using operator>>.
          
           The tab size needs to be enabled before the parse or load. Correct usage:
           @verbatim
           TiXmlDocument doc;
           doc.SetTabSize(   8  );
           doc.Load(   "myfile.xml"  );
           @endverbatim
          
           @sa Row,   Column
           */
           void SetTabSize(   int _tabsize  ) { tabsize = _tabsize; }
          
           int TabSize(   ) const { return tabsize; }
          
           /** If you have handled the error,   it can be reset with this call. The error
           state is automatically cleared if you Parse a new XML block.
           */
           void ClearError(   ) { error = false;
           errorId = 0;
           errorDesc = "";
           errorLocation.row = errorLocation.col = 0;
           //errorLocation.last = 0;
           }
          
           /** Write the document to standard out using formatted printing (  "pretty print" ). */
           void Print(   ) const { Print(   stdout,   0  ); }
          
           /* Write the document to a string using formatted printing (  "pretty print" ). This
           will allocate a character array (  new char[] ) and return it as a pointer. The
           calling code pust call delete[] on the return char* to avoid a memory leak.
           */
           //char* PrintToMemory(   ) const;
          
           /// Print this Document to a FILE stream.
           virtual void Print(   FILE* cfile,   int depth = 0  ) const;
           // [internal use]
           void SetError(   int err,   const char* errorLocation,   TiXmlParsingData* prevData,   TiXmlEncoding encoding  );
          
           virtual const TiXmlDocument* ToDocument(   ) const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
           virtual TiXmlDocument* ToDocument(   ) { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
          
           /** Walk the XML tree visiting this node and all of its children.
           */
           virtual bool Accept(   TiXmlVisitor* content  ) const;
          
          protected :
           // [internal use]
           virtual TiXmlNode* Clone(   ) const;
           #ifdef TIXML_USE_STL
           virtual void StreamIn(   std::istream * in,   TIXML_STRING * tag  );
           #endif
          
          private:
           void CopyTo(   TiXmlDocument* target  ) const;
          
           bool error;
           int errorId;
           TIXML_STRING errorDesc;
           int tabsize;
           TiXmlCursor errorLocation;
           bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this,   and try to write.
          };
          
          
          /**
           A TiXmlHandle is a class that wraps a node pointer with null checks; this is
           an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml
           DOM structure. It is a separate utility class.
          
           Take an example:
           @verbatim
           <Document>
           <Element attributeA = "valueA">
           <Child attributeB = "value1" />
           <Child attributeB = "value2" />
           </Element>
           <Document>
           @endverbatim
          
           Assuming you want the value of "attributeB" in the 2nd "Child" element,   it's very
           easy to write a *lot* of code that looks like:
          
           @verbatim
           TiXmlElement* root = document.FirstChildElement(   "Document"  );
           if (   root  )
           {
           TiXmlElement* element = root->FirstChildElement(   "Element"  );
           if (   element  )
           {
           TiXmlElement* child = element->FirstChildElement(   "Child"  );
           if (   child  )
           {
           TiXmlElement* child2 = child->NextSiblingElement(   "Child"  );
           if (   child2  )
           {
           // Finally do something useful.
           @endverbatim
          
           And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity
           of such code. A TiXmlHandle checks for null pointers so it is perfectly safe
           and correct to use:
          
           @verbatim
           TiXmlHandle docHandle(   &document  );
           TiXmlElement* child2 = docHandle.FirstChild(   "Document"  ).FirstChild(   "Element"  ).Child(   "Child",   1  ).ToElement(   );
           if (   child2  )
           {
           // do something useful
           @endverbatim
          
           Which is MUCH more concise and useful.
          
           It is also safe to copy handles - internally they are nothing more than node pointers.
           @verbatim
           TiXmlHandle handleCopy = handle;
           @endverbatim
          
           What they should not be used for is iteration:
          
           @verbatim
           int i=0;
           while (   true  )
           {
           TiXmlElement* child = docHandle.FirstChild(   "Document"  ).FirstChild(   "Element"  ).Child(   "Child",   i  ).ToElement(   );
           if (   !child  )
           break;
           // do something
           ++i;
           }
           @endverbatim
          
           It seems reasonable,   but it is in fact two embedded while loops. The Child method is
           a linear walk to find the element,   so this code would iterate much more than it needs
           to. Instead,   prefer:
          
           @verbatim
           TiXmlElement* child = docHandle.FirstChild(   "Document"  ).FirstChild(   "Element"  ).FirstChild(   "Child"  ).ToElement(   );
          
           for(   child; child; child=child->NextSiblingElement(   )  )
           {
           // do something
           }
           @endverbatim
          */
          class TiXmlHandle
          {
          public:
           /// Create a handle from any node (  at any depth of the tree. ) This can be a null pointer.
           TiXmlHandle(   TiXmlNode* _node  ) { this->node = _node; }
           /// Copy constructor
           TiXmlHandle(   const TiXmlHandle& ref  ) { this->node = ref.node; }
           TiXmlHandle operator=(   const TiXmlHandle& ref  ) { this->node = ref.node; return *this; }
          
           /// Return a handle to the first child node.
           TiXmlHandle FirstChild(   ) const;
           /// Return a handle to the first child node with the given name.
           TiXmlHandle FirstChild(   const char * value  ) const;
           /// Return a handle to the first child element.
           TiXmlHandle FirstChildElement(   ) const;
           /// Return a handle to the first child element with the given name.
           TiXmlHandle FirstChildElement(   const char * value  ) const;
          
           /** Return a handle to the "index" child with the given name.
           The first child is 0,   the second 1,   etc.
           */
           TiXmlHandle Child(   const char* value,   int index  ) const;
           /** Return a handle to the "index" child.
           The first child is 0,   the second 1,   etc.
           */
           TiXmlHandle Child(   int index  ) const;
           /** Return a handle to the "index" child element with the given name.
           The first child element is 0,   the second 1,   etc. Note that only TiXmlElements
           are indexed: other types are not counted.
           */
           TiXmlHandle ChildElement(   const char* value,   int index  ) const;
           /** Return a handle to the "index" child element.
           The first child element is 0,   the second 1,   etc. Note that only TiXmlElements
           are indexed: other types are not counted.
           */
           TiXmlHandle ChildElement(   int index  ) const;
          
           #ifdef TIXML_USE_STL
           TiXmlHandle FirstChild(   const std::string& _value  ) const { return FirstChild(   _value.c_str(   )  ); }
           TiXmlHandle FirstChildElement(   const std::string& _value  ) const { return FirstChildElement(   _value.c_str(   )  ); }
          
           TiXmlHandle Child(   const std::string& _value,   int index  ) const { return Child(   _value.c_str(   ),   index  ); }
           TiXmlHandle ChildElement(   const std::string& _value,   int index  ) const { return ChildElement(   _value.c_str(   ),   index  ); }
           #endif
          
           /** Return the handle as a TiXmlNode. This may return null.
           */
           TiXmlNode* ToNode(   ) const { return node; }
           /** Return the handle as a TiXmlElement. This may return null.
           */
           TiXmlElement* ToElement(   ) const { return (   (   node && node->ToElement(   )  ) ? node->ToElement(   ) : 0  ); }
           /** Return the handle as a TiXmlText. This may return null.
           */
           TiXmlText* ToText(   ) const { return (   (   node && node->ToText(   )  ) ? node->ToText(   ) : 0  ); }
           /** Return the handle as a TiXmlUnknown. This may return null.
           */
           TiXmlUnknown* ToUnknown(   ) const { return (   (   node && node->ToUnknown(   )  ) ? node->ToUnknown(   ) : 0  ); }
          
           /** @deprecated use ToNode.
           Return the handle as a TiXmlNode. This may return null.
           */
           TiXmlNode* Node(   ) const { return ToNode(   ); }
           /** @deprecated use ToElement.
           Return the handle as a TiXmlElement. This may return null.
           */
           TiXmlElement* Element(   ) const { return ToElement(   ); }
           /** @deprecated use ToText(   )
           Return the handle as a TiXmlText. This may return null.
           */
           TiXmlText* Text(   ) const { return ToText(   ); }
           /** @deprecated use ToUnknown(   )
           Return the handle as a TiXmlUnknown. This may return null.
           */
           TiXmlUnknown* Unknown(   ) const { return ToUnknown(   ); }
          
          private:
           TiXmlNode* node;
          };
          
          
          /** Print to memory functionality. The TiXmlPrinter is useful when you need to:
          
           -# Print to memory (  especially in non-STL mode )
           -# Control formatting (  line endings,   etc. )
          
           When constructed,   the TiXmlPrinter is in its default "pretty printing" mode.
           Before calling Accept(   ) you can call methods to control the printing
           of the XML document. After TiXmlNode::Accept(   ) is called,   the printed document can
           be accessed via the CStr(   ),   Str(   ),   and Size(   ) methods.
          
           TiXmlPrinter uses the Visitor API.
           @verbatim
           TiXmlPrinter printer;
           printer.SetIndent(   "\t"  );
          
           doc.Accept(   &printer  );
           fprintf(   stdout,   "%s",   printer.CStr(   )  );
           @endverbatim
          */
          class TiXmlPrinter : public TiXmlVisitor
          {
          public:
           TiXmlPrinter(   ) : depth(   0  ),   simpleTextPrint(   false  ),  
           buffer(   ),   indent(   " "  ),   lineBreak(   "\n"  ) {}
          
           virtual bool VisitEnter(   const TiXmlDocument& doc  );
           virtual bool VisitExit(   const TiXmlDocument& doc  );
          
           virtual bool VisitEnter(   const TiXmlElement& element,   const TiXmlAttribute* firstAttribute  );
           virtual bool VisitExit(   const TiXmlElement& element  );
          
           virtual bool Visit(   const TiXmlDeclaration& declaration  );
           virtual bool Visit(   const TiXmlText& text  );
           virtual bool Visit(   const TiXmlComment& comment  );
           virtual bool Visit(   const TiXmlUnknown& unknown  );
          
           /** Set the indent characters for printing. By default 4 spaces
           but tab (  \t ) is also useful,   or null/empty string for no indentation.
           */
           void SetIndent(   const char* _indent  ) { indent = _indent ? _indent : "" ; }
           /// Query the indention string.
           const char* Indent(   ) { return indent.c_str(   ); }
           /** Set the line breaking string. By default set to newline (  \n ).
           Some operating systems prefer other characters,   or can be
           set to the null/empty string for no indenation.
           */
           void SetLineBreak(   const char* _lineBreak  ) { lineBreak = _lineBreak ? _lineBreak : ""; }
           /// Query the current line breaking string.
           const char* LineBreak(   ) { return lineBreak.c_str(   ); }
          
           /** Switch over to "stream printing" which is the most dense formatting without
           linebreaks. Common when the XML is needed for network transmission.
           */
           void SetStreamPrinting(   ) { indent = "";
           lineBreak = "";
           }
           /// Return the result.
           const char* CStr(   ) { return buffer.c_str(   ); }
           /// Return the length of the result string.
           size_t Size(   ) { return buffer.size(   ); }
          
           #ifdef TIXML_USE_STL
           /// Return the result.
           const std::string& Str(   ) { return buffer; }
           #endif
          
          private:
           void DoIndent(   ) {
           for(   int i=0; i<depth; ++i  )
           buffer += indent;
           }
           void DoLineBreak(   ) {
           buffer += lineBreak;
           }
          
           int depth;
           bool simpleTextPrint;
           TIXML_STRING buffer;
           TIXML_STRING indent;
           TIXML_STRING lineBreak;
          };
          
          }
          #ifdef _MSC_VER
          #pragma warning(   pop  )
          #endif
          
          #endif
          

./framework/tinyxml/tinyxmlerror.cpp

       1  /*
          www.sourceforge.net/projects/tinyxml
          Original code (  2.0 and earlier  )copyright (  c ) 2000-2006 Lee Thomason (  www.grinninglizard.com )
          
          This software is provided 'as-is',   without any express or implied
          warranty. In no event will the authors be held liable for any
          damages arising from the use of this software.
          
          Permission is granted to anyone to use this software for any
          purpose,   including commercial applications,   and to alter it and
          redistribute it freely,   subject to the following restrictions:
          
          1. The origin of this software must not be misrepresented; you must
          not claim that you wrote the original software. If you use this
          software in a product,   an acknowledgment in the product documentation
          would be appreciated but is not required.
          
          2. Altered source versions must be plainly marked as such,   and
          must not be misrepresented as being the original software.
          
          3. This notice may not be removed or altered from any source
          distribution.
          */
          
          #include "tinyxml.h"
          namespace Ember {
          
          // The goal of the seperate error file is to make the first
          // step towards localization. tinyxml (  currently ) only supports
          // english error messages,   but the could now be translated.
          //
          // It also cleans up the code a bit.
          //
          
          const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
          {
           "No error",  
           "Error",  
           "Failed to open file",  
           "Memory allocation failed.",  
           "Error parsing Element.",  
           "Failed to read Element name",  
           "Error reading Element value.",  
           "Error reading Attributes.",  
           "Error: empty tag.",  
           "Error reading end tag.",  
           "Error parsing Unknown.",  
           "Error parsing Comment.",  
           "Error parsing Declaration.",  
           "Error document empty.",  
           "Error null (  0 ) or unexpected EOF found in input stream.",  
           "Error parsing CDATA.",  
           "Error when TiXmlDocument added to document,   because TiXmlDocument can only be at the root.",  
          };
          
          }

./framework/tinyxml/tinyxmlparser.cpp

       1  /*
          www.sourceforge.net/projects/tinyxml
          Original code (  2.0 and earlier  )copyright (  c ) 2000-2002 Lee Thomason (  www.grinninglizard.com )
          
          This software is provided 'as-is',   without any express or implied
          warranty. In no event will the authors be held liable for any
          damages arising from the use of this software.
          
          Permission is granted to anyone to use this software for any
          purpose,   including commercial applications,   and to alter it and
          redistribute it freely,   subject to the following restrictions:
          
          1. The origin of this software must not be misrepresented; you must
          not claim that you wrote the original software. If you use this
          software in a product,   an acknowledgment in the product documentation
          would be appreciated but is not required.
          
          2. Altered source versions must be plainly marked as such,   and
          must not be misrepresented as being the original software.
          
          3. This notice may not be removed or altered from any source
          distribution.
          */
          
          #include <ctype.h>
          #include <stddef.h>
          
          #include "tinyxml.h"
          
          //#define DEBUG_PARSER
          #if defined(   DEBUG_PARSER  )
          # if defined(   DEBUG  ) && defined(   _MSC_VER  )
          # include <windows.h>
          # define TIXML_LOG OutputDebugString
          # else
          # define TIXML_LOG printf
          # endif
          #endif
          
          namespace Ember {
          
          // Note tha "PutString" hardcodes the same list. This
          // is less flexible than it appears. Changing the entries
          // or order will break putstring.
          TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
          {
           { "&amp;",   5,   '&' },  
           { "&lt;",   4,   '<' },  
           { "&gt;",   4,   '>' },  
           { "&quot;",   6,   '\"' },  
           { "&apos;",   6,   '\'' }
          };
          
          // Bunch of unicode info at:
          // http://www.unicode.org/faq/utf_bom.html
          // Including the basic of this table,   which determines the #bytes in the
          // sequence from the lead byte. 1 placed for invalid sequences --
          // although the result will be junk,   pass it through as much as possible.
          // Beware of the non-characters in UTF-8:
          // ef bb bf (  Microsoft "lead bytes" )
          // ef bf be
          // ef bf bf
          
          const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
          const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
          const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
          
          const int TiXmlBase::utf8ByteTable[256] =
          {
           // 0 1 2 3 4 5 6 7 8 9 a b c d e f
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x00
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x10
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x20
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x30
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x40
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x50
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x60
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x70 End of ASCII range
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x80 0x80 to 0xc1 invalid
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0x90
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0xa0
           1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   // 0xb0
           1,   1,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   // 0xc0 0xc2 to 0xdf 2 byte
           2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   // 0xd0
           3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   // 0xe0 0xe0 to 0xef 3 byte
           4,   4,   4,   4,   4,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1 // 0xf0 0xf0 to 0xf4 4 byte,   0xf5 and higher invalid
          };
          
          
          void TiXmlBase::ConvertUTF32ToUTF8(   unsigned long input,   char* output,   int* length  )
          {
           const unsigned long BYTE_MASK = 0xBF;
           const unsigned long BYTE_MARK = 0x80;
           const unsigned long FIRST_BYTE_MARK[7] = { 0x00,   0x00,   0xC0,   0xE0,   0xF0,   0xF8,   0xFC };
          
           if (  input < 0x80 )
           *length = 1;
           else if (   input < 0x800  )
           *length = 2;
           else if (   input < 0x10000  )
           *length = 3;
           else if (   input < 0x200000  )
           *length = 4;
           else
           { *length = 0; return; } // This code won't covert this correctly anyway.
          
           output += *length;
          
           // Scary scary fall throughs.
           switch (  *length )
           {
           case 4:
           --output;
           *output = (  char )(  (  input | BYTE_MARK ) & BYTE_MASK );
           input >>= 6;
           case 3:
           --output;
           *output = (  char )(  (  input | BYTE_MARK ) & BYTE_MASK );
           input >>= 6;
           case 2:
           --output;
           *output = (  char )(  (  input | BYTE_MARK ) & BYTE_MASK );
           input >>= 6;
           case 1:
           --output;
           *output = (  char )(  input | FIRST_BYTE_MARK[*length] );
           }
          }
          
          
          /*static*/ int TiXmlBase::IsAlpha(   unsigned char anyByte,   TiXmlEncoding /*encoding*/  )
          {
           // This will only work for low-ascii,   everything else is assumed to be a valid
           // letter. I'm not sure this is the best approach,   but it is quite tricky trying
           // to figure out alhabetical vs. not across encoding. So take a very
           // conservative approach.
          
          // if (   encoding == TIXML_ENCODING_UTF8  )
          // {
           if (   anyByte < 127  )
           return isalpha(   anyByte  );
           else
           return 1; // What else to do? The unicode set is huge...get the english ones right.
          // }
          // else
          // {
          // return isalpha(   anyByte  );
          // }
          }
          
          
          /*static*/ int TiXmlBase::IsAlphaNum(   unsigned char anyByte,   TiXmlEncoding /*encoding*/  )
          {
           // This will only work for low-ascii,   everything else is assumed to be a valid
           // letter. I'm not sure this is the best approach,   but it is quite tricky trying
           // to figure out alhabetical vs. not across encoding. So take a very
           // conservative approach.
          
          // if (   encoding == TIXML_ENCODING_UTF8  )
          // {
           if (   anyByte < 127  )
           return isalnum(   anyByte  );
           else
           return 1; // What else to do? The unicode set is huge...get the english ones right.
          // }
          // else
          // {
          // return isalnum(   anyByte  );
          // }
          }
          
          
          class TiXmlParsingData
          {
           friend class TiXmlDocument;
           public:
           void Stamp(   const char* now,   TiXmlEncoding encoding  );
          
           const TiXmlCursor& Cursor(   ) { return cursor; }
          
           private:
           // Only used by the document!
           TiXmlParsingData(   const char* start,   int _tabsize,   int row,   int col  )
           {
           assert(   start  );
           stamp = start;
           tabsize = _tabsize;
           cursor.row = row;
           cursor.col = col;
           }
          
           TiXmlCursor cursor;
           const char* stamp;
           int tabsize;
          };
          
          
          void TiXmlParsingData::Stamp(   const char* now,   TiXmlEncoding encoding  )
          {
           assert(   now  );
          
           // Do nothing if the tabsize is 0.
           if (   tabsize < 1  )
           {
           return;
           }
          
           // Get the current row,   column.
           int row = cursor.row;
           int col = cursor.col;
           const char* p = stamp;
           assert(   p  );
          
           while (   p < now  )
           {
           // Treat p as unsigned,   so we have a happy compiler.
           const unsigned char* pU = (  const unsigned char* )p;
          
           // Code contributed by Fletcher Dunn: (  modified by lee )
           switch (  *pU ) {
           case 0:
           // We *should* never get here,   but in case we do,   don't
           // advance past the terminating null character,   ever
           return;
          
           case '\r':
           // bump down to the next line
           ++row;
           col = 0;
           // Eat the character
           ++p;
          
           // Check for \r\n sequence,   and treat this as a single character
           if (  *p == '\n' ) {
           ++p;
           }
           break;
          
           case '\n':
           // bump down to the next line
           ++row;
           col = 0;
          
           // Eat the character
           ++p;
          
           // Check for \n\r sequence,   and treat this as a single
           // character. (  Yes,   this bizarre thing does occur still
           // on some arcane platforms... )
           if (  *p == '\r' ) {
           ++p;
           }
           break;
          
           case '\t':
           // Eat the character
           ++p;
          
           // Skip to next tab stop
           col = (  col / tabsize + 1 ) * tabsize;
           break;
          
           case TIXML_UTF_LEAD_0:
           if (   encoding == TIXML_ENCODING_UTF8  )
           {
           if (   *(  p+1 ) && *(  p+2 )  )
           {
           // In these cases,   don't advance the column. These are
           // 0-width spaces.
           if (   *(  pU+1 )==TIXML_UTF_LEAD_1 && *(  pU+2 )==TIXML_UTF_LEAD_2  )
           p += 3;
           else if (   *(  pU+1 )==0xbfU && *(  pU+2 )==0xbeU  )
           p += 3;
           else if (   *(  pU+1 )==0xbfU && *(  pU+2 )==0xbfU  )
           p += 3;
           else
           { p +=3; ++col; } // A normal character.
           }
           }
           else
           {
           ++p;
           ++col;
           }
           break;
          
           default:
           if (   encoding == TIXML_ENCODING_UTF8  )
           {
           // Eat the 1 to 4 byte utf8 character.
           int step = TiXmlBase::utf8ByteTable[*(  (  const unsigned char* )p )];
           if (   step == 0  )
           step = 1; // Error case from bad encoding,   but handle gracefully.
           p += step;
          
           // Just advance one column,   of course.
           ++col;
           }
           else
           {
           ++p;
           ++col;
           }
           break;
           }
           }
           cursor.row = row;
           cursor.col = col;
           assert(   cursor.row >= -1  );
           assert(   cursor.col >= -1  );
           stamp = p;
           assert(   stamp  );
          }
          
          
          const char* TiXmlBase::SkipWhiteSpace(   const char* p,   TiXmlEncoding encoding  )
          {
           if (   !p || !*p  )
           {
           return 0;
           }
           if (   encoding == TIXML_ENCODING_UTF8  )
           {
           while (   *p  )
           {
           const unsigned char* pU = (  const unsigned char* )p;
          
           // Skip the stupid Microsoft UTF-8 Byte order marks
           if (   *(  pU+0 )==TIXML_UTF_LEAD_0
           && *(  pU+1 )==TIXML_UTF_LEAD_1
           && *(  pU+2 )==TIXML_UTF_LEAD_2  )
           {
           p += 3;
           continue;
           }
           else if(  *(  pU+0 )==TIXML_UTF_LEAD_0
           && *(  pU+1 )==0xbfU
           && *(  pU+2 )==0xbeU  )
           {
           p += 3;
           continue;
           }
           else if(  *(  pU+0 )==TIXML_UTF_LEAD_0
           && *(  pU+1 )==0xbfU
           && *(  pU+2 )==0xbfU  )
           {
           p += 3;
           continue;
           }
          
           if (   IsWhiteSpace(   *p  ) || *p == '\n' || *p =='\r'  ) // Still using old rules for white space.
           ++p;
           else
           break;
           }
           }
           else
           {
           while (   *p && IsWhiteSpace(   *p  ) || *p == '\n' || *p =='\r'  )
           ++p;
           }
          
           return p;
          }
          
          #ifdef TIXML_USE_STL
          /*static*/ bool TiXmlBase::StreamWhiteSpace(   std::istream * in,   TIXML_STRING * tag  )
          {
           for(   ;;  )
           {
           if (   !in->good(   )  ) return false;
          
           int c = in->peek(   );
           // At this scope,   we can't get to a document. So fail silently.
           if (   !IsWhiteSpace(   c  ) || c <= 0  )
           return true;
          
           *tag += (  char ) in->get(   );
           }
          }
          
          /*static*/ bool TiXmlBase::StreamTo(   std::istream * in,   int character,   TIXML_STRING * tag  )
          {
           //assert(   character > 0 && character < 128  ); // else it won't work in utf-8
           while (   in->good(   )  )
           {
           int c = in->peek(   );
           if (   c == character  )
           return true;
           if (   c <= 0  ) // Silent failure: can't get document at this scope
           return false;
          
           in->get(   );
           *tag += (  char ) c;
           }
           return false;
          }
          #endif
          
          // One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The
          // "assign" optimization removes over 10% of the execution time.
          //
          const char* TiXmlBase::ReadName(   const char* p,   TIXML_STRING * name,   TiXmlEncoding encoding  )
          {
           // Oddly,   not supported on some comilers,  
           //name->clear(   );
           // So use this:
           *name = "";
           assert(   p  );
          
           // Names start with letters or underscores.
           // Of course,   in unicode,   tinyxml has no idea what a letter *is*. The
           // algorithm is generous.
           //
           // After that,   they can be letters,   underscores,   numbers,  
           // hyphens,   or colons. (  Colons are valid ony for namespaces,  
           // but tinyxml can't tell namespaces from names. )
           if (   p && *p
           && (   IsAlpha(   (  unsigned char ) *p,   encoding  ) || *p == '_'  )  )
           {
           const char* start = p;
           while(   p && *p
           && (   IsAlphaNum(   (  unsigned char  ) *p,   encoding  )
           || *p == '_'
           || *p == '-'
           || *p == '.'
           || *p == ':'  )  )
           {
           //(  *name ) += *p; // expensive
           ++p;
           }
           if (   p-start > 0  ) {
           name->assign(   start,   p-start  );
           }
           return p;
           }
           return 0;
          }
          
          const char* TiXmlBase::GetEntity(   const char* p,   char* value,   int* length,   TiXmlEncoding encoding  )
          {
           // Presume an entity,   and pull it out.
           TIXML_STRING ent;
           int i;
           *length = 0;
          
           if (   *(  p+1 ) && *(  p+1 ) == '#' && *(  p+2 )  )
           {
           unsigned long ucs = 0;
           ptrdiff_t delta = 0;
           unsigned mult = 1;
          
           if (   *(  p+2 ) == 'x'  )
           {
           // Hexadecimal.
           if (   !*(  p+3 )  ) return 0;
          
           const char* q = p+3;
           q = strchr(   q,   ';'  );
          
           if (   !q || !*q  ) return 0;
          
           delta = q-p;
           --q;
          
           while (   *q != 'x'  )
           {
           if (   *q >= '0' && *q <= '9'  )
           ucs += mult * (  *q - '0' );
           else if (   *q >= 'a' && *q <= 'f'  )
           ucs += mult * (  *q - 'a' + 10 );
           else if (   *q >= 'A' && *q <= 'F'  )
           ucs += mult * (  *q - 'A' + 10  );
           else
           return 0;
           mult *= 16;
           --q;
           }
           }
           else
           {
           // Decimal.
           if (   !*(  p+2 )  ) return 0;
          
           const char* q = p+2;
           q = strchr(   q,   ';'  );
          
           if (   !q || !*q  ) return 0;
          
           delta = q-p;
           --q;
          
           while (   *q != '#'  )
           {
           if (   *q >= '0' && *q <= '9'  )
           ucs += mult * (  *q - '0' );
           else
           return 0;
           mult *= 10;
           --q;
           }
           }
           if (   encoding == TIXML_ENCODING_UTF8  )
           {
           // convert the UCS to UTF-8
           ConvertUTF32ToUTF8(   ucs,   value,   length  );
           }
           else
           {
           *value = (  char )ucs;
           *length = 1;
           }
           return p + delta + 1;
           }
          
           // Now try to match it.
           for(   i=0; i<NUM_ENTITY; ++i  )
           {
           if (   strncmp(   entity[i].str,   p,   entity[i].strLength  ) == 0  )
           {
           assert(   strlen(   entity[i].str  ) == entity[i].strLength  );
           *value = entity[i].chr;
           *length = 1;
           return (   p + entity[i].strLength  );
           }
           }
          
           // So it wasn't an entity,   its unrecognized,   or something like that.
           *value = *p; // Don't put back the last one,   since we return it!
           //*length = 1; // Leave unrecognized entities - this doesn't really work.
           // Just writes strange XML.
           return p+1;
          }
          
          
          bool TiXmlBase::StringEqual(   const char* p,  
           const char* tag,  
           bool ignoreCase,  
           TiXmlEncoding encoding  )
          {
           assert(   p  );
           assert(   tag  );
           if (   !p || !*p  )
           {
           assert(   0  );
           return false;
           }
          
           const char* q = p;
          
           if (   ignoreCase  )
           {
           while (   *q && *tag && ToLower(   *q,   encoding  ) == ToLower(   *tag,   encoding  )  )
           {
           ++q;
           ++tag;
           }
          
           if (   *tag == 0  )
           return true;
           }
           else
           {
           while (   *q && *tag && *q == *tag  )
           {
           ++q;
           ++tag;
           }
          
           if (   *tag == 0  ) // Have we found the end of the tag,   and everything equal?
           return true;
           }
           return false;
          }
          
          const char* TiXmlBase::ReadText(   const char* p,  
           TIXML_STRING * text,  
           bool trimWhiteSpace,  
           const char* endTag,  
           bool caseInsensitive,  
           TiXmlEncoding encoding  )
          {
           *text = "";
           if (   !trimWhiteSpace // certain tags always keep whitespace
           || !condenseWhiteSpace  ) // if true,   whitespace is always kept
           {
           // Keep all the white space.
           while (   p && *p
           && !StringEqual(   p,   endTag,   caseInsensitive,   encoding  )
            )
           {
           int len;
           char cArr[4] = { 0,   0,   0,   0 };
           p = GetChar(   p,   cArr,   &len,   encoding  );
           text->append(   cArr,   len  );
           }
           }
           else
           {
           bool whitespace = false;
          
           // Remove leading white space:
           p = SkipWhiteSpace(   p,   encoding  );
           while (   p && *p
           && !StringEqual(   p,   endTag,   caseInsensitive,   encoding  )  )
           {
           if (   *p == '\r' || *p == '\n'  )
           {
           whitespace = true;
           ++p;
           }
           else if (   IsWhiteSpace(   *p  )  )
           {
           whitespace = true;
           ++p;
           }
           else
           {
           // If we've found whitespace,   add it before the
           // new character. Any whitespace just becomes a space.
           if (   whitespace  )
           {
           (  *text ) += ' ';
           whitespace = false;
           }
           int len;
           char cArr[4] = { 0,   0,   0,   0 };
           p = GetChar(   p,   cArr,   &len,   encoding  );
           if (   len == 1  )
           (  *text ) += cArr[0]; // more efficient
           else
           text->append(   cArr,   len  );
           }
           }
           }
           if (   p  )
           p += strlen(   endTag  );
           return p;
          }
          
          #ifdef TIXML_USE_STL
          
          void TiXmlDocument::StreamIn(   std::istream * in,   TIXML_STRING * tag  )
          {
           // The basic issue with a document is that we don't know what we're
           // streaming. Read something presumed to be a tag (  and hope ),   then
           // identify it,   and call the appropriate stream method on the tag.
           //
           // This "pre-streaming" will never read the closing ">" so the
           // sub-tag can orient itself.
          
           if (   !StreamTo(   in,   '<',   tag  )  )
           {
           SetError(   TIXML_ERROR_PARSING_EMPTY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return;
           }
          
           while (   in->good(   )  )
           {
           int tagIndex = (  int ) tag->length(   );
           while (   in->good(   ) && in->peek(   ) != '>'  )
           {
           int c = in->get(   );
           if (   c <= 0  )
           {
           SetError(   TIXML_ERROR_EMBEDDED_NULL,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           break;
           }
           (  *tag ) += (  char ) c;
           }
          
           if (   in->good(   )  )
           {
           // We now have something we presume to be a node of
           // some sort. Identify it,   and call the node to
           // continue streaming.
           TiXmlNode* node = Identify(   tag->c_str(   ) + tagIndex,   TIXML_DEFAULT_ENCODING  );
          
           if (   node  )
           {
           node->StreamIn(   in,   tag  );
           bool isElement = node->ToElement(   ) != 0;
           delete node;
           node = 0;
          
           // If this is the root element,   we're done. Parsing will be
           // done by the >> operator.
           if (   isElement  )
           {
           return;
           }
           }
           else
           {
           SetError(   TIXML_ERROR,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return;
           }
           }
           }
           // We should have returned sooner.
           SetError(   TIXML_ERROR,   0,   0,   TIXML_ENCODING_UNKNOWN  );
          }
          
          #endif
          
          const char* TiXmlDocument::Parse(   const char* p,   TiXmlParsingData* prevData,   TiXmlEncoding encoding  )
          {
           ClearError(   );
          
           // Parse away,   at the document level. Since a document
           // contains nothing but other tags,   most of what happens
           // here is skipping white space.
           if (   !p || !*p  )
           {
           SetError(   TIXML_ERROR_DOCUMENT_EMPTY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return 0;
           }
          
           // Note that,   for a document,   this needs to come
           // before the while space skip,   so that parsing
           // starts from the pointer we are given.
           location.Clear(   );
           if (   prevData  )
           {
           location.row = prevData->cursor.row;
           location.col = prevData->cursor.col;
           }
           else
           {
           location.row = 0;
           location.col = 0;
           }
           TiXmlParsingData data(   p,   TabSize(   ),   location.row,   location.col  );
           location = data.Cursor(   );
          
           if (   encoding == TIXML_ENCODING_UNKNOWN  )
           {
           // Check for the Microsoft UTF-8 lead bytes.
           const unsigned char* pU = (  const unsigned char* )p;
           if (   *(  pU+0 ) && *(  pU+0 ) == TIXML_UTF_LEAD_0
           && *(  pU+1 ) && *(  pU+1 ) == TIXML_UTF_LEAD_1
           && *(  pU+2 ) && *(  pU+2 ) == TIXML_UTF_LEAD_2  )
           {
           encoding = TIXML_ENCODING_UTF8;
           useMicrosoftBOM = true;
           }
           }
          
           p = SkipWhiteSpace(   p,   encoding  );
           if (   !p  )
           {
           SetError(   TIXML_ERROR_DOCUMENT_EMPTY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return 0;
           }
          
           while (   p && *p  )
           {
           TiXmlNode* node = Identify(   p,   encoding  );
           if (   node  )
           {
           p = node->Parse(   p,   &data,   encoding  );
           LinkEndChild(   node  );
           }
           else
           {
           break;
           }
          
           // Did we get encoding info?
           if (   encoding == TIXML_ENCODING_UNKNOWN
           && node->ToDeclaration(   )  )
           {
           TiXmlDeclaration* dec = node->ToDeclaration(   );
           const char* enc = dec->Encoding(   );
           assert(   enc  );
          
           if (   *enc == 0  )
           encoding = TIXML_ENCODING_UTF8;
           else if (   StringEqual(   enc,   "UTF-8",   true,   TIXML_ENCODING_UNKNOWN  )  )
           encoding = TIXML_ENCODING_UTF8;
           else if (   StringEqual(   enc,   "UTF8",   true,   TIXML_ENCODING_UNKNOWN  )  )
           encoding = TIXML_ENCODING_UTF8; // incorrect,   but be nice
           else
           encoding = TIXML_ENCODING_LEGACY;
           }
          
           p = SkipWhiteSpace(   p,   encoding  );
           }
          
           // Was this empty?
           if (   !firstChild  ) {
           SetError(   TIXML_ERROR_DOCUMENT_EMPTY,   0,   0,   encoding  );
           return 0;
           }
          
           // All is well.
           return p;
          }
          
          void TiXmlDocument::SetError(   int err,   const char* pError,   TiXmlParsingData* data,   TiXmlEncoding encoding  )
          {
           // The first error in a chain is more accurate - don't set again!
           if (   error  )
           return;
          
           assert(   err > 0 && err < TIXML_ERROR_STRING_COUNT  );
           error = true;
           errorId = err;
           errorDesc = errorString[ errorId ];
          
           errorLocation.Clear(   );
           if (   pError && data  )
           {
           data->Stamp(   pError,   encoding  );
           errorLocation = data->Cursor(   );
           }
          }
          
          
          TiXmlNode* TiXmlNode::Identify(   const char* p,   TiXmlEncoding encoding  )
          {
           TiXmlNode* returnNode = 0;
          
           p = SkipWhiteSpace(   p,   encoding  );
           if(   !p || !*p || *p != '<'  )
           {
           return 0;
           }
          
           TiXmlDocument* doc = GetDocument(   );
           p = SkipWhiteSpace(   p,   encoding  );
          
           if (   !p || !*p  )
           {
           return 0;
           }
          
           // What is this thing?
           // - Elements start with a letter or underscore,   but xml is reserved.
           // - Comments: <!--
           // - Decleration: <?xml
           // - Everthing else is unknown to tinyxml.
           //
          
           const char* xmlHeader = { "<?xml" };
           const char* commentHeader = { "<!--" };
           const char* dtdHeader = { "<!" };
           const char* cdataHeader = { "<![CDATA[" };
          
           if (   StringEqual(   p,   xmlHeader,   true,   encoding  )  )
           {
           #ifdef DEBUG_PARSER
           TIXML_LOG(   "XML parsing Declaration\n"  );
           #endif
           returnNode = new TiXmlDeclaration(   );
           }
           else if (   StringEqual(   p,   commentHeader,   false,   encoding  )  )
           {
           #ifdef DEBUG_PARSER
           TIXML_LOG(   "XML parsing Comment\n"  );
           #endif
           returnNode = new TiXmlComment(   );
           }
           else if (   StringEqual(   p,   cdataHeader,   false,   encoding  )  )
           {
           #ifdef DEBUG_PARSER
           TIXML_LOG(   "XML parsing CDATA\n"  );
           #endif
           TiXmlText* text = new TiXmlText(   ""  );
           text->SetCDATA(   true  );
           returnNode = text;
           }
           else if (   StringEqual(   p,   dtdHeader,   false,   encoding  )  )
           {
           #ifdef DEBUG_PARSER
           TIXML_LOG(   "XML parsing Unknown(  1 )\n"  );
           #endif
           returnNode = new TiXmlUnknown(   );
           }
           else if (   IsAlpha(   *(  p+1 ),   encoding  )
           || *(  p+1 ) == '_'  )
           {
           #ifdef DEBUG_PARSER
           TIXML_LOG(   "XML parsing Element\n"  );
           #endif
           returnNode = new TiXmlElement(   ""  );
           }
           else
           {
           #ifdef DEBUG_PARSER
           TIXML_LOG(   "XML parsing Unknown(  2 )\n"  );
           #endif
           returnNode = new TiXmlUnknown(   );
           }
          
           if (   returnNode  )
           {
           // Set the parent,   so it can report errors
           returnNode->parent = this;
           }
           else
           {
           if (   doc  )
           doc->SetError(   TIXML_ERROR_OUT_OF_MEMORY,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           }
           return returnNode;
          }
          
          #ifdef TIXML_USE_STL
          
          void TiXmlElement::StreamIn (  std::istream * in,   TIXML_STRING * tag )
          {
           // We're called with some amount of pre-parsing. That is,   some of "this"
           // element is in "tag". Go ahead and stream to the closing ">"
           while(   in->good(   )  )
           {
           int c = in->get(   );
           if (   c <= 0  )
           {
           TiXmlDocument* document = GetDocument(   );
           if (   document  )
           document->SetError(   TIXML_ERROR_EMBEDDED_NULL,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return;
           }
           (  *tag ) += (  char ) c ;
          
           if (   c == '>'  )
           break;
           }
          
           if (   tag->length(   ) < 3  ) return;
          
           // Okay...if we are a "/>" tag,   then we're done. We've read a complete tag.
           // If not,   identify and stream.
          
           if (   tag->at(   tag->length(   ) - 1  ) == '>'
           && tag->at(   tag->length(   ) - 2  ) == '/'  )
           {
           // All good!
           return;
           }
           else if (   tag->at(   tag->length(   ) - 1  ) == '>'  )
           {
           // There is more. Could be:
           // text
           // cdata text (  which looks like another node )
           // closing tag
           // another node.
           for (   ;;  )
           {
           StreamWhiteSpace(   in,   tag  );
          
           // Do we have text?
           if (   in->good(   ) && in->peek(   ) != '<'  )
           {
           // Yep,   text.
           TiXmlText text(   ""  );
           text.StreamIn(   in,   tag  );
          
           // What follows text is a closing tag or another node.
           // Go around again and figure it out.
           continue;
           }
          
           // We now have either a closing tag...or another node.
           // We should be at a "<",   regardless.
           if (   !in->good(   )  ) return;
           assert(   in->peek(   ) == '<'  );
           int tagIndex = (  int ) tag->length(   );
          
           bool closingTag = false;
           bool firstCharFound = false;
          
           for(   ;;  )
           {
           if (   !in->good(   )  )
           return;
          
           int c = in->peek(   );
           if (   c <= 0  )
           {
           TiXmlDocument* document = GetDocument(   );
           if (   document  )
           document->SetError(   TIXML_ERROR_EMBEDDED_NULL,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return;
           }
          
           if (   c == '>'  )
           break;
          
           *tag += (  char ) c;
           in->get(   );
          
           // Early out if we find the CDATA id.
           if (   c == '[' && tag->size(   ) >= 9  )
           {
           size_t len = tag->size(   );
           const char* start = tag->c_str(   ) + len - 9;
           if (   strcmp(   start,   "<![CDATA["  ) == 0  ) {
           assert(   !closingTag  );
           break;
           }
           }
          
           if (   !firstCharFound && c != '<' && !IsWhiteSpace(   c  )  )
           {
           firstCharFound = true;
           if (   c == '/'  )
           closingTag = true;
           }
           }
           // If it was a closing tag,   then read in the closing '>' to clean up the input stream.
           // If it was not,   the streaming will be done by the tag.
           if (   closingTag  )
           {
           if (   !in->good(   )  )
           return;
          
           int c = in->get(   );
           if (   c <= 0  )
           {
           TiXmlDocument* document = GetDocument(   );
           if (   document  )
           document->SetError(   TIXML_ERROR_EMBEDDED_NULL,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return;
           }
           assert(   c == '>'  );
           *tag += (  char ) c;
          
           // We are done,   once we've found our closing tag.
           return;
           }
           else
           {
           // If not a closing tag,   id it,   and stream.
           const char* tagloc = tag->c_str(   ) + tagIndex;
           TiXmlNode* node = Identify(   tagloc,   TIXML_DEFAULT_ENCODING  );
           if (   !node  )
           return;
           node->StreamIn(   in,   tag  );
           delete node;
           node = 0;
          
           // No return: go around from the beginning: text,   closing tag,   or node.
           }
           }
           }
          }
          #endif
          
          const char* TiXmlElement::Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  )
          {
           p = SkipWhiteSpace(   p,   encoding  );
           TiXmlDocument* document = GetDocument(   );
          
           if (   !p || !*p  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_PARSING_ELEMENT,   0,   0,   encoding  );
           return 0;
           }
          
           if (   data  )
           {
           data->Stamp(   p,   encoding  );
           location = data->Cursor(   );
           }
          
           if (   *p != '<'  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_PARSING_ELEMENT,   p,   data,   encoding  );
           return 0;
           }
          
           p = SkipWhiteSpace(   p+1,   encoding  );
          
           // Read the name.
           const char* pErr = p;
          
           p = ReadName(   p,   &value,   encoding  );
           if (   !p || !*p  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,   pErr,   data,   encoding  );
           return 0;
           }
          
           TIXML_STRING endTag (  "</" );
           endTag += value;
           endTag += ">";
          
           // Check for and read attributes. Also look for an empty
           // tag or an end tag.
           while (   p && *p  )
           {
           pErr = p;
           p = SkipWhiteSpace(   p,   encoding  );
           if (   !p || !*p  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_READING_ATTRIBUTES,   pErr,   data,   encoding  );
           return 0;
           }
           if (   *p == '/'  )
           {
           ++p;
           // Empty tag.
           if (   *p != '>'  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_PARSING_EMPTY,   p,   data,   encoding  );
           return 0;
           }
           return (  p+1 );
           }
           else if (   *p == '>'  )
           {
           // Done with attributes (  if there were any. )
           // Read the value -- which can include other
           // elements -- read the end tag,   and return.
           ++p;
           p = ReadValue(   p,   data,   encoding  ); // Note this is an Element method,   and will set the error if one happens.
           if (   !p || !*p  )
           return 0;
          
           // We should find the end tag now
           if (   StringEqual(   p,   endTag.c_str(   ),   false,   encoding  )  )
           {
           p += endTag.length(   );
           return p;
           }
           else
           {
           if (   document  ) document->SetError(   TIXML_ERROR_READING_END_TAG,   p,   data,   encoding  );
           return 0;
           }
           }
           else
           {
           // Try to read an attribute:
           TiXmlAttribute* attrib = new TiXmlAttribute(   );
           if (   !attrib  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_OUT_OF_MEMORY,   pErr,   data,   encoding  );
           return 0;
           }
          
           attrib->SetDocument(   document  );
           pErr = p;
           p = attrib->Parse(   p,   data,   encoding  );
          
           if (   !p || !*p  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_PARSING_ELEMENT,   pErr,   data,   encoding  );
           delete attrib;
           return 0;
           }
          
           // Handle the strange case of double attributes:
           #ifdef TIXML_USE_STL
           TiXmlAttribute* node = attributeSet.Find(   attrib->NameTStr(   )  );
           #else
           TiXmlAttribute* node = attributeSet.Find(   attrib->Name(   )  );
           #endif
           if (   node  )
           {
           node->SetValue(   attrib->Value(   )  );
           delete attrib;
           return 0;
           }
          
           attributeSet.Add(   attrib  );
           }
           }
           return p;
          }
          
          
          const char* TiXmlElement::ReadValue(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  )
          {
           TiXmlDocument* document = GetDocument(   );
          
           // Read in text and elements in any order.
           const char* pWithWhiteSpace = p;
           p = SkipWhiteSpace(   p,   encoding  );
          
           while (   p && *p  )
           {
           if (   *p != '<'  )
           {
           // Take what we have,   make a text element.
           TiXmlText* textNode = new TiXmlText(   ""  );
          
           if (   !textNode  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_OUT_OF_MEMORY,   0,   0,   encoding  );
           return 0;
           }
          
           if (   TiXmlBase::IsWhiteSpaceCondensed(   )  )
           {
           p = textNode->Parse(   p,   data,   encoding  );
           }
           else
           {
           // Special case: we want to keep the white space
           // so that leading spaces aren't removed.
           p = textNode->Parse(   pWithWhiteSpace,   data,   encoding  );
           }
          
           if (   !textNode->Blank(   )  )
           LinkEndChild(   textNode  );
           else
           delete textNode;
           }
           else
           {
           // We hit a '<'
           // Have we hit a new element or an end tag? This could also be
           // a TiXmlText in the "CDATA" style.
           if (   StringEqual(   p,   "</",   false,   encoding  )  )
           {
           return p;
           }
           else
           {
           TiXmlNode* node = Identify(   p,   encoding  );
           if (   node  )
           {
           p = node->Parse(   p,   data,   encoding  );
           LinkEndChild(   node  );
           }
           else
           {
           return 0;
           }
           }
           }
           pWithWhiteSpace = p;
           p = SkipWhiteSpace(   p,   encoding  );
           }
          
           if (   !p  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_READING_ELEMENT_VALUE,   0,   0,   encoding  );
           }
           return p;
          }
          
          
          #ifdef TIXML_USE_STL
          void TiXmlUnknown::StreamIn(   std::istream * in,   TIXML_STRING * tag  )
          {
           while (   in->good(   )  )
           {
           int c = in->get(   );
           if (   c <= 0  )
           {
           TiXmlDocument* document = GetDocument(   );
           if (   document  )
           document->SetError(   TIXML_ERROR_EMBEDDED_NULL,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return;
           }
           (  *tag ) += (  char ) c;
          
           if (   c == '>'  )
           {
           // All is well.
           return;
           }
           }
          }
          #endif
          
          
          const char* TiXmlUnknown::Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  )
          {
           TiXmlDocument* document = GetDocument(   );
           p = SkipWhiteSpace(   p,   encoding  );
          
           if (   data  )
           {
           data->Stamp(   p,   encoding  );
           location = data->Cursor(   );
           }
           if (   !p || !*p || *p != '<'  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_PARSING_UNKNOWN,   p,   data,   encoding  );
           return 0;
           }
           ++p;
           value = "";
          
           while (   p && *p && *p != '>'  )
           {
           value += *p;
           ++p;
           }
          
           if (   !p  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_PARSING_UNKNOWN,   0,   0,   encoding  );
           }
           if (   *p == '>'  )
           return p+1;
           return p;
          }
          
          #ifdef TIXML_USE_STL
          void TiXmlComment::StreamIn(   std::istream * in,   TIXML_STRING * tag  )
          {
           while (   in->good(   )  )
           {
           int c = in->get(   );
           if (   c <= 0  )
           {
           TiXmlDocument* document = GetDocument(   );
           if (   document  )
           document->SetError(   TIXML_ERROR_EMBEDDED_NULL,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return;
           }
          
           (  *tag ) += (  char ) c;
          
           if (   c == '>'
           && tag->at(   tag->length(   ) - 2  ) == '-'
           && tag->at(   tag->length(   ) - 3  ) == '-'  )
           {
           // All is well.
           return;
           }
           }
          }
          #endif
          
          
          const char* TiXmlComment::Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  )
          {
           TiXmlDocument* document = GetDocument(   );
           value = "";
          
           p = SkipWhiteSpace(   p,   encoding  );
          
           if (   data  )
           {
           data->Stamp(   p,   encoding  );
           location = data->Cursor(   );
           }
           const char* startTag = "<!--";
           const char* endTag = "-->";
          
           if (   !StringEqual(   p,   startTag,   false,   encoding  )  )
    1349   {
           document->SetError(   TIXML_ERROR_PARSING_COMMENT,   p,   data,   encoding  );
           return 0;
           }
           p += strlen(   startTag  );
           p = ReadText(   p,   &value,   false,   endTag,   false,   encoding  );
           return p;
          }
          
          
          const char* TiXmlAttribute::Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  )
          {
           p = SkipWhiteSpace(   p,   encoding  );
           if (   !p || !*p  ) return 0;
          
          // int tabsize = 4;
          // if (   document  )
          // tabsize = document->TabSize(   );
          
           if (   data  )
           {
           data->Stamp(   p,   encoding  );
           location = data->Cursor(   );
    1372   }
           // Read the name,   the '=' and the value.
           const char* pErr = p;
           p = ReadName(   p,   &name,   encoding  );
           if (   !p || !*p  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_READING_ATTRIBUTES,   pErr,   data,   encoding  );
           return 0;
           }
           p = SkipWhiteSpace(   p,   encoding  );
           if (   !p || !*p || *p != '='  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_READING_ATTRIBUTES,   p,   data,   encoding  );
           return 0;
           }
          
           ++p; // skip '='
           p = SkipWhiteSpace(   p,   encoding  );
           if (   !p || !*p  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_READING_ATTRIBUTES,   p,   data,   encoding  );
           return 0;
           }
          
           const char* end;
           const char SINGLE_QUOTE = '\'';
           const char DOUBLE_QUOTE = '\"';
          
           if (   *p == SINGLE_QUOTE  )
           {
           ++p;
           end = "\'"; // single quote in string
           p = ReadText(   p,   &value,   false,   end,   false,   encoding  );
           }
           else if (   *p == DOUBLE_QUOTE  )
           {
           ++p;
           end = "\""; // double quote in string
           p = ReadText(   p,   &value,   false,   end,   false,   encoding  );
           }
           else
           {
           // All attribute values should be in single or double quotes.
           // But this is such a common error that the parser will try
           // its best,   even without them.
           value = "";
           while (   p && *p // existence
           && !IsWhiteSpace(   *p  ) && *p != '\n' && *p != '\r' // whitespace
           && *p != '/' && *p != '>'  ) // tag end
           {
           if (   *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE  ) {
           // [ 1451649 ] Attribute values with trailing quotes not handled correctly
           // We did not have an opening quote but seem to have a
           // closing one. Give up and throw an error.
           if (   document  ) document->SetError(   TIXML_ERROR_READING_ATTRIBUTES,   p,   data,   encoding  );
           return 0;
           }
           value += *p;
           ++p;
    1431   }
           }
           return p;
          }
          
          #ifdef TIXML_USE_STL
          void TiXmlText::StreamIn(   std::istream * in,   TIXML_STRING * tag  )
          {
           while (   in->good(   )  )
           {
           int c = in->peek(   );
           if (   !cdata && (  c == '<'  )  )
           {
           return;
           }
           if (   c <= 0  )
           {
           TiXmlDocument* document = GetDocument(   );
           if (   document  )
           document->SetError(   TIXML_ERROR_EMBEDDED_NULL,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return;
           }
          
           (  *tag ) += (  char ) c;
           in->get(   ); // "commits" the peek made above
          
           if (   cdata && c == '>' && tag->size(   ) >= 3  ) {
           size_t len = tag->size(   );
           if (   (  *tag )[len-2] == ']' && (  *tag )[len-3] == ']'  ) {
           // terminator of cdata.
           return;
           }
           }
           }
          }
          #endif
          
          const char* TiXmlText::Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding encoding  )
          {
           value = "";
           TiXmlDocument* document = GetDocument(   );
          
           if (   data  )
           {
           data->Stamp(   p,   encoding  );
           location = data->Cursor(   );
           }
          
           const char* const startTag = "<![CDATA[";
           const char* const endTag = "]]>";
          
           if (   cdata || StringEqual(   p,   startTag,   false,   encoding  )  )
           {
           cdata = true;
          
           if (   !StringEqual(   p,   startTag,   false,   encoding  )  )
           {
           document->SetError(   TIXML_ERROR_PARSING_CDATA,   p,   data,   encoding  );
           return 0;
           }
           p += strlen(   startTag  );
          
           // Keep all the white space,   ignore the encoding,   etc.
           while (   p && *p
           && !StringEqual(   p,   endTag,   false,   encoding  )
            )
           {
           value += *p;
           ++p;
           }
          
           TIXML_STRING dummy;
           p = ReadText(   p,   &dummy,   false,   endTag,   false,   encoding  );
           return p;
           }
           else
           {
           bool ignoreWhite = true;
          
           const char* end = "<";
           p = ReadText(   p,   &value,   ignoreWhite,   end,   false,   encoding  );
           if (   p  )
           return p-1; // don't truncate the '<'
           return 0;
           }
          }
          
          #ifdef TIXML_USE_STL
          void TiXmlDeclaration::StreamIn(   std::istream * in,   TIXML_STRING * tag  )
          {
           while (   in->good(   )  )
           {
           int c = in->get(   );
           if (   c <= 0  )
           {
           TiXmlDocument* document = GetDocument(   );
           if (   document  )
           document->SetError(   TIXML_ERROR_EMBEDDED_NULL,   0,   0,   TIXML_ENCODING_UNKNOWN  );
           return;
           }
           (  *tag ) += (  char ) c;
          
           if (   c == '>'  )
           {
           // All is well.
           return;
           }
           }
          }
          #endif
          
          const char* TiXmlDeclaration::Parse(   const char* p,   TiXmlParsingData* data,   TiXmlEncoding _encoding  )
          {
           p = SkipWhiteSpace(   p,   _encoding  );
           // Find the beginning,   find the end,   and look for
           // the stuff in-between.
           TiXmlDocument* document = GetDocument(   );
           if (   !p || !*p || !StringEqual(   p,   "<?xml",   true,   _encoding  )  )
           {
           if (   document  ) document->SetError(   TIXML_ERROR_PARSING_DECLARATION,   0,   0,   _encoding  );
           return 0;
           }
           if (   data  )
           {
           data->Stamp(   p,   _encoding  );
           location = data->Cursor(   );
           }
           p += 5;
          
           version = "";
           encoding = "";
           standalone = "";
          
           while (   p && *p  )
           {
           if (   *p == '>'  )
           {
           ++p;
           return p;
           }
          
           p = SkipWhiteSpace(   p,   _encoding  );
           if (   StringEqual(   p,   "version",   true,   _encoding  )  )
           {
           TiXmlAttribute attrib;
           p = attrib.Parse(   p,   data,   _encoding  );
           version = attrib.Value(   );
           }
           else if (   StringEqual(   p,   "encoding",   true,   _encoding  )  )
           {
           TiXmlAttribute attrib;
           p = attrib.Parse(   p,   data,   _encoding  );
           encoding = attrib.Value(   );
           }
           else if (   StringEqual(   p,   "standalone",   true,   _encoding  )  )
           {
           TiXmlAttribute attrib;
           p = attrib.Parse(   p,   data,   _encoding  );
           standalone = attrib.Value(   );
           }
           else
           {
           // Read over whatever it is.
           while(   p && *p && *p != '>' && !IsWhiteSpace(   *p  )  )
           ++p;
           }
           }
           return 0;
          }
          
          bool TiXmlText::Blank(   ) const
          {
           for (   unsigned i=0; i<value.length(   ); i++  )
           if (   !IsWhiteSpace(   value[i]  )  )
           return false;
           return true;
          }
          
          }
          

./main/Application.cpp

       1  /*
           * File: Application.cpp
           * Summary: The class which initializes the GUI.
           * Written by: nikal
           *
           * Copyright (  C ) 2001,   2002 nikal.
           * This code is distributed under the GPL.
           * See file COPYING for details.
           *
          
           */
          
          #include "Application.h"
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #ifdef WIN32
           #include <tchar.h>
           #define snprintf _snprintf
           #include <io.h> // for _access,   Win32 version of stat(   )
           #include <direct.h> // for _mkdir
          // #include <sys/stat.h>
          
           #include <iostream>
           #include <fstream>
           #include <ostream>
          #else
           #include <dirent.h>
          #endif
          
          #include <Eris/View.h>
          #include <Eris/PollDefault.h>
          
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/server/ServerService.h"
          #include "services/config/ConfigService.h"
          #include "services/metaserver/MetaserverService.h"
          #include "services/sound/SoundService.h"
          #include "services/scripting/ScriptingService.h"
          #include "services/wfut/WfutService.h"
          
          #include "framework/ConsoleBackend.h"
          #include "framework/StreamLogObserver.h"
          
          #include "components/ogre/EmberOgre.h"
          
          #include "LogObserver.h"
          
          #include <iostream>
          #include <sstream>
          #ifndef WIN32
          #include <stdio.h>
          #endif
          
          #include "framework/osdir.h"
          
          
          namespace Ember
          {
          
          template<> Ember::Application *Ember::Singleton<Ember::Application>::ms_Singleton = 0;
          
          
      67  Application::Application(  const std::string prefix,   const std::string homeDir,   const ConfigMap& configSettings )
          : mOgreView(  0 )
          ,   mShouldQuit(  false )
          ,   mPrefix(  prefix )
          ,   mHomeDir(  homeDir )
          ,   mLogObserver(  0 )
          ,   mServices(  0 )
          ,   mWorldView(  0 )
          ,   mPollEris(  true )
          ,   mConfigSettings(  configSettings )
          {
          
          }
          
          
      82  Application::~Application(   )
          {
           EmberServices::getSingleton(   ).getServerService(   )->stop(  0 );
           ///this will not destroy the scripting environments,   since there are other components,   such as windows in the gui,   that depend on the scripting environment being available at destruction time
           EmberServices::getSingleton(   ).getScriptingService(   )->stop(  0 );
          // mOgreView->shutdownGui(   );
           delete mOgreView;
           delete mServices;
           LoggingService::getInstance(   )->removeObserver(  mLogObserver );
           delete mLogObserver;
          }
          
      94  void Application::registerComponents(   )
          {
           mOgreView = new EmberOgre::EmberOgre(   );
          }
          
          
     100  void Application::mainLoopStep(   )
          {
           try {
           if (  mPollEris ) {
           EventStartErisPoll.emit(   );
           Eris::PollDefault::poll(  1 );
           if (  mWorldView )
           mWorldView->update(   );
           EventEndErisPoll.emit(   );
           }
           mOgreView->renderOneFrame(   );
           } catch (  const Ember::Exception& ex ) {
           S_LOG_CRITICAL(  ex.getError(   ) );
           throw;
           } catch (  const std::exception& ex )
           {
           S_LOG_CRITICAL(  "Got exception,   shutting down. " << ex.what(   ) );
           throw;
           } catch (  const std::string& ex )
           {
           S_LOG_CRITICAL(  "Got exception,   shutting down. " << ex );
           throw;
           } catch (  ... )
           {
           S_LOG_CRITICAL(  "Got unknown exception." );
           throw;
           }
          }
          
     129  void Application::mainLoop(   )
          {
           while(  mShouldQuit == false )
           {
           mainLoopStep(   );
           }
          }
          
     137  void Application::prepareComponents(   )
          {
          }
     140  void Application::initializeServices(   )
          {
           /// Initialize Ember services
           std::cout << "Initializing Ember services" << std::endl;
          
           mServices = new EmberServices(   );
           Ember::LoggingService *logging = EmberServices::getSingleton(   ).getLoggingService(   );
          
           /// Initialize the Configuration Service
           EmberServices::getSingleton(   ).getConfigService(   )->start(   );
           EmberServices::getSingleton(   ).getConfigService(   )->setPrefix(  mPrefix );
           if (  mHomeDir != "" ) {
           EmberServices::getSingleton(   ).getConfigService(   )->setHomeDirectory(  mHomeDir );
           std::cout << "Setting home directory to " << mHomeDir << std::endl;
           }
          
           ///output all logging to ember.log
           std::string filename(  EmberServices::getSingleton(   ).getConfigService(   )->getHomeDirectory(   ) + "/ember.log" );
           mLogOutStream = std::auto_ptr<std::ofstream>(  new std::ofstream(  filename.c_str(   ) ) );
          
           ///write to the log the version number
           *mLogOutStream << "Ember version " << VERSION << ",   using media version " << MEDIA_VERSION << std::endl;
          
           mLogObserver = new LogObserver(  *mLogOutStream );
           logging->addObserver(  mLogObserver );
          
           ///default to INFO,   though this can be changed by the config file
           mLogObserver->setFilter(  Ember::LoggingService::INFO );
          
          
          
          
           /// Change working directory
           const std::string& dirName = EmberServices::getSingleton(   ).getConfigService(   )->getHomeDirectory(   );
           oslink::directory osdir(  dirName );
          
           if (  !osdir ) {
          #ifdef WIN32
           mkdir(  dirName.c_str(   ) );
          #else
           mkdir(  dirName.c_str(   ),   S_IRWXU );
          #endif
           }
          
          
           int result = chdir(  EmberServices::getSingleton(   ).getConfigService(   )->getHomeDirectory(   ).c_str(   ) );
           if (  result ) {
           S_LOG_WARNING(  "Could not change directory to '"<< EmberServices::getSingleton(   ).getConfigService(   )->getHomeDirectory(   ).c_str(   ) <<"'." );
           }
          
          // const std::string& sharePath(  EmberServices::getSingleton(   ).getConfigService(   )->getSharedConfigDirectory(   ) );
          
           ///make sure that there are files
           ///assureConfigFile(  "ember.conf",   sharePath );
          
           EmberServices::getSingleton(   ).getConfigService(   )->loadSavedConfig(  "ember.conf" );
           ///after loading the config from file,   override with command time settings
           for (  ConfigMap::iterator I = mConfigSettings.begin(   ); I != mConfigSettings.end(   ); ++I ) {
           for (  std::map<std::string,   std::string>::iterator J = I->second.begin(   ); J != I->second.end(   ); ++J ) {
           EmberServices::getSingleton(   ).getConfigService(   )->setValue(  I->first,   J->first,   J->second );
           }
           }
          
          // #ifndef WIN32
          // /// Initialize the SoundService
          // if (  EmberServices::getSingleton(   ).getSoundService(   )->start(   ) == Ember::Service::OK ) {
          // EmberServices::getSingleton(   ).getSoundService(   )->registerSoundProvider(  new OgreSoundProvider(   ) );
          // }
          // #endif
          
           /// Initialize and start the Metaserver Service.
           S_LOG_INFO(  "Initializing metaserver service" );
          
           EmberServices::getSingleton(   ).getMetaserverService(   )->start(   );
           ///hoho,   we get linking errors if we don't do some calls to the service
           EmberServices::getSingleton(   ).getMetaserverService(   )->getMetaServer(   );
          
           /// Initialize the Server Service
           S_LOG_INFO(  "Initializing server service" );
           EmberServices::getSingleton(   ).getServerService(   )->start(   );
          
           S_LOG_INFO(  "Initializing scripting service" );
           EmberServices::getSingleton(   ).getScriptingService(   )->start(   );
          
           S_LOG_INFO(  "Initializing wfut service" );
           EmberServices::getSingleton(   ).getWfutService(   )->start(   );
          
          
           EmberServices::getSingleton(   ).getServerService(   )->GotView.connect(  sigc::mem_fun(  *this,   &Application::Server_GotView ) );
          
           EventServicesInitialized.emit(   );
          }
          
     233  void Application::Server_GotView(  Eris::View* view )
          {
           mWorldView = view;
          }
          
     238  Eris::View* Application::getMainView(   )
          {
           return mWorldView;
          }
          
     243  void Application::start(   )
          {
           try {
           mOgreView->setup(   );
           } catch (  const std::exception& ex ) {
           S_LOG_CRITICAL(  "Error when setting up Ogre: " << ex.what(   ) );
           return;
           } catch (  ... ) {
           S_LOG_CRITICAL(  "Unknown error when setting up Ogre." );
           return;
           }
           mainLoop(   );
           //mOgreView->go(  mUseBinreloc );
          }
          
     258  bool Application::shouldQuit(   )
          {
           return mShouldQuit;
          }
          
     263  void Application::requestQuit(   )
          {
           bool handled = false;
           EventRequestQuit.emit(  handled );
           ///check it was handled (  for example if the gui wants to show a confirmation window )
           if (  !handled ) {
           ///it's not handled,   quit now
           quit(   );
           }
          
          }
     274  void Application::quit(   )
          {
           mShouldQuit = true;
          }
          
     279  void Application::runCommand(  const std::string& cmd,   const std::string& args )
          {
          }
          
     283  void Application::setErisPolling(  bool doPoll )
          {
           mPollEris = doPoll;
          }
          
     288  bool Application::getErisPolling(   ) const
          {
           return mPollEris;
          }
          
          
          
          
          }

./main/Application.h

       1  /*
           * File: Application.h
           * Summary: The class which initializes the GUI.
           * Written by: nikal
           *
           * Copyright (  C ) 2001,   2002 nikal.
           * This code is distributed under the GPL.
           * See file COPYING for details.
           *
           */
          
          #ifndef EMBER_APPLICATION_H
          #define EMBER_APPLICATION_H
          
          #include <list>
          #include <string>
          #include <fstream>
          #include <map>
          
          #include "services/EmberServices.h"
          #include "framework/ConsoleObject.h"
          
          #include <sigc++/signal.h>
          
          namespace Eris
          {
      27   class View;
          }
          
          namespace EmberOgre
          {
      32   class EmberOgre;
          }
      34  namespace Ember
          {
           class EmberServices;
           class LogObserver;
          
           class Application : public ConsoleObject,   public Ember::Singleton<Application>
           {
           //======================================================================
           // Inner Classes,   Typedefs,   and Enums
           //======================================================================
          
           public:
           typedef std::map<std::string,   std::map<std::string,   std::string> > ConfigMap;
           //======================================================================
           // Public Methods
           //======================================================================
           Application(  const std::string prefix,   const std::string homeDir,   const ConfigMap& configSettings );
          
           /**
           * Dtor for Ember::Application. Free the current surface.
           *
           */
           ~Application(   );
          
           /**
           * Main loop step. Does one iteration of the mainloop.
           *
           *
           */
           void mainLoopStep(   );
          
           /**
           * the Main loop. Returns when application has received an "exit" command
           *
           */
           void mainLoop(   );
          
           /**
           * return true if application has received an "exit" command else false.
           *
           * @return true if "shouldquit" else false
           */
           bool shouldQuit(   );
          
           void registerComponents(   );
           void prepareComponents(   );
           void initializeServices(   );
           void start(   );
          
           sigc::signal<void> EventServicesInitialized;
          
          
          
           /**
           * Causes the application to quit.
           */
           void quit(   );
          
          
           /**
           * Callback for running Console Commands
           */
           void runCommand(  const std::string&,  const std::string& );
          
           /**
           * Sets whether eris should be polled each frame. Defaults to true.
           * @param doPoll
           */
           void setErisPolling(  bool doPoll );
          
           /**
           * Gets whether eris should be polled each frame.
           * @return
           */
           bool getErisPolling(   ) const;
          
           /**
           * Emitted when the use wants to quit the game. Preferrebly the GUI should show some kind of confirmation window.
           */
           sigc::signal<void,   bool&> EventRequestQuit;
          
           /**
           Emitted before the eris polling is started
           */
           sigc::signal<void> EventStartErisPoll;
          
           /**
           Emitted after the eris polling has finished
           */
           sigc::signal<void> EventEndErisPoll;
          
           /**
           * Call this to "soft quit" the app. This means that an signal will be emitted,   which hopefully will be taken care of by some widget,   which will show a confirmation window,   asking the user if he/she wants to quit.
           However,   if there is no widget etc. handling the request,   the application will instantly quit.
           */
           void requestQuit(   );
          
           /**
           * Accessor for the main eris world view,   if any.
           */
           Eris::View* getMainView(   );
          
           private:
          
          
          // IGameView mGraphicalComponent;
           EmberOgre::EmberOgre* mOgreView;
           bool mShouldQuit;
           const std::string mPrefix;
           const std::string mHomeDir;
          
           /**
           The main log observer used for all logging.
           */
           LogObserver* mLogObserver;
          
           /**
           The main services object.
           */
           EmberServices* mServices;
          
           /**
           Once connected to a world,   this will hold the main world view.
           */
           Eris::View* mWorldView;
          
           /**
           Controls whether eris should be polled at each frame update.
           */
           bool mPollEris;
          
           void Server_GotView(  Eris::View* view );
          
           std::auto_ptr<std::ofstream> mLogOutStream;
          
           ConfigMap mConfigSettings;
          
          };//class Application
          }//namespace Ember
          
          #endif

./main/Ember.cpp

          /*
           Copyright (  C ) 2001,  2002 Martin Pollard (  Xmp ),   Lakin Weckerd (  nikal )
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "Application.h"
          #include "framework/Tokeniser.h"
          
          #ifdef WIN32
           #include <tchar.h>
           #define snprintf _snprintf
           #include <io.h> // for _access,   Win32 version of stat(   )
           #include <direct.h> // for _mkdir
          // #include <sys/stat.h>
          
           #include <iostream>
           #include <fstream>
           #include <ostream>
          #else
           #include <dirent.h>
          #endif
          
          #include <stdlib.h>
          #include <stddef.h>
          #include <stdio.h>
          #include <iostream>
          
          #include "framework/binreloc.h" //this is needed for binreloc functionality
          
          
          #ifdef __WIN32__
          #define WIN32_LEAN_AND_MEAN
          #include "windows.h"
          /**
          * Main function,   just boots the application object
          */
          INT WINAPI WinMain(   HINSTANCE hInst,   HINSTANCE,   LPSTR strCmdLine,   INT  )
          #else
          int main(  int argc,   char **argv )
          #endif
          {
      59   int exitStatus(  0 );
           bool exit_program = false;
      61   std::string prefix(  "" );
      62   std::string homeDir(  "" );
           Ember::Application::ConfigMap configMap;
          #ifndef __WIN32__
           if (  argc > 1 ) {
           std::string invoked = std::string(  (  char * )argv[0] );
           (  argv )++;
           argc--;
           while (  argc > 0 ) {
           std::string arg = std::string(  (  char * )argv[0] );
           argv++;
           argc--;
           if (  arg == "-v" || arg == "--version" ) {
           std::cout << "Ember version: " << VERSION << std::endl;
           exit_program = true;
           } else if (  arg == "-h" || arg == "--help" ) {
           std::cout << invoked << " {options}" << std::endl;
           std::cout << "-h,   --help - display this message" << std::endl;
           std::cout << "-v,   --version - display version info" << std::endl;
           std::cout << "--home <path>- sets the home directory to something different than the default (  ~/.ember on *NIX systems,   $APPDATA\\Ember on win32 systems )" << std::endl;
           std::cout << "-p <path>,   --prefix <path> - sets the prefix to something else than the one set at compilation (  only valid on *NIX systems )" << std::endl;
           std::cout << "--config <section>:<key> <value> - allows you to override config file settings. See the ember.conf file for examples. (  ~/.ember/ember.conf on *NIX systems )" << std::endl;
           exit_program = true;
           } else if (  arg == "-p" || arg == "--prefix" ) {
           if (  !argc ) {
           std::cout << "You didn't supply a prefix.";
           exit_program = true;
           } else {
           prefix = std::string(  (  char * )argv[0] );
           argv++;
           argc--;
           }
          
           } else if (  arg == "--home" ) {
           if (  !argc ) {
           std::cout << "You didn't supply a home directory.";
           exit_program = true;
           } else {
           homeDir = std::string(  (  char * )argv[0] );
           argv++;
           argc--;
           }
          
           } else if (  arg == "--config" ) {
           if (  argc < 2 ) {
           std::cout << "You didn't supply any config arguments.";
           } else {
           std::string fullkey(  argv[0] );
           std::string value(  argv[1] );
           Ember::Tokeniser tokeniser(  fullkey,   ":" );
           if (  tokeniser.remainingTokens(   ) != "" ) {
           std::string category(  tokeniser.nextToken(   ) );
           if (  tokeniser.remainingTokens(   ) != "" ) {
           std::string key(  tokeniser.nextToken(   ) );
           configMap[category][key] = value;
           }
           }
           }
           }
           }
           }
          
           if (  exit_program ) {
           if (  homeDir != "" ) {
           if (  chdir(  homeDir.c_str(   ) ) ) {
           std::cerr << "Could not set homedir to '" << homeDir << "'." << std::endl;
           }
           } else {
           if (  chdir(  "~/.ember" ) ) {
           std::cerr << "Could not set homedir to '~/.ember'." << std::endl;
           }
           }
           return 0;
           }
          
          #ifdef ENABLE_BINRELOC
           if (  prefix == "" ) {
           BrInitError error;
          
           if (  br_init (  &error ) == 0 && error != BR_INIT_ERROR_DISABLED ) {
           printf (  "Warning: BinReloc failed to initialize (  error code %d )\n",   error );
           printf (  "Will fallback to hardcoded default path.\n" );
           }
          
           char* br_prefixdir = br_find_prefix(  PREFIX );
           const std::string prefixDir(  br_prefixdir );
           free(  br_prefixdir );
           prefix = prefixDir;
           }
          
          #endif
           if (  prefix == "" ) {
           prefix = PREFIX;
           }
          
          #else
           // char tmp[64];
          
           // unsigned int floatSetting = _controlfp(   0,   0  );
           //sprintf(  tmp,   "Original: 0x%.4x\n",   floatSetting  );
           // MessageBox(   0,   tmp,   "floating point control",   MB_OK | MB_ICONERROR | MB_TASKMODAL );
           //_fpreset(   );
           //_controlfp(  _PC_64,   _MCW_PC );
           //_controlfp(  _RC_NEAR ,   _MCW_RC );
           //floatSetting = _controlfp(   0,   0  );
           //sprintf(  tmp,   "New: 0x%.4x\n",   floatSetting  );
           // MessageBox(   0,   tmp,   "floating point control",   MB_OK | MB_ICONERROR | MB_TASKMODAL );
          
          #endif
          
           ///put the application object in its own scope so it gets destroyed before we signal all clear
           {
           try {
           /// Create application object
           Ember::Application app(  prefix,   homeDir,   configMap );
           //EmberOgre::EmberOgre app;
          
           std::cout << "Starting Ember version " << VERSION << std::endl;
          
           app.registerComponents(   );
          
           /// Initialize all Ember services needed for this application
           app.prepareComponents(   );
           app.initializeServices(   );
          
           app.start(   );
           } catch (  const std::exception& ex )
           {
           std::cerr << "Unexpected error,   aborting.\n\r" << ex.what(   );
           exitStatus = 1;
           }
           }
          
          #ifndef __WIN32__
           if (  homeDir != "" ) {
           if (  chdir(  homeDir.c_str(   ) ) ) {
           std::cerr << "Could not set homedir to '" << homeDir << "'." << std::endl;
           }
           } else {
           if (  chdir(  "~/.ember" ) ) {
           std::cerr << "Could not set homedir to '~/.ember'." << std::endl;
           }
           }
          #endif
           std::cout << "Ember shut down successfully." << std::endl;
           return exitStatus;
          }

./main/LogObserver.cpp

       1  //
          // C++ Implementation: LogObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "LogObserver.h"
          
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/config/ConfigService.h"
          
          namespace Ember {
          
      31  LogObserver::LogObserver(  std::ostream &out )
          : Ember::StreamLogObserver(  out )
          {
           Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->EventChangedConfigItem.connect(  sigc::mem_fun(  *this,   &LogObserver::ConfigService_EventChangedConfigItem ) );
          
          }
          
          
          
      40  LogObserver::~LogObserver(   )
          {
          }
          
          /**
           * Updates from the config. The relevant section is "general" and the key "logginglevel". It can have the values of verbose|info|warning|failure|critical
           */
      47  void LogObserver::updateFromConfig(   )
          {
           if (  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->itemExists(  "general",   "logginglevel" ) ) {
           std::string loggingLevel = static_cast<std::string>(  Ember::EmberServices::getSingletonPtr(   )->getConfigService(   )->getValue(  "general",   "logginglevel" ) );
           Ember::LoggingService::MessageImportance importance(  Ember::LoggingService::INFO );
           if (  loggingLevel == "verbose" ) {
           importance = Ember::LoggingService::VERBOSE;
           } else if (  loggingLevel == "info" ) {
           importance = Ember::LoggingService::INFO;
           } else if (  loggingLevel == "warning" ) {
           importance = Ember::LoggingService::WARNING;
           } else if (  loggingLevel == "failure" ) {
           importance = Ember::LoggingService::FAILURE;
           } else if (  loggingLevel == "critical" ) {
           importance = Ember::LoggingService::CRITICAL;
           }
           setFilter(  importance );
           }
          }
          
          
          /**
           * React on changes to the config.
           * @param section
           * @param key
           */
      73  void LogObserver::ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key )
          {
           if (  section == "general" ) {
           if (  key == "logginglevel" ) {
           updateFromConfig(   );
           }
           }
          }
          
          }

./main/LogObserver.h

       1  //
          // C++ Interface: LogObserver
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERLOGOBSERVER_H
          #define EMBERLOGOBSERVER_H
          
          #include "framework/StreamLogObserver.h"
          
          namespace Ember {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      33  class LogObserver : public Ember::StreamLogObserver,   public sigc::trackable
          {
          public:
      36   LogObserver(  std::ostream &out );
          
      38   ~LogObserver(   );
          
          protected:
          
           /**
           * Updates from the config. The relevant section is "general" and the key "logginglevel". It can have the values of verbose|info|warning|failure|critical
           */
      45   void updateFromConfig(   );
          
          
           /**
           * React on changes to the config.
           * @param section
           * @param key
           */
      53   void ConfigService_EventChangedConfigItem(  const std::string& section,   const std::string& key );
          
          
          };
          
          }
          
          #endif

./main/bindings/lua/lua_Main.cpp

       1  /*
          ** Lua binding: Application
          ** Generated automatically by tolua++-1.0.92 on Thu Apr 12 22:40:51 2007.
          */
          
          #ifndef __cplusplus
          #include "stdlib.h"
          #endif
          #include "string.h"
          
          #include "tolua++.h"
          
          /* Exported function */
      14  TOLUA_API int tolua_Application_open (  lua_State* tolua_S );
          
          #include "required.h"
          
          /* function to register type */
      19  static void tolua_reg_types (  lua_State* tolua_S )
          {
           tolua_usertype(  tolua_S,  "Ember::Application" );
           tolua_usertype(  tolua_S,  "sigc::signal<void>" );
           tolua_usertype(  tolua_S,  "Eris::View" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  bool&>" );
          }
          
          /* method: getSingleton of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_Application_Ember_Application_getSingleton00
      29  static int tolua_Application_Ember_Application_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ember::Application",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ember::Application& tolua_ret = (  Ember::Application& ) Ember::Application::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Ember::Application" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: shouldQuit of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_Application_Ember_Application_shouldQuit00
      57  static int tolua_Application_Ember_Application_shouldQuit00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::Application",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'shouldQuit'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->shouldQuit(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'shouldQuit'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventServicesInitialized of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__Application_EventServicesInitialized
      89  static int tolua_get_Ember__Application_EventServicesInitialized(  lua_State* tolua_S )
          {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventServicesInitialized'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventServicesInitialized,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventServicesInitialized of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__Application_EventServicesInitialized
     102  static int tolua_set_Ember__Application_EventServicesInitialized(  lua_State* tolua_S )
          {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventServicesInitialized'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventServicesInitialized = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: quit of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_Application_Ember_Application_quit00
     119  static int tolua_Application_Ember_Application_quit00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::Application",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'quit'",  NULL );
          #endif
           {
           self->quit(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'quit'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setErisPolling of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_Application_Ember_Application_setErisPolling00
     150  static int tolua_Application_Ember_Application_setErisPolling00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::Application",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool doPoll = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setErisPolling'",  NULL );
          #endif
           {
           self->setErisPolling(  doPoll );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setErisPolling'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getErisPolling of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_Application_Ember_Application_getErisPolling00
     183  static int tolua_Application_Ember_Application_getErisPolling00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::Application",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::Application* self = (  const Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getErisPolling'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getErisPolling(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getErisPolling'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventRequestQuit of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__Application_EventRequestQuit
     215  static int tolua_get_Ember__Application_EventRequestQuit(  lua_State* tolua_S )
          {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventRequestQuit'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventRequestQuit,  "sigc::signal<void,  bool&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventRequestQuit of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__Application_EventRequestQuit
     228  static int tolua_set_Ember__Application_EventRequestQuit(  lua_State* tolua_S )
          {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventRequestQuit'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  bool&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventRequestQuit = *(  (  sigc::signal<void,  bool&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventStartErisPoll of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__Application_EventStartErisPoll
     245  static int tolua_get_Ember__Application_EventStartErisPoll(  lua_State* tolua_S )
          {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventStartErisPoll'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventStartErisPoll,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventStartErisPoll of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__Application_EventStartErisPoll
     258  static int tolua_set_Ember__Application_EventStartErisPoll(  lua_State* tolua_S )
          {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventStartErisPoll'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventStartErisPoll = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventEndErisPoll of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__Application_EventEndErisPoll
     275  static int tolua_get_Ember__Application_EventEndErisPoll(  lua_State* tolua_S )
          {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventEndErisPoll'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventEndErisPoll,  "sigc::signal<void>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventEndErisPoll of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__Application_EventEndErisPoll
     288  static int tolua_set_Ember__Application_EventEndErisPoll(  lua_State* tolua_S )
          {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventEndErisPoll'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventEndErisPoll = *(  (  sigc::signal<void>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: requestQuit of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_Application_Ember_Application_requestQuit00
     305  static int tolua_Application_Ember_Application_requestQuit00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::Application",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'requestQuit'",  NULL );
          #endif
           {
           self->requestQuit(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'requestQuit'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMainView of class Ember::Application */
          #ifndef TOLUA_DISABLE_tolua_Application_Ember_Application_getMainView00
     336  static int tolua_Application_Ember_Application_getMainView00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::Application",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::Application* self = (  Ember::Application* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMainView'",  NULL );
          #endif
           {
           Eris::View* tolua_ret = (  Eris::View* ) self->getMainView(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Eris::View" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMainView'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* Open function */
     367  TOLUA_API int tolua_Application_open (  lua_State* tolua_S )
          {
           tolua_open(  tolua_S );
           tolua_reg_types(  tolua_S );
           tolua_module(  tolua_S,  NULL,  0 );
           tolua_beginmodule(  tolua_S,  NULL );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           tolua_cclass(  tolua_S,  "Application",  "Ember::Application",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "Application" );
           tolua_function(  tolua_S,  "getSingleton",  tolua_Application_Ember_Application_getSingleton00 );
           tolua_function(  tolua_S,  "shouldQuit",  tolua_Application_Ember_Application_shouldQuit00 );
           tolua_variable(  tolua_S,  "EventServicesInitialized",  tolua_get_Ember__Application_EventServicesInitialized,  tolua_set_Ember__Application_EventServicesInitialized );
           tolua_function(  tolua_S,  "quit",  tolua_Application_Ember_Application_quit00 );
           tolua_function(  tolua_S,  "setErisPolling",  tolua_Application_Ember_Application_setErisPolling00 );
           tolua_function(  tolua_S,  "getErisPolling",  tolua_Application_Ember_Application_getErisPolling00 );
           tolua_variable(  tolua_S,  "EventRequestQuit",  tolua_get_Ember__Application_EventRequestQuit,  tolua_set_Ember__Application_EventRequestQuit );
           tolua_variable(  tolua_S,  "EventStartErisPoll",  tolua_get_Ember__Application_EventStartErisPoll,  tolua_set_Ember__Application_EventStartErisPoll );
           tolua_variable(  tolua_S,  "EventEndErisPoll",  tolua_get_Ember__Application_EventEndErisPoll,  tolua_set_Ember__Application_EventEndErisPoll );
           tolua_function(  tolua_S,  "requestQuit",  tolua_Application_Ember_Application_requestQuit00 );
           tolua_function(  tolua_S,  "getMainView",  tolua_Application_Ember_Application_getMainView00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           return 1;
          }
          
          
          #if defined(  LUA_VERSION_NUM ) && LUA_VERSION_NUM >= 501
     396   TOLUA_API int luaopen_Application (  lua_State* tolua_S ) {
           return tolua_Application_open(  tolua_S );
          };
          #endif
          

./main/bindings/lua/required.h

       1  //
          // C++ Interface: required
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          
          #include "main/Application.h"

./mscprag.h

       1  #pragma warning (  disable:4786 )
          #pragma warning (  disable:4290 )

./services/EmberServices.cpp

          /*
           Copyright (  C ) 2002 Hans Häggström
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          //#include "test/TestService.h"
          #include "logging/LoggingService.h"
          #include "config/ConfigService.h"
          //#include "input/InputService.h"
          //#include "gui/GuiService.h"
          #include "sound/SoundService.h"
          #include "metaserver/MetaserverService.h"
          #include "server/ServerService.h"
          #include "scripting/ScriptingService.h"
          #include "wfut/WfutService.h"
          
          
          #include "EmberServices.h"
          
          namespace Ember{
          
          
          template<> Ember::EmberServices* Ember::Singleton<Ember::EmberServices>::ms_Singleton = 0;
          
          
      43   EmberServices::~EmberServices(   )
           {
           }
          
          
          // TestService* EmberServices::getTestService(   )
          // {
          // // TODO
          // return NULL;
          // }
          
      54   LoggingService* EmberServices::getLoggingService(   )
           {
           return Ember::LoggingService::getInstance(   );
           }
          
      59   ConfigService* EmberServices::getConfigService(   )
           {
           return mConfigService->getService(   );
           }
          
          /* InputService* EmberServices::getInputService(   )
           {
           return Ember::InputService::getInstance(   );
           }
           */
          
          /*
           GuiService* EmberServices::getGuiService(   )
           {
           if (  myGuiService == NULL )
           myGuiService = new Ember::GuiService(   );
          
           return myGuiService;
           }
          */
      79   MetaserverService* EmberServices::getMetaserverService(   )
           {
           return mMetaserverService->getService(   );
           }
          
      84   ServerService* EmberServices::getServerService(   )
           {
           return mServerService->getService(   );
           }
          
      89   SoundService* EmberServices::getSoundService(   )
           {
           return mSoundService->getService(   );
           }
          
      94   ScriptingService* EmberServices::getScriptingService(   )
           {
           return mScriptingService->getService(   );
           }
          
      99   Ember::WfutService* EmberServices::getWfutService(   )
           {
           return mWfutService->getService(   );
           }
          
          
     105   EmberServices::EmberServices(   )
           : mScriptingService(  std::auto_ptr<ServiceContainer<ScriptingService> >(  new ServiceContainer<ScriptingService>(   ) )  )
           ,   mSoundService(  std::auto_ptr<ServiceContainer<SoundService> >(  new ServiceContainer<SoundService>(   ) )  )
           ,   mServerService(  std::auto_ptr<ServiceContainer<ServerService> >(  new ServiceContainer<ServerService>(   ) )  )
           ,   mMetaserverService(  std::auto_ptr<ServiceContainer<MetaserverService> >(  new ServiceContainer<MetaserverService>(   ) )  )
          // ,   mInputService(  std::auto_ptr<ServiceContainer<InputService> >(  new ServiceContainer<InputService>(   ) )  )
           ,   mWfutService(  std::auto_ptr<ServiceContainer<WfutService> >(  new ServiceContainer<WfutService>(   ) )  )
           ,   mConfigService(  std::auto_ptr<ServiceContainer<ConfigService> >(  new ServiceContainer<ConfigService>(   ) )  )
           {
           }
          
          }

./services/EmberServices.h

          /*
           Copyright (  C ) 2002 Hans Häggström
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef DIME_SERVICES_H
          #define DIME_SERVICES_H
          
          #include "framework/Singleton.h"
          #include <memory>
          
          
          namespace Ember {
          
           // some forward declarations before we start
      29   class LoggingService;
      30   class ConfigService;
      31   class InputService;
           //class GuiService;
      33   class MetaserverService;
      34   class ServerService;
      35   class SoundService;
      36   class TestService;
      37   class ScriptingService;
      38   class WfutService;
          
          
          
          
          template <typename T>
      44   class UninitializedInnerServiceContainer;
          
          template <typename T>
      47  class IInnerServiceContainer
          {
          public:
      50   virtual ~IInnerServiceContainer(   ) {}
      51   virtual T* getService(   ) = 0;
      52   virtual bool hasService(   ) = 0;
          
          };
          
          /**
          A simple container for a service. Upon the first call to getService(   ),   a new instance will be created.
          The main reason for doing it this way is to remove an extra null check every time a service is accessed.
          */
          template <typename T>
      61  class ServiceContainer
          {
          public:
           ServiceContainer(   )
           : mInnerContainer(  new UninitializedInnerServiceContainer<T>(  this ) )
           {
           }
          
      69   T* getService(   )
           {
           return mInnerContainer->getService(   );
           }
          
      74   void setInnerContainer(  IInnerServiceContainer<T>* newContainer )
           {
           mInnerContainer = std::auto_ptr<IInnerServiceContainer<T> >(  newContainer );
           }
          
      79   bool hasService(   )
           {
           return mInnerContainer->hasService(   );
           }
          
          private:
           std::auto_ptr<IInnerServiceContainer<T> > mInnerContainer;
          };
          
          
          template <typename T>
          class InitializedInnerServiceContainer : public IInnerServiceContainer<T>
          {
          public:
           InitializedInnerServiceContainer(   )
           : mService(  new T )
           {
           }
          
           virtual ~InitializedInnerServiceContainer(   )
           {
           mService->stop(  0 );
           }
          
           virtual T* getService(   )
           {
           return mService.get(   );
           }
          
           virtual bool hasService(   )
           {
           return true;
           }
          
          private:
           std::auto_ptr<T> mService;
          };
          
          template <typename T>
          class UninitializedInnerServiceContainer : public IInnerServiceContainer<T>
          {
          public:
           UninitializedInnerServiceContainer(  ServiceContainer<T>* container ): mContainer(  container )
           {
           }
          
           virtual T* getService(   )
           {
           //since the call to setInnerContainer will result in this current object actually getting deleted,   we have to save the reference of the container on the stack,   else we'll get segfaults if the memory holding mContainer is claimed by something else
           ServiceContainer<T>* tempContainer = mContainer;
           tempContainer->setInnerContainer(  new InitializedInnerServiceContainer<T>(   ) );
           return tempContainer->getService(   );
           }
          
           virtual bool hasService(   )
           {
           return false;
           }
          private:
           ServiceContainer<T>* mContainer;
          };
          
          
          
          /**
           * This is a singleton class that is used to access instances of all the
           * different Ember services.
           *
           * There's a getServiceName(   ) method for each service. <p>
           *
           * TODO: Should this class also create the instances of the services,  
           * or should it have set methods for them? <p>
           *
           * Example: <p>
           * <code>
           *
           * EmberServices.getInstance(   )->getLoggingService(   )->log(   ...  ); <br/>
           * ... = EmberServices.getInstance(   )->getMetaServerService(   )->getMetaServerList(   );
           *
           * </code>
           *
           * @author Hans Häggström
           */
          class EmberServices : public Ember::Singleton<EmberServices>
          {
          
          
           public:
          
           EmberServices(   );
          
           /**
           * Deletes a EmberServices instance.
           */
           virtual ~EmberServices(   );
          
           /**
           * Returns an instance of the TestService.
           */
           Ember::TestService *getTestService(   );
          
          
           /**
           * Returns an instance of the LoggingService
           */
           Ember::LoggingService *getLoggingService(   );
          
           /**
           * Returns an instance of the ConfigService
           */
           Ember::ConfigService *getConfigService(   );
          
           /**
           * Returns an instance of the InputService
           */
           Ember::InputService *getInputService(   );
          
           /**
           * Returns an instance of the GuiService
           */
           //Ember::GuiService *getGuiService(   );
          
           /**
           * Returns an instance of the MetaserverService
           */
           Ember::MetaserverService *getMetaserverService(   );
          
           /**
           * Returns an instance of the ServerService
           */
           Ember::ServerService *getServerService(   );
          
           /**
           * Returns an instance of the SoundService
           */
           Ember::SoundService *getSoundService(   );
          
           /**
           * Returns an instance of the ScriptingService
           */
           Ember::ScriptingService *getScriptingService(   );
          
           /**
           * Returns an instance of the ScriptingService
           */
           Ember::WfutService *getWfutService(   );
          
           //----------------------------------------------------------------------
           // Setters
          
           //======================================================================
           // Disabled constructors and operators
           //======================================================================
           private:
          
          
          
           /**
           * Copy constructor not provided.
           */
           EmberServices(   const EmberServices &source  )
           {
           }
          
          
           /**
           * Assignment operator not provided.
           */
           EmberServices &operator= (   const EmberServices &source  )
           {
           return *this;
           }
          
          private:
          
           std::auto_ptr<ServiceContainer<ScriptingService> > mScriptingService;
           std::auto_ptr<ServiceContainer<SoundService> > mSoundService;
           std::auto_ptr<ServiceContainer<ServerService> > mServerService;
           std::auto_ptr<ServiceContainer<MetaserverService> > mMetaserverService;
          // std::auto_ptr<ServiceContainer<InputService> > mInputService;
           std::auto_ptr<ServiceContainer<WfutService> > mWfutService;
           std::auto_ptr<ServiceContainer<ConfigService> > mConfigService;
          
          
          };
          }
          
          #endif

./services/ServiceTest.cpp

       1  /*
           Copyright (  C ) 2002 Miguel Guzman Miranda [Aglanor]
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          //#include "ServiceManager.h"
          #include "test/TestService.h"
          #include "config/ConfigService.h"
          #include "metaserver/MetaserverService.h"
          #include "Eris/PollDefault.h"
          //#include "LoggingService.h"
          
          #include <iostream>
          
          
      29  int main(   )
          {
          
           std::cout << "Dime Service Test running" << std::endl;
          
           std::cout << "***TESTING TEST SERVICE***" << std::endl;
           dime::TestService myTestService;
           myTestService.start(   );
           std::cout << "My name is: " << myTestService.getName(   ) << std::endl;
           std::cout << myTestService.getDescription(   ) << std::endl;
           myTestService.stop(  0 );
           std::cout << "***END TEST OF TEST SERVICE***" << std::endl;
          
           std::cout << "***TESTING CONFIG SERVICE***" << std::endl;
           dime::ConfigService myConfigService;
           myConfigService.start(   );
           std::cout << "My name is: " << myConfigService.getName(   ) << std::endl;
           std::cout << myTestService.getDescription(   ) << std::endl;
           myConfigService.stop(  0 );
           std::cout << "***END TEST OF CONFIG SERVICE***" << std::endl;
          
           std::cout << "***TESTING METASERVER SERVICE***" << std::endl;
           dime::MetaserverService myMsService;
           myMsService.start(   );
           Eris::PollDefault::poll(   );
           while(  true )
           {
          // myMsService.poll(   );
           }
           std::cout << "My name is: " << myMsService.getName(   ) << std::endl;
           std::cout << myMsService.getDescription(   ) << std::endl;
           myMsService.stop(  0 );
           //delete myMsService;
           std::cout << "***END TEST OF METASERVER SERVICE***" << std::endl;
          
           //std::cout << "***TESTING SERVICE MANAGER***" << std::endl;
           //std::cout << "***adding and listing one service***" << std::endl;
           //dime::services::ServiceManager myServiceManager;
           //myServiceManager.addService(  &myTestService );
           //myServiceManager.listAll(   );
           //std::cout << "***adding and listing the second service***" << std::endl;
           //dime::services::test::TestService myTestService2;
           //myServiceManager.addService(  &myTestService2 );
           //myServiceManager.listAll(   );
           //std::cout << "***removing the first service,   listing again***" << std::endl;
           //myServiceManager.removeService(  &myTestService );
           //myServiceManager.listAll(   );
           //std::cout << "***END OF TESTING SERVICE MANAGER***" << std::endl;
           std::cout << "Dime Service Test ends" << std::endl;
           //dime::services::LoggingService ls;
          
           return 0;
          
          }

./services/bindings/lua/lua_EmberServices.cpp

       1  /*
          ** Lua binding: EmberServices
          ** Generated automatically by tolua++-1.0.92 on Thu Jan 24 21:43:03 2008.
          */
          
          #ifndef __cplusplus
          #include "stdlib.h"
          #endif
          #include "string.h"
          
          #include "tolua++.h"
          
          /* Exported function */
      14  TOLUA_API int tolua_EmberServices_open (  lua_State* tolua_S );
          
          #include "required.h"
          #include "services/EmberServices.h"
          #include "services/logging/LoggingService.h"
          #include "services/server/ServerService.h"
          #include "services/config/ConfigService.h"
          #include "services/metaserver/MetaserverService.h"
          #include "services/scripting/ScriptingService.h"
          
          /* function to release collected object via destructor */
          #ifdef __cplusplus
          
      27  static int tolua_collect_varconf__Variable (  lua_State* tolua_S )
          {
           varconf::Variable* self = (  varconf::Variable* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          
      34  static int tolua_collect_std__vector_std__string_ (  lua_State* tolua_S )
          {
           std::vector<std::string>* self = (  std::vector<std::string>* ) tolua_tousertype(  tolua_S,  1,  0 );
           delete self;
           return 0;
          }
          #endif
          
          
          /* function to register type */
      44  static void tolua_reg_types (  lua_State* tolua_S )
          {
           tolua_usertype(  tolua_S,  "varconf::Variable" );
           tolua_usertype(  tolua_S,  "WFMath::Quaternion" );
           tolua_usertype(  tolua_S,  "WFMath::Vector<3>" );
           tolua_usertype(  tolua_S,  "Eris::Meta" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const Atlas::Objects::Entity::RootEntity&>" );
           tolua_usertype(  tolua_S,  "Ember::ServerService" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::string&,  const std::string&>" );
           tolua_usertype(  tolua_S,  "Ember::EmberServices" );
           tolua_usertype(  tolua_S,  "std::vector<std::string>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  const std::string&>" );
           tolua_usertype(  tolua_S,  "Eris::Entity" );
           tolua_usertype(  tolua_S,  "Ember::IScriptingProvider" );
           tolua_usertype(  tolua_S,  "Ember::ScriptingService" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Eris::Avatar*>" );
           tolua_usertype(  tolua_S,  "Ember::MetaserverService" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Eris::Account*,  const std::string&>" );
           tolua_usertype(  tolua_S,  "Ember::ConfigService" );
           tolua_usertype(  tolua_S,  "WFMath::Point<3>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Eris::Connection*>" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Eris::Account*>" );
           tolua_usertype(  tolua_S,  "Ember::LoggingService" );
           tolua_usertype(  tolua_S,  "sigc::signal<void,  Eris::View*>" );
           tolua_usertype(  tolua_S,  "Atlas::Message::MapType" );
          }
          
          /* method: getInstance of class Ember::LoggingService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_LoggingService_getInstance00
      73  static int tolua_EmberServices_Ember_LoggingService_getInstance00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ember::LoggingService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ember::LoggingService* tolua_ret = (  Ember::LoggingService* ) Ember::LoggingService::getInstance(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ember::LoggingService" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getInstance'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: SETVALUE of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ConfigService_SETVALUE
     101  static int tolua_get_Ember__ConfigService_SETVALUE(  lua_State* tolua_S )
          {
           tolua_pushcppstring(  tolua_S,  (  const char* )Ember::ConfigService::SETVALUE );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: GETVALUE of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ConfigService_GETVALUE
     110  static int tolua_get_Ember__ConfigService_GETVALUE(  lua_State* tolua_S )
          {
           tolua_pushcppstring(  tolua_S,  (  const char* )Ember::ConfigService::GETVALUE );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getValue of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_getValue00
     119  static int tolua_EmberServices_Ember_ConfigService_getValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string section = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string key = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getValue'",  NULL );
          #endif
           {
           varconf::Variable tolua_ret = (  varconf::Variable ) self->getValue(  section,  key );
           {
          #ifdef __cplusplus
           void* tolua_obj = new varconf::Variable(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "varconf::Variable" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  varconf::Variable ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "varconf::Variable" );
          #endif
           }
           tolua_pushcppstring(  tolua_S,  (  const char* )section );
           tolua_pushcppstring(  tolua_S,  (  const char* )key );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setValue of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_setValue00
     165  static int tolua_EmberServices_Ember_ConfigService_setValue00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  4,  "const varconf::Variable",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ConfigService* self = (  Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string section = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string key = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const varconf::Variable* value = (  (  const varconf::Variable* ) tolua_tousertype(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setValue'",  NULL );
          #endif
           {
           self->setValue(  section,  key,  *value );
           tolua_pushcppstring(  tolua_S,  (  const char* )section );
           tolua_pushcppstring(  tolua_S,  (  const char* )key );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setValue'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isItemSet of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_isItemSet00
     204  static int tolua_EmberServices_Ember_ConfigService_isItemSet00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  5,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string section = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string key = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const std::string value = (  (  const std::string ) tolua_tocppstring(  tolua_S,  4,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isItemSet'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isItemSet(  section,  key,  value );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )section );
           tolua_pushcppstring(  tolua_S,  (  const char* )key );
           tolua_pushcppstring(  tolua_S,  (  const char* )value );
           }
           }
           return 4;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isItemSet'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: itemExists of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_itemExists00
     245  static int tolua_EmberServices_Ember_ConfigService_itemExists00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string section = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string key = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'itemExists'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->itemExists(  section,  key );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )section );
           tolua_pushcppstring(  tolua_S,  (  const char* )key );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'itemExists'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: deleteItem of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_deleteItem00
     283  static int tolua_EmberServices_Ember_ConfigService_deleteItem00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ConfigService* self = (  Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string section = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string key = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'deleteItem'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->deleteItem(  section,  key );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )section );
           tolua_pushcppstring(  tolua_S,  (  const char* )key );
           }
           }
           return 3;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'deleteItem'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: loadSavedConfig of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_loadSavedConfig00
     321  static int tolua_EmberServices_Ember_ConfigService_loadSavedConfig00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ConfigService* self = (  Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string filename = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'loadSavedConfig'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->loadSavedConfig(  filename );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )filename );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'loadSavedConfig'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: saveConfig of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_saveConfig00
     356  static int tolua_EmberServices_Ember_ConfigService_saveConfig00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ConfigService* self = (  Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string filename = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'saveConfig'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->saveConfig(  filename );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )filename );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'saveConfig'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getHomeDirectory of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_getHomeDirectory00
     391  static int tolua_EmberServices_Ember_ConfigService_getHomeDirectory00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getHomeDirectory'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getHomeDirectory(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getHomeDirectory'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSharedDataDirectory of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_getSharedDataDirectory00
     423  static int tolua_EmberServices_Ember_ConfigService_getSharedDataDirectory00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSharedDataDirectory'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getSharedDataDirectory(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSharedDataDirectory'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEmberDataDirectory of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_getEmberDataDirectory00
     455  static int tolua_EmberServices_Ember_ConfigService_getEmberDataDirectory00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEmberDataDirectory'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getEmberDataDirectory(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEmberDataDirectory'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEmberMediaDirectory of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_getEmberMediaDirectory00
     487  static int tolua_EmberServices_Ember_ConfigService_getEmberMediaDirectory00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEmberMediaDirectory'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getEmberMediaDirectory(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEmberMediaDirectory'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getUserMediaDirectory of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_getUserMediaDirectory00
     519  static int tolua_EmberServices_Ember_ConfigService_getUserMediaDirectory00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getUserMediaDirectory'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getUserMediaDirectory(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getUserMediaDirectory'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSharedMediaDirectory of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_getSharedMediaDirectory00
     551  static int tolua_EmberServices_Ember_ConfigService_getSharedMediaDirectory00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSharedMediaDirectory'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getSharedMediaDirectory(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSharedMediaDirectory'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSharedConfigDirectory of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ConfigService_getSharedConfigDirectory00
     583  static int tolua_EmberServices_Ember_ConfigService_getSharedConfigDirectory00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ConfigService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ConfigService* self = (  const Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getSharedConfigDirectory'",  NULL );
          #endif
           {
           const std::string tolua_ret = (  const std::string ) self->getSharedConfigDirectory(   );
           tolua_pushcppstring(  tolua_S,  (  const char* )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSharedConfigDirectory'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: EventChangedConfigItem of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ConfigService_EventChangedConfigItem
     615  static int tolua_get_Ember__ConfigService_EventChangedConfigItem(  lua_State* tolua_S )
          {
           Ember::ConfigService* self = (  Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventChangedConfigItem'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->EventChangedConfigItem,  "sigc::signal<void,  const std::string&,  const std::string&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: EventChangedConfigItem of class Ember::ConfigService */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ConfigService_EventChangedConfigItem
     628  static int tolua_set_Ember__ConfigService_EventChangedConfigItem(  lua_State* tolua_S )
          {
           Ember::ConfigService* self = (  Ember::ConfigService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'EventChangedConfigItem'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const std::string&,  const std::string&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->EventChangedConfigItem = *(  (  sigc::signal<void,  const std::string&,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMetaServer of class Ember::MetaserverService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_MetaserverService_getMetaServer00
     645  static int tolua_EmberServices_Ember_MetaserverService_getMetaServer00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::MetaserverService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::MetaserverService* self = (  const Ember::MetaserverService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMetaServer'",  NULL );
          #endif
           {
           Eris::Meta& tolua_ret = (  Eris::Meta& ) self->getMetaServer(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Eris::Meta" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMetaServer'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: isConnected of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_isConnected00
     677  static int tolua_EmberServices_Ember_ServerService_isConnected00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ServerService* self = (  const Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'isConnected'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->isConnected(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'isConnected'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: connect of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_connect00
     709  static int tolua_EmberServices_Ember_ServerService_connect00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnumber(  tolua_S,  3,  1,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string host = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           short port = (  (  short ) tolua_tonumber(  tolua_S,  3,  6767 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'connect'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->connect(  host,  port );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )host );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'connect'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: disconnect of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_disconnect00
     746  static int tolua_EmberServices_Ember_ServerService_disconnect00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'disconnect'",  NULL );
          #endif
           {
           self->disconnect(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'disconnect'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: takeCharacter of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_takeCharacter00
     777  static int tolua_EmberServices_Ember_ServerService_takeCharacter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string id = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'takeCharacter'",  NULL );
          #endif
           {
           self->takeCharacter(  id );
           tolua_pushcppstring(  tolua_S,  (  const char* )id );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'takeCharacter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: createCharacter of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_createCharacter00
     811  static int tolua_EmberServices_Ember_ServerService_createCharacter00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  4,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  5,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  6,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string name = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string sex = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
           const std::string type = (  (  const std::string ) tolua_tocppstring(  tolua_S,  4,  0 ) );
           const std::string description = (  (  const std::string ) tolua_tocppstring(  tolua_S,  5,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'createCharacter'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->createCharacter(  name,  sex,  type,  description );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           tolua_pushcppstring(  tolua_S,  (  const char* )name );
           tolua_pushcppstring(  tolua_S,  (  const char* )sex );
           tolua_pushcppstring(  tolua_S,  (  const char* )type );
           tolua_pushcppstring(  tolua_S,  (  const char* )description );
           }
           }
           return 5;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'createCharacter'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: moveToPoint of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_moveToPoint00
     855  static int tolua_EmberServices_Ember_ServerService_moveToPoint00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const WFMath::Point<3>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const WFMath::Point<3>* dest = (  (  const WFMath::Point<3>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'moveToPoint'",  NULL );
          #endif
           {
           self->moveToPoint(  *dest );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'moveToPoint'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: moveInDirection of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_moveInDirection00
     888  static int tolua_EmberServices_Ember_ServerService_moveInDirection00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const WFMath::Vector<3>",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const WFMath::Quaternion",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const WFMath::Vector<3>* velocity = (  (  const WFMath::Vector<3>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const WFMath::Quaternion* orientation = (  (  const WFMath::Quaternion* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'moveInDirection'",  NULL );
          #endif
           {
           self->moveInDirection(  *velocity,  *orientation );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'moveInDirection'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: moveInDirection of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_moveInDirection01
     923  static int tolua_EmberServices_Ember_ServerService_moveInDirection01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "const WFMath::Vector<3>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const WFMath::Vector<3>* velocity = (  (  const WFMath::Vector<3>* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'moveInDirection'",  NULL );
          #endif
           {
           self->moveInDirection(  *velocity );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_EmberServices_Ember_ServerService_moveInDirection00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: say of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_say00
     951  static int tolua_EmberServices_Ember_ServerService_say00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string message = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'say'",  NULL );
          #endif
           {
           self->say(  message );
           tolua_pushcppstring(  tolua_S,  (  const char* )message );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'say'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: touch of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_touch00
     985  static int tolua_EmberServices_Ember_ServerService_touch00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'touch'",  NULL );
          #endif
           {
           self->touch(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'touch'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: emote of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_emote00
    1018  static int tolua_EmberServices_Ember_ServerService_emote00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string emote = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'emote'",  NULL );
          #endif
           {
           self->emote(  emote );
           tolua_pushcppstring(  tolua_S,  (  const char* )emote );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'emote'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: drop of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_drop00
    1052  static int tolua_EmberServices_Ember_ServerService_drop00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'drop'",  NULL );
          #endif
           {
           self->drop(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'drop'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: drop of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_drop01
    1085  static int tolua_EmberServices_Ember_ServerService_drop01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "const WFMath::Vector<3>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           const WFMath::Vector<3>* offset = (  (  const WFMath::Vector<3>* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'drop'",  NULL );
          #endif
           {
           self->drop(  entity,  *offset );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_EmberServices_Ember_ServerService_drop00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: place of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_place00
    1115  static int tolua_EmberServices_Ember_ServerService_place00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Eris::Entity* target = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'place'",  NULL );
          #endif
           {
           self->place(  entity,  target );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'place'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: wield of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_wield00
    1150  static int tolua_EmberServices_Ember_ServerService_wield00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'wield'",  NULL );
          #endif
           {
           self->wield(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'wield'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: take of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_take00
    1183  static int tolua_EmberServices_Ember_ServerService_take00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'take'",  NULL );
          #endif
           {
           self->take(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'take'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: use of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_use00
    1216  static int tolua_EmberServices_Ember_ServerService_use00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'use'",  NULL );
          #endif
           {
           self->use(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'use'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: use of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_use01
    1249  static int tolua_EmberServices_Ember_ServerService_use01(  lua_State* tolua_S )
          {
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "WFMath::Point<3>",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           WFMath::Point<3> pos = *(  (  WFMath::Point<3>* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'use'",  NULL );
          #endif
           {
           self->use(  entity,  pos );
           }
           }
           return 0;
          tolua_lerror:
           return tolua_EmberServices_Ember_ServerService_use00(  tolua_S );
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: useStop of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_useStop00
    1279  static int tolua_EmberServices_Ember_ServerService_useStop00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'useStop'",  NULL );
          #endif
           {
           self->useStop(   );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'useStop'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: attack of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_attack00
    1310  static int tolua_EmberServices_Ember_ServerService_attack00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'attack'",  NULL );
          #endif
           {
           self->attack(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'attack'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: eat of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_eat00
    1343  static int tolua_EmberServices_Ember_ServerService_eat00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'eat'",  NULL );
          #endif
           {
           self->eat(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'eat'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: deleteEntity of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_deleteEntity00
    1376  static int tolua_EmberServices_Ember_ServerService_deleteEntity00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'deleteEntity'",  NULL );
          #endif
           {
           self->deleteEntity(  entity );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'deleteEntity'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAttributes of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ServerService_setAttributes00
    1409  static int tolua_EmberServices_Ember_ServerService_setAttributes00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ServerService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Eris::Entity",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  3,  "Atlas::Message::MapType",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Eris::Entity* entity = (  (  Eris::Entity* ) tolua_tousertype(  tolua_S,  2,  0 ) );
           Atlas::Message::MapType* attributes = (  (  Atlas::Message::MapType* ) tolua_tousertype(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAttributes'",  NULL );
          #endif
           {
           self->setAttributes(  entity,  *attributes );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAttributes'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: GotAvatar of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ServerService_GotAvatar
    1444  static int tolua_get_Ember__ServerService_GotAvatar(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotAvatar'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->GotAvatar,  "sigc::signal<void,  Eris::Avatar*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: GotAvatar of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ServerService_GotAvatar
    1457  static int tolua_set_Ember__ServerService_GotAvatar(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotAvatar'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Avatar*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->GotAvatar = *(  (  sigc::signal<void,  Eris::Avatar*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: GotView of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ServerService_GotView
    1474  static int tolua_get_Ember__ServerService_GotView(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotView'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->GotView,  "sigc::signal<void,  Eris::View*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: GotView of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ServerService_GotView
    1487  static int tolua_set_Ember__ServerService_GotView(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotView'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::View*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->GotView = *(  (  sigc::signal<void,  Eris::View*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: GotConnection of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ServerService_GotConnection
    1504  static int tolua_get_Ember__ServerService_GotConnection(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotConnection'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->GotConnection,  "sigc::signal<void,  Eris::Connection*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: GotConnection of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ServerService_GotConnection
    1517  static int tolua_set_Ember__ServerService_GotConnection(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotConnection'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Connection*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->GotConnection = *(  (  sigc::signal<void,  Eris::Connection*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: GotAccount of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ServerService_GotAccount
    1534  static int tolua_get_Ember__ServerService_GotAccount(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotAccount'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->GotAccount,  "sigc::signal<void,  Eris::Account*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: GotAccount of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ServerService_GotAccount
    1547  static int tolua_set_Ember__ServerService_GotAccount(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotAccount'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Account*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->GotAccount = *(  (  sigc::signal<void,  Eris::Account*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: LoginSuccess of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ServerService_LoginSuccess
    1564  static int tolua_get_Ember__ServerService_LoginSuccess(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'LoginSuccess'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->LoginSuccess,  "sigc::signal<void,  Eris::Account*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: LoginSuccess of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ServerService_LoginSuccess
    1577  static int tolua_set_Ember__ServerService_LoginSuccess(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'LoginSuccess'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Account*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->LoginSuccess = *(  (  sigc::signal<void,  Eris::Account*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: LoginFailure of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ServerService_LoginFailure
    1594  static int tolua_get_Ember__ServerService_LoginFailure(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'LoginFailure'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->LoginFailure,  "sigc::signal<void,  Eris::Account*,  const std::string&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: LoginFailure of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ServerService_LoginFailure
    1607  static int tolua_set_Ember__ServerService_LoginFailure(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'LoginFailure'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Account*,  const std::string&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->LoginFailure = *(  (  sigc::signal<void,  Eris::Account*,  const std::string&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: GotCharacterInfo of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ServerService_GotCharacterInfo
    1624  static int tolua_get_Ember__ServerService_GotCharacterInfo(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotCharacterInfo'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->GotCharacterInfo,  "sigc::signal<void,  const Atlas::Objects::Entity::RootEntity&>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: GotCharacterInfo of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ServerService_GotCharacterInfo
    1637  static int tolua_set_Ember__ServerService_GotCharacterInfo(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotCharacterInfo'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  const Atlas::Objects::Entity::RootEntity&>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->GotCharacterInfo = *(  (  sigc::signal<void,  const Atlas::Objects::Entity::RootEntity&>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* get function: GotAllCharacters of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_get_Ember__ServerService_GotAllCharacters
    1654  static int tolua_get_Ember__ServerService_GotAllCharacters(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotAllCharacters'",  NULL );
          #endif
           tolua_pushusertype(  tolua_S,  (  void* )&self->GotAllCharacters,  "sigc::signal<void,  Eris::Account*>" );
           return 1;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* set function: GotAllCharacters of class Ember::ServerService */
          #ifndef TOLUA_DISABLE_tolua_set_Ember__ServerService_GotAllCharacters
    1667  static int tolua_set_Ember__ServerService_GotAllCharacters(  lua_State* tolua_S )
          {
           Ember::ServerService* self = (  Ember::ServerService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in accessing variable 'GotAllCharacters'",  NULL );
           if (  !tolua_isusertype(  tolua_S,  2,  "sigc::signal<void,  Eris::Account*>",  0,  &tolua_err ) )
           tolua_error(  tolua_S,  "#vinvalid type in variable assignment.",  &tolua_err );
          #endif
           self->GotAllCharacters = *(  (  sigc::signal<void,  Eris::Account*>* ) tolua_tousertype(  tolua_S,  2,  0 ) )
          ;
           return 0;
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: registerScriptingProvider of class Ember::ScriptingService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ScriptingService_registerScriptingProvider00
    1684  static int tolua_EmberServices_Ember_ScriptingService_registerScriptingProvider00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ScriptingService",  0,  &tolua_err ) ||
           !tolua_isusertype(  tolua_S,  2,  "Ember::IScriptingProvider",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ScriptingService* self = (  Ember::ScriptingService* ) tolua_tousertype(  tolua_S,  1,  0 );
           Ember::IScriptingProvider* provider = (  (  Ember::IScriptingProvider* ) tolua_tousertype(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'registerScriptingProvider'",  NULL );
          #endif
           {
           self->registerScriptingProvider(  provider );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'registerScriptingProvider'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: loadScript of class Ember::ScriptingService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ScriptingService_loadScript00
    1717  static int tolua_EmberServices_Ember_ScriptingService_loadScript00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ScriptingService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ScriptingService* self = (  Ember::ScriptingService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string script = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'loadScript'",  NULL );
          #endif
           {
           self->loadScript(  script );
           tolua_pushcppstring(  tolua_S,  (  const char* )script );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'loadScript'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: executeCode of class Ember::ScriptingService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ScriptingService_executeCode00
    1751  static int tolua_EmberServices_Ember_ScriptingService_executeCode00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ScriptingService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  3,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  4,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ScriptingService* self = (  Ember::ScriptingService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string scriptCode = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
           const std::string scriptType = (  (  const std::string ) tolua_tocppstring(  tolua_S,  3,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'executeCode'",  NULL );
          #endif
           {
           self->executeCode(  scriptCode,  scriptType );
           tolua_pushcppstring(  tolua_S,  (  const char* )scriptCode );
           tolua_pushcppstring(  tolua_S,  (  const char* )scriptType );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'executeCode'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getEventScriptError of class Ember::ScriptingService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ScriptingService_getEventScriptError00
    1788  static int tolua_EmberServices_Ember_ScriptingService_getEventScriptError00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ScriptingService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ScriptingService* self = (  Ember::ScriptingService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getEventScriptError'",  NULL );
          #endif
           {
           sigc::signal<void,  const std::string&>& tolua_ret = (  sigc::signal<void,  const std::string&>& ) self->getEventScriptError(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "sigc::signal<void,  const std::string&>" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getEventScriptError'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getProviderFor of class Ember::ScriptingService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ScriptingService_getProviderFor00
    1820  static int tolua_EmberServices_Ember_ScriptingService_getProviderFor00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ScriptingService",  0,  &tolua_err ) ||
           !tolua_iscppstring(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ScriptingService* self = (  Ember::ScriptingService* ) tolua_tousertype(  tolua_S,  1,  0 );
           const std::string providerName = (  (  const std::string ) tolua_tocppstring(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getProviderFor'",  NULL );
          #endif
           {
           Ember::IScriptingProvider* tolua_ret = (  Ember::IScriptingProvider* ) self->getProviderFor(  providerName );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ember::IScriptingProvider" );
           tolua_pushcppstring(  tolua_S,  (  const char* )providerName );
           }
           }
           return 2;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getProviderFor'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getProviderNames of class Ember::ScriptingService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ScriptingService_getProviderNames00
    1855  static int tolua_EmberServices_Ember_ScriptingService_getProviderNames00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ScriptingService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ScriptingService* self = (  Ember::ScriptingService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getProviderNames'",  NULL );
          #endif
           {
           std::vector<std::string> tolua_ret = (  std::vector<std::string> ) self->getProviderNames(   );
           {
          #ifdef __cplusplus
           void* tolua_obj = new std::vector<std::string>(  tolua_ret );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<std::string>" );
          #else
           void* tolua_obj = tolua_copy(  tolua_S,  (  void* )&tolua_ret,  sizeof(  std::vector<std::string> ) );
           tolua_pushusertype_and_takeownership(  tolua_S,  tolua_obj,  "std::vector<std::string>" );
          #endif
           }
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getProviderNames'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getAlwaysLookup of class Ember::ScriptingService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ScriptingService_getAlwaysLookup00
    1895  static int tolua_EmberServices_Ember_ScriptingService_getAlwaysLookup00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "const Ember::ScriptingService",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           const Ember::ScriptingService* self = (  const Ember::ScriptingService* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getAlwaysLookup'",  NULL );
          #endif
           {
           bool tolua_ret = (  bool ) self->getAlwaysLookup(   );
           tolua_pushboolean(  tolua_S,  (  bool )tolua_ret );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getAlwaysLookup'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: setAlwaysLookup of class Ember::ScriptingService */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_ScriptingService_setAlwaysLookup00
    1927  static int tolua_EmberServices_Ember_ScriptingService_setAlwaysLookup00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::ScriptingService",  0,  &tolua_err ) ||
           !tolua_isboolean(  tolua_S,  2,  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  3,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::ScriptingService* self = (  Ember::ScriptingService* ) tolua_tousertype(  tolua_S,  1,  0 );
           bool alwaysLookup = (  (  bool ) tolua_toboolean(  tolua_S,  2,  0 ) );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'setAlwaysLookup'",  NULL );
          #endif
           {
           self->setAlwaysLookup(  alwaysLookup );
           }
           }
           return 0;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'setAlwaysLookup'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getSingleton of class Ember::EmberServices */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_EmberServices_getSingleton00
    1960  static int tolua_EmberServices_Ember_EmberServices_getSingleton00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertable(  tolua_S,  1,  "Ember::EmberServices",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           {
           Ember::EmberServices& tolua_ret = (  Ember::EmberServices& ) Ember::EmberServices::getSingleton(   );
           tolua_pushusertype(  tolua_S,  (  void* )&tolua_ret,  "Ember::EmberServices" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getSingleton'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getLoggingService of class Ember::EmberServices */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_EmberServices_getLoggingService00
    1988  static int tolua_EmberServices_Ember_EmberServices_getLoggingService00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::EmberServices",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::EmberServices* self = (  Ember::EmberServices* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getLoggingService'",  NULL );
          #endif
           {
           Ember::LoggingService* tolua_ret = (  Ember::LoggingService* ) self->getLoggingService(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ember::LoggingService" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getLoggingService'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getConfigService of class Ember::EmberServices */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_EmberServices_getConfigService00
    2020  static int tolua_EmberServices_Ember_EmberServices_getConfigService00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::EmberServices",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::EmberServices* self = (  Ember::EmberServices* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getConfigService'",  NULL );
          #endif
           {
           Ember::ConfigService* tolua_ret = (  Ember::ConfigService* ) self->getConfigService(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ember::ConfigService" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getConfigService'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getMetaserverService of class Ember::EmberServices */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_EmberServices_getMetaserverService00
    2052  static int tolua_EmberServices_Ember_EmberServices_getMetaserverService00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::EmberServices",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::EmberServices* self = (  Ember::EmberServices* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getMetaserverService'",  NULL );
          #endif
           {
           Ember::MetaserverService* tolua_ret = (  Ember::MetaserverService* ) self->getMetaserverService(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ember::MetaserverService" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getMetaserverService'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getServerService of class Ember::EmberServices */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_EmberServices_getServerService00
    2084  static int tolua_EmberServices_Ember_EmberServices_getServerService00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::EmberServices",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::EmberServices* self = (  Ember::EmberServices* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getServerService'",  NULL );
          #endif
           {
           Ember::ServerService* tolua_ret = (  Ember::ServerService* ) self->getServerService(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ember::ServerService" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getServerService'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* method: getScriptingService of class Ember::EmberServices */
          #ifndef TOLUA_DISABLE_tolua_EmberServices_Ember_EmberServices_getScriptingService00
    2116  static int tolua_EmberServices_Ember_EmberServices_getScriptingService00(  lua_State* tolua_S )
          {
          #ifndef TOLUA_RELEASE
           tolua_Error tolua_err;
           if (  
           !tolua_isusertype(  tolua_S,  1,  "Ember::EmberServices",  0,  &tolua_err ) ||
           !tolua_isnoobj(  tolua_S,  2,  &tolua_err )
            )
           goto tolua_lerror;
           else
          #endif
           {
           Ember::EmberServices* self = (  Ember::EmberServices* ) tolua_tousertype(  tolua_S,  1,  0 );
          #ifndef TOLUA_RELEASE
           if (  !self ) tolua_error(  tolua_S,  "invalid 'self' in function 'getScriptingService'",  NULL );
          #endif
           {
           Ember::ScriptingService* tolua_ret = (  Ember::ScriptingService* ) self->getScriptingService(   );
           tolua_pushusertype(  tolua_S,  (  void* )tolua_ret,  "Ember::ScriptingService" );
           }
           }
           return 1;
          #ifndef TOLUA_RELEASE
           tolua_lerror:
           tolua_error(  tolua_S,  "#ferror in function 'getScriptingService'.",  &tolua_err );
           return 0;
          #endif
          }
          #endif //#ifndef TOLUA_DISABLE
          
          /* Open function */
    2147  TOLUA_API int tolua_EmberServices_open (  lua_State* tolua_S )
          {
           tolua_open(  tolua_S );
           tolua_reg_types(  tolua_S );
           tolua_module(  tolua_S,  NULL,  0 );
           tolua_beginmodule(  tolua_S,  NULL );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           tolua_cclass(  tolua_S,  "LoggingService",  "Ember::LoggingService",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "LoggingService" );
           tolua_constant(  tolua_S,  "VERBOSE",  Ember::LoggingService::VERBOSE );
           tolua_constant(  tolua_S,  "INFO",  Ember::LoggingService::INFO );
           tolua_constant(  tolua_S,  "WARNING",  Ember::LoggingService::WARNING );
           tolua_constant(  tolua_S,  "FAILURE",  Ember::LoggingService::FAILURE );
           tolua_constant(  tolua_S,  "CRITICAL",  Ember::LoggingService::CRITICAL );
           tolua_constant(  tolua_S,  "END_MESSAGE",  Ember::LoggingService::END_MESSAGE );
           tolua_function(  tolua_S,  "getInstance",  tolua_EmberServices_Ember_LoggingService_getInstance00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           tolua_cclass(  tolua_S,  "ConfigService",  "Ember::ConfigService",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ConfigService" );
           tolua_variable(  tolua_S,  "SETVALUE",  tolua_get_Ember__ConfigService_SETVALUE,  NULL );
           tolua_variable(  tolua_S,  "GETVALUE",  tolua_get_Ember__ConfigService_GETVALUE,  NULL );
           tolua_function(  tolua_S,  "getValue",  tolua_EmberServices_Ember_ConfigService_getValue00 );
           tolua_function(  tolua_S,  "setValue",  tolua_EmberServices_Ember_ConfigService_setValue00 );
           tolua_function(  tolua_S,  "isItemSet",  tolua_EmberServices_Ember_ConfigService_isItemSet00 );
           tolua_function(  tolua_S,  "itemExists",  tolua_EmberServices_Ember_ConfigService_itemExists00 );
           tolua_function(  tolua_S,  "deleteItem",  tolua_EmberServices_Ember_ConfigService_deleteItem00 );
           tolua_function(  tolua_S,  "loadSavedConfig",  tolua_EmberServices_Ember_ConfigService_loadSavedConfig00 );
           tolua_function(  tolua_S,  "saveConfig",  tolua_EmberServices_Ember_ConfigService_saveConfig00 );
           tolua_function(  tolua_S,  "getHomeDirectory",  tolua_EmberServices_Ember_ConfigService_getHomeDirectory00 );
           tolua_function(  tolua_S,  "getSharedDataDirectory",  tolua_EmberServices_Ember_ConfigService_getSharedDataDirectory00 );
           tolua_function(  tolua_S,  "getEmberDataDirectory",  tolua_EmberServices_Ember_ConfigService_getEmberDataDirectory00 );
           tolua_function(  tolua_S,  "getEmberMediaDirectory",  tolua_EmberServices_Ember_ConfigService_getEmberMediaDirectory00 );
           tolua_function(  tolua_S,  "getUserMediaDirectory",  tolua_EmberServices_Ember_ConfigService_getUserMediaDirectory00 );
           tolua_function(  tolua_S,  "getSharedMediaDirectory",  tolua_EmberServices_Ember_ConfigService_getSharedMediaDirectory00 );
           tolua_function(  tolua_S,  "getSharedConfigDirectory",  tolua_EmberServices_Ember_ConfigService_getSharedConfigDirectory00 );
           tolua_variable(  tolua_S,  "EventChangedConfigItem",  tolua_get_Ember__ConfigService_EventChangedConfigItem,  tolua_set_Ember__ConfigService_EventChangedConfigItem );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           tolua_cclass(  tolua_S,  "MetaserverService",  "Ember::MetaserverService",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "MetaserverService" );
           tolua_function(  tolua_S,  "getMetaServer",  tolua_EmberServices_Ember_MetaserverService_getMetaServer00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           tolua_cclass(  tolua_S,  "ServerService",  "Ember::ServerService",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ServerService" );
           tolua_function(  tolua_S,  "isConnected",  tolua_EmberServices_Ember_ServerService_isConnected00 );
           tolua_function(  tolua_S,  "connect",  tolua_EmberServices_Ember_ServerService_connect00 );
           tolua_function(  tolua_S,  "disconnect",  tolua_EmberServices_Ember_ServerService_disconnect00 );
           tolua_function(  tolua_S,  "takeCharacter",  tolua_EmberServices_Ember_ServerService_takeCharacter00 );
           tolua_function(  tolua_S,  "createCharacter",  tolua_EmberServices_Ember_ServerService_createCharacter00 );
           tolua_function(  tolua_S,  "moveToPoint",  tolua_EmberServices_Ember_ServerService_moveToPoint00 );
           tolua_function(  tolua_S,  "moveInDirection",  tolua_EmberServices_Ember_ServerService_moveInDirection00 );
           tolua_function(  tolua_S,  "moveInDirection",  tolua_EmberServices_Ember_ServerService_moveInDirection01 );
           tolua_function(  tolua_S,  "say",  tolua_EmberServices_Ember_ServerService_say00 );
           tolua_function(  tolua_S,  "touch",  tolua_EmberServices_Ember_ServerService_touch00 );
           tolua_function(  tolua_S,  "emote",  tolua_EmberServices_Ember_ServerService_emote00 );
           tolua_function(  tolua_S,  "drop",  tolua_EmberServices_Ember_ServerService_drop00 );
           tolua_function(  tolua_S,  "drop",  tolua_EmberServices_Ember_ServerService_drop01 );
           tolua_function(  tolua_S,  "place",  tolua_EmberServices_Ember_ServerService_place00 );
           tolua_function(  tolua_S,  "wield",  tolua_EmberServices_Ember_ServerService_wield00 );
           tolua_function(  tolua_S,  "take",  tolua_EmberServices_Ember_ServerService_take00 );
           tolua_function(  tolua_S,  "use",  tolua_EmberServices_Ember_ServerService_use00 );
           tolua_function(  tolua_S,  "use",  tolua_EmberServices_Ember_ServerService_use01 );
           tolua_function(  tolua_S,  "useStop",  tolua_EmberServices_Ember_ServerService_useStop00 );
           tolua_function(  tolua_S,  "attack",  tolua_EmberServices_Ember_ServerService_attack00 );
           tolua_function(  tolua_S,  "eat",  tolua_EmberServices_Ember_ServerService_eat00 );
           tolua_function(  tolua_S,  "deleteEntity",  tolua_EmberServices_Ember_ServerService_deleteEntity00 );
           tolua_function(  tolua_S,  "setAttributes",  tolua_EmberServices_Ember_ServerService_setAttributes00 );
           tolua_variable(  tolua_S,  "GotAvatar",  tolua_get_Ember__ServerService_GotAvatar,  tolua_set_Ember__ServerService_GotAvatar );
           tolua_variable(  tolua_S,  "GotView",  tolua_get_Ember__ServerService_GotView,  tolua_set_Ember__ServerService_GotView );
           tolua_variable(  tolua_S,  "GotConnection",  tolua_get_Ember__ServerService_GotConnection,  tolua_set_Ember__ServerService_GotConnection );
           tolua_variable(  tolua_S,  "GotAccount",  tolua_get_Ember__ServerService_GotAccount,  tolua_set_Ember__ServerService_GotAccount );
           tolua_variable(  tolua_S,  "LoginSuccess",  tolua_get_Ember__ServerService_LoginSuccess,  tolua_set_Ember__ServerService_LoginSuccess );
           tolua_variable(  tolua_S,  "LoginFailure",  tolua_get_Ember__ServerService_LoginFailure,  tolua_set_Ember__ServerService_LoginFailure );
           tolua_variable(  tolua_S,  "GotCharacterInfo",  tolua_get_Ember__ServerService_GotCharacterInfo,  tolua_set_Ember__ServerService_GotCharacterInfo );
           tolua_variable(  tolua_S,  "GotAllCharacters",  tolua_get_Ember__ServerService_GotAllCharacters,  tolua_set_Ember__ServerService_GotAllCharacters );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           tolua_cclass(  tolua_S,  "ScriptingService",  "Ember::ScriptingService",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "ScriptingService" );
           tolua_function(  tolua_S,  "registerScriptingProvider",  tolua_EmberServices_Ember_ScriptingService_registerScriptingProvider00 );
           tolua_function(  tolua_S,  "loadScript",  tolua_EmberServices_Ember_ScriptingService_loadScript00 );
           tolua_function(  tolua_S,  "executeCode",  tolua_EmberServices_Ember_ScriptingService_executeCode00 );
           tolua_function(  tolua_S,  "getEventScriptError",  tolua_EmberServices_Ember_ScriptingService_getEventScriptError00 );
           tolua_function(  tolua_S,  "getProviderFor",  tolua_EmberServices_Ember_ScriptingService_getProviderFor00 );
           tolua_function(  tolua_S,  "getProviderNames",  tolua_EmberServices_Ember_ScriptingService_getProviderNames00 );
           tolua_function(  tolua_S,  "getAlwaysLookup",  tolua_EmberServices_Ember_ScriptingService_getAlwaysLookup00 );
           tolua_function(  tolua_S,  "setAlwaysLookup",  tolua_EmberServices_Ember_ScriptingService_setAlwaysLookup00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_module(  tolua_S,  "Ember",  0 );
           tolua_beginmodule(  tolua_S,  "Ember" );
           tolua_cclass(  tolua_S,  "EmberServices",  "Ember::EmberServices",  "",  NULL );
           tolua_beginmodule(  tolua_S,  "EmberServices" );
           tolua_function(  tolua_S,  "getSingleton",  tolua_EmberServices_Ember_EmberServices_getSingleton00 );
           tolua_function(  tolua_S,  "getLoggingService",  tolua_EmberServices_Ember_EmberServices_getLoggingService00 );
           tolua_function(  tolua_S,  "getConfigService",  tolua_EmberServices_Ember_EmberServices_getConfigService00 );
           tolua_function(  tolua_S,  "getMetaserverService",  tolua_EmberServices_Ember_EmberServices_getMetaserverService00 );
           tolua_function(  tolua_S,  "getServerService",  tolua_EmberServices_Ember_EmberServices_getServerService00 );
           tolua_function(  tolua_S,  "getScriptingService",  tolua_EmberServices_Ember_EmberServices_getScriptingService00 );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           tolua_endmodule(  tolua_S );
           return 1;
          }
          
          
          #if defined(  LUA_VERSION_NUM ) && LUA_VERSION_NUM >= 501
    2265   TOLUA_API int luaopen_EmberServices (  lua_State* tolua_S ) {
           return tolua_EmberServices_open(  tolua_S );
          };
          #endif
          

./services/bindings/lua/required.h

       1  #include <sigc++/sigc++.h>
          #include "framework/IScriptingProvider.h"

./services/config/ConfigService.cpp

       1  /*
           Copyright (  C ) 2002 Miguel Guzman Miranda [Aglanor]
           Joel Schander [nullstar]
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include "ConfigService.h"
          #include "services/logging/LoggingService.h"
          // #include "framework/binreloc.h"
          
          #include <iostream>
          #include "framework/ConsoleBackend.h"
          #include "framework/Tokeniser.h"
          
          #ifdef __WIN32__
          #include <Windows.h>
          
          //we need this for the PathRemoveFileSpec(  ... ) method
          #include <shlwapi.h>
          #endif
          
          
          using namespace std;
          
          namespace Ember
          {
          
      45   const std::string ConfigService::SETVALUE(  "set_value" );
      46   const std::string ConfigService::GETVALUE(  "get_value" );
          
      48   ConfigService::ConfigService(   ) : Service(   ),   mHomeDir(  "" )
           {
          #ifdef __WIN32__
           char cwd[512];
           //get the full path for the current executable
           GetModuleFileName(  0,   cwd,   512 );
          
           //use this utility function for removing the file part
           PathRemoveFileSpec(  cwd );
           baseDir = std::string(  cwd ) + "\\";
          #else
           setPrefix(  PREFIX );
          #endif
          
           setName(  "Configuration Service" );
           setDescription(  "Service for management of Ember user-defined configuration" );
          
           setStatusText(  "Configuration Service status OK." );
           }
          
      68   void ConfigService::setPrefix(  const std::string& prefix )
           {
           mSharedDataDir = prefix + "/share/ember/";
           mEtcDir = prefix + "/etc/ember/";
           }
          
      74   void ConfigService::setHomeDirectory(  const std::string& path )
           {
           mHomeDir = path;
           }
          
      79   const ConfigService::SectionMap& ConfigService::getSection(  const std::string& sectionName )
           {
           return varconf::Config::inst(   )->getSection(  sectionName );
           }
          
          
      85   varconf::Variable ConfigService::getValue(  const std::string& section,   const std::string& key ) const
           {
           string value;
           value = std::string(  varconf::Config::inst(   )->getItem(  section,   key ) );
           return value;
           }
          
      92   void ConfigService::setValue(  const std::string& section,   const std::string& key,   const varconf::Variable& value )
           {
           varconf::Config::inst(   )->setItem(  section,   key,   value );
           }
          
      97   bool ConfigService::isItemSet(  const std::string& section,   const std::string& key,   const std::string& value ) const
           {
           return (  itemExists(  section,   key ) && getValue(  section,   key ) == value );
           }
          
     102   Service::Status ConfigService::start(   )
           {
           varconf::Config::inst(   )->sige.connect(  sigc::mem_fun(  *this,   &ConfigService::configError ) );
           varconf::Config::inst(   )->sigv.connect(  sigc::mem_fun(  *this,   &ConfigService::updatedConfig ) );
           registerConsoleCommands(   );
           setRunning(  true );
           ///can't do this since we must be the first thing initialized
           //LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::INFO ) << getName(   ) << " initialized" << ENDM;
           return Service::OK;
           }
          
     113   void ConfigService::stop(  int code )
           {
           Service::stop(  code );
           deregisterConsoleCommands(   );
           return;
           }
          
     120   void ConfigService::deregisterConsoleCommands(   )
           {
           Ember::ConsoleBackend::getMainConsole(   )->deregisterCommand(  SETVALUE );
           Ember::ConsoleBackend::getMainConsole(   )->deregisterCommand(  GETVALUE );
           }
          
     126   void ConfigService::registerConsoleCommands(   )
           {
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  SETVALUE,   this,   "Sets a value in the configuration. Usage: set_value <section> <key> <value>" );
           Ember::ConsoleBackend::getMainConsole(   )->registerCommand(  GETVALUE,   this,   "Gets a value from the configuration. Usage: get_value <section> <key>" );
           }
          
     132   bool ConfigService::itemExists(  const std::string& section,   const std::string& key ) const
           {
           return varconf::Config::inst(   )->find(  section,   key );
           }
          
     137   bool ConfigService::deleteItem(  const std::string& section,   const std::string& key )
           {
           return varconf::Config::inst(   )->erase(  section,   key );
           }
          
     142   bool ConfigService::loadSavedConfig(  const std::string& filename )
           {
           S_LOG_INFO(  "Loading shared config file from " << getSharedConfigDirectory(   ) + "/"+ filename << "." );
           bool success = varconf::Config::inst(   )->readFromFile(  getSharedConfigDirectory(   ) + "/"+ filename,   varconf::GLOBAL );
           S_LOG_INFO(  "Loading user config file from "<< getHomeDirectory(   ) + "/" + filename <<"." );
           success = varconf::Config::inst(   )->readFromFile(  getHomeDirectory(   ) + "/" + filename,   varconf::USER ) || success;
           return success;
           }
          
     151   bool ConfigService::saveConfig(  const std::string& filename )
           {
           return varconf::Config::inst(   )->writeToFile(  filename );
           }
          
     156   void ConfigService::runCommand(  const std::string &command,   const std::string &args )
           {
           if(  command == SETVALUE )
           {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string section(  tokeniser.nextToken(   ) );
           std::string key(  tokeniser.nextToken(   ) );
           std::string value(  tokeniser.remainingTokens(   ) );
          
           if (  section == "" || key == "" || value == "" ) {
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  "Usage: set_value <section> <key> <value>" );
           } else {
           setValue(  section,   key,   value );
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  "New value set,   section: " + section + " key: " + key + " value: " + value );
           }
          
           }
           else if(  command == GETVALUE )
           {
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string section(  tokeniser.nextToken(   ) );
           std::string key(  tokeniser.nextToken(   ) );
          
           if (  section == "" || key == "" ) {
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  "Usage: get_value <section> <key>" );
           } else {
           if (  !itemExists(  section,   key ) ) {
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  "No such value." );
           } else {
           varconf::Variable value = getValue(  section,   key );
           Ember::ConsoleBackend::getMainConsole(   )->pushMessage(  std::string(  "Value: " ) + static_cast<std::string>(  value ) );
           }
           }
           }
           }
          
     194   void ConfigService::updatedConfig(  const std::string& section,   const std::string& key )
           {
           EventChangedConfigItem.emit(  section,   key );
           }
          
     199   void ConfigService::configError(  const char* error )
           {
           S_LOG_FAILURE(  std::string(  error ) );
           }
          
     204   const std::string& ConfigService::getHomeDirectory(   ) const
           {
           ///check if the home directory is set,   and if so use the setting. If else,   fall back to the default path.
           if (  mHomeDir != "" ) {
           return mHomeDir;
           } else {
           //taken from Sear
          #ifdef __WIN32__
           static std::string finalPath;
           static std::string fallbackPath(  "." );
           if (  !finalPath.empty(   ) ) {
           return finalPath;
           }
           std::string path(  getenv(  "APPDATA" ) );
           if (  path.empty(   ) ) {
           const char *homedrive = getenv(  "HOMEDRIVE" );
           const char *homepath = getenv(  "HOMEPATH" );
          
           if (  !homedrive || !homepath ) {
           std::cerr << "unable to determine homedir in Win32,   using ." << std::endl;
           return fallbackPath;
           }
           path = std::string(  homedrive ) + std::string(  homepath );
           }
           finalPath = path + "\\Ember\\";
           return finalPath;
          #elif __APPLE__
           static std::string path(  getAppSupportDirPath(   ) + "/Ember/" );
           return path;
          #else
           static std::string path(  std::string(  getenv(  "HOME" ) ) + "/.ember/" );
           return path;
          #endif
           }
           }
          
     240   const std::string& ConfigService::getSharedDataDirectory(   ) const
           {
           if (  itemExists(  "paths",   "sharedir" ) ) {
           static std::string path(  static_cast<std::string>(  getValue(  "paths",   "sharedir" ) ) + "/" );
           return path;
           } else {
          #ifdef __APPLE__
           return getBundleResourceDirPath(   );
          #elif __WIN32__
           return baseDir;
          #else
           return mSharedDataDir;
          #endif
           }
          
           }
          
     257   const std::string& ConfigService::getSharedConfigDirectory(   ) const
           {
          #ifdef __APPLE__
           static std::string path(  getSharedDataDirectory(   ) + "/etc/ember/" );
           return path;
          #elif __WIN32__
           static std::string path(  getSharedDataDirectory(   ) + "/etc/ember/" );
           return path;
          #else
           return mEtcDir;
          #endif
           }
          
     270   const std::string& ConfigService::getEmberDataDirectory(   ) const
           {
           if (  itemExists(  "paths",   "datadir" ) ) {
           static std::string path(  static_cast<std::string>(  getValue(  "paths",   "datadir" ) ) + "/" );
           return path;
           } else {
          //#ifdef __APPLE__
          // return getBundleResourceDirPath(   );
          //#elif __WIN32__
          // return baseDir;
          //#else
          // return BR_DATADIR(  "/games/ember/" );
          //#endif
           return getHomeDirectory(   );
           }
          
           }
          
     288   const std::string& ConfigService::getEmberMediaDirectory(   ) const
           {
           static std::string path(  getEmberDataDirectory(   ) + "/ember-media-" + std::string(  MEDIA_VERSION ) + "/" );
           return path;
           }
          
          
     295   const std::string& ConfigService::getUserMediaDirectory(   ) const
           {
           static std::string path(  getHomeDirectory(   ) + "/user-media/" );
           return path;
           }
          
     301   const std::string& ConfigService::getSharedMediaDirectory(   ) const
           {
           static std::string path(  getSharedDataDirectory(   ) + "media/shared/" );
           return path;
           }
          
          } // namespace Ember

./services/config/ConfigService.h

       1  /*
           Copyright (  C ) 2002 Miguel Guzman Miranda [Aglanor]
           Joel Schander [nullstar]
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef CONFIGSERVICE_H
          #define CONFIGSERVICE_H
          
          #include <framework/Service.h>
          #include <framework/ConsoleObject.h>
          #include <string>
          #include <varconf/varconf.h>
          
          // ------------------------------
          // Include sigc header files
          // ------------------------------
          //#include <sigc++/object.h>
          //#include <sigc++/connection.h>
          
          
          namespace Ember {
          
           /**
           * Ember Configuration Service
           *
           * @author Miguel Guzman Miranda [Aglanor]
           * @author Joel Schander [nullstar]
           *
           * @see Ember::Service
           * @see varconf
           */
      46  class ConfigService: public Service,   public Ember::ConsoleObject
          {
           private:
           //----------------------------------------------------------------------
           // Class Variables
           //----------------------------------------------------------------------
          #ifdef __WIN32__
      53   std::string baseDir;
          #endif
          
      56   std::string mSharedDataDir;
      57   std::string mEtcDir;
          
           /**
           The home directory. If this is not set,   the default one will be used. See getHomeDirectory(   )
           */
      62   std::string mHomeDir;
          
      64   void registerConsoleCommands(   );
      65   void deregisterConsoleCommands(   );
          
           /**
           * just a facade for the underlying varconf::Config::sigv
           * @param the section of the item
           * @param the key of the item
           */
      72   void updatedConfig(  const std::string& section,   const std::string& key );
          
      74   void configError(  const char* error );
          
          
           protected:
           public:
           typedef std::map< std::string,   varconf::Variable > SectionMap;
          
      81   static const std::string SETVALUE;
      82   static const std::string GETVALUE;
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
           //----------------------------------------------------------------------
          
           /**
           * Ctor for Ember::service::ConfigService.
           *
           */
      92   ConfigService(   );
          
           /**
           * Dtor for Ember::service::ConfigService.
           *
           */
      98   ~ConfigService(   )
           {
           }
          
          
           //----------------------------------------------------------------------
           // Getters & Setters
           //----------------------------------------------------------------------
          
           /**
           * Returns value stored in key in appropriate section.
           *
           * @param Section of config space to look in.
           * @param Key to return value of.
           */
     113   varconf::Variable getValue(  const std::string& section,   const std::string& key ) const;
          
           /**
           * Sets value of key in appropriate section.
           *
           * @param Section of config space to look in.
           * @param Key to store value in.
           * @param Value to store.
           */
     122   void setValue(  const std::string& section,   const std::string& key,   const varconf::Variable& value );
          
           //----------------------------------------------------------------------
           // Methods
           //----------------------------------------------------------------------
          
           /**
           * Reimplements the ConsoleObject::runCommand method
           * @param command
           * @param args
           */
     133   virtual void runCommand(  const std::string &command,   const std::string &args );
          
          
           /**
           * Starts ConfigService. Returns status.
           *
           */
     140   Service::Status start(  void );
          
           /**
           * Stops ConfigService.
           *
           * @param stop code.
           */
     147   void stop(  int code );
          
           /**
           * Returns true if the key exists in the section given.
           *
           * @param Section of config space to look in.
           * @param Key to look for.
           */
     155   bool itemExists(  const std::string& section,   const std::string& key ) const;
          
           /**
           Returns true if the item is set to the supplied value.
           */
     160   bool isItemSet(  const std::string& section,   const std::string& key,   const std::string& value ) const;
          
           /**
           * Returns true if the key exists in the section give but is successfully
           * removed.
           *
           * @param Section of config space to look in.
           * @param Key to remove.
           */
     169   bool deleteItem(  const std::string& section,   const std::string& key );
          
          
           /**
           * Returns a map of the specified section.
           * @param sectionName
           * @return
           */
     177   const SectionMap& getSection(  const std::string& sectionName );
          
           /**
           * Loads config space from given file.
           *
           * @param Name of file to read from.
           */
     184   bool loadSavedConfig(  const std::string& filename );
          
           /**
           * Saves config space to given file.
           *
           * @param Name of file to save to.
           */
     191   bool saveConfig(  const std::string& filename );
          
          
           /**
           * returns the path to the home directory,   where all configuration is stored
           */
     197   const std::string& getHomeDirectory(   ) const;
          
           /**
           * returns the path to the shared data directory,   where common media is
           */
     202   const std::string& getSharedDataDirectory(   ) const;
          
           /**
           * returns the path to the ember data directory,   where ember media is
           */
     207   const std::string& getEmberDataDirectory(   ) const;
          
           /**
           * returns the path to the media directory specific to a user,   but synced with the main server,   which would normally be ~/.ember/ember-media
           * @return
           */
     213   const std::string& getEmberMediaDirectory(   ) const;
          
           /**
           * returns the path to the media directory specific to a user,   containing media created by the user,   which would normally be ~/.ember/user-media
           * @return
           */
     219   const std::string& getUserMediaDirectory(   ) const;
          
           /**
           * returns the path to the media directory shared between users,   which would normally be $prefix/ember/media
           * @return
           */
     225   const std::string& getSharedMediaDirectory(   ) const;
          
           /**
           * returns the path to the shared config directory where all the original configuration files are stored
           * @return
           */
     231   const std::string& getSharedConfigDirectory(   ) const;
          
           /**
           * Emitted when a config item is changed.
           * @param the section of the config item
           * @param the key of the config item
           */
     238   sigc::signal<void,   const std::string&,   const std::string&> EventChangedConfigItem;
          
           /**
           * Sets the prefix for all the configuration and resources. Call this before other services have initialized.
           * @param prefix
           */
     244   void setPrefix(  const std::string& prefix );
          
           /**
           * Sets the home directory,   i.e. where all configuration and media is stored. If this is not set,   a default directory will be user (  ~/.ember on *NIX systems )
           * @param path
           */
     250   void setHomeDirectory(  const std::string& path );
          
          }; //ConfigService
          
          } // namespace Ember
          
          #endif

./services/datamodel/BoolProvider.cpp

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Include other headers of the current program here
          #include "BoolProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
      28  bool BoolProvider::getValue(   )
          {
           return myValue;
          }
          
      33  void BoolProvider::setPermissions(  DataType permissions )
          {
           myPermissions = permissions;
          }
          
      38  void BoolProvider::setValue(  bool newValue )
          {
           fireSignal(  "",   PRE_VALUE_CHANGE );
          
           myValue = newValue;
          
           fireSignal(  "",   POST_VALUE_CHANGE );
          }
          
      47  PDataKey BoolProvider::getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider )
          {
           return PDataKey(   ); //No childs available
          }
          
      52  std::string BoolProvider::getSubpath(  PDataKey key )
          {
           return ""; //No childs so the path is always ""
          }
          
      57  DataType BoolProvider::getType(  PDataKey key )
          {
           return static_cast<DataType>(  BOOLEAN |
           myPermissions | PRE_VALUE_CHANGE | POST_VALUE_CHANGE | PRE_DELETION );
          }
          
      63  std::string BoolProvider::getDescription(  PDataKey key )
          {
           return myDescription;
          }
          
      68  void BoolProvider::setDescription(  PDataKey key,   std::string description )
          {
           myDescription = description;
          }
          
      73  bool BoolProvider::getBoolVal(  PDataKey key )
          {
           return myValue;
          }
          
      78  void BoolProvider::setBoolVal(  PDataKey key,   bool newValue )
          {
           //HINT: Doesn't have to test on if the user has the permission to set
           //this since this is done by the DataObject already.
          
           setValue(  newValue );
          }
          
      86  int BoolProvider::getIntVal(  PDataKey key )
          {
           return 0;
          }
          
      91  void BoolProvider::setIntVal(  PDataKey key,   int newValue )
          {
          
          }
          
      96  float BoolProvider::getFloatVal(  PDataKey key )
          {
           return 0.0;
          }
          
     101  void BoolProvider::setFloatVal(  PDataKey key,   float newValue )
          {
          
          }
          
     106  std::string BoolProvider::getStringVal(  PDataKey key )
          {
           return "";
          }
          
     111  void BoolProvider::setStringVal(  PDataKey key,   const std::string & newValue )
          {
          
          }
          
     116  void BoolProvider::addChild(  PDataKey parent,   std::string & suggestedID,  
     117   DataProvider * provider )
          {
          
           //No childs to add
          }
          
     123  void BoolProvider::remove(  PDataKey child )
          {
           //only me to remove
           delete this;
          }
          
     129  void BoolProvider::removeAdopted(  PDataKey adopted )
          {
           //is not adopting
          }
          
     134  void BoolProvider::getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds )
          {
           //again: No childs!
          }
          
     139  BoolProvider::BoolProvider(  bool initialValue,   std::string description,  
           DataType permissions )
          {
           myValue = initialValue;
           myDescription = description;
           myPermissions = permissions;
          }
          
     147  BoolProvider::~BoolProvider(   )
          {
           // Fire a removal event to all observers listening to removal events
           fireSignal(  "",   PRE_DELETION );
          }
          
          } //dime

./services/datamodel/BoolProvider.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef BOOLPROVIDER_H
          #define BOOLPROVIDER_H
          
          // Include other headers of the current program here
          #include "DataProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
          /**
           * Provider for a holding a single bool.
           *
           * @author Tim Enderling
           */
          
      37  class BoolProvider: public DataProvider,   virtual public SigC::Object
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
           public:
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           //======================================================================
           // Private Variables
           //======================================================================
      58   bool myValue;
           DataType myPermissions; //determines whether the data model users
           //can change the value or not/remove it our not,   etc.
      61   std::string myDescription;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           /**
           * All documentation from the functions removed here to remove redundancy.
           * Look into DataProvider class instead.
           */
          
      73   virtual PDataKey getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider );
      74   virtual std::string getSubpath(  PDataKey key );
      75   virtual DataType getType(  PDataKey key );
      76   virtual std::string getDescription(  PDataKey key );
      77   virtual void setDescription(  PDataKey key,   std::string description );
          
      79   virtual bool getBoolVal(  PDataKey key );
      80   virtual void setBoolVal(  PDataKey key,   bool newValue );
      81   virtual int getIntVal(  PDataKey key );
      82   virtual void setIntVal(  PDataKey key,   int newValue );
      83   virtual float getFloatVal(  PDataKey key );
      84   virtual void setFloatVal(  PDataKey key,   float newValue );
      85   virtual std::string getStringVal(  PDataKey key );
      86   virtual void setStringVal(  PDataKey key,   const std::string & newValue );
          
      88   virtual void addChild(  PDataKey parent,   std::string & suggestedID,  
           DataProvider * provider = NULL );
      90   virtual void remove(  PDataKey child );
      91   virtual void removeAdopted(  PDataKey adopted );
      92   virtual void getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds );
          
      94   bool getValue(   );
      95   void setValue(  bool newValue );
      96   void setPermissions(  DataType permissions );
          
           //----------------------------------------------------------------------
           // Constructors
          
     101   BoolProvider(  bool initialValue,   std::string description,  
           DataType permissions = static_cast<DataType>(  0 ) );
          
           //----------------------------------------------------------------------
           // Destructor
          
     107   virtual ~BoolProvider(   );
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
          }; // BoolProvider
          
          
          } // namespace dime
          
          #endif

./services/datamodel/DataModel.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef DATAMODEL_H
          #define DATAMODEL_H
          
          // Include other headers of the current program here
          
          // Include library headers here
          
          #include <boost/shared_ptr.hpp>
          #include <sigc++/object.h>
          #if SIGC_MAJOR_VERSION == 1 && SIGC_MINOR_VERSION == 0
          #include <sigc++/handle_system.h>
          #include <sigc++/signal_system.h>
          #else
          #include <sigc++/signal.h>
          #endif
          
          // Include system headers here
          
          namespace dime {
          
      39  class DataObject;
          typedef boost::shared_ptr<DataObject> PDataObject;
      41  class DataKey;
          typedef boost::shared_ptr<DataKey> PDataKey;
          
          /**
           * Data object types/flags
           */
          
          enum DataType
          {
           /**
           * is called before the value is changed (  for data model users needing the old value ).
           */
           PRE_VALUE_CHANGE = 0x0001,  
          
           /**
           * is called after the value has changed.
           */
           POST_VALUE_CHANGE = 0x0002,  
          
           /**
           * is called after a data object was added.
           */
           POST_ADDITION = 0x0004,  
          
           /**
           * is called before a data object will be deleted.
           */
           PRE_DELETION = 0x0008,  
          
           /**
           * is called before a child node get's unlinked.
           */
           PRE_LINK_CHANGE = 0x0010,  
          
           /**
           * is called after a child node got linked.
           */
           POST_LINK_CHANGE = 0x0020,  
          
           /**
           * is used to indicate,   that a signal is fired on events concerning a direct/indirect
           * child.
           */
           FIRE_ON_CHILD_EVENT = 0x0040,  
          
           /**
           * Void nodes are also used for unspecified linking nodes.
           */
           VOID = 0x0080,  
           FOLDER = 0x0100,  
           LIST = 0x0100,  
           STREAM = 0x0100,  
           BOOLEAN = 0x0200,  
           INTEGER = 0x0400,  
           FLOAT = 0x0800,  
           STRING = 0x1000,  
           CUSTOM_TYPE = 0x2000,  
          
           /**
           * See http://www.worldforge.org/dev/eng/clients/dime/developer_doc/DataModelFW
           * for more info on certain flags.
           */
          
           HAS_CHILDS = 0x4000,  
           ADOPTS_CHILDS = 0x8000,  
           CAN_SET_VALUE = 0x10000,  
           CAN_ADD_CHILDS = 0x20000,  
           CAN_REMOVE = 0x40000,  
           IS_LINK = 0x80000
          };
          
          
          /**
           * Signal type for data model change signals.
           * The form is void DataObjectChanged(  PDataObject subject,   type event ).
           */
          typedef SigC::Signal2<void,   PDataObject,   DataType> DataSignal;
          
          /**
           * Slot type for data model change signals.
           */
          typedef DataSignal::InSlotType DataSlot;
          
          } // namespace dime
          
          #endif

./services/datamodel/DataModelService.cpp

       1  #include "DataModelService.h"
          #include "DataModel.h"
          #include "DataObject.h"
          
          namespace dime
          {
       7  void DataModelService::dump(  PDataObject toDump,   std::stringstream & dumpDest,   bool recursive,  
           int level )
          {
           //@todo advance functionality by adding dump level (  to dump out types,   description,   etc. )
           if (  level == 0 )
           {
           dumpDest << toDump->getPath(   ) << ": " << toDump->getStringVal(   ) << std::endl;
           }
           else
           {
           dumpDest << "[" << toDump->getPath(   );
          
           if (  level > 1 )
           {
           DataType type = toDump->getType(   );
          
           dumpDest << ":";
          #define DUMPTYPE(  t ) if (  type & t ) dumpDest << " " #t ;
          
           DUMPTYPE(  VOID )
           DUMPTYPE(  FOLDER )
           DUMPTYPE(  BOOLEAN )
           DUMPTYPE(  INTEGER )
           DUMPTYPE(  FLOAT )
           DUMPTYPE(  STRING )
           DUMPTYPE(  CUSTOM_TYPE )
          
           if (  level > 4 )
           {
           DUMPTYPE(  PRE_VALUE_CHANGE )
           DUMPTYPE(  POST_VALUE_CHANGE )
           DUMPTYPE(  POST_ADDITION )
           DUMPTYPE(  PRE_DELETION )
           DUMPTYPE(  PRE_LINK_CHANGE )
           DUMPTYPE(  POST_LINK_CHANGE )
           DUMPTYPE(  FIRE_ON_CHILD_EVENT )
           DUMPTYPE(  HAS_CHILDS )
           DUMPTYPE(  ADOPTS_CHILDS )
           DUMPTYPE(  CAN_SET_VALUE )
           DUMPTYPE(  CAN_ADD_CHILDS )
           DUMPTYPE(  CAN_REMOVE )
           DUMPTYPE(  IS_LINK )
           }
          
           }
           dumpDest << "]" << std::endl;
          
           if (  (  level > 3 ) && (  toDump->getType(   ) & IS_LINK ) )
           {
           {
           if (  !(  toDump->getType(   ) & VOID ) )
           {
           dumpDest << "-> " << toDump->getLinkDest(   )->getPath(   ) << std::endl;
           }
           else
           {
           dumpDest << "-> INVALID LINK" << std::endl;
           }
           }
           }
          
           if (  level > 2 )
           {
           if (  !toDump->getDescription(   ).empty(   ) )
           {
           dumpDest << "# " << toDump->getDescription(   ) << std::endl;
           }
           }
          
          
           dumpDest << toDump->getStringVal(   ) << std::endl;
           }
          
           if (  recursive )
           {
           DataObject::ChildList childs;
           toDump->getChildList(  childs );
          
           for (  DataObject::ChildList::iterator i = childs.begin(   ); i != childs.end(   ); i++ )
           {
           dump(  *i,   dumpDest,   true,   level );
           }
           }
          }
          }

./services/datamodel/DataModelService.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef DATAMODELSERVICE_H
          #define DATAMODELSERVICE_H
          
          // Include other headers of the current program here
          #include "FolderProvider.h"
          #include <framework/Service.h>
          
          // Include library headers here
          
          #include <string>
          #include <list>
          #include <sstream>
          #include <stdio.h>
          
          // Include system headers here
          
          namespace dime {
          
          //======================================================================
          // Short type macros
          //======================================================================
          
          /**
           * Service managing the data model. Retrieves DataObjects by their paths.
           *
           * See http://www.worldforge.org/dev/eng/clients/dime/developer_doc/DataModelFW
           * for more info on the data model.
           *
           * @author Tim Enderling
           */
          
      50  class DataModelService //: public Service
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
          
          
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
           public:
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           //======================================================================
           // Private Variables
           //======================================================================
           private:
      73   FolderProvider myRootProvider;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           /**
           * Functions for Data Model Providers
           */
      83   FolderProvider * getRootProvider(   )
           {
           return &myRootProvider;
           }
          
           /**
           * Helper functions
           */
          
      92   static void dump(  PDataObject toDump,   std::stringstream & dumpDest,   bool recursive = true,  
           int level = 0 );
          
           //----------------------------------------------------------------------
           // Singleton
          
           /**
           * Returns the DataModelService instance.
           */
     101   static DataModelService *getInstance(   )
           {
           static DataModelService singleinstance;
           return &singleinstance;
           }
          
           //----------------------------------------------------------------------
           // Constructors
          
     110   DataModelService(   )
           {
           myRootProvider.myPath = "/";
           myRootProvider.mySubpath = "";
           }
          
           //----------------------------------------------------------------------
           // Destructor
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
          
          
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
          }; // DataModelService
          
          } // namespace dime
          
          #endif

./services/datamodel/DataObject.cpp

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          
          // Include other headers of the current program here
          #include "DataObject.h"
          #include <framework/Exception.h>
          #include "DataModelService.h"
          #include "LinkProvider.h"
          
          // Include library headers here
          #if SIGC_MAJOR_VERSION == 1 && SIGC_MINOR_VERSION == 0
          #include <sigc++/signal_system.h>
          #else
          #include <sigc++/signal.h>
          #include <sigc++/slot.h>
          #include <sigc++/object_slot.h>
          #endif
          #include <boost/shared_ptr.hpp>
          
          // Include system headers here
          #include <string>
          #include <list>
          #include <stdio.h>
          #include <stdarg.h>
          
          namespace dime {
          
          /**
           * returns the real ID of the node. (  In cases it is a link this is different from the
           * destination of the link. )
           */
      48  std::string DataObject::getID(   )
          {
           if (  myPath == "/" )
           {
           return "";
           }
           else
           {
           return myPath.substr(  myPath.rfind(  '/' )+1 );
           }
          }
          
          /**
           * returns the destination of the link.
           */
      63  PDataObject DataObject::getLinkDest(   )
          {
           if (  getType(   ) & IS_LINK )
           {
           return PDataObject(  new DataObject(  dynamic_cast<LinkProvider*>(  myProvider )->getLinkDest(   ) ) );
           }
          
           THROW1(  "DataObject %s is not a link.",   myPath.c_str(   ) );
          
           return PDataObject(   );
          }
          
          /**
           * returns the real path to the node from the root node.
           */
      78  std::string DataObject::getPath(   )
          {
           return myPath;
          }
          
          /**
           * returns the subpath within it's data model provider. Usually not needed by
           * Data Model users.
           */
      87  std::string DataObject::getSubpath(   )
          {
           return mySubpath;
          }
          
      92  PDataKey DataObject::getKey(   )
          {
           return myKey;
          }
          
          /**
           * returns the Data Object's data model provider. Usually not needed by
           * Data Model users.
           */
     101  DataProvider * DataObject::getProvider(   )
          {
           return myProvider;
          }
          
          /**
           * returns the DataType of the Data Object consisting of different flags described above
           */
     109  DataType DataObject::getType(   )
          {
           if (  myProvider )
           {
           return myProvider->getType(  myKey );
           }
           else
           {
           // We've lost the connection to our provider (  the object may be deleted ).
           return VOID;
           }
          }
          
          /**
           * returns the description of a Data Object.
           */
     125  std::string DataObject::getDescription(   )
          {
           if (  myProvider )
           {
           return myProvider->getDescription(  myKey );
           }
           else
           {
           return "Lost connection.";
           }
          }
          
          /**
           * sets the description of a Data Object.
           */
     140  void DataObject::setDescription(  std::string description )
          {
           if (  myProvider )
           {
           myProvider->setDescription(  myKey,   description );
           }
          }
          
          
          
          /**
           * All of the following value getting and setting methods can also be applied
           * to Data Objects of other types. In this case the values are converted in some default way. Some
           * of the conversions don't work for the setting method.
           *
           * If the value of a Data Object is 0 or "" or it has no child nodes,   it's boolean value is false,  
           * otherwise true.
           *
           * Booleans are presented as -1 for TRUE and 0 for FALSE,   if asked for integers. Floats
           * are rounded to get an integer and strings are parsed (  some kind of atoi ). Folders return the
           * number of child nodes as integer.
           *
           * Float convertions are performed in the same way as integer conversions.
           *
           * String conversion of boolean values are "TRUE" and "FALSE". Other string values are
           * some printf-like version of integers and floats and the ID of a folder's childs.
           */
          
     168  bool DataObject::getBoolVal(   )
          {
           DataType DataType = getType(   );
          
           if (  DataType & BOOLEAN || DataType & CUSTOM_TYPE )
           {
           return myProvider->getBoolVal(  myKey );
           }
          
           if (  DataType & VOID )
           {
           return false;
           }
          
           if (  DataType & FOLDER )
           {
           std::vector<std::string> listOfChilds;
           myProvider->getChilds(  myKey,   listOfChilds );
           return !listOfChilds.empty(   );
           }
          
           if (  DataType & INTEGER )
           {
           return myProvider->getIntVal(  myKey ) != 0;
           }
          
           if (  DataType & FLOAT )
           {
           return myProvider->getFloatVal(  myKey ) != 0.0;
           }
          
           //@todo: Should we test on != "false" rather?
           return !myProvider->getStringVal(  myKey ).empty(   );
          }
          
     203  int DataObject::getIntVal(   )
          {
           DataType DataType = getType(   );
          
           if (  DataType & INTEGER || DataType & CUSTOM_TYPE )
           {
           return myProvider->getIntVal(  myKey );
           }
          
           if (  DataType & BOOLEAN  )
           {
           return myProvider->getBoolVal(  myKey ) ? -1 : 0;
           }
          
           if (  DataType & VOID )
           {
           return 0;
           }
          
           if (  DataType & FOLDER )
           {
           std::vector<std::string> listOfChilds;
           myProvider->getChilds(  myKey,   listOfChilds );
           return listOfChilds.size(   );
           }
          
           if (  DataType & FLOAT )
           {
           //@todo: Should we take the next integer here instead?
           return static_cast<int>(  myProvider->getFloatVal(  myKey ) );
           }
          
           return myProvider->getStringVal(  myKey ).size(   );
          }
          
     238  float DataObject::getFloatVal(   )
          {
           DataType DataType = getType(   );
          
           if (  DataType & FLOAT || DataType & CUSTOM_TYPE )
           {
           return myProvider->getFloatVal(  myKey );
           }
          
           if (  DataType & BOOLEAN  )
           {
           return myProvider->getBoolVal(  myKey ) ? -1.0 : 0.0;
           }
          
           if (  DataType & VOID )
           {
           return 0.0;
           }
          
           if (  DataType & FOLDER )
           {
           std::vector<std::string> listOfChilds;
           myProvider->getChilds(  myKey,   listOfChilds );
           return (  float )listOfChilds.size(   );
           }
          
           if (  DataType & INTEGER )
           {
           return (  float )myProvider->getIntVal(  myKey );
           }
          
           return (  float )myProvider->getStringVal(  myKey ).size(   );
          }
          
     272  std::string DataObject::getStringVal(   )
          {
           DataType DataType = getType(   );
          
           if (  DataType & STRING || DataType & CUSTOM_TYPE )
           {
           return myProvider->getStringVal(  myKey );
           }
          
           if (  DataType & FLOAT )
           {
           char buffer[CONVERT_BUFFER_SIZE];
           sprintf(  buffer,   "%2.10f",   myProvider->getFloatVal(  myKey ) );
           return std::string(  buffer );
           }
          
           if (  DataType & BOOLEAN  )
           {
           return std::string(  myProvider->getBoolVal(  myKey ) ? "true" : "false" );
           }
          
           if (  DataType & VOID )
           {
           return "";
           }
          
           if (  DataType & FOLDER )
           {
           //@todo: Should we rather return "" here?
           return "";
           /*
           std::vector<std::string> listOfChilds;
           myProvider->getChilds(  myKey,   listOfChilds );
          
           std::string buffer = "{ ";
          
           for (  unsigned int i = 0; i < listOfChilds.size(   ); i++ )
           {
          
           buffer += listOfChilds[i];
           if (  i < listOfChilds.size(   )-1 )
           {
           buffer += ",   ";
           }
           }
          
           buffer += " }";
          
           return buffer;*/
           }
          
           {
           char buffer[CONVERT_BUFFER_SIZE];
           sprintf(  buffer,   "%d",   myProvider->getIntVal(  myKey ) );
           return std::string(  buffer );
           }
          }
          
     330  void DataObject::setBoolVal(  bool newValue )
          {
           DataType DataType = getType(   );
          
           if (  !(  DataType & CAN_SET_VALUE ) )
           {
           THROW1(  "Cannot set value of Data Object %s.",   myPath.c_str(   ) );
           }
          
           if (  DataType & BOOLEAN || DataType & CUSTOM_TYPE )
           {
           myProvider->setBoolVal(  myKey,   newValue );
           return;
           }
          
           if (  DataType & VOID || DataType & FOLDER )
           {
           return;
           }
          
           if (  DataType & FLOAT )
           {
           myProvider->setFloatVal(  myKey,   newValue ? 1.0 : 0.0 );
           return;
           }
          
           if (  DataType & INTEGER )
           {
           myProvider->setIntVal(  myKey,   newValue ? 1 : 0 );
           return;
           }
          
           myProvider->setStringVal(  myKey,   newValue ? "true" : "false" );
          }
          
     365  void DataObject::setIntVal(  int newValue )
          {
           DataType DataType = getType(   );
          
           if (  !(  DataType & CAN_SET_VALUE ) )
           {
           THROW1(  "Cannot set value of Data Object %s.",   myPath.c_str(   ) );
           }
          
           if (  DataType & INTEGER || DataType & CUSTOM_TYPE )
           {
           myProvider->setIntVal(  myKey,   newValue );
           return;
           }
          
           if (  DataType & VOID || DataType & FOLDER )
           {
           return;
           }
          
           if (  DataType & FLOAT )
           {
           myProvider->setFloatVal(  myKey,   static_cast<float>(  newValue ) );
           return;
           }
          
           if (  DataType & BOOLEAN )
           {
           myProvider->setBoolVal(  myKey,   newValue != 0 );
           return;
           }
          
           {
           char buffer[CONVERT_BUFFER_SIZE];
           sprintf(  buffer,   "%d",   newValue );
           myProvider->setStringVal(  myKey,   std::string(  buffer ) );
           }
          }
          
     404  void DataObject::setFloatVal(  float newValue )
          {
           DataType DataType = getType(   );
          
           if (  !(  DataType & CAN_SET_VALUE ) )
           {
           THROW1(  "Cannot set value of Data Object %s.",   myPath.c_str(   ) );
           }
          
           if (  DataType & FLOAT || DataType & CUSTOM_TYPE )
           {
           myProvider->setFloatVal(  myKey,   newValue );
           return;
           }
          
           if (  DataType & VOID || DataType & FOLDER )
           {
           return;
           }
          
           if (  DataType & INTEGER )
           {
           //@todo: Should we take the next integer here instead?
           myProvider->setIntVal(  myKey,   static_cast<int>(  newValue ) );
           return;
           }
          
           if (  DataType & BOOLEAN )
           {
           myProvider->setBoolVal(  myKey,   newValue != 0.0 );
           return;
           }
          
           {
           char buffer[CONVERT_BUFFER_SIZE];
           sprintf(  buffer,   "%2.10f",   newValue );
           myProvider->setStringVal(  myKey,   std::string(  buffer ) );
           }
          }
          
     444  void DataObject::setStringVal(  std::string newValue )
          {
           DataType DataType = getType(   );
          
           if (  !(  DataType & CAN_SET_VALUE ) )
           {
           THROW1(  "Cannot set value of Data Object %s.",   myPath.c_str(   ) );
           }
          
           if (  DataType & STRING || DataType & CUSTOM_TYPE )
           {
           myProvider->setStringVal(  myKey,   newValue );
           return;
           }
          
           if (  DataType & VOID || DataType & FOLDER )
           {
           return;
           }
          
           if (  DataType & INTEGER )
           {
           int dest = 0;
           sscanf(  newValue.c_str(   ),  "%d",   &dest );
           myProvider->setIntVal(  myKey,   dest );
           return;
           }
          
           if (  DataType & BOOLEAN )
           {
           //@todo: Should we test on != "false" rather?
           myProvider->setBoolVal(  myKey,   !newValue.empty(   ) );
           return;
           }
          
           {
           float dest = 0.0;
           sscanf(  newValue.c_str(   ),   "%f",   &dest );
           myProvider->setFloatVal(  myKey,   dest );
           }
          }
          
          /**
           * returns a direct/indirect child specified by the subpath.
           */
     489  PDataObject DataObject::getChild(  std::string subpath )
          {
           return PDataObject(  new DataObject(  myProvider,   myKey,   subpath,  
           DataProvider::makePath(  myPath,   subpath ) ) );
          }
          
          /**
           * Fills a list with the subpath of all direct childs.
           */
     498  void DataObject::getChildList(  ChildList & childList )
          {
           childList.clear(   );
          
           if (  !(  getType(   ) & HAS_CHILDS ) )
           {
           // THROW1(  "DataObject %s cannot have childs.",   myPath.c_str(   ) );
           return;
           }
          
          
           std::vector<std::string> IDList;
           myProvider->getChilds(  myKey,   IDList );
          
           for (  unsigned int i = 0; i < IDList.size(   ); i++ )
           {
           childList.push_back(  getChild(  IDList[i] ) );
           }
          }
          
     518  std::string DataObject::getUniqueID(   )
          {
           static int uniqueCounter = 0; //2^32 should be enough of uniqueness ;- )
           uniqueCounter++;
          
           char buffer[CONVERT_BUFFER_SIZE];
           sprintf(  buffer,   "~@#x%X",   uniqueCounter ); //some prefixing to not collide with non-generated names
          
           return buffer;
          }
          
          /**
           * returns a new Data Object added as child node. You can specify the new data object
           * to be another provider's top node.
           *
           * If no suggestedID (  = "" ) is given,   an unused ID is generated automatically.
           * ATTENTION: Don't rely on the child to have the suggested ID. (  That's why it's called
           * suggested! )
           */
     537  PDataObject DataObject::addChild(  std::string suggestedID,   DataProvider * provider )
          {
           DataType DataType = getType(   );
          
           if (  !(  DataType & CAN_ADD_CHILDS ) )
           {
           THROW1(  "You cannot add childs to Data Object %s.",   myPath.c_str(   ) );
           }
          
           if (  provider && !(  DataType & ADOPTS_CHILDS ) )
           {
           THROW1(  "Data Object %s doesn't adopt childs.",   myPath.c_str(   ) );
           }
          
          
           if (  suggestedID.empty(   ) )
           {
           suggestedID = getUniqueID(   );
           }
          
           myProvider->addChild(  myKey,   suggestedID,   provider );
          
           if (  provider )
           {
           return PDataObject(  new DataObject(  provider,   PDataKey(   ),   "",  
           DataProvider::makePath(  myPath,   suggestedID ) ) );
           }
           else
           {
           return PDataObject(  new DataObject(  myProvider,   myKey,   suggestedID,  
           DataProvider::makePath(  myPath,   suggestedID ) ) );
           }
          }
          
          
          /**
           * returns a new Data Object added as child node. If linkTo is specified (  non "" ),  
           * a link is added as new child Data Object.
           *
           * If no suggestedID (  = "" ) is given,   an unused ID is generated automatically.
           * ATTENTION: Don't rely on the child to have the suggested ID. (  That's why it's called
           * suggested! )
           */
     580  PDataObject DataObject::addChild(  std::string suggestedID,   std::string linkTo )
          {
           if (  !linkTo.empty(   ) )
           {
           LinkProvider * provider = new LinkProvider(  linkTo );
          
           try
           {
           return addChild(  suggestedID,   provider );
           }
           catch (  Exception * )
           {
           delete provider;
           throw;
           }
          
           }
           else
           {
           return addChild(  suggestedID,   NULL );
           }
          }
          
          /**
           * removes a Data Object. If the object is a link,   only the link will be removed.
           *
           * All links pointing to this child Data Object will be set to VOID-DataType. The same
           * happens on the DataObject itself and all other DataObjects using it.
           */
     609  void DataObject::remove(   )
          {
           DataType DataType = getType(   );
           if (  !(  DataType & CAN_REMOVE ) )
           {
           THROW1(  "Cannot remove Data Object %s.",   myPath.c_str(   ) );
           }
          
           myProvider->remove(  myKey );
          }
          
          /**
           * Adds a new connection to the signal. The returned DataConnection can be saved to
           * remove the connection later. To disconnect just hold the DataConnection and call
           * disconnect to it.
           *
           * types are all DataType of events the connection should be used for,  
           * or'd together. This can also include the FIRE_ON_CHILD_EVENT. If so,   all event of specified
           * DataType concerning direct OR indirect child nodes of the node are forwarded to this
           * connection,   too.
           */
     630  DataConnection DataObject::addConnection(  const DataSlot & slot,   DataType types )
          {
           if (  myProvider )
           {
           return myProvider->addConnection(  mySubpath,   slot,   types );
           }
           else
           {
           // @todo: Should it throw an exception,   that there's nothing to connect instead?
           return DataConnection(   );
           }
          }
          
          /**
           * Returns a new root data object for the specified path.
           */
     646  PDataObject DataObject::getRoot(  std::string path )
          {
           return PDataObject(  new DataObject(  path ) );
          }
          
          //----------------------------------------------------------------------
          // Constructors
          
     654  void DataObject::findObject(  std::string & subpath,  
     655   DataProvider *& provider,  
     656   PDataKey & key )
          {
           if (  provider == NULL )
           {
           //an absolute path is given
           provider =
          static_cast<DataProvider*>(  DataModelService::getInstance(   )->getRootProvider(   ) );
          
           if (  subpath[0] != '/' )
           {
           THROW1(  "Invalid path - missing trailing '/': %s'.",   subpath.c_str(   ) );
           }
          
           subpath = subpath.substr(  1 );
           }
          
           if (  !subpath.empty(   ) && subpath[0] == '/' )
           {
           THROW1(  "Invalid subpath - needs no trailing '/': %s'.",   subpath.c_str(   ) );
           }
          
           unsigned int i;
           std::string ID;
          
           std::string path = DataProvider::makePath(  provider->myPath,   subpath );
          
           while (  !subpath.empty(   ) )
           {
           DataProvider * newProvider = NULL;
          
           i = subpath.find(  '/' );
           ID = subpath.substr(  0,   i );
           key = provider->getChild(  key,   ID,   newProvider );
          
           if (  key.get(   ) == NULL )
           {
           THROW1(  "Cannot find Data Object %s in the Data Model.",  
           path.c_str(   ) );
           }
          
           if (  newProvider != NULL )
           {
           // Have to make the connection to the upper provider
           if (  !newProvider->myParent )
           {
           newProvider->myParent = provider;
           newProvider->myKey = key;
           newProvider->mySubpath = provider->getSubpath(  key );
           newProvider->myPath = DataProvider::makePath(  
           provider->myPath,   newProvider->mySubpath );
           }
          
           provider = newProvider;
           key.reset(   );
           }
          
           if (  i == std::basic_string<char>::npos )
           {
           subpath = "";
           }
           else
           {
           subpath = subpath.substr(  i+1 );
           }
           }
          
           subpath = provider->getSubpath(  key );
          }
          
     725  DataObject::DataObject(  DataProvider * provider,  
     726   PDataKey key,  
     727   std::string subpath,  
     728   std::string path )
          {
           myPath = path;
           myProvider = provider;
           myKey = key;
           mySubpath = subpath;
          
           findObject(  mySubpath,   myProvider,   myKey );
          
           // The DataObject should listen to removal operations,   so
           // it can be switched to VOID-state when necessary
          
           //@todo: What happens to Data Objects not supporting PRE_DELETION?
          
           myConnection = myProvider->addConnection(  mySubpath,  
           SigC::slot(  *this,   &DataObject::onObjectDeletion ),   PRE_DELETION );
          }
          
     746  DataObject::DataObject(  std::string path )
          {
           myPath = path;
           myProvider = NULL;
           mySubpath = path;
          
           findObject(  mySubpath,   myProvider,   myKey );
          
           // The DataObject should listen to removal operations,   so
           // it can be switched to VOID-state when necessary
          
           //@todo: What happens to Data Objects not supporting PRE_DELETION?
          
           myConnection = myProvider->addConnection(  mySubpath,  
           SigC::slot(  *this,   &DataObject::onObjectDeletion ),   PRE_DELETION );
          }
          
     763  DataObject::~DataObject(   )
          {
           myConnection.disconnect(   );
          }
          
     768  void DataObject::onObjectDeletion(  PDataObject object,   DataType event )
          {
           myProvider = NULL;
           myKey.reset(   );
          }
          
          } //dime

./services/datamodel/DataObject.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef DATAOBJECT_H
          #define DATAOBJECT_H
          
          // Include other headers of the current program here
          #include "DataProvider.h"
          #include "DataModel.h"
          
          // Include library headers here
          
          #include <boost/shared_ptr.hpp>
          
          // Include system headers here
          #include <string>
          #include <list>
          #include <vector>
          
          namespace dime {
          //@todo: Needs to use smartpointers
          
          //======================================================================
          // Short type macros
          //======================================================================
          
          const int CONVERT_BUFFER_SIZE = 24;
          
      44  class DataProvider;
      45  class DataKey;
      46  class DataConnection;
          
          typedef boost::shared_ptr<DataObject> PDataObject;
          
          /**
           * Class representing a node in the tree of the data model.
           *
           * This one and the DataService-class are the only classes used by data model users.
           * DataProvider should not be used by them!
           *
           * See http://www.worldforge.org/dev/eng/clients/dime/developer_doc/DataModelFW
           * for more info on the data model.
           *
           * @author Tim Enderling
           */
          
      62  class DataObject: virtual public SigC::Object
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
          
           public:
          
           /**
           * List used for holding data object's childs.
           */
           typedef std::vector<PDataObject> ChildList;
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           //======================================================================
           // Private Variables
           //======================================================================
           private:
      90   DataProvider * myProvider;
      91   PDataKey myKey;
      92   std::string mySubpath;
      93   std::string myPath;
      94   DataConnection myConnection;
          
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           /**
           * returns the ID of the node.
           */
     105   std::string getID(   );
          
           /**
           * returns the destination of the link.
           */
     110   PDataObject getLinkDest(   );
          
           /**
           * returns the path to the node from the root node.
           */
     115   std::string getPath(   );
          
           /**
           * returns the subpath within it's data model provider. Usually not needed by
           * Data Model users.
           */
     121   std::string getSubpath(   );
     122   PDataKey getKey(   );
          
           /**
           * returns the Data Object's data model provider. Usually not needed by
           * Data Model users.
           */
     128   DataProvider * getProvider(   );
          
           /**
           * returns the type of the Data Object consisting of different flags described above
           */
     133   DataType getType(   );
          
           /**
           * returns the description of a Data Object.
           */
     138   std::string getDescription(   );
     139   void setDescription(  std::string description );
          
           /**
           * All of the following value getting and setting methods can also be applied
           * to Data Objects of other types. In this case the values are converted in some default way. Some
           * of the conversions don't work for the setting method.
           *
           * If the value of a Data Object is 0 or "" or it has no child nodes,   it's boolean value is false,  
           * otherwise true.
           *
           * Booleans are presented as -1 for TRUE and 0 for FALSE,   if asked for integers. Floats
           * are rounded to get an integer and strings are parsed (  some kind of atoi ). Folders return the
           * number of child nodes as integer.
           *
           * Float convertions are performed in the same way as integer conversions.
           *
           * String conversion of boolean values are "TRUE" and "FALSE". Other string values are
           * some printf-like version of integers and floats and the ID of a folder's childs.
           */
          
     159   bool getBoolVal(   );
     160   int getIntVal(   );
     161   float getFloatVal(   );
     162   std::string getStringVal(   );
          
     164   void setBoolVal(  bool newValue );
     165   void setIntVal(  int newValue );
     166   void setFloatVal(  float newValue );
     167   void setStringVal(  std::string newValue );
          
           /**
           * returns a direct/indirect child specified by the subpath.
           */
     172   PDataObject getChild(  std::string subpath );
          
           /**
           * Fills a list with the subpath of all direct childs.
           */
     177   void getChildList(  ChildList & childList );
          
           /**
           * returns a new Data Object added as child node. You can specify the new data object
           * to be another provider's top node.
           *
           * If no suggestedID (  = "" ) is given,   an unused ID is generated automatically.
           * ATTENTION: Don't rely on the child to have the suggested ID. (  That's why it's called
           * suggested! )
           */
     187   PDataObject addChild(  std::string suggestedID,   DataProvider * provider );
          
           /**
           * returns a new Data Object added as child node. If linkTo is specified (  non "" ),  
           * a link is added as new child Data Object.
           *
           * If no suggestedID (  = "" ) is given,   an unused ID is generated automatically.
           * ATTENTION: Don't rely on the child to have the suggested ID. (  That's why it's called
           * suggested! )
           */
     197   PDataObject addChild(  std::string suggestedID = "",   std::string linkTo = "" );
          
           /**
           * removes a Data Object. If the object is a link,   only the link will be removed.
           *
           * All links pointing to this child Data Object will be set to VOID-type. The same
           * happens on the DataObject itself and all other DataObjects using it.
           */
     205   void remove(   );
          
           /**
           * Adds a new connection to the signal. The returned DataConnection can be saved to
           * remove the connection later. To disconnect just hold the DataConnection and call
           * disconnect to it.
           *
           * types are all type of events the connection should be used for,  
           * or'd together. This can also include the FIRE_ON_CHILD_EVENT. If so,   all event of specified
           * type concerning direct OR indirect child nodes of the node are forwarded to this
           * connection,   too.
           */
     217   DataConnection addConnection(  const DataSlot & slot,   DataType types );
          
           /**
           * Returns a unique ID string.
           */
     222   static std::string DataObject::getUniqueID(   );
          
           /**
           * Returns a new root data object for the specified path.
           */
     227   static PDataObject getRoot(  std::string path = "/" );
          
     229   static void findObject(  std::string & subpath,  
     230   DataProvider *& provider,  
     231   PDataKey & key );
          
           //----------------------------------------------------------------------
           // Constructors
     235   DataObject(  DataProvider * provider,  
     236   PDataKey key,  
     237   std::string subpath,  
     238   std::string path );
          
     240   DataObject(  std::string path );
          
           //----------------------------------------------------------------------
           // Destructor
          
     245   ~DataObject(   );
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
          
          
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
     262   void onObjectDeletion(  PDataObject object,   DataType event );
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
          }; // DataObject
          
          } // namespace dime
          
          #endif

./services/datamodel/DataProvider.cpp

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Include other headers of the current program here
          #include "DataProvider.h"
          #include "DataObject.h"
          #include "DataModelService.h"
          
          // Include library headers here
          
          #include <string>
          #include <list>
          #include <stdio.h>
          #include <stdarg.h>
          #include <ctime>
          
          // Include system headers here
          
          namespace dime {
          
          
      37  DataConnection::DataConnection(   )
          {
           myConnected = false;
          }
          
      42  DataConnection::DataConnection(  std::string path,  
      43   InternDataConnection * conn )
          {
           myPath = path;
           myConn = conn;
           myConnected = true;
          }
          
      50  DataConnection & DataConnection::operator=(  const DataConnection & source )
          {
           myPath = source.myPath;
           myConn = source.myConn;
           myConnected = source.myConnected;
           return *this;
          }
          
      58  void DataConnection::disconnect(   )
          {
           if (  !myConnected ) return;
          
           //If it isn't there the connection is probably removed already
           try
           {
           std::string path = myPath;
           DataProvider * provider = NULL;
           PDataKey key;
          
           DataObject::findObject(  path,   provider,   key );
          
           provider->removeConnection(  path,   myConn );
           }
           catch(  ... )
           {
          
           }
          
           myConnected = false;
          }
          
      81  DataProvider::DataProvider(   )
          {
           myParent = NULL;
          }
          
          
          //----------------------------------------------------------------------
          // Destructor
          
      90  DataProvider::~DataProvider(   )
          {
           // free the connections
           DataConnectionMap::iterator i;
          
           for (  i = myConns.begin(   ); i != myConns.end(   ); i++ )
           {
           DataConnectionList * list = i->second;
           DataConnectionList::iterator j;
          
           for (  j = list->begin(   ); j != list->end(   ); j++ )
           {
           delete *j;
           }
          
           delete list;
           }
          
           // remove me from my parent
           if (  myParent )
           {
           myParent->removeAdopted(  myKey );
           }
          }
          
          //----------------------------------------------------------------------
          // Other public methods
     117  DataConnection DataProvider::addConnection(  std::string subpath,   const DataSlot & slot,  
           DataType event )
          {
           DataConnectionList * list = myConns[subpath];
          
           if (  !list )
           {
           list = new DataConnectionList;
           myConns[subpath] = list;
           }
          
           InternDataConnection * conn = new InternDataConnection;
          
           conn->mySignal.connect(  slot );
           conn->myTypes = event;
          
           if (  event & FIRE_ON_CHILD_EVENT )
           {
           // Child-forward events always go in front
           list->push_front(  conn );
           }
           else
           {
           // Non-child-forward events always go back
           list->push_back(  conn );
           }
          
           DataConnection conn2 = DataConnection(  makePath(  myPath,   subpath ),   conn );
           std::string last = "";
           return conn2;
          }
          
     149  void DataProvider::removeConnection(  std::string subpath,  
     150   InternDataConnection * conn )
          {
           DataConnectionList * list = myConns[subpath];
          
           // Only if the list's not already removed.
           if (  list )
           {
           DataConnectionList::iterator i = list->begin(   );
          
           for(  ;i != list->end(   ); i++ )
           {
           if (  *i == conn )
           {
           delete *i;
           list->erase(  i );
           break;
           }
           }
           }
          }
          
     171  void DataProvider::removeAllConnections(  std::string subpath )
          {
           DataConnectionList::iterator i;
          
           DataConnectionList * list = NULL;
           DataConnectionMap::iterator a = myConns.find(  subpath );
          
           if (  a != myConns.end(   ) )
           {
           list = a->second;
           for (  i = list->begin(   ); i != list->end(   ); i++ )
           {
           delete *i;
           }
          
           delete list;
           myConns.erase(  a );
           }
          
          }
          
     192  void DataProvider::fireSignal(  std::string subpath,   DataType event )
          {
           PDataObject subject(  new DataObject(  this,   PDataKey(   ),   subpath,  
           makePath(  myPath,   subpath ) ) );
          
           // Event for this data object first.
           DataConnectionList::iterator i;
          
           DataConnectionList * list = NULL;
           DataConnectionMap::iterator m = myConns.find(  subpath );
          
           if (  m != myConns.end(   ) )
           {
           list = m->second;
           for (  i = list->begin(   ); i != list->end(   ); i++ )
           {
           if (  event & (  *i )->myTypes )
           {
           (  *i )->mySignal(  subject,   event );
           }
           }
           }
          
           // Events for all parent data objects.
           DataProvider * provider = this;
          
           unsigned int a;
           if (  subpath.empty(   ) )
           {
           provider = provider->myParent;
          
           if (  provider )
           {
           subpath = provider->mySubpath;
           a = subpath.rfind(  '/' );
           subpath = subpath.substr(  0,   a );
           }
           }
           else
           {
           a = subpath.rfind(  '/' );
           if (  a != std::string::npos )
           {
           subpath = subpath.substr(  0,   a );
           }
           else
           {
           subpath = "";
           }
           }
          
           while (  provider )
           {
           m = myConns.find(  subpath );
          
           if (  m != myConns.end(   ) )
           {
           list = m->second;
           for (  i = list->begin(   ); i != list->end(   ); i++ )
           {
           if (  ! (  (  *i )->myTypes & FIRE_ON_CHILD_EVENT ) )
           {
           // Since all fire-on-child-handler are added in front,   one
           // can stop finding the first non-child handler.
           break;
           }
          
           if (  event & (  *i )->myTypes )
           {
           (  *i )->mySignal(  subject,   event );
           }
           }
           }
          
           if (  subpath.empty(   ) )
           {
           provider = provider->myParent;
          
           if (  provider )
           {
           subpath = provider->mySubpath;
           a = subpath.rfind(  '/' );
           subpath = subpath.substr(  0,   a );
           }
           }
           else
           {
           a = subpath.rfind(  '/' );
           if (  a != std::string::npos )
           {
           subpath = subpath.substr(  0,   a );
           }
           else
           {
           subpath = "";
           }
           }
           }
          }
          
     292  void DataProvider::fireGeneralSignal(  DataType event )
          {
           DataConnectionMap::iterator i;
          
           for (  i = myConns.begin(   ); i != myConns.end(   ); i++ )
           {
           fireSignal(  i->first,   event );
           }
          }
          
     302  std::string DataProvider::makeSubpath(  std::string parentSubpath,   std::string ID )
          {
           std::string subpath = parentSubpath;
          
           if (  !parentSubpath.empty(   ) )
           {
           subpath += "/";
           }
          
           subpath += ID;
          
           return subpath;
          }
          
     316  std::string DataProvider::makePath(  std::string parentPath,   std::string ID )
          {
           std::string path = parentPath;
           if (  parentPath != "/" )
           {
           path += '/';
           }
           path += ID;
          
           return path;
          }
          
          } // namespace dime

./services/datamodel/DataProvider.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef DATAPROVIDER_H
          #define DATAPROVIDER_H
          
          // Include other headers of the current program here
          #include "DataModel.h"
          
          // Include library headers here
          
          #include <string>
          #include <vector>
          #include <list>
          #include <map>
          
          // Include system headers here
          
          namespace dime {
          
          //======================================================================
          // Short type macros
          //======================================================================
          /**
           * This class is what is used in OOP instead of 'void * cookie'
           */
          
      43  class DataKey
          {
          public:
      46   DataKey(   ) {}
           /**
           * The 'virtual' in front of this destructor is the only
           * reason we need DataKey for (  and to make a type browser
           * becoming handy ).
           */
      52   virtual ~DataKey (   ) {}
          };
          
          template <class T>
      56  class DataKeyImpl: public DataKey
          {
          private:
      59   T myKey;
          public:
      61   DataKeyImpl(  const T & key ) { myKey = key; }
      62   const T & getKey(   ) { return myKey; }
      63   virtual ~DataKeyImpl(   ) {} //This causes to free myKey
          
      65   static T& spec/*ialize*/(  boost::shared_ptr<DataKey> ptr )
           {
           return static_cast<DataKeyImpl<T> *>(  ptr.get(   ) )->myKey;
           }
          
      70   static boost::shared_ptr<DataKey> gen/*aralize*/(  const T & t )
           {
           return boost::shared_ptr<DataKey>(  static_cast<DataKey*>(  new DataKeyImpl<T>(  t ) ) );
           }
          };
          
      76  class InternDataConnection
          {
          public:
      79   DataSignal mySignal;
           DataType myTypes;
          };
          
          typedef std::list<InternDataConnection *> DataConnectionList;
          typedef std::map<std::string,   DataConnectionList *> DataConnectionMap;
          
          /**
           * HINT: Not to be confused with IternDataConnection.
           * This class hides from the Data Model user what's actually going on
           * with his connections. He can use it to remove Connections
           * once made.
           */
          
      93  class DataConnection
          {
          private:
      96   std::string myPath;
      97   InternDataConnection * myConn;
      98   bool myConnected;
          
          public:
          
     102   DataConnection(   );
     103   DataConnection(  std::string path,  
     104   InternDataConnection * conn );
          
     106   DataConnection & operator=(  const DataConnection & source );
     107   void disconnect(   );
          };
          
          
          /**
           * (  Nearly ) abstract base class for all parts of the program hosting own subtrees of the data model.
           *
           * See http://www.worldforge.org/dev/eng/clients/dime/developer_doc/DataModelFW
           * for more info on the data model and the role of data model providers.
           *
           * @author Tim Enderling
           */
          
     120  class DataProvider
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
           public:
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           //======================================================================
           // Private Variables
           //======================================================================
          
     142   DataConnectionMap myConns;
          
           public:
          
           DataProvider * myParent;
     147   PDataKey myKey;
     148   std::string mySubpath;
     149   std::string myPath;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           /**
           * Returns a new DataKey to an arbitrary child of a Data Object given by its DataKey. As
           * the ID of a child node,   DataKey's cannot change till objects deletion.
           * NULL is used for the root node of the hosted branch.
           * The return value is NULL if the ID is unknown
           *
           * If another Provider is responsible provider is filled with the responsible provider,  
           * the return value is though a valid DataKey for this provider. This special DataKey
           * is also called AdoptionKey. If not otherwise stated the AdoptionKey can not be
           * used for subsequent function calls to the interface.
           *
           * (  Hence there are two Datakeys for adopted objects - since there's also NULL
           * for the adopted provider. )
           */
     170   virtual PDataKey getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider ) = 0;
          
           /**
           * Returns the subpath of a given key. As an exception to the general rule
           * AdoptionKeys are allowed to use as value for key.
           */
     176   virtual std::string getSubpath(  PDataKey key ) = 0;
          
          
     179   virtual DataType getType(  PDataKey key ) = 0;
     180   virtual std::string getDescription(  PDataKey key ) = 0;
     181   virtual void setDescription(  PDataKey key,   std::string description ) = 0;
          
           /**
           * Getters and setters. Although getters and setters are only called by the DataModelService
           * value changes are not automatically signaled from it.
           * Setters are never called for DataObjects not having the CAN_SET_VALUE flag in it's type.
           */
           /* only called for BOOLEAN or CUSTOM - type */
     189   virtual bool getBoolVal(  PDataKey key ) = 0;
     190   virtual void setBoolVal(  PDataKey key,   bool newValue ) = 0;
          
           /* only called for INTEGER or CUSTOM - type */
     193   virtual int getIntVal(  PDataKey key ) = 0;
     194   virtual void setIntVal(  PDataKey key,   int newValue ) = 0;
          
           /* only called for FLOAT or CUSTOM - type */
     197   virtual float getFloatVal(  PDataKey key ) = 0;
     198   virtual void setFloatVal(  PDataKey key,   float newValue ) = 0;
          
           /* only called for STRING or CUSTOM - type */
     201   virtual std::string getStringVal(  PDataKey key ) = 0;
     202   virtual void setStringVal(  PDataKey key,   const std::string & newValue ) = 0;
          
           /**
           * Adds a new child. If it should be handled by some
           * other provider this has to be specified by a non-NULL value of DataProvider.
           *
           * HINT: The provider may or may not take the suggestedID as ID for the new DataObject.
           * The caller finds the corrected ID after the call in suggestedID.
           */
     211   virtual void addChild(  PDataKey parent,   std::string & suggestedID,  
           DataProvider * provider = NULL ) = 0;
          
           /**
           * Removes a Data Object given by it's DataKey.
           */
     217   virtual void remove(  PDataKey key ) = 0;
          
           /**
           * Removes an adopted Data Provider (  given by it's Adoption Key )
           */
     222   virtual void removeAdopted(  PDataKey adopted ) = 0;
          
     224   virtual void getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds ) = 0;
          
           //----------------------------------------------------------------------
           // Constructors
          
     229   DataProvider(   );
          
           //----------------------------------------------------------------------
           // Destructor
          
     234   virtual ~DataProvider(   );
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
     244   void removeAllConnections(  std::string subpath );
     245   void fireGeneralSignal(  DataType event );
     246   DataConnection addConnection(  std::string subpath,   const DataSlot & slot,  
           DataType event );
     248   void removeConnection(  std::string subpath,   InternDataConnection * conn );
     249   void fireSignal(  std::string subpath,   DataType event );
          
     251   static std::string makeSubpath(  std::string parentSubpath,   std::string ID );
     252   static std::string makePath(  std::string parentPath,   std::string ID );
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
          }; // DataProvider
          
          
          
          
          } // namespace dime
          
          #endif

./services/datamodel/FloatProvider.cpp

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistrbute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Include other headers of the current program here
          #include "FloatProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
      28  float FloatProvider::getValue(   )
          {
           return myValue;
          }
          
      33  void FloatProvider::setPermissions(  DataType permissions )
          {
           myPermissions = permissions;
          }
          
      38  void FloatProvider::setValue(  float newValue )
          {
           fireSignal(  "",   PRE_VALUE_CHANGE );
          
           myValue = newValue;
          
           fireSignal(  "",   POST_VALUE_CHANGE );
          }
          
      47  PDataKey FloatProvider::getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider )
          {
           return PDataKey(   ); //No childs available
          }
          
      52  std::string FloatProvider::getSubpath(  PDataKey key )
          {
           return ""; //No childs so the path is always ""
          }
          
      57  DataType FloatProvider::getType(  PDataKey key )
          {
           return static_cast<DataType>(  FLOAT |
           myPermissions | PRE_VALUE_CHANGE | POST_VALUE_CHANGE | PRE_DELETION );
          }
          
      63  std::string FloatProvider::getDescription(  PDataKey key )
          {
           return myDescription;
          }
          
      68  void FloatProvider::setDescription(  PDataKey key,   std::string description )
          {
           myDescription = description;
          }
          
      73  bool FloatProvider::getBoolVal(  PDataKey key )
          {
           return false;
          }
          
      78  void FloatProvider::setBoolVal(  PDataKey key,   bool newValue )
          {
          
          }
          
      83  int FloatProvider::getIntVal(  PDataKey key )
          {
           return 0;
          }
          
      88  void FloatProvider::setIntVal(  PDataKey key,   int newValue )
          {
          
          }
          
      93  float FloatProvider::getFloatVal(  PDataKey key )
          {
           return myValue;
          }
          
      98  void FloatProvider::setFloatVal(  PDataKey key,   float newValue )
          {
           //HINT: Doesn't have to test on if the user has the permission to set
           //this since this is done by the DataObject already.
          
           setValue(  newValue );
          }
          
     106  std::string FloatProvider::getStringVal(  PDataKey key )
          {
           return "";
          }
          
     111  void FloatProvider::setStringVal(  PDataKey key,   const std::string & newValue )
          {
          
          }
          
     116  void FloatProvider::addChild(  PDataKey parent,   std::string & suggestedID,  
     117   DataProvider * provider )
          {
          
           //No childs to add
          }
          
     123  void FloatProvider::remove(  PDataKey child )
          {
           //only me to remove
           delete this;
          }
          
     129  void FloatProvider::removeAdopted(  PDataKey adopted )
          {
           //is not adopting
          }
          
     134  void FloatProvider::getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds )
          {
           //again: No childs!
          }
          
     139  FloatProvider::FloatProvider(  float initialValue,   std::string description,  
           DataType permissions )
          {
           myValue = initialValue;
           myDescription = description;
           myPermissions = permissions;
          }
          
     147  FloatProvider::~FloatProvider(   )
          {
           // Fire a removal event to all observers listening to removal events
           fireSignal(  "",   PRE_DELETION );
          }
          
          } //dime

./services/datamodel/FloatProvider.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef FLOATPROVIDER_H
          #define FLOATPROVIDER_H
          
          // Include other headers of the current program here
          #include "DataProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
          /**
           * Provider for a holding a single float.
           *
           * @author Tim Enderling
           */
          
      37  class FloatProvider: public DataProvider,   virtual public SigC::Object
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
           public:
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           //======================================================================
           // Private Variables
           //======================================================================
           float myValue;
           DataType myPermissions; //determines whether the data model users
           //can change the value or not/remove it our not,   etc.
      61   std::string myDescription;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           /**
           * All documentation from the functions removed here to remove redundancy.
           * Look into DataProvider class instead.
           */
          
      73   virtual PDataKey getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider );
      74   virtual std::string getSubpath(  PDataKey key );
      75   virtual DataType getType(  PDataKey key );
      76   virtual std::string getDescription(  PDataKey key );
      77   virtual void setDescription(  PDataKey key,   std::string description );
          
      79   virtual bool getBoolVal(  PDataKey key );
      80   virtual void setBoolVal(  PDataKey key,   bool newValue );
      81   virtual int getIntVal(  PDataKey key );
      82   virtual void setIntVal(  PDataKey key,   int newValue );
      83   virtual float getFloatVal(  PDataKey key );
      84   virtual void setFloatVal(  PDataKey key,   float newValue );
      85   virtual std::string getStringVal(  PDataKey key );
      86   virtual void setStringVal(  PDataKey key,   const std::string & newValue );
          
      88   virtual void addChild(  PDataKey parent,   std::string & suggestedID,  
           DataProvider * provider = NULL );
      90   virtual void remove(  PDataKey child );
      91   virtual void removeAdopted(  PDataKey adopted );
      92   virtual void getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds );
          
      94   float getValue(   );
      95   void setValue(  float newValue );
      96   void setPermissions(  DataType permissions );
          
           //----------------------------------------------------------------------
           // Constructors
          
     101   FloatProvider(  float initialValue,   std::string description,  
           DataType permissions = static_cast<DataType>(  0 ) );
          
           //----------------------------------------------------------------------
           // Destructor
          
     107   virtual ~FloatProvider(   );
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
          }; // FloatProvider
          
          
          } // namespace dime
          
          #endif

./services/datamodel/FolderProvider.cpp

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Include other headers of the current program here
          #include "FolderProvider.h"
          #include "DataObject.h"
          #include <framework/Exception.h>
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
          
          
      32  PDataKey FolderProvider::getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider )
          {
           Item * parentItem = parent.get(   ) ? Key::spec(  parent ) : myRoot;
          
           ItemMap::iterator i = parentItem->myMap.find(  ID );
          
           if (  i == parentItem->myMap.end(   ) ) return PDataKey(   );
          
           if (  i->second->myDest )
           {
           provider = i->second->myDest;
           }
          
           return Key::gen(  i->second );
          }
          
      48  std::string FolderProvider::getSubpath(  PDataKey key )
          {
           return key.get(   ) ? Key::spec(  key )->mySubpath : "";
          }
          
      53  DataType FolderProvider::getType(  PDataKey key )
          {
           return static_cast<DataType>(   POST_ADDITION | PRE_DELETION |
           FOLDER | HAS_CHILDS | ADOPTS_CHILDS | CAN_ADD_CHILDS | CAN_REMOVE );
          }
          
      59  std::string FolderProvider::getDescription(  PDataKey key )
          {
           Item * item = key.get(   ) ? Key::spec(  key ) : myRoot;
          
           return item->myDescrip;
          }
          
      66  void FolderProvider::setDescription(  PDataKey key,   std::string description )
          {
           Item * item = key.get(   ) ? Key::spec(  key ) : myRoot;
          
           item->myDescrip = description;
          }
          
      73  bool FolderProvider::getBoolVal(  PDataKey key )
          {
           return false;
          }
          
      78  void FolderProvider::setBoolVal(  PDataKey key,   bool newValue )
          {
          
          }
          
      83  int FolderProvider::getIntVal(  PDataKey key )
          {
           return 0;
          }
          
      88  void FolderProvider::setIntVal(  PDataKey key,   int newValue )
          {
          
          }
          
      93  float FolderProvider::getFloatVal(  PDataKey key )
          {
           return 0.0;
          }
          
      98  void FolderProvider::setFloatVal(  PDataKey key,   float newValue )
          {
          
          }
          
     103  std::string FolderProvider::getStringVal(  PDataKey key )
          {
           return "";
          }
          
     108  void FolderProvider::setStringVal(  PDataKey key,   const std::string & newValue )
          {
          
          }
          
     113  void FolderProvider::addChild(  PDataKey parent,   std::string & suggestedID,  
     114   DataProvider * provider )
          {
           Item * parentItem = parent.get(   ) ? Key::spec(  parent ) : myRoot;
          
           //Not in general but useful for FolderProvider:
           //If the suggestedID doesn't work,   throw an exception
          
           ItemMap::iterator i = parentItem->myMap.find(  suggestedID );
          
           if (  i != parentItem->myMap.end(   ) )
           {
           std::string path = myPath;
           if (  myPath != "/" )
           {
           path += '/';
           }
           path += parentItem->mySubpath;
          
           THROW2(  "There's already a child %s of %s.",   suggestedID.c_str(   ),  
           makePath(  myPath,   parentItem->mySubpath ).c_str(   ) );
           }
          
           std::string subpath = makeSubpath(  parentItem->mySubpath,   suggestedID );
          
           parentItem->myMap[suggestedID] = new Item(  subpath,   parentItem,   provider );
           fireSignal(  subpath,   POST_ADDITION );
          }
          
     142  void FolderProvider::removeAdopted(  PDataKey child )
          {
           Item * item = Key::spec(  child );
          
           //HINT: No PRE_DELETION warning to be fired here,   since
           //the adopted data provider is responsible.
          
           item->myParent->myMap.erase(  item->mySubpath.substr(  item->mySubpath.rfind(  '/' )+1 ) );
          
           delete item;
          }
          
     154  void FolderProvider::remove(  PDataKey child )
          {
           if (  child.get(   ) == NULL )
           {
           //HINT: This can only be NULL for an outer call. So don't worry:
           //if the destructor calls this with the top element,   he uses
           //the actual pointer value as key.
           delete this;
           return;
           }
          
           Item * item = Key::spec(  child );
          
          
           //remove all below childs (  depth first )
           ItemMap::iterator i;
          
           for (  i = item->myMap.begin(   ); i != item->myMap.end(   ); )
           {
           Item * subitem = i->second;
           PDataKey subchild = Key::gen(  subitem );
          
           i++;
          
           if (  subitem->myDest )
           {
           //don't remove the provider - it is removing itself!
           delete subitem->myDest;
           }
           else
           {
           remove(  subchild );
           }
           }
          
           //Before you start removing the actual node,   the observers
           //should be warned that something is deleted.
           fireSignal(  item->mySubpath,   PRE_DELETION );
          
           if (  item->myParent )
           {
           item->myParent->myMap.erase(  item->mySubpath.substr(  item->mySubpath.rfind(  '/' )+1 ) );
           }
          
           removeAllConnections(  item->mySubpath );
           delete item;
          }
          
     202  void FolderProvider::getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds )
          {
           Item * parentItem = parent.get(   ) ? Key::spec(  parent ) : myRoot;
          
           listOfChilds.clear(   );
          
           ItemMap::iterator i;
          
           for (  i = parentItem->myMap.begin(   ); i != parentItem->myMap.end(   ); i++ )
           {
           listOfChilds.push_back(  i->first );
           }
          }
          
     216  FolderProvider::FolderProvider(   )
          {
           myRoot = new Item(   );
          }
          
     221  FolderProvider::~FolderProvider(   )
          {
           remove(  Key::gen(  myRoot ) );
          }
          
          } //dime

./services/datamodel/FolderProvider.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef FOLDERPROVIDER_H
          #define FOLDERPROVIDER_H
          
          // Include other headers of the current program here
          #include "DataProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
          /**
           * Provider for arbitrary structure support. Hasn't to be used directly,   but by DataObject,   though can.
           *
           * @author Tim Enderling
           */
          
      37  class FolderProvider: public DataProvider
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
           public:
          
           /**
           * The data is hold in a simple double linked tree,   where the parent has a named
           * map to it's childs and the child has a pointer to the parent.
           */
      54   class Item;
           typedef std::map<std::string,   Item *> ItemMap;
          
      57   class Item
           {
           public:
      60   Item(   )
           {
           mySubpath = "";
           myParent = NULL;
           myDest = NULL;
           myDescrip = "";
           }
          
      68   Item(  std::string subpath,   Item * parent,   DataProvider * dest )
           {
           mySubpath = subpath;
           myParent = parent;
           myDest = dest;
           myDescrip = "";
           }
          
      76   std::string mySubpath;
           Item * myParent;
      78   DataProvider * myDest;
      79   ItemMap myMap;
      80   std::string myDescrip;
           };
          
           typedef DataKeyImpl<Item *> Key;
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           //======================================================================
           // Private Variables
           //======================================================================
          
      94   Item * myRoot;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           /**
           * All documentation from the functions removed here to remove redundancy.
           * Look into DataProvider class instead.
           */
          
     106   virtual PDataKey getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider );
     107   virtual std::string getSubpath(  PDataKey key );
     108   virtual DataType getType(  PDataKey key );
     109   virtual std::string getDescription(  PDataKey key );
     110   virtual void setDescription(  PDataKey key,   std::string description );
          
     112   virtual bool getBoolVal(  PDataKey key );
     113   virtual void setBoolVal(  PDataKey key,   bool newValue );
     114   virtual int getIntVal(  PDataKey key );
     115   virtual void setIntVal(  PDataKey key,   int newValue );
     116   virtual float getFloatVal(  PDataKey key );
     117   virtual void setFloatVal(  PDataKey key,   float newValue );
     118   virtual std::string getStringVal(  PDataKey key );
     119   virtual void setStringVal(  PDataKey key,   const std::string & newValue );
          
     121   virtual void addChild(  PDataKey parent,   std::string & suggestedID,  
           DataProvider * provider = NULL );
     123   virtual void remove(  PDataKey child );
     124   virtual void removeAdopted(  PDataKey adopted );
     125   virtual void getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds );
          
           //----------------------------------------------------------------------
           // Constructors
          
     130   FolderProvider(   );
          
           //----------------------------------------------------------------------
           // Destructor
          
     135   virtual ~FolderProvider(   );
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
          }; // FolderProvider
          
          } // namespace dime
          
          #endif

./services/datamodel/IntProvider.cpp

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Include other headers of the current program here
          #include "IntProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
      28  int IntProvider::getValue(   )
          {
           return myValue;
          }
          
      33  void IntProvider::setPermissions(  DataType permissions )
          {
           myPermissions = permissions;
          }
          
      38  void IntProvider::setValue(  int newValue )
          {
           fireSignal(  "",   PRE_VALUE_CHANGE );
          
           myValue = newValue;
          
           fireSignal(  "",   POST_VALUE_CHANGE );
          }
          
      47  PDataKey IntProvider::getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider )
          {
           return PDataKey(   ); //No childs available
          }
          
      52  std::string IntProvider::getSubpath(  PDataKey key )
          {
           return ""; //No childs so the path is always ""
          }
          
      57  DataType IntProvider::getType(  PDataKey key )
          {
           return static_cast<DataType>(  INTEGER |
           myPermissions | PRE_VALUE_CHANGE | POST_VALUE_CHANGE | PRE_DELETION );
          }
          
      63  std::string IntProvider::getDescription(  PDataKey key )
          {
           return myDescription;
          }
          
      68  void IntProvider::setDescription(  PDataKey key,   std::string description )
          {
           myDescription = description;
          }
          
      73  bool IntProvider::getBoolVal(  PDataKey key )
          {
           return false;
          }
          
      78  void IntProvider::setBoolVal(  PDataKey key,   bool newValue )
          {
          
          }
          
      83  int IntProvider::getIntVal(  PDataKey key )
          {
           return myValue;
          }
          
      88  void IntProvider::setIntVal(  PDataKey key,   int newValue )
          {
           //HINT: Doesn't have to test on if the user has the permission to set
           //this since this is done by the DataObject already.
          
           setValue(  newValue );
          }
          
      96  float IntProvider::getFloatVal(  PDataKey key )
          {
           return 0.0;
          }
          
     101  void IntProvider::setFloatVal(  PDataKey key,   float newValue )
          {
          
          }
          
     106  std::string IntProvider::getStringVal(  PDataKey key )
          {
           return "";
          }
          
     111  void IntProvider::setStringVal(  PDataKey key,   const std::string & newValue )
          {
          
          }
          
     116  void IntProvider::addChild(  PDataKey parent,   std::string & suggestedID,  
     117   DataProvider * provider )
          {
          
           //No childs to add
          }
          
     123  void IntProvider::remove(  PDataKey child )
          {
           //only me to remove
           delete this;
          }
          
     129  void IntProvider::removeAdopted(  PDataKey adopted )
          {
           //is not adopting
          }
          
     134  void IntProvider::getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds )
          {
           //again: No childs!
          }
          
     139  IntProvider::IntProvider(  int initialValue,   std::string description,  
           DataType permissions )
          {
           myValue = initialValue;
           myDescription = description;
           myPermissions = permissions;
          }
          
     147  IntProvider::~IntProvider(   )
          {
           // Fire a removal event to all observers listening to removal events
           fireSignal(  "",   PRE_DELETION );
          }
          
          } //dime

./services/datamodel/IntProvider.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef INTPROVIDER_H
          #define INTPROVIDER_H
          
          // Include other headers of the current program here
          #include "DataProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
          /**
           * Provider for a holding a single int.
           *
           * @author Tim Enderling
           */
          
      37  class IntProvider: public DataProvider,   virtual public SigC::Object
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
           public:
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           //======================================================================
           // Private Variables
           //======================================================================
           int myValue;
           DataType myPermissions; //determines whether the data model users
           //can change the value or not/remove it our not,   etc.
      61   std::string myDescription;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           /**
           * All documentation from the functions removed here to remove redundancy.
           * Look into DataProvider class instead.
           */
          
      73   virtual PDataKey getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider );
      74   virtual std::string getSubpath(  PDataKey key );
      75   virtual DataType getType(  PDataKey key );
      76   virtual std::string getDescription(  PDataKey key );
      77   virtual void setDescription(  PDataKey key,   std::string description );
          
      79   virtual bool getBoolVal(  PDataKey key );
      80   virtual void setBoolVal(  PDataKey key,   bool newValue );
      81   virtual int getIntVal(  PDataKey key );
      82   virtual void setIntVal(  PDataKey key,   int newValue );
      83   virtual float getFloatVal(  PDataKey key );
      84   virtual void setFloatVal(  PDataKey key,   float newValue );
      85   virtual std::string getStringVal(  PDataKey key );
      86   virtual void setStringVal(  PDataKey key,   const std::string & newValue );
          
      88   virtual void addChild(  PDataKey parent,   std::string & suggestedID,  
           DataProvider * provider = NULL );
      90   virtual void remove(  PDataKey child );
      91   virtual void removeAdopted(  PDataKey adopted );
      92   virtual void getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds );
          
      94   int getValue(   );
      95   void setValue(  int newValue );
      96   void setPermissions(  DataType permissions );
          
           //----------------------------------------------------------------------
           // Constructors
          
     101   IntProvider(  int initialValue,   std::string description,  
           DataType permissions = static_cast<DataType>(  0 ) );
          
           //----------------------------------------------------------------------
           // Destructor
          
     107   virtual ~IntProvider(   );
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
          }; // IntProvider
          
          
          } // namespace dime
          
          #endif

./services/datamodel/LinkProvider.cpp

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Include other headers of the current program here
          #include "LinkProvider.h"
          #include "DataObject.h"
          
          // Include library headers here
          #if SIGC_MAJOR_VERSION == 1 && SIGC_MINOR_VERSION == 0
          #else
          #include <sigc++/object_slot.h>
          #endif
          
          // Include system headers here
          
          namespace dime {
          
          /**
           * Most of the LinkProviders actions are:
           * - Replace the NULL-DataKey by the Root destination Key
           * - Pass through to the other provider
           *
           * Also it translates subpaths and forwards all signals.
           */
          
          /**
           * Really short for 'real key'
           **/
          #define RK(  key ) (  (  key.get(   ) == NULL ) ? &myRoot : (  &Key::spec(  key ) ) )
          
          /**
           * Really short for 'real key variable'
           */
          
          #define RKV(  key ) Item * item = RK(  key ) /*;*/
          
      52  PDataKey LinkProvider::getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider )
          {
           RKV(  parent );
          
           if (  myRoot.myDest )
           {
           Item newItem;
           newItem.myDestKey =
           item->myDest->getChild(  item->myDestKey,   ID,   newItem.myDest );
           newItem.mySubpath = DataProvider::makeSubpath(  item->mySubpath,   ID );
           return Key::gen(  newItem );
           }
           else
           {
           return PDataKey(   );
           }
          }
          
      70  std::string LinkProvider::getSubpath(  PDataKey key )
          {
           if (  myRoot.myDest )
           {
           return RK(  key )->mySubpath;
           }
           else
           {
           // @todo: Should an exception be thrown instead?
           return "";
           }
          }
          
      83  DataType LinkProvider::getType(  PDataKey key )
          {
           if (  myRoot.myDest )
           {
           RKV(  key );
           return static_cast<DataType>(  item->myDest->getType(  item->myDestKey ) | IS_LINK );
           }
           else
           {
           return static_cast<DataType>(  VOID | IS_LINK );
           }
          }
          
      96  std::string LinkProvider::getDescription(  PDataKey key )
          {
           if (  myRoot.myDest )
           {
           RKV(  key );
           return item->myDest->getDescription(  item->myDestKey );
           }
           else
           {
           return "Link to nothing.";
           }
          }
          
     109  void LinkProvider::setDescription(  PDataKey key,   std::string description )
          {
           if (  myRoot.myDest )
           {
           RKV(  key );
           item->myDest->setDescription(  item->myDestKey,   description );
           }
          }
          
     118  bool LinkProvider::getBoolVal(  PDataKey key )
          {
           RKV(  key );
           return item->myDest->getBoolVal(  item->myDestKey );
          }
          
     124  void LinkProvider::setBoolVal(  PDataKey key,   bool newValue )
          {
           RKV(  key );
           item->myDest->setBoolVal(  item->myDestKey,   newValue );
          }
          
     130  int LinkProvider::getIntVal(  PDataKey key )
          {
           RKV(  key );
           return item->myDest->getIntVal(  item->myDestKey );
          }
          
     136  void LinkProvider::setIntVal(  PDataKey key,   int newValue )
          {
           RKV(  key );
           item->myDest->setIntVal(  item->myDestKey,   newValue );
          }
          
     142  float LinkProvider::getFloatVal(  PDataKey key )
          {
           RKV(  key );
           return item->myDest->getFloatVal(  item->myDestKey );
          }
          
     148  void LinkProvider::setFloatVal(  PDataKey key,   float newValue )
          {
           RKV(  key );
           item->myDest->setFloatVal(  item->myDestKey,   newValue );
          }
          
     154  std::string LinkProvider::getStringVal(  PDataKey key )
          {
           RKV(  key );
           return item->myDest->getStringVal(  item->myDestKey );
          }
          
     160  void LinkProvider::setStringVal(  PDataKey key,   const std::string & newValue )
          {
           RKV(  key );
           item->myDest->setStringVal(  item->myDestKey,   newValue );
          }
          
     166  void LinkProvider::addChild(  PDataKey parent,   std::string & suggestedID,  
     167   DataProvider * provider )
          {
           RKV(  parent );
           item->myDest->addChild(  item->myDestKey,   suggestedID,   provider );
          }
          
     173  void LinkProvider::remove(  PDataKey child )
          {
           if (  child.get(   ) == NULL )
           {
           delete this;
           }
           else
           {
           RKV(  child );
           item->myDest->remove(  item->myDestKey );
           }
          }
          
     186  void LinkProvider::removeAdopted(  PDataKey adopted )
          {
           //is not adopting
          }
          
     191  void LinkProvider::getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds )
          {
           RKV(  parent );
           item->myDest->getChilds(  item->myDestKey,   listOfChilds );
          }
          
     197  void LinkProvider::onSignal(  PDataObject object,   DataType event )
          {
           std::string subpath = object->getPath(   );
          
           if (  subpath.size(   ) <= myDestPath.size(   ) )
           {
           subpath = "";
           }
           else
           {
           subpath = subpath.substr(  myDestPath.size(   )+1 );
           }
          
           if (  subpath.empty(   ) && (  event & PRE_DELETION ) )
           {
           fireSignal(  "",   PRE_LINK_CHANGE );
           }
           else
           {
           fireSignal(  subpath,   event );
           }
          
           if (  event & PRE_DELETION )
           {
           if (  subpath.empty(   ) )
           {
           //lost connection to the provider
           myRoot.myDest = NULL;
           fireSignal(  "",   POST_LINK_CHANGE );
           }
           else
           {
           removeAllConnections(  subpath );
           }
           }
          }
          
     234  std::string LinkProvider::getLinkDest(   )
          {
           return myDestPath;
          }
          
     239  LinkProvider::LinkProvider(  std::string destPath )
          {
           myRoot.myDest = NULL;
           myDestPath = destPath;
           std::string destSubpath = destPath;
          
           DataObject::findObject(  destSubpath,   myRoot.myDest,   myRoot.myDestKey );
          
           myRoot.myDest->addConnection(  destSubpath,   SigC::slot(  *this,   &LinkProvider::onSignal ),  
           static_cast<DataType>(  PRE_VALUE_CHANGE | POST_VALUE_CHANGE | POST_ADDITION | PRE_DELETION |
           PRE_LINK_CHANGE | POST_LINK_CHANGE | FIRE_ON_CHILD_EVENT ) );
          
          }
          
     253  LinkProvider::~LinkProvider(   )
          {
           myConnection.disconnect(   );
          
           // Fire a removal event to all observers listening to removal events
           fireGeneralSignal(  PRE_DELETION );
          }
          } //dime

./services/datamodel/LinkProvider.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef LINKPROVIDER_H
          #define LINKPROVIDER_H
          
          // Include other headers of the current program here
          #include "DataProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
          /**
           * Provider for linkage support. Hasn't to be used directly,   but by DataObject,   though can.
           *
           * @author Tim Enderling
           */
          
      37  class LinkProvider: public DataProvider,   virtual public SigC::Object
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
           public:
          
      50   class Item
           {
           public:
      53   Item(   )
           {
           myDest = NULL;
           }
          
      58   std::string mySubpath;
      59   DataProvider * myDest;
      60   PDataKey myDestKey;
           };
          
           typedef DataKeyImpl<Item> Key;
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           //======================================================================
           // Private Variables
           //======================================================================
          
      74   Item myRoot;
      75   std::string myDestPath;
      76   DataConnection myConnection;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           /**
           * All documentation from the functions removed here to remove redundancy.
           * Look into DataProvider class instead.
           */
          
      88   virtual PDataKey getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider );
      89   virtual std::string getSubpath(  PDataKey key );
      90   virtual DataType getType(  PDataKey key );
      91   virtual std::string getDescription(  PDataKey key );
      92   virtual void setDescription(  PDataKey key,   std::string description );
          
      94   virtual bool getBoolVal(  PDataKey key );
      95   virtual void setBoolVal(  PDataKey key,   bool newValue );
      96   virtual int getIntVal(  PDataKey key );
      97   virtual void setIntVal(  PDataKey key,   int newValue );
      98   virtual float getFloatVal(  PDataKey key );
      99   virtual void setFloatVal(  PDataKey key,   float newValue );
     100   virtual std::string getStringVal(  PDataKey key );
     101   virtual void setStringVal(  PDataKey key,   const std::string & newValue );
          
     103   virtual void addChild(  PDataKey parent,   std::string & suggestedID,  
           DataProvider * provider = NULL );
     105   virtual void remove(  PDataKey child );
     106   virtual void removeAdopted(  PDataKey adopted );
     107   virtual void getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds );
          
     109   std::string getLinkDest(   );
          
           //----------------------------------------------------------------------
           // Constructors
          
     114   LinkProvider(  std::string destPath );
          
           //----------------------------------------------------------------------
           // Destructor
          
     119   virtual ~LinkProvider(   );
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
     134   void onSignal(  PDataObject object,   DataType event );
          
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
          }; // LinkProvider
          
          
          } // namespace dime
          
          #endif

./services/datamodel/StringProvider.cpp

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          // Include other headers of the current program here
          #include "StringProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
      28  std::string StringProvider::getValue(   )
          {
           return myValue;
          }
          
      33  void StringProvider::setPermissions(  DataType permissions )
          {
           myPermissions = permissions;
          }
          
      38  void StringProvider::setValue(  std::string newValue )
          {
           fireSignal(  "",   PRE_VALUE_CHANGE );
          
           myValue = newValue;
          
           fireSignal(  "",   POST_VALUE_CHANGE );
          }
          
      47  PDataKey StringProvider::getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider )
          {
           return PDataKey(   ); //No childs available
          }
          
      52  std::string StringProvider::getSubpath(  PDataKey key )
          {
           return ""; //No childs so the path is always ""
          }
          
      57  DataType StringProvider::getType(  PDataKey key )
          {
           return static_cast<DataType>(  STRING |
           myPermissions | PRE_VALUE_CHANGE | POST_VALUE_CHANGE | PRE_DELETION );
          }
          
      63  std::string StringProvider::getDescription(  PDataKey key )
          {
           return myDescription;
          }
          
      68  void StringProvider::setDescription(  PDataKey key,   std::string description )
          {
           myDescription = description;
          }
          
      73  bool StringProvider::getBoolVal(  PDataKey key )
          {
           return false;
          }
          
      78  void StringProvider::setBoolVal(  PDataKey key,   bool newValue )
          {
          
          }
          
      83  int StringProvider::getIntVal(  PDataKey key )
          {
           return 0;
          }
          
      88  void StringProvider::setIntVal(  PDataKey key,   int newValue )
          {
          }
          
      92  float StringProvider::getFloatVal(  PDataKey key )
          {
           return 0.0;
          }
          
      97  void StringProvider::setFloatVal(  PDataKey key,   float newValue )
          {
          
          }
          
     102  std::string StringProvider::getStringVal(  PDataKey key )
          {
           return myValue;
          }
          
     107  void StringProvider::setStringVal(  PDataKey key,   const std::string & newValue )
          {
           //HINT: Doesn't have to test on if the user has the permission to set
           //this since this is done by the DataObject already.
          
           setValue(  newValue );
          }
          
     115  void StringProvider::addChild(  PDataKey parent,   std::string & suggestedID,  
     116   DataProvider * provider )
          {
          
           //No childs to add
          }
          
     122  void StringProvider::remove(  PDataKey child )
          {
           //only me to remove
           delete this;
          }
          
     128  void StringProvider::removeAdopted(  PDataKey adopted )
          {
           //is not adopting
          }
          
     133  void StringProvider::getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds )
          {
           //again: No childs!
          }
          
     138  StringProvider::StringProvider(  std::string initialValue,   std::string description,  
           DataType permissions )
          {
           myValue = initialValue;
           myDescription = description;
           myPermissions = permissions;
          }
          
     146  StringProvider::~StringProvider(   )
          {
           // Fire a removal event to all observers listening to removal events
           fireSignal(  "",   PRE_DELETION );
          }
          
          } //dime

./services/datamodel/StringProvider.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef STRINGPROVIDER_H
          #define STRINGPROVIDER_H
          
          // Include other headers of the current program here
          #include "DataProvider.h"
          
          // Include library headers here
          
          // Include system headers here
          
          namespace dime {
          
          /**
           * Provider for a holding a single string.
           *
           * @author Tim Enderling
           */
          
      37  class StringProvider: public DataProvider,   virtual public SigC::Object
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
           public:
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           //======================================================================
           // Private Variables
           //======================================================================
      58   std::string myValue;
           DataType myPermissions; //determines whether the data model users
           //can change the value or not/remove it our not,   etc.
      61   std::string myDescription;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           /**
           * All documentation from the functions removed here to remove redundancy.
           * Look into DataProvider class instead.
           */
          
      73   virtual PDataKey getChild(  PDataKey parent,   std::string ID,   DataProvider *& provider );
      74   virtual std::string getSubpath(  PDataKey key );
      75   virtual DataType getType(  PDataKey key );
      76   virtual std::string getDescription(  PDataKey key );
      77   virtual void setDescription(  PDataKey key,   std::string description );
          
      79   virtual bool getBoolVal(  PDataKey key );
      80   virtual void setBoolVal(  PDataKey key,   bool newValue );
      81   virtual int getIntVal(  PDataKey key );
      82   virtual void setIntVal(  PDataKey key,   int newValue );
      83   virtual float getFloatVal(  PDataKey key );
      84   virtual void setFloatVal(  PDataKey key,   float newValue );
      85   virtual std::string getStringVal(  PDataKey key );
      86   virtual void setStringVal(  PDataKey key,   const std::string & newValue );
          
      88   virtual void addChild(  PDataKey parent,   std::string & suggestedID,  
           DataProvider * provider = NULL );
      90   virtual void remove(  PDataKey child );
      91   virtual void removeAdopted(  PDataKey adopted );
      92   virtual void getChilds(  PDataKey parent,   std::vector<std::string> & listOfChilds );
          
      94   std::string getValue(   );
      95   void setValue(  std::string newValue );
      96   void setPermissions(  DataType permissions );
          
           //----------------------------------------------------------------------
           // Constructors
          
     101   StringProvider(  std::string initialValue,   std::string description,  
           DataType permissions = static_cast<DataType>(  0 ) );
          
           //----------------------------------------------------------------------
           // Destructor
          
     107   virtual ~StringProvider(   );
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
          }; // StringProvider
          
          
          } // namespace dime
          
          #endif

./services/input/EmberKey.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef DIMEKEY_H
          #define DIMEKEY_H
          
          
          #include <SDL/SDL_keysym.h>
          #include <SDL/SDL_events.h>
          #include <SDL/SDL.h>
          namespace dime
          {
          
          
          /**
           * General class to hold both SDLKey and the unicode value for a keypress
           */
      33  class DimeKey
          {
          private:
           //my SDLKey
      37   SDLKey myKey;
           //my unicode value
      39   Uint16 myUnicode;
          public:
      41   DimeKey(  SDLKey key,   Uint16 unicode )
           : myKey(  key ),   myUnicode(  unicode )
           {
           }
          
      46   ~DimeKey(   )
           {
           }
          
      50   SDLKey getKey(   ) const
           {
           return myKey;
           }
          
      55   Uint16 getUnicode(   ) const
           {
           return myUnicode;
           }
          
      60   void setKey(  SDLKey key )
           {
           myKey = key;
           }
          
      65   void setUnicode(  Uint16 unicode )
           {
           myUnicode = unicode;
           }
          
          
          };//end class DimeKey
          
          }//end namespace dime
          #endif

./services/input/InputDevice.cpp

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "InputDevice.h"
          #include "InputMapping.h"
          #include "InputService.h"
          
          namespace dime
          {
          
      26  InputDevice::InputDevice(  InputDevice::DeviceType type,   int index,   int subIndex )
          {
           myType = type;
           myIndex = index;
           mySubIndex = subIndex;
          
           //automatic registration
          
           InputService * inputService = InputService::getInstance(   );
           inputService->myInputDevices.push_back(  this );
          }
          
      38  InputDevice::~InputDevice(   )
          {
           InputService * inputService = InputService::getInstance(   );
          
           //all mappings have to be removed prior to deleting this input device
           while (  !myMotionMappings.empty(   ) )
           {
           inputService->removeInputMapping(  *myMotionMappings.begin(   ) );
           }
          
           while (  !myKeyMappings.empty(   ) )
           {
           inputService->removeInputMapping(  *myKeyMappings.begin(   ) );
           }
          
           InputService::InputDeviceIterator i2;
          
           for (  i2 = inputService->myInputDevices.begin(   ); i2 != inputService->myInputDevices.end(   ); i2++ )
           {
           if (  *i2 == this )
           {
           inputService->myInputDevices.erase(  i2 );
           break;
           }
           }
          }
          
      65  InputDevice::DeviceType InputDevice::getType(   )
          {
           return myType;
          }
          
      70  int InputDevice::getAxisCount(   )
          {
           return myPhysicalPosition.size(   );
          }
          
      75  int InputDevice::getAxisPosition(  int axis )
          {
           return myPhysicalPosition[axis];
          }
          
      80  float InputDevice::getAxisScaledPosition(  int axis )
          {
           return (  (  float )(  myPhysicalPosition[axis]-myPhysicalMin[axis] ) /
           (  (  float )(  myPhysicalMax[axis]-myPhysicalMin[axis] ) ) );
          }
          
      86  void InputDevice::initAxis(   )
          {
           //default implementation is a device with no axis
          }
          
          
      92  InputDevice::KeyState InputDevice::getKeyState(  SDLKey key )
          {
           //default implementation is a device with no keys
           return UNSUPPORTED_KEY;
          }
          
      98  void InputDevice::keyPressed(  DimeKey & key )
          {
           SDLMod modifiers = SDL_GetModState(   );
          
           for (  MappingIterator i = myKeyMappings.begin(   ); i != myKeyMappings.end(   ); i++ )
           {
           (  *i )->keyPressed(  key,   modifiers );
           }
          }
          
     108  void InputDevice::keyReleased(  DimeKey & key )
          {
           for (  MappingIterator i = myKeyMappings.begin(   ); i != myKeyMappings.end(   ); i++ )
           {
           (  *i )->keyReleased(  key );
           }
          }
          
     116  void InputDevice::motion(   )
          {
           for (  MappingIterator i = myMotionMappings.begin(   ); i != myMotionMappings.end(   ); i++ )
           {
           (  *i )->motion(   );
           }
          }
          
     124  KeyboardDevice::KeyboardDevice(   ):
           InputDevice(  KEYBOARD,   0,   0 )
          {
           Uint8 * keys = SDL_GetKeyState(  &myKeyCount );
          
           myKeys = new KeyState[myKeyCount];
          
           for (  int i = 0; i < myKeyCount; i++ )
           {
           //%TODO Tim,  2: Test if the key is actually supported. Supported by SDL?
          
           if (  keys[i] == 1 )
           {
           myKeys[i] = PRESSED;
           }
           else
           {
           myKeys[i] = RELEASED;
           }
           }
          }
          
     146  KeyboardDevice::~KeyboardDevice(   )
          {
           delete[] myKeys;
          }
          
     151  InputDevice::KeyState KeyboardDevice::getKeyState(  SDLKey key )
          {
           if (  static_cast<int>(  key ) < myKeyCount &&
           static_cast<int>(  key ) > 0 )
           {
           return myKeys[static_cast<int>(  key )];
           }
          
           return UNSUPPORTED_KEY;
          }
          
     162  bool KeyboardDevice::handleEvent(  SDL_Event & event )
          {
           DimeKey key(  event.key.keysym.sym,   event.key.keysym.unicode );
           switch(  event.type )
           {
           case SDL_KEYDOWN:
           myKeys[static_cast<int>(  event.key.keysym.sym )] = PRESSED;
           keyPressed(  key );
           return true;
          
           case SDL_KEYUP:
           myKeys[static_cast<int>(  event.key.keysym.sym )] = RELEASED;
           keyReleased(  key );
           return true;
          
           default:
           return false;
           }
          }
          
     182  MouseDevice::MouseDevice(   ):
           InputDevice(  MOUSE,   0,   0 )
          {
           //%TODO Tim,  2: Really test if the mouse has three buttons
           myHasThreeButtons = true;
          
           initAxis(   );
          }
          
     191  MouseDevice::~MouseDevice(   )
          {
          }
          
     195  InputDevice::KeyState MouseDevice::getKeyState(  SDLKey key )
          {
           Uint8 state = SDL_GetMouseState(  NULL,   NULL );
          
           switch(  key )
           {
           case SDLK_LEFT_MB:
           return (  SDL_BUTTON_LMASK & state ) ? PRESSED : RELEASED;
           break;
          
           case SDLK_RIGHT_MB:
           return (  SDL_BUTTON_RMASK & state ) ? PRESSED : RELEASED;
           break;
          
           case SDLK_MIDDLE_MB:
           return myHasThreeButtons ? (   (  SDL_BUTTON_MMASK & state ) ? PRESSED : RELEASED ) : UNSUPPORTED_KEY;
           break;
          
           default:
           return UNSUPPORTED_KEY;
           }
          }
          
     218  void MouseDevice::initAxis(   )
          {
           //HINT: If at some day mouse wheel supports get's available,   consider carefully if
           //to put it here (  think of motion events )! I would prefer to make an extra device type.
          
           //mouse has two axis
           //the minimum of both is 0
           //the maximum of both is the screen resolution
          
           myPhysicalMin.resize(  2,   0 );
           myPhysicalMax.resize(  2,   0 );
           myPhysicalPosition.resize(  2,   0 );
          
           myPhysicalMin[0] = 0;
           myPhysicalMax[1] = 0;
          
           SDL_Surface * surf = SDL_GetVideoSurface(   );
          
           if (  surf )
           {
           myPhysicalMax[0] = surf->w;
           myPhysicalMax[1] = surf->h;
           }
           else
           {
           myPhysicalMax[0] = 800;
           myPhysicalMax[1] = 600;
           }
          
           int x,   y;
          
           SDL_GetMouseState(  &x,   &y );
          
           myPhysicalPosition[0] = x;
           myPhysicalPosition[1] = y;
          }
          
     255  bool MouseDevice::handleEvent(  SDL_Event & event )
          {
           DimeKey key(  static_cast<SDLKey>(  event.button.button ),  static_cast<Uint16>(  event.button.button ) );
          
           switch (  event.type )
           {
           case SDL_MOUSEMOTION:
           //%TODO Tim,  2: Test if this works properly also,   if the cursor is hidden
           //esp. concerning if the mouse movements are cut at the screen borders
          
           myPhysicalPosition[0] = event.motion.x;
           myPhysicalPosition[1] = event.motion.y;
          
           motion(   );
          
           return true;
          
           case SDL_MOUSEBUTTONDOWN:
           keyPressed(  key );
           return true;
          
          
           case SDL_MOUSEBUTTONUP:
           keyReleased(  key );
           return true;
          
           case SDL_VIDEORESIZE:
           initAxis(   );
           return false;
          
           default:
           return false;
           }
          }
          
     290  RepetitionDevice::RepetitionDevice(  long unsigned int initialDelay,   long unsigned int delay,  
     291   bool alwaysRunning ):
           InputDevice(  REPETITOR,   0,   0 )
          {
           myInitialDelay = initialDelay;
           myDelay = delay;
           myTimerID = 0;
          
           if (  alwaysRunning )
           {
           myTimerID = SDL_AddTimer(  delay,   TimerCallback,   static_cast<void*>(  this ) );
           }
          
          }
          
     305  RepetitionDevice::~RepetitionDevice(   )
          {
           if (  myTimerID )
           {
           SDL_RemoveTimer(  myTimerID );
           }
          }
          
     313  Uint32 RepetitionDevice::TimerCallback(  Uint32 interval,   void *param )
          {
           SDL_Event event;
          
           event.type = TIMEREVENT;
           event.user.data1 = param;
          
           SDL_PushEvent(  &event );
          
           return (  (  RepetitionDevice* )param )->myDelay;
          }
          
     325  void RepetitionDevice::switchOn(  InputDevice * motionDevice,   InputDevice * keyDevice,  
     326   const DimeKey & Key,   InputMapping::InputSignalType type )
          {
          
           if (  type == InputMapping::KEY_PRESSED )
           {
           if (  myTimerID )
           {
           SDL_RemoveTimer(  myTimerID );
           myTimerID = 0;
           }
          
           myTimerID = SDL_AddTimer(  myInitialDelay,   TimerCallback,   static_cast<void*>(  this ) );
           }
          }
          
     341  long unsigned int RepetitionDevice::getDelay(   )
          {
           return myDelay;
          }
          
     346  bool RepetitionDevice::handleEvent(  SDL_Event & event )
          {
           switch(  event.type )
           {
           case TIMEREVENT:
           //HINT: Repetition events should be handled by the respective owner only,   to ensure
           //that the RepetitionDevice wasn't deleted in the meantime.
          
           if (  event.user.data1 == (  void* )this )
           {
           motion(   );
           return true;
           }
          
           return false;
          
           default:
           return false;
           }
          }
          
          } // namespace dime
          

./services/input/InputDevice.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef INPUT_DEVICE_H
          #define INPUT_DEVICE_H
          
          // Include other headers of the current program here
          #include "DimeKey.h"
          
          // Include library headers here
          #include <SDL/SDL_keysym.h>
          #include <SDL/SDL_events.h>
          #include <SDL/SDL_mouse.h>
          #include <sigc++/object.h>
          #if SIGC_MAJOR_VERSION == 1 && SIGC_MINOR_VERSION == 0
          #include <sigc++/signal_system.h>
          #else
          #include <sigc++/signal.h>
          #endif
          #include <SDL/SDL_timer.h>
          
          
          // Include system headers here
          #include <string>
          #include <vector>
          
          //General TODOs
          //%TODO Tim,  2: Add JoystickDevice,   JoystickHatDevice and JoystickBallDevice
          //%TODO Tim,  2: Add debug assertions
          
          namespace dime {
          
          /**
           * An input device used to hold the positions and to provide info on the available devices.
           *
           * At the moment SDL only supports multiple joysticks (  and only one mouse and keyboard ).
           *
           * @author Tim Enderling
           */
          
          //SDL user event
          const Uint8 TIMEREVENT = SDL_USEREVENT;
          
          //extensions of SDL key enum type
          //left mouse button
          const SDLKey SDLK_LEFT_MB = static_cast<SDLKey>(  SDL_BUTTON_LEFT );
           //middle mouse button
          const SDLKey SDLK_MIDDLE_MB = static_cast<SDLKey>(  SDL_BUTTON_MIDDLE );
          //right mouse button
          const SDLKey SDLK_RIGHT_MB = static_cast<SDLKey>(  SDL_BUTTON_RIGHT );
          
          //joystick buttons
          const SDLKey SDLK_JB0 = static_cast<SDLKey>(  0 );
          const SDLKey SDLK_JB1 = static_cast<SDLKey>(  1 );
          const SDLKey SDLK_JB2 = static_cast<SDLKey>(  2 );
          const SDLKey SDLK_JB3 = static_cast<SDLKey>(  3 );
          const SDLKey SDLK_JB4 = static_cast<SDLKey>(  4 );
          const SDLKey SDLK_JB5 = static_cast<SDLKey>(  5 );
          const SDLKey SDLK_JB6 = static_cast<SDLKey>(  6 );
          const SDLKey SDLK_JB7 = static_cast<SDLKey>(  7 );
          const SDLKey SDLK_JB8 = static_cast<SDLKey>(  8 );
          const SDLKey SDLK_JB9 = static_cast<SDLKey>(  9 );
          
          
          
          /**
           * General base class for any kind of input device.
           *
           * An general an input device is a collection of an arbitrary number of axis (  physical values
           * or scaled values from 0 to 1 ) and keys (  in pressed or released state ).
           * Anything more special is (  e.g. repetition ) handled in the derived classes.
           *
           * Because sometimes there is more than one physical input device of the sime type
           * (  multiple joysticks ) and even multiple subdevices (  multiple joystick hats ) an
           * index and a subindex can be specified when creating an InputDevice of such kind.
           *
           * HINT: The InputDevices do not hold the InputMappings (  means are not responsible
           * for freeing the memory ),   because there can be two different of them
           * (  a motional and a key state ) having a pointer to the same InputMapping. Instead
           * InputMappings are generally added/removed/deallocated by the InputService.
           */
          
      98  class InputMapping;
          
     100  class InputDevice
          {
     102   friend class InputService;
           //======================================================================
           // Inner classes and typedefs
           //======================================================================
           public:
          
           typedef std::vector<InputMapping*> MappingVector;
           typedef MappingVector::iterator MappingIterator;
          
           //======================================================================
           // Public Constants
           //======================================================================
           public:
          
           /**
           * Input Signal Types
           */
          
           enum DeviceType
           {
           MOUSE,  
           KEYBOARD,  
           JOYSTICK_AXIS,  
           JOYSTICK_BALL,  
           JOYSTICK_HAT,  
           REPETITOR
           };
          
           enum KeyState
           {
           PRESSED,  
           RELEASED,  
           UNSUPPORTED_KEY
           };
          
           //======================================================================
           // Private Variables
           //======================================================================
           private:
          
           DeviceType myType;
           int myIndex;
           int mySubIndex;
          
          
           //======================================================================
           // Protected Variables
           //======================================================================
          
           protected:
          
     153   std::vector<int> myPhysicalPosition;
     154   std::vector<int> myPhysicalMin;
     155   std::vector<int> myPhysicalMax;
          
     157   MappingVector myKeyMappings;
     158   MappingVector myMotionMappings;
          
          
           //======================================================================
           // Public methods
           //======================================================================
           public:
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           /**
           * Creates a new InputDevice and registers it at the InputService.
           *
           * @param type Type of input device to represent.
           * @param index Handling number used in SDL if multiple devices of the same type
           * are available.
           * @param subIndex Subnumber when it is needed (  multiple hats at the same joystick... ).
           */
          
     178   InputDevice(  DeviceType type,   int index,   int subIndex );
          
           /**
           * Deletes a InputDevice instance and unregisters it from the InputService.
           */
     183   virtual ~InputDevice(   );
          
           //----------------------------------------------------------------------
           // Public properties
          
     188   DeviceType getType(   );
     189   int getAxisCount(   );
     190   int getAxis(  int axis );
     191   int getAxisPosition(  int axis );
     192   float getAxisScaledPosition(  int axis );
          
     194   virtual KeyState getKeyState(  SDLKey key );
     195   virtual KeyState getKeyState(  DimeKey key )
           {
           return getKeyState(  key.getKey(   ) );
           }
          
          
           //======================================================================
           // Protected methods
           //======================================================================
           protected:
          
           /**
           * Retrieves the axis(  es )'s minima,   maxima and current positions and saves
           * them for internal handling of the input device.
           *
           * ATTENTION: Since this is a virtual function,   it cannot be called by the ctor
           * of InputDevice (  as it should ). Thus every derived class has to call initAxis
           * in it's ctor itself,   if needed.
           */
     214   virtual void initAxis(   );
          
           /**
           * Called whenever an SDL event ocurres. Should return TRUE only if it's _absolutely sure_,  
           * that no other event handler needs this event. Thus returning TRUE means that the
           * event has been 'eaten up' by handleEvent.
           */
     221   virtual bool handleEvent(  SDL_Event & event )
           {
           //default implementation handles no events
           return false;
           }
          
           /**
           * Helping functions called by all derived input devices to signal changes.
           */
          
     231   void keyPressed(  DimeKey & key );
     232   void keyReleased(  DimeKey & key );
     233   void motion(   );
          
          }; // InputMapping
          
          /**
           * Special derivation of input device for a keyboard.
           */
          
     241  class KeyboardDevice: public InputDevice
          {
           //======================================================================
           // Private Variables
           //======================================================================
           private:
          
           int myKeyCount; //count of keys
           KeyState * myKeys; //array of key states
          
           //======================================================================
           // Public methods
           //======================================================================
           public:
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           /**
           * Creates a new Keyboard device. Since SDL supports only one keyboard,  
           * no index is supported.
           */
          
     264   KeyboardDevice(   );
          
           /**
           * Deletes a KeyboardDevice instance.
           */
     269   virtual ~KeyboardDevice(   );
          
           //----------------------------------------------------------------------
           // Public properties
          
     274   virtual KeyState getKeyState(  SDLKey key );
          
           //======================================================================
           // Protected methods
           //======================================================================
           protected:
          
     281   bool KeyboardDevice::handleEvent(  SDL_Event & event );
          };
          
          /**
           * Special derivation of input device for a mouse.
           */
          
     288  class MouseDevice: public InputDevice
          {
           //======================================================================
           // Private Variables
           //======================================================================
           private:
     294   bool myHasThreeButtons; //determines wether the mouse has three buttons or not
          
           //======================================================================
           // Public methods
           //======================================================================
           public:
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           /**
           * Creates a new mouse device. Since SDL supports only one mouse,  
           * no index is supported.
           */
          
     309   MouseDevice(   );
          
           /**
           * Deletes a MouseDevice instance.
           */
     314   virtual ~MouseDevice(   );
          
           //----------------------------------------------------------------------
           // Public properties
          
     319   virtual KeyState getKeyState(  SDLKey key );
          
          
           //======================================================================
           // Protected methods
           //======================================================================
           protected:
          
     327   virtual bool handleEvent(  SDL_Event & event );
     328   virtual void initAxis(   );
          };
          
          } // namespace dime
          
          #endif
          
          
          

./services/input/InputMapping.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef INPUT_MAPPING_H
          #define INPUT_MAPPING_H
          
          // Include other headers of the current program here
          #include "InputDevice.h"
          
          // Include library headers here
          #if SIGC_MAJOR_VERSION == 1 && SIGC_MINOR_VERSION == 0
          #include <sigc++/handle_system.h>
          #include <sigc++/signal_system.h>
          #else
          #include <sigc++/signal.h>
          #endif
          
          
          // Include system headers here
          #include <string>
          #include <set>
          #include <assert.h>
          
          //General TODOs:
          //%TASK Tim,  2: Add debug assertions
          //%TASK Tim,  2: Is there a way for timing out handling of input events? (  Just to avoid the 'user presses
          // button serveral times,   because he sees no reaction and afterwards he has to wait,   because
          // all events are really processed...' )
          //%TASK Tim,  2: Should InputMappings be autoregistring? (  ATM: No. )
          //%TASK Tim,  2: Is a state only true,   if the modifiers where pressed _before_ the base key? (  ATM: Yes. )
          //%TASK Tim,  2: Should KEY_RELEASED also occur,  
          // if the modifiers are released _before_ the base key? (  ATM: No. )
          //%TASK Tim,  2: Should KEY_PRESSED events also occur,   if there are more modifiers pressed than
          // specified in the mapping? (  ATM: No. )
          
          namespace dime {
          
          /**
           * an input mapping,   used to filter the users input and give signals to the listeners.
           *
           * In general input mapping is based on the combination of two principles:
           * (  Motion ) events and (  key/button ) states.
           *
           * All these motions are seen as changes of the some axis vectors,   where it is possible to
           * change more than one axis by one event.
           *
           * See InputDevice for more details on available motion events and key states.
           *
           * For convenience also a range of keys (  of the same input device ) can be used instead
           * of one key. The range includes it's border item.
           *
           * Further there is a way to combine some states by 'AND'. This you have a base state
           * (  arbitrary key/button ) and some modifiers (  not only a modifier! ). Available modifiers are
           * capslock,   left/right control/shift/alt/meta and any of both control/shift/alt/meta keys.
           * *
           * HINT: If you want the user to press multiple modifiers,   you have to combine them by bitwise
           * or |. An exception of this rule is connecting the left and the right version of the same key
           * In this case the user can press any of both keys,   not only both at the same time.
           *
           * An input signal is fired when
           * - A key and it's modifiers were pressed synchronously. (  KEY_PRESSED )
           * - The motion event occurs,   while the key is pressed is true.
           * (  one of the key's pressed is passed to the signal handler ) (  EVENT_OCCURED )
           * - The key or one of it's modifiers was released. (  KEY_RELEASED )
           *
           * For a key range you get seperate a KEY_PRESSED/KEY_RELEASED signal for each key.
           *
           * The types of input signals can be or'd together to get only those types wanted,   like
           * you would expect it.
           *
           * Same examples of adding InputMappings to InputDevice:
           *
           * <code>
           * //assuming your in dime namespace
           * InputService * inputService;
           * //and you have a pointer to the inputService
           *
           * //get the default input devices
           * InputDevice * keyboard = inputService->getDevice(  InputDevice::KEYBOARD );
           * InputDevice * mouse = inputService->getDevice(  InputDevice::MOUSE );
           * InputDevice * repetitor = inputService->getDevice(  InputDevice::REPETITOR );
           *
           * //Single action on return
           * inputService.addMapping(  new
           * InputMapping(  keyboard,   SDLK_RETURN,   false,   slot(  dialog,  &dialog::onDefault ) ) )
           *
           * //Observing a key being pressed and released
           * inputService.addMapping(  new
           * InputMapping(  keyboard,   SDLK_CAPS,   true,  
           *
           * //Observing mouse movement only
           * inputService.addMapping(  new
           * InputMapping(  mouse,   slot(  dialog,   &dialog::updateMousePosition ) );
           *
           * [TODO]
           *
           * </code>
           *
           * @author Tim Enderling
           */
          
     117  class InputMapping
          {
     119   friend class InputDevice;
          
           //======================================================================
           // Public Constants
           //======================================================================
           public:
          
           /**
           * Input Signal Types
           */
          
           enum InputSignalType
           {
           KEY_PRESSED = 0x1,  
           KEY_RELEASED = 0x2,  
           EVENT_OCCURED = 0x4
           };
          
           //======================================================================
           // Inner classes and typedefs
           //======================================================================
           public:
          
           /**
           * A signal takes the following params:
           * - InputDevice * motionDevice
           * - InputDevice * keyDevice
           * - const SDLKey & key (  pressed )
           * - InputSignalType type
           *
           * HINT: With the help of sigc++'s 'bind' you can pass further constant
           * params to your handling function (  usually called 'cockie' ).
           */
          
           typedef SigC::Signal4<void,   InputDevice *,   InputDevice *,   const DimeKey & ,  
           InputSignalType,   SigC::Marshal<void> > InputSignal;
          
           typedef SigC::Slot4<void,   InputDevice *,   InputDevice *,   const DimeKey &,   InputSignalType> InputSlot;
          
          
           //======================================================================
           // Private Variables
           //======================================================================
           private:
          
     164   InputDevice * myMotionDevice;
     165   InputDevice * myKeyDevice;
     166   SDLKey myKeyRangeStart;
     167   SDLKey myKeyRangeEnd;
     168   SDLMod myModifiers;
     169   InputSignal mySignal;
           InputSignalType myTypes;
          
     172   std::set<SDLKey>myKeysPressed;
          
          
          
           //======================================================================
           // Public methods
           //======================================================================
           public:
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           /**
           * Creates a new InputMapping. Exists in various forms to fit everyone's needs.
           *
           * @param motionDevice Input device to observe motion of.
           * @param keyDevice Input device to observe key state of.
           * @param baseKey Key to listen to.
           * @param keyRangeStart Start of the key range.
           * @param keyRangeEnd End of the key range.
           * @param modifiers Key modifiers that should be pressed synchronous to baseKey/ a key
           * inner key range.
           * @param slot A callback or some other signal slot.
           * @param types Types of input signals to pass through the slot. Can be any OR-combination
           * of InputSignalType enum's items.
           * @param fireOnRelease Decides wether to fire a signal on key releasing,   i.e. wether
           * include KEY_RELEASED into types or not.
           */
          
           /**
           * Version used to observe a motion only.
           */
          
     205   InputMapping(  InputDevice * motionDevice,   const InputSlot &slot )
           {
           assert(  this );
           myMotionDevice = motionDevice;
           myKeyDevice = NULL;
           myTypes = EVENT_OCCURED;
          
           myKeysPressed.insert(  SDLK_UNKNOWN ); //adds a pseudo key,   that is always 'pressed'
          
           mySignal.connect(  slot );
           }
          
           /**
           * Version used to observe a key only.
           */
     220   InputMapping(  InputDevice * keyDevice,   SDLKey baseKey,  
     221   bool fireOnRelease,   const InputSlot &slot )
           {
           assert(  this );
           myMotionDevice = NULL;
           myKeyDevice = keyDevice;
           myKeyRangeStart = baseKey;
           myKeyRangeEnd = baseKey;
           myModifiers = KMOD_NONE;
           myTypes = static_cast<InputSignalType>
           (  KEY_PRESSED | (  fireOnRelease ? KEY_RELEASED : 0 ) );
           mySignal.connect(  slot );
           }
          
           /**
           * Version used to observe a key and some modifiers.
           */
     237   InputMapping(  InputDevice * keyDevice,   SDLKey baseKey,   SDLMod modifiers,  
     238   bool fireOnRelease,   const InputSlot &slot )
           {
           assert(  this );
           myMotionDevice = NULL;
           myKeyDevice = keyDevice;
           myKeyRangeStart = baseKey;
           myKeyRangeEnd = baseKey;
           myModifiers = modifiers;
           myTypes = static_cast<InputSignalType>(  
           KEY_PRESSED | (  fireOnRelease ? KEY_RELEASED : 0 ) );
          
           mySignal.connect(  slot );
           }
          
          
           /**
           * Version used to observe a key range.
           */
     256   InputMapping(  InputDevice * keyDevice,   SDLKey keyRangeStart,   SDLKey keyRangeEnd,  
     257   bool fireOnRelease,   const InputSlot &slot )
           {
           assert(  this );
           myMotionDevice = NULL;
           myKeyDevice = keyDevice;
           myKeyRangeStart = keyRangeStart;
           myKeyRangeEnd = keyRangeEnd;
           myModifiers = KMOD_NONE;
           myTypes = static_cast<InputSignalType>
           (  KEY_PRESSED | (  fireOnRelease ? KEY_RELEASED : 0 ) );
          
           mySignal.connect(  slot );
           }
          
           /**
           * Version used to observe a key range and some modifiers.
           */
     274   InputMapping(  InputDevice * keyDevice,   SDLKey keyRangeStart,   SDLKey keyRangeEnd,  
     275   SDLMod modifiers,   bool fireOnRelease,   const InputSlot &slot )
           {
           assert(  this );
           myMotionDevice = NULL;
           myKeyDevice = keyDevice;
           myKeyRangeStart = keyRangeStart;
           myKeyRangeEnd = keyRangeEnd;
           myModifiers = modifiers;
           myTypes = static_cast<InputSignalType>
           (  KEY_PRESSED | (  fireOnRelease ? KEY_RELEASED : 0 ) );
          
           mySignal.connect(  slot );
           }
          
           /**
           * Version used to observe a motion event and a key with modifiers.
           */
          
     293   InputMapping(  InputDevice * motionDevice,  
     294   InputDevice * keyDevice,   SDLKey baseKey,  
     295   SDLMod modifiers,   InputSignalType types,   const InputSlot &slot )
           {
           assert(  this );
           myMotionDevice = motionDevice;
           myKeyDevice = keyDevice;
           myKeyRangeStart = baseKey;
           myKeyRangeEnd = baseKey;
           myModifiers = modifiers;
           myTypes = types;
          
           mySignal.connect(  slot );
           }
          
           /**
           * Version used to observe a motion event and a key range with modifiers.
           */
          
     312   InputMapping(  InputDevice * motionDevice,  
     313   InputDevice * keyDevice,   SDLKey keyRangeStart,   SDLKey keyRangeEnd,  
     314   SDLMod modifiers,   InputSignalType types,   const InputSlot &slot )
           {
           assert(  this );
           myMotionDevice = motionDevice;
           myKeyDevice = keyDevice;
           myKeyRangeStart = keyRangeStart;
           myKeyRangeEnd = keyRangeEnd;
           myModifiers = modifiers;
           myTypes = types;
          
           mySignal.connect(  slot );
           }
          
           /** Deletes a InputMapping instance. */
     328   virtual ~InputMapping(   )
           {
           // Free any allocated memory and resources
           }
          
           //----------------------------------------------------------------------
           // Public properties
          
     336   InputDevice * getKeyDevice(   )
           {
           return myKeyDevice;
           }
          
     341   InputDevice * getMotionDevice(   )
           {
           return myMotionDevice;
           }
          
     346   InputSignal * getSignal(   )
           {
           return &mySignal;
           }
          
           //======================================================================
           // Protected methods
           //======================================================================
           protected:
          
           /**
           * Is called by the InputDevice mapped as keyDevice,   whenever a key
           * was pressed.
           *
           * For performance reasons this should be inline in any case.
           */
          
     363   inline void keyPressed(  DimeKey & key,   SDLMod modifier )
           {
           SDLKey sdlkey = key.getKey(   );
           if (  sdlkey >= myKeyRangeStart && sdlkey <= myKeyRangeEnd )
           {
           if (  (  (  KMOD_CTRL & myModifiers ) == KMOD_CTRL ) && (  modifier & KMOD_CTRL ) )
           {
           (  (  int& )modifier ) |= KMOD_CTRL;
           }
          
           if (  (  (  KMOD_SHIFT & myModifiers ) == KMOD_SHIFT ) && (  modifier & KMOD_SHIFT ) )
           {
           (  (  int& )modifier ) |= KMOD_SHIFT;
           }
          
           if (  (  (  KMOD_ALT & myModifiers ) == KMOD_ALT ) && (  modifier & KMOD_ALT ) )
           {
           (  (  int& )modifier ) |= KMOD_ALT;
           }
          
           if (  (  (  KMOD_META & myModifiers ) == KMOD_META ) && (  modifier & KMOD_META ) )
           {
           (  (  int& )modifier ) |= KMOD_META;
           }
          
           if (  (  modifier & myModifiers ) == myModifiers )
           {
           myKeysPressed.insert(  sdlkey );
          
           if (  myTypes & KEY_PRESSED )
           {
           mySignal(  myMotionDevice,   myKeyDevice,   key,   KEY_PRESSED );
           }
           }
           }
           }
          
           /**
           * Is called by the InputDevice mapped as keyDevice,   whenever a key
           * was released.
           *
           * For performance reasons this should be inline in any case.
           */
          
     407   inline void keyReleased(  DimeKey & key )
           {
           SDLKey sdlkey = key.getKey(   );
          
           if (  sdlkey >= myKeyRangeStart && sdlkey <= myKeyRangeEnd )
           {
           //remove only keys that was pressed synchronous with their modifiers.
           if (  myKeysPressed.erase(  sdlkey ) )
           {
           if (  myTypes & KEY_RELEASED )
           {
           mySignal(  myMotionDevice,   myKeyDevice,   key,   KEY_RELEASED );
           }
           }
           }
           }
          
           /**
           * Is called by the InputDevice mapped as motionDevice,   whenever at least one axis
           * position changes.
           *
           * For performance reasons this should be inline in any case.
           */
          
     431   inline void motion(   )
           {
           if (  myTypes & EVENT_OCCURED )
           {
           for (  std::set<SDLKey>::iterator i = myKeysPressed.begin(   ); i != myKeysPressed.end(   ); i++ )
           {
           DimeKey key(  *i,  static_cast<Uint16>(  *i ) );
           mySignal(  myMotionDevice,   myKeyDevice,   key,   EVENT_OCCURED );
           }
           }
           }
          }; // InputMapping
          
          } // namespace dime
          
          #endif
          
          

./services/input/InputService.h

       1  /*
           Copyright (  C ) 2002 Hans Häggström,   Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef INPUT_SERVICE_H
          #define INPUT_SERVICE_H
          
          // Include other headers of the current program here
          #include <framework/Service.h>
          #include "InputMapping.h"
          #include "RepetitionDevice.h"
          
          // Include library headers here
          #include <SDL/SDL_events.h>
          
          // Include system headers here
          #include <string>
          #include <vector>
          #include <list>
          
          
          namespace dime {
          
          
          //General TODOs:
          //%TASK Tim,  2: Add debug assertions
          //%TASK Tim,  1: No eating up of events till now. Add it if we need it.
          
          /**
           * A service for getting input from the user,   and sending it to
           * different listeners.
           *
           * Thus it is the owner of all input mappings. If an input mapping
           * is not removed from the list before the dtor of InputService is called,   it is automatically
           * deleteted.
           *
           * It also owns a list of input devices,   that handles their input events.
           *
           * See InputDevice and InputMapping for more details.
           *
           * @author Hans Häggström/Tim Enderling
           */
          
      58  class InputService: public Service
          {
      60   friend class InputDevice;
          
           //======================================================================
           // Inner classes and typedefs
           //======================================================================
           public:
          
           /**
           * The type of iterators used to iterate through the input mappings table.
           */
           typedef std::vector<InputMapping *>::iterator InputMappingIterator;
           typedef std::vector<InputMapping *>::const_iterator ConstInputMappingIterator;
          
           /**
           * They type of iterators used to iterate through the input devices table.
           */
          
           typedef std::vector<InputDevice*>::iterator InputDeviceIterator;
           typedef std::vector<InputDevice*>::const_iterator ConstInputDeviceIterator;
          
           //======================================================================
           // Public Constants
           //======================================================================
           public:
          
          
           //======================================================================
           // Private Variables
           //======================================================================
           private:
          
           /**
           * Stores a list of input mappings that are searched in order to find
           * one that handles a certain input event.
           */
      95   std::vector<InputMapping *> myInputMappings;
          
           protected:
          
      99   std::vector<InputDevice *> myInputDevices;
          
           //======================================================================
           // Public methods
           //======================================================================
           public:
          
           //----------------------------------------------------------------------
           // Singleton
          
           /**
           * Returns the LoggingService instance.
           */
     112   static InputService *getInstance(   )
           {
           static InputService singleinstance;
           return &singleinstance;
           }
          
           //----------------------------------------------------------------------
           // Destructor
          
          
           /** Deletes a InputService instance. */
     123   virtual ~InputService(   )
           {
           //delete all mappings
           for (  InputMappingIterator i = myInputMappings.begin(   ); i != myInputMappings.end(   ); i++ )
           {
           delete *i;
           }
           }
          
          
           //----------------------------------------------------------------------
           // Input Mapping methods
          
           /**
           * Returns a const iterator that can be used to iterate through the input mappings
           */
     139   virtual ConstInputMappingIterator getInputMappings(   ) const
           {
           return myInputMappings.begin(   );
           }
          
           /**
           * Adds a new input mapping.
           *
           * @param inputMapping pointer to the input mapping to add.
           */
     149   virtual void addInputMapping(   InputMapping * inputMapping )
           {
           myInputMappings.push_back(  inputMapping );
          
           InputDevice * device = inputMapping->getMotionDevice(   );
          
           if (  device != NULL )
           {
           device->myMotionMappings.push_back(  inputMapping );
           }
          
           device = inputMapping->getKeyDevice(   );
          
           if (  device != NULL )
           {
           device->myKeyMappings.push_back(  inputMapping );
           }
           }
          
           /**
           * Removes the specified input mapping. (  but doesn't delete it ).
           */
     171   virtual void removeInputMapping(   InputMapping * inputMapping  )
           {
           for (  InputMappingIterator i = myInputMappings.begin(   ); i != myInputMappings.end(   ); i++ )
           {
           if (  *i == inputMapping )
           {
           myInputMappings.erase(  i );
          
           InputDevice * device = inputMapping->getMotionDevice(   );
          
           if (  device != NULL )
           {
           for (  i = device->myMotionMappings.begin(   );
           i != device->myMotionMappings.end(   ); i++ )
           {
           if (  *i == inputMapping )
           {
           device->myMotionMappings.erase(  i );
           break;
           }
           }
           }
          
           device = inputMapping->getKeyDevice(   );
          
           if (  device != NULL )
           {
           for (  i = device->myKeyMappings.begin(   );
           i != device->myKeyMappings.end(   ); i++ )
           {
           if (  *i == inputMapping )
           {
           device->myKeyMappings.erase(  i );
           break;
           }
           }
           }
          
           return;
           }
           }
           }
          
           /**
           * Returns an iterator that can be used to iterate through the input devices
           */
     217   virtual InputDeviceIterator getDevices(   )
           {
           return myInputDevices.begin(   );
           }
          
           /**
           * Searches for the first input device of specified type staring a specified iterator.
           *
           * @param startSearch Iterator at which the search should start. startSearch should be
           * set to getDevices(   ) to start at the beginning.
           */
          
     229   InputDevice * getInputDevice(  InputDevice::DeviceType type,   InputDeviceIterator * startSearch
           = NULL )
           {
           InputDeviceIterator i = myInputDevices.begin(   );
           InputDeviceIterator * pI = startSearch ? startSearch : &i;
          
           for (  ; *pI != myInputDevices.end(   ); (  *pI )++ )
           {
           if (  (  **pI )->getType(   ) == type )
           {
           return *(  (  *pI )++ );
           }
           }
          
           if (  type == InputDevice::MOUSE )
           {
           return new MouseDevice(   );
           }
           return NULL;
           }
          
           //----------------------------------------------------------------------
           // Methods inherited from Service
          
           /**
           * This method is used to start the service.
           * It takes care of aquiring needed resources,   initializing
           * data structures,   and so on. <p>
           *
           * If the initialization succeeds,   it should also call setRunning(   true  )
           * to indicate that the service is running. <p>
           *
           * If initialization fails,   it should set appropriate status code and
           * status text. It could also write an entry into a log through the logging
           * service. <p>
           *
           * @returns success or error code
           */
     267   virtual Service::Status start(   )
           {
           setRunning(   true  );
           setStatus(  Service::OK );
          
           // Start listening to SDL events.
           // TODO
          
           return Service::OK;
           }
          
          
           /**
           * This method stops the service,   and frees any used resources.
           *
           * @ param code code which represents the cause of the service halt
           * TODO(  zzorn ): What do we need it for?
           */
     285   virtual void stop(   int code  )
           {
           // Stop listening to SDL events.
           // TODO
          
           setRunning(   false  );
           }
          
          
           //----------------------------------------------------------------------
           // Event handling methods
          
           /**
           * This method handles the next event from the SDL event queue,  
           * sending it off to a listener.
           *
           * Should return TRUE only if it's _absolutely sure_,   that no other event handler needs
           * this event. Thus returning TRUE means that the event has been 'eaten up' by handleEvent.
           */
          
     305   virtual bool handleEvent(  SDL_Event & event )
           {
           for (  InputDeviceIterator i = myInputDevices.begin(   ); i != myInputDevices.end(   ); i++ )
           {
           if (  (  *i )->handleEvent(  event ) ) return true;
           }
          
           return false;
           }
          
           //======================================================================
           // Private methods
           //======================================================================
           private:
          
           //----------------------------------------------------------------------
           // Constructor
          
           /** Creates a new InputService using default values. */
     324   InputService(   )
           {
           setName(   "InputService"  );
           setDescription(   "Maps user input to different actions."  );
           }
          
          }; // InputService
          
          } // namespace dime
          
          #endif
          
          

./services/input/RepetitionDevice.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef REPETITION_DEVICE_H
          #define REPETITION_DEVICE_H
          
          // Include other headers of the current program here
          #include "InputMapping.h"
          
          // Include library headers here
          #include <SDL/SDL_keysym.h>
          #include <SDL/SDL_events.h>
          #include <SDL/SDL_mouse.h>
          #include <SDL/SDL_timer.h>
          #if SIGC_MAJOR_VERSION == 1 && SIGC_MINOR_VERSION == 0
          #include <sigc++/handle_system.h>
          #include <sigc++/signal_system.h>
          #else
          #include <sigc++/signal.h>
          #include <sigc++/object.h>
          #endif
          
          
          // Include system headers here
          #include <string>
          #include <vector>
          
          namespace dime {
          
          /**
           * Special derivation of input device for automatic repetition. RepetitionDevice
           * Objects send motion events in constant delays. This can be useful for
           * key repetition.
           *
           * HINT: Because timer functions are called from other threads,   the repetition
           * device uses the SDL message loop passing some SDL_USEREVENT to fix this.
           */
          
      54  class RepetitionDevice: public InputDevice,   virtual public SigC::Object
          {
           //======================================================================
           // Private Variables
           //======================================================================
           private:
           long unsigned int myInitialDelay; //initial delay in milliseconds
           long unsigned int myDelay; //delay in milliseconds
      62   SDL_TimerID myTimerID;
          
           //======================================================================
           // Public methods
           //======================================================================
           public:
          
           /**
           * Connect this to the input mapping of your choice. If a KEY_PRESSED event
           * is found,   the repetition device synchronizes it's calles to this event.
           */
          
      74   void switchOn(  InputDevice * motionDevice,   InputDevice * keyDevice,  
      75   const DimeKey & Key,   InputMapping::InputSignalType type );
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           /**
           * Creates a repetition device. Since this is no actual SDL input device
           * no index or subindex is needed.
           */
      84   RepetitionDevice(  long unsigned int initialDelay,   long unsigned int delay,  
      85   bool alwaysRunning = false );
          
           /**
           * Deletes a RepetitionDevice instance.
           */
      90   virtual ~RepetitionDevice(   );
          
          
           //----------------------------------------------------------------------
           // Public properties
          
      96   long unsigned int getDelay(   );
          
           //======================================================================
           // Protected methods
           //======================================================================
           protected:
          
           /**
           * Is called back by the SDL and pushes a TIMEREVENT into the message loop.
           */
          
          
     108   static Uint32 TimerCallback(  Uint32 interval,   void *param );
     109   virtual bool handleEvent(  SDL_Event & event );
          };
          
          
          
          } // namespace dime
          
          #endif
          
          
          

./services/logging/ErisLogReciever.cpp

       1  //
          // C++ Implementation: ErisLogReciever
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ErisLogReciever.h"
          
          namespace Ember {
          
      27  ErisLogReciever::ErisLogReciever(  LoggingService& logService )
          : mLogService(  logService )
          {
           //Hook up to Eris's logging Service
           Eris::Logged.
           connect (  sigc::mem_fun (  *this,   &ErisLogReciever::Eris_Logged ) );
          
          }
          
          
      37  ErisLogReciever::~ErisLogReciever(   )
          {
          }
          
      41  void ErisLogReciever::Eris_Logged (  Eris::LogLevel level,   const std::string & msg )
          {
           LoggingService::MessageImportance importance;
          
          
           // Translate Eris importance's to ours
          
           switch (  level )
           {
           case Eris::LOG_ERROR:
           importance = LoggingService::CRITICAL;
           break;
           case Eris::LOG_WARNING:
           importance = LoggingService::WARNING;
           break;
           case Eris::LOG_NOTICE:
           importance=LoggingService::INFO;
           break;
           case Eris::LOG_VERBOSE:
           default:
           importance = LoggingService::VERBOSE;
           }
          
           mLogService.sendMessage (  msg,   "ERIS",   0,   importance );
          }
          
          }

./services/logging/ErisLogReciever.h

       1  //
          // C++ Interface: ErisLogReciever
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERERISLOGRECIEVER_H
          #define EMBERERISLOGRECIEVER_H
          
          #include <Eris/Log.h>
          #include "LoggingService.h"
          
          namespace Ember {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      34  class ErisLogReciever{
          public:
      36   ErisLogReciever(  LoggingService& logService );
          
      38   ~ErisLogReciever(   );
          private:
           /**
           *
           */
      43   void Eris_Logged(  Eris::LogLevel level,   const std::string & msg );
          
      45   LoggingService& mLogService;
          };
          
          }
          
          #endif

./services/logging/LoggingService.cpp

       1  #include "LoggingService.h"
          #include "ErisLogReciever.h"
          
          // Include system headers here
          #include <string>
          #include <list>
          #include <stdio.h>
          #include <sstream>
          //#include <varargs.h> //TODO: Needed by unix?
          
          #include <sigc++/object_slot.h>
          
          namespace Ember {
          
          LoggingService* LoggingService::theInstance = NULL;
          
      17  Service::Status LoggingService::start (   )
          {
           setRunning (  true );
           setStatus (  Service::OK );
           return Service::OK;
          }
          
          
      25  void LoggingService::log (  const char *message,   ... )
          {
           va_list vl;
           va_start (  vl,   message );
           logVarParam (  "",   -1,   INFO,   message,   vl );
           va_end (  vl );
          }
          
          
      34  void LoggingService::log (  const char *file,   const char *message,   ... )
          {
           va_list vl;
           va_start (  vl,   message );
           logVarParam (  file,   -1,   INFO,   message,   vl );
           va_end (  vl );
          }
          
          
          
      44  void LoggingService::log (  const char *file,   const int line,  
           const char *message,   ... )
          {
           va_list vl;
           va_start (  vl,   message );
           logVarParam (  file,   line,   INFO,   message,   vl );
           va_end (  vl );
          }
          
          
      54  void LoggingService::log (  const MessageImportance importance,  
           const char *message,   ... )
          {
           va_list vl;
           va_start (  vl,   message );
           logVarParam (  "",   -1,   importance,   message,   vl );
           va_end (  vl );
          }
          
      63  void LoggingService::log (  const char *file,  
           const MessageImportance importance,  
           const char *message,   ... )
          {
           va_list vl;
           va_start (  vl,   message );
           logVarParam (  file,   -1,   importance,   message,   vl );
           va_end (  vl );
          }
          
      73  void LoggingService::log (  const char *file,   const int line,  
           const MessageImportance importance,  
           const char *message,   ... )
          {
           va_list vl;
           va_start (  vl,   message );
           logVarParam (  file,   line,   importance,   message,   vl );
           va_end (  vl );
          }
          
      83  void LoggingService::logVarParam (  const char *file,   const int line,  
           const MessageImportance importance,  
      85   const char *message,   va_list argptr )
          {
           char Buffer[MESSAGE_BUFFER_SIZE];
           vsprintf (  (  char * ) Buffer,   message,   argptr );
           sendMessage (  std::string (  (  char * ) Buffer ),   file,   line,   importance );
          }
          
          
      93  LoggingService & LoggingService::slog (  const std::string & file,  
           const int line,  
           const MessageImportance
           importance )
          {
           myFile = file;
           myLine = line;
           myImportance = importance;
           return *this;
          }
          
     104  LoggingService & LoggingService::
          slog (  const MessageImportance importance )
          {
           myImportance = importance;
           return *this;
          }
          
     111  LoggingService & LoggingService::slog (  const std::string & file,  
           const MessageImportance
           importance )
          {
           myFile = file;
           myImportance = importance;
           return *this;
          }
          
     120  LoggingService & LoggingService::slog (  const std::string & file,  
           const int line )
          {
           myFile = file;
           myLine = line;
           return *this;
          }
          
     128  LoggingService & LoggingService::slog (  const std::string & file )
          {
           myFile = file;
           return *this;
          }
          
          
          
          
     137  void LoggingService::addObserver (  Observer * observer )
          {
           //test on already existing observer
           for (  ObserverList::iterator i = myObserverList.begin (   );
           i != myObserverList.end (   ); i++ )
           {
           if (  *i == observer )
           {
           return;
           }
           }
          
           //no existing observer,   add a new
           myObserverList.push_back (  observer );
          }
          
     153  int LoggingService::removeObserver (  Observer * observer )
          {
           for (  ObserverList::iterator i = myObserverList.begin (   );
           i != myObserverList.end (   ); i++ )
           {
           if (  *i == observer )
           {
           myObserverList.erase (  i );
           return 0;
           }
           }
          
           return -1;
          }
          
     168  LoggingService::HexNumber LoggingService::
          hexNumber (  const int intDecimal )
          {
           HexNumber intHex;
           intHex.myNumber = intDecimal;
           return intHex;
          }
          
     176  LoggingService & LoggingService::operator<< (  const std::
           string & stringToAdd )
          {
           myMessage += stringToAdd;
           return *this;
          }
          
     183  LoggingService & LoggingService::operator<< (  const unsigned int uintToAdd )
          {
           std::stringstream ss;
           ss << uintToAdd;
           myMessage += ss.str(   );
          
           return *this;
          }
          
     192  LoggingService & LoggingService::operator<< (  const int intToAdd )
          {
           std::stringstream ss;
           ss << intToAdd;
           myMessage += ss.str(   );
          
           return *this;
          }
          
     201  LoggingService & LoggingService::
          operator<< (  const HexNumber & intHexToAdd )
          {
           char buffer[NUMBER_BUFFER_SIZE];
           sprintf (  buffer,   "%x",   intHexToAdd.myNumber );
           myMessage += buffer;
           return *this;
          }
          
     210  LoggingService & LoggingService::
          operator<< (  const double doubleToAdd )
          {
           std::stringstream ss;
           ss << doubleToAdd;
           myMessage += ss.str(   );
           return *this;
          }
          
     219  LoggingService & LoggingService::
          operator<< (  const unsigned long ulongToAdd )
          {
           std::stringstream ss;
           ss << ulongToAdd;
           myMessage += ss.str(   );
           return *this;
          }
          
          
     229  void LoggingService::operator<< (  const EndMessageEnum endMessage )
          {
           sendMessage (  myMessage,   myFile,   myLine,   myImportance );
          
           myMessage = "";
           myFile = "";
           myLine = -1;
           myImportance = INFO;
          }
          
     239  LoggingService::LoggingService (   ) : Service(   )
          {
           //set service properties
          
           setName (  "Logging" );
           setDescription (  "Eases message writing and distribution." );
          
          
           //set all option values to not specified
           myMessage = "";
           myFile = "";
           myLine = -1;
           myImportance = INFO;
          
           mErisLogReciever = std::auto_ptr<ErisLogReciever>(  new ErisLogReciever(  *this ) );
          }
          
          
     257  LoggingService::~LoggingService (   )
          {
          
          }
          
          
     263  void LoggingService::sendMessage (  const std::string & message,  
     264   const std::string & file,  
           const int line,  
           const MessageImportance importance )
          {
           time_t currentTime;
           time (  &currentTime );
          
           for (  ObserverList::iterator i = myObserverList.begin (   );
           i != myObserverList.end (   ); i++ )
           {
           if (  (  int ) importance >= (  int ) (  *i )->getFilter (   ) )
           {
           (  *i )->onNewMessage (  message,   file,   line,   importance,   currentTime );
           }
           }
          }
          
          }

./services/logging/LoggingService.h

       1  /*
           Copyright (  C ) 2002 Tim Enderling
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef LOGGINGSERVICE_H
          #define LOGGINGSERVICE_H
          
          // Include other headers of the current program here
          #include "framework/Service.h"
          
          // Include library headers here
          #include <sigc++/object.h>
          
          #include <ctime>
          #include <stdarg.h>
          
          
          namespace Ember
          {
          
          //General TODOs:
          //%TASK Tim,  2: make LoggingService threadsafe!
          //%TASK Tim,  2: Is it necessary to support UNICODE/wide characters?
          //%TASK Tim,  2: Add debug assertions. (  How are the platform independent macros called? )
          
          
      41  class ErisLogReciever;
          
          //======================================================================
          // Short type macros
          //======================================================================
          
          #define ENDM Ember::LoggingService::END_MESSAGE;
          #define HEX_NUM(  number ) Ember::LoggingService::hexNumber(  number )
          
          //Added by nikal 2002/10/22 For convenience.
          //%TASK nikal,  1: Perhaps a script to switch the macros to the actual function call would make code more readable?
          #define S_LOG_VERBOSE(  message ) Ember::LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   Ember::LoggingService::VERBOSE ) << message << ENDM;
          #define S_LOG_INFO(  message ) Ember::LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   Ember::LoggingService::INFO ) << message << ENDM;
          #define S_LOG_WARNING(  message ) Ember::LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   Ember::LoggingService::WARNING ) << message << ENDM;
          #define S_LOG_FAILURE(  message )Ember::LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   Ember::LoggingService::FAILURE ) << message << ENDM;
          #define S_LOG_CRITICAL(  message ) Ember::LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   Ember::LoggingService::CRITICAL ) << message << ENDM;
          
          
          //#define S_LOG_INFO(  message ) Ember::LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::INFO ) << message << ENDM;
          
          //TODO: Sorry,   but innerclass didn't work properly
          const int NUMBER_BUFFER_SIZE = 24;
          const int MESSAGE_BUFFER_SIZE = 4096;
          
          /**
          * Easy-to-deal-with logging class.
          *
          * This service class should make adding and observing logging messages more easy. This
          * can be done using printf-like log method or just streaming operator << in
          * cout-like way.
          *
          * The cout-like way always needs a LoggingService::END_MESSAGE to be streamed-in
          * last (  use ENDM* macro ). To specify formats like hexadecimal printing static functions
          * are available for conversion (  use the HEX_NUM* macro ).
          *
          * NOTE: Since streaming actually constist of many operations that can be interrupted by
          * switching the active thread,   streaming should only be used in thread safe areas. [TODO: How
          * to fix this unwanted behaviour?]
          *
          *
          * There are some log variants for which you can specify some options:
          * - source file (  use __FILE__ )
          * - source line (  use __LINE__ )
          * - level of importance (  see enum called MessageImportance ),   always INFO if not specified
          *
          * As a special feature you can use a function called slog* (  abbr. for stream log ) that can
          * be used for setting the options before using streaming. (  See example. )
          *
          * Observers of logging process can easily be managed
          * using addObserver and removeObserver. An observer class handling FILE * is predefined already.
          *
          * To less the amount of messages passed through to the observers,   you can specify a filter by
          * levels of importance. Thus all messages above or equal a filter level of importance are
          * written/passed by the callback to an observer.
          *
          *
          * HINT: Names marked with * were chosen this short,   because they are intentended to be used very
          * frequently.
          *
          * SAMPLE:
          * using namespace Ember::services;
          * LoggingService * logger;
          * //service is assumed to be started; observers are added
          *
          * //do you prefer this way?
          * logger->log(  __FILE__,   __LINE__,   LoggingService::WARNING,  
          * "Player %s (  ID: %x ) is already dead (  but used in %d new messages ).",  
          * player->getName(   ),   player->getID(   ),   player->getMessages(   )->getCount(   ) );
          *
          * //or this?
          * logger->slog(  __FILE__,   __LINE__,   LoggingService::WARNING ) << "Player: " << player->getName(   )
          * <<"(  ID: " << HEX_NUM(  player->getID(   ) ) << "is already dead (  but used in " <<
          * player->getMessages(   )->getCount(   ) << " new messages )." << ENDM;
          *
          *
          * @author Tim Enderling
          */
          
     119  class LoggingService:public Service
          {
           //======================================================================
           // Public Constants and enums
           //======================================================================
           public:
     125   friend class ErisLogReciever;
           /**
           * This enum contains all levels of message importance.
           * -VERBOSE messages are for maxiumum level of verboseness and are emitted frequently with details of Ember's internal state.
           * -INFO messages are intended to be read only to look for reasons of errors.
           * -WARNING messages appear whenever something could get critical in some case.
           * -CRITICAL messages should be read always and contain fatal errors.
           */
           enum MessageImportance
           {
           VERBOSE = 0,  
           INFO = 1,  
           WARNING = 2,  
           FAILURE = 3,  
           CRITICAL = 4
           };
          
          
           /**
           * Pseudo-enum necessary to make the END_MESSAGE constant not be mixed with ints
           */
           enum EndMessageEnum
           {
           END_MESSAGE = 0
           };
          
           //======================================================================
           // Inner Classes and typedefs
           //======================================================================
          
           public:
          
          
           /**
           * Abstract base class (  =interface ) for all observers
           */
     161   class Observer
           {
           public:
          
     165   Observer (   )
           {
           myFilter = INFO; //No filtering assumed
           }
          
     170   virtual ~Observer(   ) {}
          
           /**
           * Called every time a new message arrived at the LoggingService
           *
           * @param message The message string to send.
           * @param file The source code file the message was initiated or empty if not specified.
           * @param line The source code line the message was initiated or -1 if not specified.
           * @param importance The level of importance (  see MessageImportance enum )
           * @param time_t The time the message was initiated.
           */
          
     182   virtual void onNewMessage (  const std::string & message,  
     183   const std::string & file,  
           const int &line,  
           const MessageImportance & importance,  
     186   const time_t & timeStamp ) = 0;
          
     188   MessageImportance getFilter (   )
           {
           return myFilter;
           }
          
     193   void setFilter (  MessageImportance filter )
           {
           myFilter = filter;
           }
          
           private:
          
           /**
           * A filter used by the LoggingService to determine wether the message should be send
           * to onNewMessage. This happens only if the message is at least as important as
           * the filter value.
           */
          
           MessageImportance myFilter;
           };
          
           /**
           * Predefined implementation of Observer-class handling FILE *
           *
           * The format of messages written into a FILE * is the following:
           *
           * timeStamp "\t" importance "\t" file "\t" line "\t" message
           */
          
     217   class FileObserver:public Observer
           {
           public:
     220   FileObserver (  FILE * file,   MessageImportance filter )
           {
           setFilter (  filter );
           myFile = file;
           }
     225   virtual ~FileObserver(   ) {}
          
     227   virtual void onNewMessage (  const std::string & message,  
     228   const std::string & file,  
           const int &line,  
           const MessageImportance & importance,  
     231   const time_t & timeStamp )
           {
           tm *ctm = localtime (  &timeStamp ); //currentLocalTime was too long,   sorry
          
           fprintf (  myFile,  
           "[%04d-%02d-%02d %02d:%02d:%02d]\t%s\t%s\t%d\t%s\n",  
           ctm->tm_year,   ctm->tm_mon,   ctm->tm_mday,  
           ctm->tm_hour,   ctm->tm_min,   ctm->tm_sec,  
           (  importance ==
           CRITICAL ) ? "CRITICAL" : (  (  importance ==
           FAILURE ) ? "FAILURE"
           : (  (  importance ==
           WARNING ) ? "WARNING" :
           (  (  importance== INFO ) ?"INFO":"VERBOSE" ) ) ),  
           file.c_str (   ),   line,   message.c_str (   ) );
           }
          
     248   FILE *getFile (   )
           {
           return myFile;
           }
          
           private:
     254   FILE * myFile;
           };
          
          private:
          
           typedef std::list < Observer * >ObserverList;
          
           /**
           * pseudo-type used for multiple overriding with the same type of the operator<<
           */
          
           struct HexNumber
           {
           int myNumber;
           };
          
           //======================================================================
           // Private Constants
           //======================================================================
          private:
          
           //======================================================================
           // Private Variables
           //======================================================================
          private:
          
           /**
           list of observers
           */
     283   ObserverList myObserverList;
          
           /**
           currently given part of the message string (  used by << streaming only )
           */
     288   std::string myMessage;
          
           /**
           * currently set source file (  option; used by << streaming only )
           * An empty string indicates that no file option was set.
           */
     294   std::string myFile;
          
           /**
           * currently set source code line (  option; used by << streaming only )
           * -1 indicates that no line option was set.
           */
           int myLine;
          
           /**
           * currently set importance (  option; used by << streaming only )
           * The default value is INFO.
           */
           MessageImportance myImportance;
           /**
           * Singleton instance
           */
           static LoggingService* theInstance;
          
          
           //======================================================================
           // Public Methods
           //======================================================================
          public:
          
           //----------------------------------------------------------------------
           // Singleton
          
           /**
           * Returns the LoggingService instance.
           */
     324   static LoggingService *getInstance (   )
           {
           if(   !theInstance  )
           {
           theInstance = new LoggingService;
           }
          
           return theInstance;
           }
          
           //----------------------------------------------------------------------
           // Constructors
          
           /* NOTE: No copy constructor available (  needed anywhere? )
           LoggingService(   const LoggingService &source  )
           {
           // Use assignment operator to do the copy
           // NOTE: If you need to do custom initialization in the constructor this may not be enough.
           *this = source;
           }
          
           LoggingService &operator= (   const LoggingService &source  )
           {
           // Copy fields from source class to this class here.
          
           // Return this object with new value
           return *this;
           } */
          
          
           //----------------------------------------------------------------------
           // Destructor
          
           /**
           * Deletes a LoggingService instance.
           */
     360   virtual ~LoggingService (   );
          
          
           //----------------------------------------------------------------------
           // Getters
          
           //----------------------------------------------------------------------
           // Setters
          
           //----------------------------------------------------------------------
           // Other public methods
          
     372   virtual Service::Status start (   );
          
           /**
           * Adds a message presented by various options,   a format string and variable params like
           * in printf using also the same format specifications.
           *
           * @param file The source code file the message was initiated.
           * @param line The source code line the message was initiated.
           * @param importance The level of importance (  see MessageImportance enum )
           * @param message The message format string.
           *
           */
     384   void log (  const char *message,   ... );
          
     386   void log (  const char *file,   const char *message,   ... );
          
     388   void log (  const char *file,   const int line,   const char *message,   ... );
          
     390   void log (  const MessageImportance importance,   const char *message,  
           ... );
          
     393   void log (  const char *file,   const MessageImportance importance,  
           const char *message,   ... );
          
     396   void log (  const char *file,   const int line,  
           const MessageImportance importance,   const char *message,  
           ... );
          
          
           /**
           * Is actually used in all cases of log. (  Generates the message and then uses sendMessage. )
           * @see log
           */
     405   void logVarParam (  const char *file,   const int line,  
           const MessageImportance importance,  
     407   const char *message,   va_list argptr );
          
           /**
           * Gives the possibility to specify options when using the streaming method << for messages.
           *
           * @param file The source code file the message was initiated.
           * @param line The source code line the message was initiated.
           * @param importance The level of importance (  see MessageImportance enum )
           *
           * @return This function always returns a reference to the LoggingService object. You
           * can thus easily apply the shifting operator to it.
           */
          
     420   LoggingService & slog (  const std::string & file,   const int line,  
           const MessageImportance importance );
          
     423   LoggingService & slog (  const MessageImportance importance );
          
     425   LoggingService & slog (  const std::string & file,  
           const MessageImportance importance );
          
     428   LoggingService & slog (  const std::string & file,   const int line );
          
     430   LoggingService & slog (  const std::string & file );
          
           /**
           * Adds an observer to the list.
           *
           * @param observer Pointer to an object with an Observer interface to be added to the list.
           */
          
     438   void addObserver (  Observer * observer );
          
          
           /**
           * Removes an observer from the list.
           *
           * @param observer The pointer previously added the the observer list via addObserver.
           *
           * @return 0 if the observer was found and removed,   <> 0 otherwise
           */
          
          
     450   int removeObserver (  Observer * observer );
          
           //----------------------------------------------------------------------
           // shifting operator and helper functions
          
           /**
           * Converts a normal int to a hexadecimal int that can be streamed into the
           * LoggingService object. (  use HEX_NUM macro if you want )
           */
          
     460   static HexNumber hexNumber (  const int intDecimal );
          
     462   LoggingService & operator<< (  const std::string & stringToAdd );
          
     464   LoggingService & operator<< (  const int intToAdd );
          
     466   LoggingService & operator<< (  const unsigned int uintToAdd );
          
     468   LoggingService & operator<< (  const unsigned long ulongToAdd );
          
     470   LoggingService & operator<< (  const HexNumber & intHexToAdd );
          
     472   LoggingService & operator<< (  const double doubleToAdd );
          
          // LoggingService & operator<< (  const size_t sizetToAdd );
           /**
           * By streaming in END_MESSAGE (  equally to ENDM-macro ) you finish the message and start
           * sending it.
           */
          
     480   void operator<< (  const EndMessageEnum endMessage );
          
           //======================================================================
           // Protected Methods
           //======================================================================
          protected:
          
          
           //======================================================================
           // Private Methods
           //======================================================================
          private:
          
           //----------------------------------------------------------------------
           // Constructors
          
           /**
           * Creates a new LoggingService using default values.
           * Private so LoggingService can only be initialized through getInstance.
           */
     500   LoggingService (   );
          
           //----------------------------------------------------------------------
           // Other private methods
          
     505   std::auto_ptr<ErisLogReciever> mErisLogReciever;
          
           /**
           * Unifies the sending mechanism for streaming- and formatting-input
           */
          
     511   virtual void sendMessage (  const std::string & message,  
     512   const std::string & file,   const int line,  
           const MessageImportance importance );
          
          }; // LoggingService
          
          } // namespace Ember
          
          #endif

./services/metaserver/MetaserverService.cpp

          /*
           Copyright (  C ) 2002 Miguel Guzman Miranda [Aglanor]
           Based on YUP::Metacmd code by Adam Wendt
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #include "MetaserverService.h"
          
          // Current project
          #include "services/logging/LoggingService.h"
          #include "services/config/ConfigService.h"
          #include "services/EmberServices.h"
          #include "framework/ConsoleBackend.h"
          
          // System headers
          #include <iostream>
          #include <list>
          #include <algorithm>
          #include <sstream>
          
          // Libraries we are using
          
          #include <sigc++/signal.h>
          
          #include <Eris/Metaserver.h>
          #include <Eris/ServerInfo.h>
          
          
          using namespace std;
          
          namespace Ember
          {
          
           typedef std::list<Eris::ServerInfo> svrl;
           typedef svrl::iterator Iter;
          
      50   MetaserverService::MetaserverService(   ) :mMetaserver(  0 )
           ,   MetaRefresh(  "meta_refresh",   this,   "Refresh the meta server listing." )
      52   ,   MetaAbort(  "meta_abort",   this,   "Abort the meta server update process." )
          // ,   MetaList(  "meta_list",   this,   "List all servers." )
           {
           setName(  "Metaserver Service" );
           setDescription(  "Service for Metaserver session" );
           // TODO(  zzorn,   2002-01-19 ): Set the status of the service to OK.
           // setStatus(   Service::Status::OK  );
           S_LOG_INFO(  "Metaserver Service created" );
           }
          
           /* dtor */
      63   MetaserverService::~MetaserverService(   )
           {
           delete mMetaserver;
           }
          
           /* Method for starting this service */
      69   Service::Status MetaserverService::start(   )
           {
           setStatus(  Service::OK );
           setRunning(   true  );
          
           Ember::ConfigService* configSrv = Ember::EmberServices::getSingletonPtr(   )->getConfigService(   );
          
           std::string metaserverHostname;
           if (  configSrv->itemExists(  "metaserver",   "server" ) ) {
           metaserverHostname = std::string(  configSrv->getValue(  "metaserver",   "server" ) );
           } else {
           metaserverHostname = "metaserver.worldforge.org";
           }
          
           mMetaserver = new Eris::Meta(  metaserverHostname,   10 );
           mMetaserver->Failure.connect(  sigc::mem_fun(  *this,   &MetaserverService::gotFailure ) );
           mMetaserver->ReceivedServerInfo.connect(  sigc::mem_fun(  *this,   &MetaserverService::receivedServerInfo ) );
           mMetaserver->CompletedServerList.connect(  sigc::mem_fun(  *this,   &MetaserverService::completedServerList ) );
          
          
          // std::string metaserver = "metaserver.worldforge.org";
          //
          // msrv = new Eris::Meta(  metaserver,   10 );
          // msrv->Failure.connect(  SigC::slot(  *this,   &MetaserverService::gotFailure ) );
          // msrv->ReceivedServerInfo.connect(  SigC::slot(  *this,   &MetaserverService::receivedServerInfo ) );
          // msrv->CompletedServerList.connect(  SigC::slot(  *this,   &MetaserverService::completedServerList ) );
          // listed = false;
          
          
           return Service::OK;
           }
          
           /* Interface method for stopping this service */
     102   void MetaserverService::stop(  int code )
           {
           Service::stop(  code );
           setStatus(  Service::OK );
           }
          
          
     109   void MetaserverService::gotFailure(  const string& msg )
           {
           S_LOG_WARNING(  "Got Meta-server error: " << msg );
           }
          
     114   void MetaserverService::receivedServerInfo(  const Eris::ServerInfo& sInfo )
           {
          
           S_LOG_VERBOSE(  "Got serverinfo:\n"
           << "Hostname: " <<sInfo.getHostname(   )
           << "\nServerName: "<<sInfo.getServername(   )
           << "\nRuleset: "<<sInfo.getRuleset(   )
           << "\nServer Type: "<<sInfo.getServer(   )
           << "\nClients: "<<sInfo.getNumClients(   )
           << "\nPing: "<< sInfo.getPing(   )
           << "\nUptime: "<< (  int )sInfo.getUptime(   ) );
           }
          
     127   void MetaserverService::completedServerList(  int count )
           {
           S_LOG_INFO(  "Server List completed." );
           S_LOG_INFO(  "Servers: " << count );
          
          // stringstream out;
          // out << "Listing hostnames..." << endl;
          //
          // for(  int i = 0; i < count; i++ )
          // {
          // //HINT: Always use .c_str(   ) for compatibility to MSVC
          // Eris::ServerInfo inf = mMetaserver->getInfoForServer(  i );
          //
          //
          // out << "Hostname: " << inf.getHostname(   ).c_str(   ) << endl;
          // }
          //
          //
          // S_LOG_INFO(   out.str(   ) );
          
           }
          
     149  Eris::Meta& MetaserverService::getMetaServer(   ) const
          {
           return *mMetaserver;
          }
          
          
     155   void MetaserverService::runCommand(  const std::string &command,   const std::string &args )
           {
           if (  !mMetaserver ) return;
          /* if (  MetaList == command ){
           } else */
           if (  MetaAbort == command ) {
           mMetaserver->cancel(   );
           } else if (  MetaRefresh == command ) {
           mMetaserver->refresh(   );
           }
          
           return;
           }
          } // namespace Ember

./services/metaserver/MetaserverService.h

       1  /*
           Copyright (  C ) 2002 Miguel Guzman Miranda [Aglanor],   Martin Pollard (  Xmp )
           Based on YUP::Metacmd code by Adam Wendt
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef METASERVERSERVICE_H
          #define METASERVERSERVICE_H
          
          #include <framework/Service.h>
          #include <framework/ConsoleObject.h>
          
          #include <sigc++/object.h>
          #include <Eris/Metaserver.h>
          #include <Eris/ServerInfo.h>
          
          #include <string>
          
          namespace Ember {
          
          /**
           * Ember Metaserver Service
           *
           * @author Miguel Guzman Miranda [Aglanor]
           *
           * @see Ember::Service
           * @see Ember::ServerService
           * @see Ember::ConsoleObject
           */
      43  class MetaserverService: public Service,  
      44   public ConsoleObject
          {
           //======================================================================
           // Private Variables
           //======================================================================
           private:
          
      51   Eris::Meta* mMetaserver;
          // Eris::ServerList serverlist;
          // bool listed;
          // //StringProvider * myStateDMP;
      55   const Ember::ConsoleCommandWrapper MetaRefresh;
      56   const Ember::ConsoleCommandWrapper MetaAbort;
          // const Ember::ConsoleCommandWrapper MetaList;
          
          
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           public:
          
           /** Creates a new ConfigService using default values. */
      67   MetaserverService(   );
          
          
           /** Deletes a ConfigService instance. */
      71   ~MetaserverService(   );
          
           //----------------------------------------------------------------------
           // Getters & Setters
          
      76   Eris::Meta& getMetaServer(   ) const;
          
           //----------------------------------------------------------------------
           // Methods
          
      81   Service::Status start(   );
          
      83   void stop(  int code ) ;
          
          
          
      87   void gotFailure(  const std::string& msg );
          
      89   void receivedServerInfo(  const Eris::ServerInfo& sInfo );
          
      91   void completedServerList(  int count );
          
           /**
           * This is the function that needs to be extended to use the console.
           * command is a command that has been previously registered with the console
           * args is the argument string that has been provided for the command
           */
      98   virtual void runCommand(  const std::string &command,   const std::string &args );
          
          }; //MetaserverService
          
          } // namespace Ember
          
          #endif
          
          

./services/scripting/ScriptingService.cpp

          //
          // C++ Implementation: ScriptingService
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ScriptingService.h"
          
          
          #include "services/logging/LoggingService.h"
          #include "framework/IScriptingProvider.h"
          #include "framework/Tokeniser.h"
          #include "framework/ConsoleBackend.h"
          #include "framework/Exception.h"
          
          namespace Ember {
          
      34  ScriptingService::ScriptingService(   )
      35  : LoadScript(  "loadscript",   this,   "Loads a script." ),   mResourceProvider(  0 ),   mAlwaysLookup(  false )
          {
          }
          
          
      40  ScriptingService::~ScriptingService(   )
          {
           stop(  0 );
           for(  ProviderStore::iterator I = mProviders.begin(   ); I != mProviders.end(   ); ++I )
           {
           delete I->second;
           }
          }
          
      49  void ScriptingService::stop(  int code )
          {
           Service::stop(  code );
           for(  ProviderStore::iterator I = mProviders.begin(   ); I != mProviders.end(   ); ++I )
           {
           I->second->stop(   );
           }
          }
          
      58  Service::Status ScriptingService::start(   )
          {
           return Service::OK;
          }
          
      63  void ScriptingService::loadScript(  const std::string& script )
          {
           if (  mResourceProvider ) {
           Ember::ResourceWrapper resWrapper = mResourceProvider->getResource(  script );
           if (  !resWrapper.hasData(   ) ) {
           scriptError(  "Unable to find script file " + script + "." );
           S_LOG_FAILURE(  "Unable to find script file " + script + "." );
           return;
           }
          
           for(  ProviderStore::iterator I = mProviders.begin(   ); I != mProviders.end(   ); ++I )
           {
           //check if the provider will load the script
           if (  I->second->willLoadScript(  script ) ) {
           S_LOG_INFO(  "Loading script: " << script << " with scripting provider " << I->second->getName(   )  );
           try {
           I->second->loadScript(  resWrapper );
           } catch (  const Ember::Exception& ex ) {
           S_LOG_WARNING(  "Error when loading script " << script << " with provider " << I->second->getName(   ) << ". Message: " << ex.getError(   ) );
           scriptError(  ex.getError(   ) );
           } catch (  const std::exception& ex ) {
           S_LOG_WARNING(  "Error when loading script " << script << " with provider " << I->second->getName(   ) << ". Message: " << ex.what(   ) );
           scriptError(  ex.what(   ) );
           } catch (  ... ) {
           S_LOG_WARNING(  "Got unknown script error when loading the script " << script );
           scriptError(  "Unknown error loading script " + script  );
           }
           return;
           }
           }
           S_LOG_FAILURE(  "Could not find a scripting provider which will load the script " << script << "." );
           }
          }
          
      97  void ScriptingService::executeCode(  const std::string& scriptCode,   const std::string& scriptType )
          {
           ProviderStore::iterator I = mProviders.find(  scriptType );
           if (  I == mProviders.end(   ) ) {
           S_LOG_FAILURE(  "There is no scripting provider with the name \"" << scriptType << "\"" );
           } else {
           try {
           I->second->executeScript(  scriptCode );
           } catch (  const Ember::Exception& ex ) {
           S_LOG_WARNING(  "Error when executing script\n" << scriptCode << "\nwith provider " << I->second->getName(   ) << ". Message: " << ex.getError(   ) );
           scriptError(  ex.getError(   ) );
           } catch (  const std::exception& ex ) {
           S_LOG_WARNING(  "Error when executing script\n" << scriptCode << "\nwith provider " << I->second->getName(   ) << ". Message: " << ex.what(   ) );
           scriptError(  ex.what(   ) );
           } catch (  ... ) {
           S_LOG_WARNING(  "Got unknown script error when executing the script " << scriptCode );
           scriptError(  "Unknown error executing script." );
           }
           }
          }
          
          
     119  sigc::signal<void,   const std::string&>& ScriptingService::getEventScriptError(   )
          {
           return mEventScriptError;
          }
          
     124  void ScriptingService::registerScriptingProvider(  IScriptingProvider* provider )
          {
           if (  mProviders.find(  provider->getName(   ) ) != mProviders.end(   ) ) {
           S_LOG_FAILURE(  "Could not add alreay existing scripting provider with name " + provider->getName(   ) );
           } else {
           mProviders[provider->getName(   )] = provider;
           provider->_registerWithService(  this );
           S_LOG_INFO(  "Registered scripting provider " << provider->getName(   ) );
           }
          }
          
     135  void ScriptingService::scriptError(  const std::string& error )
          {
           //S_LOG_WARNING(  error );
           mEventScriptError.emit(  error );
          }
          
     141  IScriptingProvider* ScriptingService::getProviderFor(  const std::string &providerName )
          {
           ProviderStore::iterator I = mProviders.find(  providerName );
           if (  I != mProviders.end(   ) )
           {
           return I->second;
           }
           return 0;
          }
          
     151  void ScriptingService::runCommand(  const std::string &command,   const std::string &args )
          {
           if (  LoadScript == command ){
           Ember::Tokeniser tokeniser;
           tokeniser.initTokens(  args );
           std::string script = tokeniser.nextToken(   );
           if (  script != "" ) {
           loadScript(  script );
           }
           }
          
           return;
          }
          
     165  std::vector<std::string> ScriptingService::getProviderNames(   )
          {
           std::vector<std::string> names;
           for(  ProviderStore::iterator I = mProviders.begin(   ); I != mProviders.end(   ); ++I )
           {
           names.push_back(  I->second->getName(   ) );
           }
           return names;
          
          }
          
     176  Ember::IResourceProvider* ScriptingService::getResourceProvider(   )
          {
           return mResourceProvider;
          }
          
     181  void ScriptingService::setResourceProvider(  Ember::IResourceProvider* resourceProvider )
          {
           mResourceProvider = resourceProvider;
          }
          
          
          
          
          }

./services/scripting/ScriptingService.h

       1  //
          // C++ Interface: ScriptingService
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2005
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERSCRIPTINGSERVICE_H
          #define EMBERSCRIPTINGSERVICE_H
          
          #include <framework/Service.h>
          #include <framework/ConsoleObject.h>
          
          #include <sigc++/signal.h>
          #include <map>
          #include <vector>
          
          namespace Ember {
      34  class IResourceProvider;
      35  class IScriptingProvider;
          /**
          @author Erik Hjortsberg
          
          This service provides scripting support.
          In order to use it,   an instance implementing IScriptingProvider must be created and registered with the service.
          Scripts are then loaded through call to the method loadScript(  ... ). Scripts can also be loaded through the console command /loadscript <path>
          */
      43  class ScriptingService : public Service,   public ConsoleObject
          {
      45  friend class IScriptingProvider;
          public:
          
      48   ScriptingService(   );
          
      50   virtual ~ScriptingService(   );
          
      52   virtual Service::Status start(   );
          
      54   virtual void stop(  int code );
          
           /**
           Console command for loading scripts.
           */
      59   const Ember::ConsoleCommandWrapper LoadScript;
          
           /**
           * Registers a new scripting provider.
           * @param provider
           */
      65   void registerScriptingProvider(  IScriptingProvider* provider );
          
           /**
           * Loads a new script,   if there is an registered scripting provider which will be able to load it.
           * @param script
           */
      71   void loadScript(  const std::string& script );
          
           /**
           * Executes the supplied code directly into the provider with the supplied name.
           * @param scriptCode
           * @param scriptType
           */
      78   void executeCode(  const std::string& scriptCode,   const std::string& scriptType );
          
           /**
           * The EventScriptError signal will be emitted when there is an error in a script.
           * @return
           */
      84   sigc::signal<void,   const std::string&>& getEventScriptError(   );
          
           /**
           * Implement ConsoleObject method.
           * @param command
           * @param args
           */
      91   virtual void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           * Returns the provider with the specified name,   or 0 if no can be found.
           * @param providerName
           * @return
           */
      98   IScriptingProvider* getProviderFor(  const std::string &providerName );
          
           /**
           * Returns a list of the names of all registered scripting providers.
           * @return
           */
     104   std::vector<std::string> getProviderNames(   );
          
     106   IResourceProvider* getResourceProvider(   );
          
     108   void setResourceProvider(  Ember::IResourceProvider* resourceProvider );
          
           /**
           Returns whether all scripting methods should be looked up at every call. Setting this to true will decrease performance,   but allow for dynamic updating of script methods.
           */
     113   inline bool getAlwaysLookup(   ) const;
           /**
           Sets whether all scripting methods should be looked up at every call. Setting this to true will decrease performance,   but allow for dynamic updating of script methods.
           */
     117   inline void setAlwaysLookup(  bool alwaysLookup );
          private:
          
           /**
           * Call this method when there's an error in a script. This will emit the mEventScriptError signal.
           * @param error
           */
     124   void scriptError(  const std::string& error );
          
           typedef std::map<std::string,   IScriptingProvider*> ProviderStore;
          
           /**
           A map of all scripting providers.
           */
     131   ProviderStore mProviders;
          
     133   sigc::signal<void,   const std::string&> mEventScriptError;
          
     135   IResourceProvider* mResourceProvider;
          
     137   bool mAlwaysLookup;
          
          };
          
     141  bool ScriptingService::getAlwaysLookup(   ) const
          {
           return mAlwaysLookup;
          }
          
     146  void ScriptingService::setAlwaysLookup(  bool alwaysLookup )
          {
           mAlwaysLookup = alwaysLookup;
          }
          
          
          }
          
          #endif

./services/server/ConnectedAdapter.cpp

       1  //
          // C++ Implementation: ConnectedAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "ConnectedAdapter.h"
          #include <Eris/Connection.h>
          #include <Eris/Account.h>
          #include <Eris/Lobby.h>
          #include <Eris/View.h>
          #include <Eris/Avatar.h>
          #include <Eris/TypeInfo.h>
          #include <Eris/Exceptions.h>
          #include <Eris/Entity.h>
          
          #include "services/logging/LoggingService.h"
          #include "framework/ConsoleBackend.h"
          
          
          namespace Ember {
          
      39  ConnectedAdapter::ConnectedAdapter(  Eris::Avatar* avatar,   Eris::Connection* connection ) : mAvatar(  avatar ),   mConnection(  connection )
          {
          }
          
          
      44  ConnectedAdapter::~ConnectedAdapter(   )
          {
          }
          
      48  void ConnectedAdapter::moveToPoint(  const WFMath::Point<3>& dest ) {
           try {
           mAvatar->moveToPoint(  dest );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(   "Got Eris error on moving: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on moving: " << except.what(   ) );
           }
          
          }
          
      63  void ConnectedAdapter::moveInDirection(  const WFMath::Vector<3>& velocity,   const WFMath::Quaternion& orientation ) {
           try {
           mAvatar->moveInDirection(  velocity,   orientation );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on moving: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on moving: " << except.what(   ) );
           }
          }
          
          
      78  void ConnectedAdapter::moveInDirection(  const WFMath::Vector<3>& velocity ) {
           try {
           mAvatar->moveInDirection(  velocity );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on moving: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on moving: " << except.what(   ) );
           }
          }
          
          // void ConnectedAdapter::teleportTo(  const WFMath::Point<3>& dest )
          // {
          //
          // }
          
          
      98  void ConnectedAdapter::touch(  Eris::Entity* entity )
          {
           try {
           mAvatar->touch(  entity );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on touching: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on touching: " << except.what(   ) );
           }
          }
          
     113  void ConnectedAdapter::emote(  const std::string& emote )
          {
           try {
           mAvatar->emote(  emote );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on emoting: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on emoting: " << except.what(   ) );
           }
          }
          
     128  void ConnectedAdapter::take(  Eris::Entity* entity )
          {
           try {
           mAvatar->take(  entity );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on taking: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on taking: " << except.what(   ) );
           }
          }
          
     143  void ConnectedAdapter::drop(  Eris::Entity* entity,   const WFMath::Vector<3>& offset )
          {
           try {
           mAvatar->drop(  entity,   offset );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on dropping: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on dropping: " << except.what(   ) );
           }
          }
     157  void ConnectedAdapter::place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos )
          {
           ///use the existing orientation
           place(  entity,   target,   pos,   entity->getOrientation(    ) );
          }
          
     163  void ConnectedAdapter::place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos,   const WFMath::Quaternion& orient )
          {
           try {
           /// we want to do orientation too so we can't use the Avatar::place method until that's updated
           Atlas::Objects::Entity::Anonymous what;
           what->setLoc(  target->getId(   ) );
           what->setPosAsList(  Atlas::Message::Element(  pos.toAtlas(   ) ).asList(   ) );
           what->setAttr(  "orientation",   orient.toAtlas(   ) );
          
           what->setId(  entity->getId(   ) );
          
           Atlas::Objects::Operation::Move moveOp;
           moveOp->setFrom(  mAvatar->getEntity(   )->getId(   ) );
           moveOp->setArgs1(  what );
          
           ///if the avatar is a "creator",   i.e. and admin,   we will set the TO property
           ///this will bypass all of the server's filtering,   allowing us to place any entity,   unrelated to if it's too heavy or belong to someone else
           if (  mAvatar->getEntity(   )->getType(   )->isA(  mConnection->getTypeService(   )->getTypeByName(  "creator" ) ) ) {
           moveOp->setTo(  entity->getId(   ) );
           }
          
           mConnection->send(  moveOp );
          
          
          // mAvatar->place(  entity,   target,   pos,   orient );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on dropping: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on dropping: " << except.what(   ) );
           }
          }
          
     199  void ConnectedAdapter::wield(  Eris::Entity* entity )
          {
           try {
           mAvatar->wield(  entity );
          
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on wielding: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on wielding: " << except.what(   ) );
           }
          }
          
     215  void ConnectedAdapter::use(  Eris::Entity* entity,   WFMath::Point<3> pos )
          {
           try {
           mAvatar->useOn(  entity,   pos,   "" );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on using: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on using: " << except.what(   ) );
           }
          }
          
     230  void ConnectedAdapter::useStop(   )
          {
           try {
           mAvatar->useStop(   );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on stopping using: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on stopping using: " << except.what(   ) );
           }
          }
          
     245  void ConnectedAdapter::deleteEntity(  Eris::Entity* entity )
          {
           try {
           Atlas::Objects::Entity::Anonymous what;
           what->setId(  entity->getId(   ) );
          
           Atlas::Objects::Operation::Delete deleteOp;
           deleteOp->setFrom(  mAvatar->getEntity(   )->getId(   ) );
           deleteOp->setTo(  entity->getId(   ) );
           deleteOp->setArgs1(  what );
          
           S_LOG_INFO(  "Deleting entity with id " << entity->getId(   ) << ",   named " << entity->getName(   ) );
           mConnection->send(  deleteOp );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on deleting entity: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on deleting entity: " << except.what(   ) );
           }
          }
          
     269  void ConnectedAdapter::setAttributes(  Eris::Entity* entity,   Atlas::Message::MapType& elements )
          {
           try {
           Atlas::Objects::Entity::Anonymous what;
           what->setId(  entity->getId(   ) );
           for(  Atlas::Message::MapType::iterator I = elements.begin(   ); I != elements.end(   ); ++I ) {
           what->setAttr(  I->first,   I->second );
           }
          
           Atlas::Objects::Operation::Set setOp;
           setOp->setFrom(  mAvatar->getEntity(   )->getId(   ) );
           //setOp->setTo(  entity->getId(   ) );
           setOp->setArgs1(  what );
          
           S_LOG_INFO(  "Setting attributes of entity with id " << entity->getId(   ) << ",   named " << entity->getName(   ) );
           mConnection->send(  setOp );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on setting attributes on entity: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on setting attributes on entity: " << except.what(   ) );
           }
          }
          
          
     297  void ConnectedAdapter::attack(  Eris::Entity* entity )
          {
           try {
           mAvatar->attack(  entity );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on attack: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on attack: " << except.what(   ) );
           }
          }
          
     312  void ConnectedAdapter::eat(  Eris::Entity* entity )
          {
           try {
           Atlas::Objects::Entity::Anonymous what;
           what->setId(  entity->getId(   ) );
          
           Atlas::Objects::Operation::Generic op;
           op->setType(  "eat",   -1 );
           op->setFrom(  mAvatar->getEntity(   )->getId(   ) );
           op->setArgs1(  what );
          
           S_LOG_INFO(  "Eating entity with id " << entity->getId(   ) << ",   named " << entity->getName(   ) );
           mConnection->send(  op );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on eating entity: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on eating entity: " << except.what(   ) );
           }
          }
          
          
     337  void ConnectedAdapter::say(  const std::string &message )
          {
           try {
           mAvatar->say(  message );
          
           std::string msg;
           msg = "Saying: [" + message + "]. ";
           ConsoleBackend::getMainConsole(   )->pushMessage(  msg );
           S_LOG_VERBOSE(   msg );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on say: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on say: " << except.what(   ) );
           }
          }
          
     357  void ConnectedAdapter::adminTell(  const std::string& entityId,   const std::string& attribute,   const std::string &value )
          {
           try {
          
           Atlas::Objects::Entity::Anonymous what;
           what->setAttr(  attribute,   value );
           Atlas::Objects::Operation::Talk talk;
           talk->setFrom(  entityId );
           talk->setTo(  entityId );
           talk->setArgs1(  what );
          
           Atlas::Objects::Operation::Sound sound;
           sound->setFrom(  mAvatar->getEntity(   )->getId(   ) );
           sound->setTo(  entityId );
           sound->setArgs1(  talk );
          
           mConnection->send(  sound );
          
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got Eris error on admin_tell: " << except._msg );
           }
           catch (  const std::runtime_error& except )
           {
           S_LOG_WARNING(  "Got unknown error on admin_tell: " << except.what(   ) );
           }
          }
          
          }

./services/server/ConnectedAdapter.h

       1  //
          // C++ Interface: ConnectedAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERCONNECTEDADAPTER_H
          #define EMBERCONNECTEDADAPTER_H
          
          #include "IServerAdapter.h"
          
          namespace Eris {
      29   class Avatar;
      30   class Connection;
          }
          
          namespace Ember {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      38  class ConnectedAdapter : public IServerAdapter
          {
          public:
      41   ConnectedAdapter(  Eris::Avatar* avatar,   Eris::Connection* connection );
          
      43   ~ConnectedAdapter(   );
          
      45   virtual void moveToPoint(  const WFMath::Point<3>& dest );
      46   virtual void moveInDirection(  const WFMath::Vector<3>& velocity,   const WFMath::Quaternion& orientation );
      47   virtual void moveInDirection(  const WFMath::Vector<3>& velocity );
          // virtual void teleportTo(  const WFMath::Point<3>& dest );
      49   virtual void say(  const std::string &message );
      50   virtual void touch(  Eris::Entity* entity );
      51   virtual void emote(  const std::string& emote );
      52   virtual void drop(  Eris::Entity* entity,   const WFMath::Vector<3>& offset );
      53   virtual void place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos = WFMath::Point<3>(  0,   0,   0 ) );
      54   virtual void place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos,   const WFMath::Quaternion& orient );
      55   virtual void wield(  Eris::Entity* entity );
      56   virtual void take(  Eris::Entity* entity );
      57   virtual void use(  Eris::Entity* entity,   WFMath::Point<3> pos = WFMath::Point<3>(  0,  0,  0 ) );
      58   virtual void useStop(   );
      59   virtual void attack(  Eris::Entity* entity );
      60   virtual void eat(  Eris::Entity* entity );
      61   virtual void deleteEntity(  Eris::Entity* entity );
      62   virtual void setAttributes(  Eris::Entity* entity,   Atlas::Message::MapType& elements );
      63   virtual void adminTell(  const std::string& entityId,   const std::string& attribute,   const std::string &value );
          
          private:
      66   Eris::Avatar* mAvatar;
      67   Eris::Connection* mConnection;
          };
          
          }
          
          #endif

./services/server/IServerAdapter.cpp

       1  //
          // C++ Implementation: IServerAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "IServerAdapter.h"
          
          namespace Ember {
          
      27  IServerAdapter::IServerAdapter(   )
          {
          }
          
          
      32  IServerAdapter::~IServerAdapter(   )
          {
          }
          
          
          }

./services/server/IServerAdapter.h

       1  //
          // C++ Interface: IServerAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERISERVERADAPTER_H
          #define EMBERISERVERADAPTER_H
          
          #include <Atlas/Objects/Entity.h>
          
          #include <wfmath/atlasconv.h>
          #include <wfmath/point.h>
          
          namespace Eris
          {
      33   class Entity;
          }
          
          namespace Ember {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      41  class IServerAdapter{
          public:
          
      44   virtual ~IServerAdapter(   ) {}
          
      46   virtual void moveToPoint(  const WFMath::Point<3>& dest ) = 0;
      47   virtual void moveInDirection(  const WFMath::Vector<3>& velocity,   const WFMath::Quaternion& orientation ) = 0;
      48   virtual void moveInDirection(  const WFMath::Vector<3>& velocity ) = 0;
          // virtual void teleportTo(  const WFMath::Point<3>& dest ) = 0;
      50   virtual void say(  const std::string &message ) = 0;
      51   virtual void touch(  Eris::Entity* entity ) = 0;
      52   virtual void emote(  const std::string& emote ) = 0;
      53   virtual void drop(  Eris::Entity* entity,   const WFMath::Vector<3>& offset ) = 0;
      54   virtual void place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos = WFMath::Point<3>(  0,   0,   0 ) ) = 0;
      55   virtual void place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos,   const WFMath::Quaternion& orient ) = 0;
      56   virtual void wield(  Eris::Entity* entity ) = 0;
      57   virtual void take(  Eris::Entity* entity ) = 0;
      58   virtual void use(  Eris::Entity* entity,   WFMath::Point<3> pos = WFMath::Point<3>(  0,  0,  0 ) ) = 0;
      59   virtual void useStop(   ) = 0;
      60   virtual void attack(  Eris::Entity* entity ) = 0;
      61   virtual void eat(  Eris::Entity* entity ) = 0;
      62   virtual void deleteEntity(  Eris::Entity* entity ) = 0;
      63   virtual void setAttributes(  Eris::Entity* entity,   Atlas::Message::MapType& attributes ) = 0;
      64   virtual void adminTell(  const std::string& entityId,   const std::string& attribute,   const std::string &value ) = 0;
          };
          
          }
          
          #endif

./services/server/NonConnectedAdapter.cpp

       1  //
          // C++ Implementation: NonConnectedAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "NonConnectedAdapter.h"
          
          namespace Ember {
          
      27  NonConnectedAdapter::NonConnectedAdapter(   )
          {
          }
          
          
      32  NonConnectedAdapter::~NonConnectedAdapter(   )
          {
          }
          
      36  void NonConnectedAdapter::moveToPoint(  const WFMath::Point<3>& dest ) {
          
          
          }
          
      41  void NonConnectedAdapter::moveInDirection(  const WFMath::Vector<3>& velocity,   const WFMath::Quaternion& orientation ) {
          
          }
          
          
      46  void NonConnectedAdapter::moveInDirection(  const WFMath::Vector<3>& velocity ) {
          
          }
          
          
      51  void NonConnectedAdapter::touch(  Eris::Entity* entity )
          {
          
          }
          
      56  void NonConnectedAdapter::take(  Eris::Entity* entity )
          {
          
          }
          
      61  void NonConnectedAdapter::drop(  Eris::Entity* entity,   const WFMath::Vector<3>& offset )
          {
          
          }
          
      66  void NonConnectedAdapter::place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos )
          {
          
          }
          
      71  void NonConnectedAdapter::place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos,   const WFMath::Quaternion& orient )
          {
          
          }
          
      76  void NonConnectedAdapter::wield(  Eris::Entity* entity )
          {
          
          }
          
      81  void NonConnectedAdapter::use(  Eris::Entity* entity,   WFMath::Point<3> pos )
          {
          
          }
          
      86  void NonConnectedAdapter::useStop(   )
          {
          
          }
          
          
      92  void NonConnectedAdapter::attack(  Eris::Entity* entity )
          {
          
          }
          
      97  void NonConnectedAdapter::eat(  Eris::Entity* entity )
          {
          }
          
          
     102  void NonConnectedAdapter::say(  const std::string &message )
          {
          
          }
          
     107  void NonConnectedAdapter::deleteEntity(  Eris::Entity* entity )
          {
          }
          
     111  void NonConnectedAdapter::setAttributes(  Eris::Entity* entity,   Atlas::Message::MapType& attributes )
          {
          }
          
     115  void NonConnectedAdapter::adminTell(  const std::string& entityId,   const std::string& attribute,   const std::string &value )
          {
          }
          
          
          }

./services/server/NonConnectedAdapter.h

       1  //
          // C++ Interface: NonConnectedAdapter
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERNONCONNECTEDADAPTER_H
          #define EMBERNONCONNECTEDADAPTER_H
          
          #include "IServerAdapter.h"
          
          namespace Ember {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      33  class NonConnectedAdapter : public IServerAdapter
          {
          public:
      36   NonConnectedAdapter(   );
          
      38   ~NonConnectedAdapter(   );
          
      40   virtual void moveToPoint(  const WFMath::Point<3>& dest );
      41   virtual void moveInDirection(  const WFMath::Vector<3>& velocity,   const WFMath::Quaternion& orientation );
      42   virtual void moveInDirection(  const WFMath::Vector<3>& velocity );
          // virtual void teleportTo(  const WFMath::Point<3>& dest ) {}
      44   virtual void say(  const std::string &message );
      45   virtual void touch(  Eris::Entity* entity );
      46   virtual void emote(  const std::string& emote ) {}
      47   virtual void drop(  Eris::Entity* entity,   const WFMath::Vector<3>& offset );
      48   virtual void place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos = WFMath::Point<3>(  0,   0,   0 ) );
      49   virtual void place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos,   const WFMath::Quaternion& orient );
      50   virtual void wield(  Eris::Entity* entity );
      51   virtual void take(  Eris::Entity* entity );
      52   virtual void use(  Eris::Entity* entity,   WFMath::Point<3> pos = WFMath::Point<3>(  0,  0,  0 ) );
      53   virtual void useStop(   );
      54   virtual void attack(  Eris::Entity* entity );
      55   virtual void eat(  Eris::Entity* entity );
      56   virtual void deleteEntity(  Eris::Entity* entity );
      57   virtual void setAttributes(  Eris::Entity* entity,   Atlas::Message::MapType& attributes );
      58   virtual void adminTell(  const std::string& entityId,   const std::string& attribute,   const std::string &value );
          
          };
          
          }
          
          #endif

./services/server/OOGChat.cpp

          /*
           Copyright (  C ) 2002 Martin Pollard
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
           */
          
          #include "OOGChat.h"
          #include "services/logging/LoggingService.h"
          #include "framework/ConsoleBackend.h"
          
          #include <Eris/Person.h>
          #include <Eris/Lobby.h>
          #include <Eris/Account.h>
          
          #include <sstream>
          
          namespace Ember {
          
           // List of OOGChat's console commands
      32   const char * const OOGChat::CMD_TALK = "talk";
      33   const char * const OOGChat::CMD_EMOTE = "emote";
      34   const char * const OOGChat::CMD_ME = "me";
      35   const char * const OOGChat::CMD_JOIN = "join";
      36   const char * const OOGChat::CMD_PART = "part";
      37   const char * const OOGChat::CMD_MSG = "msg";
          
      39   OOGChat::OOGChat(  Eris::Account* account ) : myLobby(  NULL )
           {
           // Set up the lobby object
           //HACK: to get it to work with eris 1.3
           myLobby = new Eris::Lobby(  account );
          
           // Specfic to lobby Callbacks setup
           myLobby->SightPerson.connect(  sigc::mem_fun(  *this,  &OOGChat::sightPerson ) );
           myLobby->PrivateTalk.connect(  sigc::mem_fun(  *this,  &OOGChat::privateTalk ) );
           //myLobby->LoggedIn.connect(  SigC::slot(  *this,  &OOGChat::loggedIn ) );
          
           // Ordinary rooms callbacks
           myLobby->Entered.connect(  sigc::mem_fun(  *this,  &OOGChat::entered ) );
           myLobby->Speech.connect(  sigc::mem_fun(  *this,  &OOGChat::talk ) );
           myLobby->Emote.connect(  sigc::mem_fun(  *this,  &OOGChat::emote ) );
           myLobby->Appearance.connect(  sigc::mem_fun(  *this,  &OOGChat::appearance ) );
           myLobby->Disappearance.connect(  sigc::mem_fun(  *this,  &OOGChat::disappearance ) );
          // myLobby->Changed.connect(  SigC::bind(  SigC::slot(  *this,  &OOGChat::changed ),  myLobby ) );
          
          /* ConsoleBackend::getMainConsole(   )->registerCommand(   CMD_TALK,   this  );
           ConsoleBackend::getMainConsole(   )->registerCommand(   CMD_EMOTE,   this  );
           ConsoleBackend::getMainConsole(   )->registerCommand(   CMD_ME,   this  );
           ConsoleBackend::getMainConsole(   )->registerCommand(   CMD_JOIN,   this  );
           ConsoleBackend::getMainConsole(   )->registerCommand(   CMD_PART,   this  );
           ConsoleBackend::getMainConsole(   )->registerCommand(   CMD_MSG,   this  );*/
           }
          
      66   OOGChat::~OOGChat(   )
           {
           // TODO: Free any allocated resources here.
           // Deregister our console commands
          /* ConsoleBackend::getMainConsole(   )->deregisterCommand(   CMD_TALK  );
           ConsoleBackend::getMainConsole(   )->deregisterCommand(   CMD_EMOTE  );
           ConsoleBackend::getMainConsole(   )->deregisterCommand(   CMD_ME  );
           ConsoleBackend::getMainConsole(   )->deregisterCommand(   CMD_JOIN  );
           ConsoleBackend::getMainConsole(   )->deregisterCommand(   CMD_PART  );
           ConsoleBackend::getMainConsole(   )->deregisterCommand(   CMD_MSG  );*/
           }
          
          
           // Lobby Specific callbacks
          
      81   void OOGChat::sightPerson(  Eris::Person* person )
           {
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::INFO ) << "Sighted Person name:\""<< person->getName(   )<<"\" id:"<<person->getAccount(   )<< ENDM;
           }
          
      86   void OOGChat::privateTalk(  Eris::Person* person,   const std::string& msg )
           {
           std::ostringstream temp;
          
           temp << "PRIVMSG(  "<<person->getName(   )<<" ) says:"<<msg;
          
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::INFO )<<temp.str(   )<<ENDM;
          
          #if 0 // not new sstream
           temp<<std::ends;
          #endif
           ConsoleBackend::getMainConsole(   )->pushMessage(  temp.str(   ) );
           }
          
     100   void OOGChat::loggedIn(   const Atlas::Objects::Entity::Player& player )
           {
           // Xmp's Notes
           // Erm dunno what this function is for eris's doxygen doesn't explain
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Logged In eris msg received" );
           }
          
     107   void OOGChat::runCommand(  const std::string &command,   const std::string &args )
           {
           // %FIXME xmp,  4: Don't allow talk until we have logged in
           // %FIXME xmp,  4: Stop just using myLobby to allow chat to multiple rooms
          
           if (  command==CMD_TALK )
           {
           myLobby->say(  args );
           return;
           } else if (  command == CMD_EMOTE || command == CMD_ME ) {
           myLobby->emote(  args );
           return;
           } else if (  command == CMD_JOIN ) {
           return;
           } else if (  command == CMD_PART ) {
           return;
           } else if (  command == CMD_MSG ) {
           return;
           }
           }
          
           // All Eris::Room callbacks
          
     130   void OOGChat::entered(  Eris::Room *room )
           {
           std::ostringstream temp;
          
           temp << "Entry of "<< room->getName(   )<<" complete";
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::VERBOSE ) << temp.str(   ) << ENDM;
          #if 0 //not new stream
           temp<<std::ends;
          #endif
           ConsoleBackend::getMainConsole(   )->pushMessage(  temp.str(   ) );
           }
          
     142   void OOGChat::talk(  Eris::Room *room,   Eris::Person* person,   const std::string& msg )
           {
           std::ostringstream temp;
          
           temp << "["<< room->getName(   )<<"] "<<person->getName(   )<<" says: "<<msg;
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::VERBOSE ) << temp.str(   ) << ENDM;
           temp<<std::ends;
           ConsoleBackend::getMainConsole(   )->pushMessage(  temp.str(   ) );
           }
          
     152   void OOGChat::emote(  Eris::Room *room,   Eris::Person* person,   const std::string& msg )
           {
           std::ostringstream temp;
          
           temp << "["<< room->getName(   )<<"] "<<person->getName(   )<<" "<<msg;
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::VERBOSE ) << temp.str(   ) << ENDM;
          #if 0 // not new sstream
           temp<<std::ends;
          #endif
           ConsoleBackend::getMainConsole(   )->pushMessage(  temp.str(   ) );
           }
          
     164   void OOGChat::appearance(  Eris::Room *room,   Eris::Person* person )
           {
           std::ostringstream temp;
          
           temp << person->getName(   ) << " appears in "<< room->getName(   );
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::VERBOSE ) << temp.str(   ) <<ENDM;
          #if 0 // not new sstream
           temp<<std::ends;
          #endif
           ConsoleBackend::getMainConsole(   )->pushMessage(  temp.str(   ) );
           }
          
     176   void OOGChat::disappearance(  Eris::Room* room,   Eris::Person* person )
           {
           std::ostringstream temp;
          
           temp << person->getName(   ) << " disappears from "<< room->getName(   );
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::VERBOSE )<<temp.str(   )<<ENDM;
          #if 0 // if not new sstream
           temp<<std::ends;
          #endif
           ConsoleBackend::getMainConsole(   )->pushMessage(  temp.str(   ) );
           }
          
     188   void OOGChat::changed(  const Eris::StringSet& sset,   Eris::Room *room )
           {
           }
          }

./services/server/OOGChat.h

          /*
           Copyright (  C ) 2002 Martin Pollard
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
           */
          
          #ifndef OOGCHAT_H
          #define OOGCHAT_H
          
          // Included headers from the current project
          #include "framework/ConsoleObject.h"
          
          // Included custom library headers
          #include <Eris/Lobby.h>
          #include <Eris/Room.h>
          #include <Eris/Account.h>
          #include <sigc++/object.h>
          #include <sigc++/bind.h>
          
          // Included system headers
          
          namespace Ember {
          
          /**
           * Eris Lobby management object.
           *
           * This class holds the Eris::Lobby object for the current session
           * and handles it's callback,   etc.
           *
           * A short piece of example code demonstarting how this class it is used,  
           * and in what context,   is encouraged.
           *
           * @author Martin Pollard aka Xmp
           *
           * NOTE: You can also specify the author for individual methods
           * if different persons have created them.
           * It is also possible to have multiple @author tags for a method.
           * Only add yourself as an @author if you have done serious work
           * on a class/method,   and can help fixing bugs in it,   etc.
           * If you just fixed a bug or added a short code snipplet you
           * don't need to add yourself.
           *
           * @see Ember::ServerService
           *
           * NOTE: Add other related classes here,   doxygen will create links to them.
           */
          
      60  class OOGChat : public ConsoleObject
          {
           //======================================================================
           // Inner Classes,   Typedefs,   and Enums
           //======================================================================
           public:
          
          
           //======================================================================
           // Public Constants
           //======================================================================
           public:
          
          
           //======================================================================
           // Private Constants
           //======================================================================
           private:
          
           // List of OOGChat's console commands
           static const char * const CMD_TALK;
           static const char * const CMD_EMOTE;
           static const char * const CMD_ME;
           static const char * const CMD_JOIN;
           static const char * const CMD_PART;
           static const char * const CMD_MSG;
          
           //======================================================================
           // Private Variables
           //======================================================================/
           private:
          
           /**
           * Holds the lobby of this server
           */
           Eris::Lobby* myLobby;
          
           //======================================================================
           // Public Methods
           //======================================================================
           public:
          
           //----------------------------------------------------------------------
           // Constructors
          
           /**
           * Creates a new OOGChat using default values.
           */
           OOGChat(  Eris::Account* account );
          
           /**
           * Copy constructor.
           */
           OOGChat(   const OOGChat &source  )
           {
           // Use assignment operator to do the copy
           // NOTE: If you need to do custom initialization in the constructor this may not be enough.
           *this = source;
           }
          
          
           /**
           * Assignment operator.
           */
     124   OOGChat &operator= (   const OOGChat &source  )
           {
           // Copy fields from source class to this class here.
           myLobby = source.myLobby;
          
           // Return this object with new value
           return *this;
           }
          
          
           //----------------------------------------------------------------------
           // Destructor
          
           /**
           * Deletes a OOGChat instance.
           */
     140   virtual ~OOGChat (   );
          
          
           //----------------------------------------------------------------------
           // Getters
          
           // Example of a getter method:
          
           /**
           * Gets the value of Lobby of this OOGChat
           */
     151   Eris::Lobby* getLobby(   ) const
           {
           return myLobby;
           }
          
          
           //----------------------------------------------------------------------
           // Setters
          
           /**
           * Sets the value of Lobby of this OOGChat
           */
     163   void setLobby(   Eris::Lobby* lobby  )
           {
           myLobby = lobby;
           }
          
          
           //----------------------------------------------------------------------
           // Other public methods
           // NOTE: Group related public methods together and crate a separator comment like above for them.
          
           //======================================================================
           // Protected Methods
           //======================================================================
           protected:
          
           /**
           * Command handler for console backend.
           */
           void runCommand(  const std::string &command,   const std::string &args );
          
           //----------------------------------------------------------------------
           // Callbacks from Eris
          
           // Lobby Callbacks
          
           void sightPerson(  Eris::Person* );
          
           void privateTalk(  Eris::Person* person,   const std::string& );
          
           void loggedIn(   const Atlas::Objects::Entity::Player&  );
          
           void entered(  Eris::Room *room );
          
           void talk(  Eris::Room *room,   Eris::Person* person,   const std::string& msg );
          
           void emote(  Eris::Room *room,   Eris::Person* person,   const std::string& msg );
          
           void appearance(  Eris::Room *room,   Eris::Person* person );
          
           void disappearance(  Eris::Room *room,   Eris::Person* person );
          
           void changed(  const Eris::StringSet& sset,   Eris::Room *room );
          
          
           //======================================================================
           // Private Methods
           //======================================================================
           private:
          
          
           //======================================================================
           // Disabled constructors and operators
           //======================================================================
           private:
          
          
          }; // End of OOGChat
          
          } // End of Ember namespace
          
          #endif

./services/server/ServerService.cpp

          /*
           Copyright (  C ) 2002 Martin Pollard (  Xmp )
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #include <Atlas/Objects/Entity.h>
          #include <Atlas/Objects/Operation.h>
          #include <Atlas/Message/Element.h>
          #include <Atlas/Objects/Anonymous.h>
          #include "ServerService.h"
          #include "services/logging/LoggingService.h"
          #include "framework/ConsoleBackend.h"
          #include "framework/Tokeniser.h"
          #include <wfmath/atlasconv.h>
          
          #include <sigc++/object_slot.h>
          #include <sigc++/object.h>
          #include <Eris/Connection.h>
          #include <Eris/Person.h>
          #include <Eris/Avatar.h>
          #include <Eris/Entity.h>
          #include <Eris/TypeInfo.h>
          #include <Eris/Exceptions.h>
          #include <Eris/View.h>
          
          
          #include <list>
          #include <algorithm>
          #include <iostream>
          #include <sstream>
          
          #include "ConnectedAdapter.h"
          #include "NonConnectedAdapter.h"
          
          #include "OOGChat.h"
          
          #include "framework/ConsoleCommandWrapper.h"
          
          
          
          namespace Ember
          {
          
      61  ServerService::ServerService(   ) :
           mConn(  0 ),  
           mAccount(  0 ),  
           mView(  0 ),  
           mAvatar(  0 ),  
           mOOGChat(  0 ),  
           mConnected(  false ),  
           Connect(  "connect",   this,   "Connect to a server." ),  
      69   DisConnect(  "disconnect",   this,   "Disconnect from the server." ),  
          // ReConnect(  "reconnect",   this,   "Reconnect to the server" ),  
           CreateAcc(  "create",   this,   "Create an account on the server." ),  
           Login(  "login",   this,   "Login to the connected server." ),  
           Logout(  "logout",   this,   "Logout from the connected server." ),  
           CreateChar(  "add",   this,   "Create a character on the server." ),  
           TakeChar(  "take",   this,   "Take control of one of your characters." ),  
           ListChars(  "list",   this,   "List you available characters on the server." ),  
           Say(  "say",   this,   "Say something." ),  
           Emote(  "me",   this,   "Emotes something." ),  
           Delete(  "delete",   this,   "Deletes an entity." ),  
           AdminTell(  "admin_tell",   this,   "Uses admin mode to directly tell a NPC something. Usage: /admin_tell <entityid> <key> <value>" ),  
           mServerAdapter(  new NonConnectedAdapter(   ) )
          {
           setName(  "Server Service" );
           setDescription(  "Service for Server session" );
          }
          
          /* dtor */
      88  ServerService::~ServerService(   )
          {
           delete mConn;
           //delete mAccount;
           //delete mView;
           delete mServerAdapter;
          }
          
          /* Method for starting this service */
      97  Service::Status ServerService::start(   )
          {
           setStatus(  Service::OK );
           setRunning(   true  );
          
           return Service::OK;
          
          }
          
          /* Interface method for stopping this service */
     107  void ServerService::stop(  int code )
          {
           setStatus(  Service::OK );
           setRunning(   false  );
          
           disconnect(   );
          }
          
          /* Interface method for connecting to host */
     116  bool ServerService::connect(  const std::string& host,   short port )
          {
           myHost = host;
           myPort = port;
           try {
           // Create new instance of mConn the constructor sets the
           // singleton instance up. Do _not_ use Connection::Instance(   )
           // this does not create a new connection.
           // We are connected without debuging enabled thus the false
           mConn = new Eris::Connection(  std::string(  "Ember " ) + VERSION,  myHost,   port,   false );
          
           // Bind signals
           mConn->Failure.connect(  sigc::mem_fun(  *this,   &ServerService::gotFailure ) );
           mConn->Connected.connect(  sigc::mem_fun(  *this,   &ServerService::connected ) );
           mConn->Disconnected.connect(  sigc::mem_fun(  *this,   &ServerService::disconnected ) );
           mConn->Disconnecting.connect(  sigc::mem_fun(  *this,   &ServerService::disconnecting ) );
           mConn->StatusChanged.connect(  sigc::mem_fun(  *this,   &ServerService::statusChanged ) );
           //mConn->Timeout.connect(  SigC::slot(  *this,   &ServerService::timeout ) );
           // If the connection fails here an errnumber is returned
           int errorno = mConn->connect(   );
           if (  errorno )
           {
           return false;
           }
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got error on connect:" << except._msg );
           return false;
           } catch (  ... )
           {
           S_LOG_WARNING(  "Got unknown error on connect." );
           return false;
           }
          
           return true;
          }
          
          
          // void ServerService::reconnect(   )
          // {
          // if (  !mConn ) return;
          // try {
          // const std::string host = mConn->get
          // mConn->reconnect(   );
          // }
          // catch (  const Eris::BaseException& except )
          // {
          // LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::WARNING ) << "Got error on reconnect:" << except._msg << ENDM;
          // return;
          // }
          // catch (  ... )
          // {
          // LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::WARNING ) << "Got unknown error on reconnect" << ENDM;
          // return;
          // }
          // }
          
          
     175  void ServerService::disconnect(   )
          {
           if (  !mConn ) return;
           try {
           Eris::Account* tempAccount = mAccount;
           mAccount = 0;
           delete tempAccount;
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got error on account deletion:" << except._msg );
           return;
           }
           catch (  const std::exception& e )
           {
           S_LOG_WARNING(  "Got error on account deletion:" << e.what(   ) );
           return;
           }
           catch (  ... )
           {
           S_LOG_WARNING(   "Got unknown error on disconnect" );
           return;
           }
           try {
           mConn->disconnect(   );
           }
           catch (  const Eris::BaseException& except )
           {
           S_LOG_WARNING(  "Got error on disconnect:" << except._msg );
           return;
           }
           catch (  const std::exception& e )
           {
           S_LOG_WARNING(  "Got error on disconnect:" << e.what(   ) );
           return;
           }
           catch (  ... )
           {
           S_LOG_WARNING(  "Got unknown error on disconnect" );
           return;
           }
          
          }
          
     219  void ServerService::gotFailure(  const std::string & msg )
          {
           std::ostringstream temp;
          
           temp << "Got Server error: " << msg;
           S_LOG_WARNING(  temp.str(   ) );
          
           ConsoleBackend::getMainConsole(   )->pushMessage(  temp.str(   ) );
          }
          
     229  void ServerService::connected(   )
          {
           S_LOG_INFO(  "Connected" );
           mConnected = true;
           GotConnection.emit(  mConn );
          
           // Set up the player object
           mAccount=new Eris::Account(  mConn );
           mAccount->GotCharacterInfo.connect(  sigc::mem_fun(  *this,  &ServerService::gotCharacterInfo ) );
           mAccount->GotAllCharacters.connect(  sigc::mem_fun(  *this,  &ServerService::gotAllCharacters ) );
           mAccount->LoginFailure.connect(  sigc::mem_fun(  *this,  &ServerService::loginFailure ) );
           mAccount->LoginSuccess.connect(  sigc::mem_fun(  *this,  &ServerService::loginSuccess ) );
           mAccount->LogoutComplete.connect(  sigc::mem_fun(  *this,  &ServerService::logoutComplete ) );
           mAccount->AvatarSuccess.connect(  sigc::mem_fun(  *this,  &ServerService::gotAvatarSuccess ) );
           mAccount->AvatarDeactivated.connect(  sigc::mem_fun(  *this,  &ServerService::gotAvatarDeactivated ) );
          
           GotAccount.emit(  mAccount );
           // Init OOGChat controller
          // mOOGChat = new OOGChat(  mAccount );
          
          
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Connected to Server" );
          }
          
     253  bool ServerService::disconnecting(   )
          {
           S_LOG_INFO(  "Disconnecting" );
           Eris::Account* tempAccount = mAccount;
           mAccount = 0;
           delete tempAccount;
           return true;
          }
          
     262  void ServerService::disconnected(   )
          {
           S_LOG_INFO(  "Disconnected" );
          
           // NULL out OOGChat & player so noone gets tempted to play with an unconnected lobby/player
          /* delete mAccount;
           mAccount=NULL;*/
           mConnected = false;
           delete mOOGChat;
           mOOGChat = NULL;
          
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Disconnected from server." );
          }
          
     276  void ServerService::statusChanged(  Eris::BaseConnection::Status status )
          {
           S_LOG_INFO(  "Status Changed to: "<<status );
          }
          
     281  void ServerService::timeout(  Eris::BaseConnection::Status status )
          {
           S_LOG_INFO(   "Connection Timed Out" );
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Connection to server timed out" );
          }
          
     287  void ServerService::gotCharacterInfo(  const Atlas::Objects::Entity::RootEntity & info )
          {
           S_LOG_INFO(  "Got Character Info" );
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Got character info" );
          
           GotCharacterInfo.emit(  info );
          }
          
     295   void ServerService::gotAllCharacters(   )
           {
           S_LOG_INFO(  "Got All Characters" );
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Got all characters" );
           Eris::CharacterMap cm = mAccount->getCharacters(   );
           Eris::CharacterMap::iterator i;
           for(  i=cm.begin(   );i!=cm.end(   );i++ ) {
           std::string msg;
           msg = "Character ID: [" + (  *i ).first + "].";
           ConsoleBackend::getMainConsole(   )->pushMessage(  msg );
           }
           GotAllCharacters.emit(  mAccount );
          
           }
          
          // void ServerService::loginFailure(  Eris::LoginFailureType,   const std::string &msg )
     311  void ServerService::loginFailure(  const std::string &msg )
          {
           std::ostringstream temp;
          
           temp<< "Login Failure:"<<msg;
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::WARNING ) << temp.str(   ) << ENDM;
          
           ConsoleBackend::getMainConsole(   )->pushMessage(  temp.str(   ) );
           LoginFailure.emit(  mAccount,   msg );
          }
          
     322  void ServerService::loginSuccess(   ){
           //mView = new Eris::View(  mAccount,   mConn );
          
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::INFO ) << "Login Success."<< ENDM;
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Login Successful" );
           LoginSuccess.emit(  mAccount );
          }
          
     330  void ServerService::takeCharacter(  const std::string &id ){
           mAccount->takeCharacter(  id );
          }
          
     334  void ServerService::gotAvatarSuccess(  Eris::Avatar* avatar ) {
           //if we already have a avatar,   do nothing
           //TODO: perhaps signal an error?
           if (  !mAvatar ) {
           mAvatar = avatar;
           mView = mAvatar->getView(   );
           GotAvatar.emit(  mAvatar );
           GotView.emit(  mView );
           }
           delete mServerAdapter;
           mServerAdapter = new ConnectedAdapter(  mAvatar,   mConn );
          
          }
          
     348  void ServerService::gotAvatarDeactivated(  Eris::Avatar* avatar ) {
           mAvatar = 0;
           mView = 0;
           delete mServerAdapter;
           mServerAdapter = new NonConnectedAdapter(   );
          }
          
          
          
          
     358  void ServerService::logoutComplete(  bool clean ) {
          // delete mView;
           mView = 0;
          
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::INFO ) << "Logout Complete cleanness="<<clean<< ENDM;
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Logged out from server" );
          }
          
     366   void ServerService::runCommand(  const std::string &command,   const std::string &args )
           {
           // Connect command
           if(  Connect == command ){
           // Split string into server / port pair
           Tokeniser tokeniser = Tokeniser(   );
           tokeniser.initTokens(  args );
           std::string server = tokeniser.nextToken(   );
           std::string port = tokeniser.remainingTokens(   );
           std::string msg;
           msg = "Connecting to: [" + server + "]";
           ConsoleBackend::getMainConsole(   )->pushMessage(  msg );
           if (  port=="" )
           connect(  server );
           else
           connect(  server,   (  short )atoi(  port.c_str(   ) ) );
          
           // Disonnect command
           } else if (  DisConnect == command ){
           disconnect(   );
          
           // Create Account command
           } else if (  CreateAcc == command ) {
           if (  !mAccount ) return;
           Tokeniser tokeniser = Tokeniser(   );
           tokeniser.initTokens(  args );
           std::string uname = tokeniser.nextToken(   );
           std::string password = tokeniser.nextToken(   );
           std::string realname = tokeniser.remainingTokens(   );
          
           std::string msg;
           msg = "Creating account: Name: [" + uname + "],   Password: [" + password + "],   Real Name: [" + realname + "]";
          
           try {
           mAccount->createAccount(  uname,  realname,  password );
           }
           catch (  const Eris::BaseException& except )
           {
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::WARNING ) << "Got Eris error on account creation: " << except._msg << ENDM;
           return;
           }
           catch (  const std::runtime_error& except )
           {
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::WARNING ) << "Got unknown error on account creation: " << except.what(   ) << ENDM;
           return;
           }
          
           // Login command
           } else if (  Login == command ) {
          
           // TODO: put this in a separate method
           if (  mAccount )
           {
           // Split string into userid / password pair
           Tokeniser tokeniser = Tokeniser(   );
           tokeniser.initTokens(  args );
           std::string userid = tokeniser.nextToken(   );
           std::string password = tokeniser.remainingTokens(   );
          
           mAccount->login(  userid,  password );
          
           std::string msg;
           msg = "Login: [" + userid + ",  " + password + "]";
           ConsoleBackend::getMainConsole(   )->pushMessage(  msg );
           } else {
           ConsoleBackend::getMainConsole(   )->pushMessage(  "not connected" );
           }
          
           // Logout command
           } else if (  Logout == command ) {
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Logging out..." );
           if (  mAccount )
           {
           mAccount->logout(   );
           }
          
           // Create Character command
           } else if (  CreateChar == command ) {
           // Split string into name/type/sex/description
           Tokeniser tokeniser = Tokeniser(   );
           tokeniser.initTokens(  args );
           std::string name = tokeniser.nextToken(   );
           std::string sex = tokeniser.nextToken(   );
           std::string type = tokeniser.nextToken(   );
           std::string description = tokeniser.remainingTokens(   );
          
           if (  !createCharacter(  name,   sex,   type,   description ) ) {
           return;
           }
          
           // Take Character Command
           } else if (  TakeChar == command ) {
           if (  mAccount )
           {
           takeCharacter(  args );
           }
          
           // List Characters Command
           } else if (  ListChars == command ) {
           if (  mAccount )
           {
           mAccount->refreshCharacterInfo(   );
           }
          
           // Say (  In-Game chat ) Command
           } else if (  Say == command ) {
           say(  args );
           } else if (  Emote == command ) {
           emote(  args );
           } else if (  Delete == command ) {
           Tokeniser tokeniser = Tokeniser(   );
           tokeniser.initTokens(  args );
           std::string entityId = tokeniser.nextToken(   );
           if (  entityId != "" ) {
           Eris::Entity* entity = getView(   )->getEntity(  entityId  );
           if (  entity ) {
           deleteEntity(  entity );
           }
           }
          
          
          
          /* // Touch Command
           } else if (  command==TOUCH ) {
           // TODO: make this switch call the touch method
           // TODO: polish this rough check
           S_LOG_VERBOSE(  "Touching" );
           if(  !mAvatar ) {
           S_LOG_WARNING(  "No avatar." );
           return;
           }
          
           Atlas::Objects::Operation::Touch touch;
           Atlas::Message::MapType opargs;
          
           opargs["id"] = args;
           touch->setFrom(  mAvatar->getId(   ) );
           touch->setArgsAsList(  Atlas::Message::ListType(  1,   opargs ) );
          
           mConn->send(  touch );*/
           } else if (  AdminTell == command )
           {
           Tokeniser tokeniser = Tokeniser(   );
           tokeniser.initTokens(  args );
           std::string entityId = tokeniser.nextToken(   );
           if (  entityId != "" ) {
           std::string key = tokeniser.nextToken(   );
           if (  key != "" ) {
           std::string value = tokeniser.nextToken(   );
           if (  value != "" ) {
           adminTell(  entityId,   key,   value );
           }
           }
           }
           }
           }
          
     523   bool ServerService::createCharacter(  const std::string& name,   const std::string& sex,   const std::string& type,   const std::string& description )
           {
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Creating char..." );
           if (  mAccount )
           {
           std::string msg;
           msg = "Creating character: Name: [" + name + "],   Sex: [" + sex + "],   Type: [" + type + "],   Desc: [" + description + "]";
           ConsoleBackend::getMainConsole(   )->pushMessage(  msg );
          
           S_LOG_INFO(  "Creating character." );
           Atlas::Objects::Entity::RootEntity character;
           character->setParentsAsList(  Atlas::Message::ListType(  1,  type ) );
           character->setName(  name );
           character->setAttr(  "sex",   sex );
           character->setAttr(  "description",   description );
           try {
           mAccount->createCharacter(  character );
           }
           catch (  const Eris::BaseException& except )
           {
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::WARNING ) << "Got Eris error on character creation: " << except._msg << ENDM;
           return false;
           }
           catch (  const std::runtime_error& except )
           {
           LoggingService::getInstance(   )->slog(  __FILE__,   __LINE__,   LoggingService::WARNING ) << "Got unknown error on character creation: " << except.what(   ) << ENDM;
           return false;
           }
           S_LOG_INFO(  "Done creating character." );
           if (  mAvatar ) {
           GotAvatar.emit(  mAvatar );
           mView = mAvatar->getView(   );
           if (  mView ) {
           GotView.emit(  mView );
           }
           }
           } else {
           ConsoleBackend::getMainConsole(   )->pushMessage(  "Not logged in. Can't create char..." );
           }
          
          
           return true;
           }
          
     567   void ServerService::moveToPoint(  const WFMath::Point<3>& dest ) {
           mServerAdapter->moveToPoint(  dest );
           }
          
     571   void ServerService::moveInDirection(  const WFMath::Vector<3>& velocity,   const WFMath::Quaternion& orientation ) {
           mServerAdapter->moveInDirection(  velocity,   orientation );
           }
          
          
     576   void ServerService::moveInDirection(  const WFMath::Vector<3>& velocity ) {
           mServerAdapter->moveInDirection(  velocity );
           }
          
          // void ServerService::teleportTo(  const WFMath::Point<3>& dest )
          // {
          // mServerAdapter->teleportTo(  dest );
          // }
          
          
          
     587   void ServerService::touch(  Eris::Entity* entity )
           {
           mServerAdapter->touch(  entity );
           }
          
     592   void ServerService::take(  Eris::Entity* entity )
           {
           mServerAdapter->take(  entity );
           }
          
     597   void ServerService::drop(  Eris::Entity* entity,   const WFMath::Vector<3>& offset )
           {
           mServerAdapter->drop(  entity,   offset );
           }
          
     602   void ServerService::place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos )
           {
           mServerAdapter->place(  entity,   target,   pos );
           }
          
     607   void ServerService::place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos,   const WFMath::Quaternion& orient )
           {
           mServerAdapter->place(  entity,   target,   pos,   orient );
           }
          
     612   void ServerService::wield(  Eris::Entity* entity )
           {
           mServerAdapter->wield(  entity );
           }
          
     617   void ServerService::use(  Eris::Entity* entity,   WFMath::Point<3> pos )
           {
           mServerAdapter->use(  entity,   pos );
           }
          
     622   void ServerService::useStop(   )
           {
           mServerAdapter->useStop(   );
           }
          
          
     628   void ServerService::attack(  Eris::Entity* entity )
           {
           mServerAdapter->attack(  entity );
           }
          
     633   void ServerService::eat(  Eris::Entity* entity )
           {
           mServerAdapter->eat(  entity );
           }
          
     638   void ServerService::say(  const std::string &message ) {
           mServerAdapter->say(  message );
           }
          
     642   void ServerService::emote(  const std::string &message ) {
           mServerAdapter->emote(  message );
           }
          
     646   void ServerService::deleteEntity(  Eris::Entity* entity )
           {
           mServerAdapter->deleteEntity(  entity );
           }
          
     651   void ServerService::setAttributes(  Eris::Entity* entity,   Atlas::Message::MapType& attributes )
           {
           mServerAdapter->setAttributes(  entity,   attributes );
           }
          
     656   void ServerService::adminTell(  const std::string& entityId,   const std::string& attribute,   const std::string &value )
           {
           mServerAdapter->adminTell(  entityId,   attribute,   value );
           }
          
          
          } // namespace Ember

./services/server/ServerService.h

       1  /*
           Copyright (  C ) 2002 Martin Pollard (  Xmp )
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef SERVERSERVICE_H
          #define SERVERSERVICE_H
          
          #include <framework/Service.h>
          #include <framework/ConsoleObject.h>
          
          #include <Atlas/Objects/RootOperation.h>
          #include <Eris/BaseConnection.h>
          
          #include <sigc++/object_slot.h>
          
          #include "IServerAdapter.h"
          
          namespace Eris
          {
      34   class Avatar;
      35   class Connection;
      36   class View;
      37   class Lobby;
      38   class Account;
          }
          
          namespace Ember {
          
      43   class OOGChat;
          
          /**
           * Ember Server Service
           *
           * @author Martin Pollard (  Xmp )
           *
           * @see Ember::Service
           * @see Ember::MetaserverService
           * @see Ember::ConsoleObject
           */
      54  class ServerService : public Service,   public ConsoleObject
          {
           //======================================================================
           // Private Variables
           //======================================================================
           private:
          
           /**
           * Holds our connection to the server
           */
      64   Eris::Connection *mConn;
          
           /**
           * Holds the player object we are connected with
           */
      69   Eris::Account *mAccount;
          
           /**
           * Holds the world object of this server
           */
      74   Eris::View *mView;
          
           /**
           * Holds the current avatar
           */
      79   Eris::Avatar *mAvatar;
          
           /**
           * Contains the class that controls Out of Game Chat
           */
      84   OOGChat *mOOGChat;
          
           /**
           * The host we are connected/ing to at present
           */
      89   std::string myHost;
          
           /**
           * The port we are using to connect
           */
      94   short myPort;
          
           /**
           * True if and only if we are successfully connected to the server
           */
      99   bool mConnected;
          
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           public:
          
           //HACK!!!
           //this is only for testing purposes
     109   Eris::Connection* getConnection(   ) { return mConn; }
          
           /** Creates a new ServerService using default values. */
     112   ServerService(   );
          
          
           /** Deletes a ServerService instance. */
     116   ~ServerService(   );
          
           //----------------------------------------------------------------------
           // Getters & Setters
     120   inline bool isConnected(   ) const;
          
           //----------------------------------------------------------------------
           // Methods
          
     125   Service::Status start(   );
          
     127   void stop(  int code );
          
     129   bool connect(  const std::string& host,   short port = 6767 );
          
     131   void reconnect(   );
          
     133   void disconnect(   );
          
     135   void takeCharacter(  const std::string &id );
          
     137   bool createCharacter(  const std::string& name,   const std::string& sex,   const std::string& type,   const std::string& description );
          
     139   void runCommand(  const std::string &,   const std::string & );
          
     141   inline Eris::View* getView(   );
          
           /**
           * Tells the server to try to move the user to the specified point.
           * @param dest
           */
     147   void moveToPoint(  const WFMath::Point<3>& dest );
           /**
           * Moves the user.
           * @param velocity The velocity with which to move the user.
           * @param orientation The user's orientation.
           */
     153   void moveInDirection(  const WFMath::Vector<3>& velocity,   const WFMath::Quaternion& orientation );
           /**
           * Moves the user.
           * @param velocity The velocity with which to move the user.
           */
     158   void moveInDirection(  const WFMath::Vector<3>& velocity );
           /**
           * Teleports the avatar to the specified location.
           * NOTE: This will only work if the user is logged in as admin.
           * @param dest The destination coords.
           * @param entity The location entity. In most cases this will be the world entity.
           */
          // void teleportTo(  const WFMath::Point<3>& dest,   Eris::Entity* entity );
           /**
           * Say something out loud.
           * @param message
           */
     170   void say(  const std::string &message );
           /**
           * Touch another entity.
           * @param entity
           */
     175   void touch(  Eris::Entity* entity );
          
           /**
           * Emotes something.
           * @param entity
           */
     181   void emote(  const std::string& emote );
     182   void drop(  Eris::Entity* entity,   const WFMath::Vector<3>& offset = WFMath::Vector<3>(  0,  0,  0 ) );
     183   void place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos = WFMath::Point<3>(  0,   0,   0 ) );
     184   void place(  Eris::Entity* entity,   Eris::Entity* target,   const WFMath::Point<3>& pos,   const WFMath::Quaternion& orient );
     185   void wield(  Eris::Entity* entity );
     186   void take(  Eris::Entity* entity );
     187   void use(  Eris::Entity* entity,   WFMath::Point<3> pos = WFMath::Point<3>(  0,  0,  0 ) );
     188   void useStop(   );
     189   void attack(  Eris::Entity* entity );
     190   void eat(  Eris::Entity* entity );
     191   void deleteEntity(  Eris::Entity* entity );
     192   void setAttributes(  Eris::Entity* entity,   Atlas::Message::MapType& attributes );
     193   void adminTell(  const std::string& entityId,   const std::string& attribute,   const std::string &value );
           //void use(  Eris::Entity* entity );
          
           //----------------------------------------------------------------------
           // Signals
     198   sigc::signal<void,   Eris::Avatar*> GotAvatar;
     199   sigc::signal<void,   Eris::View*> GotView;
     200   sigc::signal<void,   Eris::Connection*> GotConnection;
     201   sigc::signal<void,   Eris::Account*> GotAccount;
     202   sigc::signal<void,   Eris::Account *> LoginSuccess;
     203   sigc::signal<void,   Eris::Account *,   const std::string &> LoginFailure;
     204   sigc::signal<void,   const Atlas::Objects::Entity::RootEntity &> GotCharacterInfo;
     205   sigc::signal<void,   Eris::Account *> GotAllCharacters;
          
          
           //----------------------------------------------------------------------
           // Callbacks from Eris
           private:
          
           // Connection Callbacks
          
     214   void gotFailure(  const std::string& msg );
          
     216   void connected(   );
          
     218   bool disconnecting(   );
          
     220   void disconnected(   );
          
     222   void statusChanged(  Eris::BaseConnection::Status );
          
     224   void timeout(  Eris::BaseConnection::Status );
          
           // Account Callbacks
          
     228   void gotAvatarSuccess(  Eris::Avatar* avatar );
          
     230   void gotAvatarDeactivated(  Eris::Avatar* avatar );
          
     232   void gotCharacterInfo(  const Atlas::Objects::Entity::RootEntity & );
          
     234   void gotAllCharacters(   );
          
          // void loginFailure(  Eris::LoginFailureType,   const std::string & );
     237   void loginFailure(  const std::string & );
          
     239   void loginSuccess(   );
          
     241   void logoutComplete(  bool );
          
           // List of ServerService's console commands
          
     245   const Ember::ConsoleCommandWrapper Connect;
           //const Ember::ConsoleCommandWrapper ReConnect;
     247   const Ember::ConsoleCommandWrapper DisConnect;
     248   const Ember::ConsoleCommandWrapper CreateAcc;
     249   const Ember::ConsoleCommandWrapper Login;
     250   const Ember::ConsoleCommandWrapper Logout;
     251   const Ember::ConsoleCommandWrapper CreateChar;
     252   const Ember::ConsoleCommandWrapper TakeChar;
     253   const Ember::ConsoleCommandWrapper ListChars;
     254   const Ember::ConsoleCommandWrapper Say;
     255   const Ember::ConsoleCommandWrapper Emote;
     256   const Ember::ConsoleCommandWrapper Delete;
     257   const Ember::ConsoleCommandWrapper AdminTell;
          
     259   IServerAdapter* mServerAdapter;
          };
          
     262  bool ServerService::isConnected(   ) const
          {
           return mConnected;
          }
          
     267  inline Eris::View* ServerService::getView(   )
          {
           return mView;
          }
          
          
          } // namespace Ember
          
          #endif

./services/sound/SoundService.cpp

          /*
           Copyright (  C ) 2002 Miguel Guzman Miranda (  Aglanor )
           Code based on the Worldspace OpenAL tutorials by Lord Loki
           at http://worldspace.berlios.de/openal/
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifdef HAVE_CONFIG_H
          #include "config.h"
          #endif
          
          #ifdef __WIN32__
           #include <al.h>
           #include <alc.h>
           #include <AL/alut.h>
          #else
           #include <AL/al.h>
           #include <AL/alc.h>
           #include <AL/alut.h>
          #endif
          
          #include "framework/Service.h"
          #include "framework/ConsoleObject.h"
          
          #include "services/EmberServices.h"
          #include "services/config/ConfigService.h"
          #include "services/logging/LoggingService.h"
          #include "framework/ConsoleBackend.h"
          #include "framework/Tokeniser.h"
          
          /*
          #include <list>
          #include <algorithm>
          */
          #include <sstream>
          
          #include "SoundService.h"
          
          
          
          namespace Ember
          {
           // List of SoundService's console commands
      57   const char * const SoundService::PLAYSOUND = "playsound";
      58   const char * const SoundService::PLAYMUSIC = "playmusic";
      59   const char * const SoundService::PLAYFILE = "playfile";
      60   const char * const SoundService::PLAYSPEECH = "playspeech";
          
          
           /* ctor */
      64   SoundService::SoundService(   )
           {
           setName(  "Sound Service" );
           setDescription(  "Service for reproduction of sound effects and background music" );
           }
          
           /* dtor */
      71   SoundService::~SoundService(   )
           {
          
           }
          
           /* Method for starting this service */
      77   Service::Status SoundService::start(   )
           {
          
           S_LOG_INFO(  "Sound Service starting" );
          
           #ifndef WIN32
           // Test that /dev/dsp is availible
           FILE *temp = fopen(  "/dev/dsp",  "w" );
           if (  temp ) {
           fclose(  temp );
           } else {
           return Service::FAILURE;
           }
           #endif
          
           ALfloat listenerPos[3]={0.0,  0.0,  0.0}; // listener position
           ALfloat listenerVel[3]={0.0,  0.0,  0.0}; // listener velocity
           ALfloat listenerOri[6]={0.0,  0.0,  1.0,  0.0,  1.0,  0.0}; // listener orientation
           ALfloat sourcePos[3]={ 0.0,   10.0,   0.0}; // source position
           ALfloat sourceVel[3]={ 0.0,   0.0,   1.0}; // source velocity
          
           data=NULL;
          
           // Initialize OpenAL
           S_LOG_VERBOSE(  "Initializing OpenAL" );
          
           if(  !alutInit(  NULL,  0 ) ) {
           S_LOG_FAILURE(   "Error initiatin AL: " << alutGetErrorString(  alutGetError(   ) )  );
           return Service::FAILURE;
           } else {
           S_LOG_INFO(   "AL initiated"  );
           }
          
           // set listener initial parameters
           alListenerfv(  AL_POSITION,  listenerPos );
           alListenerfv(  AL_VELOCITY,  listenerVel );
           alListenerfv(  AL_ORIENTATION,  listenerOri );
          
           // Generate buffers
           S_LOG_VERBOSE(  "Generating Buffers" );
          
           alGenBuffers(  1,  &systemBuffer );
           if (  !alIsBuffer(  systemBuffer ) )
           {
           S_LOG_FAILURE(  "Error creating system buffer" );
           return Service::FAILURE;
           }
          
           alGenBuffers(  1,  &musicBuffer );
           if (  !alIsBuffer(  musicBuffer ) )
           {
           S_LOG_FAILURE(  "Error creating music buffer" );
           return Service::FAILURE;
           }
          
           alGenBuffers(  NUM_WORLD_BUFFERS,  worldBuffers );
           for (  int i=0;i<NUM_WORLD_BUFFERS;i++ )
           {
           if (  !alIsBuffer(  worldBuffers[i] ) )
           {
           S_LOG_FAILURE(   "Error creating world buffers"  );
           return Service::FAILURE;
           }
           }
          
          
           // Generate sources
          
           S_LOG_VERBOSE(  "Generating Sources" );
           alGenSources(  1,  &systemSource );
           if (  !alIsSource(  systemSource ) )
           {
           S_LOG_FAILURE(  "Error creating system source" );
           return Service::FAILURE;
           }
          
           alGenSources(  1,  &musicSource );
           if (  !alIsSource(  musicSource ) )
           {
           S_LOG_FAILURE(  "Error creating music source" );
           return Service::FAILURE;
           }
          
           alGenSources(  NUM_WORLD_SOURCES,  worldSources );
           for (  int i=0;i<NUM_WORLD_SOURCES;i++ )
           {
           if (  !alIsSource(  worldSources[i] ) )
           {
           S_LOG_FAILURE(  "Error creating world sources" )
           return Service::FAILURE;
           }
           }
          
           // Register service commands with the console
           S_LOG_VERBOSE(  "Registering Sound Service commands" );
           ConsoleBackend::getMainConsole(   )->registerCommand(  PLAYSOUND,  this );
           ConsoleBackend::getMainConsole(   )->registerCommand(  PLAYMUSIC,  this );
           ConsoleBackend::getMainConsole(   )->registerCommand(  PLAYFILE,  this );
           ConsoleBackend::getMainConsole(   )->registerCommand(  PLAYSPEECH,  this );
          
           // Service initialized successfully
           setRunning(   true  );
           setStatus(  Service::OK );
           setStatusText(  "Sound Service status OK." );
          
           S_LOG_INFO(  "Sound Service initialized" );
           return Service::OK;
          
           }
          
           /* Interface method for stopping this service */
     188   void SoundService::stop(  int code )
           {
           Service::stop(  code );
           alSourceStop(  worldSources[0] );
           alutExit(   ); // Finalize OpenAL
           setStatus(  Service::OK );
           }
          
     196   void SoundService::runCommand(  const std::string &command,   const std::string &args )
           {
           if(  command == PLAYSOUND )
           {
           playTestSound(   );
          
           }
           else if(  command == PLAYMUSIC )
           {
           // TODO: play test music here
           S_LOG_INFO(  getName(   ) << " I should be playing music" )
           }
           else if(  command == PLAYFILE )
           {
           playSystemSound(  "pig_grunt.wav" );
           }
           else if(  command == PLAYSPEECH )
           {
           // TODO: play test music here
           S_LOG_INFO(  getName(   ) << " I should be playing speech" )
           }
           }
          
     219   void SoundService::registerSoundProvider(  ISoundProvider* provider )
           {
           mProvider = provider;
           provider->_registerWithService(  this );
           S_LOG_INFO(  "Registered scripting provider " << provider->getName(   ) );
           }
          
     226   bool SoundService::LoadWAV(  const char *fname,  int buffer )
           {
           char* alName = new char[strlen(  fname )];
           strcpy(  alName,   fname );
          //#ifdef _WIN32 // Windows
          //
          // alutLoadWAVFile(  alName,  &format,  &data,  &size,  &freq,   &loop ); // Load WAV file
          // alBufferData(  buffer,  format,  data,  size,  freq ); // Connect WAV to buffer
          //
          //#endif
          //
          //#ifdef _LINUX // Linux
          //
          // alutLoadWAV(  alName,  &data,  &format,  &size,  &bits,  &freq ); // Load WAV file
          // alBufferData(  buffer,  format,  data,  size,  freq ); // Connect WAV to buffer
          // S_LOG_INFO(  "Loading WAV and stuff" )
          //
          //#endif
          
           delete[] alName;
           return true;
          
           }
          
     250   bool SoundService::UnloadWAV(  void )
           {
          
          #ifdef _WIN32 //Windows
          
           alutUnloadWAV(  format,  data,  size,  freq ); // Funtion that unloads the Wav file on windows
          
          #endif
          
          #ifdef _LINUX // Linux
          
           free (  data ); // Free the memory used when loading the WAV file
          
          #endif
          
           return true;
          
           }
          
     269   void SoundService::TestPlatform(  void )
           {
          
           S_LOG_INFO(  "Testing Platform" )
          
          #ifdef _WIN32 //Windows
          
           S_LOG_INFO(  "Windows Platform found" )
          
          #endif
          
          #ifdef _LINUX // Linux
          
           S_LOG_INFO(  "Linux Platform found" )
          
          #endif
          
          
           }
          /*
           void SoundService::playTestGYPH(  void ) {
           alSourcePlay(  worldSources[0] );
           int error = alGetError(   );
           if(  error != AL_NO_ERROR )
           {
           S_LOG_FAILURE(  "Error playing sound: " << error )
           }
           }
          */
     298   void SoundService::playTestGrunt(  void ) {
          
           std::stringstream gruntPath;
           gruntPath << soundsDirPath << "pig_grunt.wav";
           S_LOG_INFO(   "Loading sound: [" << gruntPath.str(   ) << "]"  )
           //alutLoadWAV(  gruntPath.str(   ).c_str(   ),  &data,  &format,  &size,  &bits,  &freq );
          
           // Connect WAV to buffer
           //alBufferData(  worldBuffers[1],  format,  data,  size,  freq );
          
           // Play
           //alSourcePlay(  worldSources[1] );
          
           // Check errors
           int error = alGetError(   );
           if(  error != AL_NO_ERROR )
           {
           char* errorStr = (  char* )alGetString(  error );
           //std::string errorStr = alGetString(  error );
           S_LOG_FAILURE(   "Error playing sound: " << errorStr  )
           }
           }
          
     321   void SoundService::updateListenerPosition(  
     322   const WFMath::Point<3>& position,  
     323   const WFMath::Quaternion& orientation ) {
          
           ALfloat listenerPosition[3]={position.x(   ),  position.y(   ),  position.z(   )};
           //ALfloat listenerOri[6]={0.0,  0.0,  1.0,  0.0,  1.0,  0.0};
          
           // set listener initial parameters
           alListenerfv(  AL_POSITION,  listenerPosition );
           //alListenerfv(  AL_ORIENTATION,  listenerOri );
          
           // update the System and Music Source,  
           // because they will always be with the listener
           // TODO: WRONG! do this with relative position (  0,  0,  0 ) to the listener
           //alSourcefv(  systemSource,  AL_POSITION,  listenerPosition );
           }
          
          /*
           void SoundService::updateSourcePosition(  
           const int sourceId,  
           const WFMath::Point<3>& position,  
           const WFMath::Quaternion& orientation ) {
          
           ALfloat sourcePosition[3]={position.x(   ),  position.y(   ),  position.z(   )};
           //ALfloat listenerOri[6]={0.0,  0.0,  1.0,  0.0,  1.0,  0.0};
          
           // set listener initial parameters
           alSourcefv(  AL_POSITION,  sourcePosition );
           //alListenerfv(  AL_ORIENTATION,  listenerOri );
           }
          */
          
     353   void SoundService::updateAvatarSourcePosition(  
     354   const WFMath::Point<3>& position,  
     355   const WFMath::Quaternion& orientation ) {
          
           ALfloat avatarSourcePosition[3]={position.x(   ),  position.y(   ),  position.z(   )};
           //ALfloat listenerOri[6]={0.0,  0.0,  1.0,  0.0,  1.0,  0.0};
          
           alSourcefv(  avatarSource,  AL_POSITION,  avatarSourcePosition );
           //alListenerfv(  AL_ORIENTATION,  listenerOri );
           }
          
     364   void SoundService::playTestSound(   ) {
           systemBuffer = alutCreateBufferHelloWorld(   );
           alSourcei(  systemSource,   AL_BUFFER,   systemBuffer );
           alSourcePlay(  systemSource );
           }
          
     370   void SoundService::playAvatarSound(   ) {
           avatarBuffer = alutCreateBufferHelloWorld(   );
           alSourcei(  avatarSource,   AL_BUFFER,   avatarBuffer );
           alSourcePlay(  avatarSource );
           }
          
     376   void SoundService::playTalk(  std::string message,  
     377   const WFMath::Point<3>& position,  
     378   const WFMath::Quaternion& orientation ) {
          
           S_LOG_INFO(   "Playing talk: " << message  );
          
           // determine the source and buffer that will play the sound
           int i = getWorldSourceIndexForPlaying(  0 );
           ALuint worldSource = worldSources[i];
           ALuint worldBuffer = worldBuffers[i];
          
           // adjust position
           // TODO: adjust orientation
           ALfloat worldSourcePosition[3]={position.x(   ),  position.y(   ),  position.z(   )};
           alSourcefv(  worldSource,  AL_POSITION,  worldSourcePosition );
          
           worldBuffer = alutCreateBufferHelloWorld(   );
           alSourcei(  worldSource,   AL_BUFFER,   worldBuffer );
           alSourcePlay(  worldSource );
           }
          
     397   void SoundService::playSystemSound(  std::string soundName ) {
          
           // load the sound through the sound provider
           mProvider->loadSound(  soundName );
          
           // play sound
          
           /*
           Ogre::FileInfoListPtr files =
           Ogre::ResourceGroupManager::getSingleton(   ).findResourceFileInfo(  
           "General",   "pig_grunt.wav" );
          
           Ogre::String filePath;
           for(  Ogre::FileInfoList::iterator it=files->begin(   ); it!=files->end(   ); ++it  )
           {
           filePath = (  *it ).path;
           //filePath.append(  (  *it ).filename );
           S_LOG_INFO(   "Found a filepath: " << filePath );
           }
           // TODO: this plays the last one found. Should play the first one found
           // TODO: check error if it finds none
          
           systemBuffer = alutCreateBufferFromFile(  filePath.c_str(   ) );
           if(  systemBuffer == AL_NONE )
           {
           S_LOG_FAILURE(  alutGetErrorString(  alutGetError(   ) ) );
           } else
           {
           S_LOG_INFO(  "TRACE - BUFFER LOADED" );
           }
           alSourcei(  systemSource,   AL_BUFFER,   systemBuffer );
          
           alSourcePlay(  systemSource );
           */
           }
          
     433   ALuint SoundService::getWorldSourceIndexForPlaying(  int priority ) {
           return 0;
           }
          
          } // namespace Ember

./services/sound/SoundService.h

       1  /*
           Copyright (  C ) 2002 Miguel Guzman Miranda (  Aglanor )
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef SOUNDSERVICE_H
          #define SOUNDSERVICE_H
          
          #define NUM_WORLD_SOURCES 16
          #define NUM_WORLD_BUFFERS 16
          
          
      26  class Service;
      27  class ISoundProvider;
          
          #include "framework/ConsoleObject.h"
          #include "framework/ISoundProvider.h"
          
          //#include <AL/altypes.h>
          //Might need a proper preprocessor to handle different versions
          #include<AL/al.h>
          
          #include <wfmath/point.h>
          #include <wfmath/vector.h>
          #include <wfmath/quaternion.h>
          
          namespace Ember {
          
          /**
           * Ember Sound Service
           *
           * @author Miguel Guzman Miranda (  Aglanor )
           *
           * @see Ember::Service
           * @see Ember::ConsoleObject
           */
      50  class SoundService: public Service,   public ConsoleObject
          {
          
      53  friend class IScriptingProvider;
          
           //======================================================================
           // Private Variables
           //======================================================================
           private:
          
           //ALCdevice *device; // device for the Audio Layer Context
           //this should be a void* if it is enabled again. It is not currently used
          
          
          
           /** System source - this source will play system sounds,  
           like user input request or program error.
           Will always remain in the same relative position to the listener. */
      68   ALuint systemSource;
           /** System buffer - buffer used to load system sounds files */
      70   ALuint systemBuffer;
           /** Music source - this source will play background music.
           Will always remain in the same relative position to the listener. */
      73   ALuint musicSource;
           /** Music buffer - buffer used to load background music files */
      75   ALuint musicBuffer;
           /** Avatar source - this source will play avatar sounds,  
           which are more important than the same sounds for other entities
           Example: avatar footsteps vs other people's footsteps
           */
      80   ALuint avatarSource;
           /** Avatar buffer - buffer used to load avatar sounds files */
      82   ALuint avatarBuffer;
           /** World sources - array of sources to play world sounds.
           They will be placed in 3D space.
           This field may change depending on the data model */
      86   ALuint worldSources[NUM_WORLD_SOURCES];
           /** Wold buffers - array of buffers for loading world sounds */
      88   ALuint worldBuffers[NUM_WORLD_BUFFERS];
          
      90   ALuint getWorldSourceIndexForPlaying(  int priority );
          
      92   std::string soundsDirPath;
          
          #ifdef _WIN32
           unsigned int size,   freq;
          #else
           int size,   freq;
          #endif
           int bits,  format;
           void *data;
           char loop;
          
           /**
           The Sound Provider
           */
     106   ISoundProvider* mProvider;
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           public:
          
           /** Creates a new SoundService using default values. */
     114   SoundService(   );
          
          
           /** Deletes a SoundService instance. */
     118   ~SoundService(   );
          
           //----------------------------------------------------------------------
           // Getters & Setters
          
           //----------------------------------------------------------------------
           // Methods
          
     126   Service::Status start(   );
          
     128   void stop(  int code );
          
     130   void runCommand(  const std::string &command,   const std::string &args );
          
           /**
           * Registers a new sound provider.
           * @param provider
           */
     136   void registerSoundProvider(  ISoundProvider* provider );
          
     138   bool LoadWAV(  const char *fname,  int buffer );
          
     140   bool UnloadWAV(  void );
          
     142   void TestPlatform(  void );
          
           //void playTestGYPH(  void );
     145   void playTestGrunt(  void );
          
     147   void updateListenerPosition(  
     148   const WFMath::Point<3>& position,  
     149   const WFMath::Quaternion& orientation );
          
           /*
           void SoundService::updateSourcePosition(  
           const WFMath::Point<3>& position,  
           const WFMath::Quaternion& orientation );
           */
          
     157   void updateAvatarSourcePosition(  
     158   const WFMath::Point<3>& position,  
     159   const WFMath::Quaternion& orientation );
          
     161   void playTestSound(   );
     162   void playAvatarSound(   );
     163   void playTalk(  std::string message,  
     164   const WFMath::Point<3>& position,  
     165   const WFMath::Quaternion& orientation );
     166   void playSystemSound(  std::string soundFileName );
          
           // List of SoundService's console commands
           static const char * const PLAYSOUND;
           static const char * const PLAYMUSIC;
           static const char * const PLAYFILE;
           static const char * const PLAYSPEECH;
          
          }; //SoundService
          
          } // namespace Ember
          
          #endif

./services/test/TestService.cpp

       1  #include "TestService.h"
          
          #include <iostream>
          
          namespace dime
          {
          
           /* ctor */
       9   TestService::TestService(   )
           {
           myTestMessage = "Hello WorldForge !!!";
           //setDescription(  "I am a simple test service" );
           // setActive = 0; // inactive
           //setStatus(  Service::OK ); // stopped
          
           setName(  "Test Service" );
           setDescription(  "Basic test service for testing and debugging." );
          // TODO(  zzorn,   2002-01-19 ): Set the status of the service to OK.
          // setStatus(   Service::OK  );
          
          
           }
          
           /* Method for starting the test service */
      25   Service::Status TestService::start(   )
           {
           std::cout << "I'm the Test Service Starting" << std::endl;
           setStatus(  Service::OK );
           setRunning(   true  );
           return Service::OK;
           }
          
           /* Interface method for stopping the test service */
      34   void TestService::stop(  int code )
           {
           std::cout << "I'm the Test Service Stopping" << std::endl;
           //setStatus(  code );
           //setActive(  0 );
           setRunning(   false  );
           }
          
          } // namespace dime

./services/test/TestService.h

       1  /*
           Copyright (  C ) 2002 Miguel Guzman Miranda [Aglanor]
          
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License,   or
           (  at your option ) any later version.
          
           This program is distributed in the hope that it will be useful,  
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
           GNU General Public License for more details.
          
           You should have received a copy of the GNU General Public License
           along with this program; if not,   write to the Free Software
           Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.
          */
          
          #ifndef TESTSERVICE_H
          #define TESTSERVICE_H
          
          #include <framework/Service.h>
          #include <string>
          
          namespace dime {
          
          /**
           * Basic test service for testing and debugging.
           *
           * @author Miguel Guzman Miranda [Aglanor]
           *
           * @see dime::framework::Service
           * @see dime::framework::AbstractService
           */
      35  class TestService : public Service
          {
           //======================================================================
           // Private Variables
           //======================================================================
           private:
      41   std::string myTestMessage;
           int myTestNumber;
          
          
           //----------------------------------------------------------------------
           // Constructors & Destructor
          
           public:
          
           /** Creates a new TestService using default values. */
      51   TestService(   );
          
          
           /** Deletes a Service instance. */
      55   ~TestService(   )
           {
           }
          
          
           //----------------------------------------------------------------------
           // Getters & Setters
          
           //----------------------------------------------------------------------
           // Methods
          
      66   Service::Status start(   );
          
      68   void stop(  int code ) ;
          
          }; // TestService
          
          } // namespace dime
          
          #endif
          
          

./services/time/TimeService.cpp

       1  //
          // C++ Implementation: TimeService
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "TimeService.h"
          
          namespace Ember {
          
          namespace Services {
          
      29  TimeService::TimeService(   )
          {
          }
          
          
      34  TimeService::~TimeService(   )
          {
          }
          
          
          }
          
          }

./services/time/TimeService.h

       1  //
          // C++ Interface: TimeService
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2006
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBER_SERVICESTIMESERVICE_H
          #define EMBER_SERVICESTIMESERVICE_H
          
          #include "framework/Service.h"
          #include <sigc++/object.h>
          
          
          namespace Ember {
          
          namespace Services {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          
           Provides time services.
          */
      39  class TimeService : public Service
          {
          public:
      42   TimeService(   );
          
      44   virtual ~TimeService(   );
          
          // int getHours(   );
          // int getMinutes(   );
          // int getSeconds(   );
          
          };
          
          }
          
          }
          
          #endif

./services/wfut/WfutService.cpp

       1  //
          // C++ Implementation: WfutService
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          // Simon Goodall,   (  C ) 2005 - 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "WfutService.h"
          #include "WfutSession.h"
          
          #include "services/logging/LoggingService.h"
          
          using namespace WFUT;
          
          namespace Ember {
          
          
          
      35  WfutService::WfutService(   )
          {
           mDownloadCompleteSlot = sigc::mem_fun(  this,   &WfutService::wfutSession_DownloadComplete );
           mDownloadFailureSlot = sigc::mem_fun(  this,   &WfutService::wfutSession_DownloadFailed );
           mServerListDownloadingSlot = sigc::mem_fun(  this,   &WfutService::wfutSession_ServerListDownloading );
           mUpdatesCalculatedSlot = sigc::mem_fun(  this,   &WfutService::wfutSession_UpdatesCalculated );
          
           mSession = std::auto_ptr<WfutSession>(  new WfutSession(  mDownloadCompleteSlot,   mDownloadFailureSlot,   mServerListDownloadingSlot,   mUpdatesCalculatedSlot ) );
          }
          
          
      46  WfutService::~WfutService(   )
          {
          }
          
      50  Service::Status WfutService::start(   )
          {
           mSession->init(   );
           return Service::OK;
          }
          
          // void WfutService::stop(  int code )
          // {
          // Service::stop(  code );
          // }
          
      61  void WfutService::startUpdate(  const std::string &serverRoot,  
      62  const std::string &channelName,  
      63  const std::string &localPath,  
      64  const std::string &systemPath
           )
          {
           mSession->startUpdate(  serverRoot,   channelName,   localPath,   systemPath );
          
          }
          
      71  int WfutService::poll(   )
          {
           int result = mSession->poll(   );
           if (  !result ) {
           AllDownloadsComplete.emit(   );
           }
           return result;
          }
          
      80  void WfutService::wfutSession_DownloadComplete(  const std::string &url,   const std::string &filename )
          {
           S_LOG_INFO(  "Wfut download of " << filename << " from " << url <<" complete." );
           DownloadComplete.emit(  url,   filename );
          }
          
      86  void WfutService::wfutSession_DownloadFailed(  const std::string &url,   const std::string &filename,   const std::string &reason )
          {
           S_LOG_WARNING(  "Wfut download of " << filename << " from " << url <<" failed with reason " << reason << "." );
           DownloadFailed.emit(  url,   filename,   reason );
          }
          
      92  void WfutService::wfutSession_ServerListDownloading(  const std::string &url )
          {
           S_LOG_INFO(  "Wfut downloading of server list from " << url <<"." );
           DownloadingServerList.emit(  url );
          }
          
      98  void WfutService::wfutSession_UpdatesCalculated(  size_t numberOfFilesToUpdate )
          {
           S_LOG_INFO(  "Wfut needs to download " << numberOfFilesToUpdate <<" updates." );
           UpdatesCalculated.emit(  numberOfFilesToUpdate );
          }
          
          }

./services/wfut/WfutService.h

       1  //
          // C++ Interface: WfutService
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          // Simon Goodall,   (  C ) 2005 - 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBERWFUTSERVICE_H
          #define EMBERWFUTSERVICE_H
          
          #include "framework/Service.h"
          #include <sigc++/object.h>
          #include <sigc++/signal.h>
          
          namespace Ember {
          
          
      34  class WfutSession;
          
          /**
           Provides abilities to update media through the WFUT tool.
          
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      41  class WfutService : public Service
          {
          public:
      44   WfutService(   );
          
      46   virtual ~WfutService(   );
          
      48   virtual Service::Status start(   );
          
          
      51   void startUpdate(  const std::string &serverRoot,  
      52   const std::string &channelName,  
      53   const std::string &localPath,  
      54   const std::string &systemPath );
          
           /** The poll function is used to perform a chunk of downloading. This means
           * that it needs to be called frequently. It returns the number of files still
           * being downloaded. It will return 0 when all files have finished
           * downloading.
           */
      61   int poll(   );
          
           /** The DownloadComplete signal is fired every time a file is successfully
           * downloaded. The first argument is the source url and the second argument
           * is the filename from the FileObject.
           */
      67   sigc::signal<void,   const std::string&,   const std::string&> DownloadComplete;
          
           /** The DownloadFailed signal is fired when there was a problem downloading
           * a file. This could happen due to a broken url,   or a problem saving the
           * file in the temp location,   or copying it from the tmp location to the
           * destination. The first argument is the source url and the second argument
           * is the filename from the FileObject. The third argument is a message
           * indicating a general reason why the download failed.
           */
      76   sigc::signal<void,   const std::string&,   const std::string&,   const std::string&> DownloadFailed;
          
           /** The AllDownloadsComplete is emitted when all files have been downloaded.
           */
      80   sigc::signal<void> AllDownloadsComplete;
          
           /**
           The DownloadingServerList is emitted when the file list (  most often wfut.xml ) is being downloaded from the server.
           @param the path to the file
           */
      86   sigc::signal<void,   const std::string&> DownloadingServerList;
          
           /**
           The UpdatesCalculated is emitted when all local files and server side files have been calculated,   and a list of those that needs updates have been put together.
           @param the number of files to update
           */
      92   sigc::signal<void,   size_t> UpdatesCalculated;
          
          protected:
      95   std::auto_ptr<WfutSession> mSession;
          
      97   void wfutSession_DownloadComplete(  const std::string &url,   const std::string &filename );
      98   void wfutSession_DownloadFailed(  const std::string &url,   const std::string &filename,   const std::string &reason );
      99   void wfutSession_ServerListDownloading(  const std::string &url );
     100   void wfutSession_UpdatesCalculated(  size_t numberOfFilesToUpdate );
     101   sigc::slot<void,   const std::string&,   const std::string&> mDownloadCompleteSlot;
     102   sigc::slot<void,   const std::string&,   const std::string&,   const std::string&> mDownloadFailureSlot;
     103   sigc::slot<void,   const std::string&> mServerListDownloadingSlot;
     104   sigc::slot<void,   size_t> mUpdatesCalculatedSlot;
          };
          
          }
          
          #endif

./services/wfut/WfutSession.cpp

       1  //
          // C++ Implementation: WfutSession
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #include "WfutSession.h"
          #include <fstream>
          #include "../logging/LoggingService.h"
          
          using namespace WFUT;
          
          namespace Ember {
          
      31  static bool fileExists(  const std::string& fileName )
          {
           std::fstream fin;
           fin.open(  fileName.c_str(   ),  std::ios::in );
           if(   fin.is_open(   )  )
           {
           fin.close(   );
           return true;
           }
           fin.close(   );
           return false;
          }
          
          
      45  WfutSession::WfutSession(  sigc::slot<void,   const std::string&,   const std::string&>& downloadCompleteSlot
      46  ,   sigc::slot<void,   const std::string&,   const std::string&,   const std::string&>& downloadFailedSlot
      47  ,   sigc::slot<void,   const std::string&>& serverListDownloadingSlot
      48  ,   sigc::slot<void,   size_t>& updatesCalculatedSlot
           )
          : mServerListDownloadingSlot(  serverListDownloadingSlot )
          ,   mUpdatesCalculatedSlot(  updatesCalculatedSlot )
          {
           mWfutClient.DownloadComplete.connect(  downloadCompleteSlot );
           mWfutClient.DownloadFailed.connect(  downloadFailedSlot );
          }
          
          
      58  WfutSession::~WfutSession(   )
          {
           mWfutClient.shutdown(   );
          }
          
      63  void WfutSession::init(   )
          {
           mWfutClient.init(   );
          }
          
      68  void WfutSession::startUpdate(  const std::string &serverRoot,  
      69  const std::string &channelName,  
      70  const std::string &localPath,  
      71  const std::string &systemPath
           )
          {
          
           S_LOG_VERBOSE(  "Channel name: " << channelName );
           /// This is the base path for all files that will be downloaded
           const std::string &local_root = localPath + "/" + channelName + "/";
          
           std::string channel(  channelName );
           std::string channel_file = "wfut.xml";
           std::string tmpfile = "tempwfut.xml";
          
           /// Look for mLocal mWfutClient file.
           mLocalWfut = std::string(  localPath + "/" + channelName + "/" + channel_file );
           S_LOG_VERBOSE(  "Local wfut: " << mLocalWfut );
           if (  fileExists(  mLocalWfut ) ) {
           if (  mWfutClient.getLocalList(  mLocalWfut,   mLocal ) ) {
           S_LOG_WARNING(  "Error reading local wfut.xml file." );
           }
           }
          
           /// Look for tmpwfut file. If it exists,   update the mLocal files list.
           const std::string &tmp_wfut = localPath + "/" + tmpfile;
           S_LOG_VERBOSE(  "Tmp wfut: " << tmp_wfut );
          
           if (  fileExists(  tmp_wfut ) ) {
           if (  mWfutClient.getLocalList(  tmp_wfut,   mTmplist ) ) {
           S_LOG_WARNING(  "Error reading local tmpwfut.xml file." );
           } else {
           const FileMap &fm = mTmplist.getFiles(   );
           FileMap::const_iterator I = fm.begin(   );
           FileMap::const_iterator Iend = fm.end(   );
           for (  ; I != Iend; ++I ) {
           mLocal.addFile(  I->second );
           }
           }
           }
          
          
           /// Look for a mSystem mWfutClient file
           if (  !systemPath.empty(   ) ) {
           const std::string &system_wfut = systemPath + "/" + channel + "/" + channel_file;
           S_LOG_VERBOSE(  "System wfut: " << system_wfut );
          
           if (  fileExists(  system_wfut ) ) {
           if (  mWfutClient.getLocalList(  system_wfut,   mSystem ) ) {
           S_LOG_WARNING(  "Error reading system wfut.xml file." );
           }
           }
           }
          
           /// By now we should have a proper channel name. If not,   then there is nothing
           /// we can do to find the mServer mUpdates.
           if (  channel.empty(   ) || channel == "." ) {
           S_LOG_WARNING(  "Unable to determine channel name." );
           return;
           }
          
           const std::string &server_wfut = serverRoot + "/" + channel + "/" + channel_file;
           S_LOG_VERBOSE(  "Server wfut: " << server_wfut );
          
           mServerListDownloadingSlot(  server_wfut );
           if (  mWfutClient.getFileList(  server_wfut,   mServer ) ) {
           S_LOG_WARNING(  "Error downloading server channel file." );
           return;
           }
          
           S_LOG_VERBOSE(  "Local Root: " << local_root );
          
           S_LOG_INFO(  "Updating Channel: " << channel );
          
           /// Now we have loaded all our data files,   lets find out what we really need
           /// to download
           if (  mWfutClient.calculateUpdates(  mServer,   mSystem,   mLocal,   mUpdates,   local_root ) ) {
           S_LOG_WARNING(  "Error determining file to update." );
           return;
           }
          
           mUpdatesCalculatedSlot(  mUpdates.getFiles(   ).size(   ) );
          
           /// Make sure the mLocal file has the correct channel name
           mLocal.setName(  mServer.getName(   ) );
          
           /// Queue the list of files to download
           mWfutClient.updateChannel(  mUpdates,   serverRoot + "/" + channel,   local_root );
          
          }
          
     159  int WfutSession::poll(   )
          {
           int result = mWfutClient.poll(   );
           if (  !result ) {
           /// Save the completed download list
           mWfutClient.saveLocalList(  mServer,   mLocalWfut );
           }
           return result;
          }
          
          
          }

./services/wfut/WfutSession.h

       1  //
          // C++ Interface: WfutSession
          //
          // Description:
          //
          //
          // Author: Erik Hjortsberg <erik@katastrof.nu>,   (  C ) 2007
          //
          // This program is free software; you can redistribute it and/or modify
          // it under the terms of the GNU General Public License as published by
          // the Free Software Foundation; either version 2 of the License,   or
          // (  at your option ) any later version.
          //
          // This program is distributed in the hope that it will be useful,  
          // but WITHOUT ANY WARRANTY; without even the implied warranty of
          // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
          // GNU General Public License for more details.
          //
          // You should have received a copy of the GNU General Public License
          // along with this program; if not,   write to the Free Software
          // Foundation,   Inc.,   675 Mass Ave,   Cambridge,   MA 02139,   USA.//
          //
          #ifndef EMBEROGREWFUTSESSION_H
          #define EMBEROGREWFUTSESSION_H
          
          #include <libwfut/WFUT.h>
          #include <sigc++/object.h>
          
          namespace Ember {
          
          /**
           @author Erik Hjortsberg <erik@katastrof.nu>
          */
      34  class WfutSession : public sigc::trackable
          {
          public:
      37   WfutSession(  sigc::slot<void,   const std::string&,   const std::string&>& downloadCompleteSlot
      38   ,   sigc::slot<void,   const std::string&,   const std::string&,   const std::string&>& downloadFailedSlot
      39   ,   sigc::slot<void,   const std::string&>& serverListDownloadingSlot
      40   ,   sigc::slot<void,   size_t>& updatesCalculatedSlot );
          
      42   virtual ~WfutSession(   );
          
      44   void init(   );
          
      46   int poll(   );
          
      48   void startUpdate(  const std::string &serverRoot,  
      49   const std::string &channelName,  
      50   const std::string &localPath,  
      51   const std::string &systemPath
            );
          private:
      54   WFUT::ChannelFileList mLocal,   mSystem,   mServer,   mUpdates,   mTmplist;
      55   WFUT::WFUTClient mWfutClient;
      56   std::string mLocalWfut;
      57   sigc::slot<void,   const std::string&>& mServerListDownloadingSlot;
      58   sigc::slot<void,   size_t>& mUpdatesCalculatedSlot;
          };
          
          }
          
          #endif